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

More updates.

This commit is contained in:
ssallam 2020-01-16 15:47:29 +01:00
parent c6876ca9e2
commit e22b63cc80
3 changed files with 36 additions and 9 deletions

View File

@ -30,10 +30,11 @@ export class TemplateStoreManager extends ContractBase {
}
public generateId(templateName: string) {
return this.call(
"generateId",
[templateName]
)
const args: any = [
{ type: 'string', value: templateName },
]
return this.web3.utils.soliditySha3(...args)
}
public getOwner(): Promise<string> {
@ -83,6 +84,14 @@ export class TemplateStoreManager extends ContractBase {
)
}
public async getActorTypeValue(actorTypeId: string) {
const typeValue = await this.call(
"getTemplateActorTypeValue",
[actorTypeId]
)
return typeValue
}
public async getTemplate(templateId: string) {
const {
state,

View File

@ -87,7 +87,7 @@ export class AgreementTemplateBase {
}
public getId() {
return ''
return this.templateManager.generateId(this.templateName)
}
/**
@ -143,8 +143,8 @@ export class AgreementTemplateBase {
* Conditions address list.
* @return {Promise<string[]>} Conditions address.
*/
public getConditionTypes(): Promise<string[]> {
return this.templateManager.getConditionTypes(this.getId())
public async getConditionTypes(): Promise<string[]> {
return await this.templateManager.getConditionTypes(this.getId())
}
/**
@ -276,4 +276,21 @@ export class AgreementTemplateBase {
return this.agreementStoreManager.getAgreementCreatedEvent(agreementId)
}
/**
* Return actor type ids for this template (specified by subclass)
*
*/
public async getActorTypeIds() {
const { actorTypeIds } = await this.templateManager.getTemplate(this.getId())
return actorTypeIds
}
/**
* Return actor types (strings) for this template (specified by subclass)
*
*/
public async getActorTypes() {
const actorTypeIds = await this.getActorTypeIds()
return actorTypeIds.map(typeId => this.templateManager.getActorTypeValue(typeId))
}
}

View File

@ -56,7 +56,8 @@ export class OceanAssets extends Instantiable {
/**
* Creates a new DDO.
* @param {MetaData} metadata DDO metadata.
* @param {Account} publisher Publisher account.
* @param {Account} publisher Publisher account.
* @param {list} services list of Service description documents
* @return {Promise<DDO>}
*/
public create(
@ -106,7 +107,7 @@ export class OceanAssets extends Instantiable {
{
type: 'access',
serviceEndpoint: this.ocean.brizo.getConsumeEndpoint(),
templateId: templates.escrowAccessSecretStoreTemplate.getAddress(),
templateId: templates.escrowAccessSecretStoreTemplate.getId(),
attributes: {
main: {
creator: publisher.getId(),