display published

This commit is contained in:
Jernej Pregelj 2019-03-20 10:49:37 +01:00
parent cd03398dcf
commit 43d0847d48
3 changed files with 906 additions and 1148 deletions

2012
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@
},
"dependencies": {
"@oceanprotocol/art": "^2.2.0",
"@oceanprotocol/squid": "^0.3.1",
"@oceanprotocol/squid": "^0.4.0",
"classnames": "^2.2.6",
"is-url": "^1.2.4",
"moment": "^2.24.0",
@ -29,7 +29,7 @@
"react-router-dom": "^4.3.1",
"react-transition-group": "^2.6.0",
"slugify": "^1.3.4",
"web3": "^1.0.0-beta.46"
"web3": "^1.0.0-beta.48"
},
"devDependencies": {
"@types/classnames": "^2.2.7",

View File

@ -2,8 +2,10 @@ import React, { Component } from 'react'
import Route from '../components/templates/Route'
import { User } from '../context/User'
import Asset from '../components/molecules/Asset'
import { Logger } from '@oceanprotocol/squid';
import styles from './Search.module.scss'
interface InvoicesState {
results: any[]
}
@ -12,27 +14,31 @@ export default class Invoices extends Component<{}, InvoicesState> {
public state = { results: [] }
public async componentDidMount() {
/*
TODO:
- squid-js with exposed contracts
- request user to sign (unlock account) to get public key? retrieve it form previous signatures?
- subscribe to the `AccessSecretStoreCondition.Fulfill` event filtering by `_grantee` : https://github.com/oceanprotocol/keeper-contracts/blob/release/v0.8/contracts/conditions/AccessSecretStoreCondition.sol#L13
AccessSecretStoreCondition.Fulfill({_grantee: 'public key'}, { fromBlock: 0, toBlock: 'latest' }).get((error, eventResult) => {
if (error)
console.log('Error in myEvent event handler: ' + error);
else
console.log('events: ' + JSON.stringify(eventResult.args));
});
*/
const assets = await this.context.ocean.assets.search('')
this.setState({ results: assets })
// this is currently my published assets
this.context.ocean.keeper.didRegistry.contract.getPastEvents('DIDAttributeRegistered', {
filter: {_owner:this.context.account},
fromBlock: 0,
toBlock: 'latest'
}, async (error: any, events: any) => {
if (error) {
Logger.log('error retrieving', error)
} else {
const results = []
for (const event of events) {
const ddo = await this.context.ocean.resolveDID(`did:op:${event.returnValues._did.substring(2)}`)
results.push(ddo)
}
this.setState({ results })
}
})
}
public renderResults = () =>
this.state.results.length ? (
<div className={styles.results}>
{this.state.results.map(asset => (
<Asset key={asset} asset={asset} />
{this.state.results.map((asset, index) => (
<Asset key={index} asset={asset} />
))}
</div>
) : (