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:
parent
347915a41e
commit
b31a661dcb
@ -81,4 +81,14 @@ describe('Asset Owners', () => {
|
|||||||
const { length: finalLength2 } = await ocean.assets.consumerAssets(account2.getId())
|
const { length: finalLength2 } = await ocean.assets.consumerAssets(account2.getId())
|
||||||
assert.equal(finalLength2 - initialLength, 1)
|
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())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -62,7 +62,11 @@ export default class DIDRegistry extends ContractBase {
|
|||||||
return this.call('getPermission', [didZeroX(did), zeroX(grantee)])
|
return this.call('getPermission', [didZeroX(did), zeroX(grantee)])
|
||||||
}
|
}
|
||||||
|
|
||||||
public async transferDIDOwnership(did: string, owner: string, newOwner: string): Promise<TransactionReceipt> {
|
public async transferDIDOwnership(
|
||||||
return this.send('transferDIDOwnership', owner, [zeroX(did), zeroX(newOwner)])
|
did: string,
|
||||||
|
newOwnerAddress: string,
|
||||||
|
ownerAddress: string
|
||||||
|
): Promise<TransactionReceipt> {
|
||||||
|
return this.send('transferDIDOwnership', ownerAddress, [didZeroX(did), newOwnerAddress])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,12 +359,12 @@ export class OceanAssets extends Instantiable {
|
|||||||
/**
|
/**
|
||||||
* Transfer ownership of an asset.
|
* Transfer ownership of an asset.
|
||||||
* @param {string} did Asset DID.
|
* @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.
|
* @param {string} newOwner Ethereum address of the new owner of the DID.
|
||||||
* @return {Promise<TransactionReceipt>} Returns Web3 transaction receipt.
|
* @return {Promise<TransactionReceipt>} Returns Web3 transaction receipt.
|
||||||
*/
|
*/
|
||||||
public async transferOwnership(did: string, owner: string, newOwner: string): Promise<TransactionReceipt> {
|
public async transferOwnership(did: string, newOwner: string): Promise<TransactionReceipt> {
|
||||||
return this.ocean.keeper.didRegistry.transferDIDOwnership(did, owner, newOwner)
|
const owner = await this.ocean.assets.owner(did)
|
||||||
|
return this.ocean.keeper.didRegistry.transferDIDOwnership(did, newOwner, owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,7 @@ describe('DIDRegistry', () => {
|
|||||||
|
|
||||||
// transfer
|
// transfer
|
||||||
const newOwnerAccount: Account = (await ocean.accounts.list())[1]
|
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
|
// check
|
||||||
const newOwner = await didRegistry.getDIDOwner(did)
|
const newOwner = await didRegistry.getDIDOwner(did)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user