diff --git a/CHANGELOG.md b/CHANGELOG.md index 9008082..e511bf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## [0.7.1] - 2024-02-06 + +### Added Changes +- Added `chainId` param to `useEtherspotBalances` hook's `getBalances` method + ## [0.7.0] - 2024-01-30 ### Added Changes diff --git a/__tests__/hooks/useEtherspotBalances.test.js b/__tests__/hooks/useEtherspotBalances.test.js index 0be4504..39469d0 100644 --- a/__tests__/hooks/useEtherspotBalances.test.js +++ b/__tests__/hooks/useEtherspotBalances.test.js @@ -41,5 +41,10 @@ describe('useEtherspotBalances()', () => { const accountBalancesPolygon = await result.current.getAccountBalances(); expect(accountBalancesPolygon.length).toEqual(1); expect(accountBalancesPolygon[0].balance.toString()).toEqual(ethers.utils.parseEther('0').toString()); + + const accountBalancesManualMainnet = await result.current.getAccountBalances('0xAb4C67d8D7B248B2fA6B638C645466065fE8F1F1', 1); + expect(accountBalancesManualMainnet.length).toEqual(2); + expect(accountBalancesManualMainnet[1].token).not.toBeNull(); + expect(accountBalancesManualMainnet[1].balance.toString()).toEqual(ethers.utils.parseEther('69').toString()); }); }) diff --git a/package-lock.json b/package-lock.json index 21a5da4..5f065e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@etherspot/transaction-kit", - "version": "0.7.0", + "version": "0.7.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@etherspot/transaction-kit", - "version": "0.7.0", + "version": "0.7.1", "license": "MIT", "dependencies": { "@etherspot/eip1271-verification-util": "0.1.2", diff --git a/package.json b/package.json index 6f1753a..f0df882 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@etherspot/transaction-kit", "description": "React Etherspot Transaction Kit", - "version": "0.7.0", + "version": "0.7.1", "main": "dist/cjs/index.js", "scripts": { "rollup:build": "NODE_OPTIONS=--max-old-space-size=8192 rollup -c", diff --git a/src/hooks/useEtherspotBalances.ts b/src/hooks/useEtherspotBalances.ts index 42788f6..91aa4a0 100644 --- a/src/hooks/useEtherspotBalances.ts +++ b/src/hooks/useEtherspotBalances.ts @@ -14,14 +14,17 @@ interface IEtherspotBalancesHook { * @returns {IEtherspotBalancesHook} - hook method to fetch Etherspot account balances */ const useEtherspotBalances = (chainId?: number): IEtherspotBalancesHook => { - const { getSdk, chainId: defaultChainId } = useEtherspot(); + const { getSdk, chainId: etherspotChainId } = useEtherspot(); - const balancesChainId = useMemo(() => { + const defaultChainId = useMemo(() => { if (chainId) return chainId; - return defaultChainId; - }, [chainId, defaultChainId]); + return etherspotChainId; + }, [chainId, etherspotChainId]); - const getAccountBalances = async (accountAddress?: string) => { + const getAccountBalances = async ( + accountAddress?: string, + balancesChainId: number = defaultChainId, + ) => { const sdkForChainId = await getSdk(balancesChainId); const balancesForAccount = accountAddress ?? await sdkForChainId.getCounterFactualAddress();