Skip to content

Commit

Permalink
fix: add insufficient funds error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed May 11, 2023
1 parent c2989de commit 6991ee4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/wallet-management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/experimental": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@lifi/sdk": "^2.0.0-beta.12",
"@lifi/sdk": "^2.0.0-beta.13",
"@walletconnect/ethereum-provider": "^1.8.0",
"@walletconnect/web3-provider": "^1.8.0",
"events": "^3.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/widget-embedded/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"author": "Eugene Chybisov <[email protected]>",
"dependencies": {
"@ethersproject/abstract-signer": "^5.7.0",
"@lifi/sdk": "^2.0.0-beta.12",
"@lifi/sdk": "^2.0.0-beta.13",
"@lifi/wallet-management": "^2.0.0-beta.6",
"@lifi/widget": "^2.0.0-beta.8",
"@mui/icons-material": "^5.11.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/widget-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"author": "Eugene Chybisov <[email protected]>",
"dependencies": {
"@lifi/sdk": "^2.0.0-beta.12",
"@lifi/sdk": "^2.0.0-beta.13",
"@lifi/wallet-management": "^2.0.0-beta.6",
"@lifi/widget": "^2.0.0-beta.8",
"@mui/icons-material": "^5.11.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@ethersproject/address": "^5.7.0",
"@ethersproject/experimental": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@lifi/sdk": "^2.0.0-beta.12",
"@lifi/sdk": "^2.0.0-beta.13",
"@lifi/wallet-management": "^2.0.0-beta.6",
"@mui/icons-material": "^5.11.16",
"@mui/lab": "^5.0.0-alpha.129",
Expand Down
6 changes: 6 additions & 0 deletions packages/widget/src/hooks/useProcessMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ export function getProcessMessage(
title = t(`swap.error.title.gasLimitIsTooLow`);
message = getTransactionNotSentMessage();
break;
case LifiErrorCode.InsufficientFunds:
title = t(`swap.error.title.insufficientFunds`);
message = `${t(
`swap.error.message.insufficientFunds`,
)} ${getTransactionNotSentMessage()}`;
break;
case LifiErrorCode.SlippageError:
title = t(`swap.error.title.slippageNotMet`);
message = t(`swap.error.message.slippageThreshold`);
Expand Down
2 changes: 2 additions & 0 deletions packages/widget/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"error": {
"message": {
"allowanceRequired": "Transfer amount for {{tokenSymbol}} exceeds your current allowance. Please increase your allowance and try again.",
"insufficientFunds": "You don't have enough gas to cover the cost of the transaction.",
"slippageThreshold": "The slippage is larger than the defined threshold. Please request a new route to get a fresh quote.",
"transactionFailed": "Please check the block explorer for more information.",
"transactionNotSent": "Transaction was not sent. {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
Expand All @@ -95,6 +96,7 @@
"chainSwitch": "Chain switch required",
"failed": "Swap failed",
"gasLimitIsTooLow": "The gas limit is too low",
"insufficientFunds": "Insufficient funds",
"slippageNotMet": "Slippage conditions not met",
"transactionCanceled": "Transaction canceled",
"transactionFailed": "Transaction failed",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2627,17 +2627,17 @@ __metadata:
languageName: node
linkType: hard

"@lifi/sdk@npm:^2.0.0-beta.12":
version: 2.0.0-beta.12
resolution: "@lifi/sdk@npm:2.0.0-beta.12"
"@lifi/sdk@npm:^2.0.0-beta.13":
version: 2.0.0-beta.13
resolution: "@lifi/sdk@npm:2.0.0-beta.13"
dependencies:
"@ethersproject/abi": ^5.7.0
"@ethersproject/contracts": ^5.7.0
"@lifi/types": ^6.0.0
bignumber.js: ^9.1.1
eth-rpc-errors: ^4.0.3
ethers: ^5.7.2
checksum: 7240974c05f52b7fa8c95b602b4c8bf3ec0dc28d16d8f202884569d1c1917852422828da8cb371271d6ea3fbfd6236c4707277ebc11ccbeccccf43e85758711e
checksum: aba59d9ea9c95bf07c467781ad19f9b5e656c55a38ff4a148e2c2a45325ff92eef64cd47e87b151d249b07c1baabf00e115774b5fb935f7e8fccb419720b568f
languageName: node
linkType: hard

Expand All @@ -2658,7 +2658,7 @@ __metadata:
"@ethersproject/abstract-signer": ^5.7.0
"@ethersproject/experimental": ^5.7.0
"@ethersproject/providers": ^5.7.2
"@lifi/sdk": ^2.0.0-beta.12
"@lifi/sdk": ^2.0.0-beta.13
"@walletconnect/ethereum-provider": ^1.8.0
"@walletconnect/web3-provider": ^1.8.0
cpy-cli: ^4.2.0
Expand All @@ -2674,7 +2674,7 @@ __metadata:
dependencies:
"@esbuild-plugins/node-globals-polyfill": ^0.2.3
"@ethersproject/abstract-signer": ^5.7.0
"@lifi/sdk": ^2.0.0-beta.12
"@lifi/sdk": ^2.0.0-beta.13
"@lifi/wallet-management": ^2.0.0-beta.6
"@lifi/widget": ^2.0.0-beta.8
"@mui/icons-material": ^5.11.16
Expand Down Expand Up @@ -2705,7 +2705,7 @@ __metadata:
resolution: "@lifi/widget-playground@workspace:packages/widget-playground"
dependencies:
"@esbuild-plugins/node-globals-polyfill": ^0.2.3
"@lifi/sdk": ^2.0.0-beta.12
"@lifi/sdk": ^2.0.0-beta.13
"@lifi/wallet-management": ^2.0.0-beta.6
"@lifi/widget": ^2.0.0-beta.8
"@mui/icons-material": ^5.11.16
Expand Down Expand Up @@ -2734,7 +2734,7 @@ __metadata:
"@ethersproject/address": ^5.7.0
"@ethersproject/experimental": ^5.7.0
"@ethersproject/providers": ^5.7.2
"@lifi/sdk": ^2.0.0-beta.12
"@lifi/sdk": ^2.0.0-beta.13
"@lifi/wallet-management": ^2.0.0-beta.6
"@mui/icons-material": ^5.11.16
"@mui/lab": ^5.0.0-alpha.129
Expand Down

0 comments on commit 6991ee4

Please sign in to comment.