Skip to content

Commit

Permalink
fix: compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
Holybasil committed May 17, 2023
1 parent c3c2ff1 commit b249138
Show file tree
Hide file tree
Showing 7 changed files with 34 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
17 changes: 17 additions & 0 deletions src/pages/ecosystem/helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ReactComponent as TwitterIcon } from "@/assets/svgs/twitter.svg"
import { ReactComponent as WebsiteIcon } from "@/assets/svgs/website.svg"

export const socialLinks = [
{
name: "Twitter",
icon: TwitterIcon,
viewBox: "0 0 20 16",
prefixLink: "https://twitter.com/",
},
{
name: "Website",
icon: WebsiteIcon,
viewBox: "0 0 15 16",
prefixLink: "",
},
]
60 changes: 0 additions & 60 deletions src/pages/nftBridge/FAQ/index.tsx

This file was deleted.

Loading

0 comments on commit b249138

Please sign in to comment.