Fix TracksInfo values being undefined and causing a whitescreen (#11320)

* Fix TracksInfo values being undefined and causing a whitescreen

* lint
This commit is contained in:
Tarik Gul 2025-02-22 05:30:59 -08:00 committed by GitHub
parent 7d872912b2
commit 894c2f90dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,12 +8,15 @@ import type { PalletReferenda, TrackDescription } from './types.js';
import { useMemo } from 'react';
import { createNamedHook, useApi } from '@polkadot/react-hooks';
import { BN_ZERO } from '@polkadot/util';
import { calcCurves } from './util.js';
const zeroGraph = { approval: [BN_ZERO], support: [BN_ZERO], x: [BN_ZERO] };
function expandTracks (tracks: [BN, PalletReferendaTrackInfo][]): TrackDescription[] {
return tracks.map(([id, info]) => ({
graph: calcCurves(info),
graph: info.decisionDeposit && info.minApproval && info.minSupport ? calcCurves(info) : zeroGraph,
id,
info
}));