diff --git a/packages/apps-config/src/api/spec/interbtc.ts b/packages/apps-config/src/api/spec/interbtc.ts index c07cf7836e33..6a75c9eca21f 100644 --- a/packages/apps-config/src/api/spec/interbtc.ts +++ b/packages/apps-config/src/api/spec/interbtc.ts @@ -3,13 +3,13 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */ -import type { Observable } from 'rxjs'; -import type { ApiInterfaceRx } from '@polkadot/api/types'; +import type { ApiInterfaceRx, SubmittableExtrinsic } from '@polkadot/api/types'; import type { OverrideBundleDefinition } from '@polkadot/types/types'; import interbtc from '@interlay/interbtc-types'; -import { combineLatest, map } from 'rxjs'; +import { combineLatest, map, Observable } from 'rxjs'; +import { ApiPromise } from '@polkadot/api'; import { DeriveBalancesAll } from '@polkadot/api-derive/types'; import { memo } from '@polkadot/api-derive/util'; import { TypeRegistry, U128 } from '@polkadot/types'; @@ -63,10 +63,27 @@ export function getBalance ( ); } +export function transferBalance ( + account: string, + amount: number, + api: ApiPromise +): SubmittableExtrinsic<'promise'> | undefined { + if (!api) { + return; + } + + const nativeToken = api.registry.chainTokens[0] || formatBalance.getDefaults().unit; + + return api.tx.tokens.transfer(account, { Token: nativeToken }, amount); +} + const definitions: OverrideBundleDefinition = { derives: { balances: { - all: getBalance + all: getBalance, + transfer: transferBalance, + transferAll: transferBalance, + transferKeepAlive: transferBalance } }, diff --git a/packages/page-accounts/src/Accounts/Account.tsx b/packages/page-accounts/src/Accounts/Account.tsx index 87f79ea5938d..579531cb8b27 100644 --- a/packages/page-accounts/src/Accounts/Account.tsx +++ b/packages/page-accounts/src/Accounts/Account.tsx @@ -652,11 +652,12 @@ function Account ({ account: { address, meta }, className = '', delegation, filt isLogo type='address' /> - {isFunction(api.api.tx.balances?.transfer) && ( + { /* eslint-disable-next-line @typescript-eslint/no-unsafe-member-access */ } + {(isFunction(api.api.tx.balances?.transfer) || isFunction((api.api.derive.balances as any).transfer)) && (