mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
init network switcher component
This commit is contained in:
parent
70a3339f8b
commit
8023e30061
@ -26,7 +26,13 @@
|
|||||||
"error",
|
"error",
|
||||||
{ "multiline": { "delimiter": "none" } }
|
{ "multiline": { "delimiter": "none" } }
|
||||||
],
|
],
|
||||||
"@typescript-eslint/no-explicit-any": "off"
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"react/no-unescaped-entities": 0,
|
||||||
|
"react/self-closing-comp": 0,
|
||||||
|
"react/void-dom-elements-no-children": 0,
|
||||||
|
"react/jsx-indent": 0,
|
||||||
|
"react/jsx-indent-props": 0,
|
||||||
|
"react/jsx-max-props-per-line": 0
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"es6": true,
|
"es6": true,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"semi": false,
|
"semi": false,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"trailingComma": "none"
|
"trailingComma": "none",
|
||||||
|
"tabWidth": 2
|
||||||
}
|
}
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"typescript.tsdk": "node_modules/typescript/lib"
|
||||||
|
}
|
@ -5,9 +5,12 @@ import Footer from './components/organisms/Footer'
|
|||||||
import Spinner from './components/atoms/Spinner'
|
import Spinner from './components/atoms/Spinner'
|
||||||
import { User } from './context'
|
import { User } from './context'
|
||||||
import Routes from './Routes'
|
import Routes from './Routes'
|
||||||
|
import {commonsNetwork} from './components/molecules/NetworkSwitcher'
|
||||||
import './styles/global.scss'
|
import './styles/global.scss'
|
||||||
import styles from './App.module.scss'
|
import styles from './App.module.scss'
|
||||||
|
|
||||||
|
console.log(commonsNetwork)
|
||||||
|
|
||||||
export default class App extends Component {
|
export default class App extends Component {
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
@ -25,7 +28,6 @@ export default class App extends Component {
|
|||||||
<Routes />
|
<Routes />
|
||||||
)}
|
)}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
<Footer />
|
||||||
</>
|
</>
|
||||||
</Router>
|
</Router>
|
||||||
@ -34,4 +36,5 @@ export default class App extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
App.contextType = User
|
App.contextType = User
|
||||||
|
12
client/src/components/molecules/NetworkSwitcher.tsx
Normal file
12
client/src/components/molecules/NetworkSwitcher.tsx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { CONNECTIONS } from '../../config'
|
||||||
|
|
||||||
|
/* TEMP NETWORK SWITCHER */
|
||||||
|
|
||||||
|
const urlParams = new URLSearchParams(window.location.search)
|
||||||
|
const network = urlParams.get('network') || 'pacific'
|
||||||
|
const idx = Object.keys(CONNECTIONS).indexOf(network)
|
||||||
|
const commonsNetwork = Object.values(CONNECTIONS)[idx]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export { commonsNetwork }
|
@ -3,6 +3,7 @@ import { VersionNumbersState } from '.'
|
|||||||
import VersionTableRow from './VersionTableRow'
|
import VersionTableRow from './VersionTableRow'
|
||||||
import styles from './VersionTable.module.scss'
|
import styles from './VersionTable.module.scss'
|
||||||
import VersionNumber from './VersionNumber'
|
import VersionNumber from './VersionNumber'
|
||||||
|
import { useParams } from 'react-router-dom'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
serviceUri,
|
serviceUri,
|
||||||
@ -11,9 +12,11 @@ import {
|
|||||||
brizoUri,
|
brizoUri,
|
||||||
brizoAddress,
|
brizoAddress,
|
||||||
secretStoreUri,
|
secretStoreUri,
|
||||||
faucetUri
|
faucetUri,
|
||||||
|
CONNECTIONS
|
||||||
} from '../../../config'
|
} from '../../../config'
|
||||||
|
|
||||||
|
|
||||||
const commonsConfig = {
|
const commonsConfig = {
|
||||||
serviceUri,
|
serviceUri,
|
||||||
nodeUri,
|
nodeUri,
|
||||||
@ -42,10 +45,7 @@ export const VersionTableContracts = ({
|
|||||||
<strong>Keeper Contracts</strong>
|
<strong>Keeper Contracts</strong>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<VersionNumber
|
<VersionNumber name="Keeper Contracts" version={keeperVersion} />
|
||||||
name="Keeper Contracts"
|
|
||||||
version={keeperVersion}
|
|
||||||
/>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{contracts &&
|
{contracts &&
|
||||||
@ -54,12 +54,11 @@ export const VersionTableContracts = ({
|
|||||||
.sort((a, b) => a.localeCompare(b))
|
.sort((a, b) => a.localeCompare(b))
|
||||||
.map(key => {
|
.map(key => {
|
||||||
const submarineLink = `https://submarine.${
|
const submarineLink = `https://submarine.${
|
||||||
network === 'pacific'
|
network === 'pacific' ? 'oceanprotocol' : `${network}.dev-ocean`
|
||||||
? 'oceanprotocol'
|
|
||||||
: `${network}.dev-ocean`
|
|
||||||
}.com/address/${contracts[key]}`
|
}.com/address/${contracts[key]}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<tr key={key}>
|
<tr key={key}>
|
||||||
<td>
|
<td>
|
||||||
<code className={styles.label}>{key}</code>
|
<code className={styles.label}>{key}</code>
|
||||||
|
@ -40,3 +40,30 @@ export const ipfsGatewayUri =
|
|||||||
process.env.REACT_APP_IPFS_GATEWAY_URI || 'https://gateway.ipfs.io'
|
process.env.REACT_APP_IPFS_GATEWAY_URI || 'https://gateway.ipfs.io'
|
||||||
export const ipfsNodeUri =
|
export const ipfsNodeUri =
|
||||||
process.env.REACT_APP_IPFS_NODE_URI || 'https://ipfs.infura.io:5001'
|
process.env.REACT_APP_IPFS_NODE_URI || 'https://ipfs.infura.io:5001'
|
||||||
|
|
||||||
|
export const CONNECTIONS = {
|
||||||
|
pacific: {
|
||||||
|
nodeUri: 'https://pacific.oceanprotocol.com',
|
||||||
|
aquariusUri: 'https://aquarius.commons.oceanprotocol.com',
|
||||||
|
brizoUri: 'https://brizo.commons.oceanprotocol.com',
|
||||||
|
brizoAddress: '0x008c25ed3594e094db4592f4115d5fa74c4f41ea',
|
||||||
|
secretStoreUri: 'https://secret-store.oceanprotocol.com',
|
||||||
|
faucetUri: 'https://faucet.oceanprotocol.com'
|
||||||
|
},
|
||||||
|
nile: {
|
||||||
|
nodeUri: 'https://nile.dev-ocean.com',
|
||||||
|
aquariusUri: 'https://aquarius.nile.dev-ocean.com',
|
||||||
|
brizoUri: 'https://brizo.nile.dev-ocean.com',
|
||||||
|
brizoAddress: '0x4aaab179035dc57b35e2ce066919048686f82972',
|
||||||
|
secretStoreUri: 'https://secret-store.nile.dev-ocean.com',
|
||||||
|
faucetUri: 'https://faucet.nile.dev-ocean.com'
|
||||||
|
},
|
||||||
|
duero: {
|
||||||
|
nodeUri: 'https://duero.dev-ocean.com',
|
||||||
|
aquariusUri: 'https://aquarius.duero.dev-ocean.com',
|
||||||
|
brizoUri: 'https://brizo.duero.dev-ocean.com',
|
||||||
|
brizoAddress: '0x9d4ed58293f71122ad6a733c1603927a150735d0',
|
||||||
|
secretStoreUri: 'https://secret-store.duero.dev-ocean.com',
|
||||||
|
faucetUri: 'https://faucet.duero.dev-ocean.com'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@ export { renderToDOM }
|
|||||||
|
|
||||||
renderToDOM()
|
renderToDOM()
|
||||||
|
|
||||||
|
|
||||||
// If you want your app to work offline and load faster, you can change
|
// If you want your app to work offline and load faster, you can change
|
||||||
// unregister() to register() below. Note this comes with some pitfalls.
|
// unregister() to register() below. Note this comes with some pitfalls.
|
||||||
// Learn more about service workers: http://bit.ly/CRA-PWA
|
// Learn more about service workers: http://bit.ly/CRA-PWA
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Ocean, Logger } from '@oceanprotocol/squid'
|
import { Ocean, Logger } from '@oceanprotocol/squid'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
|
import { User } from './context'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
aquariusUri,
|
aquariusUri,
|
||||||
@ -11,6 +12,8 @@ import {
|
|||||||
verbose
|
verbose
|
||||||
} from './config'
|
} from './config'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export async function provideOcean(web3Provider: Web3) {
|
export async function provideOcean(web3Provider: Web3) {
|
||||||
const config = {
|
const config = {
|
||||||
web3Provider,
|
web3Provider,
|
||||||
|
@ -74,8 +74,7 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
|||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
isFormShown: form === 'url' ? !this.state.isFormShown : false,
|
isFormShown: form === 'url' ? !this.state.isFormShown : false,
|
||||||
isIpfsFormShown:
|
isIpfsFormShown: form === 'ipfs' ? !this.state.isIpfsFormShown : false
|
||||||
form === 'ipfs' ? !this.state.isIpfsFormShown : false
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,9 +193,7 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
|||||||
<Button
|
<Button
|
||||||
key={shortid.generate()}
|
key={shortid.generate()}
|
||||||
link
|
link
|
||||||
onClick={(e: Event) =>
|
onClick={(e: Event) => this.toggleForm(e, button.id)}
|
||||||
this.toggleForm(e, button.id)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{isActive ? button.titleActive : button.title}
|
{isActive ? button.titleActive : button.title}
|
||||||
</Button>
|
</Button>
|
||||||
@ -204,10 +201,7 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
|||||||
})}
|
})}
|
||||||
|
|
||||||
{isFormShown && (
|
{isFormShown && (
|
||||||
<ItemForm
|
<ItemForm placeholder={placeholder} addFile={this.addFile} />
|
||||||
placeholder={placeholder}
|
|
||||||
addFile={this.addFile}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isIpfsFormShown && (
|
{isIpfsFormShown && (
|
||||||
|
Loading…
Reference in New Issue
Block a user