Skip to content

Commit 1ed4e1f

Browse files
committed
Cleanup updateSecondaryToken func
1 parent 167eef4 commit 1ed4e1f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/core/src/update-balances.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@ export const updateSecondaryTokens = async (
4646
const chainRPC = chain.rpcUrl
4747
if (!chain.secondaryTokens || !chain.secondaryTokens.length || !chainRPC)
4848
return
49+
4950
const ethersProvider = new ethers.providers.Web3Provider(
5051
wallet.provider,
5152
'any'
5253
)
5354
const signer = ethersProvider.getSigner()
5455

55-
const abi = [
56+
const erc20ABISubset = [
5657
{
5758
inputs: [{ name: 'owner', type: 'address' }],
5859
name: 'balanceOf',
@@ -68,10 +69,15 @@ export const updateSecondaryTokens = async (
6869
type: 'function'
6970
}
7071
]
71-
const updatedBalances = await Promise.all(
72+
73+
const tokenBalances = await Promise.all(
7274
chain.secondaryTokens.map(async token => {
7375
try {
74-
const swapContract = new ethers.Contract(token.address, abi, signer)
76+
const swapContract = new ethers.Contract(
77+
token.address,
78+
erc20ABISubset,
79+
signer
80+
)
7581
const bigNumBalance = await swapContract.balanceOf(account)
7682
const tokenName = await swapContract.symbol()
7783
return {
@@ -87,7 +93,7 @@ export const updateSecondaryTokens = async (
8793
}
8894
})
8995
)
90-
return updatedBalances
96+
return tokenBalances
9197
}
9298

9399
export default updateBalances

0 commit comments

Comments
 (0)