From bb2de6343b172e8299e1bfbffe79d3b0488939af Mon Sep 17 00:00:00 2001 From: Saad Ahmed Siddiqui Date: Tue, 14 May 2024 17:46:23 +0200 Subject: [PATCH 1/2] substrate balance fix --- .../widget/src/controllers/wallet-manager/token-balance.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/widget/src/controllers/wallet-manager/token-balance.ts b/packages/widget/src/controllers/wallet-manager/token-balance.ts index 9905a38e..e8ff11e0 100644 --- a/packages/widget/src/controllers/wallet-manager/token-balance.ts +++ b/packages/widget/src/controllers/wallet-manager/token-balance.ts @@ -17,6 +17,7 @@ import { walletContext } from '../../context'; import { isEvmResource } from '../../utils'; import { substrateProviderContext } from '../../context/wallet'; import type { SubstrateWallet } from '../../context/wallet'; +import Keyring from '@polkadot/keyring'; const BALANCE_REFRESH_MS = 5_000; @@ -165,6 +166,8 @@ export class TokenBalanceController implements ReactiveController { return; } + const prefix = substrateProvider.consts.ss58Prefix as unknown as number; + void async function (this: TokenBalanceController) { try { this.loadingBalance = true; @@ -172,7 +175,7 @@ export class TokenBalanceController implements ReactiveController { const tokenBalance = await getAssetBalance( substrateProvider, resource.assetID as number, - signerAddress + new Keyring().encodeAddress(signerAddress, prefix) ); this.loadingBalance = false; this.balance = BigNumber.from(tokenBalance.balance.toString()); From 94da39d82ac612ffcabd31ddc4f7dc5e1eeb71d3 Mon Sep 17 00:00:00 2001 From: Saad Ahmed Siddiqui Date: Tue, 14 May 2024 17:53:13 +0200 Subject: [PATCH 2/2] fix import order --- packages/widget/src/controllers/wallet-manager/token-balance.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/widget/src/controllers/wallet-manager/token-balance.ts b/packages/widget/src/controllers/wallet-manager/token-balance.ts index e8ff11e0..346495a6 100644 --- a/packages/widget/src/controllers/wallet-manager/token-balance.ts +++ b/packages/widget/src/controllers/wallet-manager/token-balance.ts @@ -13,11 +13,11 @@ import { ethers, BigNumber } from 'ethers'; import type { ReactiveController, ReactiveElement } from 'lit'; import type { ParachainID } from '@buildwithsygma/sygma-sdk-core/substrate'; import { getAssetBalance } from '@buildwithsygma/sygma-sdk-core/substrate'; +import Keyring from '@polkadot/keyring'; import { walletContext } from '../../context'; import { isEvmResource } from '../../utils'; import { substrateProviderContext } from '../../context/wallet'; import type { SubstrateWallet } from '../../context/wallet'; -import Keyring from '@polkadot/keyring'; const BALANCE_REFRESH_MS = 5_000;