From 7aafa02e5cbf893f9c48acb8f1b4e3b37eeecd90 Mon Sep 17 00:00:00 2001 From: Richard Kenigs Date: Thu, 21 Mar 2024 11:01:10 +0100 Subject: [PATCH] fix erc20 contract call --- packages/sdk/src/contract/contracts/Erc20/Erc20Public.ts | 2 +- packages/sdk/src/getTransferData/getTransferData.utils.ts | 4 +++- .../sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/sdk/src/contract/contracts/Erc20/Erc20Public.ts b/packages/sdk/src/contract/contracts/Erc20/Erc20Public.ts index adf6adec..bb40a652 100644 --- a/packages/sdk/src/contract/contracts/Erc20/Erc20Public.ts +++ b/packages/sdk/src/contract/contracts/Erc20/Erc20Public.ts @@ -28,7 +28,7 @@ export class Erc20Public implements BalanceContractInterface { const data = await this.#publicClient.readContract({ abi, address: this.#config.address as `0x${string}`, - args: [this.address], + args: this.#config.args, functionName: 'balanceOf', }); diff --git a/packages/sdk/src/getTransferData/getTransferData.utils.ts b/packages/sdk/src/getTransferData/getTransferData.utils.ts index ec989cd3..d2a68635 100644 --- a/packages/sdk/src/getTransferData/getTransferData.utils.ts +++ b/packages/sdk/src/getTransferData/getTransferData.utils.ts @@ -45,7 +45,9 @@ export async function getBalance({ chain as EvmParachain, ) as BalanceContractInterface; - return contract.getBalance(); + const balance = await contract.getBalance(); + + return balance; } export async function getDecimals({ diff --git a/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap b/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap index 6e17ff28..b9316698 100644 --- a/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap +++ b/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap @@ -201,7 +201,7 @@ exports[`sdk getParachainBalances should get expected balances for HydraDX for s exports[`sdk getParachainBalances should get expected balances for Moonbase Alpha 1`] = ` [ r { - "amount": 0n, + "amount": 1234567890000000000n, "decimals": 18, "key": "ftmwh", "originSymbol": "FTM.wh", @@ -264,7 +264,7 @@ exports[`sdk getParachainBalances should get expected balances for Moonbase Alph "symbol": "ALAN", }, r { - "amount": 0n, + "amount": 6543210000000000000n, "decimals": 18, "key": "dev", "originSymbol": "DEV", @@ -386,7 +386,7 @@ exports[`sdk getParachainBalances should get expected balances for Moonbeam 1`] "symbol": "USDT.Wh", }, r { - "amount": 374573n, + "amount": 0n, "decimals": 6, "key": "usdcwh", "originSymbol": "USDC.Wh",