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