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 & - ganache-cli --port 18545 > ganache-cli.log &
- git clone https://github.com/oceanprotocol/barge - git clone https://github.com/oceanprotocol/barge
- cd barge - cd barge
- export AQUARIUS_VERSION=v1.0.5 - export AQUARIUS_VERSION=unstable
- export BRIZO_VERSION=v0.8.1 - export BRIZO_VERSION=v0.8.1
- export KEEPER_VERSION=v0.13.2 - export KEEPER_VERSION=v0.13.2
- export EVENTS_HANDLER_VERSION=v0.4.4 - export EVENTS_HANDLER_VERSION=v0.4.4

View File

@ -230,14 +230,14 @@ export class Aquarius {
signature: string signature: string
): Promise<string> { ): Promise<string> {
did = did && DID.parse(did) 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 const result = await this.fetch
.put( .put(
fullUrl, fullUrl,
JSON.stringify({ JSON.stringify({
signature: signature, signature: signature,
updated: updated, updated: updated,
newowner: newOwner newOwner: newOwner
}) })
) )
.then((response: any) => { .then((response: any) => {
@ -253,7 +253,7 @@ export class Aquarius {
}) })
.catch(error => { .catch(error => {
this.logger.error('Error updating metadata: ', error) this.logger.error('Error transfering ownership metadata: ', error)
return null return null
}) })

View File

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

View File

@ -75,9 +75,8 @@ describe('Asset Owners', () => {
const { length: initialLength } = await ocean.assets.consumerAssets( const { length: initialLength } = await ocean.assets.consumerAssets(
account2.getId() account2.getId()
) )
const ddo = await ocean.assets.create(metadata as any, account1) const ddo = await ocean.assets.create(metadata as any, account1)
const { length: finalLength1 } = await ocean.assets.consumerAssets( const { length: finalLength1 } = await ocean.assets.consumerAssets(
account2.getId() account2.getId()
) )
@ -89,12 +88,10 @@ describe('Asset Owners', () => {
+metadata.main.price * 10 ** -(await ocean.keeper.token.decimals()) +metadata.main.price * 10 ** -(await ocean.keeper.token.decimals())
) )
} catch {} } catch {}
const { index } = ddo.findServiceByType('access') const { index } = ddo.findServiceByType('access')
await ocean.assets.order(ddo.id, index, account2) await ocean.assets.order(ddo.id, index, account2)
// Access granted // Access granted
const { length: finalLength2 } = await ocean.assets.consumerAssets( const { length: finalLength2 } = await ocean.assets.consumerAssets(
account2.getId() account2.getId()
) )
@ -103,11 +100,12 @@ describe('Asset Owners', () => {
it('should be able to transfer ownership', async () => { it('should be able to transfer ownership', async () => {
const { id } = await ocean.assets.create(metadata as any, account1) const { id } = await ocean.assets.create(metadata as any, account1)
// transfer // transfer
await ocean.assets.transferOwnership(id, account2.getId()) await ocean.assets.transferOwnership(id, account2.getId(), account1)
const newOwner = await ocean.keeper.didRegistry.getDIDOwner(id) const newOwner = await ocean.keeper.didRegistry.getDIDOwner(id)
assert.equal(newOwner, account2.getId()) assert.equal(newOwner, account2.getId())
// check aquarius
const aquariusOwner = await ocean.assets.owner(id)
assert.equal(aquariusOwner, account2.getId())
}) })
}) })