diff --git a/integration/ocean/AssetOwners.test.ts b/integration/ocean/AssetOwners.test.ts index 1eea73a..74704da 100644 --- a/integration/ocean/AssetOwners.test.ts +++ b/integration/ocean/AssetOwners.test.ts @@ -81,4 +81,14 @@ describe('Asset Owners', () => { const { length: finalLength2 } = await ocean.assets.consumerAssets(account2.getId()) assert.equal(finalLength2 - initialLength, 1) }) + + 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()) + const newOwner = await ocean.keeper.didRegistry.getDIDOwner(id) + + assert.equal(newOwner, account2.getId()) + }) }) diff --git a/src/keeper/contracts/DIDRegistry.ts b/src/keeper/contracts/DIDRegistry.ts index a790b20..ecb0768 100644 --- a/src/keeper/contracts/DIDRegistry.ts +++ b/src/keeper/contracts/DIDRegistry.ts @@ -62,7 +62,11 @@ export default class DIDRegistry extends ContractBase { return this.call('getPermission', [didZeroX(did), zeroX(grantee)]) } - public async transferDIDOwnership(did: string, owner: string, newOwner: string): Promise { - return this.send('transferDIDOwnership', owner, [zeroX(did), zeroX(newOwner)]) + public async transferDIDOwnership( + did: string, + newOwnerAddress: string, + ownerAddress: string + ): Promise { + return this.send('transferDIDOwnership', ownerAddress, [didZeroX(did), newOwnerAddress]) } } diff --git a/src/ocean/OceanAssets.ts b/src/ocean/OceanAssets.ts index dff3a96..d94f1e6 100644 --- a/src/ocean/OceanAssets.ts +++ b/src/ocean/OceanAssets.ts @@ -359,12 +359,12 @@ export class OceanAssets extends Instantiable { /** * Transfer ownership of an asset. * @param {string} did Asset DID. - * @param {string} owner Ethereum address of the current owner of the DID. * @param {string} newOwner Ethereum address of the new owner of the DID. * @return {Promise} Returns Web3 transaction receipt. */ - public async transferOwnership(did: string, owner: string, newOwner: string): Promise { - return this.ocean.keeper.didRegistry.transferDIDOwnership(did, owner, newOwner) + public async transferOwnership(did: string, newOwner: string): Promise { + const owner = await this.ocean.assets.owner(did) + return this.ocean.keeper.didRegistry.transferDIDOwnership(did, newOwner, owner) } /** diff --git a/test/keeper/DIDRegistry.test.ts b/test/keeper/DIDRegistry.test.ts index 581c81b..0b467c9 100644 --- a/test/keeper/DIDRegistry.test.ts +++ b/test/keeper/DIDRegistry.test.ts @@ -78,7 +78,7 @@ describe('DIDRegistry', () => { // transfer const newOwnerAccount: Account = (await ocean.accounts.list())[1] - await didRegistry.transferDIDOwnership(did, ownerAccount.getId(), newOwnerAccount.getId()) + await didRegistry.transferDIDOwnership(did, newOwnerAccount.getId(), ownerAccount.getId()) // check const newOwner = await didRegistry.getDIDOwner(did)