Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/tidy-lizards-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@0xsequence/connect': patch
---

Compare WaaS fee token addresses case-insensitively when matching balances.
9 changes: 7 additions & 2 deletions packages/connect/src/hooks/useWaasFeeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { Connector } from 'wagmi'
import { useConnections } from 'wagmi'

import { Deferred } from '../utils/deferred.js'
import { compareAddress } from '../utils/helpers.js'

// Shared state across hook instances
let sharedPendingConfirmation: WaasFeeOptionConfirmation | undefined = undefined
Expand Down Expand Up @@ -101,8 +102,12 @@ export function useWaasFeeOptions(options?: WaasFeeOptionsConfig): UseWaasFeeOpt
const { token, value } = option
const decimals = token.decimals ?? 18
const rawValue = BigInt(value)
const balance = token.contractAddress
? BigInt(balances.balances.find(({ contractAddress }) => contractAddress === token.contractAddress)?.balance ?? '0')
const tokenContractAddress = token.contractAddress
const balance = tokenContractAddress
? BigInt(
balances.balances.find(({ contractAddress }) => compareAddress(contractAddress, tokenContractAddress))?.balance ??
'0'
)
: BigInt(balances.nativeBalances?.[0]?.balance ?? '0')

return {
Expand Down
Loading