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:
commit
d84e2dc8d9
@ -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.
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user