diff --git a/packages/api-derive/src/balances/all.ts b/packages/api-derive/src/balances/all.ts index 308d42f198..f28cb7d52d 100644 --- a/packages/api-derive/src/balances/all.ts +++ b/packages/api-derive/src/balances/all.ts @@ -44,11 +44,11 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan if (Array.isArray(locks)) { // only get the locks that are valid until passed the current block lockedBreakdown = (locks as BalanceLockTo212[]).filter(({ until }): boolean => !until || (bestNumber && until.gt(bestNumber))); - allLocked = lockedBreakdown.some(({ amount }) => amount.isMax()); + allLocked = lockedBreakdown.some(({ amount }) => amount && amount.isMax()); vestingLocked = api.registry.createType('Balance', lockedBreakdown.filter(({ id }) => id.eq(VESTING_ID)).reduce((result: BN, { amount }) => result.iadd(amount), new BN(0))); // get the maximum of the locks according to https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L699 - const notAll = lockedBreakdown.filter(({ amount }) => !amount.isMax()); + const notAll = lockedBreakdown.filter(({ amount }) => amount && !amount.isMax()); if (notAll.length) { lockedBalance = api.registry.createType('Balance', bnMax(...notAll.map(({ amount }): Balance => amount))); diff --git a/packages/api-derive/src/staking/stakerRewards.ts b/packages/api-derive/src/staking/stakerRewards.ts index 715d934c00..930f6091b8 100644 --- a/packages/api-derive/src/staking/stakerRewards.ts +++ b/packages/api-derive/src/staking/stakerRewards.ts @@ -28,7 +28,7 @@ function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [erasPoints, era Object.entries(eraValidators).forEach(([validatorId, exposure]): void => { const valPoints = allValPoints[validatorId] || BN_ZERO; const valComm = allValPrefs[validatorId]?.commission.unwrap() || BN_ZERO; - const expTotal = exposure.total.unwrap(); + const expTotal = exposure.total?.unwrap() || BN_ZERO; let avail = BN_ZERO; let value: BN | undefined;