Skip to content

Commit

Permalink
fix: compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
Holybasil committed Jun 14, 2023
1 parent 17db1e0 commit 7d8a9ca
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 402 deletions.
24 changes: 14 additions & 10 deletions src/contexts/NFTBridgeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import L2_ERC721 from "@/assets/abis/L2_ERC721.json"
import L2_ERC1155 from "@/assets/abis/L2_ERC1155.json"
import { ChainId, TOEKN_TYPE } from "@/constants"
import { useWeb3Context } from "@/contexts/Web3ContextProvider"
import { useAsyncMemo } from "@/hooks"
import useNFTBridgeStore from "@/stores/nftBridgeStore"
import { requireEnv } from "@/utils"

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

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

const tokenInstance = useMemo(() => {
const signer = provider?.getSigner(0)
if (contract?.type === TOEKN_TYPE[721] && checkConnectedChainId(ChainId.SCROLL_LAYER_1)) {
return new ethers.Contract(contract.l1 as string, L1_ERC721, signer)
} else if (contract?.type === TOEKN_TYPE[721] && checkConnectedChainId(ChainId.SCROLL_LAYER_2)) {
return new ethers.Contract(contract.l2 as string, L2_ERC721, signer)
} else if (contract?.type === TOEKN_TYPE[1155] && checkConnectedChainId(ChainId.SCROLL_LAYER_1)) {
return new ethers.Contract(contract.l1 as string, L1_ERC1155, signer)
} else if (contract?.type === TOEKN_TYPE[1155] && checkConnectedChainId(ChainId.SCROLL_LAYER_2)) {
return new ethers.Contract(contract.l2 as string, L2_ERC1155, signer)
const tokenInstance = useAsyncMemo(async () => {
if (provider) {
const signer = await provider.getSigner(0)
if (contract?.type === TOEKN_TYPE[721] && checkConnectedChainId(ChainId.SCROLL_LAYER_1)) {
return new ethers.Contract(contract.l1 as string, L1_ERC721, signer)
} else if (contract?.type === TOEKN_TYPE[721] && checkConnectedChainId(ChainId.SCROLL_LAYER_2)) {
return new ethers.Contract(contract.l2 as string, L2_ERC721, signer)
} else if (contract?.type === TOEKN_TYPE[1155] && checkConnectedChainId(ChainId.SCROLL_LAYER_1)) {
return new ethers.Contract(contract.l1 as string, L1_ERC1155, signer)
} else if (contract?.type === TOEKN_TYPE[1155] && checkConnectedChainId(ChainId.SCROLL_LAYER_2)) {
return new ethers.Contract(contract.l2 as string, L2_ERC1155, signer)
}
return null
}
return null
}, [provider, checkConnectedChainId, contract?.type])
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useGasFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const useNFTGasFee = () => {

const gasFee = useMemo(() => {
if (gasPrice) {
return gasPrice.mul(gasLimit)
return gasPrice * BigInt(gasLimit)
}
return null
}, [gasLimit, gasPrice])
Expand Down
60 changes: 0 additions & 60 deletions src/pages/nftBridge/FAQ/index.tsx

This file was deleted.

281 changes: 0 additions & 281 deletions src/pages/nftBridge/NFTPanel/SendBackup.tsx

This file was deleted.

Loading

0 comments on commit 7d8a9ca

Please sign in to comment.