Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix balance #1838

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions packages/wagmi/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,17 @@ export class Web3Modal extends Web3ModalScaffold {

private async syncBalance(address: Hex, chainId: number) {
const chain = this.wagmiConfig.chains.find((c: Chain) => c.id === chainId)
if (chain) {
const balance = await getBalance(this.wagmiConfig, {
address,
chainId: chain.id,
token: this.options?.tokens?.[chain.id]?.address as Hex
})
this.setBalance(balance.formatted, balance.symbol)

const id = chain?.id || this.options?.defaultChain?.id || this.wagmiConfig?.chains?.[0]?.id
const balance = await getBalance(this.wagmiConfig, {
address,
chainId: id,
token: this.options?.tokens?.[id]?.address as Hex
})
this.setBalance(balance.formatted, balance.symbol)
return
}
this.setBalance(undefined, undefined)
}

private syncConnectors(
Expand Down
Loading