Skip to content

Commit

Permalink
fix wrap/unwrap when wallet is not connected (#2448)
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv authored Dec 13, 2023
1 parent 64d3d57 commit 9bbfb67
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/hooks/useContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ export function useTokenReadingContract(tokenAddress?: string, customChainId?: C
}

export function useWETHContract(customChainId?: ChainId): Contract | null {
const { chainId: walletChainId } = useActiveWeb3React()
const { chainId: walletChainId, account } = useActiveWeb3React()
const chainId = customChainId || walletChainId
return useSigningContract(WETH[chainId].address, WETH_ABI)
const signContract = useSigningContract(WETH[chainId].address, WETH_ABI)
const readContract = useReadingContract(WETH[chainId].address, WETH_ABI)

return account ? signContract : readContract
}

export function useArgentWalletDetectorContract(): Contract | null {
Expand Down

0 comments on commit 9bbfb67

Please sign in to comment.