add consumed list function

This commit is contained in:
Jernej Pregelj 2019-04-05 10:58:38 +02:00
parent a1ab653ffb
commit 6706cb6fa1
1 changed files with 36 additions and 22 deletions

View File

@ -18,29 +18,43 @@ export default class AssetsUser extends PureComponent<
private async searchOcean() { private async searchOcean() {
if (this.context.account) { if (this.context.account) {
this.context.ocean.keeper.didRegistry.contract.getPastEvents( try {
const publishedEvents = await this.context.ocean.keeper.didRegistry.contract.getPastEvents(
'DIDAttributeRegistered', 'DIDAttributeRegistered',
{ {
filter: { _owner: this.context.account }, filter: { _owner: this.context.account },
fromBlock: 0, fromBlock: 0,
toBlock: 'latest' toBlock: 'latest'
}, })
async (error: any, events: any) => {
if (error) {
Logger.log('error retrieving', error)
this.setState({ isLoading: false })
} else {
const results = [] const results = []
for (const event of events) { for (const event of publishedEvents) {
const ddo = await this.context.ocean.assets.resolve( const ddo = await this.context.ocean.assets.resolve(
`did:op:${event.returnValues._did.substring(2)}` `did:op:${event.returnValues._did.substring(2)}`
) )
results.push(ddo) results.push(ddo)
} }
this.setState({ results, isLoading: false }) this.setState({ results, isLoading: false })
} /*
} const consumedEvents = this.context.ocean.keeper.templates.escrowAccessSecretStoreTemplate.contract.getPastEvents(
'AgreementCreated',
{
filter: { _accessConsumer: this.context.account },
fromBlock: 0,
toBlock: 'latest'
})
const consumedResults = []
for (const event of publishedEvents) {
const ddo = await this.context.ocean.assets.resolve(
`did:op:${event.returnValues._did.substring(2)}`
) )
consumedResults.push(ddo)
}
this.setState({ consumedResults, isLoading: false })
*/
} catch (error) {
Logger.log('error getting history', error)
this.setState({ isLoading: false })
}
} else { } else {
this.setState({ isLoading: false }) this.setState({ isLoading: false })
} }