mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
isCorrectNetwork -> isOceanNetwork
This commit is contained in:
parent
74e2d204dc
commit
807723be35
@ -2,7 +2,7 @@ const userMock = {
|
||||
isLogged: false,
|
||||
isLoading: false,
|
||||
isWeb3: false,
|
||||
isCorrectNetwork: false,
|
||||
isOceanNetwork: false,
|
||||
account: '',
|
||||
web3: {},
|
||||
ocean: {},
|
||||
@ -17,7 +17,7 @@ const userMockConnected = {
|
||||
isLogged: true,
|
||||
isLoading: false,
|
||||
isWeb3: true,
|
||||
isCorrectNetwork: true,
|
||||
isOceanNetwork: true,
|
||||
account: '0xxxxxx',
|
||||
web3: {},
|
||||
ocean: {},
|
||||
|
@ -22,7 +22,7 @@ const Indicator = ({
|
||||
{states =>
|
||||
!states.isWeb3 ? (
|
||||
<span className={styles.statusIndicator} />
|
||||
) : !states.isLogged || !states.isCorrectNetwork ? (
|
||||
) : !states.isLogged || !states.isOceanNetwork ? (
|
||||
<span className={styles.statusIndicatorCloseEnough} />
|
||||
) : states.isLogged ? (
|
||||
<span className={styles.statusIndicatorActive} />
|
||||
|
@ -38,7 +38,7 @@ describe('Popover', () => {
|
||||
<User.Provider
|
||||
value={{
|
||||
...userMockConnected,
|
||||
isCorrectNetwork: false,
|
||||
isOceanNetwork: false,
|
||||
network: '1'
|
||||
}}
|
||||
>
|
||||
|
@ -13,7 +13,7 @@ export default class Popover extends PureComponent<{
|
||||
balance,
|
||||
network,
|
||||
isWeb3,
|
||||
isCorrectNetwork
|
||||
isOceanNetwork
|
||||
} = this.context
|
||||
|
||||
return (
|
||||
@ -53,7 +53,7 @@ export default class Popover extends PureComponent<{
|
||||
)}
|
||||
|
||||
<div className={styles.popoverInfoline}>
|
||||
{network && !isCorrectNetwork
|
||||
{network && !isOceanNetwork
|
||||
? 'Please connect to Custom RPC\n https://nile.dev-ocean.com'
|
||||
: network && `Connected to ${network} network`}
|
||||
</div>
|
||||
|
@ -57,10 +57,10 @@ export default class AssetsUser extends PureComponent<
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { account, isCorrectNetwork } = this.context
|
||||
const { account, isOceanNetwork } = this.context
|
||||
|
||||
return (
|
||||
isCorrectNetwork &&
|
||||
isOceanNetwork &&
|
||||
account && (
|
||||
<div className={styles.assetsUser}>
|
||||
{this.props.recent && (
|
||||
|
@ -28,7 +28,7 @@ describe('Web3message', () => {
|
||||
it('renders with noAccount message', () => {
|
||||
const { container } = render(
|
||||
<User.Provider
|
||||
value={{ ...userMock, isWeb3: true, isCorrectNetwork: true }}
|
||||
value={{ ...userMock, isWeb3: true, isOceanNetwork: true }}
|
||||
>
|
||||
<Web3message />
|
||||
</User.Provider>
|
||||
@ -51,7 +51,7 @@ describe('Web3message', () => {
|
||||
value={{
|
||||
...userMock,
|
||||
isWeb3: true,
|
||||
isCorrectNetwork: true
|
||||
isOceanNetwork: true
|
||||
}}
|
||||
>
|
||||
<Web3message />
|
||||
|
@ -32,7 +32,7 @@ export default class Web3message extends PureComponent {
|
||||
public render() {
|
||||
const {
|
||||
isWeb3,
|
||||
isCorrectNetwork,
|
||||
isOceanNetwork,
|
||||
isLogged,
|
||||
account,
|
||||
unlockAccounts
|
||||
@ -40,7 +40,7 @@ export default class Web3message extends PureComponent {
|
||||
|
||||
return !isWeb3
|
||||
? this.message(content.noweb3)
|
||||
: !isCorrectNetwork
|
||||
: !isOceanNetwork
|
||||
? this.message(content.wrongNetwork)
|
||||
: !isLogged
|
||||
? this.message(content.noAccount, '', unlockAccounts)
|
||||
|
@ -9,17 +9,17 @@ export const servicePort = process.env.REACT_APP_SERVICE_PORT || 4000
|
||||
// OCEAN REMOTE CONNECTIONS
|
||||
//
|
||||
export const nodeScheme = process.env.REACT_APP_NODE_SCHEME || 'https'
|
||||
export const nodeHost = process.env.REACT_APP_NODE_HOST || 'nile.dev-ocean.com'
|
||||
export const nodeHost = process.env.REACT_APP_NODE_HOST || 'duero.dev-ocean.com'
|
||||
export const nodePort = process.env.REACT_APP_NODE_PORT || 443
|
||||
|
||||
export const aquariusScheme = process.env.REACT_APP_AQUARIUS_SCHEME || 'https'
|
||||
export const aquariusHost =
|
||||
process.env.REACT_APP_AQUARIUS_HOST || 'nginx-aquarius.dev-ocean.com'
|
||||
process.env.REACT_APP_AQUARIUS_HOST || 'aquarius.duero.dev-ocean.com'
|
||||
export const aquariusPort = process.env.REACT_APP_AQUARIUS_PORT || 443
|
||||
|
||||
export const brizoScheme = process.env.REACT_APP_BRIZO_SCHEME || 'https'
|
||||
export const brizoHost =
|
||||
process.env.REACT_APP_BRIZO_HOST || 'nginx-brizo.dev-ocean.com'
|
||||
process.env.REACT_APP_BRIZO_HOST || 'brizo.duero.dev-ocean.com'
|
||||
export const brizoPort = process.env.REACT_APP_BRIZO_PORT || 443
|
||||
export const brizoAddress =
|
||||
process.env.REACT_APP_BRIZO_ADDRESS ||
|
||||
@ -27,18 +27,19 @@ export const brizoAddress =
|
||||
|
||||
export const parityScheme = process.env.REACT_APP_PARITY_SCHEME || 'https'
|
||||
export const parityHost =
|
||||
process.env.REACT_APP_PARITY_HOST || 'nile.dev-ocean.com'
|
||||
process.env.REACT_APP_PARITY_HOST || 'duero.dev-ocean.com'
|
||||
export const parityPort = process.env.REACT_APP_PARITY_PORT || 443
|
||||
|
||||
export const secretStoreScheme =
|
||||
process.env.REACT_APP_SECRET_STORE_SCHEME || 'https'
|
||||
export const secretStoreHost =
|
||||
process.env.REACT_APP_SECRET_STORE_HOST || 'secret-store.dev-ocean.com'
|
||||
process.env.REACT_APP_SECRET_STORE_HOST ||
|
||||
'secret-store.duero.dev-ocean.com'
|
||||
export const secretStorePort = process.env.REACT_APP_SECRET_STORE_PORT || 443
|
||||
|
||||
export const faucetScheme = process.env.REACT_APP_FAUCET_SCHEME || 'https'
|
||||
export const faucetHost =
|
||||
process.env.REACT_APP_FAUCET_HOST || 'faucet.nile.dev-ocean.com'
|
||||
process.env.REACT_APP_FAUCET_HOST || 'faucet.duero.dev-ocean.com'
|
||||
export const faucetPort = process.env.REACT_APP_FAUCET_PORT || 443
|
||||
|
||||
//
|
||||
|
@ -46,7 +46,7 @@ interface UserProviderState {
|
||||
isLogged: boolean
|
||||
isLoading: boolean
|
||||
isWeb3: boolean
|
||||
isCorrectNetwork: boolean
|
||||
isOceanNetwork: boolean
|
||||
account: string
|
||||
balance: {
|
||||
eth: number
|
||||
@ -74,7 +74,7 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
||||
isLogged: false,
|
||||
isLoading: true,
|
||||
isWeb3: false,
|
||||
isCorrectNetwork: false,
|
||||
isOceanNetwork: false,
|
||||
balance: {
|
||||
eth: 0,
|
||||
ocn: 0
|
||||
@ -151,7 +151,7 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
||||
//
|
||||
// Detecting network with window.web3
|
||||
//
|
||||
let isCorrectNetwork
|
||||
let isOceanNetwork
|
||||
|
||||
await window.web3.eth.net.getId((err, netId) => {
|
||||
if (err) return
|
||||
@ -159,7 +159,7 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
||||
const isNile = netId === 8995
|
||||
const isDuero = netId === 2199
|
||||
|
||||
isCorrectNetwork = isNile || isDuero
|
||||
isOceanNetwork = isNile || isDuero
|
||||
|
||||
const network = isNile
|
||||
? 'Nile'
|
||||
@ -168,14 +168,14 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
||||
: netId.toString()
|
||||
|
||||
if (
|
||||
isCorrectNetwork !== this.state.isCorrectNetwork ||
|
||||
isOceanNetwork !== this.state.isOceanNetwork ||
|
||||
network !== this.state.network
|
||||
) {
|
||||
this.setState({ isCorrectNetwork, network })
|
||||
this.setState({ isOceanNetwork, network })
|
||||
}
|
||||
})
|
||||
|
||||
if (!isCorrectNetwork) {
|
||||
if (!isOceanNetwork) {
|
||||
web3 = this.state.web3 // eslint-disable-line
|
||||
}
|
||||
|
||||
@ -209,13 +209,13 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
||||
}
|
||||
|
||||
private fetchAccounts = async () => {
|
||||
const { ocean, isWeb3, isLogged, isCorrectNetwork } = this.state
|
||||
const { ocean, isWeb3, isLogged, isOceanNetwork } = this.state
|
||||
|
||||
if (isWeb3) {
|
||||
let accounts
|
||||
|
||||
// Modern dapp browsers
|
||||
if (window.ethereum && !isLogged && isCorrectNetwork) {
|
||||
if (window.ethereum && !isLogged && isOceanNetwork) {
|
||||
// simply set to empty, and have user click a button somewhere
|
||||
// to initiate account unlocking
|
||||
accounts = []
|
||||
@ -259,10 +259,10 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
||||
const network = await ocean.keeper.getNetworkName()
|
||||
const isNile = network === 'Nile'
|
||||
const isDuero = network === 'Development'
|
||||
const isCorrectNetwork = isNile || isDuero
|
||||
const isOceanNetwork = isNile || isDuero
|
||||
|
||||
network !== this.state.network &&
|
||||
this.setState({ isCorrectNetwork, network })
|
||||
this.setState({ isOceanNetwork, network })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ export const User = React.createContext({
|
||||
isLogged: false,
|
||||
isLoading: false,
|
||||
isWeb3: false,
|
||||
isCorrectNetwork: false,
|
||||
isOceanNetwork: false,
|
||||
account: '',
|
||||
web3: {},
|
||||
ocean: {},
|
||||
|
@ -20,7 +20,7 @@ const contextConnectedMock = {
|
||||
isLogged: true,
|
||||
isLoading: false,
|
||||
isWeb3: true,
|
||||
isCorrectNetwork: true,
|
||||
isOceanNetwork: true,
|
||||
account: '',
|
||||
web3: {},
|
||||
ocean: {},
|
||||
|
@ -76,7 +76,7 @@ export default class AssetFile extends PureComponent<
|
||||
public render() {
|
||||
const { ddo, file } = this.props
|
||||
const { isLoading, message, error } = this.state
|
||||
const { isLogged, isCorrectNetwork } = this.context
|
||||
const { isLogged, isOceanNetwork } = this.context
|
||||
const { index } = file
|
||||
|
||||
return (
|
||||
@ -102,7 +102,7 @@ export default class AssetFile extends PureComponent<
|
||||
// https://github.com/oceanprotocol/squid-js/pull/221
|
||||
// is released
|
||||
onClick={() => this.purchaseAsset(ddo, index || 0)}
|
||||
disabled={!isLogged || !isCorrectNetwork}
|
||||
disabled={!isLogged || !isOceanNetwork}
|
||||
>
|
||||
Get file
|
||||
</Button>
|
||||
|
@ -19,7 +19,7 @@ export default class AssetFilesDetails extends PureComponent<{
|
||||
<AssetFile key={file.index} ddo={ddo} file={file} />
|
||||
))}
|
||||
</div>
|
||||
{(!this.context.isCorrectNetwork || !this.context.isLogged) && (
|
||||
{(!this.context.isOceanNetwork || !this.context.isLogged) && (
|
||||
<Web3message />
|
||||
)}
|
||||
</>
|
||||
|
@ -81,7 +81,7 @@ export default class Faucet extends PureComponent<{}, FaucetState> {
|
||||
primary
|
||||
onClick={() => this.getTokens(this.context.requestFromFaucet)}
|
||||
disabled={
|
||||
!this.context.isLogged || !this.context.isCorrectNetwork
|
||||
!this.context.isLogged || !this.context.isOceanNetwork
|
||||
}
|
||||
>
|
||||
Request Ether
|
||||
|
@ -14,7 +14,7 @@ describe('History', () => {
|
||||
isLogged: false,
|
||||
isLoading: false,
|
||||
isWeb3: false,
|
||||
isCorrectNetwork: false,
|
||||
isOceanNetwork: false,
|
||||
account: '',
|
||||
web3: {},
|
||||
ocean: {},
|
||||
|
@ -8,7 +8,7 @@ export default class History extends Component {
|
||||
public render() {
|
||||
return (
|
||||
<Route title="History">
|
||||
{(!this.context.isLogged || !this.context.isCorrectNetwork) && (
|
||||
{(!this.context.isLogged || !this.context.isOceanNetwork) && (
|
||||
<Web3message />
|
||||
)}
|
||||
|
||||
|
@ -319,7 +319,7 @@ class Publish extends Component<{}, PublishState> {
|
||||
title="Publish"
|
||||
description="Publish a new data set into the Ocean Protocol Network."
|
||||
>
|
||||
{(!this.context.isLogged || !this.context.isCorrectNetwork) && (
|
||||
{(!this.context.isLogged || !this.context.isOceanNetwork) && (
|
||||
<Web3message />
|
||||
)}
|
||||
|
||||
|
@ -14,7 +14,7 @@ describe('Search', () => {
|
||||
isLogged: false,
|
||||
isLoading: false,
|
||||
isWeb3: false,
|
||||
isCorrectNetwork: false,
|
||||
isOceanNetwork: false,
|
||||
account: '',
|
||||
web3: {},
|
||||
ocean: {
|
||||
|
Loading…
Reference in New Issue
Block a user