From 8d27af9a309d4985211954aaa0153cb17d627fab Mon Sep 17 00:00:00 2001 From: envin Date: Wed, 27 Nov 2024 15:44:12 +0100 Subject: [PATCH 01/16] refactor: remove all ptokens.io references --- SECURITY.md | 2 +- __mocks__/@p.network/react-web3-settings.js | 9 ++++----- src/App.jsx | 2 +- .../molecules/popup/__test__/RedirectBanner.test.jsx | 6 +++--- src/settings/__tests__/utils.test.js | 4 ++-- src/settings/index.js | 4 ++-- src/store/migration/migration.actions.js | 2 +- src/utils/url.js | 10 +--------- 8 files changed, 15 insertions(+), 24 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 81b882d7..19ffa3a3 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,7 +1,7 @@ # Security Policy Pnetwork declines any responibilites coming from the use of this repository. Use it use at your own risk. -Please check https://dapp.ptokens.io/#/risks to understand risks involved. +Please check https://dapp.p.network/#/risks to understand risks involved. ## Supported Versions diff --git a/__mocks__/@p.network/react-web3-settings.js b/__mocks__/@p.network/react-web3-settings.js index 616a271d..0a581fc5 100644 --- a/__mocks__/@p.network/react-web3-settings.js +++ b/__mocks__/@p.network/react-web3-settings.js @@ -1,16 +1,15 @@ export const getWeb3Settings = () => ({ eth: 'https://cloudflare-eth.com/', - eos: 'https://corsproxy.ptokens.io/v1/?apiurl=https://eos.greymass.com', + eos: 'https://eos.greymass.com', telos: 'https://telos.eosphere.io', - libre: 'https://libre-node-2.ptokens.io:8889', + libre: 'https://lb.libre.org', bsc: 'https://bsc-dataseed1.binance.org/', gnosis: 'https://rpc.gnosischain.com', polygon: 'https://polygon-rpc.com/', - ultra: 'https://corsproxy.ptokens.io/v1/?apiurl=https://api.ultra.eossweden.org', + ultra: 'https://api.ultra.eossweden.org', arbitrum: 'https://arb1.arbitrum.io/rpc', - luxochain: 'https://corsproxy.ptokens.io/v1/?apiurl=https://lugano.nodes.luxochain.io', + luxochain: 'https://lugano.nodes.luxochain.io', algorand: 'https://mainnet-api.algonode.cloud', ftm: 'https://rpc.ftm.tools/', - ore: 'https://ore-node-1.ptokens.io', btc: 'https://blockstream.info/api/', }) diff --git a/src/App.jsx b/src/App.jsx index 99ad82b9..5a88d626 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -141,7 +141,7 @@ const App = ({ loading, setTheme, loadSwapData, loadSwapOldPntData, loadMigratio Now the dApp supports host-to-host swaps!
Have a try{' '} - + here. diff --git a/src/components/molecules/popup/__test__/RedirectBanner.test.jsx b/src/components/molecules/popup/__test__/RedirectBanner.test.jsx index 822f2563..a8575663 100644 --- a/src/components/molecules/popup/__test__/RedirectBanner.test.jsx +++ b/src/components/molecules/popup/__test__/RedirectBanner.test.jsx @@ -8,9 +8,9 @@ const expectedText = 'You are using an old domain that will be dismissed in the describe('RedirectBanner', async () => { test.each([ - ['http://ptokens.io'], - ['http://dapp.ptokens.io'], - ['https://dapp.ptokens.io/#/swap?asset=btc&from=btc&to=eth'], + ['http://p.network'], + ['http://dapp.p.network'], + ['https://dapp.p.network/#/swap?asset=btc&from=btc&to=eth'], ])('Should show the url popup only on specific url', async (url) => { Object.defineProperty(window, 'location', { value: { diff --git a/src/settings/__tests__/utils.test.js b/src/settings/__tests__/utils.test.js index 342987ea..f1a6bcb5 100644 --- a/src/settings/__tests__/utils.test.js +++ b/src/settings/__tests__/utils.test.js @@ -10,7 +10,7 @@ describe('generateRpcSettings', () => { host: 'https://eos.greymass.com', port: 443, protocol: 'https', - endpoint: 'https://corsproxy.ptokens.io/v1/?apiurl=https://eos.greymass.com', + endpoint: 'https://eos.greymass.com', label: 'Eos', }, ftm: { @@ -22,7 +22,7 @@ describe('generateRpcSettings', () => { const expected = { eos: { label: 'Eos', - value: 'https://corsproxy.ptokens.io/v1/?apiurl=https://eos.greymass.com', + value: 'https://eos.greymass.com', }, ftm: { label: 'Ftm', diff --git a/src/settings/index.js b/src/settings/index.js index e7b33c7f..0784e5e0 100644 --- a/src/settings/index.js +++ b/src/settings/index.js @@ -87,10 +87,10 @@ const settings = { }, libre: { chainId: '38b1d7815474d0c60683ecbea321d723e83f5da6ae5f1c1f9fecc69d9ba96465', - host: 'libre-node-2.ptokens.io', + host: 'lb.libre.org', port: 443, protocol: 'https', - endpoint: 'https://libre-node-2.ptokens.io:8889', + endpoint: 'https://lb.libre.org', label: 'Libre', }, bsc: { diff --git a/src/store/migration/migration.actions.js b/src/store/migration/migration.actions.js index b7362c00..507239d8 100644 --- a/src/store/migration/migration.actions.js +++ b/src/store/migration/migration.actions.js @@ -45,7 +45,7 @@ const loadApys = () => { try { const { data: { result }, - } = await axios.get('https://extra.ptokens.io/pbtc-v1-migration-apys') + } = await axios.get('https://extra.p.network/pbtc-v1-migration-apys') _dispatch({ type: APYS_LOADED, payload: { diff --git a/src/utils/url.js b/src/utils/url.js index 2f10a812..d6c66c0c 100644 --- a/src/utils/url.js +++ b/src/utils/url.js @@ -1,7 +1,5 @@ import history from './history' -const LEGACY_DAPP_BASE_URL = 'http://dapp-legacy.ptokens.io/' - const encodeForUrl = (_str) => encodeURIComponent(_str).toLowerCase() const updateUrlForSwap = (_from, _to) => @@ -16,10 +14,4 @@ const updateUrlForSwap = (_from, _to) => ` ) -const getLegacyUrl = (_from, _to) => - LEGACY_DAPP_BASE_URL + - `swap?asset=${encodeForUrl(_from.nativeSymbol)}&from=${encodeForUrl(_from.blockchain)}&to=${encodeForUrl( - _to.blockchain - )}` - -export { getLegacyUrl, updateUrlForSwap } +export { updateUrlForSwap } From 5753a8878d747b1d016d470e6cbc6eac85a27b0b Mon Sep 17 00:00:00 2001 From: envin Date: Thu, 28 Nov 2024 03:08:36 +0100 Subject: [PATCH 02/16] feat: update warning for cold shutdown --- src/components/molecules/popup/Warning.jsx | 14 +- src/components/pages/swap/Swap.jsx | 219 ++------------------- 2 files changed, 20 insertions(+), 213 deletions(-) diff --git a/src/components/molecules/popup/Warning.jsx b/src/components/molecules/popup/Warning.jsx index a37548c5..c1df0a57 100644 --- a/src/components/molecules/popup/Warning.jsx +++ b/src/components/molecules/popup/Warning.jsx @@ -18,7 +18,7 @@ const WarningIcon = styled(Icon)` height: 20px; width: 20px; margin: 5px; - vertical-align: top; + vertical-align: mid; color: #475965; ` @@ -32,15 +32,19 @@ const WarningPopup = ({ show, onClose }) => { return ( - + + PNETWORK V2 HAS REACHED END OF LIFE + +
+ If you want to redeem pTokens proceed at your own risk.
- pNetwork is a new technology, and security audits don't + Please be aware that the pegout tx burns the amount
- eliminate risks completely. Please don't provide assets you + of pTokens selected. Please be patient as completion times
- can't afford to lose. + for redeems are uncertain and may take several days.
diff --git a/src/components/pages/swap/Swap.jsx b/src/components/pages/swap/Swap.jsx index 70516c3d..5ba3fc8a 100644 --- a/src/components/pages/swap/Swap.jsx +++ b/src/components/pages/swap/Swap.jsx @@ -1,5 +1,4 @@ import BigNumber from 'bignumber.js' -import _ from 'lodash' import PropTypes from 'prop-types' import React, { useCallback, useEffect, useState } from 'react' import { Row, Col, Container } from 'react-bootstrap' @@ -7,20 +6,18 @@ import ReactTooltip from 'react-tooltip' import styled from 'styled-components' import TermsOfService from '../../../components/molecules/popup/TermsOfService' -import { MAX_IMPACT, PBTC_ON_ETH_MAINNET_V1_MIGRATION, PUOS_ON_ULTRA_MAINNET } from '../../../constants' +import { PBTC_ON_ETH_MAINNET_V1_MIGRATION } from '../../../constants' import { sendEvent } from '../../../ga4' import { useAssets } from '../../../hooks/use-assets' import { useSwap } from '../../../hooks/use-swap' -import defaultAssets, { dismissedAssets } from '../../../settings/swap-assets' +import defaultAssets from '../../../settings/swap-assets' import Button from '../../atoms/button/Button' import Icon from '../../atoms/icon/Icon' -import Switch from '../../atoms/switch/Switch' import AddressWarning from '../../molecules/popup/AddressWarning' import Progress from '../../molecules/progress/Progress' import AssetListModal from '../../organisms/assetListModal/AssetListModal' import DepositAddressModal from '../../organisms/depositAddressModal/DepositAddressModal' import InfoModal from '../../organisms/infoModal/InfoModal' -import SwapInfo from '../../organisms/swapInfo/SwapInfo' import SwapLine from '../../organisms/swapLine/SwapLine' export const OuterContainerSwap = styled.div` @@ -128,10 +125,6 @@ const WarningEta = styled.div` text-align: center; ` -const ProvisionalSafemoonBox = styled(InfoEta)`` - -const CurveInfo = styled(InfoEta)`` - const MigrationNotification = styled(InfoEta)` width: 460px; margin-bottom: 30px; @@ -150,23 +143,6 @@ const PnetworkV2Badge = styled.span` padding: 5px 10px 5px 10px; ` -const EnableTelosEvmRow = styled.div` - display: flex; - padding: 0px 6px 0px 6px; - align-items: center; -` - -const EnableTelosEvmText = styled.span` - padding-left: 0px; - text-align: left; - font-weight: 300; - color: ${({ theme }) => theme.text1}; - font-size: 14px; - @media (max-width: 767.98px) { - font-size: 12px; - } -` - const Link = styled.span` color: #007bff; text-decoration: none; @@ -371,186 +347,22 @@ const Swap = ({ onMax={onToMax} /> - {from && - (from.id === 'TLOS_ON_BSC_MAINNET' || from.id === 'TLOS_ON_ETH_MAINNET') && - to && - to.id === 'TLOS' ? ( - - - Receive on a tEVM (Telos EVM) compatible address - - - - - - ) : null} + {progress.show ? ( ) : null} - {(to && to.id === 'PBTC_ON_BSC_MAINNET') || (from && from.id === 'PBTC_ON_BSC_MAINNET') ? ( - - pBTC on BSC has been relaunched on pNetwork v2 in late 2022 (token address - 0x1003d3574ac79303a5fa0951ecb04cc7acba9747) and it is the only official pBTC representation on BSC. - - ) : null} - {to && to.id === 'UOS' ? ( - - By bridging to Ethereum you will get native ERC20 UOS tokens passing through the pUOS pToken - - ) : null} - {to && to.id === PUOS_ON_ULTRA_MAINNET ? ( - By bridging to Ultra you will get native UOS tokens passing through the pUOS pToken - ) : null} - {to && to.id === 'PBTC_ON_ALGORAND_MAINNET' ? ( - - Please make sure that the receiving Algorand account has opted in for pBTC (Asset ID: {to.address}). -
-
- pBTC on Algorand is still experimental and the security audit is ongoing - please proceed with - caution! -
- ) : null} - {from && - from.isNative && - to && - to.notifyDepositAddressWarning && - to.id !== 'PBTC_ON_ARBITRUM_MAINNET' && - to.id !== 'PBTC_ON_TELOS_MAINNET' && - to.id !== 'PBTC_ON_LIBRE_MAINNET' && - !(dismissedAssets.includes(from.id) || dismissedAssets.includes(to.id)) && ( - - 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){' '} - - pGALA on BSC - {' '} - for GALA ERC-20. You will receive both{' '} - - GALA v1 - {' '} - and{' '} - - GALA v2 - {' '} - tokens at the same time (Check the official{' '} - - GalaGames channels - {' '} - for more information on GALA v2). Make sure that the destination address you provide is under your - direct control (i.e. not a CEX deposit address). - - ) : null} - {from && to && !dismissedAssets.includes(from.id) && !dismissedAssets.includes(to.id) ? ( - from.isNative ? ( - - {`${from.name} on ${from.blockchain} has been dismissed. Please pegout ASAP if you have pTokens.`} - - ) : to.isNative ? ( - {`Proceed ASAP for a smooth redeem process.`} - ) : ( - - {`${from.name} on ${from.blockchain} and ${to.name} on ${to.blockchain} have been dismissed. - Please pegout to ${from.nativeSymbol} if you have pTokens ASAP.`} - - ) - ) : null} - {to && - (to.id === 'PUSDC_ON_ALGORAND_MAINNET' || - to.id === 'USDC_ON_ALGORAND_MAINNET' || - to.id === 'PUSDT_ON_ALGORAND_MAINNET' || - to.id === 'USDT_ON_ALGORAND_MAINNET') ? ( - - Please make sure that the receiving Algorand account has opted in for {to.name} (Asset ID:{' '} - {to.address}) {to.ptokenAddress ? `and p${to.name} (Asset ID: ${to.ptokenAddress})` : null}. - {to.swapperAddress && ( - <> -
-
- Please note that under certain circumstances (i.e. low liquidity in the stableswap pool), - especially for bigger swaps, you may receive p{to.name} rather than native {to.nativeSymbol}. - - )} -
- ) : null} - {to && to.swapperAddress && _.isNil(poolAmount) ? ( + + {from && to && !to.isNative ? ( - It is currently not possible to check the liquidity pool availability. It is possible the configured - Algorand endpoint is offline, please try with a different one. If the amount exceeds the pool - availability you will likely receive p{to.symbol} rather than native {to.nativeSymbol}. Proceed at - your own risk. + {`pNetwork v2 has been dismissed. Pegin are disabled.`} - ) : null} - {from && from.swapperAddress && _.isNil(poolAmount) ? ( + ) : - It is currently not possible to check the liquidity pool availability. It is possible the configured - Algorand endpoint is offline, please try with a different one. If the amount exceeds the pool - availability, the transaction will likely fail. + pNetwork v2 has been dismissed. Pegout at your own risk. Please be patient as completion times for redeems are uncertain and may take several days. + Expected return amount is only indicative and actual fees cannot be predicted at swap time. - ) : null} - {to && to.swapperAddress && poolAmount < 1.2 * toAmount ? ( - - Due to insufficient liquidity it may not be possible to process a swap of this size. Please try with a - smaller amount or try again later. If you decide to proceed anyway, you may receive p{to.symbol}{' '} - instead. - - ) : null} - {from && from.swapperAddress && poolAmount < fromAmount ? ( - - There is not enough liquidity in the stableswap pool to process this swap right now, please try again - later - - ) : null} - {eta === -1 || eta > 15 ? ( - - {eta > 15 && eta < 45 - ? 'Please note that this operation may take longer than usual to get processed as the bridge is experiencing some delays.' - : 'Please note that this operation may take longer than usual to get processed as the bridge is experiencing major delays.'} - - ) : null} - {from && to && (from.symbol.toUpperCase() === 'SAFEMOON' || to.symbol.toUpperCase() === 'SAFEMOON') ? ( - - Using this bridge requires a SFM transfer on BSC so a transfer fee may apply - - ) : null} - {from && from.requiresCurve ? ( - - This swap works using Curve.fi.

- - More info about Curve.fi - -

- - More info about the used liquidity pool - -
- ) : null} - {from && from.requiresCurve && +curveImpact > MAX_IMPACT ? ( - High price impact! - ) : null} - {!onPnetworkV2 ? ( - This swap is not supported by pNetwork v2. Please write to hello@p.network. - ) : null} + } +