Skip to content

Commit

Permalink
fix(suite): handle estimated fee error (#11671)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjojoy authored May 14, 2024
1 parent edbc2ad commit 32a42b1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export const NotificationRenderer = ({
return error(render, notification, 'METADATA_PROVIDER_AUTH_ERROR');
case 'metadata-unexpected-error':
return error(render, notification, 'METADATA_PROVIDER_UNEXPECTED_ERROR');
case 'estimated-fee-error':
return info(render, notification, 'TOAST_ESTIMATED_FEE_ERROR');
case 'auto-updater-error':
return error(render, notification, 'TOAST_AUTO_UPDATER_ERROR', {
state: notification.state,
Expand Down
4 changes: 4 additions & 0 deletions packages/suite/src/support/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8853,6 +8853,10 @@ export default defineMessages({
id: 'TOAST_SUCCESSFUL_CLAIM',
defaultMessage: '{symbol} claimed successfully',
},
TOAST_ESTIMATED_FEE_ERROR: {
id: 'TOAST_ESTIMATED_FEE_ERROR',
defaultMessage: 'Fee estimation from network failed. Using backup value.',
},
TR_STAKE_TOTAL_PENDING: {
id: 'TR_STAKE_TOTAL_PENDING',
defaultMessage: 'Total stake pending:',
Expand Down
59 changes: 16 additions & 43 deletions suite-common/toast-notifications/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,29 @@ export type ToastPayload = (
| 'sign-message-success'
| 'verify-message-success'
| 'firmware-check-authenticity-success'
| 'device-authenticity-success';
| 'device-authenticity-success'
| 'clear-storage'
| 'add-token-success'
| 'auto-updater-no-new'
| 'qr-incorrect-address'
| 'copy-to-clipboard'
| 'savings-kyc-failed'
| 'savings-kyc-success'
| 'tor-is-slow'
| 'coinjoin-interrupted'
| 'firmware-language-changed'
| 'firmware-language-fetch-error'
| 'estimated-fee-error';
}
| SentTransactionNotification
| {
type: 'raw-tx-sent';
txid: string;
}
| {
type: 'copy-to-clipboard';
}
| {
type: 'clear-storage';
}
| {
type: 'bridge-dev-restart';
devMode: boolean;
}
| {
type: 'add-token-success';
}
| {
type:
| 'error'
Expand All @@ -94,16 +97,15 @@ export type ToastPayload = (
| 'metadata-auth-error'
| 'metadata-not-found-error'
| 'metadata-unexpected-error'
| 'device-authenticity-error';
| 'device-authenticity-error'
| 'cardano-delegate-error'
| 'cardano-withdrawal-error';
error: string;
}
| {
type: 'auto-updater-error';
state: DesktopAppUpdateState;
}
| {
type: 'auto-updater-no-new';
}
| {
type: 'auto-updater-new-version-first-run';
version: string;
Expand All @@ -115,49 +117,20 @@ export type ToastPayload = (
type: 'qr-incorrect-coin-scheme-protocol';
coin: string;
}
| {
type: 'qr-incorrect-address';
}
| {
type: 'coin-scheme-protocol';
scheme: PROTOCOL_SCHEME;
address: string;
amount?: number;
}
| {
type: 'cardano-delegate-error';
error: string;
}
| {
type: 'cardano-withdrawal-error';
error: string;
}
| {
type: 'savings-kyc-failed';
}
| {
type: 'savings-kyc-success';
}
| {
type: 'tor-toggle-error';
error: TranslationKey;
}
| {
type: 'tor-is-slow';
}
| {
type: 'coinjoin-interrupted';
}
| {
type: 'successful-claim';
symbol: string;
}
| {
type: 'firmware-language-changed';
}
| {
type: 'firmware-language-fetch-error';
}
| StakedTransactionNotification
| UnstakedTransactionNotification
| ClaimedTransactionNotification
Expand Down
8 changes: 6 additions & 2 deletions suite-common/wallet-core/src/send/sendFormEthereumThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const calculate = (

export const composeEthereumSendFormTransactionThunk = createThunk(
`${SEND_MODULE_PREFIX}/composeEthereumSendFormTransactionThunk`,
async ({ formValues, formState }: ComposeTransactionThunkArguments) => {
async ({ formValues, formState }: ComposeTransactionThunkArguments, { dispatch }) => {
const { account, network, feeInfo } = formState;
const composeOutputs = getExternalComposeOutput(formValues, account, network);
if (!composeOutputs) return; // no valid Output
Expand Down Expand Up @@ -151,7 +151,11 @@ export const composeEthereumSendFormTransactionThunk = createThunk(
} else {
customFeeLimit = tokenInfo ? ERC20_BACKUP_GAS_LIMIT : ETH_BACKUP_GAS_LIMIT;

// TODO: catch error from blockbook/geth (invalid contract, not enough balance...)
dispatch(
notificationsActions.addToast({
type: 'estimated-fee-error',
}),
);
}

// FeeLevels are read-only
Expand Down

0 comments on commit 32a42b1

Please sign in to comment.