From 39632927e0a1b6a654d98ef7ca77ad7b53810d6c Mon Sep 17 00:00:00 2001 From: sander2 Date: Sat, 14 Jan 2023 10:55:28 +0100 Subject: [PATCH] fix: add account derive (#8683) --- packages/apps-config/src/api/spec/interbtc.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/apps-config/src/api/spec/interbtc.ts b/packages/apps-config/src/api/spec/interbtc.ts index b95c1fcc15..562e1975e7 100644 --- a/packages/apps-config/src/api/spec/interbtc.ts +++ b/packages/apps-config/src/api/spec/interbtc.ts @@ -14,6 +14,7 @@ import { DeriveBalancesAll } from '@polkadot/api-derive/types'; import { memo } from '@polkadot/api-derive/util'; import { TypeRegistry, U128 } from '@polkadot/types'; import { Balance } from '@polkadot/types/interfaces'; +import { FrameSystemAccountInfo } from '@polkadot/types/lookup'; import { BN, formatBalance } from '@polkadot/util'; function balanceOf (number: number | string): U128 { @@ -49,11 +50,12 @@ export function getBalance ( return memo( instanceId, (account: string): Observable => - combineLatest<[any]>([api.query.tokens.accounts(account, { Token: nativeToken })]).pipe( - map(([data]: [OrmlAccountData]): DeriveBalancesAll => { + combineLatest<[any, any]>([api.query.tokens.accounts(account, { Token: nativeToken }), api.query.system.account(account)]).pipe( + map(([data, systemAccount]: [OrmlAccountData, FrameSystemAccountInfo]): DeriveBalancesAll => { return { ...defaultAccountBalance(), accountId: api.registry.createType('AccountId', account), + accountNonce: systemAccount.nonce, availableBalance: api.registry.createType('Balance', data.free.sub(data.frozen)), freeBalance: data.free, lockedBalance: data.frozen, @@ -67,6 +69,7 @@ export function getBalance ( const definitions: OverrideBundleDefinition = { derives: { balances: { + account: getBalance, all: getBalance } },