diff --git a/netlify.toml b/netlify.toml
index 214f71019..3c121bbe2 100644
--- a/netlify.toml
+++ b/netlify.toml
@@ -53,4 +53,3 @@ REACT_APP_L1_MESSAGE_QUEUE = "0xF0B2293F5D834eAe920c6974D50957A1732de763"
REACT_APP_SCROLL_ORIGINS_NFT="0x90a274D591d5AB1a25f0DD0F06F28533C34D7d9f"
REACT_APP_SCROLL_ORIGINS_NFT_V2="0xDd7d857F570B0C211abfe05cd914A85BefEC2464"
REACT_APP_L1_MESSAGE_QUEUE_WITH_GAS_PRICE_ORACLE="0xF0B2293F5D834eAe920c6974D50957A1732de763"
-REACT_APP_L1_BATCH_BRIDGE_GATEWAY_PROXY_ADDR = "0xE86ad3312FA693aDeD34dEc3899176d97ac883B2"
\ No newline at end of file
diff --git a/src/assets/abis/L1BatchBridgeGateway.json b/src/assets/abis/L1BatchBridgeGateway.json
deleted file mode 100644
index e6fafdbbf..000000000
--- a/src/assets/abis/L1BatchBridgeGateway.json
+++ /dev/null
@@ -1,681 +0,0 @@
-[
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "_counterpart",
- "type": "address"
- },
- {
- "internalType": "address",
- "name": "_router",
- "type": "address"
- },
- {
- "internalType": "address",
- "name": "_messenger",
- "type": "address"
- },
- {
- "internalType": "address",
- "name": "_queue",
- "type": "address"
- }
- ],
- "stateMutability": "nonpayable",
- "type": "constructor"
- },
- {
- "inputs": [],
- "name": "ErrorCallerNotMessenger",
- "type": "error"
- },
- {
- "inputs": [],
- "name": "ErrorDepositAmountTooSmall",
- "type": "error"
- },
- {
- "inputs": [],
- "name": "ErrorIncorrectMethodForETHDeposit",
- "type": "error"
- },
- {
- "inputs": [],
- "name": "ErrorInsufficientMsgValueForBatchDepositFee",
- "type": "error"
- },
- {
- "inputs": [],
- "name": "ErrorInvalidBatchConfig",
- "type": "error"
- },
- {
- "inputs": [],
- "name": "ErrorNoPendingBatch",
- "type": "error"
- },
- {
- "inputs": [],
- "name": "ErrorTokenNotSupported",
- "type": "error"
- },
- {
- "inputs": [],
- "name": "ErrorTransferETHFailed",
- "type": "error"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "address",
- "name": "caller",
- "type": "address"
- },
- {
- "indexed": true,
- "internalType": "address",
- "name": "l1Token",
- "type": "address"
- },
- {
- "indexed": true,
- "internalType": "uint256",
- "name": "batchIndex",
- "type": "uint256"
- },
- {
- "indexed": false,
- "internalType": "address",
- "name": "l2Token",
- "type": "address"
- }
- ],
- "name": "BatchDeposit",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "address",
- "name": "sender",
- "type": "address"
- },
- {
- "indexed": true,
- "internalType": "address",
- "name": "token",
- "type": "address"
- },
- {
- "indexed": true,
- "internalType": "uint256",
- "name": "batchIndex",
- "type": "uint256"
- },
- {
- "indexed": false,
- "internalType": "uint256",
- "name": "amount",
- "type": "uint256"
- },
- {
- "indexed": false,
- "internalType": "uint256",
- "name": "fee",
- "type": "uint256"
- }
- ],
- "name": "Deposit",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": false,
- "internalType": "uint8",
- "name": "version",
- "type": "uint8"
- }
- ],
- "name": "Initialized",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- },
- {
- "indexed": true,
- "internalType": "bytes32",
- "name": "previousAdminRole",
- "type": "bytes32"
- },
- {
- "indexed": true,
- "internalType": "bytes32",
- "name": "newAdminRole",
- "type": "bytes32"
- }
- ],
- "name": "RoleAdminChanged",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- },
- {
- "indexed": true,
- "internalType": "address",
- "name": "account",
- "type": "address"
- },
- {
- "indexed": true,
- "internalType": "address",
- "name": "sender",
- "type": "address"
- }
- ],
- "name": "RoleGranted",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- },
- {
- "indexed": true,
- "internalType": "address",
- "name": "account",
- "type": "address"
- },
- {
- "indexed": true,
- "internalType": "address",
- "name": "sender",
- "type": "address"
- }
- ],
- "name": "RoleRevoked",
- "type": "event"
- },
- {
- "inputs": [],
- "name": "DEFAULT_ADMIN_ROLE",
- "outputs": [
- {
- "internalType": "bytes32",
- "name": "",
- "type": "bytes32"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "KEEPER_ROLE",
- "outputs": [
- {
- "internalType": "bytes32",
- "name": "",
- "type": "bytes32"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- },
- {
- "internalType": "uint256",
- "name": "",
- "type": "uint256"
- }
- ],
- "name": "batches",
- "outputs": [
- {
- "internalType": "uint128",
- "name": "amount",
- "type": "uint128"
- },
- {
- "internalType": "uint64",
- "name": "startTime",
- "type": "uint64"
- },
- {
- "internalType": "uint64",
- "name": "numDeposits",
- "type": "uint64"
- },
- {
- "internalType": "bytes32",
- "name": "hash",
- "type": "bytes32"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "name": "configs",
- "outputs": [
- {
- "internalType": "uint96",
- "name": "feeAmountPerTx",
- "type": "uint96"
- },
- {
- "internalType": "uint96",
- "name": "minAmountPerTx",
- "type": "uint96"
- },
- {
- "internalType": "uint16",
- "name": "maxTxsPerBatch",
- "type": "uint16"
- },
- {
- "internalType": "uint24",
- "name": "maxDelayPerBatch",
- "type": "uint24"
- },
- {
- "internalType": "uint24",
- "name": "safeBridgeGasLimit",
- "type": "uint24"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "counterpart",
- "outputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "token",
- "type": "address"
- },
- {
- "internalType": "uint96",
- "name": "amount",
- "type": "uint96"
- }
- ],
- "name": "depositERC20",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "depositETH",
- "outputs": [],
- "stateMutability": "payable",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "token",
- "type": "address"
- }
- ],
- "name": "executeBatchDeposit",
- "outputs": [],
- "stateMutability": "payable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "feeVault",
- "outputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- }
- ],
- "name": "getRoleAdmin",
- "outputs": [
- {
- "internalType": "bytes32",
- "name": "",
- "type": "bytes32"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- },
- {
- "internalType": "uint256",
- "name": "index",
- "type": "uint256"
- }
- ],
- "name": "getRoleMember",
- "outputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- }
- ],
- "name": "getRoleMemberCount",
- "outputs": [
- {
- "internalType": "uint256",
- "name": "",
- "type": "uint256"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- },
- {
- "internalType": "address",
- "name": "account",
- "type": "address"
- }
- ],
- "name": "grantRole",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- },
- {
- "internalType": "address",
- "name": "account",
- "type": "address"
- }
- ],
- "name": "hasRole",
- "outputs": [
- {
- "internalType": "bool",
- "name": "",
- "type": "bool"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "_feeVault",
- "type": "address"
- }
- ],
- "name": "initialize",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "messenger",
- "outputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "queue",
- "outputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- },
- {
- "internalType": "address",
- "name": "account",
- "type": "address"
- }
- ],
- "name": "renounceRole",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "bytes32",
- "name": "role",
- "type": "bytes32"
- },
- {
- "internalType": "address",
- "name": "account",
- "type": "address"
- }
- ],
- "name": "revokeRole",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "router",
- "outputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "token",
- "type": "address"
- },
- {
- "components": [
- {
- "internalType": "uint96",
- "name": "feeAmountPerTx",
- "type": "uint96"
- },
- {
- "internalType": "uint96",
- "name": "minAmountPerTx",
- "type": "uint96"
- },
- {
- "internalType": "uint16",
- "name": "maxTxsPerBatch",
- "type": "uint16"
- },
- {
- "internalType": "uint24",
- "name": "maxDelayPerBatch",
- "type": "uint24"
- },
- {
- "internalType": "uint24",
- "name": "safeBridgeGasLimit",
- "type": "uint24"
- }
- ],
- "internalType": "struct L1BatchBridgeGateway.BatchConfig",
- "name": "newConfig",
- "type": "tuple"
- }
- ],
- "name": "setBatchConfig",
- "outputs": [],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "bytes4",
- "name": "interfaceId",
- "type": "bytes4"
- }
- ],
- "name": "supportsInterface",
- "outputs": [
- {
- "internalType": "bool",
- "name": "",
- "type": "bool"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "name": "tokens",
- "outputs": [
- {
- "internalType": "uint128",
- "name": "pending",
- "type": "uint128"
- },
- {
- "internalType": "uint64",
- "name": "currentBatchIndex",
- "type": "uint64"
- },
- {
- "internalType": "uint64",
- "name": "pendingBatchIndex",
- "type": "uint64"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "stateMutability": "payable",
- "type": "receive"
- }
-]
diff --git a/src/assets/svgs/common/info.svg b/src/assets/svgs/common/info.svg
deleted file mode 100644
index 687a0e159..000000000
--- a/src/assets/svgs/common/info.svg
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/src/constants/common.ts b/src/constants/common.ts
index b7aa4deb5..9f8205632 100644
--- a/src/constants/common.ts
+++ b/src/constants/common.ts
@@ -46,10 +46,6 @@ export const USDC_GATEWAY_PROXY_ADDR = {
[CHAIN_ID.L2]: requireEnv("REACT_APP_L2_USDC_GATEWAY_PROXY_ADDR"),
}
-export const BATCH_BRIDGE_GATEWAY_PROXY_ADDR = {
- [CHAIN_ID.L1]: requireEnv("REACT_APP_L1_BATCH_BRIDGE_GATEWAY_PROXY_ADDR"),
-}
-
export const DOCUMENTATION_URL = {
Mainnet: "https://docs.scroll.io/en/developers/developer-quickstart/",
Sepolia: "https://docs.scroll.io/en/user-guide/",
diff --git a/src/constants/transaction.ts b/src/constants/transaction.ts
index 5974d36d3..1cd441c09 100644
--- a/src/constants/transaction.ts
+++ b/src/constants/transaction.ts
@@ -24,9 +24,4 @@ export enum TX_STATUS {
RelayedReverted,
Skipped,
Dropped,
- BatchDepositSent,
- BatchDepositRelayed,
- BatchDepositFailed,
}
-
-export const BATCH_DEPOSIT_TOKENS = [""]
diff --git a/src/contexts/BridgeContextProvider.tsx b/src/contexts/BridgeContextProvider.tsx
index 34e7ca306..7b749b098 100644
--- a/src/contexts/BridgeContextProvider.tsx
+++ b/src/contexts/BridgeContextProvider.tsx
@@ -4,12 +4,11 @@ import useStorage from "squirrel-gill"
import { Alert, Snackbar } from "@mui/material"
-import BATCH_BRIDGE_GATEWAY_PROXY_ABI from "@/assets/abis/L1BatchBridgeGateway.json"
import L1_SCROLL_MESSENGER_ABI from "@/assets/abis/L1ScrollMessenger.json"
import L1_GATEWAY_ROUTER_PROXY_ABI from "@/assets/abis/L1_GATEWAY_ROUTER_PROXY_ADDR.json"
import L2_SCROLL_MESSENGER_ABI from "@/assets/abis/L2ScrollMessenger.json"
import L2_GATEWAY_ROUTER_PROXY_ABI from "@/assets/abis/L2_GATEWAY_ROUTER_PROXY_ADDR.json"
-import { BATCH_BRIDGE_GATEWAY_PROXY_ADDR, CHAIN_ID, GATEWAY_ROUTE_PROXY_ADDR, NATIVE_TOKEN_LIST, RPC_URL, SCROLL_MESSENGER_ADDR } from "@/constants"
+import { CHAIN_ID, GATEWAY_ROUTE_PROXY_ADDR, NATIVE_TOKEN_LIST, RPC_URL, SCROLL_MESSENGER_ADDR } from "@/constants"
import { BLOCK_NUMBERS, USER_TOKEN_LIST } from "@/constants/storageKey"
import { useRainbowContext } from "@/contexts/RainbowProvider"
import useBlockNumbers from "@/hooks/useBlockNumbers"
@@ -59,16 +58,7 @@ const BridgeContextProvider = ({ children }: any) => {
// TODO: need refactoring inspired by publicClient and walletClient
const update = async (walletProvider: BrowserProvider, address: string) => {
- let l1signer,
- l2signer,
- l1Gateway,
- l2Gateway,
- l1Provider,
- l2Provider,
- l1ProviderForSafeBlock,
- l1ScrollMessenger,
- l2ScrollMessenger,
- l1BatchBridgeGateway
+ let l1signer, l2signer, l1Gateway, l2Gateway, l1Provider, l2Provider, l1ProviderForSafeBlock, l1ScrollMessenger, l2ScrollMessenger
if (chainId === CHAIN_ID.L1) {
l1Provider = walletProvider
l2Provider = await new JsonRpcProvider(RPC_URL.L2)
@@ -89,7 +79,6 @@ const BridgeContextProvider = ({ children }: any) => {
l1ProviderForSafeBlock = await new JsonRpcProvider(RPC_URL.L1)
l1ScrollMessenger = new ethers.Contract(SCROLL_MESSENGER_ADDR[CHAIN_ID.L1], L1_SCROLL_MESSENGER_ABI, l1signer)
l2ScrollMessenger = new ethers.Contract(SCROLL_MESSENGER_ADDR[CHAIN_ID.L2], L2_SCROLL_MESSENGER_ABI, l2signer)
- l1BatchBridgeGateway = new ethers.Contract(BATCH_BRIDGE_GATEWAY_PROXY_ADDR[CHAIN_ID.L1], BATCH_BRIDGE_GATEWAY_PROXY_ABI, l1signer)
setNetworksAndSigners({
[CHAIN_ID.L1]: {
@@ -97,7 +86,6 @@ const BridgeContextProvider = ({ children }: any) => {
signer: l1signer,
gateway: l1Gateway,
scrollMessenger: l1ScrollMessenger,
- batchBridgeGateway: l1BatchBridgeGateway,
},
[`${CHAIN_ID.L1}ForSafeBlock`]: {
provider: l1ProviderForSafeBlock,
diff --git a/src/hooks/useApprove.ts b/src/hooks/useApprove.ts
index c85ffd42f..b46464314 100644
--- a/src/hooks/useApprove.ts
+++ b/src/hooks/useApprove.ts
@@ -2,31 +2,21 @@ import { ethers } from "ethers"
import { useCallback, useEffect, useMemo, useState } from "react"
import L1_erc20ABI from "@/assets/abis/L1_erc20ABI.json"
-import {
- BATCH_BRIDGE_GATEWAY_PROXY_ADDR,
- BATCH_DEPOSIT_TOKENS,
- GATEWAY_ROUTE_PROXY_ADDR,
- USDC_GATEWAY_PROXY_ADDR,
- USDC_SYMBOL,
- WETH_GATEWAY_PROXY_ADDR,
- WETH_SYMBOL,
-} from "@/constants"
+import { GATEWAY_ROUTE_PROXY_ADDR, USDC_GATEWAY_PROXY_ADDR, USDC_SYMBOL, WETH_GATEWAY_PROXY_ADDR, WETH_SYMBOL } from "@/constants"
import { CHAIN_ID } from "@/constants"
import { useBridgeContext } from "@/contexts/BridgeContextProvider"
import { useRainbowContext } from "@/contexts/RainbowProvider"
-import useBatchBridgeStore, { BridgeSummaryType, DepositBatchMode } from "@/stores/batchBridgeStore"
import { amountToBN } from "@/utils"
const useApprove = (fromNetwork, selectedToken, amount) => {
const { walletCurrentAddress, chainId } = useRainbowContext()
const { networksAndSigners } = useBridgeContext()
- const { bridgeSummaryType, depositBatchMode } = useBatchBridgeStore()
const [isLoading, setIsLoading] = useState(false)
const [isRequested, setIsRequested] = useState(false)
const [error, setError] = useState(null)
- const [isNeeded, setIsNeeded] = useState()
+ const [isNeeded, setIsNeeded] = useState()
const approveAddress = useMemo(() => {
if (!fromNetwork.isL1 && selectedToken.symbol === WETH_SYMBOL) return WETH_GATEWAY_PROXY_ADDR[fromNetwork.chainId]
@@ -61,17 +51,10 @@ const useApprove = (fromNetwork, selectedToken, amount) => {
const parsedAmount = amountToBN(amount, selectedToken.decimals)
const approvedAmount = await tokenInstance.allowance(walletCurrentAddress, approveAddress)
- if (BATCH_DEPOSIT_TOKENS.includes(selectedToken.symbol)) {
- let fastNeedApproval
- let economyNeedApproval
-
- fastNeedApproval = parsedAmount > approvedAmount ? 2 : 0
- const approvedAmount2 = await tokenInstance.allowance(walletCurrentAddress, BATCH_BRIDGE_GATEWAY_PROXY_ADDR[fromNetwork.chainId])
- economyNeedApproval = parsedAmount > approvedAmount2 ? 1 : 0
- return fastNeedApproval | economyNeedApproval
- } else {
- return parsedAmount > approvedAmount
+ if (approvedAmount >= parsedAmount) {
+ return false
}
+ return true
} catch (err) {
return undefined
}
@@ -92,11 +75,7 @@ const useApprove = (fromNetwork, selectedToken, amount) => {
const toApproveAmount = isMaximum ? ethers.MaxUint256 : amountToBN(amount, selectedToken.decimals)
try {
- let proxyAddress = approveAddress
- if (bridgeSummaryType === BridgeSummaryType.Selector && depositBatchMode === DepositBatchMode.Economy) {
- proxyAddress = BATCH_BRIDGE_GATEWAY_PROXY_ADDR[fromNetwork.chainId]
- }
- const tx = await tokenInstance.approve(proxyAddress, toApproveAmount)
+ const tx = await tokenInstance.approve(approveAddress, toApproveAmount)
setIsRequested(true)
await tx?.wait()
const needApproval = await checkApproval()
@@ -111,11 +90,7 @@ const useApprove = (fromNetwork, selectedToken, amount) => {
// TODO: test
const cancelApproval = async () => {
- let proxyAddress = approveAddress
- if (bridgeSummaryType === BridgeSummaryType.Selector && depositBatchMode === DepositBatchMode.Economy) {
- proxyAddress = BATCH_BRIDGE_GATEWAY_PROXY_ADDR[fromNetwork.chainId]
- }
- const tx = await tokenInstance?.approve(proxyAddress, 0)
+ const tx = await tokenInstance?.approve(approveAddress, 0)
await tx?.wait()
const needApproval = await checkApproval()
setIsNeeded(needApproval)
diff --git a/src/hooks/useEstimateBatchDeposit.ts b/src/hooks/useEstimateBatchDeposit.ts
deleted file mode 100644
index ec0360781..000000000
--- a/src/hooks/useEstimateBatchDeposit.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { CHAIN_ID } from "@/constants"
-import { useBridgeContext } from "@/contexts/BridgeContextProvider"
-import { useRainbowContext } from "@/contexts/RainbowProvider"
-import useBatchBridgeStore from "@/stores/batchBridgeStore"
-
-type TxOptions = {
- value: bigint
- maxFeePerGas?: bigint | null
- maxPriorityFeePerGas?: bigint | null
-}
-
-export function useEstimateBatchDeposit(props) {
- const { fromNetwork, selectedToken } = props
- const { checkConnectedChainId, walletCurrentAddress } = useRainbowContext()
- const { batchDepositConfig } = useBatchBridgeStore()
-
- const { networksAndSigners } = useBridgeContext()
-
- const depositETH = async () => {
- const options: TxOptions = {
- value: batchDepositConfig.minAmountPerTx + batchDepositConfig.feeAmountPerTx,
- }
-
- return networksAndSigners[CHAIN_ID.L1].batchBridgeGateway.depositETH.estimateGas(options)
- }
-
- const depositERC20 = async () => {
- return networksAndSigners[CHAIN_ID.L1].batchBridgeGateway.depositERC20.estimateGas(
- selectedToken.address,
- batchDepositConfig.minAmountPerTx + batchDepositConfig.feeAmountPerTx,
- )
- }
-
- const estimateSend = async () => {
- const isNetworkConnected = await checkConnectedChainId(fromNetwork.chainId)
- if (!isNetworkConnected) return BigInt(0)
- const nativeTokenBalance = await networksAndSigners[fromNetwork.chainId].provider.getBalance(walletCurrentAddress)
- if (!nativeTokenBalance) {
- return null
- } else if (fromNetwork.isL1 && batchDepositConfig.minAmountPerTx) {
- return await estimateSendL1ToL2()
- }
- return BigInt(0)
- }
-
- const estimateSendL1ToL2 = () => {
- try {
- if (selectedToken.native) {
- return depositETH()
- } else {
- return depositERC20()
- }
- } catch (error) {
- console.error("estimateSendL1ToL2", error)
- }
- }
-
- return {
- estimateSend,
- }
-}
diff --git a/src/hooks/useGasFee.ts b/src/hooks/useGasFee.ts
index f55d5540d..4447fbe73 100644
--- a/src/hooks/useGasFee.ts
+++ b/src/hooks/useGasFee.ts
@@ -3,16 +3,13 @@ import { isNumber } from "lodash"
import { useCallback, useEffect, useState } from "react"
import { useBlockNumber } from "wagmi"
-import { BATCH_DEPOSIT_TOKENS } from "@/constants"
// import { useBridgeContext } from "@/contexts/BridgeContextProvider"
// import { useBridgeContext } from "@/contexts/BridgeContextProvider"
import { usePriceFeeContext } from "@/contexts/PriceFeeProvider"
import { config } from "@/contexts/RainbowProvider/configs"
-import { DepositBatchMode } from "@/stores/batchBridgeStore"
import useBridgeStore from "@/stores/bridgeStore"
-import { checkApproved, trimErrorMessage } from "@/utils"
+import { trimErrorMessage } from "@/utils"
-import { useEstimateBatchDeposit } from "./useEstimateBatchDeposit"
import { useEstimateSendTransaction } from "./useEstimateSendTransaction"
const useGasFee = (selectedToken, needApproval) => {
@@ -25,16 +22,8 @@ const useGasFee = (selectedToken, needApproval) => {
selectedToken,
})
- const { estimateSend: estimateBatchDeposit } = useEstimateBatchDeposit({
- fromNetwork,
- toNetwork,
- selectedToken,
- })
-
const [gasFee, setGasFee] = useState(null)
- const [batchDepositGasFee, setBatchDepositGasFee] = useState(null)
const [gasLimit, setGasLimit] = useState(null)
- const [gasLimitBatch, setGasLimitBatch] = useState(null)
const [enlargedGasLimit, setEnlargedGasLimit] = useState(null)
const [maxFeePerGas, setMaxFeePerGas] = useState(null)
const [maxPriorityFeePerGas, setMaxPriorityFeePerGas] = useState(null)
@@ -51,7 +40,6 @@ const useGasFee = (selectedToken, needApproval) => {
) {
let gasPrice
let priorityFee
- let gasLimitBatch
// scroll not support EIP-1559
if (fromNetwork.isL1) {
@@ -63,22 +51,11 @@ const useGasFee = (selectedToken, needApproval) => {
gasPrice = legacyGasPrice as bigint
priorityFee = null
}
- const gasLimit = checkApproved(needApproval, DepositBatchMode.Fast) ? await estimateSend() : BigInt(0)
-
- try {
- gasLimitBatch =
- checkApproved(needApproval, DepositBatchMode.Economy) && BATCH_DEPOSIT_TOKENS.includes(selectedToken.symbol)
- ? await estimateBatchDeposit()
- : BigInt(0)
- } catch (error) {
- gasLimitBatch = 100000n
- }
+ const gasLimit = await estimateSend()
if (gasLimit === null) {
return {
gasLimit: null,
- gasLimitBatch: null,
- batchDepositGasFee: null,
enlargedGasLimit: null,
gasFee: null,
gasPrice,
@@ -86,24 +63,19 @@ const useGasFee = (selectedToken, needApproval) => {
}
}
const estimatedGasCost = (gasLimit as bigint) * (gasPrice || BigInt(1e9))
- const estimatedBatchDepositGasCost = (gasLimitBatch as bigint) * (gasPrice || BigInt(1e9))
const enlargedGasLimit = (gasLimit * BigInt(120)) / BigInt(100)
return {
gasLimit,
- gasLimitBatch,
enlargedGasLimit,
gasFee: estimatedGasCost,
- batchDepositGasFee: estimatedBatchDepositGasCost,
gasPrice,
maxPriorityFeePerGas: priorityFee,
}
}
return {
gasLimit: null,
- gasLimitBatch: null,
enlargedGasLimit: null,
gasFee: null,
- batchDepositGasFee: null,
gasPrice: null,
maxPriorityFeePerGas: null,
}
@@ -111,22 +83,18 @@ const useGasFee = (selectedToken, needApproval) => {
useEffect(() => {
calculateGasFee()
- .then(({ gasLimit, enlargedGasLimit, gasFee, gasPrice, maxPriorityFeePerGas, batchDepositGasFee, gasLimitBatch }) => {
+ .then(({ gasLimit, enlargedGasLimit, gasFee, gasPrice, maxPriorityFeePerGas }) => {
setGasLimit(gasLimit)
- setGasLimitBatch(gasLimitBatch)
setEnlargedGasLimit(enlargedGasLimit)
setGasFee(gasFee)
- setBatchDepositGasFee(batchDepositGasFee)
setMaxFeePerGas(gasPrice)
setMaxPriorityFeePerGas(maxPriorityFeePerGas)
setError("")
})
.catch(error => {
setGasLimit(null)
- setGasLimitBatch(null)
setEnlargedGasLimit(null)
setGasFee(null)
- setBatchDepositGasFee(null)
setMaxFeePerGas(null)
setMaxPriorityFeePerGas(null)
setError(trimErrorMessage(error.message))
@@ -134,7 +102,7 @@ const useGasFee = (selectedToken, needApproval) => {
})
}, [calculateGasFee])
- return { enlargedGasLimit, gasLimit, gasLimitBatch, gasFee, error, calculateGasFee, maxFeePerGas, maxPriorityFeePerGas, batchDepositGasFee }
+ return { enlargedGasLimit, gasLimit, gasFee, error, calculateGasFee, maxFeePerGas, maxPriorityFeePerGas }
}
export default useGasFee
diff --git a/src/hooks/useSendTransaction.ts b/src/hooks/useSendTransaction.ts
index ab90b5dac..292b75f74 100644
--- a/src/hooks/useSendTransaction.ts
+++ b/src/hooks/useSendTransaction.ts
@@ -5,7 +5,6 @@ import { CHAIN_ID, NETWORKS, TX_STATUS } from "@/constants"
import { useBridgeContext } from "@/contexts/BridgeContextProvider"
import { usePriceFeeContext } from "@/contexts/PriceFeeProvider"
import { useRainbowContext } from "@/contexts/RainbowProvider"
-import useBatchBridgeStore, { BridgeSummaryType, DepositBatchMode } from "@/stores/batchBridgeStore"
import useBridgeStore from "@/stores/bridgeStore"
import useTxStore from "@/stores/txStore"
import { isValidOffsetTime } from "@/stores/utils"
@@ -17,20 +16,15 @@ type TxOptions = {
value: bigint
maxFeePerGas?: bigint | null
maxPriorityFeePerGas?: bigint | null
- gasLimit?: number | null
}
-const LOWER_BOUND = 1e5
-
export function useSendTransaction(props) {
- const { amount: fromTokenAmount, selectedToken, receiver, needApproval } = props
+ const { amount: fromTokenAmount, selectedToken, receiver } = props
const { walletCurrentAddress } = useRainbowContext()
const { networksAndSigners, blockNumbers } = useBridgeContext()
- const { enlargedGasLimit: txGasLimit, gasLimitBatch } = useGasFee(selectedToken, needApproval)
+ const { enlargedGasLimit: txGasLimit } = useGasFee(selectedToken, false)
const { addTransaction, addEstimatedTimeMap, removeFrontTransactions, updateTransaction } = useTxStore()
const { fromNetwork, toNetwork, changeTxResult, changeWithdrawStep } = useBridgeStore()
- const { bridgeSummaryType, depositBatchMode, batchDepositConfig } = useBatchBridgeStore()
-
const { gasLimit, gasPrice } = usePriceFeeContext()
const [isLoading, setIsLoading] = useState(false)
@@ -44,24 +38,18 @@ export function useSendTransaction(props) {
const send = async () => {
setIsLoading(true)
let tx
- const isBatchMode = bridgeSummaryType === BridgeSummaryType.Selector && depositBatchMode === DepositBatchMode.Economy
- // let currentBlockNumber
+ let currentBlockNumber
try {
- if (isBatchMode) {
- // currentBlockNumber = await networksAndSigners[CHAIN_ID.L1].provider.getBlockNumber()
- tx = await batchSendL1ToL2()
- setIsLoading(false)
- } else if (fromNetwork.isL1) {
- // currentBlockNumber = await networksAndSigners[CHAIN_ID.L1].provider.getBlockNumber()
+ if (fromNetwork.isL1) {
+ currentBlockNumber = await networksAndSigners[CHAIN_ID.L1].provider.getBlockNumber()
tx = await sendl1ToL2()
} else if (!fromNetwork.isL1 && toNetwork.isL1) {
- // currentBlockNumber = await networksAndSigners[CHAIN_ID.L2].provider.getBlockNumber()
+ currentBlockNumber = await networksAndSigners[CHAIN_ID.L2].provider.getBlockNumber()
tx = await sendl2ToL1()
}
-
// start to check tx replacement from current block number
// TODO: shouldn't add it here(by @ricmoo)
- // tx = tx.replaceableTransaction(currentBlockNumber)
+ tx = tx.replaceableTransaction(currentBlockNumber)
handleTransaction(tx)
tx.wait()
@@ -75,9 +63,7 @@ export function useSendTransaction(props) {
fromBlockNumber: receipt.blockNumber,
})
if (fromNetwork.isL1) {
- const estimatedOffsetTime = isBatchMode
- ? (receipt.blockNumber - blockNumbers[0]) * 12 * 1000 + 1000 * 60 * 10
- : (receipt.blockNumber - blockNumbers[0]) * 12 * 1000
+ const estimatedOffsetTime = (receipt.blockNumber - blockNumbers[0]) * 12 * 1000
if (isValidOffsetTime(estimatedOffsetTime)) {
addEstimatedTimeMap(`from_${tx.hash}`, Date.now() + estimatedOffsetTime)
} else {
@@ -106,9 +92,7 @@ export function useSendTransaction(props) {
hash: transactionHash,
})
if (fromNetwork.isL1) {
- const estimatedOffsetTime = isBatchMode
- ? (blockNumber - blockNumbers[0]) * 12 * 1000 + 1000 * 60 * 10
- : (blockNumber - blockNumbers[0]) * 12 * 1000
+ const estimatedOffsetTime = (blockNumber - blockNumbers[0]) * 12 * 1000
if (isValidOffsetTime(estimatedOffsetTime)) {
addEstimatedTimeMap(`from_${transactionHash}`, Date.now() + estimatedOffsetTime)
} else {
@@ -131,7 +115,6 @@ export function useSendTransaction(props) {
if (isError(error, "ACTION_REJECTED")) {
setSendError("reject")
} else {
- console.log(error, "error")
setSendError(error)
}
}
@@ -217,30 +200,6 @@ export function useSendTransaction(props) {
})
}
- const batchDepositETH = async () => {
- const options: TxOptions = {
- value: parsedAmount + batchDepositConfig.feeAmountPerTx,
- gasLimit: Math.max(Number(gasLimitBatch), LOWER_BOUND),
- }
-
- return networksAndSigners[CHAIN_ID.L1].batchBridgeGateway.depositETH(options)
- }
-
- const batchDepositERC20 = async () => {
- // const options: TxOptions = {
- // value: batchDepositConfig.feeAmountPerTx,
- // }
- return networksAndSigners[CHAIN_ID.L1].batchBridgeGateway.depositERC20(selectedToken.address, parsedAmount + batchDepositConfig.feeAmountPerTx)
- }
-
- const batchSendL1ToL2 = () => {
- if (selectedToken.native) {
- return batchDepositETH()
- } else {
- return batchDepositERC20()
- }
- }
-
const sendl1ToL2 = () => {
if (selectedToken.native) {
return depositETH()
diff --git a/src/hooks/useTxHistory.ts b/src/hooks/useTxHistory.ts
index 88beec149..872c3f2dd 100644
--- a/src/hooks/useTxHistory.ts
+++ b/src/hooks/useTxHistory.ts
@@ -38,9 +38,7 @@ const useTxHistory = () => {
// fetch to hash/blockNumber from backend
const { data } = useSWR(
() => {
- const needToRefreshTransactions = pageTransactions.filter(
- item => item.txStatus !== TX_STATUS.Relayed && item.txStatus !== TX_STATUS.BatchDepositRelayed,
- )
+ const needToRefreshTransactions = pageTransactions.filter(item => item.txStatus !== TX_STATUS.Relayed)
if (needToRefreshTransactions.length && walletCurrentAddress && historyVisible) {
const txs = needToRefreshTransactions.map(item => item.hash).filter((item, index, arr) => index === arr.indexOf(item))
diff --git a/src/pages/bridge/Send/SendTransaction/DepositSelector/EconomyTooltip.tsx b/src/pages/bridge/Send/SendTransaction/DepositSelector/EconomyTooltip.tsx
deleted file mode 100644
index 68fb01ef4..000000000
--- a/src/pages/bridge/Send/SendTransaction/DepositSelector/EconomyTooltip.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { useMemo } from "react"
-
-// import { makeStyles } from "tss-react/mui"
-import { SvgIcon, Typography } from "@mui/material"
-
-import { ReactComponent as InfoSvg } from "@/assets/svgs/common/info.svg"
-import useBatchBridgeStore from "@/stores/batchBridgeStore"
-import { toTokenDisplay } from "@/utils"
-
-const EconomyTooltip = props => {
- const { selectedToken } = props
- const { batchDepositConfig } = useBatchBridgeStore()
-
- const minAmount = useMemo(() => {
- if (batchDepositConfig.minAmountPerTx) {
- return toTokenDisplay(batchDepositConfig.minAmountPerTx, selectedToken.decimals, selectedToken.symbol)
- }
- }, [batchDepositConfig])
-
- return (
-
- You can only use "Economy"
- for deposit more than {minAmount}
-
- )
-}
-
-export default EconomyTooltip
diff --git a/src/pages/bridge/Send/SendTransaction/DepositSelector/index.tsx b/src/pages/bridge/Send/SendTransaction/DepositSelector/index.tsx
deleted file mode 100644
index 8f1cb64bd..000000000
--- a/src/pages/bridge/Send/SendTransaction/DepositSelector/index.tsx
+++ /dev/null
@@ -1,269 +0,0 @@
-import { useCallback, useEffect, useMemo, useState } from "react"
-import { makeStyles } from "tss-react/mui"
-
-import { Box, Card, Grid, Stack, SvgIcon, Typography } from "@mui/material"
-
-import { ReactComponent as SelectedSvg } from "@/assets/svgs/bridge/approve-token-selected.svg"
-import { ETH_SYMBOL } from "@/constants"
-import { useBridgeContext } from "@/contexts/BridgeContextProvider"
-import useCheckViewport from "@/hooks/useCheckViewport"
-import useBatchBridgeStore, { DepositBatchMode } from "@/stores/batchBridgeStore"
-import useBridgeStore from "@/stores/bridgeStore"
-import { BNToAmount, checkApproved, toTokenDisplay } from "@/utils"
-import { formatAmount } from "@/utils"
-
-import EconomyTooltip from "./EconomyTooltip"
-
-type TransactionValue = bigint | null
-
-const DEPOSIT_OPTIONS = [
- {
- title: "Fast ⚡️",
- type: DepositBatchMode.Fast,
- time: "20 min",
- },
- {
- title: "Economy 💰",
- type: DepositBatchMode.Economy,
- time: "30 min ~ 1 hour",
- },
-]
-
-const useStyles = makeStyles()(theme => ({
- cardRoot: {
- position: "relative",
- borderRadius: "2rem",
- backgroundColor: theme.palette.themeBackground.light,
- padding: "2.7rem 1.5rem 3.1rem",
- display: "flex",
- overflow: "visible",
- cursor: "pointer",
- flex: 1,
- border: "1px solid transparent",
- transition: "backgroundColor 0.3s ease",
-
- "&:hover": {
- backgroundColor: theme.palette.background.default,
- },
-
- [theme.breakpoints.down("sm")]: {
- aspectRatio: "unset",
- justifyContent: "center",
- },
- },
- invaildCard: {
- opacity: 0.6,
- pointerEvents: "none",
- },
- selectedCard: {
- border: `1px solid ${theme.palette.text.primary}`,
- backgroundColor: theme.palette.background.default,
- },
- selectedIcon: {
- fontSize: "3.2rem",
- position: "absolute",
- right: "0.8rem",
- top: "0.8rem",
- },
- label: {
- fontSize: "1.6rem",
- lineHeight: "2.4rem",
- fontWeight: 700,
- fontFamily: "var(--default-font-family) !important",
- },
- info: {
- fontSize: "1.6rem",
- lineHeight: "2.4rem",
- display: "flex",
- justifyContent: "flex-end",
- },
- price: {
- fontSize: "1.4rem",
- lineHeight: "2.4rem",
- color: "#5B5B5B",
- marginLeft: "0.6rem",
- },
- subheader: {
- fontSize: "1.2rem",
- lineHeight: "2.4rem",
- color: "#5B5B5B",
- fontWeight: 700,
- textTransform: "uppercase",
- fontFamily: "var(--default-font-family) !important",
- },
-}))
-
-const CustomTypography = ({ isError, ...props }) =>
-
-const DepositSelector = props => {
- const { amount, feeError, l1GasFee, l2GasFee, l1EconomyGasFee, l2EconomyGasFee, needApproval, selectedToken, isVaild } = props
- const { isMobile } = useCheckViewport()
- const { classes, cx } = useStyles()
-
- const [selectedType, setSelectedType] = useState(DepositBatchMode.Fast)
- const { isNetworkCorrect } = useBridgeStore()
- const { changeDepositBatchMode, depositBatchMode } = useBatchBridgeStore()
- const { tokenPrice } = useBridgeContext()
-
- const handleSelect = value => {
- setSelectedType(value)
- }
-
- useEffect(() => {
- changeDepositBatchMode(selectedType)
- }, [selectedType])
-
- const allowDisplayValue = useMemo(() => {
- return isNetworkCorrect && amount && !feeError
- }, [isNetworkCorrect, amount, feeError, depositBatchMode])
-
- const showFeeError = useMemo(() => {
- return !!feeError && amount && !needApproval
- }, [feeError, amount, needApproval])
-
- const getDisplayedPrice = useCallback(
- (amount = "", tokenAddress = "ethereum") => {
- if (allowDisplayValue && tokenPrice.price?.[tokenAddress.toLowerCase()]) {
- return (+amount * tokenPrice.price[tokenAddress.toLowerCase()].usd).toFixed(2)
- }
- return ""
- },
- [allowDisplayValue, showFeeError, tokenPrice],
- )
-
- const getDisplayedValue = useCallback(
- (value: TransactionValue = BigInt(0), decimals = BigInt(18), symbol = ETH_SYMBOL) => {
- if (allowDisplayValue) {
- return toTokenDisplay(value, decimals, symbol)
- }
- return -
- },
- [allowDisplayValue, showFeeError],
- )
-
- const displayedL1Fee = useMemo(() => {
- let displayedFee = "-"
- let displayedPrice = ""
- if (checkApproved(needApproval, DepositBatchMode.Fast) && allowDisplayValue) {
- displayedFee = getDisplayedValue(l1GasFee) as any
- displayedPrice = getDisplayedPrice(BNToAmount(l1GasFee as bigint))
- }
- let displayedBatchFee = "-"
- let displayedBatchPrice = ""
- if (checkApproved(needApproval, DepositBatchMode.Economy) && allowDisplayValue) {
- displayedBatchFee = getDisplayedValue(l1EconomyGasFee) as any
- displayedBatchPrice = getDisplayedPrice(BNToAmount(l1EconomyGasFee as bigint))
- }
- return {
- [DepositBatchMode.Fast]: {
- value: displayedFee,
- price: displayedPrice,
- },
- [DepositBatchMode.Economy]: {
- value: displayedBatchFee,
- price: displayedBatchPrice,
- },
- }
- }, [l1GasFee, l1EconomyGasFee, getDisplayedValue, getDisplayedPrice, needApproval, allowDisplayValue])
-
- const displayedL2Fee = useMemo(() => {
- let displayedFee = "-"
- let displayedPrice = ""
- if (checkApproved(needApproval, DepositBatchMode.Fast) && allowDisplayValue) {
- displayedFee = getDisplayedValue(l2GasFee) as any
- displayedPrice = getDisplayedPrice(BNToAmount(l2GasFee as bigint))
- }
- let displayedBatchFee = "-"
- let displayedBatchPrice = ""
- if (checkApproved(needApproval, DepositBatchMode.Economy) && allowDisplayValue) {
- displayedBatchFee = getDisplayedValue(l2EconomyGasFee, selectedToken.decimals, selectedToken.symbol) as any
- displayedBatchPrice = getDisplayedPrice(BNToAmount(l2EconomyGasFee as bigint))
- }
- return {
- [DepositBatchMode.Fast]: {
- value: displayedFee,
- price: displayedPrice,
- },
- [DepositBatchMode.Economy]: {
- value: displayedBatchFee,
- price: displayedBatchPrice,
- },
- }
- }, [l2GasFee, l2EconomyGasFee, getDisplayedValue, getDisplayedPrice, needApproval, allowDisplayValue])
-
- return (
-
-
- {DEPOSIT_OPTIONS.map((item, idx) => (
- handleSelect(item.type)}
- >
- {item.type === selectedType && }
-
-
- {item.title}
-
-
-
- Time
-
-
- {item.time}
-
-
-
- Gas fee
-
-
-
- Ethereum
-
-
- {displayedL1Fee[DepositBatchMode[item.type]].value}
-
- {displayedL1Fee[DepositBatchMode[item.type]]?.price ? ` $${formatAmount(displayedL1Fee[DepositBatchMode[item.type]].price)}` : ""}
-
-
-
-
-
-
- Scroll
-
-
- {displayedL2Fee[DepositBatchMode[item.type]].value}
-
- {displayedL1Fee[DepositBatchMode[item.type]]?.price
- ? ` $${formatAmount(displayedL2Fee[DepositBatchMode[item.type]].price)}`
- : " "}
-
-
-
-
-
- ))}
-
- {!isVaild && }
-
- )
-}
-
-export default DepositSelector
diff --git a/src/pages/bridge/Send/SendTransaction/hooks/useBatchDeposit.ts b/src/pages/bridge/Send/SendTransaction/hooks/useBatchDeposit.ts
deleted file mode 100644
index bfd77afd5..000000000
--- a/src/pages/bridge/Send/SendTransaction/hooks/useBatchDeposit.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { ethers } from "ethers"
-import { useEffect, useMemo } from "react"
-
-import { BATCH_DEPOSIT_TOKENS, CHAIN_ID } from "@/constants"
-import { useBridgeContext } from "@/contexts/BridgeContextProvider"
-import useBatchBridgeStore, { BridgeSummaryType } from "@/stores/batchBridgeStore"
-import useBridgeStore from "@/stores/bridgeStore"
-import { BNToAmount } from "@/utils"
-
-export default function useBatchDeposit(props) {
- const { selectedToken, amount } = props
- const { networksAndSigners } = useBridgeContext()
- const { txType, isNetworkCorrect } = useBridgeStore()
- const { batchDepositConfig, changeBatchDepositConfig, changeBridgeSummaryType } = useBatchBridgeStore()
-
- const getBatchDepositConfigsByToken = async selectedToken => {
- return networksAndSigners[CHAIN_ID.L1].batchBridgeGateway.configs(selectedToken.address || ethers.ZeroAddress)
- }
-
- const enableBatchDeposit = useMemo(() => {
- return BATCH_DEPOSIT_TOKENS.includes(selectedToken.symbol)
- }, [selectedToken])
-
- // < 0.001 need special check for economy mode
- const depositAmountIsVaild = useMemo(() => {
- const minAmount = BNToAmount(batchDepositConfig.minAmountPerTx, selectedToken.decimals)
- if (amount && txType === "Deposit" && enableBatchDeposit) {
- return amount >= minAmount
- }
- return true
- }, [batchDepositConfig, amount, selectedToken, txType, enableBatchDeposit])
-
- useEffect(() => {
- if (txType === "Deposit" && enableBatchDeposit) {
- changeBridgeSummaryType(BridgeSummaryType.Selector)
- if (networksAndSigners[CHAIN_ID.L1].signer) {
- getBatchDepositConfigsByToken(selectedToken)
- .then(configs => {
- changeBatchDepositConfig(configs)
- })
- .catch(err => {
- console.error("getBatchDepositConfigsByToken", err)
- })
- }
- } else {
- changeBridgeSummaryType(BridgeSummaryType.Summary)
- }
- }, [txType, isNetworkCorrect, enableBatchDeposit, networksAndSigners, selectedToken])
-
- return {
- getBatchDepositConfigsByToken,
- depositAmountIsVaild,
- }
-}
diff --git a/src/pages/bridge/Send/SendTransaction/index.tsx b/src/pages/bridge/Send/SendTransaction/index.tsx
index 1dac141a3..1d6fbcf75 100644
--- a/src/pages/bridge/Send/SendTransaction/index.tsx
+++ b/src/pages/bridge/Send/SendTransaction/index.tsx
@@ -18,17 +18,14 @@ import useCheckViewport from "@/hooks/useCheckViewport"
import useGasFee from "@/hooks/useGasFee"
import { useSendTransaction } from "@/hooks/useSendTransaction"
import useSufficientBalance from "@/hooks/useSufficientBalance"
-import useBatchBridgeStore, { BridgeSummaryType, DepositBatchMode } from "@/stores/batchBridgeStore"
import useBridgeStore from "@/stores/bridgeStore"
-import { amountToBN, checkApproved, switchNetwork, trimErrorMessage } from "@/utils"
+import { amountToBN, switchNetwork, trimErrorMessage } from "@/utils"
import ApprovalDialog from "./ApprovalDialog"
import BalanceInput from "./BalanceInput"
import CustomiseRecipient from "./CustomiseRecipient"
-import DepositSelector from "./DepositSelector"
import NetworkDirection from "./NetworkDirection"
import TransactionSummary from "./TransactionSummary"
-import useBatchDeposit from "./hooks/useBatchDeposit"
const SendTransaction = props => {
const [searchParams, setSearchParams] = useSearchParams()
@@ -43,7 +40,6 @@ const SendTransaction = props => {
const { gasLimit, gasPrice, errorMessage: relayFeeErrorMessage, fetchData: fetchPriceFee, getL1DataFee } = usePriceFeeContext()
const { txType, isNetworkCorrect, fromNetwork, changeTxResult } = useBridgeStore()
- const { bridgeSummaryType, depositBatchMode, batchDepositConfig } = useBatchBridgeStore()
const [amount, setAmount] = useState("")
@@ -72,7 +68,6 @@ const SendTransaction = props => {
isRequested: isRequestedApproval,
isLoading: approveLoading,
} = useApprove(fromNetwork, selectedToken, validAmount)
-
const {
send: sendTransaction,
isLoading: sendLoading,
@@ -81,19 +76,10 @@ const SendTransaction = props => {
amount: validAmount,
selectedToken,
receiver: recipient,
- needApproval,
})
- const { depositAmountIsVaild } = useBatchDeposit({ selectedToken, amount: validAmount })
-
// fee start
- const {
- gasFee: estimatedGasCost,
- batchDepositGasFee: estimatedBatchDepositGasCost,
- gasLimit: txGasLimit,
- error: gasFeeErrorMessage,
- calculateGasFee,
- } = useGasFee(selectedToken, needApproval)
+ const { gasFee: estimatedGasCost, gasLimit: txGasLimit, error: gasFeeErrorMessage, calculateGasFee } = useGasFee(selectedToken, needApproval)
const l1DataFee = useAsyncMemo(
async () =>
@@ -102,25 +88,11 @@ const SendTransaction = props => {
: BigInt(0),
[amount, selectedToken, txGasLimit, txType],
)
- const relayFee = useMemo(() => gasLimit * gasPrice, [gasLimit, gasPrice])
-
- const l1GasFee = useMemo(() => {
- if (depositBatchMode === DepositBatchMode.Economy && bridgeSummaryType === BridgeSummaryType.Selector) {
- return estimatedBatchDepositGasCost
- }
- return estimatedGasCost
- }, [depositBatchMode, bridgeSummaryType, estimatedBatchDepositGasCost, estimatedGasCost])
-
- const l2GasFee = useMemo(() => {
- if (depositBatchMode === DepositBatchMode.Economy && bridgeSummaryType === BridgeSummaryType.Selector) {
- return batchDepositConfig.feeAmountPerTx
- }
- return relayFee
- }, [depositBatchMode, bridgeSummaryType, batchDepositConfig, relayFee])
+ const relayFee = useMemo(() => gasLimit * gasPrice, [gasLimit, gasPrice])
const totalFee = useMemo(
- () => (l1GasFee && !relayFeeErrorMessage ? l1GasFee + l2GasFee + (l1DataFee ?? BigInt(0)) : null),
- [l1GasFee, relayFeeErrorMessage, l2GasFee, l1DataFee],
+ () => (estimatedGasCost && !relayFeeErrorMessage ? estimatedGasCost + relayFee + (l1DataFee ?? BigInt(0)) : null),
+ [estimatedGasCost, relayFeeErrorMessage, relayFee, l1DataFee],
)
const { insufficientWarning } = useSufficientBalance(
@@ -180,8 +152,8 @@ const SendTransaction = props => {
// fee end
const necessaryCondition = useMemo(() => {
- return validAmount && !bridgeWarning && (depositAmountIsVaild || (!depositAmountIsVaild && depositBatchMode === DepositBatchMode.Fast))
- }, [validAmount, bridgeWarning, depositAmountIsVaild, depositBatchMode])
+ return validAmount && !bridgeWarning
+ }, [validAmount, bridgeWarning])
const sendText = useMemo(() => {
if (txType === "Deposit" && sendLoading) {
@@ -264,11 +236,7 @@ const SendTransaction = props => {
)
}
- if (
- needApproval === true ||
- (!checkApproved(needApproval, DepositBatchMode.Economy) && depositBatchMode === DepositBatchMode.Economy) ||
- (!checkApproved(needApproval, DepositBatchMode.Fast) && depositBatchMode === DepositBatchMode.Fast)
- ) {
+ if (needApproval) {
return (