1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-28 00:27:49 +02:00

Fix: show test label according to network type (#1002)

Co-authored-by: ClaudiaHolhos <claudia@oceanprotocol.com>
This commit is contained in:
claudiaHash 2022-01-17 21:47:03 +02:00 committed by GitHub
parent fea0c1bfac
commit 6689f55808
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

@ -17,8 +17,10 @@ import { getEnsName } from '@utils/ens'
import { getOceanBalance } from '@utils/ocean' import { getOceanBalance } from '@utils/ocean'
import useNetworkMetadata, { import useNetworkMetadata, {
getNetworkDataById, getNetworkDataById,
getNetworkDisplayName getNetworkDisplayName,
} from '@hooks/useNetworkMetadata' getNetworkType,
NetworkType
} from '../@hooks/useNetworkMetadata'
interface Web3ProviderValue { interface Web3ProviderValue {
web3: Web3 web3: Web3
@ -260,10 +262,7 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
const networkDisplayName = getNetworkDisplayName(networkData, networkId) const networkDisplayName = getNetworkDisplayName(networkData, networkId)
setNetworkDisplayName(networkDisplayName) setNetworkDisplayName(networkDisplayName)
// Figure out if we're on a chain's testnet, or not setIsTestnet(getNetworkType(networkData) !== NetworkType.Mainnet)
// setIsTestnet(
// networkData?.network !== 'mainnet' && networkData.network !== 'moonriver'
// )
LoggerInstance.log( LoggerInstance.log(
`[web3] Network display name set to: ${networkDisplayName}` `[web3] Network display name set to: ${networkDisplayName}`

View File

@ -1,5 +1,10 @@
import { networkDataGaiaX } from './constants' import { networkDataGaiaX } from './constants'
export enum NetworkType {
Mainnet = 'mainnet',
Testnet = 'testnet'
}
export function getNetworkType(network: EthereumListsChain): string { export function getNetworkType(network: EthereumListsChain): string {
// HEADS UP! Hack for getting network's type main/test, without using // HEADS UP! Hack for getting network's type main/test, without using
// .network field, which is innexistent on https://chainid.network/chains.json // .network field, which is innexistent on https://chainid.network/chains.json
@ -9,9 +14,9 @@ export function getNetworkType(network: EthereumListsChain): string {
!network.title?.includes('Testnet') && !network.title?.includes('Testnet') &&
network.name !== 'Moonbase Alpha' network.name !== 'Moonbase Alpha'
) { ) {
return 'mainnet' return NetworkType.Mainnet
} else { } else {
return 'testnet' return NetworkType.Testnet
} }
} }