mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
fetch market network, use it in some places to switch copy, fix faucet button
This commit is contained in:
parent
84c0877c43
commit
ac2cd2eb70
|
@ -9,6 +9,10 @@
|
||||||
padding-top: $spacer / 2;
|
padding-top: $spacer / 2;
|
||||||
padding-bottom: $spacer / 2;
|
padding-bottom: $spacer / 2;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
||||||
|
> div:first-child {
|
||||||
|
margin-bottom: $spacer / 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
|
|
|
@ -16,6 +16,7 @@ interface MarketProviderProps {
|
||||||
interface MarketProviderState {
|
interface MarketProviderState {
|
||||||
totalAssets: number
|
totalAssets: number
|
||||||
categories: string[]
|
categories: string[]
|
||||||
|
network: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class MarketProvider extends PureComponent<
|
export default class MarketProvider extends PureComponent<
|
||||||
|
@ -24,7 +25,8 @@ export default class MarketProvider extends PureComponent<
|
||||||
> {
|
> {
|
||||||
public state = {
|
public state = {
|
||||||
totalAssets: 0,
|
totalAssets: 0,
|
||||||
categories
|
categories,
|
||||||
|
network: 'Pacific'
|
||||||
}
|
}
|
||||||
|
|
||||||
public async componentDidMount() {}
|
public async componentDidMount() {}
|
||||||
|
@ -34,6 +36,7 @@ export default class MarketProvider extends PureComponent<
|
||||||
// Cause there is no `prevContext`.
|
// Cause there is no `prevContext`.
|
||||||
if (prevProps.ocean !== this.props.ocean) {
|
if (prevProps.ocean !== this.props.ocean) {
|
||||||
await this.getTotalAssets()
|
await this.getTotalAssets()
|
||||||
|
await this.getMarketNetwork()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +59,19 @@ export default class MarketProvider extends PureComponent<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getMarketNetwork = async () => {
|
||||||
|
try {
|
||||||
|
const { ocean } = this.props
|
||||||
|
// Set desired network to whatever Brizo is running in
|
||||||
|
const brizo = await ocean.brizo.getVersionInfo()
|
||||||
|
const network =
|
||||||
|
brizo.network.charAt(0).toUpperCase() + brizo.network.slice(1)
|
||||||
|
this.setState({ network })
|
||||||
|
} catch (error) {
|
||||||
|
Logger.error('Error', error.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<Market.Provider value={this.state}>
|
<Market.Provider value={this.state}>
|
||||||
|
|
|
@ -25,4 +25,8 @@ export const User = React.createContext({
|
||||||
message: ''
|
message: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
export const Market = React.createContext({ totalAssets: 0, categories: [''] })
|
export const Market = React.createContext({
|
||||||
|
totalAssets: 0,
|
||||||
|
categories: [''],
|
||||||
|
network: ''
|
||||||
|
})
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { FaucetResponse } from '../ocean'
|
||||||
import Route from '../components/templates/Route'
|
import Route from '../components/templates/Route'
|
||||||
import Button from '../components/atoms/Button'
|
import Button from '../components/atoms/Button'
|
||||||
import Spinner from '../components/atoms/Spinner'
|
import Spinner from '../components/atoms/Spinner'
|
||||||
import { User } from '../context'
|
import { User, Market } from '../context'
|
||||||
import Web3message from '../components/organisms/Web3message'
|
import Web3message from '../components/organisms/Web3message'
|
||||||
import styles from './Faucet.module.scss'
|
import styles from './Faucet.module.scss'
|
||||||
import Content from '../components/atoms/Content'
|
import Content from '../components/atoms/Content'
|
||||||
|
@ -112,30 +112,34 @@ export default class Faucet extends PureComponent<{}, FaucetState> {
|
||||||
)
|
)
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { isWeb3 } = this.context
|
const { isLogged } = this.context
|
||||||
const { isLoading, error, success } = this.state
|
const { isLoading, error, success } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Route
|
<Market.Consumer>
|
||||||
title="Faucet"
|
{market => (
|
||||||
description="Shower yourself with some Ether for Ocean's Pacific network."
|
<Route
|
||||||
>
|
title="Faucet"
|
||||||
<Content>
|
description={`Shower yourself with some Ether for Ocean's ${market.network} network.`}
|
||||||
<Web3message />
|
>
|
||||||
|
<Content>
|
||||||
|
<Web3message />
|
||||||
|
|
||||||
<div className={styles.action}>
|
<div className={styles.action}>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<Spinner message="Getting Ether..." />
|
<Spinner message="Getting Ether..." />
|
||||||
) : error ? (
|
) : error ? (
|
||||||
<this.Error />
|
<this.Error />
|
||||||
) : success ? (
|
) : success ? (
|
||||||
<this.Success />
|
<this.Success />
|
||||||
) : (
|
) : (
|
||||||
isWeb3 && <this.Action />
|
isLogged && <this.Action />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Content>
|
</Content>
|
||||||
</Route>
|
</Route>
|
||||||
|
)}
|
||||||
|
</Market.Consumer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Logger } from '@oceanprotocol/squid'
|
||||||
import Route from '../../components/templates/Route'
|
import Route from '../../components/templates/Route'
|
||||||
import Form from '../../components/atoms/Form/Form'
|
import Form from '../../components/atoms/Form/Form'
|
||||||
import AssetModel from '../../models/AssetModel'
|
import AssetModel from '../../models/AssetModel'
|
||||||
import { User } from '../../context'
|
import { User, Market } from '../../context'
|
||||||
import Web3message from '../../components/organisms/Web3message'
|
import Web3message from '../../components/organisms/Web3message'
|
||||||
import Step from './Step'
|
import Step from './Step'
|
||||||
import Progress from './Progress'
|
import Progress from './Progress'
|
||||||
|
@ -319,41 +319,47 @@ export default class Publish extends Component<{}, PublishState> {
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<Route
|
<Market.Consumer>
|
||||||
title="Publish"
|
{market => (
|
||||||
description="Publish a new data set into the Ocean Protocol Network."
|
<Route
|
||||||
>
|
title="Publish"
|
||||||
<Content>
|
description={`Publish a new data set into the Ocean Protocol ${market.network} Network.`}
|
||||||
{(!this.context.isLogged ||
|
>
|
||||||
!this.context.isOceanNetwork) && <Web3message />}
|
<Content>
|
||||||
|
{(!this.context.isLogged ||
|
||||||
|
!this.context.isOceanNetwork) && (
|
||||||
|
<Web3message />
|
||||||
|
)}
|
||||||
|
|
||||||
<Progress
|
<Progress
|
||||||
steps={steps}
|
steps={steps}
|
||||||
currentStep={this.state.currentStep}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Form onSubmit={this.registerAsset}>
|
|
||||||
{steps.map((step: any, index: number) => (
|
|
||||||
<Step
|
|
||||||
key={index}
|
|
||||||
index={index}
|
|
||||||
title={step.title}
|
|
||||||
description={step.description}
|
|
||||||
currentStep={this.state.currentStep}
|
currentStep={this.state.currentStep}
|
||||||
fields={step.fields}
|
|
||||||
inputChange={this.inputChange}
|
|
||||||
state={this.state}
|
|
||||||
next={this.next}
|
|
||||||
prev={this.prev}
|
|
||||||
totalSteps={steps.length}
|
|
||||||
tryAgain={this.tryAgain}
|
|
||||||
toStart={this.toStart}
|
|
||||||
content={step.content}
|
|
||||||
/>
|
/>
|
||||||
))}
|
|
||||||
</Form>
|
<Form onSubmit={this.registerAsset}>
|
||||||
</Content>
|
{steps.map((step: any, index: number) => (
|
||||||
</Route>
|
<Step
|
||||||
|
key={index}
|
||||||
|
index={index}
|
||||||
|
title={step.title}
|
||||||
|
description={step.description}
|
||||||
|
currentStep={this.state.currentStep}
|
||||||
|
fields={step.fields}
|
||||||
|
inputChange={this.inputChange}
|
||||||
|
state={this.state}
|
||||||
|
next={this.next}
|
||||||
|
prev={this.prev}
|
||||||
|
totalSteps={steps.length}
|
||||||
|
tryAgain={this.tryAgain}
|
||||||
|
toStart={this.toStart}
|
||||||
|
content={step.content}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Form>
|
||||||
|
</Content>
|
||||||
|
</Route>
|
||||||
|
)}
|
||||||
|
</Market.Consumer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user