Skip to content

Commit

Permalink
fix(wrw): remove gas fields from EVM CCR FORM and bump sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
venkateshv1266 committed Sep 17, 2024
1 parent c085651 commit 09809f9
Show file tree
Hide file tree
Showing 7 changed files with 336 additions and 419 deletions.
584 changes: 292 additions & 292 deletions package-lock.json

Large diffs are not rendered by default.

82 changes: 41 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,47 @@
}
},
"dependencies": {
"@bitgo/abstract-cosmos": "11.0.3",
"@bitgo/abstract-utxo": "8.14.0",
"@bitgo/sdk-api": "1.53.3",
"@bitgo/sdk-coin-ada": "4.2.12",
"@bitgo/sdk-coin-algo": "2.1.32",
"@bitgo/sdk-coin-arbeth": "21.0.26",
"@bitgo/sdk-coin-atom": "13.0.3",
"@bitgo/sdk-coin-avaxc": "5.0.26",
"@bitgo/sdk-coin-bch": "2.0.34",
"@bitgo/sdk-coin-bcha": "2.1.18",
"@bitgo/sdk-coin-bld": "3.0.3",
"@bitgo/sdk-coin-bsc": "22.1.18",
"@bitgo/sdk-coin-bsv": "2.0.34",
"@bitgo/sdk-coin-btc": "2.2.5",
"@bitgo/sdk-coin-btg": "2.0.34",
"@bitgo/sdk-coin-coreum": "21.0.3",
"@bitgo/sdk-coin-dash": "2.0.34",
"@bitgo/sdk-coin-doge": "2.0.34",
"@bitgo/sdk-coin-dot": "4.1.12",
"@bitgo/sdk-coin-eos": "2.1.27",
"@bitgo/sdk-coin-etc": "2.2.1",
"@bitgo/sdk-coin-eth": "24.2.23",
"@bitgo/sdk-coin-ethlike": "1.1.15",
"@bitgo/sdk-coin-ethw": "20.0.34",
"@bitgo/sdk-coin-hash": "3.0.3",
"@bitgo/sdk-coin-hbar": "2.0.34",
"@bitgo/sdk-coin-injective": "3.0.3",
"@bitgo/sdk-coin-ltc": "3.0.34",
"@bitgo/sdk-coin-near": "2.0.34",
"@bitgo/sdk-coin-opeth": "18.1.19",
"@bitgo/sdk-coin-osmo": "3.0.3",
"@bitgo/sdk-coin-polygon": "21.0.3",
"@bitgo/sdk-coin-sei": "3.0.3",
"@bitgo/sdk-coin-sol": "4.5.0",
"@bitgo/sdk-coin-sui": "5.6.2",
"@bitgo/sdk-coin-tia": "3.0.3",
"@bitgo/sdk-coin-trx": "2.0.34",
"@bitgo/sdk-coin-xlm": "3.2.8",
"@bitgo/sdk-coin-xrp": "2.1.15",
"@bitgo/sdk-coin-zec": "2.0.34",
"@bitgo/sdk-coin-zeta": "3.0.3",
"@bitgo/abstract-cosmos": "11.0.5",
"@bitgo/abstract-utxo": "8.14.2",
"@bitgo/sdk-api": "1.54.1",
"@bitgo/sdk-coin-ada": "4.2.14",
"@bitgo/sdk-coin-algo": "2.1.34",
"@bitgo/sdk-coin-arbeth": "21.0.28",
"@bitgo/sdk-coin-atom": "13.0.5",
"@bitgo/sdk-coin-avaxc": "5.0.28",
"@bitgo/sdk-coin-bch": "2.0.36",
"@bitgo/sdk-coin-bcha": "2.1.20",
"@bitgo/sdk-coin-bld": "3.0.5",
"@bitgo/sdk-coin-bsc": "22.1.20",
"@bitgo/sdk-coin-bsv": "2.0.36",
"@bitgo/sdk-coin-btc": "2.2.7",
"@bitgo/sdk-coin-btg": "2.0.36",
"@bitgo/sdk-coin-coreum": "21.0.5",
"@bitgo/sdk-coin-dash": "2.0.36",
"@bitgo/sdk-coin-doge": "2.0.36",
"@bitgo/sdk-coin-dot": "4.1.14",
"@bitgo/sdk-coin-eos": "2.1.29",
"@bitgo/sdk-coin-etc": "2.2.3",
"@bitgo/sdk-coin-eth": "24.2.25",
"@bitgo/sdk-coin-ethlike": "1.1.17",
"@bitgo/sdk-coin-ethw": "20.0.36",
"@bitgo/sdk-coin-hash": "3.0.5",
"@bitgo/sdk-coin-hbar": "2.0.36",
"@bitgo/sdk-coin-injective": "3.0.5",
"@bitgo/sdk-coin-ltc": "3.0.36",
"@bitgo/sdk-coin-near": "2.0.36",
"@bitgo/sdk-coin-opeth": "18.1.21",
"@bitgo/sdk-coin-osmo": "3.0.5",
"@bitgo/sdk-coin-polygon": "21.0.5",
"@bitgo/sdk-coin-sei": "3.0.5",
"@bitgo/sdk-coin-sol": "4.5.2",
"@bitgo/sdk-coin-sui": "5.6.4",
"@bitgo/sdk-coin-tia": "3.0.5",
"@bitgo/sdk-coin-trx": "2.0.36",
"@bitgo/sdk-coin-xlm": "3.2.10",
"@bitgo/sdk-coin-xrp": "2.1.17",
"@bitgo/sdk-coin-zec": "2.0.36",
"@bitgo/sdk-coin-zeta": "3.0.5",
"@bitgo/utxo-lib": "10.3.0",
"@ethereumjs/common": "2.6.5",
"@lottiefiles/react-lottie-player": "3.4.9",
Expand Down
12 changes: 0 additions & 12 deletions src/containers/EvmCrossChainRecoveryWallet/ColdWalletForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import { EvmCrossChainRecoveryBaseForm } from './EvmCrossChainRecoveryBaseForm';

const validationSchema = Yup.object({
bitgoFeeAddress: Yup.string().required(),
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(),
recoveryDestination: Yup.string().required(),
userKey: Yup.string().required(),
userKeyId: Yup.string(),
Expand All @@ -21,7 +14,6 @@ const validationSchema = Yup.object({
apiKey: Yup.string().required(),
wrongChain: Yup.string().required(),
intendedChain: Yup.string().required(),
gasPrice: Yup.number().required(),
}).required();

export type FormProps = {
Expand All @@ -38,9 +30,6 @@ export function ColdWalletForm({ onSubmit }: FormProps) {
onSubmit,
initialValues: {
bitgoFeeAddress: '',
gasLimit: 500000,
maxFeePerGas: 500,
maxPriorityFeePerGas: 50,
recoveryDestination: '',
userKey: '',
userKeyId: '',
Expand All @@ -49,7 +38,6 @@ export function ColdWalletForm({ onSubmit }: FormProps) {
apiKey: '',
wrongChain: '',
intendedChain: '',
gasPrice: 20,
},
validationSchema,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -128,50 +120,6 @@ export function EvmCrossChainRecoveryBaseForm({
Width="fill"
/>
</div>

{!isCustodyWallet && (
<div className="tw-mb-4">
<FormikTextfield
HelperText="Gas limit for the Polygon transaction. The value should be between 30,000 and 20,000,000. The default is 500,000 unit of gas."
Label="Gas Limit"
name="gasLimit"
Width="fill"
/>
</div>
)}

{!isCustodyWallet && !isBscChain(wrongChain) && (
<>
<div className="tw-mb-4">
<FormikTextfield
HelperText="Max fee per gas for the Polygon transaction. The default is 20 Gwei."
Label="Max Fee Per Gas (Gwei)"
name="maxFeePerGas"
Width="fill"
/>
</div>

<div className="tw-mb-4">
<FormikTextfield
HelperText='"Tip" to the Polygon miner. This is by default 10 Gwei.'
Label="Max Priority Fee Per Gas (Gwei)"
name="maxPriorityFeePerGas"
Width="fill"
/>
</div>
</>
)}

{!isCustodyWallet && isBscChain(wrongChain) && (
<div className="tw-mb-4">
<FormikTextfield
HelperText="Provide the Gas Price for BSC. This is by default 20 Gwei"
Label="Gas Price (Gwei)"
name="gasPrice"
Width="fill"
/>
</div>
)}
<div className="tw-mb-4">
<FormikTextfield
HelperText="The contract address of the token which needs to be recovered."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
assert,
isRecoveryTransaction,
safeEnv,
toWei,
getEip1559Params,
getEthCommonConfigParams,
} from '~/helpers';
import { ColdWalletForm } from './ColdWalletForm';
Expand Down Expand Up @@ -44,11 +42,7 @@ interface CustodyWalletParams extends BaseParams {
interface NonCustodyWalletParams extends BaseParams {
walletContractAddress: string;
bitgoFeeAddress: string;
gasLimit: number;
maxFeePerGas: number;
maxPriorityFeePerGas: number;
apiKey: string;
gasPrice: number;
}

interface HotWalletParams extends NonCustodyWalletParams {
Expand Down Expand Up @@ -181,10 +175,9 @@ async function handleNonCustodyFormSubmit(
values.wrongChain,
values as ColdWalletParams
);
values.gasPrice = toWei(values.gasPrice);

const recoverData = await window.commands.recover(values.wrongChain, {
...values,
eip1559: getEip1559Params(values.wrongChain, maxFeePerGas, maxPriorityFeePerGas),
bitgoKey: '',
userKey: Object.prototype.hasOwnProperty.call(rest, 'userKey')
? rest.userKey
Expand Down
12 changes: 0 additions & 12 deletions src/containers/EvmCrossChainRecoveryWallet/HotWalletForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@ import { EvmCrossChainRecoveryBaseForm } from './EvmCrossChainRecoveryBaseForm';
const validationSchema = Yup.object({
userKey: Yup.string().required(),
bitgoFeeAddress: Yup.string().required(),
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(),
recoveryDestination: Yup.string().required(),
walletContractAddress: Yup.string().required(),
walletPassphrase: Yup.string().required(),
tokenContractAddress: Yup.string(),
apiKey: Yup.string().required(),
wrongChain: Yup.string().required(),
intendedChain: Yup.string().required(),
gasPrice: Yup.number().required(),
}).required();

export type FormProps = {
Expand All @@ -39,17 +31,13 @@ export function HotWalletForm({ onSubmit }: FormProps) {
initialValues: {
userKey: '',
bitgoFeeAddress: '',
gasLimit: 500000,
maxFeePerGas: 500,
maxPriorityFeePerGas: 50,
recoveryDestination: '',
walletContractAddress: '',
walletPassphrase: '',
tokenContractAddress: undefined,
apiKey: '',
wrongChain: '',
intendedChain: '',
gasPrice: 20,
},
validationSchema,
});
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 09809f9

Please sign in to comment.