Skip to content

Commit

Permalink
Merge pull request #59 from pnetwork-association/feat/tx-underpriced-…
Browse files Browse the repository at this point in the history
…error

feat(underpriced-message): handle tx underpriced error
  • Loading branch information
envin3 authored Nov 7, 2023
2 parents d4a3a39 + a4c3ac1 commit 95388ff
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 24 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plain-dapp-update",
"private": true,
"version": "1.15.1",
"version": "1.16.0",
"type": "module",
"scripts": {
"dev": "npm run create-version-file && vite",
Expand Down
5 changes: 3 additions & 2 deletions src/settings/swap-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,16 @@ const swapAssets = [
isPerc20: true,
isHidden: false,
blockchain: 'EOS',
decimals: 0,
decimals: 9,
withMiniImage: true,
symbol: 'PETH',
isPtoken: true,
nativeSymbol: 'ETH',
nativeBlockchain: 'ETH',
image: 'pETH.svg',
withBalanceDecimalsConversion: true,
withBalanceDecimalsConversion: false,
chainId: ChainId.EosMainnet,
onPnetworkV2: true,
},
{
address: 'pnt.ptokens',
Expand Down
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

1 comment on commit 95388ff

@4everland
Copy link

@4everland 4everland bot commented on 95388ff Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following parameters

parameters Value
IPFS CID bafybeiammndwyxn2mklnqthajs75xr6r2ow2aaobwrgrb6bwlnuozjsn4e
Assigned domain https://ptokens-dapp-lynxomwh-pnetwork-association.4everland.app
https://ptokens-dapp.4everland.app
Custom domain

Please sign in to comment.