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

fix transferOwnership

This commit is contained in:
alexcos20 2020-03-25 11:21:03 +02:00
parent 55b03da4c6
commit 3ff0e87778
4 changed files with 20 additions and 12 deletions

View File

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

View File

@ -230,14 +230,14 @@ export class Aquarius {
signature: string
): Promise<string> {
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
})

View File

@ -379,9 +379,19 @@ export class OceanAssets extends Instantiable {
/**
* Returns the owner of a asset.
* @param {string} did Decentralized ID.
* @return {Promise<string>} Returns Agreement ID
* @return {Promise<string>} Returns eth address
*/
public async owner(did: string): Promise<string> {
const ddo = await this.resolve(did)
return ddo.publicKey[0].owner
}
/**
* Returns the creator of a asset.
* @param {string} did Decentralized ID.
* @return {Promise<string>} Returns eth address
*/
public async creator(did: string): Promise<string> {
const ddo = await this.resolve(did)
const checksum = ddo.getChecksum()
const { creator, signatureValue } = ddo.proof

View File

@ -77,7 +77,6 @@ describe('Asset Owners', () => {
)
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())
})
})