Skip to content

Commit 7d8a9ca

Browse files
committed
fix: compatibility code
1 parent 17db1e0 commit 7d8a9ca

File tree

6 files changed

+17
-402
lines changed

6 files changed

+17
-402
lines changed

src/contexts/NFTBridgeProvider.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import L2_ERC721 from "@/assets/abis/L2_ERC721.json"
77
import L2_ERC1155 from "@/assets/abis/L2_ERC1155.json"
88
import { ChainId, TOEKN_TYPE } from "@/constants"
99
import { useWeb3Context } from "@/contexts/Web3ContextProvider"
10+
import { useAsyncMemo } from "@/hooks"
1011
import useNFTBridgeStore from "@/stores/nftBridgeStore"
1112
import { requireEnv } from "@/utils"
1213

@@ -26,16 +27,19 @@ const NFTBridgeProvider = props => {
2627

2728
const isLayer1 = useMemo(() => checkConnectedChainId(ChainId.SCROLL_LAYER_1), [checkConnectedChainId])
2829

29-
const tokenInstance = useMemo(() => {
30-
const signer = provider?.getSigner(0)
31-
if (contract?.type === TOEKN_TYPE[721] && checkConnectedChainId(ChainId.SCROLL_LAYER_1)) {
32-
return new ethers.Contract(contract.l1 as string, L1_ERC721, signer)
33-
} else if (contract?.type === TOEKN_TYPE[721] && checkConnectedChainId(ChainId.SCROLL_LAYER_2)) {
34-
return new ethers.Contract(contract.l2 as string, L2_ERC721, signer)
35-
} else if (contract?.type === TOEKN_TYPE[1155] && checkConnectedChainId(ChainId.SCROLL_LAYER_1)) {
36-
return new ethers.Contract(contract.l1 as string, L1_ERC1155, signer)
37-
} else if (contract?.type === TOEKN_TYPE[1155] && checkConnectedChainId(ChainId.SCROLL_LAYER_2)) {
38-
return new ethers.Contract(contract.l2 as string, L2_ERC1155, signer)
30+
const tokenInstance = useAsyncMemo(async () => {
31+
if (provider) {
32+
const signer = await provider.getSigner(0)
33+
if (contract?.type === TOEKN_TYPE[721] && checkConnectedChainId(ChainId.SCROLL_LAYER_1)) {
34+
return new ethers.Contract(contract.l1 as string, L1_ERC721, signer)
35+
} else if (contract?.type === TOEKN_TYPE[721] && checkConnectedChainId(ChainId.SCROLL_LAYER_2)) {
36+
return new ethers.Contract(contract.l2 as string, L2_ERC721, signer)
37+
} else if (contract?.type === TOEKN_TYPE[1155] && checkConnectedChainId(ChainId.SCROLL_LAYER_1)) {
38+
return new ethers.Contract(contract.l1 as string, L1_ERC1155, signer)
39+
} else if (contract?.type === TOEKN_TYPE[1155] && checkConnectedChainId(ChainId.SCROLL_LAYER_2)) {
40+
return new ethers.Contract(contract.l2 as string, L2_ERC1155, signer)
41+
}
42+
return null
3943
}
4044
return null
4145
}, [provider, checkConnectedChainId, contract?.type])

src/hooks/useGasFee.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const useNFTGasFee = () => {
3737

3838
const gasFee = useMemo(() => {
3939
if (gasPrice) {
40-
return gasPrice.mul(gasLimit)
40+
return gasPrice * BigInt(gasLimit)
4141
}
4242
return null
4343
}, [gasLimit, gasPrice])

src/pages/nftBridge/FAQ/index.tsx

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/pages/nftBridge/NFTPanel/SendBackup.tsx

Lines changed: 0 additions & 281 deletions
This file was deleted.

0 commit comments

Comments
 (0)