Skip to content

Commit

Permalink
improved cw20 list query efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Jun 10, 2024
1 parent 40a6091 commit 9b74a33
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/data/formulas/wallet/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,27 @@ export const list: WalletFormula<ContractWithBalance[]> = {
true
)) ?? []

const contractInfos = await Promise.all(
matchingContracts.map(({ contractAddress }) =>
info.compute({
...env,
contractAddress,
})
)
)

const balances = await Promise.all(
matchingContracts.map(({ contractAddress }) =>
balance.compute({
...env,
contractAddress,
args: {
address: env.walletAddress,
},
})
)
)
const [contractInfos, balances] = await Promise.all([
Promise.all(
matchingContracts.map(({ contractAddress }) =>
info.compute({
...env,
contractAddress,
})
)
),
Promise.all(
matchingContracts.map(({ contractAddress }) =>
balance.compute({
...env,
contractAddress,
args: {
address: env.walletAddress,
},
})
)
),
])

const contractsWithBalance = matchingContracts
// Filter by those with cw20 in the contract name and with a >0 balance.
Expand Down

0 comments on commit 9b74a33

Please sign in to comment.