Skip to content

Commit

Permalink
Fix use wrong instance for erc20
Browse files Browse the repository at this point in the history
  • Loading branch information
zzq0826 committed Feb 19, 2024
1 parent db3e0db commit a98c38c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/hooks/useEstimateSendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export function useEstimateSendTransaction(props) {
const minimumAmount = BigInt(1)

useEffect(() => {
const scrollMessenger = networksAndSigners[fromNetwork.isL1 ? CHAIN_ID.L1 : CHAIN_ID.L2].scrollMessenger
if (scrollMessenger) {
setInstance(scrollMessenger)
const instance = selectedToken.native
? networksAndSigners[fromNetwork.isL1 ? CHAIN_ID.L1 : CHAIN_ID.L2].scrollMessenger
: networksAndSigners[fromNetwork.isL1 ? CHAIN_ID.L1 : CHAIN_ID.L2].gateway
if (instance) {
setInstance(instance)
}
}, [networksAndSigners, fromNetwork])
}, [networksAndSigners, fromNetwork, selectedToken.native])

const depositETH = async () => {
const fee = gasPrice * gasLimit
Expand All @@ -32,6 +34,7 @@ export function useEstimateSendTransaction(props) {

const depositERC20 = async () => {
const fee = gasPrice * gasLimit

return instance["depositERC20(address,uint256,uint256)"].estimateGas(selectedToken.address, minimumAmount, gasLimit, {
value: fee,
})
Expand Down

0 comments on commit a98c38c

Please sign in to comment.