diff --git a/.env.example b/.env.example index 0decfa7..a1eeca2 100644 --- a/.env.example +++ b/.env.example @@ -1,71 +1,16 @@ -# LOCAL -VITE_APP_LOCAL_CAPTCHA_SITE_KEY='' -VITE_APP_LOCAL_FAUCET_URL='' -VITE_APP_LOCAL_FAUCET_ADDRESS='' -VITE_APP_LOCAL_BRIDGE_URL='' -VITE_APP_LOCAL_GRAPHQL_URL='' -VITE_APP_LOCAL_GRAPHQL_WS='' -VITE_APP_LOCAL_RPC='' -VITE_APP_LOCAL_API='' -VITE_APP_LOCAL_EXPLORER_URL='' -VITE_APP_LOCAL_STAKING_URL='' -VITE_APP_LOCAL_CHAIN_NAME='' -VITE_APP_LOCAL_CHAIN_ID='' - -# DEV -VITE_APP_DEV_CAPTCHA_SITE_KEY='' -VITE_APP_DEV_FAUCET_URL='' -VITE_APP_DEV_FAUCET_ADDRESS='' -VITE_APP_DEV_BRIDGE_URL='' -VITE_APP_DEV_GRAPHQL_URL='' -VITE_APP_DEV_GRAPHQL_WS='' -VITE_APP_DEV_RPC='' -VITE_APP_DEV_API='' -VITE_APP_DEV_EXPLORER_URL='' -VITE_APP_DEV_STAKING_URL='' -VITE_APP_DEV_CHAIN_NAME='' -VITE_APP_DEV_CHAIN_ID='' - -# PRIVATE -VITE_APP_PRIVATE_CAPTCHA_SITE_KEY='' -VITE_APP_PRIVATE_FAUCET_URL='' -VITE_APP_PRIVATE_FAUCET_ADDRESS='' -VITE_APP_PRIVATE_BRIDGE_URL='' -VITE_APP_PRIVATE_GRAPHQL_URL='' -VITE_APP_PRIVATE_GRAPHQL_WS='' -VITE_APP_PRIVATE_RPC='' -VITE_APP_PRIVATE_API='' -VITE_APP_PRIVATE_EXPLORER_URL='' -VITE_APP_PRIVATE_STAKING_URL='' -VITE_APP_PRIVATE_CHAIN_NAME='' -VITE_APP_PRIVATE_CHAIN_ID='' - -# PUBLIC -VITE_APP_PUBLIC_CAPTCHA_SITE_KEY='' -VITE_APP_PUBLIC_FAUCET_URL='' -VITE_APP_PUBLIC_FAUCET_ADDRESS='' -VITE_APP_PUBLIC_BRIDGE_URL='' -VITE_APP_PUBLIC_GRAPHQL_UR='' -VITE_APP_PUBLIC_GRAPHQL_WS='' -VITE_APP_PUBLIC_RPC='' -VITE_APP_PUBLIC_API='' -VITE_APP_PUBLIC_EXPLORER_URL='' -VITE_APP_PUBLIC_STAKING_URL='' -VITE_APP_PUBLIC_CHAIN_NAME='' -VITE_APP_PUBLIC_CHAIN_ID='' - -# MAINNET -VITE_APP_MAINNET_BRIDGE_URL='' -VITE_APP_MAINNET_GRAPHQL_URL='' -VITE_APP_MAINNET_GRAPHQL_WS='' -VITE_APP_MAINNET_RPC='' -VITE_APP_MAINNET_API='' -VITE_APP_MAINNET_EXPLORER_URL='' -VITE_APP_MAINNET_STAKING_URL='' -VITE_APP_MAINNET_CHAIN_NAME='' -VITE_APP_MAINNET_CHAIN_ID='' - -# GENERAL SETTINGS -VITE_NODE_ENV='' #Production or empty -VITE_APP_DEFAULT_NETWORK='' # LOCAL | PRIVATE | PUBLIC | MAINNET +# APP SETTINGS +VITE_APP_DEPLOYMENT_VERSION='' #v0.0.1 format +VITE_APP_NODE_ENV='' #Production or empty VITE_APP_GAS_PRICE=5000000000000 +VITE_APP_CAPTCHA_SITE_KEY='' +VITE_APP_FAUCET_URL='' +VITE_APP_FAUCET_ADDRESS='' +VITE_APP_BRIDGE_URL='' +VITE_APP_GRAPHQL_URL='' +VITE_APP_GRAPHQL_WS='' +VITE_APP_RPC='' +VITE_APP_API='' +VITE_APP_STAKING_URL='' +VITE_APP_EXPLORER_URL='' +VITE_APP_CHAIN_NAME='' +VITE_APP_CHAIN_ID='' diff --git a/.vscode/launch.json b/.vscode/launch.json index 6384559..45ea252 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,14 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "Launch Edge", + "request": "launch", + "type": "pwa-msedge", + "url": "http://localhost:3000", + "webRoot": "${workspaceFolder}", + "userDataDir": false + }, { "type": "pwa-chrome", "request": "launch", diff --git a/index.html b/index.html index 6c4f905..96e382f 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,10 @@ + diff --git a/package.json b/package.json index 26d59fc..769ca5b 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,10 @@ "bech32": "^2.0.0", "big.js": "^6.1.1", "bignumber.js": "^9.0.2", + "buffer": "^6.0.3", "copy-to-clipboard": "^3.3.1", "cosmjs-types": "^0.4.1", - "cudosjs": "^1.2.5", + "cudosjs": "^1.2.7", "detect-browser": "^5.3.0", "dompurify": "^2.3.8", "graphql": "^16.3.0", diff --git a/src/App.tsx b/src/App.tsx index f55deeb..06a2181 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,14 +1,13 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import { useCallback, useEffect, useState } from 'react' +import { useCallback, useEffect } from 'react' import { ThemeProvider } from '@mui/material/styles' import { useDispatch, useSelector } from 'react-redux' import { Box, CssBaseline } from '@mui/material' -import { ApolloClient, ApolloProvider, NormalizedCacheObject } from '@apollo/client' +import { ApolloProvider } from '@apollo/client' import { Routes, Route, useLocation, Navigate } from 'react-router-dom' import { updateUser } from 'store/profile' import { updateUserTransactions } from 'store/userTransactions' import NotificationPopup from 'components/NotificationPopup' -import CosmosNetworkConfig from 'ledgers/CosmosNetworkConfig' import { switchLedgerType } from 'ledgers/utils' import { connectUser } from './utils/projectUtils' import { useApollo } from './graphql/client' @@ -25,7 +24,7 @@ import theme from './theme' import { RootState } from './store' import '@fontsource/poppins' -import { ApolloLinks, defaultApolloLinks } from 'graphql/helpers' +import { defaultApolloLinks } from 'graphql/helpers' import { CHAIN_DETAILS } from 'utils/constants' import NetworkChangingLoading from 'components/NetworkChangeLoading' import { networkLoadingStyles } from 'components/NetworkChangeLoading/styles' @@ -35,22 +34,20 @@ const App = () => { const location = useLocation() const themeColor = useSelector((state: RootState) => state.settings.theme) const newApolloClient = useApollo(null) - const [currentApolloClient, setCurrentApolloClient] = useState>( - newApolloClient(defaultApolloLinks) - ) + const isMainnet = CHAIN_DETAILS.CHAIN_ID === 'cudos-1' + const { lastLoggedAddress, - chosenNetwork: currentNetwork, connectedLedger, loadingState } = useSelector((state: RootState) => state.profile) const dispatch = useDispatch() - const connectAccount = useCallback(async (chosenNetwork: string, walletName: SUPPORTED_WALLET) => { + const connectAccount = useCallback(async (walletName: SUPPORTED_WALLET) => { try { - const { address } = await switchLedgerType(chosenNetwork!, walletName) + const { address } = await switchLedgerType(walletName) if (address !== lastLoggedAddress || lastLoggedAddress === '') { dispatch( updateUserTransactions({ @@ -62,7 +59,7 @@ const App = () => { ) } - const connectedUser = await connectUser(chosenNetwork, walletName) + const connectedUser = await connectUser(walletName) dispatch(updateUser(connectedUser)) } catch (e) { @@ -82,46 +79,27 @@ const App = () => { }) ) - await connectAccount(currentNetwork, SUPPORTED_WALLET.Keplr) + await connectAccount(SUPPORTED_WALLET.Keplr) }) if (isExtensionEnabled(SUPPORTED_WALLET.Cosmostation)) { window.cosmostation.cosmos.on('accountChanged', async () => { - await connectAccount(currentNetwork, SUPPORTED_WALLET.Cosmostation) + await connectAccount(SUPPORTED_WALLET.Cosmostation) }) } return () => { window.removeEventListener('keplr_keystorechange', async () => { - await connectAccount(currentNetwork, SUPPORTED_WALLET.Keplr) + await connectAccount(SUPPORTED_WALLET.Keplr) }) window.removeEventListener('accountChanged', async () => { - await connectAccount(currentNetwork, SUPPORTED_WALLET.Cosmostation) + await connectAccount(SUPPORTED_WALLET.Cosmostation) }) } }, []) - - useEffect(() => { - dispatch(updateUser({ loadingState: true }) - ) - const newApolloLinks: ApolloLinks = { - uri: CHAIN_DETAILS.GRAPHQL_URL[currentNetwork! as keyof typeof CHAIN_DETAILS.GRAPHQL_URL], - url: CHAIN_DETAILS.GRAPHQL_WS[currentNetwork! as keyof typeof CHAIN_DETAILS.GRAPHQL_WS] - } - - setCurrentApolloClient(newApolloClient(newApolloLinks)) - - if (connectedLedger) { - connectAccount(currentNetwork, connectedLedger) - } - - setTimeout(() => { dispatch(updateUser({ loadingState: false })) }, 4000) - - }, [currentNetwork]) - return ( - + {location.pathname !== '/' ? null : ( @@ -150,13 +128,11 @@ const App = () => { } /> - { - CHAIN_DETAILS.CHAIN_ID[currentNetwork! as keyof typeof CHAIN_DETAILS.CHAIN_ID] - === CHAIN_DETAILS.CHAIN_ID.MAINNET ? null : ( - - } /> - - )} + {isMainnet ? null : ( + + } /> + + )} } /> diff --git a/src/api/getAccountDelegations.ts b/src/api/getAccountDelegations.ts index abba20c..2230112 100644 --- a/src/api/getAccountDelegations.ts +++ b/src/api/getAccountDelegations.ts @@ -3,7 +3,6 @@ import { CHAIN_DETAILS } from 'utils/constants' import { AccountDelegationsDocument } from '../graphql/account_actions' export const fetchDelegations = async ( - chosenNetwork: string, address: string, signal?: AbortSignal ) => { @@ -11,7 +10,7 @@ export const fetchDelegations = async ( try { const { data } = await axios.post( - CHAIN_DETAILS.GRAPHQL_URL[chosenNetwork! as keyof typeof CHAIN_DETAILS.GRAPHQL_URL].toString(), + CHAIN_DETAILS.GRAPHQL_URL, { variables: { address }, query: AccountDelegationsDocument diff --git a/src/api/getAccountRedelegations.ts b/src/api/getAccountRedelegations.ts index ec0915c..a4ddb36 100644 --- a/src/api/getAccountRedelegations.ts +++ b/src/api/getAccountRedelegations.ts @@ -4,7 +4,6 @@ import { CHAIN_DETAILS } from 'utils/constants' import { AccountRedelegationsDocument } from '../graphql/account_actions' export const fetchRedelegations = async ( - chosenNetwork: string, address: string, signal?: AbortSignal ) => { @@ -16,7 +15,7 @@ export const fetchRedelegations = async ( try { const { data } = await axios.post( - CHAIN_DETAILS.GRAPHQL_URL[chosenNetwork! as keyof typeof CHAIN_DETAILS.GRAPHQL_URL].toString(), + CHAIN_DETAILS.GRAPHQL_URL, { variables: { address }, query: AccountRedelegationsDocument diff --git a/src/api/getAccountUndelegations.ts b/src/api/getAccountUndelegations.ts index 55739f2..ddb5941 100644 --- a/src/api/getAccountUndelegations.ts +++ b/src/api/getAccountUndelegations.ts @@ -3,7 +3,6 @@ import { CHAIN_DETAILS } from 'utils/constants' import { AccountUndelegationsDocument } from '../graphql/account_actions' export const fetchUndedelegations = async ( - chosenNetwork: string, address: string, signal?: AbortSignal ) => { @@ -15,7 +14,7 @@ export const fetchUndedelegations = async ( try { const { data } = await axios.post( - CHAIN_DETAILS.GRAPHQL_URL[chosenNetwork! as keyof typeof CHAIN_DETAILS.GRAPHQL_URL].toString(), + CHAIN_DETAILS.GRAPHQL_URL, { variables: { address }, query: AccountUndelegationsDocument diff --git a/src/api/getRewards.ts b/src/api/getRewards.ts index 8d92dc8..a0ed657 100644 --- a/src/api/getRewards.ts +++ b/src/api/getRewards.ts @@ -5,13 +5,13 @@ import { formatBigNum } from '../utils/projectUtils' import { AccountDelegationRewardsDocument } from '../graphql/account_actions' import { CHAIN_DETAILS } from 'utils/constants' -export const fetchRewards = async (chosenNetwork: string, address: string, signal?: AbortSignal) => { +export const fetchRewards = async (address: string, signal?: AbortSignal) => { const defaultReturnValue = new BigNumber(0) const rewardArray: Array = [] const validatorArray: { address: string; amount: string }[] = [] try { const { data } = await axios.post( - CHAIN_DETAILS.GRAPHQL_URL[chosenNetwork! as keyof typeof CHAIN_DETAILS.GRAPHQL_URL].toString(), + CHAIN_DETAILS.GRAPHQL_URL, { variables: { address }, query: AccountDelegationRewardsDocument diff --git a/src/api/getUnbondingBalance.ts b/src/api/getUnbondingBalance.ts index 64d458f..c7ce64f 100644 --- a/src/api/getUnbondingBalance.ts +++ b/src/api/getUnbondingBalance.ts @@ -5,7 +5,6 @@ import { formatBigNum } from 'utils/projectUtils' import { AccountUnbondingBalanceDocument } from '../graphql/account_actions' export const getUnbondingBalance = async ( - chosenNetwork: string, address: string, signal?: AbortSignal ) => { @@ -14,7 +13,7 @@ export const getUnbondingBalance = async ( try { const { data } = await axios.post( - CHAIN_DETAILS.GRAPHQL_URL[chosenNetwork! as keyof typeof CHAIN_DETAILS.GRAPHQL_URL]?.toString(), + CHAIN_DETAILS.GRAPHQL_URL, { variables: { address }, query: AccountUnbondingBalanceDocument diff --git a/src/components/Dialog/components/DelegationModal/Delegation.tsx b/src/components/Dialog/components/DelegationModal/Delegation.tsx index 7094072..d1d5913 100644 --- a/src/components/Dialog/components/DelegationModal/Delegation.tsx +++ b/src/components/Dialog/components/DelegationModal/Delegation.tsx @@ -58,7 +58,7 @@ const Delegation: React.FC = ({ modalProps, handleModal }) => { const [delegationAmount, setDelegationAmount] = useState('') const { validator, amount, fee } = modalProps - const { address, connectedLedger, chosenNetwork } = useSelector( + const { address, connectedLedger } = useSelector( ({ profile }: RootState) => profile ) const dispatch = useDispatch() @@ -66,7 +66,7 @@ const Delegation: React.FC = ({ modalProps, handleModal }) => { useEffect(() => { let isMounted = true const loadBalance = async () => { - const client = await signingClient(chosenNetwork, connectedLedger!) + const client = await signingClient(connectedLedger!) const walletBalance = await client.getBalance( address, @@ -104,7 +104,7 @@ const Delegation: React.FC = ({ modalProps, handleModal }) => { value: msg } - const client = await signingClient(chosenNetwork, connectedLedger!) + const client = await signingClient(connectedLedger!) const gasUsed = await client.simulate(address, [msgAny], 'memo') @@ -162,7 +162,6 @@ const Delegation: React.FC = ({ modalProps, handleModal }) => { try { const delegationResult = await delegate( - chosenNetwork, address, validator?.address || '', amount || '', @@ -176,13 +175,11 @@ const Delegation: React.FC = ({ modalProps, handleModal }) => { txHash: delegationResult.transactionHash }) - const walletBalance = await getWalletBalance(chosenNetwork!, address) + const walletBalance = await getWalletBalance(address) const { delegationsArray } = await fetchDelegations( - chosenNetwork!, address ) const stakedAmountBalance = await getStakedBalance( - chosenNetwork!, address ) @@ -256,11 +253,7 @@ const Delegation: React.FC = ({ modalProps, handleModal }) => { fontWeight={700} color="primary.main" > - { - CHAIN_DETAILS.CHAIN_NAME[ - chosenNetwork as keyof typeof CHAIN_DETAILS.CHAIN_NAME - ] - } + {CHAIN_DETAILS.CHAIN_NAME} diff --git a/src/components/Dialog/components/DelegationModal/Success.tsx b/src/components/Dialog/components/DelegationModal/Success.tsx index accefe8..69d3dc9 100644 --- a/src/components/Dialog/components/DelegationModal/Success.tsx +++ b/src/components/Dialog/components/DelegationModal/Success.tsx @@ -4,8 +4,6 @@ import { DelegationModalProps, initialDelegationModalState } from 'store/modal' import numeral from 'numeral' import SuccessIcon from 'assets/vectors/success.svg' import { ModalContainer, CancelRoundedIcon } from '../styles' -import { RootState } from 'store' -import { useSelector } from 'react-redux' import { CHAIN_DETAILS } from 'utils/constants' type SuccessProps = { @@ -15,7 +13,6 @@ type SuccessProps = { const Success: React.FC = ({ modalProps, handleModal }) => { const { validator, gasUsed, txHash, fee } = modalProps - const { chosenNetwork } = useSelector((state: RootState) => state.profile) const handleClose = () => { handleModal({ @@ -78,9 +75,7 @@ const Success: React.FC = ({ modalProps, handleModal }) => { onClick={() => window .open( - `${ - CHAIN_DETAILS.EXPLORER_URL[chosenNetwork as keyof typeof CHAIN_DETAILS.EXPLORER_URL] - }/transactions/${txHash}`, + `${CHAIN_DETAILS.EXPLORER_URL}/transactions/${txHash}`, '_blank' ) ?.focus() diff --git a/src/components/Layout/Footer.tsx b/src/components/Layout/Footer.tsx index ef56242..cab3287 100644 --- a/src/components/Layout/Footer.tsx +++ b/src/components/Layout/Footer.tsx @@ -8,6 +8,7 @@ import MediumIcon from 'assets/vectors/medium.svg?component' import YouTubeIcon from 'assets/vectors/youtube.svg?component' import FacebookIcon from 'assets/vectors/facebook.svg?component' import SpotifyIcon from 'assets/vectors/spotify.svg?component' +import { APP_DETAILS } from 'utils/constants' import { styles } from './styles' const linksLeft = [ @@ -17,7 +18,8 @@ const linksLeft = [ }, { text: 'Privacy Policy', url: 'https://www.cudos.org/privacy-policy' }, { text: 'cudos.org', url: 'https://www.cudos.org/' }, - { text: `License © 2018 - ${moment().year()}`, url: 'https://www.cudos.org/' } + { text: `License © 2018 - ${moment().year()}`, url: 'https://www.cudos.org/' }, + { text: `${APP_DETAILS.DEPLOYMENT_VERSION}`, url: `https://github.com/CudoVentures/cudos-dashboard/releases/tag/${APP_DETAILS.DEPLOYMENT_VERSION}` } ] const linksRight = [ diff --git a/src/components/Layout/Header.tsx b/src/components/Layout/Header.tsx index e6d9381..6c7e97b 100644 --- a/src/components/Layout/Header.tsx +++ b/src/components/Layout/Header.tsx @@ -19,8 +19,8 @@ const Header = () => { const nagivate = useNavigate() const isMidLowewRes = useMidLowerResCheck() const isMidLowRes = useMidlowResCheck() - const { chosenNetwork, loadingState } = useSelector((state: RootState) => state.profile) - const isMainnet = CHAIN_DETAILS.CHAIN_ID[chosenNetwork as keyof typeof CHAIN_DETAILS.CHAIN_ID] === CHAIN_DETAILS.CHAIN_ID.MAINNET + const { loadingState } = useSelector((state: RootState) => state.profile) + const isMainnet = CHAIN_DETAILS.CHAIN_ID === 'cudos-1' const isWelcomePage = location.pathname === '/' const [logoComponent, setLogoComponent] = useState() @@ -51,7 +51,7 @@ const Header = () => { gap={1} sx={headerStyles.linkHolder} onClick={() => window - .open(CHAIN_DETAILS.BRIDGE_URL[chosenNetwork as keyof typeof CHAIN_DETAILS.BRIDGE_URL], '_blank') + .open(CHAIN_DETAILS.BRIDGE_URL, '_blank') ?.focus()} > diff --git a/src/components/Layout/LeftMenu.tsx b/src/components/Layout/LeftMenu.tsx index d37d7d9..e638651 100644 --- a/src/components/Layout/LeftMenu.tsx +++ b/src/components/Layout/LeftMenu.tsx @@ -11,15 +11,15 @@ import { styles } from './styles' const Menu = () => { const [selected, setSelected] = useState(0) const [menuItems, setMenuItems] = useState([]) - const { chosenNetwork, loadingState } = useSelector((state: RootState) => state.profile) + const { loadingState } = useSelector((state: RootState) => state.profile) const { pathname } = useLocation() const isScreenWidthLessThan1440px = useIsScreenLessThan('1440px', 'width') useEffect(() => { - setMenuItems(getMenuItems(chosenNetwork, loadingState)) + setMenuItems(getMenuItems(loadingState)) - }, [chosenNetwork, loadingState]) + }, [loadingState]) useEffect(() => { diff --git a/src/components/Layout/NetworkInfo.tsx b/src/components/Layout/NetworkInfo.tsx index fc9c0ae..17852e9 100644 --- a/src/components/Layout/NetworkInfo.tsx +++ b/src/components/Layout/NetworkInfo.tsx @@ -1,75 +1,20 @@ -import { useState } from 'react' import { StyledNetwork, styles } from './networkStyles' -import ArrowIcon from 'assets/vectors/arrow-down.svg?component' import { CHAIN_DETAILS } from 'utils/constants' import { COLORS_DARK_THEME } from 'theme/colors' import GlobusIcon from 'assets/vectors/globus-icon.svg?component' -import { Typography, Box, Collapse } from '@mui/material' +import { Typography, Box } from '@mui/material' import { RootState } from 'store' -import { useDispatch, useSelector } from 'react-redux' -import { handleAvailableNetworks } from 'utils/projectUtils' -import { updateUser } from 'store/profile' -import Card from 'components/Card' - -const NetworkLinkComponent = ({ network, setChosenNetwork }: { - network: networkToDisplay, - setChosenNetwork: (selectedNetwork: string) => void -}): JSX.Element => { - - const [hovered, setHovered] = useState(false) - - return ( - setHovered(true)} - onMouseOut={() => setHovered(false)} - onClick={() => setChosenNetwork(network.SHORT_NAMES[0].toUpperCase())} - > - - - {network.ALIAS_NAME} - - - ) -} +import { useSelector } from 'react-redux' +import { getChainPrettyName } from 'utils/projectUtils' const NetworkInfo = () => { - const dispatch = useDispatch() - const [open, setOpen] = useState(false) - const { chosenNetwork, loadingState } = useSelector((state: RootState) => state.profile) - const aliasChainName = CHAIN_DETAILS[chosenNetwork as keyof typeof CHAIN_DETAILS].ALIAS_NAME - const networksToDisplayInMenu = handleAvailableNetworks(CHAIN_DETAILS.DEFAULT_NETWORK) - - const setChosenNetwork = (selectedNetwork: string) => { - dispatch(updateUser({ chosenNetwork: selectedNetwork })) - setOpen(false) - } - - // const collapsable = networksToDisplayInMenu.length > 1 - const collapsable = false + const { loadingState } = useSelector((state: RootState) => state.profile) + const aliasChainName = getChainPrettyName(CHAIN_DETAILS.CHAIN_ID) return ( - - - { } : () => setOpen(true)} - onMouseLeave={() => setOpen(false)} - style={styles.userContainer} - > + + { {aliasChainName} } - {collapsable ? - - - : null} - { } : () => setOpen(true)} - onMouseLeave={() => setOpen(false)} - style={{ marginTop: '-28px', zIndex: '-1' }} - in={open} - > - - {networksToDisplayInMenu.map((NETWORK, idx) => { - return aliasChainName !== NETWORK.ALIAS_NAME ? - : null - })} - - ) } diff --git a/src/components/Layout/UserInfo.tsx b/src/components/Layout/UserInfo.tsx index 68cd016..3a330b1 100644 --- a/src/components/Layout/UserInfo.tsx +++ b/src/components/Layout/UserInfo.tsx @@ -21,7 +21,7 @@ import { styles } from './styles' const UserInfo = () => { const navigate = useNavigate() const dispatch = useDispatch() - const { address, accountName, connectedLedger, chosenNetwork } = useSelector( + const { address, accountName, connectedLedger } = useSelector( (state: RootState) => state.profile ) @@ -38,7 +38,7 @@ const UserInfo = () => { } const handleExplorer = () => { - window.open(`${CHAIN_DETAILS.EXPLORER_URL[chosenNetwork as keyof typeof CHAIN_DETAILS.EXPLORER_URL].toString()}`, '_blank') + window.open(`${CHAIN_DETAILS.EXPLORER_URL}`, '_blank') } const handleDisconnect = () => { @@ -54,8 +54,7 @@ const UserInfo = () => { delegations: [], redelegations: [], undelegations: [], - connectedLedger: '', - chosenNetwork: CHAIN_DETAILS.DEFAULT_NETWORK + connectedLedger: '' }) ) navigate('/') diff --git a/src/components/Layout/menuHelpers.tsx b/src/components/Layout/menuHelpers.tsx index 38417ce..c62e272 100644 --- a/src/components/Layout/menuHelpers.tsx +++ b/src/components/Layout/menuHelpers.tsx @@ -10,7 +10,7 @@ export interface MenuItems { text: string; } -export const getMenuItems = (chosenNetwork: string, loadingState: boolean): MenuItems[] => { +export const getMenuItems = (loadingState: boolean): MenuItems[] => { const MenuItems = [ { icon: , link: '/dashboard', text: 'Dashboard' }, @@ -18,8 +18,8 @@ export const getMenuItems = (chosenNetwork: string, loadingState: boolean): Menu { icon: , link: '/proposals', text: 'Proposals' }, ] - if (CHAIN_DETAILS.CHAIN_ID[chosenNetwork! as keyof typeof CHAIN_DETAILS.CHAIN_ID] - !== CHAIN_DETAILS.CHAIN_ID.MAINNET && !loadingState) { + if (CHAIN_DETAILS.CHAIN_ID + !== 'cudos-1' && !loadingState) { MenuItems.push({ icon: , link: '/faucet', text: 'Faucet' }) } diff --git a/src/components/NetworkChangeLoading/index.tsx b/src/components/NetworkChangeLoading/index.tsx index eaaccfe..ec64e92 100644 --- a/src/components/NetworkChangeLoading/index.tsx +++ b/src/components/NetworkChangeLoading/index.tsx @@ -1,13 +1,11 @@ import { Box, CircularProgress, Typography } from "@mui/material" import { Fragment } from "react" -import { useSelector } from "react-redux" -import { RootState } from "store" import { CHAIN_DETAILS } from "utils/constants" +import { getChainPrettyName } from "utils/projectUtils" const NetworkChangingLoading = () => { - const { chosenNetwork } = useSelector((state: RootState) => state.profile) - const aliasChainName = CHAIN_DETAILS[chosenNetwork as keyof typeof CHAIN_DETAILS].ALIAS_NAME + const aliasChainName = getChainPrettyName(CHAIN_DETAILS.CHAIN_ID) return ( diff --git a/src/containers/ConnectWallet/ConnectWallet.tsx b/src/containers/ConnectWallet/ConnectWallet.tsx index 11e1833..957e98d 100644 --- a/src/containers/ConnectWallet/ConnectWallet.tsx +++ b/src/containers/ConnectWallet/ConnectWallet.tsx @@ -36,7 +36,7 @@ import { styles } from './styles' const ConnectWallet = () => { const dispatch = useDispatch() const navigate = useNavigate() - const { lastLoggedAddress, chosenNetwork: currentNetwork } = useSelector((state: RootState) => state.profile) + const { lastLoggedAddress } = useSelector((state: RootState) => state.profile) const { setWarning } = useNotifications() const [loading, setLoading] = useState(new Map()) const [userBrowser, setUserBrowser] = useState(undefined) @@ -47,18 +47,18 @@ const ConnectWallet = () => { } } - const connect = async (chosenNetwork: string, walletName: SUPPORTED_WALLET) => { + const connect = async (walletName: SUPPORTED_WALLET) => { try { setLoading(new Map(loading.set(walletName, true))) await delay(1000) - const { address } = await switchLedgerType(chosenNetwork, walletName) + const { address } = await switchLedgerType(walletName) if (address !== lastLoggedAddress) { dispatch(updateUserTransactions({ offsetCount: 0, data: [] })) } - const connectedUser = await connectUser(chosenNetwork, walletName) + const connectedUser = await connectUser(walletName) dispatch(updateUser(connectedUser)) navigate('dashboard') @@ -75,7 +75,7 @@ const ConnectWallet = () => { const click = (walletName: SUPPORTED_WALLET) => { if (isExtensionEnabled(walletName)) { - connect(currentNetwork, walletName) + connect(walletName) return } @@ -178,9 +178,9 @@ const ConnectWallet = () => { order to continue you need to connect your Keplr Wallet. - {getSupportedWallets().map((wallet) => { + {getSupportedWallets().map((wallet, idx) => { return ( - +