Skip to content

Commit e179453

Browse files
authored
fix: add insufficient funds error (#141)
1 parent 022afe1 commit e179453

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/utils/errors.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ export enum LifiErrorCode {
2525
TransactionRejected = 1012,
2626
BalanceError = 1013,
2727
AllowanceRequired = 1014,
28+
InsufficientFunds = 1015,
2829
}
2930

3031
export enum EthersErrorType {
31-
CallExecption = 'CALL_EXCEPTION',
3232
ActionRejected = 'ACTION_REJECTED',
33+
CallExecption = 'CALL_EXCEPTION',
34+
InsufficientFunds = 'INSUFFICIENT_FUNDS',
3335
}
3436

3537
export enum EthersErrorMessage {

src/utils/parseError.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import {
44
getMessageFromCode,
55
} from 'eth-rpc-errors'
66

7+
import { fetchTxErrorDetails } from '../helpers'
78
import ChainsService from '../services/ChainsService'
89
import {
910
ErrorMessage,
10-
EthersErrorType,
1111
EthersErrorMessage,
12+
EthersErrorType,
1213
LifiError,
1314
LifiErrorCode,
1415
MetaMaskProviderErrorCode,
@@ -22,7 +23,6 @@ import {
2223
ValidationError,
2324
} from './errors'
2425
import { formatTokenAmountOnly } from './utils'
25-
import { fetchTxErrorDetails } from '../helpers'
2626

2727
/**
2828
* Available MetaMask error codes:
@@ -203,7 +203,13 @@ export const parseError = async (
203203
e.stack
204204
)
205205
}
206-
206+
case EthersErrorType.InsufficientFunds:
207+
return new TransactionError(
208+
LifiErrorCode.InsufficientFunds,
209+
e.message,
210+
await getTransactionNotSentMessage(step, process),
211+
e.stack
212+
)
207213
case EthersErrorType.ActionRejected:
208214
case MetaMaskProviderErrorCode.userRejectedRequest:
209215
return new TransactionError(

0 commit comments

Comments
 (0)