mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
WIP
This commit is contained in:
parent
8023e30061
commit
125df58464
@ -5,12 +5,9 @@ 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 (
|
||||||
@ -36,5 +33,4 @@ export default class App extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
App.contextType = User
|
App.contextType = User
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
|
import React, { useState } from 'react'
|
||||||
import { CONNECTIONS } from '../../config'
|
import { CONNECTIONS } from '../../config'
|
||||||
|
|
||||||
/* TEMP NETWORK SWITCHER */
|
/* NETWORK SWITCHER */
|
||||||
|
|
||||||
const urlParams = new URLSearchParams(window.location.search)
|
const urlParams = new URLSearchParams(window.location.search)
|
||||||
const network = urlParams.get('network') || 'pacific'
|
const networkFromParam = urlParams.get('network') || 'pacific'
|
||||||
const idx = Object.keys(CONNECTIONS).indexOf(network)
|
const idx = Object.keys(CONNECTIONS).indexOf(networkFromParam)
|
||||||
const commonsNetwork = Object.values(CONNECTIONS)[idx]
|
const commonsNetwork = Object.values(CONNECTIONS)[idx] // TypeScript won't let me access CONNECTIONS[networkFromParam] directly
|
||||||
|
|
||||||
|
console.log(commonsNetwork)
|
||||||
|
|
||||||
|
export function NetworkSwitcher() {
|
||||||
export { commonsNetwork }
|
return null
|
||||||
|
}
|
||||||
|
@ -142,9 +142,7 @@ export default class AssetFile extends PureComponent<
|
|||||||
primary
|
primary
|
||||||
className={styles.buttonMain}
|
className={styles.buttonMain}
|
||||||
// weird 0 hack so TypeScript is happy
|
// weird 0 hack so TypeScript is happy
|
||||||
onClick={() =>
|
onClick={() => this.purchaseAsset(ddo, index || 0)}
|
||||||
this.purchaseAsset(ddo, index || 0)
|
|
||||||
}
|
|
||||||
disabled={!isLogged || !market.networkMatch}
|
disabled={!isLogged || !market.networkMatch}
|
||||||
name="Download"
|
name="Download"
|
||||||
>
|
>
|
||||||
|
@ -8,6 +8,8 @@ import MarketProvider from './MarketProvider'
|
|||||||
import { MetamaskProvider } from './MetamaskProvider'
|
import { MetamaskProvider } from './MetamaskProvider'
|
||||||
import { BurnerWalletProvider } from './BurnerWalletProvider'
|
import { BurnerWalletProvider } from './BurnerWalletProvider'
|
||||||
|
|
||||||
|
import { NetworkSwitcher } from '../components/molecules/NetworkSwitcher'
|
||||||
|
|
||||||
const POLL_ACCOUNTS = 1000 // every 1s
|
const POLL_ACCOUNTS = 1000 // every 1s
|
||||||
const POLL_NETWORK = POLL_ACCOUNTS * 60 // every 1 min
|
const POLL_NETWORK = POLL_ACCOUNTS * 60 // every 1 min
|
||||||
const DEFAULT_WEB3 = new Web3(new Web3.providers.HttpProvider(nodeUri)) // default web3
|
const DEFAULT_WEB3 = new Web3(new Web3.providers.HttpProvider(nodeUri)) // default web3
|
||||||
@ -100,10 +102,7 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
|||||||
|
|
||||||
private initAccountsPoll() {
|
private initAccountsPoll() {
|
||||||
if (!this.accountsInterval) {
|
if (!this.accountsInterval) {
|
||||||
this.accountsInterval = setInterval(
|
this.accountsInterval = setInterval(this.fetchAccounts, POLL_ACCOUNTS)
|
||||||
this.fetchAccounts,
|
|
||||||
POLL_ACCOUNTS
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +225,7 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
|||||||
return (
|
return (
|
||||||
<User.Provider value={this.state}>
|
<User.Provider value={this.state}>
|
||||||
<MarketProvider ocean={this.state.ocean}>
|
<MarketProvider ocean={this.state.ocean}>
|
||||||
|
<NetworkSwitcher />
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</MarketProvider>
|
</MarketProvider>
|
||||||
</User.Provider>
|
</User.Provider>
|
||||||
|
@ -21,7 +21,6 @@ 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
|
||||||
|
@ -143,8 +143,7 @@ class Search extends PureComponent<SearchProps, SearchState> {
|
|||||||
{totalResults} results for{' '}
|
{totalResults} results for{' '}
|
||||||
<span>
|
<span>
|
||||||
{decodeURIComponent(
|
{decodeURIComponent(
|
||||||
this.state.searchTerm ||
|
this.state.searchTerm || this.state.searchCategories
|
||||||
this.state.searchCategories
|
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
</h2>
|
</h2>
|
||||||
|
Loading…
Reference in New Issue
Block a user