Skip to content

Commit

Permalink
Merge pull request #91 from pnetwork-association/feat/disable-tokens
Browse files Browse the repository at this point in the history
Feat/disable tokens
  • Loading branch information
envin3 authored Sep 9, 2024
2 parents c54537c + 74bc631 commit b1ae51c
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 45 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-tomatoes-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'ptokens-dapp-v2': minor
---

disable unsupported tokens
12 changes: 6 additions & 6 deletions .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ ignore:
SNYK-JS-WEB3UTILS-6229337:
- '*':
reason: will be fixed in v4 - fix planned
expires: 2024-09-04T00:00:00.000Z
expires: 2024-09-10T00:00:00.000Z
created: 2024-04-04T11:30:11.068Z
SNYK-JS-WS-7266574:
- '*':
reason: will be fixed in v4 - fix planned
expires: 2024-09-04T00:00:00.000Z
expires: 2024-09-10T00:00:00.000Z
created: 2024-08-28T11:30:11.068Z
SNYK-JS-ELLIPTIC-7577916:
- '*':
reason: Will be fixed in v4 - fix planned
expires: 2024-09-04T00:00:00.000Z
expires: 2024-09-10T00:00:00.000Z
created: 2024-08-28T11:30:11.068Z
SNYK-JS-ELLIPTIC-7577917:
- '*':
reason: Will be fixed in v4 - fix planned
expires: 2024-09-04T00:00:00.000Z
expires: 2024-09-10T00:00:00.000Z
created: 2024-08-28T11:30:11.068Z
SNYK-JS-ELLIPTIC-7577918:
- '*':
reason: Will be fixed in v4 - fix planned
expires: 2024-09-04T00:00:00.000Z
expires: 2024-09-10T00:00:00.000Z
created: 2024-08-28T11:30:11.068Z
SNYK-JS-MICROMATCH-6838728:
- '*':
reason: Will be fixed in v4 - fix planned
expires: 2024-09-04T00:00:00.000Z
expires: 2024-09-10T00:00:00.000Z
created: 2024-08-28T11:30:11.068Z
patch: {}
7 changes: 4 additions & 3 deletions package-lock.json

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

