import { DeriveStakingAccount } from '@polkadot/api-derive/types' ; import BN from 'bn.js' ; export function calcBonded ( stakingInfo ? , bonded ? ) { let other = [ ] ; let own = new BN ( 0 ) ; if ( Array . isArray ( bonded ) ) { other = bonded . filter ( ( _ , index ) : boolean => index !== 0 ) . filter ( ( value ) : boolean => value . gtn ( 0 ) ) ; own = bonded [ 0 ] ; } else if ( stakingInfo && stakingInfo . stakingLedger && stakingInfo . accountId . eq ( stakingInfo . stashId ) ) { own = stakingInfo . stakingLedger . active . unwrap ( ) ; } return [ own , other ] ; }