1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

web3message fixes, formatting fixes

This commit is contained in:
Matthias Kretschmann 2019-04-08 10:44:03 +02:00
parent 00e69646ad
commit a04b2553e5
Signed by: m
GPG Key ID: 606EEEF3C479A91F
10 changed files with 102 additions and 97 deletions

View File

@ -1026,14 +1026,14 @@
"integrity": "sha512-p2n505t2K0zD1ZvGPhI6EsSviEVLCB7BYowhf/ONmVaWED138PaG4Z9nY6YuHU383uOoIWT+Lq3dLkFzDzstXw==" "integrity": "sha512-p2n505t2K0zD1ZvGPhI6EsSviEVLCB7BYowhf/ONmVaWED138PaG4Z9nY6YuHU383uOoIWT+Lq3dLkFzDzstXw=="
}, },
"@oceanprotocol/keeper-contracts": { "@oceanprotocol/keeper-contracts": {
"version": "0.9.0", "version": "0.9.1",
"resolved": "https://registry.npmjs.org/@oceanprotocol/keeper-contracts/-/keeper-contracts-0.9.0.tgz", "resolved": "https://registry.npmjs.org/@oceanprotocol/keeper-contracts/-/keeper-contracts-0.9.1.tgz",
"integrity": "sha512-QrTCQNiQa9KszH6/dTAS0a8AoW/SIEkZazXTwA2aoePBS0X8fNpsKvT3N2OuR1YPAjCU3rGWzYdV4TNnMNbsSw==" "integrity": "sha512-c1LvaH+e1tzow0gZLwSWe19ap+DrZuNmZfxBdwEVEPQXarI0jTXa5qVDoiBow8kBWaqSIUgFAzQOJW8rKdlS1A=="
}, },
"@oceanprotocol/squid": { "@oceanprotocol/squid": {
"version": "0.5.0", "version": "0.5.1",
"resolved": "https://registry.npmjs.org/@oceanprotocol/squid/-/squid-0.5.0.tgz", "resolved": "https://registry.npmjs.org/@oceanprotocol/squid/-/squid-0.5.1.tgz",
"integrity": "sha512-yGu121WJ9XEX1U4ql/p7ISV36fqNydxGBYgXHbOjeXS/kvNFx3hP2emBf4QA12PjPZcmuLz0wE+7GBL4H/v+eA==", "integrity": "sha512-YJewmMIpHG5cjsOsgOynky7z+5YT7l5+niW9AqCMOoMGy76VEe1+6nmAhZ/PB9BtIpYCGWOl1Y68I32qhX9IWQ==",
"requires": { "requires": {
"@oceanprotocol/keeper-contracts": "^0.9.0", "@oceanprotocol/keeper-contracts": "^0.9.0",
"bignumber.js": "^8.0.1", "bignumber.js": "^8.0.1",

View File

@ -150,7 +150,7 @@ class App extends Component<{}, AppState> {
balance, balance,
network, network,
account: accounts[0].getId(), account: accounts[0].getId(),
isLoading: false, isLoading: false
}) })
} else { } else {
this.setState({ this.setState({

View File

@ -48,51 +48,48 @@ export default class AssetsUser extends PureComponent<
} }
public render() { public render() {
return ( return this.context.isNile && this.context.account ? (
this.context.isNile && <div className={styles.assetsUser}>
this.context.account ? ( {this.props.recent && (
<div className={styles.assetsUser}> <h2 className={styles.subTitle}>
{this.props.recent && ( Your Latest Published Data Sets
<h2 className={styles.subTitle}> </h2>
Your Latest Published Data Sets )}
</h2>
)}
{this.state.isLoading ? ( {this.state.isLoading ? (
<Spinner /> <Spinner />
) : this.state.results.length ? ( ) : this.state.results.length ? (
<> <>
{this.state.results {this.state.results
.slice( .slice(
0, 0,
this.props.recent this.props.recent
? this.props.recent ? this.props.recent
: undefined : undefined
) )
.filter(asset => !!asset) .filter(asset => !!asset)
.map((asset: any) => ( .map((asset: any) => (
<Asset <Asset
list={this.props.list} list={this.props.list}
key={asset.id} key={asset.id}
asset={asset} asset={asset}
/> />
))} ))}
{this.props.recent && ( {this.props.recent && (
<Link className={styles.link} to={'/history'}> <Link className={styles.link} to={'/history'}>
All Data Sets All Data Sets
</Link> </Link>
)} )}
</> </>
) : ( ) : (
<div className={styles.empty}> <div className={styles.empty}>
<p>No Data Sets Yet.</p> <p>No Data Sets Yet.</p>
<Link to="/publish">+ Publish A Data Set</Link> <Link to="/publish">+ Publish A Data Set</Link>
</div> </div>
)} )}
</div> </div>
) : ( ) : (
<Web3message /> <Web3message />
)
) )
} }
} }

View File

@ -26,9 +26,12 @@ export default class Web3message extends PureComponent {
public noWeb3() { public noWeb3() {
return ( return (
<div className={styles.message}> <div className={styles.message}>
<AccountStatus className={styles.status} /> Not a Web3 Browser. For <AccountStatus className={styles.status} /> Not a Web3 Browser.
publishing or consuming an asset you need to{' '} For publishing or consuming an asset you need to{' '}
<a href="https://docs.oceanprotocol.com/tutorials/metamask-setup/" target="_blank"> <a
href="https://docs.oceanprotocol.com/tutorials/metamask-setup/"
target="_blank"
>
setup MetaMask setup MetaMask
</a>{' '} </a>{' '}
or use any other Web3-capable plugin or browser. or use any other Web3-capable plugin or browser.
@ -40,7 +43,7 @@ export default class Web3message extends PureComponent {
return ( return (
<div className={styles.message}> <div className={styles.message}>
<AccountStatus className={styles.status} /> Account locked. For <AccountStatus className={styles.status} /> Account locked. For
publishing an asset you need to unlock your Web3 account. publishing an asset you need to unlock your Web3 account.{' '}
<Button link onClick={states.startLogin}> <Button link onClick={states.startLogin}>
Unlock account Unlock account
</Button> </Button>

View File

@ -13,24 +13,32 @@ export const nodeHost = process.env.REACT_APP_NODE_HOST || 'nile.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 = process.env.REACT_APP_AQUARIUS_HOST || 'nginx-aquarius.dev-ocean.com' export const aquariusHost =
process.env.REACT_APP_AQUARIUS_HOST || 'nginx-aquarius.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 = process.env.REACT_APP_BRIZO_HOST || 'nginx-brizo.dev-ocean.com' export const brizoHost =
process.env.REACT_APP_BRIZO_HOST || 'nginx-brizo.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 = process.env.REACT_APP_BRIZO_ADDRESS || '0x376817c638d2a04f475a73af37f7b51a2862d567' export const brizoAddress =
process.env.REACT_APP_BRIZO_ADDRESS ||
'0x376817c638d2a04f475a73af37f7b51a2862d567'
export const parityScheme = process.env.REACT_APP_PARITY_SCHEME || 'https' export const parityScheme = process.env.REACT_APP_PARITY_SCHEME || 'https'
export const parityHost = process.env.REACT_APP_PARITY_HOST || 'nile.dev-ocean.com' export const parityHost =
process.env.REACT_APP_PARITY_HOST || 'nile.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 = process.env.REACT_APP_SECRET_STORE_SCHEME || 'https' export const secretStoreScheme =
export const secretStoreHost = process.env.REACT_APP_SECRET_STORE_HOST || 'secret-store.dev-ocean.com' process.env.REACT_APP_SECRET_STORE_SCHEME || 'https'
export const secretStoreHost =
process.env.REACT_APP_SECRET_STORE_HOST || 'secret-store.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 = process.env.REACT_APP_FAUCET_HOST || 'faucet.nile.dev-ocean.com' export const faucetHost =
process.env.REACT_APP_FAUCET_HOST || 'faucet.nile.dev-ocean.com'
export const faucetPort = process.env.REACT_APP_FAUCET_PORT || 443 export const faucetPort = process.env.REACT_APP_FAUCET_PORT || 443
// //
@ -65,4 +73,3 @@ export const faucetPort = process.env.REACT_APP_FAUCET_PORT || 443
// export const faucetPort = 3001 // export const faucetPort = 3001
export const verbose = true export const verbose = true

View File

@ -85,18 +85,22 @@ export default class AssetFile extends PureComponent<
<Button <Button
primary primary
className={styles.buttonMain} className={styles.buttonMain}
onClick={() => this.purchaseAsset(ddo, file.index)} onClick={() =>
this.purchaseAsset(ddo, file.index)
}
> >
Get file Get file
</Button> </Button>
) : ) : (
states.isWeb3 && ( states.isWeb3 && (
<Button <Button
primary primary
className={styles.buttonMain} className={styles.buttonMain}
onClick={states.startLogin}> onClick={states.startLogin}
Get file >
</Button> Get file
</Button>
)
) )
} }
</User.Consumer> </User.Consumer>

View File

@ -20,9 +20,7 @@ export default class AssetFilesDetails extends PureComponent<{
</div> </div>
<User.Consumer> <User.Consumer>
{states => {states =>
(!states.isNile || !states.isLogged) && ( (!states.isNile || !states.isLogged) && <Web3message />
<Web3message />
)
} }
</User.Consumer> </User.Consumer>
</> </>

View File

@ -10,15 +10,13 @@ interface FaucetState {
isLoading: boolean isLoading: boolean
success?: string success?: string
error?: string error?: string
eth?: string
} }
export default class Faucet extends PureComponent<{}, FaucetState> { export default class Faucet extends PureComponent<{}, FaucetState> {
public state = { public state = {
isLoading: false, isLoading: false,
success: undefined, success: undefined,
error: undefined, error: undefined
eth: 'xx'
} }
private getTokens = async (requestFromFaucet: () => any) => { private getTokens = async (requestFromFaucet: () => any) => {
@ -55,15 +53,10 @@ export default class Faucet extends PureComponent<{}, FaucetState> {
> >
Request Ether Request Ether
</Button> </Button>
) : ) : states.isWeb3 ? (
states.isWeb3 ? ( <Web3message />
<Button onClick={states.startLogin}>
Request Ether (unlock Metamask)
</Button>
) : ( ) : (
<Button onClick={(e: Event) => window.open("https://docs.oceanprotocol.com/tutorials/metamask-setup/", "_blank")}> <Web3message />
Request Ether (install Metamask)
</Button>
) )
} }
</User.Consumer> </User.Consumer>
@ -105,11 +98,7 @@ export default class Faucet extends PureComponent<{}, FaucetState> {
description="Shower yourself with some Ether for the Ocean POA network." description="Shower yourself with some Ether for the Ocean POA network."
> >
<User.Consumer> <User.Consumer>
{states => {states => !states.isNile && <Web3message />}
!states.isNile && (
<Web3message />
)
}
</User.Consumer> </User.Consumer>
<this.ActionMarkup /> <this.ActionMarkup />

View File

@ -158,16 +158,20 @@ export default class Step extends PureComponent<StepProps, {}> {
{states => {states =>
states.isLogged ? ( states.isLogged ? (
<Button primary>Register asset</Button> <Button primary>Register asset</Button>
) : ) : states.isWeb3 ? (
states.isWeb3 ? (
<Button onClick={states.startLogin}> <Button onClick={states.startLogin}>
Register asset (unlock Metamask) Register asset (unlock Metamask)
</Button> </Button>
) : ( ) : (
<Button onClick={(e: Event) => { <Button
onClick={(e: Event) => {
e.preventDefault() e.preventDefault()
window.open("https://docs.oceanprotocol.com/tutorials/metamask-setup/", "_blank") window.open(
}}> 'https://docs.oceanprotocol.com/tutorials/metamask-setup/',
'_blank'
)
}}
>
Register asset (install Metamask) Register asset (install Metamask)
</Button> </Button>
) )

View File

@ -22,7 +22,10 @@ export class UrlCheckRouter {
headers: { Range: 'bytes=0-' } headers: { Range: 'bytes=0-' }
}, },
(error, response) => { (error, response) => {
if (response && response.statusCode.toString().startsWith('2')) { if (
response &&
response.statusCode.toString().startsWith('2')
) {
const result: any = {} const result: any = {}
result.found = true result.found = true