Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #1441 #1442

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Scroll
Copyright (c) 2025 Scroll

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions src/app/bridge/Send/SendTransaction/DepositSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const useStyles = makeStyles()(theme => ({
justifyContent: "center",
},
},
invaildCard: {
invalidCard: {
opacity: 0.6,
pointerEvents: "none",
},
Expand Down Expand Up @@ -205,7 +205,7 @@ const DepositSelector = props => {
role="button"
tabIndex={0}
variant="outlined"
classes={{ root: cx(classes.cardRoot, !idx && !isVaild && classes.invaildCard, selectedType === item.type && classes.selectedCard) }}
classes={{ root: cx(classes.cardRoot, !idx && !isVaild && classes.invalidCard, selectedType === item.type && classes.selectedCard) }}
onClick={() => handleSelect(item.type)}
>
{item.type === selectedType && <SvgIcon classes={{ root: classes.selectedIcon }} component={SelectedSvg} inheritViewBox></SvgIcon>}
Expand Down
4 changes: 2 additions & 2 deletions src/app/bridge/Send/SendTransaction/hooks/useBatchDeposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function useBatchDeposit(props) {
}, [selectedToken])

// < 0.001 need special check for economy mode
const depositAmountIsVaild = useMemo(() => {
const depositAmountIsValid = useMemo(() => {
const minAmount = BNToAmount(batchDepositConfig.minAmountPerTx, selectedToken.decimals)
if (amount && txType === "Deposit" && enableBatchDeposit) {
return Number(amount) >= Number(minAmount)
Expand All @@ -49,6 +49,6 @@ export default function useBatchDeposit(props) {

return {
getBatchDepositConfigsByToken,
depositAmountIsVaild,
depositAmountIsValid,
}
}
8 changes: 4 additions & 4 deletions src/app/bridge/Send/SendTransaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const SendTransaction = () => {
needApproval,
})

const { depositAmountIsVaild } = useBatchDeposit({ selectedToken, amount: validAmount })
const { depositAmountIsValid } = useBatchDeposit({ selectedToken, amount: validAmount })

// fee start
const {
Expand Down Expand Up @@ -183,8 +183,8 @@ const SendTransaction = () => {
// fee end

const necessaryCondition = useMemo(() => {
return validAmount && !bridgeWarning && (depositAmountIsVaild || (!depositAmountIsVaild && depositBatchMode === DepositBatchMode.Fast))
}, [validAmount, bridgeWarning, depositAmountIsVaild, depositBatchMode])
return validAmount && !bridgeWarning && (depositAmountIsValid || (!depositAmountIsValid && depositBatchMode === DepositBatchMode.Fast))
}, [validAmount, bridgeWarning, depositAmountIsValid, depositBatchMode])

const sendText = useMemo(() => {
if (txType === "Deposit" && sendLoading) {
Expand Down Expand Up @@ -354,7 +354,7 @@ const SendTransaction = () => {
l2EconomyGasFee={batchDepositConfig.feeAmountPerTx}
l1DataFee={l1DataFee}
needApproval={needApproval}
isVaild={depositAmountIsVaild}
isVaild={depositAmountIsValid}
/>
)}
{!(bridgeSummaryType === BridgeSummaryType.Selector && depositBatchMode === DepositBatchMode.Economy) && (
Expand Down
4 changes: 2 additions & 2 deletions src/app/bridge/Send/Withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ const useStyles = makeStyles()(theme => ({

const Withdraw = () => {
const { classes } = useStyles()
const { withDrawStep, changeWithdrawStep } = useBridgeStore()
const { withdrawStep, changeWithdrawStep } = useBridgeStore()

const handleChange = (e, newValue) => {
changeWithdrawStep(newValue)
}

return (
<Stack direction="column" sx={{ height: "100%" }}>
<TabContext value={withDrawStep}>
<TabContext value={withdrawStep}>
<TabList
onChange={handleChange}
textColor="primary"
Expand Down
8 changes: 4 additions & 4 deletions src/app/bridge/Send/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const useStyles = makeStyles()(theme => ({
const Send = () => {
const { classes, cx } = useStyles()
const { chainId } = useRainbowContext()
const { txType, txResult, fromNetwork, withDrawStep, changeTxType, changeTxResult, changeHistoryVisible, changeIsNetworkCorrect } = useBridgeStore()
const { txType, txResult, fromNetwork, withdrawStep, changeTxType, changeTxResult, changeHistoryVisible, changeIsNetworkCorrect } = useBridgeStore()

const { depositBatchMode } = useBatchBridgeStore()

Expand All @@ -101,13 +101,13 @@ const Send = () => {
let networkCorrect
if (txType === "Deposit") {
networkCorrect = fromNetwork.isL1 && chainId === CHAIN_ID.L1
} else if (withDrawStep === "1") {
} else if (withdrawStep === "1") {
networkCorrect = !fromNetwork.isL1 && chainId === CHAIN_ID.L2
} else {
networkCorrect = chainId === CHAIN_ID.L1
}
changeIsNetworkCorrect(networkCorrect)
}, [fromNetwork, txType, withDrawStep, chainId])
}, [fromNetwork, txType, withdrawStep, chainId])

const handleChange = (e, newValue) => {
changeTxType(newValue)
Expand Down Expand Up @@ -137,7 +137,7 @@ const Send = () => {
<TabPanel value="Deposit" classes={{ root: classes.tabPanel }}>
<Deposit></Deposit>
</TabPanel>
<TabPanel value="Withdraw" className={withDrawStep === "2" ? "tx" : ""} classes={{ root: cx(classes.tabPanel, "withdraw") }}>
<TabPanel value="Withdraw" className={withdrawStep === "2" ? "tx" : ""} classes={{ root: cx(classes.tabPanel, "withdraw") }}>
<Withdraw></Withdraw>
</TabPanel>
</TabContext>
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useClaimHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export interface TxHistory {

const useClaimHistory = () => {
const { walletCurrentAddress } = useRainbowContext()
const { txType, withDrawStep, historyVisible } = useBridgeStore()
const { txType, withdrawStep, historyVisible } = useBridgeStore()

const { comboPageTransactions, pageTransactions, generateTransactions } = useClaimHistoryStore()

const isOnClaimPage = useMemo(() => {
return !historyVisible && txType === "Withdraw" && withDrawStep === "2"
}, [historyVisible, txType, withDrawStep])
return !historyVisible && txType === "Withdraw" && withdrawStep === "2"
}, [historyVisible, txType, withdrawStep])

const [errorMessage, setErrorMessage] = useState("")

Expand Down
6 changes: 3 additions & 3 deletions src/services/canvasService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ const getBadgeOrder = async profileContract => {
}
}

const fetchCanvasDetail = async (privider, othersAddress, profileAddress) => {
const { profileContract, name } = await queryCanvasUsername(privider, profileAddress)
const userBadges = await queryUserBadgesWrapped(privider, othersAddress)
const fetchCanvasDetail = async (provider, othersAddress, profileAddress) => {
const { profileContract, name } = await queryCanvasUsername(provider, profileAddress)
const userBadges = await queryUserBadgesWrapped(provider, othersAddress)
const { orderedAttachedBadges, attachedBadges, badgeOrder } = await getOrderedAttachedBadges(profileContract)
return { name, profileContract, userBadges, attachedBadges, orderedAttachedBadges, badgeOrder }
}
Expand Down
12 changes: 6 additions & 6 deletions src/stores/batchBridgeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ interface BatchBridgeStore {
bridgeSummaryType: BridgeSummaryType
depositBatchMode: DepositBatchMode
batchDepositConfig: BatchDepositConfig
depositAmountIsVaild: boolean
depositAmountIsValid: boolean

changeBridgeSummaryType: (depositTpye: BridgeSummaryType) => void
changeBridgeSummaryType: (depositType: BridgeSummaryType) => void
changeDepositBatchMode: (depositBatchMode: DepositBatchMode) => void
changeBatchDepositConfig: (batchDepositConfig: BatchDepositConfig) => void
changeDepositAmountIsVaild: (depositAmountIsVaild: boolean) => void
changeDepositAmountIsValid: (depositAmountIsValid: boolean) => void
}

const useBatchBridgeStore = create<BatchBridgeStore>()(set => ({
Expand All @@ -40,7 +40,7 @@ const useBatchBridgeStore = create<BatchBridgeStore>()(set => ({
maxDelayPerBatch: 0n,
safeBridgeGasLimit: 0n,
},
depositAmountIsVaild: true,
depositAmountIsValid: true,

changeBridgeSummaryType: bridgeSummaryType => {
set({
Expand All @@ -58,9 +58,9 @@ const useBatchBridgeStore = create<BatchBridgeStore>()(set => ({
batchDepositConfig,
})
},
changeDepositAmountIsVaild: depositAmountIsVaild => {
changeDepositAmountIsValid: depositAmountIsValid => {
set({
depositAmountIsVaild,
depositAmountIsValid,
})
},
}))
Expand Down
12 changes: 6 additions & 6 deletions src/stores/bridgeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { loadState } from "@/utils/localStorage"

type TransactionType = "Deposit" | "Withdraw"

type WithDrawStep = "1" | "2"
type WithdrawStep = "1" | "2"

interface TxSuccess {
code: 1
Expand All @@ -26,7 +26,7 @@ interface BridgeStore {
fromNetwork: Network
toNetwork: Network
txType: TransactionType
withDrawStep: WithDrawStep
withdrawStep: WithdrawStep
txResult: TxResult
isNetworkCorrect: boolean
tokenList: Array<Token>
Expand All @@ -35,7 +35,7 @@ interface BridgeStore {
changeToNetwork: (network: Network) => void
changeTxType: (txType: TransactionType) => void
changeTxResult: (txResult: TxResult | null) => void
changeWithdrawStep: (withDrawStep: WithDrawStep) => void
changeWithdrawStep: (withdrawStep: WithdrawStep) => void
changeIsNetworkCorrect: (isNetworkCorrect: boolean) => void
fetchTokenList: () => Promise<void>
}
Expand All @@ -45,7 +45,7 @@ const useBridgeStore = create<BridgeStore>()((set, get) => ({
fromNetwork: NETWORKS[0],
toNetwork: NETWORKS[1],
txType: "Deposit",
withDrawStep: "1",
withdrawStep: "1",
txResult: null,
isNetworkCorrect: true,
tokenList: NATIVE_TOKEN_LIST,
Expand Down Expand Up @@ -114,9 +114,9 @@ const useBridgeStore = create<BridgeStore>()((set, get) => ({
})
},

changeWithdrawStep: withDrawStep => {
changeWithdrawStep: withdrawStep => {
set({
withDrawStep,
withdrawStep,
})
},

Expand Down
12 changes: 6 additions & 6 deletions src/stores/canvasStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ interface CanvasStore {
changeIsBadgeUpgrading: (id, loading) => void
checkIfProfileMinted: (instance: Contract, address: string, test?: boolean) => Promise<any>
fetchCurrentCanvasDetail: (signer, walletAddress, profileAddress) => void
checkAndFetchCurrentWalletCanvas: (prividerOrSigner, unsignedProfileRegistryContract, walletAddress) => Promise<any>
fetchOthersCanvasDetail: (prividerOrSigner, othersAddress, profileAddress) => void
checkAndFetchCurrentWalletCanvas: (providerOrSigner, unsignedProfileRegistryContract, walletAddress) => Promise<any>
fetchOthersCanvasDetail: (providerOrSigner, othersAddress, profileAddress) => void
changeProfileMintedLoading: (loading: boolean) => void
changeProfileDetailLoading: (loading: boolean) => void
queryUsername: () => void
Expand Down Expand Up @@ -187,8 +187,8 @@ const useCanvasStore = create<CanvasStore>()((set, get) => ({
// return { profileAddress: null, minted: null }
}
},
fetchOthersCanvasDetail: async (privider, othersAddress, profileAddress) => {
const { name, userBadges, attachedBadges, orderedAttachedBadges, badgeOrder } = await fetchCanvasDetail(privider, othersAddress, profileAddress)
fetchOthersCanvasDetail: async (provider, othersAddress, profileAddress) => {
const { name, userBadges, attachedBadges, orderedAttachedBadges, badgeOrder } = await fetchCanvasDetail(provider, othersAddress, profileAddress)
set({
canvasUsername: name,
userBadges,
Expand All @@ -199,15 +199,15 @@ const useCanvasStore = create<CanvasStore>()((set, get) => ({
},

// fetch wallet profile when viewing others canvas
checkAndFetchCurrentWalletCanvas: async (prividerOrSigner, unsignedProfileRegistryContract, walletAddress) => {
checkAndFetchCurrentWalletCanvas: async (providerOrSigner, unsignedProfileRegistryContract, walletAddress) => {
set({
walletDetailLoading: true,
})
try {
const { minted, profileAddress } = await get().checkIfProfileMinted(unsignedProfileRegistryContract, walletAddress)

if (minted) {
const { profileContract, name } = await queryCanvasUsername(prividerOrSigner, profileAddress)
const { profileContract, name } = await queryCanvasUsername(providerOrSigner, profileAddress)
set({
username: name,
profileContract,
Expand Down