Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Commit

Permalink
isCorrectNetwork -> isOceanNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed May 14, 2019
1 parent 74e2d20 commit 807723b
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 39 deletions.
4 changes: 2 additions & 2 deletions client/__mocks__/user-mock.ts
Expand Up @@ -2,7 +2,7 @@ const userMock = {
isLogged: false,
isLoading: false,
isWeb3: false,
isCorrectNetwork: false,
isOceanNetwork: false,
account: '',
web3: {},
ocean: {},
Expand All @@ -17,7 +17,7 @@ const userMockConnected = {
isLogged: true,
isLoading: false,
isWeb3: true,
isCorrectNetwork: true,
isOceanNetwork: true,
account: '0xxxxxx',
web3: {},
ocean: {},
Expand Down
Expand Up @@ -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} />
Expand Down
Expand Up @@ -38,7 +38,7 @@ describe('Popover', () => {
<User.Provider
value={{
...userMockConnected,
isCorrectNetwork: false,
isOceanNetwork: false,
network: '1'
}}
>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/molecules/AccountStatus/Popover.tsx
Expand Up @@ -13,7 +13,7 @@ export default class Popover extends PureComponent<{
balance,
network,
isWeb3,
isCorrectNetwork
isOceanNetwork
} = this.context

return (
Expand Down Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/organisms/AssetsUser.tsx
Expand Up @@ -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 && (
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/organisms/Web3message.test.tsx
Expand Up @@ -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>
Expand All @@ -51,7 +51,7 @@ describe('Web3message', () => {
value={{
...userMock,
isWeb3: true,
isCorrectNetwork: true
isOceanNetwork: true
}}
>
<Web3message />
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/organisms/Web3message.tsx
Expand Up @@ -32,15 +32,15 @@ export default class Web3message extends PureComponent {
public render() {
const {
isWeb3,
isCorrectNetwork,
isOceanNetwork,
isLogged,
account,
unlockAccounts
} = this.context

return !isWeb3
? this.message(content.noweb3)
: !isCorrectNetwork
: !isOceanNetwork
? this.message(content.wrongNetwork)
: !isLogged
? this.message(content.noAccount, '', unlockAccounts)
Expand Down
13 changes: 7 additions & 6 deletions client/src/config.ts
Expand Up @@ -9,36 +9,37 @@ 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 ||
'0x376817c638d2a04f475a73af37f7b51a2862d567'

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

//
Expand Down
22 changes: 11 additions & 11 deletions client/src/context/UserProvider.tsx
Expand Up @@ -46,7 +46,7 @@ interface UserProviderState {
isLogged: boolean
isLoading: boolean
isWeb3: boolean
isCorrectNetwork: boolean
isOceanNetwork: boolean
account: string
balance: {
eth: number
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -151,15 +151,15 @@ 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

const isNile = netId === 8995
const isDuero = netId === 2199

isCorrectNetwork = isNile || isDuero
isOceanNetwork = isNile || isDuero

const network = isNile
? 'Nile'
Expand All @@ -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
}

Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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 })
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/context/index.tsx
Expand Up @@ -4,7 +4,7 @@ export const User = React.createContext({
isLogged: false,
isLoading: false,
isWeb3: false,
isCorrectNetwork: false,
isOceanNetwork: false,
account: '',
web3: {},
ocean: {},
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/Details/AssetFile.test.tsx
Expand Up @@ -20,7 +20,7 @@ const contextConnectedMock = {
isLogged: true,
isLoading: false,
isWeb3: true,
isCorrectNetwork: true,
isOceanNetwork: true,
account: '',
web3: {},
ocean: {},
Expand Down
4 changes: 2 additions & 2 deletions client/src/routes/Details/AssetFile.tsx
Expand Up @@ -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 (
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/Details/AssetFilesDetails.tsx
Expand Up @@ -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 />
)}
</>
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/Faucet.tsx
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/History.test.tsx
Expand Up @@ -14,7 +14,7 @@ describe('History', () => {
isLogged: false,
isLoading: false,
isWeb3: false,
isCorrectNetwork: false,
isOceanNetwork: false,
account: '',
web3: {},
ocean: {},
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/History.tsx
Expand Up @@ -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 />
)}

Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/Publish/index.tsx
Expand Up @@ -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 />
)}

Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/Search.test.tsx
Expand Up @@ -14,7 +14,7 @@ describe('Search', () => {
isLogged: false,
isLoading: false,
isWeb3: false,
isCorrectNetwork: false,
isOceanNetwork: false,
account: '',
web3: {},
ocean: {
Expand Down

0 comments on commit 807723b

Please sign in to comment.