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

add consumed list function

This commit is contained in:
Jernej Pregelj 2019-04-05 10:58:38 +02:00
parent a1ab653ffb
commit 6706cb6fa1

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 {
'DIDAttributeRegistered', const publishedEvents = await this.context.ocean.keeper.didRegistry.contract.getPastEvents(
{ 'DIDAttributeRegistered',
filter: { _owner: this.context.account }, {
fromBlock: 0, filter: { _owner: this.context.account },
toBlock: 'latest' fromBlock: 0,
}, toBlock: 'latest'
async (error: any, events: any) => { })
if (error) { const results = []
Logger.log('error retrieving', error) for (const event of publishedEvents) {
this.setState({ isLoading: false }) const ddo = await this.context.ocean.assets.resolve(
} else { `did:op:${event.returnValues._did.substring(2)}`
const results = [] )
for (const event of events) { results.push(ddo)
const ddo = await this.context.ocean.assets.resolve(
`did:op:${event.returnValues._did.substring(2)}`
)
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 })
} }