1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Merge pull request #126 from oceanprotocol/fix/ocean-assets

Fix/ocean assets
This commit is contained in:
Ahmed Ali 2020-07-03 14:12:11 +02:00 committed by GitHub
commit d84e2dc8d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 18 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -315,6 +315,20 @@ export class MetadataStore {
return result
}
public async getOwnerAssets(owner: string): Promise<DDO[]> {
const q = {
offset: 100,
page: 1,
query: {
'publicKey.owner': [owner]
},
sort: {
value: 1
}
} as SearchQuery
return (await this.queryMetadata(q)).results
}
/**
* Edit Metadata for a DDO.
* @param {did} string DID.

View File

@ -167,27 +167,13 @@ export class Assets extends Instantiable {
})
}
/**
* Returns the owner of an asset.
* @param {string} did Decentralized ID.
* @return {Promise<string>} Returns Account ID
*/
public async owner(did: string): Promise<string> {
// TODO:
// const owner = await this.ocean.keeper.didRegistry.getDIDOwner(did)
// return owner
return ''
}
/**
* Returns the assets of a owner.
* @param {string} owner Owner address.
* @return {Promise<string[]>} List of DIDs.
*/
public async ownerAssets(owner: string): Promise<string[]> {
// TODO:
// return this.ocean.keeper.didRegistry.getAttributesByOwner(owner)
return ['']
public async ownerAssets(owner: string): Promise<DDO[]> {
return this.ocean.metadatastore.getOwnerAssets(owner)
}
/**

View File

@ -57,7 +57,7 @@ describe('Marketplace flow', () => {
web3
)
tokenAddress = await datatoken.create(blob, alice.getId())
console.log(blob)
assert(tokenAddress != null)
})
it('Generates metadata', async () => {
@ -177,9 +177,13 @@ describe('Marketplace flow', () => {
tx.transactionHash,
tokenAddress,
bob,
'~/my-datasets'
'./node_modules/my-datasets'
)
})
})
it('owner can list there assets', async () => {
const assets = await ocean.assets.ownerAssets(alice.getId())
assert(assets.length > 0)
})
})
})