From 168b12d98f1bbe41f67e363e12478fe468e90318 Mon Sep 17 00:00:00 2001 From: kwingram25 Date: Thu, 9 May 2019 20:13:31 +0200 Subject: [PATCH] Check array before running bnMax (#893) * Updated with derive.balances.all * add new keys to votingBalance * remove multi test * vestedBalance > 0 * bestNumber bug * Check balances.all > 0 * Check balances.all > 0 * Check balances.all > 0 * check locks array * check locks array --- packages/api-derive/src/balances/all.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api-derive/src/balances/all.ts b/packages/api-derive/src/balances/all.ts index 26af330080..fc47f1ca19 100644 --- a/packages/api-derive/src/balances/all.ts +++ b/packages/api-derive/src/balances/all.ts @@ -37,7 +37,7 @@ export function all (api: ApiInterface$Rx) { // only get the locks that are valid until passed the current block const totals = locks.filter((value) => bestNumber && value.until.gt(bestNumber)); // get the maximum of the locks according to https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L699 - lockedBalance = bnMax(...totals.map(({ amount }) => amount)) as Balance; + lockedBalance = totals[0] ? bnMax(...totals.map(({ amount }) => amount)) as Balance : new Balance(0); } const { offset, perBlock } = vesting.unwrapOr({