diff --git a/package.json b/package.json index 758b664..f39fffc 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@cosmjs/proto-signing": "^0.31.0", "@cosmjs/stargate": "^0.31.0", "@cosmjs/tendermint-rpc": "^0.31.0", - "@dydxprotocol/v4-abacus": "^1.0.22", + "@dydxprotocol/v4-abacus": "^1.0.24", "@dydxprotocol/v4-client-js": "^1.0.0", "@dydxprotocol/v4-localization": "^1.0.5", "@ethersproject/providers": "^5.7.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9831d58..470293e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,8 +27,8 @@ dependencies: specifier: ^0.31.0 version: 0.31.0 '@dydxprotocol/v4-abacus': - specifier: ^1.0.22 - version: 1.0.22 + specifier: ^1.0.24 + version: 1.0.24 '@dydxprotocol/v4-client-js': specifier: ^1.0.0 version: 1.0.0 @@ -982,8 +982,8 @@ packages: resolution: {integrity: sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA==} dev: true - /@dydxprotocol/v4-abacus@1.0.22: - resolution: {integrity: sha512-KLkBGY61T5xBYOS1WWDdH4Xk17TGJeDWuLmLEuQSdT4l0BKwasbI5F44ayBMyuu6vLvsP0iWSHtk5LlZHY5ChA==} + /@dydxprotocol/v4-abacus@1.0.24: + resolution: {integrity: sha512-wDGSjkrc3Se6Ev7UTjPgJV7PiyzZSz2mJwOTZikLwH7W3k1iPYGQmaCd7TudFk8h2aSdlEwNsQBCf0sLoyvHaQ==} dev: false /@dydxprotocol/v4-client-js@1.0.0: diff --git a/src/views/forms/AccountManagementForms/DepositForm.tsx b/src/views/forms/AccountManagementForms/DepositForm.tsx index c60b541..6797fcf 100644 --- a/src/views/forms/AccountManagementForms/DepositForm.tsx +++ b/src/views/forms/AccountManagementForms/DepositForm.tsx @@ -66,6 +66,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => { resources, summary, errors: routeErrors, + errorMessage: routeErrorMessage, } = useSelector(getTransferInputs, shallowEqual) || {}; const chainId = chainIdStr ? parseInt(chainIdStr) : undefined; @@ -289,18 +290,12 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => { } if (routeErrors) { - try { - const parsedErrors = JSON.parse(routeErrors); - if (parsedErrors?.[0]?.message) { - return stringGetter({ + return routeErrorMessage + ? stringGetter({ key: STRING_KEYS.SOMETHING_WENT_WRONG_WITH_MESSAGE, - params: { ERROR_MESSAGE: parsedErrors?.[0]?.message }, - }); - } - } catch (e) { - log('WithDrawForm/errorMessage', e); - return stringGetter({ key: STRING_KEYS.SOMETHING_WENT_WRONG }); - } + params: { ERROR_MESSAGE: routeErrorMessage }, + }) + : stringGetter({ key: STRING_KEYS.SOMETHING_WENT_WRONG }); } if (fromAmount) { @@ -316,7 +311,16 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => { } return undefined; - }, [error, routeErrors, balance, chainId, fromAmount, sourceToken, stringGetter]); + }, [ + error, + routeErrors, + routeErrorMessage, + balance, + chainId, + fromAmount, + sourceToken, + stringGetter, + ]); const isDisabled = Boolean(errorMessage) || diff --git a/src/views/forms/AccountManagementForms/WithdrawForm.tsx b/src/views/forms/AccountManagementForms/WithdrawForm.tsx index 1c23d91..75d5ba2 100644 --- a/src/views/forms/AccountManagementForms/WithdrawForm.tsx +++ b/src/views/forms/AccountManagementForms/WithdrawForm.tsx @@ -70,6 +70,7 @@ export const WithdrawForm = () => { address: toAddress, resources, errors: routeErrors, + errorMessage: routeErrorMessage, } = useSelector(getTransferInputs, shallowEqual) || {}; const isValidAddress = toAddress && isAddress(toAddress); @@ -283,18 +284,12 @@ export const WithdrawForm = () => { } if (routeErrors) { - try { - const parsedErrors = JSON.parse(routeErrors); - if (parsedErrors?.[0]?.message) { - return stringGetter({ + return routeErrorMessage + ? stringGetter({ key: STRING_KEYS.SOMETHING_WENT_WRONG_WITH_MESSAGE, - params: { ERROR_MESSAGE: parsedErrors?.[0]?.message }, - }); - } - } catch (e) { - log('WithDrawForm/errorMessage', e); - return stringGetter({ key: STRING_KEYS.SOMETHING_WENT_WRONG }); - } + params: { ERROR_MESSAGE: routeErrorMessage }, + }) + : stringGetter({ key: STRING_KEYS.SOMETHING_WENT_WRONG }); } if (!toAddress) return stringGetter({ key: STRING_KEYS.WITHDRAW_MUST_SPECIFY_ADDRESS }); @@ -320,6 +315,7 @@ export const WithdrawForm = () => { }, [ error, routeErrors, + routeErrorMessage, freeCollateralBN, chainIdStr, debouncedAmountBN,