From 163b902d3b7d88edb7a22e629d63b36707f9983c Mon Sep 17 00:00:00 2001 From: envin Date: Mon, 9 Sep 2024 16:51:34 +0200 Subject: [PATCH 1/6] feat(swap): disable unsupported token --- src/components/pages/swap/Swap.jsx | 29 ++++++++++++++++++++++------- src/hooks/use-swap.js | 8 ++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/components/pages/swap/Swap.jsx b/src/components/pages/swap/Swap.jsx index 841c0c6b..074e382a 100644 --- a/src/components/pages/swap/Swap.jsx +++ b/src/components/pages/swap/Swap.jsx @@ -410,12 +410,19 @@ const Swap = ({ caution! ) : null} - {from && from.isNative && to && to && to.notifyDepositAddressWarning && ( - - Please refrain from using previously generated deposit addresses, as doing so may result in a loss of - funds. - - )} + {from && + from.isNative && + to && + to && + to.notifyDepositAddressWarning && + to.id !== 'PBTC_ON_ARBITRUM_MAINNET' && + to.id !== 'PBTC_ON_TELOS_MAINNET' && + to.id !== 'PBTC_ON_LIBRE_MAINNET' && ( + + Please refrain from using previously generated deposit addresses, as doing so may result in a loss + of funds. + + )} {from && from.id === 'GALA_ON_BSC_MAINNET' && to && to.id === 'GALA' ? ( You are about to pegout (redeem){' '} @@ -453,6 +460,8 @@ const Swap = ({ {(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 === 'BTC' && to && to.id === 'PBTC_ON_LIBRE_MAINNET') || + (from && from.id === 'BTC' && to && to.id === 'PBTC_ON_TELOS_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') || @@ -462,8 +471,14 @@ const Swap = ({ (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 === 'TLOS' && to && to.id === 'TLOS_ON_ETH_MAINNET') || + (from && from.id === 'TLOS' && to && to.id === 'TLOS_ON_BSC_MAINNET') || + (from && from.id === 'USDT' && to && to.id === 'PUSDT_ON_LIBRE_MAINNET') || + (from && from.id === 'USDT' && to && to.id === 'PUSDT_ON_TELOS_MAINNET') || + (from && from.id === 'ETH' && to && to.id === 'PETH_ON_TELOS_MAINNET') || + (from && from.id === 'NUCO' && to && to.id === 'NUCO_ON_TELOS_MAINNET') || (from && from.id === 'ZMT' && to && to.id === 'ZMT_ON_BSC_MAINNET') ? ( - {`${to.name} on ${to.blockchain} has been dismissed and pegins are disabled. Pegouts are available until 09/30/2024`} + {`${to.name} on ${to.blockchain} has been dismissed and pegins are disabled. Pegout the native token ASAP for a smooth redeem process.`} ) : null} {to && (to.id === 'PUSDC_ON_ALGORAND_MAINNET' || diff --git a/src/hooks/use-swap.js b/src/hooks/use-swap.js index c3248533..54ce52b7 100644 --- a/src/hooks/use-swap.js +++ b/src/hooks/use-swap.js @@ -323,6 +323,8 @@ const useSwap = ({ (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 === 'BTC' && to.id === 'PBTC_ON_LIBRE_MAINNET') || + (from.id === 'BTC' && to.id === 'PBTC_ON_TELOS_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') || @@ -332,6 +334,12 @@ const useSwap = ({ (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 === 'TLOS' && to.id === 'TLOS_ON_ETH_MAINNET') || + (from.id === 'TLOS' && to.id === 'TLOS_ON_BSC_MAINNET') || + (from.id === 'USDT' && to.id === 'PUSDT_ON_LIBRE_MAINNET') || + (from.id === 'USDT' && to.id === 'PUSDT_ON_TELOS_MAINNET') || + (from.id === 'ETH' && to.id === 'PETH_ON_TELOS_MAINNET') || + (from.id === 'NUCO' && to.id === 'NUCO_ON_TELOS_MAINNET') || (from.id === 'ZMT' && to.id === 'ZMT_ON_BSC_MAINNET') ) { updateSwapButton('Disabled Swap', true) From daa9884fce3c1860dc5bd3bd2c8b5b6f1042f0db Mon Sep 17 00:00:00 2001 From: envin Date: Mon, 9 Sep 2024 17:03:38 +0200 Subject: [PATCH 2/6] refactor(swap): cleanup code --- src/components/pages/swap/Swap.jsx | 25 ++----------------------- src/settings/swap-assets.js | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/components/pages/swap/Swap.jsx b/src/components/pages/swap/Swap.jsx index 074e382a..942d3b67 100644 --- a/src/components/pages/swap/Swap.jsx +++ b/src/components/pages/swap/Swap.jsx @@ -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' @@ -413,7 +413,6 @@ const Swap = ({ {from && from.isNative && to && - to && to.notifyDepositAddressWarning && to.id !== 'PBTC_ON_ARBITRUM_MAINNET' && to.id !== 'PBTC_ON_TELOS_MAINNET' && @@ -457,27 +456,7 @@ const Swap = ({ direct control (i.e. not a CEX deposit address). ) : 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 === 'BTC' && to && to.id === 'PBTC_ON_LIBRE_MAINNET') || - (from && from.id === 'BTC' && to && to.id === 'PBTC_ON_TELOS_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 === 'TLOS' && to && to.id === 'TLOS_ON_ETH_MAINNET') || - (from && from.id === 'TLOS' && to && to.id === 'TLOS_ON_BSC_MAINNET') || - (from && from.id === 'USDT' && to && to.id === 'PUSDT_ON_LIBRE_MAINNET') || - (from && from.id === 'USDT' && to && to.id === 'PUSDT_ON_TELOS_MAINNET') || - (from && from.id === 'ETH' && to && to.id === 'PETH_ON_TELOS_MAINNET') || - (from && from.id === 'NUCO' && to && to.id === 'NUCO_ON_TELOS_MAINNET') || - (from && from.id === 'ZMT' && to && to.id === 'ZMT_ON_BSC_MAINNET') ? ( + {from && to && (disabledAssets.includes(from.id) || disabledAssets.includes(to.id)) ? ( {`${to.name} on ${to.blockchain} has been dismissed and pegins are disabled. Pegout the native token ASAP for a smooth redeem process.`} ) : null} {to && diff --git a/src/settings/swap-assets.js b/src/settings/swap-assets.js index c7b0df12..138545fc 100644 --- a/src/settings/swap-assets.js +++ b/src/settings/swap-assets.js @@ -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 #################*/ { From acca86393cf095f293a235dd8913ada8d8f12f46 Mon Sep 17 00:00:00 2001 From: envin Date: Mon, 9 Sep 2024 17:04:19 +0200 Subject: [PATCH 3/6] feat(swap): disable pegins also from other ptokens --- src/hooks/use-swap.js | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/hooks/use-swap.js b/src/hooks/use-swap.js index 54ce52b7..3904d37c 100644 --- a/src/hooks/use-swap.js +++ b/src/hooks/use-swap.js @@ -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' @@ -319,29 +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 === 'BTC' && to.id === 'PBTC_ON_LIBRE_MAINNET') || - (from.id === 'BTC' && to.id === 'PBTC_ON_TELOS_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 === 'TLOS' && to.id === 'TLOS_ON_ETH_MAINNET') || - (from.id === 'TLOS' && to.id === 'TLOS_ON_BSC_MAINNET') || - (from.id === 'USDT' && to.id === 'PUSDT_ON_LIBRE_MAINNET') || - (from.id === 'USDT' && to.id === 'PUSDT_ON_TELOS_MAINNET') || - (from.id === 'ETH' && to.id === 'PETH_ON_TELOS_MAINNET') || - (from.id === 'NUCO' && to.id === 'NUCO_ON_TELOS_MAINNET') || - (from.id === 'ZMT' && to.id === 'ZMT_ON_BSC_MAINNET') - ) { + if (disabledAssets.includes(to.id)) { updateSwapButton('Disabled Swap', true) return } From 34ae53dea95a19754a0020588930ca116fe2d6d6 Mon Sep 17 00:00:00 2001 From: envin Date: Mon, 9 Sep 2024 17:07:02 +0200 Subject: [PATCH 4/6] chore(package): update deps --- package-lock.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8fa0471..e60887e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22790,9 +22790,10 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", + "license": "MIT", "engines": { "node": ">=8.3.0" }, From 6c0b0300f29de522f521d406ba163837cb9e9ab0 Mon Sep 17 00:00:00 2001 From: envin Date: Mon, 9 Sep 2024 17:17:23 +0200 Subject: [PATCH 5/6] chore: update snyk waive --- .snyk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.snyk b/.snyk index c55bdd38..d22ef4fa 100644 --- a/.snyk +++ b/.snyk @@ -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: {} From 74bc63156a16e72f526c8e24dea37aa5d1c6c424 Mon Sep 17 00:00:00 2001 From: envin Date: Mon, 9 Sep 2024 17:18:51 +0200 Subject: [PATCH 6/6] chore: add changeset comment --- .changeset/khaki-tomatoes-own.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/khaki-tomatoes-own.md diff --git a/.changeset/khaki-tomatoes-own.md b/.changeset/khaki-tomatoes-own.md new file mode 100644 index 00000000..99ef0bca --- /dev/null +++ b/.changeset/khaki-tomatoes-own.md @@ -0,0 +1,5 @@ +--- +'ptokens-dapp-v2': minor +--- + +disable unsupported tokens