11import { useCallback , useState } from 'react'
22import BigNumber from 'bignumber.js'
33import type { SwapParameters } from '@uniswap/v2-sdk'
4- import { GasOptionConfig , TransactionState , TransactionStateType , useAccount , useWeb3 } from '@masknet/web3-shared-evm'
4+ import {
5+ GasOptionConfig ,
6+ TransactionState ,
7+ TransactionStateType ,
8+ useAccount ,
9+ useWeb3 ,
10+ ChainId ,
11+ } from '@masknet/web3-shared-evm'
512import { useSwapParameters as useTradeParameters } from './useTradeParameters'
613import type { SwapCall , Trade , TradeComputed } from '../../types'
714import { swapErrorToUserReadableMessage } from '../../helpers'
8- import type { TradeProvider } from '@masknet/public-api'
15+ import { TradeProvider } from '@masknet/public-api'
916import { TargetChainIdContext } from '../useTargetChainIdContext'
1017import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx'
1118
@@ -28,6 +35,8 @@ interface FailedCall extends SwapCallEstimate {
2835 error : Error
2936}
3037
38+ const SUPPORTED_OPTMISTIC_CHAIN_ID_LIST = [ ChainId . Optimistic , ChainId . Boba , ChainId . Metis ]
39+
3140export function useTradeCallback (
3241 trade : TradeComputed < Trade > | null ,
3342 tradeProvider ?: TradeProvider ,
@@ -123,8 +132,8 @@ export function useTradeCallback(
123132 bestCallOption = firstNoErrorCall
124133 }
125134
126- // check if boba network
127- if ( targetChainId === 288 ) {
135+ // check if optimistic network
136+ if ( SUPPORTED_OPTMISTIC_CHAIN_ID_LIST && ! ! TradeProvider . OPENOCEAN && ! ! TradeProvider . DODO ) {
128137 return new Promise < string > ( async ( resolve , reject ) => {
129138 if ( ! bestCallOption ) {
130139 setTradeState ( {
@@ -145,8 +154,8 @@ export function useTradeCallback(
145154 ...( 'gasEstimate' in bestCallOption
146155 ? {
147156 gas : bestCallOption . gasEstimate . toFixed ( ) ,
148- maxFeePerGas : '1.5' ,
149- maxPriorityFeePerGas : '1.5' ,
157+ maxFeePerGas : gasConfig ?. maxFeePerGas ,
158+ maxPriorityFeePerGas : gasConfig ?. maxPriorityFeePerGas ,
150159 }
151160 : { } ) ,
152161 ...( ! value || / ^ 0 x 0 * $ / . test ( value ) ? { } : { value } ) ,
0 commit comments