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

transferOwnership fixes, add integration test

This commit is contained in:
Matthias Kretschmann 2019-11-13 16:48:53 +01:00
parent 347915a41e
commit b31a661dcb
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 20 additions and 6 deletions

View File

@ -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())
})
})

View File

@ -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<TransactionReceipt> {
return this.send('transferDIDOwnership', owner, [zeroX(did), zeroX(newOwner)])
public async transferDIDOwnership(
did: string,
newOwnerAddress: string,
ownerAddress: string
): Promise<TransactionReceipt> {
return this.send('transferDIDOwnership', ownerAddress, [didZeroX(did), newOwnerAddress])
}
}

View File

@ -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<TransactionReceipt>} Returns Web3 transaction receipt.
*/
public async transferOwnership(did: string, owner: string, newOwner: string): Promise<TransactionReceipt> {
return this.ocean.keeper.didRegistry.transferDIDOwnership(did, owner, newOwner)
public async transferOwnership(did: string, newOwner: string): Promise<TransactionReceipt> {
const owner = await this.ocean.assets.owner(did)
return this.ocean.keeper.didRegistry.transferDIDOwnership(did, newOwner, owner)
}
/**

View File

@ -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)