diff --git a/integration/ocean/AssetOwners.test.ts b/integration/ocean/AssetOwners.test.ts index a32a904..e188ffc 100644 --- a/integration/ocean/AssetOwners.test.ts +++ b/integration/ocean/AssetOwners.test.ts @@ -25,7 +25,7 @@ describe('Asset Owners', () => { } }) - it('should be set correctly the owner of a asset', async () => { + it('should be set correctly the owner of an asset', async () => { const ddo = await ocean.assets.create(metadata as any, account1) const owner = await ocean.assets.owner(ddo.id) @@ -33,6 +33,17 @@ describe('Asset Owners', () => { assert.equal(owner, account1.getId()) }) + it('should be set correctly the provider of an asset', async () => { + const ddo = await ocean.assets.create(metadata as any, account1) + + const isProvider = await ocean.keeper.didRegistry.isDIDProvider( + ddo.id, + config.brizoAddress + ) + + assert.isTrue(isProvider) + }) + it('should get the assets owned by a user', async () => { const { length: initialLength } = await ocean.assets.ownerAssets( account2.getId() diff --git a/src/keeper/contracts/DIDRegistry.ts b/src/keeper/contracts/DIDRegistry.ts index abf441b..eca2cb4 100644 --- a/src/keeper/contracts/DIDRegistry.ts +++ b/src/keeper/contracts/DIDRegistry.ts @@ -1,4 +1,3 @@ -import Web3Provider from '../Web3Provider' import ContractBase from './ContractBase' import { zeroX, didPrefixed, didZeroX } from '../../utils' import { InstantiableConfig } from '../../Instantiable.abstract' @@ -28,13 +27,17 @@ export default class DIDRegistry extends ContractBase { } public async getDIDOwner(did: string): Promise { - return this.call('getDIDOwner', [zeroX(did)]) + return this.call('getDIDOwner', [didZeroX(did)]) } public async getBlockNumberUpdated(did: string): Promise { return +(await this.call('getBlockNumberUpdated', [zeroX(did)])) } + public async isDIDProvider(did: string, provider: string): Promise { + return this.call('isDIDProvider', [didZeroX(did), zeroX(provider)]) + } + public async getAttributesByOwner(owner: string): Promise { return (await this.getPastEvents('DIDAttributeRegistered', { _owner: zeroX(owner)