diff --git a/.travis.yml b/.travis.yml index 33a8834..71f42b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ before_script: - ganache-cli --port 18545 > ganache-cli.log & - git clone https://github.com/oceanprotocol/barge - cd barge - - export AQUARIUS_VERSION=v1.0.5 + - export AQUARIUS_VERSION=unstable - export BRIZO_VERSION=v0.8.1 - export KEEPER_VERSION=v0.13.2 - export EVENTS_HANDLER_VERSION=v0.4.4 diff --git a/src/aquarius/Aquarius.ts b/src/aquarius/Aquarius.ts index 1df4005..f1b3063 100644 --- a/src/aquarius/Aquarius.ts +++ b/src/aquarius/Aquarius.ts @@ -230,14 +230,14 @@ export class Aquarius { signature: string ): Promise { did = did && DID.parse(did) - const fullUrl = `${this.url}${apiPath}/transferownership/${did.getDid()}` + const fullUrl = `${this.url}${apiPath}/owner/update//${did.getDid()}` const result = await this.fetch .put( fullUrl, JSON.stringify({ signature: signature, updated: updated, - newowner: newOwner + newOwner: newOwner }) ) .then((response: any) => { @@ -253,7 +253,7 @@ export class Aquarius { }) .catch(error => { - this.logger.error('Error updating metadata: ', error) + this.logger.error('Error transfering ownership metadata: ', error) return null }) diff --git a/src/ocean/OceanAssets.ts b/src/ocean/OceanAssets.ts index 71d1500..ed7fb4a 100644 --- a/src/ocean/OceanAssets.ts +++ b/src/ocean/OceanAssets.ts @@ -379,9 +379,19 @@ export class OceanAssets extends Instantiable { /** * Returns the owner of a asset. * @param {string} did Decentralized ID. - * @return {Promise} Returns Agreement ID + * @return {Promise} Returns eth address */ public async owner(did: string): Promise { + const ddo = await this.resolve(did) + return ddo.publicKey[0].owner + } + + /** + * Returns the creator of a asset. + * @param {string} did Decentralized ID. + * @return {Promise} Returns eth address + */ + public async creator(did: string): Promise { const ddo = await this.resolve(did) const checksum = ddo.getChecksum() const { creator, signatureValue } = ddo.proof diff --git a/test/integration/ocean/AssetOwners.test.ts b/test/integration/ocean/AssetOwners.test.ts index 798971c..b97853e 100644 --- a/test/integration/ocean/AssetOwners.test.ts +++ b/test/integration/ocean/AssetOwners.test.ts @@ -75,9 +75,8 @@ describe('Asset Owners', () => { const { length: initialLength } = await ocean.assets.consumerAssets( account2.getId() ) - + const ddo = await ocean.assets.create(metadata as any, account1) - const { length: finalLength1 } = await ocean.assets.consumerAssets( account2.getId() ) @@ -89,12 +88,10 @@ describe('Asset Owners', () => { +metadata.main.price * 10 ** -(await ocean.keeper.token.decimals()) ) } catch {} - const { index } = ddo.findServiceByType('access') await ocean.assets.order(ddo.id, index, account2) // Access granted - const { length: finalLength2 } = await ocean.assets.consumerAssets( account2.getId() ) @@ -103,11 +100,12 @@ describe('Asset Owners', () => { it('should be able to transfer ownership', async () => { const { id } = await ocean.assets.create(metadata as any, account1) - // transfer - await ocean.assets.transferOwnership(id, account2.getId()) + await ocean.assets.transferOwnership(id, account2.getId(), account1) const newOwner = await ocean.keeper.didRegistry.getDIDOwner(id) - assert.equal(newOwner, account2.getId()) + // check aquarius + const aquariusOwner = await ocean.assets.owner(id) + assert.equal(aquariusOwner, account2.getId()) }) })