Skip to content

Commit

Permalink
feat(underpriced-message): handle tx underpriced error
Browse files Browse the repository at this point in the history
  • Loading branch information
envin3 committed Nov 7, 2023
1 parent d4a3a39 commit 019fdec
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/store/swap/utils/pegin-with-deposit-address.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { sendEvent } from '../../../ga4'
import { getCorrespondingTxExplorerLinkByBlockchain } from '../../../utils/explorer'
import { updateInfoModal } from '../../pages/pages.actions'
import {
showDepositAddressModal,
hideDepositAddressModal,
Expand All @@ -6,9 +9,6 @@ import {
resetProgress,
updateSwapButton,
} from '../swap.actions'
import { getCorrespondingTxExplorerLinkByBlockchain } from '../../../utils/explorer'
import { updateInfoModal } from '../../pages/pages.actions'
import { sendEvent } from '../../../ga4'

const peginWithDepositAddress = async ({ swap, ptokenFrom, ptokenTo, dispatch }) => {
let link = null
Expand Down
17 changes: 11 additions & 6 deletions src/store/swap/utils/pegin-with-wallet.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { getCorrespondingTxExplorerLinkByBlockchain } from '../../../utils/explorer'
import { updateProgress, loadBalanceByAssetId, resetProgress, updateSwapButton } from '../swap.actions'
import { updateInfoModal } from '../../pages/pages.actions'
import Web3 from 'web3'

import { parseError } from '../../../utils/errors'
import { getCorrespondingTxExplorerLinkByBlockchain } from '../../../utils/explorer'
import { approveTransaction, getBigNumber } from '../../evm-approve'
import Web3 from 'web3'
import { updateInfoModal } from '../../pages/pages.actions'
import { getWalletByBlockchain } from '../../wallets/wallets.selectors'
import { updateProgress, loadBalanceByAssetId, resetProgress, updateSwapButton } from '../swap.actions'

const peginWithWallet = async ({ swap, ptokenFrom, ptokenTo, dispatch }) => {
let link
Expand All @@ -27,7 +28,9 @@ const peginWithWallet = async ({ swap, ptokenFrom, ptokenTo, dispatch }) => {
dispatch(
updateInfoModal({
show: true,
text: 'Error during pegin, try again!',
text: _err.message.includes('transaction underpriced')
? "You transaction wasn't accepted by the network as underpriced. Please try again increasing the gasprice from your wallet before signing."
: 'Error during pegin, try again!',
showMoreText: _err.message ? _err.message : _err,
showMoreLabel: 'Show Details',
icon: 'cancel',
Expand Down Expand Up @@ -119,7 +122,9 @@ const peginWithWallet = async ({ swap, ptokenFrom, ptokenTo, dispatch }) => {
dispatch(
updateInfoModal({
show: true,
text: 'Error during pegin, try again!',
text: _err.message.includes('underpriced')
? "You transaction wasn't accepted by the network as underpriced. Please try again increasing the gasprice from your wallet before signing."
: 'Error during pegin, try again!',
showMoreText: _err.message ? _err.message : _err,
showMoreLabel: 'Show Details',
icon: 'cancel',
Expand Down
15 changes: 9 additions & 6 deletions src/store/swap/utils/pegout-curve.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { getCorrespondingTxExplorerLinkByBlockchain } from '../../../utils/explorer'
import { updateProgress, loadBalanceByAssetId, resetProgress, updateSwapButton } from '../swap.actions'
import { updateInfoModal } from '../../pages/pages.actions'
import { parseError } from '../../../utils/errors'
import curve from '@curvefi/api'
import polling from 'light-async-polling'
import Web3 from 'web3'

import { PBTC_ON_ETH_POOL, TRANSFER_EVENT_TOPIC } from '../../../constants/index'
import { sendEvent } from '../../../ga4'
import { parseError } from '../../../utils/errors'
import { getCorrespondingTxExplorerLinkByBlockchain } from '../../../utils/explorer'
import { updateInfoModal } from '../../pages/pages.actions'
import { updateProgress, loadBalanceByAssetId, resetProgress, updateSwapButton } from '../swap.actions'

function getInputAmount(web3, txReceipt, poolAddress, returnAddress, trLink) {
poolAddress = poolAddress.toUpperCase()
Expand Down Expand Up @@ -151,7 +152,7 @@ const curvePhase = async (swap, provider, tokenFrom, ptokenFrom, dispatch) => {
let updatedAmount = getInputAmount(txReceipt, pool.address, provider.selectedAddress, link)
swap._amount = updatedAmount
} catch (_err) {
console.log(_err)
console.error(_err)
dispatch(
updateInfoModal({
show: true,
Expand Down Expand Up @@ -265,7 +266,9 @@ const pegoutFromCurve = async ({ swap, provider, tokenFrom, ptokenFrom, ptokenTo
dispatch(
updateInfoModal({
show: true,
text: 'Error during pegout, try again!',
text: _err.message.includes('transaction underpriced')
? "You transaction wasn't accepted by the network as underpriced. Please try again increasing the gasprice from your wallet before signing."
: 'Error during pegout, try again!',
showMoreText: _err.message ? _err.message : _err,
showMoreLabel: 'Show Details',
icon: 'cancel',
Expand Down
10 changes: 6 additions & 4 deletions src/store/swap/utils/pegout.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { sendEvent } from '../../../ga4'
import { parseError } from '../../../utils/errors'
import { getCorrespondingTxExplorerLinkByBlockchain } from '../../../utils/explorer'
import { updateProgress, loadBalanceByAssetId, resetProgress, updateSwapButton } from '../swap.actions'
import { updateInfoModal } from '../../pages/pages.actions'
import { parseError } from '../../../utils/errors'
import { sendEvent } from '../../../ga4'
import { updateProgress, loadBalanceByAssetId, resetProgress, updateSwapButton } from '../swap.actions'

const pegout = async ({ swap, ptokenFrom, ptokenTo, dispatch }) => {
let link
Expand Down Expand Up @@ -98,7 +98,9 @@ const pegout = async ({ swap, ptokenFrom, ptokenTo, dispatch }) => {
dispatch(
updateInfoModal({
show: true,
text: 'Error during pegout, try again!',
text: _err.message.includes('transaction underpriced')
? "You transaction wasn't accepted by the network as underpriced. Please try again increasing the gasprice from your wallet before signing."
: 'Error during pegout, try again!',
showMoreText: _err.message ? _err.message : _err,
showMoreLabel: 'Show Details',
icon: 'cancel',
Expand Down

0 comments on commit 019fdec

Please sign in to comment.