Skip to content

Commit

Permalink
fix: max amount button and timeout error (#3181)
Browse files Browse the repository at this point in the history
* fix: Hide MAX amount button if amount is 0

* fix: Show human-readable timeout error

* fix: Max amount button
  • Loading branch information
usame-algan authored Jan 31, 2024
1 parent e210bb5 commit ca17d27
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/common/TokenAmountInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const TokenAmountInput = ({
variant="standard"
InputProps={{
disableUnderline: true,
endAdornment: maxAmount !== undefined && Number(maxAmount) && (
endAdornment: maxAmount !== undefined && (
<Button data-testid="max-btn" className={css.max} onClick={onMaxAmountClick}>
Max
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/components/tx-flow/flows/SuccessScreen/StatusMessage.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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) : '',
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/utils/ethers-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit ca17d27

Please sign in to comment.