36 changes: 15 additions & 21 deletions src/components/pages/swap/Swap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { MAX_IMPACT, PBTC_ON_ETH_MAINNET_V1_MIGRATION, PUOS_ON_ULTRA_MAINNET } f
import { sendEvent } from '../../../ga4'
import { useAssets } from '../../../hooks/use-assets'
import { useSwap } from '../../../hooks/use-swap'
import defaultAssets from '../../../settings/swap-assets'
import defaultAssets, { disabledAssets } from '../../../settings/swap-assets'
import Button from '../../atoms/button/Button'
import Icon from '../../atoms/icon/Icon'
import Switch from '../../atoms/switch/Switch'
Expand Down Expand Up @@ -410,12 +410,18 @@ const Swap = ({
caution!
</InfoEta>
) : null}
{from && from.isNative && to && to && to.notifyDepositAddressWarning && (
<WarningEta>
Please refrain from using previously generated deposit addresses, as doing so may result in a loss of
funds.
</WarningEta>
)}
{from &&
from.isNative &&
to &&
to.notifyDepositAddressWarning &&
to.id !== 'PBTC_ON_ARBITRUM_MAINNET' &&
to.id !== 'PBTC_ON_TELOS_MAINNET' &&
to.id !== 'PBTC_ON_LIBRE_MAINNET' && (
<WarningEta>
Please refrain from using previously generated deposit addresses, as doing so may result in a loss
of funds.
</WarningEta>
)}
{from && from.id === 'GALA_ON_BSC_MAINNET' && to && to.id === 'GALA' ? (
<InfoEta>
You are about to pegout (redeem){' '}
Expand Down Expand Up @@ -450,20 +456,8 @@ const Swap = ({
direct control (i.e. not a CEX deposit address).
</InfoEta>
) : null}
{(from && from.id === 'GALA' && to && to.id === 'GALA_ON_BSC_MAINNET') ||
(from && from.id === '$ANRX' && to && to.id === '$ANRX_ON_BSC_MAINNET') ||
(from && from.id === 'BTC' && to && to.id === 'PBTC_ON_ARBITRUM_MAINNET') ||
(from && from.id === 'PNT_ON_ETH_MAINNET' && to && to.id === 'PNT_ON_ARBITRUM_MAINNET') ||
(from && from.id === 'ETHPNT_ON_ETH_MAINNET' && to && to.id === 'PNT_ON_ARBITRUM_MAINNET') ||
(from && from.id === 'IQ' && to && to.id === 'IQ_ON_ETH_MAINNET') ||
(from && from.id === 'KEYS' && to && to.id === 'PKEYS_ON_BSC_MAINNET') ||
(from && from.id === 'LUXO' && to && to.id === 'LUXO_ON_BSC_MAINNET') ||
(from && from.id === 'OPEN' && to && to.id === 'POPEN_ON_BSC_MAINNET') ||
(from && from.id === 'OPIUM' && to && to.id === 'POPIUM_ON_BSC_MAINNET') ||
(from && from.id === 'PTERIA' && to && to.id === 'PTERIA_ON_BSC_MAINNET') ||
(from && from.id === 'SEEDS' && to && to.id === 'PSEEDS_ON_ETH_MAINNET') ||
(from && from.id === 'ZMT' && to && to.id === 'ZMT_ON_BSC_MAINNET') ? (
<WarningEta>{`${to.name} on ${to.blockchain} has been dismissed and pegins are disabled. Pegouts are available until 09/30/2024`}</WarningEta>
{from && to && (disabledAssets.includes(from.id) || disabledAssets.includes(to.id)) ? (
<WarningEta>{`${to.name} on ${to.blockchain} has been dismissed and pegins are disabled. Pegout the native token ASAP for a smooth redeem process.`}</WarningEta>
) : null}
{to &&
(to.id === 'PUSDC_ON_ALGORAND_MAINNET' ||
Expand Down
17 changes: 2 additions & 15 deletions src/hooks/use-swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
CURVE_MAX_AMOUNT,
} from '../constants'
import { sendEvent } from '../ga4'
import { disabledAssets } from '../settings/swap-assets'
import { maybeOptInAlgoApp, maybeOptInAlgoAsset } from '../store/swap/utils/opt-in-algo'
import { isValidAccountByBlockchain } from '../utils/account-validator'
import { getSwapFees, computeSwapAmount } from '../utils/fee'
Expand Down Expand Up @@ -319,21 +320,7 @@ const useSwap = ({
return
}

if (
(from.id === 'GALA' && to.id === 'GALA_ON_BSC_MAINNET') ||
(from.id === '$ANRX' && to.id === '$ANRX_ON_BSC_MAINNET') ||
(from.id === 'BTC' && to.id === 'PBTC_ON_ARBITRUM_MAINNET') ||
(from.id === 'PNT_ON_ETH_MAINNET' && to.id === 'PNT_ON_ARBITRUM_MAINNET') ||
(from.id === 'ETHPNT_ON_ETH_MAINNET' && to.id === 'PNT_ON_ARBITRUM_MAINNET') ||
(from.id === 'IQ' && to.id === 'IQ_ON_ETH_MAINNET') ||
(from.id === 'KEYS' && to.id === 'PKEYS_ON_BSC_MAINNET') ||
(from.id === 'LUXO' && to.id === 'LUXO_ON_BSC_MAINNET') ||
(from.id === 'OPEN' && to.id === 'POPEN_ON_BSC_MAINNET') ||
(from.id === 'OPIUM' && to.id === 'POPIUM_ON_BSC_MAINNET') ||
(from.id === 'PTERIA' && to.id === 'PTERIA_ON_BSC_MAINNET') ||
(from.id === 'SEEDS' && to.id === 'PSEEDS_ON_ETH_MAINNET') ||
(from.id === 'ZMT' && to.id === 'ZMT_ON_BSC_MAINNET')
) {
if (disabledAssets.includes(to.id)) {
updateSwapButton('Disabled Swap', true)
return
}
Expand Down
23 changes: 23 additions & 0 deletions src/settings/swap-assets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
import { ChainId } from '@p.network/ptokens-constants'

export const disabledAssets = [
'GALA_ON_BSC_MAINNET',
'ANRX_ON_BSC_MAINNET',
'PBTC_ON_ARBITRUM_MAINNET',
'PBTC_ON_LIBRE_MAINNET',
'PBTC_ON_TELOS_MAINNET',
'PNT_ON_ARBITRUM_MAINNET',
'IQ_ON_ETH_MAINNET',
'PKEYS_ON_BSC_MAINNET',
'LUXO_ON_BSC_MAINNET',
'POPEN_ON_BSC_MAINNET',
'POPIUM_ON_BSC_MAINNET',
'PTERIA_ON_BSC_MAINNET',
'PSEEDS_ON_ETH_MAINNET',
'TLOS_ON_ETH_MAINNET',
'TLOS_ON_BSC_MAINNET',
'PUSDT_ON_LIBRE_MAINNET',
'PUSDT_ON_TELOS_MAINNET',
'PETH_ON_TELOS_MAINNET',
'NUCO_ON_TELOS_MAINNET',
'ZMT_ON_BSC_MAINNET',
]

const swapAssets = [
/* ################# pTokens #################*/
{
Expand Down

0 comments on commit b1ae51c

Please sign in to comment.