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
This commit is contained in:
kwingram25
2019-06-12 16:45:45 +12:00
committed by Ian He
parent be617df21f
commit afcc7fb701
+1 -1
View File
@@ -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({