import { FixedPointNumber , Token } from '@acala-network/sdk-core' ; import { AcalaStakingLedge } from '@acala-network/types/interfaces' ; import { StorageKey , u16 , Option } from '@polkadot/types' ; import { StakingLedger } from '../types' ; export function transformStakingLedger ( data , stakingToken ) { return data . map ( ( item ) => { const key = item [ 0 ] ; const ledge = item [ 1 ] . unwrapOrDefault ( ) ; return { index : key . args [ 0 ] . toNumber ( ) , bonded : FixedPointNumber . fromInner ( ledge . bonded . unwrap ( ) . toString ( ) , stakingToken . decimals ) , unlocking : ledge . unlocking . map ( ( item ) => { return { value : FixedPointNumber . fromInner ( item . value . unwrap ( ) . toString ( ) , stakingToken . decimals ) , era : item . era . unwrap ( ) . toNumber ( ) } ; } ) } ; } ) ; }