1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

Expose the granted agreementIds for a consumer.

This commit is contained in:
Pedro Gutiérrez 2019-05-28 15:53:14 +02:00 committed by Pedro Gutiérrez
parent 7f0d50691c
commit 90fbc0b1d6
2 changed files with 7 additions and 4 deletions

View File

@ -20,9 +20,11 @@ export class AccessSecretStoreCondition extends Condition {
return this.call<boolean>("checkPermissions", [grantee, didZeroX(did)].map(zeroX), from)
}
public async getGrantedDidByConsumer(consumer: string): Promise<string[]> {
public async getGrantedDidByConsumer(consumer: string): Promise<{did: string, agreementId: string}[]> {
return (await this.getPastEvents("Fulfilled", {_grantee: zeroX(consumer)}))
.map(({returnValues}) => returnValues._documentId)
.map(didPrefixed)
.map(({returnValues}) => ({
did: didPrefixed(returnValues._documentId),
agreementId: zeroX(returnValues._agreementId),
}))
}
}

View File

@ -292,7 +292,8 @@ export class OceanAssets extends Instantiable {
* @return {Promise<string[]>} List of DIDs.
*/
public async consumerAssets(consumer: string) {
return this.ocean.keeper.conditions.accessSecretStoreCondition.getGrantedDidByConsumer(consumer)
return (await this.ocean.keeper.conditions.accessSecretStoreCondition.getGrantedDidByConsumer(consumer))
.map(({did}) => did)
}
/**