import { u128 } from 'as-bignum' ; import { BytesReader , CompactInt , UInt128 , UInt64 } from 'as-scale-codec' ; import { AccountData , AccountId , Utils } from 'subsembly-core' ; export type Balance = UInt128 ; description param freeBalance export function getAccountDataBytes ( freeBalance ) { const balance = BytesReader . decodeInto < Balance > ( Utils . toU8Array ( freeBalance ) ) ; const accData = new AccountData < Balance > ( balance , instantiate < Balance > ( u128 . Zero ) , instantiate < Balance > ( u128 . Zero ) , instantiate < Balance > ( u128 . Zero ) ) ; return accData . toU8a ( ) ; } description param authorities export function getAccountIdBytes ( authorities ) { let input = Utils . toU8Array ( authorities ) ; let auths = [ ] ; let bytesReader = new BytesReader ( input ) ; let counter = 0 ; while ( bytesReader . getLeftoverBytes ( ) . length != 0 ) { let accId = bytesReader . readInto < AccountId > ( ) ; auths = auths . concat ( accId . getAddress ( ) ) ; counter += 1 ; } let result = [ ] ; const length = new CompactInt ( counter ) ; return result . concat ( length . toU8a ( ) ) . concat ( auths ) ; } description param str param scale export function stringToU8a ( str , scale ) { return Utils . stringsToBytes ( [ str ] , scale ) ; } export const UInt8Array_ID = idof < Uint8Array > ( ) ;