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

wait for ocean object, sort contracts

This commit is contained in:
Matthias Kretschmann 2019-06-18 13:28:35 +02:00
parent c4f862baa5
commit d92c3e92f4
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 78 additions and 65 deletions

View File

@ -16,28 +16,31 @@ const VersionTableContracts = ({
<table>
<tbody>
{contracts &&
Object.keys(contracts).map(key => {
const submarineLink = `https://submarine${
network === 'duero'
? '.duero'
: network === 'pacific'
? '.pacific'
: ''
}.dev-ocean.com/address/${contracts[key]}`
Object.keys(contracts)
// sort alphabetically
.sort((a, b) => a.localeCompare(b))
.map(key => {
const submarineLink = `https://submarine${
network === 'duero'
? '.duero'
: network === 'pacific'
? '.pacific'
: ''
}.dev-ocean.com/address/${contracts[key]}`
return (
<tr key={key}>
<td>
<span className={styles.label}>{key}</span>
</td>
<td>
<a href={submarineLink}>
<code>{contracts[key]}</code>
</a>
</td>
</tr>
)
})}
return (
<tr key={key}>
<td>
<span className={styles.label}>{key}</span>
</td>
<td>
<a href={submarineLink}>
<code>{contracts[key]}</code>
</a>
</td>
</tr>
)
})}
</tbody>
</table>
)
@ -72,42 +75,44 @@ const VersionTable = ({ data }: { data: VersionNumbersState }) => (
<div className={styles.tableWrap}>
<table className={styles.table}>
<tbody>
{Object.entries(data).map(([key, value]) => (
<Fragment key={key}>
<tr>
<td>
<a
href={
value.name &&
`https://github.com/oceanprotocol/${slugify(
value.name
)}`
}
>
<strong>{value.name}</strong>
</a>
</td>
<td>
<VersionNumber
name={value.name}
version={value.version}
status={value.status}
// network={value.network}
/>
</td>
</tr>
{/* {value.contracts && (
{Object.entries(data)
.filter(([key, value]) => key !== 'status')
.map(([key, value]) => (
<Fragment key={key}>
<tr>
<td colSpan={2}>
<VersionTableContracts
contracts={value.contracts}
network={value.network || ''}
<td>
<a
href={
value.name &&
`https://github.com/oceanprotocol/${slugify(
value.name
)}`
}
>
<strong>{value.name}</strong>
</a>
</td>
<td>
<VersionNumber
name={value.name}
version={value.version}
status={value.status}
network={value.network}
/>
</td>
</tr>
)} */}
</Fragment>
))}
{value.contracts && (
<tr>
<td colSpan={2}>
<VersionTableContracts
contracts={value.contracts}
network={value.network || ''}
/>
</td>
</tr>
)}
</Fragment>
))}
</tbody>
</table>
</div>

View File

@ -8,7 +8,7 @@ import axios from 'axios'
import { version } from '../../../../package.json'
import styles from './index.module.scss'
import { faucetUri } from '../../../config'
// import { faucetUri } from '../../../config'
import { User } from '../../../context'
import VersionTable from './VersionTable'
@ -43,11 +43,6 @@ export default class VersionNumbers extends PureComponent<
name: 'Commons',
version: commonsVersion
},
faucet: {
name: 'Faucet',
version: '',
status: OceanPlatformTechStatus.Loading
},
squid: {
name: 'Squid-js',
status: OceanPlatformTechStatus.Loading
@ -58,7 +53,18 @@ export default class VersionNumbers extends PureComponent<
},
brizo: {
name: 'Brizo',
network: 'Nile',
status: OceanPlatformTechStatus.Loading
},
faucet: {
name: 'Faucet',
version: '',
status: OceanPlatformTechStatus.Loading
},
status: {
ok: false,
contracts: false,
network: false
}
}
@ -75,10 +81,12 @@ export default class VersionNumbers extends PureComponent<
private async getOceanVersions() {
const { ocean } = this.context
const { versions } = ocean
const componentVersions = versions && (await versions.get())
const { squid, brizo, aquarius } = componentVersions
console.log(componentVersions)
// wait until ocean object is properly populated
if (ocean.versions === undefined) return
const response = await ocean.versions.get()
const { squid, brizo, aquarius, status } = response
// const faucet = await this.getData(faucetUri)
@ -86,10 +94,10 @@ export default class VersionNumbers extends PureComponent<
commons: { ...this.state.commons },
squid,
brizo,
aquarius
aquarius,
status
// faucet
})
console.log(this.state)
}
private async getData(uri: string) {