diff --git a/__mocks__/react-web3-settings.js b/__mocks__/react-web3-settings.js index 67dfe550..22cbfc96 100644 --- a/__mocks__/react-web3-settings.js +++ b/__mocks__/react-web3-settings.js @@ -4,7 +4,7 @@ export const getWeb3Settings = () => ({ telos: 'https://telos.eosphere.io', libre: 'https://libre-node-2.ptokens.io:8889', bsc: 'https://bsc-dataseed1.binance.org/', - xdai: 'https://rpc.xdaichain.com/', + gnosis: 'https://rpc.gnosischain.com', polygon: 'https://polygon-rpc.com/', ultra: 'https://corsproxy.ptokens.io/v1/?apiurl=http://ultra-mainnet-1.ptokens.io:8888', arbitrum: 'https://arb1.arbitrum.io/rpc', diff --git a/package-lock.json b/package-lock.json index c8bed6e1..95f2191d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "plain-dapp-update", - "version": "1.14.1", + "version": "1.14.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "plain-dapp-update", - "version": "1.14.1", + "version": "1.14.2", "dependencies": { "@blockshake/defly-connect": "^1.1.5", "@curvefi/api": "^2.28.0", diff --git a/package.json b/package.json index 07a4f4a0..3934ee0a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "plain-dapp-update", "private": true, - "version": "1.14.1", + "version": "1.14.2", "type": "module", "scripts": { "dev": "npm run create-version-file && vite", diff --git a/public/assets/svg/GNOSIS.svg b/public/assets/svg/GNOSIS.svg new file mode 100644 index 00000000..136f74cb --- /dev/null +++ b/public/assets/svg/GNOSIS.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/public/assets/svg/XDAI.svg b/public/assets/svg/XDAI.svg deleted file mode 100644 index 044b3395..00000000 --- a/public/assets/svg/XDAI.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - -Group 6 -Created with Sketch. - - - - - - - - - - - - diff --git a/src/constants/index.js b/src/constants/index.js index a901e4fd..25660184 100755 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -45,10 +45,10 @@ export const WALLET_POLYGON_CONNECTED = 'WALLET_POLYGON_CONNECTED' export const WALLET_POLYGON_DISCONNECTED = 'WALLET_POLYGON_DISCONNECTED' export const WALLET_POLYGON_NETWORK_CHANGED = 'WALLET_POLYGON_NETWORK_CHANGED' export const WALLET_POLYGON_ACCOUNT_CHANGED = 'WALLET_POLYGON_ACCOUNT_CHANGED' -export const WALLET_XDAI_CONNECTED = 'WALLET_XDAI_CONNECTED' -export const WALLET_XDAI_DISCONNECTED = 'WALLET_XDAI_DISCONNECTED' -export const WALLET_XDAI_NETWORK_CHANGED = 'WALLET_XDAI_NETWORK_CHANGED' -export const WALLET_XDAI_ACCOUNT_CHANGED = 'WALLET_XDAI_ACCOUNT_CHANGED' +export const WALLET_GNOSIS_CONNECTED = 'WALLET_GNOSIS_CONNECTED' +export const WALLET_GNOSIS_DISCONNECTED = 'WALLET_GNOSIS_DISCONNECTED' +export const WALLET_GNOSIS_NETWORK_CHANGED = 'WALLET_GNOSIS_NETWORK_CHANGED' +export const WALLET_GNOSIS_ACCOUNT_CHANGED = 'WALLET_GNOSIS_ACCOUNT_CHANGED' export const WALLET_EOS_CONNECTED = 'WALLET_EOS_CONNECTED' export const WALLET_EOS_DISCONNECTED = 'WALLET_EOS_DISCONNECTED' export const WALLET_TELOS_CONNECTED = 'WALLET_TELOS_CONNECTED' @@ -108,7 +108,7 @@ export const PZRX_ON_EOS_MAINNET = 'PZRX_ON_EOS_MAINNET' export const PPNK_ON_EOS_MAINNET = 'PPNK_ON_EOS_MAINNET' export const PDOGE_ON_ETH_MAINNET = 'PDOGE_ON_ETH_MAINNET' export const PBTC_ON_BSC_MAINNET = 'PBTC_ON_BSC_MAINNET' -export const PBTC_ON_XDAI_MAINNET = 'PBTC_ON_XDAI_MAINNET' +export const PBTC_ON_GNOSIS_MAINNET = 'PBTC_ON_GNOSIS_MAINNET' export const PEOS_ON_POLYGON_MAINNET = 'PEOS_ON_POLYGON_MAINNET' export const IQ_ON_ETH_MAINNET = 'IQ_ON_ETH_MAINNET' export const TLOS_ON_ETH_MAINNET = 'TLOS_ON_ETH_MAINNET' @@ -125,7 +125,7 @@ export const PNT_ON_TELOS_MAINNET = 'PNT_ON_TELOS_MAINNET' export const PUSDT_ON_TELOS_MAINNET = 'PUSDT_ON_TELOS_MAINNET' export const PUSDT_ON_LIBRE_MAINNET = 'PUSDT_ON_LIBRE_MAINNET' export const PUSDC_ON_TELOS_MAINNET = 'PUSDC_ON_TELOS_MAINNET' -export const PNT_ON_XDAI_MAINNET = 'PNT_ON_XDAI_MAINNET' +export const PNT_ON_GNOSIS_MAINNET = 'PNT_ON_GNOSIS_MAINNET' export const PRVN_ON_BSC_MAINNET = 'PRVN_ON_BSC_MAINNET' export const TLOS_ON_BSC_MAINNET = 'TLOS_ON_BSC_MAINNET' export const POPEN_ON_BSC_MAINNET = 'POPEN_ON_BSC_MAINNET' diff --git a/src/hooks/use-assets.js b/src/hooks/use-assets.js index 88ed851e..ec25a307 100644 --- a/src/hooks/use-assets.js +++ b/src/hooks/use-assets.js @@ -1,10 +1,10 @@ -import { useMemo, useState } from 'react' import _ from 'lodash' +import { stringUtils } from 'ptokens-helpers' +import { useMemo, useState } from 'react' import { offChainFormat, strip } from '../utils/amount-utils' -import { blockchainSymbolToName, blockchainSymbolToCoin } from '../utils/maps' import { getCorrespondingTokenExplorerLinkByBlockchain } from '../utils/explorer' -import { stringUtils } from 'ptokens-helpers' +import { blockchainSymbolToName, blockchainSymbolToCoin } from '../utils/maps' const useAssets = (_assets) => { return useMemo(() => { diff --git a/src/hooks/use-wallets.js b/src/hooks/use-wallets.js index a0786f11..2a374cbf 100644 --- a/src/hooks/use-wallets.js +++ b/src/hooks/use-wallets.js @@ -1,6 +1,7 @@ import { useMemo } from 'react' -import { blockchainSymbolToName } from '../utils/maps' + import { slicerByBlockchain } from '../utils/account-viewer' +import { blockchainSymbolToName } from '../utils/maps' const useWallets = (_wallets) => { return useMemo(() => { diff --git a/src/middleware/index.js b/src/middleware/index.js index 58b3700c..fcc7c869 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -6,8 +6,8 @@ import { WALLET_EOS_CONNECTED, WALLET_BSC_CONNECTED, WALLET_BSC_ACCOUNT_CHANGED, - WALLET_XDAI_ACCOUNT_CHANGED, - WALLET_XDAI_CONNECTED, + WALLET_GNOSIS_ACCOUNT_CHANGED, + WALLET_GNOSIS_CONNECTED, WALLET_POLYGON_ACCOUNT_CHANGED, WALLET_POLYGON_CONNECTED, WALLET_TELOS_CONNECTED, @@ -22,13 +22,13 @@ import { WALLET_FTM_CONNECTED, WALLET_FTM_ACCOUNT_CHANGED, } from '../constants' -import { loadBalances } from '../store/swap/swap.actions' +import settings from '../settings' import * as migrationActions from '../store/migration/migration.actions' -import { loadOldPntBalance } from '../store/swap-old-pnt/swap-old-pnt.actions' import { loadNftsData } from '../store/nfts/nfts.actions' import { setLoading } from '../store/pages/pages.actions' import { getIsLoading } from '../store/pages/pages.selectors' -import settings from '../settings' +import { loadBalances } from '../store/swap/swap.actions' +import { loadOldPntBalance } from '../store/swap-old-pnt/swap-old-pnt.actions' let countNftsLoading = 0 const middleware = ({ dispatch }) => { @@ -49,8 +49,8 @@ const middleware = ({ dispatch }) => { dispatch(loadOldPntBalance(payload.account)) } - if (type === WALLET_XDAI_CONNECTED || type === WALLET_XDAI_ACCOUNT_CHANGED) { - dispatch(loadBalances(payload.account, 'XDAI')) + if (type === WALLET_GNOSIS_CONNECTED || type === WALLET_GNOSIS_ACCOUNT_CHANGED) { + dispatch(loadBalances(payload.account, 'GNOSIS')) } if (type === WALLET_POLYGON_CONNECTED || type === WALLET_POLYGON_ACCOUNT_CHANGED) { diff --git a/src/settings/index.js b/src/settings/index.js index 4401bc72..d0655334 100644 --- a/src/settings/index.js +++ b/src/settings/index.js @@ -38,8 +38,8 @@ const settings = { symbol: 'LIBRE', }, { - name: 'xDai', - symbol: 'XDAI', + name: 'Gnosis Chain', + symbol: 'GNOSIS', }, { name: 'Ultra', @@ -102,10 +102,10 @@ const settings = { chainId: 56, label: 'BSC', }, - xdai: { - endpoint: 'https://rpc.xdaichain.com/', + gnosis: { + endpoint: 'https://rpc.gnosischain.com', chainId: 100, - label: 'xDAI', + label: 'Gnosis', }, polygon: { endpoint: 'https://polygon-rpc.com/', @@ -164,7 +164,7 @@ const settings = { libre: 'https://lb.libre.org/v2/explore/', ltc: 'https://live.blockcypher.com/ltc/', bsc: 'https://bscscan.com/', - xdai: 'https://gnosisscan.io/', + gnosis: 'https://gnosisscan.io/', polygon: 'https://polygonscan.com/', doge: 'https://dogechain.info/', rvn: 'https://ravencoin.network/', diff --git a/src/settings/swap-assets.js b/src/settings/swap-assets.js index 338f820c..54ab3366 100644 --- a/src/settings/swap-assets.js +++ b/src/settings/swap-assets.js @@ -654,13 +654,13 @@ const swapAssets = [ }, { address: '0x3effbc016fc50beacd4fa1c7be20cddca38e7f66', - id: 'PBTC_ON_XDAI_MAINNET', + id: 'PBTC_ON_GNOSIS_MAINNET', name: 'pBTC', workingName: 'pbtc', nativeDecimals: 8, network: 'mainnet', isHidden: false, - blockchain: 'XDAI', + blockchain: 'GNOSIS', decimals: 18, withMiniImage: true, symbol: 'PBTC', @@ -669,7 +669,7 @@ const swapAssets = [ nativeBlockchain: 'BTC', image: 'pBTC.svg', withBalanceDecimalsConversion: true, - chainId: ChainId.XDaiMainnet, + chainId: ChainId.XdaiMainnet, }, { address: '0xa23d33d5e0a61ba81919bfd727c671bb03ab0fea', @@ -968,13 +968,13 @@ const swapAssets = [ }, { address: '0x0259461eed4d76d4f0f900f9035f6c4dfb39159a', - id: 'PNT_ON_XDAI_MAINNET', + id: 'PNT_ON_GNOSIS_MAINNET', name: 'PNT', workingName: 'pnt', nativeDecimals: 18, network: 'mainnet', isHidden: false, - blockchain: 'XDAI', + blockchain: 'GNOSIS', decimals: 18, withMiniImage: true, symbol: 'PNT', diff --git a/src/store/swap/swap.actions.js b/src/store/swap/swap.actions.js index d1d7f6d8..9854f45a 100644 --- a/src/store/swap/swap.actions.js +++ b/src/store/swap/swap.actions.js @@ -1,6 +1,8 @@ import axios from 'axios' -import assets from '../../settings/swap-assets' -import settings from '../../settings' +import BigNumber from 'bignumber.js' +import { getAmountInEosFormat } from 'ptokens-assets-eosio' +import Web3 from 'web3' + import { ASSETS_LOADED, SHOW_DEPOSIT_ADDRESS_MODAL, @@ -11,6 +13,17 @@ import { BPM_LOADED, SWAPPERS_BALANCES_LOADED, } from '../../constants/index' +import settings from '../../settings' +import assets from '../../settings/swap-assets' +import eosioTokenAbi from '../../utils/abi/eosio.token' +import { parseError } from '../../utils/errors' +import { createAsset, getSwapBuilder } from '../../utils/ptokens' +import { getReadOnlyProviderByBlockchain } from '../../utils/read-only-providers' +import { updateInfoModal } from '../pages/pages.actions' +import { getWallets, getWalletByBlockchain } from '../wallets/wallets.selectors' + +import { getAssetsByBlockchain, getAssetById } from './swap.selectors' +import { getAsaBalance, encodeUserData, buildPoolSwapTransactions } from './utils/algorand' import { loadEvmCompatibleBalances, loadEosioCompatibleBalances, @@ -18,22 +31,11 @@ import { loadEosioCompatibleBalance, loadAlgorandBalances, } from './utils/balances' -import { parseError } from '../../utils/errors' -import { updateInfoModal } from '../pages/pages.actions' -import { getReadOnlyProviderByBlockchain } from '../../utils/read-only-providers' +import { getDefaultSelection } from './utils/default-selection' import peginWithDepositAddress from './utils/pegin-with-deposit-address' import peginWithWallet from './utils/pegin-with-wallet' import pegout from './utils/pegout' import pegoutFromCurve from './utils/pegout-curve' -import { getAssetsByBlockchain, getAssetById } from './swap.selectors' -import { getWallets, getWalletByBlockchain } from '../wallets/wallets.selectors' -import { getDefaultSelection } from './utils/default-selection' -import { getAsaBalance, encodeUserData, buildPoolSwapTransactions } from './utils/algorand' -import { getAmountInEosFormat } from 'ptokens-assets-eosio' -import Web3 from 'web3' -import BigNumber from 'bignumber.js' -import eosioTokenAbi from '../../utils/abi/eosio.token' -import { createAsset, getSwapBuilder } from '../../utils/ptokens' const loadSwapData = (_opts = {}) => { const { @@ -194,12 +196,12 @@ const loadBalances = (_account, _blockchain) => { }) break } - case 'XDAI': { + case 'GNOSIS': { loadEvmCompatibleBalances({ - assets: getAssetsByBlockchain('XDAI'), + assets: getAssetsByBlockchain('GNOSIS'), account: _account, dispatch: _dispatch, - blockchain: 'XDAI', + blockchain: 'GNOSIS', }) break } @@ -288,8 +290,8 @@ const loadBalanceByAssetId = (_id) => { loadEvmCompatibleBalance({ asset, account, blockchain: 'POLYGON', dispatch: _dispatch }) break } - case 'XDAI': { - loadEvmCompatibleBalance({ asset, account, blockchain: 'XDAI', dispatch: _dispatch }) + case 'GNOSIS': { + loadEvmCompatibleBalance({ asset, account, blockchain: 'GNOSIS', dispatch: _dispatch }) break } case 'TELOS': { diff --git a/src/store/wallets/xdai/index.js b/src/store/wallets/gnosis/index.js similarity index 65% rename from src/store/wallets/xdai/index.js rename to src/store/wallets/gnosis/index.js index 3ff107b1..4a38c3dd 100644 --- a/src/store/wallets/xdai/index.js +++ b/src/store/wallets/gnosis/index.js @@ -1,17 +1,18 @@ +import WalletLink from 'walletlink' import Web3 from 'web3' import Web3Modal from 'web3modal' -import WalletLink from 'walletlink' -import { WALLET_XDAI_CONNECTED, WALLET_XDAI_ACCOUNT_CHANGED, WALLET_XDAI_DISCONNECTED } from '../../../constants' -import { changeNetwork, setupNetwork } from '../../../utils/wallet' + +import { WALLET_GNOSIS_CONNECTED, WALLET_GNOSIS_ACCOUNT_CHANGED, WALLET_GNOSIS_DISCONNECTED } from '../../../constants' import settings from '../../../settings' import { getWeb3ModalTheme } from '../../../theme/web3-modal' +import { changeNetwork, setupNetwork } from '../../../utils/wallet' import { getTheme } from '../../pages/pages.selectors' import { getWalletProviderByBlockchain } from '../wallets.selectors' import { createWalletConnect2 } from '../wallets.utils' let web3Modal -const connectWithXdaiWallet = async (_dispatch) => { +const connectWithGnosisWallet = async (_dispatch) => { try { if (document.getElementById('WEB3_CONNECT_MODAL_ID')) { document.getElementById('WEB3_CONNECT_MODAL_ID').remove() @@ -20,13 +21,13 @@ const connectWithXdaiWallet = async (_dispatch) => { web3Modal = new Web3Modal({ theme: getWeb3ModalTheme(getTheme()), providerOptions: { - 'custom-walletconnectv2': createWalletConnect2(settings.rpc.mainnet.xdai.chainId), + 'custom-walletconnectv2': createWalletConnect2(settings.rpc.mainnet.gnosis.chainId), walletlink: { package: WalletLink, options: { appName: settings.dappName, - rpc: settings.rpc.mainnet.xdai.endpoint, - chainId: settings.rpc.mainnet.xdai.chainId, + rpc: settings.rpc.mainnet.gnosis.endpoint, + chainId: settings.rpc.mainnet.gnosis.chainId, darkMode: getTheme() === 'dark', }, }, @@ -40,7 +41,7 @@ const connectWithXdaiWallet = async (_dispatch) => { provider.on('accountsChanged', (_accounts) => { _dispatch({ - type: WALLET_XDAI_ACCOUNT_CHANGED, + type: WALLET_GNOSIS_ACCOUNT_CHANGED, payload: { account: _accounts[0], }, @@ -51,14 +52,14 @@ const connectWithXdaiWallet = async (_dispatch) => { } } -const disconnectFromXdaiWallet = async (_dispatch) => { - const provider = getWalletProviderByBlockchain('XDAI') +const disconnectFromGnosisWallet = async (_dispatch) => { + const provider = getWalletProviderByBlockchain('GNOSIS') if (provider.close) { await provider.close() } await web3Modal.clearCachedProvider() _dispatch({ - type: WALLET_XDAI_DISCONNECTED, + type: WALLET_GNOSIS_DISCONNECTED, }) } @@ -67,42 +68,42 @@ const _connectionSuccesfull = async (_provider, _dispatch) => { const { accounts, chainId } = _provider const account = accounts ? accounts[0] : await _getAccount(_provider) - if (Number(chainId) !== settings.rpc.mainnet.xdai.chainId && _provider.isMetaMask) { + if (Number(chainId) !== settings.rpc.mainnet.gnosis.chainId && _provider.isMetaMask) { try { await changeNetwork({ provider: _provider, - chainId: settings.rpc.mainnet.xdai.chainId, + chainId: settings.rpc.mainnet.gnosis.chainId, }) } catch (err) { if (err.code === 4902) { await setupNetwork({ provider: _provider, - chainId: settings.rpc.mainnet.xdai.chainId, - chainName: 'XDAI', + chainId: settings.rpc.mainnet.gnosis.chainId, + chainName: 'Gnosis Chain', nativeCurrency: { - name: 'MATIC', - symbol: 'matic', + name: 'xDAI', + symbol: 'xDAI', decimals: 18, }, - nodes: [settings.rpc.mainnet.xdai.endpoint], - blockExplorerUrls: [settings.explorers.mainnet.xdai], + nodes: [settings.rpc.mainnet.gnosis.endpoint], + blockExplorerUrls: [settings.explorers.mainnet.gnosis], }) } } _dispatch({ - type: WALLET_XDAI_CONNECTED, + type: WALLET_GNOSIS_CONNECTED, payload: { provider: _provider, account, network: 'mainnet', - chainId: settings.rpc.mainnet.xdai.chainId, + chainId: settings.rpc.mainnet.gnosis.chainId, }, }) return - } else if (Number(chainId) === settings.rpc.mainnet.xdai.chainId) { + } else if (Number(chainId) === settings.rpc.mainnet.gnosis.chainId) { _dispatch({ - type: WALLET_XDAI_CONNECTED, + type: WALLET_GNOSIS_CONNECTED, payload: { provider: _provider, account, @@ -122,8 +123,8 @@ const _getAccount = async (_provider) => { const accounts = await web3.eth.getAccounts() return accounts[0] } catch (_err) { - console.error(`Error during getting xDai account ${_err.message}`) + console.error(`Error during getting Gnosis account ${_err.message}`) } } -export { connectWithXdaiWallet, disconnectFromXdaiWallet } +export { connectWithGnosisWallet, disconnectFromGnosisWallet } diff --git a/src/store/wallets/wallets.actions.js b/src/store/wallets/wallets.actions.js index 0d93ee0c..50169e99 100644 --- a/src/store/wallets/wallets.actions.js +++ b/src/store/wallets/wallets.actions.js @@ -1,17 +1,18 @@ +import { sendEvent } from '../../ga4' + +import { connectWithAlgorandWallet, disconnectFromAlgorandWallet } from './algorand' import { connectWithArbitrumWallet, disconnectFromArbitrumWallet } from './arbitrum' +import { connectWithBscWallet, disconnectFromBscWallet } from './bsc' import { connectWithEosWallet, disconnectFromEosWallet } from './eos' import { connectWithEthWallet, disconnectFromEthWallet } from './eth' -import { connectWithBscWallet, disconnectFromBscWallet } from './bsc' -import { connectWithPolygonWallet, disconnectFromPolygonWallet } from './polygon' -import { connectWithXdaiWallet, disconnectFromXdaiWallet } from './xdai' -import { connectWithTelosWallet, disconnectFromTelosWallet } from './telos' +import { connectWithFtmWallet, disconnectFromFtmWallet } from './ftm' +import { connectWithGnosisWallet, disconnectFromGnosisWallet } from './gnosis' import { connectWithLibreWallet, disconnectFromLibreWallet } from './libre' -import { connectWithUltraWallet, disconnectFromUltraWallet } from './ultra' import { connectWithLuxochainWallet, disconnectFromLuxochainWallet } from './luxochain' -import { connectWithAlgorandWallet, disconnectFromAlgorandWallet } from './algorand' -import { connectWithFtmWallet, disconnectFromFtmWallet } from './ftm' import { connectWithOreWallet, disconnectFromOreWallet } from './ore' -import { sendEvent } from '../../ga4' +import { connectWithPolygonWallet, disconnectFromPolygonWallet } from './polygon' +import { connectWithTelosWallet, disconnectFromTelosWallet } from './telos' +import { connectWithUltraWallet, disconnectFromUltraWallet } from './ultra' const connectWithWallet = (_blockchain) => { return async (_dispatch) => { @@ -40,8 +41,8 @@ const connectWithWallet = (_blockchain) => { connectWithPolygonWallet(_dispatch) break } - case 'XDAI': { - connectWithXdaiWallet(_dispatch) + case 'GNOSIS': { + connectWithGnosisWallet(_dispatch) break } case 'ULTRA': { @@ -102,8 +103,8 @@ const disconnectFromWallet = (_blockchain) => { disconnectFromPolygonWallet(_dispatch) break } - case 'XDAI': { - disconnectFromXdaiWallet(_dispatch) + case 'GNOSIS': { + disconnectFromGnosisWallet(_dispatch) break } case 'ULTRA': { diff --git a/src/store/wallets/wallets.reducer.js b/src/store/wallets/wallets.reducer.js index 3b579d78..a5609751 100644 --- a/src/store/wallets/wallets.reducer.js +++ b/src/store/wallets/wallets.reducer.js @@ -9,15 +9,15 @@ import { WALLET_BSC_ACCOUNT_CHANGED, WALLET_POLYGON_CONNECTED, WALLET_POLYGON_ACCOUNT_CHANGED, - WALLET_XDAI_ACCOUNT_CHANGED, - WALLET_XDAI_CONNECTED, + WALLET_GNOSIS_ACCOUNT_CHANGED, + WALLET_GNOSIS_CONNECTED, WALLET_TELOS_CONNECTED, WALLET_LIBRE_CONNECTED, WALLET_ULTRA_CONNECTED, WALLET_ETH_DISCONNECTED, WALLET_BSC_DISCONNECTED, WALLET_POLYGON_DISCONNECTED, - WALLET_XDAI_DISCONNECTED, + WALLET_GNOSIS_DISCONNECTED, WALLET_EOS_DISCONNECTED, WALLET_ULTRA_DISCONNECTED, WALLET_TELOS_DISCONNECTED, @@ -77,7 +77,7 @@ const initialState = { chainId: null, network: null, }, - xdai: { + gnosis: { provider: null, account: null, chainId: null, @@ -167,10 +167,10 @@ const walletsReducer = (_state = initialState, _action) => { }, }) } - if (_action.type === WALLET_XDAI_CONNECTED) { + if (_action.type === WALLET_GNOSIS_CONNECTED) { const { provider, account, network, chainId } = _action.payload return Object.assign({}, _state, { - xdai: { + gnosis: { provider, account, network, @@ -178,11 +178,11 @@ const walletsReducer = (_state = initialState, _action) => { }, }) } - if (_action.type === WALLET_XDAI_ACCOUNT_CHANGED) { + if (_action.type === WALLET_GNOSIS_ACCOUNT_CHANGED) { const { account } = _action.payload return Object.assign({}, _state, { - xdai: { - ..._state.xdai, + gnosis: { + ..._state.gnosis, account, }, }) @@ -278,9 +278,9 @@ const walletsReducer = (_state = initialState, _action) => { }, }) } - if (_action.type === WALLET_XDAI_DISCONNECTED) { + if (_action.type === WALLET_GNOSIS_DISCONNECTED) { return Object.assign({}, _state, { - xdai: { + gnosis: { provider: null, account: null, network: null, diff --git a/src/utils/__tests__/account-validator.test.js b/src/utils/__tests__/account-validator.test.js index ae70afbd..218e49aa 100644 --- a/src/utils/__tests__/account-validator.test.js +++ b/src/utils/__tests__/account-validator.test.js @@ -1,6 +1,7 @@ +import { validators } from 'ptokens-helpers' import { test, describe, expect, vi } from 'vitest' + import { isValidAccountByBlockchain } from '../account-validator' -import { validators } from 'ptokens-helpers' describe('isValidAccountByBlockchain', () => { beforeAll(() => { @@ -21,7 +22,7 @@ describe('isValidAccountByBlockchain', () => { account | blockchain | expectedChainId | expectedAccount ${`account`} | ${'ETH'} | ${'0x005fe7f9'} | ${'0xaccount'} ${`0xaccount`} | ${'ETH'} | ${'0x005fe7f9'} | ${'0xaccount'} - ${`account`} | ${'XDAI'} | ${'0x00f1918e'} | ${'0xaccount'} + ${`account`} | ${'GNOSIS'} | ${'0x00f1918e'} | ${'0xaccount'} ${`account`} | ${'POLYGON'} | ${'0x0075dd4c'} | ${'0xaccount'} ${`account`} | ${'BSC'} | ${'0x00e4b170'} | ${'0xaccount'} ${`account`} | ${'ARBITRUM'} | ${'0x00ce98c4'} | ${'0xaccount'} diff --git a/src/utils/__tests__/explorer.test.js b/src/utils/__tests__/explorer.test.js index 948045d1..85d7487c 100644 --- a/src/utils/__tests__/explorer.test.js +++ b/src/utils/__tests__/explorer.test.js @@ -1,10 +1,11 @@ import { test, describe, expect } from 'vitest' + import { getCorrespondingTxExplorerLinkByBlockchain, getCorrespondingTokenExplorerLinkByBlockchain } from '../explorer' describe('getCorrespondingTxExplorerLinkByBlockchain', () => { test.each([ ['ETH', 'https://etherscan.io/tx/txhash'], - ['XDAI', 'https://gnosisscan.io/tx/txhash'], + ['GNOSIS', 'https://gnosisscan.io/tx/txhash'], ['POLYGON', 'https://polygonscan.com/tx/txhash'], ['BSC', 'https://bscscan.com/tx/txhash'], ['EOS', 'https://bloks.io/tx/txhash'], @@ -31,7 +32,7 @@ describe('getCorrespondingTxExplorerLinkByBlockchain', () => { describe('getCorrespondingTokenExplorerLinkByBlockchain', () => { test.each([ ['ETH', 'https://etherscan.io/token/tokenaddress'], - ['XDAI', 'https://gnosisscan.io/token/tokenaddress'], + ['GNOSIS', 'https://gnosisscan.io/token/tokenaddress'], ['POLYGON', 'https://polygonscan.com/address/tokenaddress'], ['BSC', 'https://bscscan.com/token/tokenaddress'], ['EOS', 'https://bloks.io/account/tokenaddress'], diff --git a/src/utils/__tests__/swap-valildator.test.js b/src/utils/__tests__/swap-valildator.test.js index 1e1e0492..8883aee9 100644 --- a/src/utils/__tests__/swap-valildator.test.js +++ b/src/utils/__tests__/swap-valildator.test.js @@ -26,7 +26,7 @@ describe('isValidSwap', () => { 'PBTC_ON_LIBRE_MAINNET', 'PBTC_ON_POLYGON_MAINNET', 'PBTC_ON_TELOS_MAINNET', - 'PBTC_ON_XDAI_MAINNET', + 'PBTC_ON_GNOSIS_MAINNET', 'PBTC_ON_EOS_MAINNET', 'PBTC_ON_TELOS_MAINNET', ], diff --git a/src/utils/account-validator.js b/src/utils/account-validator.js index d15e0765..58fc4815 100644 --- a/src/utils/account-validator.js +++ b/src/utils/account-validator.js @@ -6,7 +6,7 @@ const isValidAccountByBlockchain = (_account, _blockchain) => { switch (_blockchain) { case 'ETH': return validators.isValidAddressByChainId(stringUtils.addHexPrefix(_account), ChainId.EthereumMainnet) - case 'XDAI': + case 'GNOSIS': return validators.isValidAddressByChainId(stringUtils.addHexPrefix(_account), ChainId.XdaiMainnet) case 'POLYGON': return validators.isValidAddressByChainId(stringUtils.addHexPrefix(_account), ChainId.PolygonMainnet) diff --git a/src/utils/estimations.js b/src/utils/estimations.js index b47a790f..7dabc02c 100644 --- a/src/utils/estimations.js +++ b/src/utils/estimations.js @@ -7,7 +7,7 @@ const estimations = { telos: 4, libre: 4, bsc: 5, - xdai: 5, + gnosis: 5, polygon: 5, ltc: 10, doge: 5, diff --git a/src/utils/explorer.js b/src/utils/explorer.js index 68820ac3..cb0113bd 100644 --- a/src/utils/explorer.js +++ b/src/utils/explorer.js @@ -1,9 +1,10 @@ import { sprintf } from 'sprintf-js' + import settings from '../settings' const transactionBaseLink = { ETH: `${settings.explorers.mainnet.eth}tx/%s`, - XDAI: `${settings.explorers.mainnet.xdai}tx/%s`, + GNOSIS: `${settings.explorers.mainnet.gnosis}tx/%s`, POLYGON: `${settings.explorers.mainnet.polygon}tx/%s`, BSC: `${settings.explorers.mainnet.bsc}tx/%s`, EOS: `${settings.explorers.mainnet.eos}tx/%s`, @@ -24,7 +25,7 @@ const transactionBaseLink = { const tokenBaseLink = { ETH: `${settings.explorers.mainnet.eth}token/%s`, - XDAI: `${settings.explorers.mainnet.xdai}token/%s`, + GNOSIS: `${settings.explorers.mainnet.gnosis}token/%s`, POLYGON: `${settings.explorers.mainnet.polygon}address/%s`, BSC: `${settings.explorers.mainnet.bsc}token/%s`, EOS: `${settings.explorers.mainnet.eos}account/%s`, diff --git a/src/utils/maps.js b/src/utils/maps.js index 6b54d580..d08942aa 100644 --- a/src/utils/maps.js +++ b/src/utils/maps.js @@ -4,7 +4,7 @@ const blockchainSymbolToName = { LTC: 'Litecoin', TELOS: 'Telos', LIBRE: 'Libre', - XDAI: 'xDai', + GNOSIS: 'Gnosis Chain', BSC: 'Binance Smart Chain', DOGE: 'Dogecoin', EOS: 'EOS', @@ -25,7 +25,7 @@ const blockchainSymbolToCoin = { LTC: 'Litecoin', TELOS: 'Telos', LIBRE: 'Libre', - XDAI: 'xDai', + GNOSIS: 'xDai', BSC: 'Binance Coin', DOGE: 'Dogecoin', EOS: 'EOS', diff --git a/src/utils/ptokens.js b/src/utils/ptokens.js index 50fb2b7a..c487da2f 100644 --- a/src/utils/ptokens.js +++ b/src/utils/ptokens.js @@ -11,7 +11,7 @@ import { PNETWORK_NODE_V3 } from '../constants/index' import { getReadOnlyProviderByBlockchain } from './read-only-providers' const utxoBlockchains = ['btc', 'ltc'] -const evmBlockchains = ['eth', 'bsc', 'ftm', 'polygon', 'luxochain', 'arbitrum', 'xdai'] +const evmBlockchains = ['eth', 'bsc', 'ftm', 'polygon', 'luxochain', 'arbitrum', 'gnosis'] const eosioBlockchains = ['telos', 'eos', 'libre', 'ultra'] const algorandBlockchains = ['algorand'] diff --git a/src/utils/read-only-providers.js b/src/utils/read-only-providers.js index 2297993b..8acb0175 100644 --- a/src/utils/read-only-providers.js +++ b/src/utils/read-only-providers.js @@ -1,8 +1,8 @@ -import Web3 from 'web3' -import { JsonRpc } from 'eosjs' -import fetch from 'cross-fetch' import { Algodv2 } from 'algosdk' +import fetch from 'cross-fetch' +import { JsonRpc } from 'eosjs' import { getWeb3Settings } from 'react-web3-settings' +import Web3 from 'web3' import settings from '../settings' @@ -19,8 +19,8 @@ const getReadOnlyProviderByBlockchain = (_blockchain) => { if (_blockchain === 'POLYGON') { return new Web3.providers.HttpProvider(configs.polygon) } - if (_blockchain === 'XDAI') { - return new Web3.providers.HttpProvider(configs.xdai) + if (_blockchain === 'GNOSIS') { + return new Web3.providers.HttpProvider(configs.gnosis) } if (_blockchain === 'EOS') { return new JsonRpc(configs.eos, { fetch })