From ca17d27f1c31c433120992b9877676fd99b8e895 Mon Sep 17 00:00:00 2001 From: Usame Algan <5880855+usame-algan@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:07:38 +0100 Subject: [PATCH] fix: max amount button and timeout error (#3181) * fix: Hide MAX amount button if amount is 0 * fix: Show human-readable timeout error * fix: Max amount button --- src/components/common/TokenAmountInput/index.tsx | 2 +- .../tx-flow/flows/SuccessScreen/StatusMessage.tsx | 4 ++-- src/utils/ethers-utils.ts | 6 +----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/common/TokenAmountInput/index.tsx b/src/components/common/TokenAmountInput/index.tsx index 9be9a9b9cd..854f7db600 100644 --- a/src/components/common/TokenAmountInput/index.tsx +++ b/src/components/common/TokenAmountInput/index.tsx @@ -67,7 +67,7 @@ const TokenAmountInput = ({ variant="standard" InputProps={{ disableUnderline: true, - endAdornment: maxAmount !== undefined && Number(maxAmount) && ( + endAdornment: maxAmount !== undefined && ( diff --git a/src/components/tx-flow/flows/SuccessScreen/StatusMessage.tsx b/src/components/tx-flow/flows/SuccessScreen/StatusMessage.tsx index c91c74d3bd..4632a14182 100644 --- a/src/components/tx-flow/flows/SuccessScreen/StatusMessage.tsx +++ b/src/components/tx-flow/flows/SuccessScreen/StatusMessage.tsx @@ -1,4 +1,4 @@ -import { getTimeoutErrorMessage, isTimeoutError } from '@/utils/ethers-utils' +import { isTimeoutError } from '@/utils/ethers-utils' import classNames from 'classnames' import { Box, Typography } from '@mui/material' import LoadingSpinner, { SpinnerStatus } from '@/components/new-safe/create/steps/StatusStep/LoadingSpinner' @@ -21,7 +21,7 @@ const getStep = (status: PendingStatus, error?: Error) => { default: return { description: error ? 'Transaction failed' : 'Transaction was successful', - instruction: error ? (isTimeoutError(error) ? getTimeoutErrorMessage(error) : error.message) : '', + instruction: error ? (isTimeoutError(error) ? 'Transaction timed out' : error.message) : '', } } } diff --git a/src/utils/ethers-utils.ts b/src/utils/ethers-utils.ts index 7abef1b3d1..1513707971 100644 --- a/src/utils/ethers-utils.ts +++ b/src/utils/ethers-utils.ts @@ -26,11 +26,7 @@ type TimeoutError = Error & { } export const isTimeoutError = (value?: Error): value is TimeoutError => { - return !!value && 'timeout' in value && 'code' in value -} - -export const getTimeoutErrorMessage = (error: TimeoutError) => { - return `Transaction timed out after ${Math.floor(error.timeout / 1000)} seconds` + return !!value && 'reason' in value && value.reason === 'timeout' && 'code' in value } export const splitSignature = (sigBytes: string): Signature => {