diff --git a/src/containers/EvmCrossChainRecoveryWallet/ColdWalletForm.tsx b/src/containers/EvmCrossChainRecoveryWallet/ColdWalletForm.tsx index fecfb5fd..43452d97 100644 --- a/src/containers/EvmCrossChainRecoveryWallet/ColdWalletForm.tsx +++ b/src/containers/EvmCrossChainRecoveryWallet/ColdWalletForm.tsx @@ -9,10 +9,9 @@ const validationSchema = Yup.object({ gasLimit: Yup.number() .typeError('Gas limit must be a number') .integer() - .positive('Gas limit must be a positive integer') - .required(), - maxFeePerGas: Yup.number().required(), - maxPriorityFeePerGas: Yup.number().required(), + .positive('Gas limit must be a positive integer'), + maxFeePerGas: Yup.number(), + maxPriorityFeePerGas: Yup.number(), recoveryDestination: Yup.string().required(), userKey: Yup.string().required(), userKeyId: Yup.string(), @@ -21,7 +20,7 @@ const validationSchema = Yup.object({ apiKey: Yup.string().required(), wrongChain: Yup.string().required(), intendedChain: Yup.string().required(), - gasPrice: Yup.number().required(), + gasPrice: Yup.number(), }).required(); export type FormProps = { @@ -38,9 +37,9 @@ export function ColdWalletForm({ onSubmit }: FormProps) { onSubmit, initialValues: { bitgoFeeAddress: '', - gasLimit: 500000, - maxFeePerGas: 500, - maxPriorityFeePerGas: 50, + gasLimit: undefined, + maxFeePerGas: undefined, + maxPriorityFeePerGas: undefined, recoveryDestination: '', userKey: '', userKeyId: '', @@ -49,7 +48,7 @@ export function ColdWalletForm({ onSubmit }: FormProps) { apiKey: '', wrongChain: '', intendedChain: '', - gasPrice: 20, + gasPrice: undefined, }, validationSchema, }); diff --git a/src/containers/EvmCrossChainRecoveryWallet/EvmCrossChainRecoveryBaseForm.tsx b/src/containers/EvmCrossChainRecoveryWallet/EvmCrossChainRecoveryBaseForm.tsx index 73946fa8..9f5ace01 100644 --- a/src/containers/EvmCrossChainRecoveryWallet/EvmCrossChainRecoveryBaseForm.tsx +++ b/src/containers/EvmCrossChainRecoveryWallet/EvmCrossChainRecoveryBaseForm.tsx @@ -23,9 +23,6 @@ export function EvmCrossChainRecoveryBaseForm({ const [intendedChainCoins, setIntendedChainCoins] = useState< readonly CoinMetadata[] >([]); - const [gasLimit, setGasLimit] = useState(500000); - const [maxFeePerGas, setMaxFeePerGas] = useState(500); - const [maxPriorityFeePerGas, setMaxPriorityFeePerGas] = useState(50); const { env } = useParams<'env'>(); const { wallet } = useParams<'wallet'>(); const isCustodyWallet = wallet === allWalletMetas.custody.value; @@ -53,11 +50,6 @@ export function EvmCrossChainRecoveryBaseForm({ setDisabled(false); const intendedChainCoins = evmCCRIntendedChainCoins[wrongChainName]; setIntendedChainCoins(intendedChainCoins); - setGasLimit(allCoinMetas[wrongChainName]?.defaultGasLimitNum ?? 500000); - setMaxFeePerGas(allCoinMetas[wrongChainName]?.defaultMaxFeePerGas ?? 500); - setMaxPriorityFeePerGas( - allCoinMetas[wrongChainName]?.defaultMaxPriorityFeePerGas ?? 50 - ); }; const getIntendedChainCoins = () => { @@ -132,8 +124,8 @@ export function EvmCrossChainRecoveryBaseForm({ {!isCustodyWallet && (
@@ -144,8 +136,8 @@ export function EvmCrossChainRecoveryBaseForm({ <>
@@ -153,8 +145,8 @@ export function EvmCrossChainRecoveryBaseForm({
@@ -165,8 +157,8 @@ export function EvmCrossChainRecoveryBaseForm({ {!isCustodyWallet && isBscChain(wrongChain) && (
diff --git a/src/containers/EvmCrossChainRecoveryWallet/EvmCrossChainRecoveryWallet.tsx b/src/containers/EvmCrossChainRecoveryWallet/EvmCrossChainRecoveryWallet.tsx index 8d945fda..3ff96da8 100644 --- a/src/containers/EvmCrossChainRecoveryWallet/EvmCrossChainRecoveryWallet.tsx +++ b/src/containers/EvmCrossChainRecoveryWallet/EvmCrossChainRecoveryWallet.tsx @@ -44,11 +44,11 @@ interface CustodyWalletParams extends BaseParams { interface NonCustodyWalletParams extends BaseParams { walletContractAddress: string; bitgoFeeAddress: string; - gasLimit: number; - maxFeePerGas: number; - maxPriorityFeePerGas: number; + gasLimit?: number; + maxFeePerGas?: number; + maxPriorityFeePerGas?: number; apiKey: string; - gasPrice: number; + gasPrice?: number; } interface HotWalletParams extends NonCustodyWalletParams { @@ -181,7 +181,9 @@ async function handleNonCustodyFormSubmit( values.wrongChain, values as ColdWalletParams ); - values.gasPrice = toWei(values.gasPrice); + if (values.gasPrice) { + values.gasPrice = toWei(values.gasPrice); + } const recoverData = await window.commands.recover(values.wrongChain, { ...values, eip1559: getEip1559Params(values.wrongChain, maxFeePerGas, maxPriorityFeePerGas), diff --git a/src/containers/EvmCrossChainRecoveryWallet/HotWalletForm.tsx b/src/containers/EvmCrossChainRecoveryWallet/HotWalletForm.tsx index 3c2c7e0e..3b2b0d08 100644 --- a/src/containers/EvmCrossChainRecoveryWallet/HotWalletForm.tsx +++ b/src/containers/EvmCrossChainRecoveryWallet/HotWalletForm.tsx @@ -10,10 +10,9 @@ const validationSchema = Yup.object({ gasLimit: Yup.number() .typeError('Gas limit must be a number') .integer() - .positive('Gas limit must be a positive integer') - .required(), - maxFeePerGas: Yup.number().required(), - maxPriorityFeePerGas: Yup.number().required(), + .positive('Gas limit must be a positive integer'), + maxFeePerGas: Yup.number(), + maxPriorityFeePerGas: Yup.number(), recoveryDestination: Yup.string().required(), walletContractAddress: Yup.string().required(), walletPassphrase: Yup.string().required(), @@ -21,7 +20,7 @@ const validationSchema = Yup.object({ apiKey: Yup.string().required(), wrongChain: Yup.string().required(), intendedChain: Yup.string().required(), - gasPrice: Yup.number().required(), + gasPrice: Yup.number(), }).required(); export type FormProps = { @@ -39,9 +38,9 @@ export function HotWalletForm({ onSubmit }: FormProps) { initialValues: { userKey: '', bitgoFeeAddress: '', - gasLimit: 500000, - maxFeePerGas: 500, - maxPriorityFeePerGas: 50, + gasLimit: undefined, + maxFeePerGas: undefined, + maxPriorityFeePerGas: undefined, recoveryDestination: '', walletContractAddress: '', walletPassphrase: '', @@ -49,7 +48,7 @@ export function HotWalletForm({ onSubmit }: FormProps) { apiKey: '', wrongChain: '', intendedChain: '', - gasPrice: 20, + gasPrice: undefined, }, validationSchema, }); diff --git a/src/helpers/index.ts b/src/helpers/index.ts index 3604c9c1..3cf0903e 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -264,9 +264,9 @@ export function isEtcChain(coin: string) { return (coin === 'etc' || coin === 'tetc') } -export function getEip1559Params(coin: string, maxFeePerGas: number, maxPriorityFeePerGas: number) { +export function getEip1559Params(coin: string, maxFeePerGas?: number, maxPriorityFeePerGas?: number) { // bsc/tbsc and etc/tetc doesn't support EIP-1559 - if (isBscChain(coin) || isEtcChain(coin)) { + if (isBscChain(coin) || isEtcChain(coin) || !maxFeePerGas || !maxPriorityFeePerGas) { return undefined; } return {