mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Add a way to know if an address is provider of an asset.
This commit is contained in:
parent
860967d246
commit
3235e4f930
@ -25,7 +25,7 @@ describe('Asset Owners', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should be set correctly the owner of a asset', async () => {
|
it('should be set correctly the owner of an asset', async () => {
|
||||||
const ddo = await ocean.assets.create(metadata as any, account1)
|
const ddo = await ocean.assets.create(metadata as any, account1)
|
||||||
|
|
||||||
const owner = await ocean.assets.owner(ddo.id)
|
const owner = await ocean.assets.owner(ddo.id)
|
||||||
@ -33,6 +33,17 @@ describe('Asset Owners', () => {
|
|||||||
assert.equal(owner, account1.getId())
|
assert.equal(owner, account1.getId())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should be set correctly the provider of an asset', async () => {
|
||||||
|
const ddo = await ocean.assets.create(metadata as any, account1)
|
||||||
|
|
||||||
|
const isProvider = await ocean.keeper.didRegistry.isDIDProvider(
|
||||||
|
ddo.id,
|
||||||
|
config.brizoAddress
|
||||||
|
)
|
||||||
|
|
||||||
|
assert.isTrue(isProvider)
|
||||||
|
})
|
||||||
|
|
||||||
it('should get the assets owned by a user', async () => {
|
it('should get the assets owned by a user', async () => {
|
||||||
const { length: initialLength } = await ocean.assets.ownerAssets(
|
const { length: initialLength } = await ocean.assets.ownerAssets(
|
||||||
account2.getId()
|
account2.getId()
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import Web3Provider from '../Web3Provider'
|
|
||||||
import ContractBase from './ContractBase'
|
import ContractBase from './ContractBase'
|
||||||
import { zeroX, didPrefixed, didZeroX } from '../../utils'
|
import { zeroX, didPrefixed, didZeroX } from '../../utils'
|
||||||
import { InstantiableConfig } from '../../Instantiable.abstract'
|
import { InstantiableConfig } from '../../Instantiable.abstract'
|
||||||
@ -28,13 +27,17 @@ export default class DIDRegistry extends ContractBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getDIDOwner(did: string): Promise<string> {
|
public async getDIDOwner(did: string): Promise<string> {
|
||||||
return this.call('getDIDOwner', [zeroX(did)])
|
return this.call('getDIDOwner', [didZeroX(did)])
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getBlockNumberUpdated(did: string): Promise<number> {
|
public async getBlockNumberUpdated(did: string): Promise<number> {
|
||||||
return +(await this.call('getBlockNumberUpdated', [zeroX(did)]))
|
return +(await this.call('getBlockNumberUpdated', [zeroX(did)]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async isDIDProvider(did: string, provider: string): Promise<string> {
|
||||||
|
return this.call('isDIDProvider', [didZeroX(did), zeroX(provider)])
|
||||||
|
}
|
||||||
|
|
||||||
public async getAttributesByOwner(owner: string): Promise<string[]> {
|
public async getAttributesByOwner(owner: string): Promise<string[]> {
|
||||||
return (await this.getPastEvents('DIDAttributeRegistered', {
|
return (await this.getPastEvents('DIDAttributeRegistered', {
|
||||||
_owner: zeroX(owner)
|
_owner: zeroX(owner)
|
||||||
|
Loading…
Reference in New Issue
Block a user