mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Fix lint errors.
This commit is contained in:
parent
48c4f64599
commit
7b5b110cec
@ -24,7 +24,7 @@ import { objectPromiseAll } from '../utils'
|
|||||||
import { EventHandler } from './EventHandler'
|
import { EventHandler } from './EventHandler'
|
||||||
|
|
||||||
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
||||||
import { AgreementTemplateBase } from "./contracts/templates/AgreementTemplateBase";
|
import { AgreementTemplateBase } from './contracts/templates/AgreementTemplateBase'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface with Ocean Keeper contracts.
|
* Interface with Ocean Keeper contracts.
|
||||||
|
@ -93,5 +93,4 @@ export class AgreementStoreManager extends ContractBase {
|
|||||||
agreementId: zeroX(agreementId)
|
agreementId: zeroX(agreementId)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,7 @@ export class TemplateStoreManager extends ContractBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public generateId(templateName: string) {
|
public generateId(templateName: string) {
|
||||||
const args: any = [
|
const args: any = [{ type: 'string', value: templateName }]
|
||||||
{ type: 'string', value: templateName },
|
|
||||||
]
|
|
||||||
|
|
||||||
return this.web3.utils.soliditySha3(...args)
|
return this.web3.utils.soliditySha3(...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +38,11 @@ export class TemplateStoreManager extends ContractBase {
|
|||||||
return this.call('owner', [])
|
return this.call('owner', [])
|
||||||
}
|
}
|
||||||
|
|
||||||
public async proposeTemplate(templateId: string, from?: string, ignoreExists?: boolean) {
|
public async proposeTemplate(
|
||||||
|
templateId: string,
|
||||||
|
from?: string,
|
||||||
|
ignoreExists?: boolean
|
||||||
|
) {
|
||||||
const template = await this.getTemplate(templateId)
|
const template = await this.getTemplate(templateId)
|
||||||
if (template.blockNumberUpdated !== 0) {
|
if (template.blockNumberUpdated !== 0) {
|
||||||
this.logger.warn(`Template "${templateId}" already exist.`)
|
this.logger.warn(`Template "${templateId}" already exist.`)
|
||||||
@ -73,7 +74,7 @@ export class TemplateStoreManager extends ContractBase {
|
|||||||
return this.sendFrom('revokeTemplate', [zeroX(templateId)], from)
|
return this.sendFrom('revokeTemplate', [zeroX(templateId)], from)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getConditionTypes(templateId: string): Promise<string[]> {
|
public async getConditionTypes(templateId: string): Promise<string[]> {
|
||||||
const { conditionTypes } = await this.getTemplate(templateId)
|
const { conditionTypes } = await this.getTemplate(templateId)
|
||||||
return conditionTypes
|
return conditionTypes
|
||||||
}
|
}
|
||||||
@ -85,10 +86,7 @@ export class TemplateStoreManager extends ContractBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getActorTypeValue(actorTypeId: string) {
|
public async getActorTypeValue(actorTypeId: string) {
|
||||||
const typeValue = await this.call(
|
const typeValue = await this.call('getTemplateActorTypeValue', [actorTypeId])
|
||||||
"getTemplateActorTypeValue",
|
|
||||||
[actorTypeId]
|
|
||||||
)
|
|
||||||
return typeValue
|
return typeValue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +106,6 @@ export class TemplateStoreManager extends ContractBase {
|
|||||||
blockNumberUpdated: +blockNumberUpdated,
|
blockNumberUpdated: +blockNumberUpdated,
|
||||||
conditionTypes,
|
conditionTypes,
|
||||||
actorTypeIds
|
actorTypeIds
|
||||||
|
|
||||||
} as TemplateMetadata
|
} as TemplateMetadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
import { escrowAccessServiceAgreementTemplate } from './EscrowAccess.serviceAgreementTemplate'
|
import {
|
||||||
import {TemplateStoreManager, AgreementStoreManager, ConditionStoreManager} from '../managers'
|
TemplateStoreManager,
|
||||||
|
AgreementStoreManager,
|
||||||
|
ConditionStoreManager
|
||||||
|
} from '../managers'
|
||||||
import DIDRegistry from '../DIDRegistry'
|
import DIDRegistry from '../DIDRegistry'
|
||||||
import { LockRewardCondition } from '../conditions/LockRewardCondition'
|
import { LockRewardCondition } from '../conditions/LockRewardCondition'
|
||||||
import { AccessSecretStoreCondition } from '../conditions/AccessSecretStoreCondition'
|
import { AccessSecretStoreCondition } from '../conditions/AccessSecretStoreCondition'
|
||||||
import { EscrowReward } from '../conditions/EscrowReward'
|
import { EscrowReward } from '../conditions/EscrowReward'
|
||||||
import { DDO } from '../../../ddo/DDO'
|
import { DDO } from '../../../ddo/DDO'
|
||||||
import {generateId, LoggerInstance, Logger, zeroX} from '../../../utils'
|
import { generateId, LoggerInstance, Logger, zeroX } from '../../../utils'
|
||||||
|
|
||||||
import {ComputeExecutionCondition, Condition, ConditionState, conditionStateNames} from '../conditions'
|
|
||||||
|
|
||||||
|
import {
|
||||||
|
ComputeExecutionCondition,
|
||||||
|
Condition,
|
||||||
|
ConditionState,
|
||||||
|
conditionStateNames
|
||||||
|
} from '../conditions'
|
||||||
|
|
||||||
export interface Conditions {
|
export interface Conditions {
|
||||||
lockRewardCondition: LockRewardCondition
|
lockRewardCondition: LockRewardCondition
|
||||||
@ -17,7 +24,6 @@ export interface Conditions {
|
|||||||
escrowReward: EscrowReward
|
escrowReward: EscrowReward
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface AgreementConditionsStatus {
|
export interface AgreementConditionsStatus {
|
||||||
[condition: string]: {
|
[condition: string]: {
|
||||||
condition: string
|
condition: string
|
||||||
@ -28,7 +34,6 @@ export interface AgreementConditionsStatus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class AgreementTemplateBase {
|
export class AgreementTemplateBase {
|
||||||
public templateName: string
|
public templateName: string
|
||||||
|
|
||||||
@ -77,7 +82,7 @@ export class AgreementTemplateBase {
|
|||||||
consumer: string,
|
consumer: string,
|
||||||
from?: string
|
from?: string
|
||||||
) {
|
) {
|
||||||
return await this.createFullAgreementData(
|
return this.createFullAgreementData(
|
||||||
agreementId,
|
agreementId,
|
||||||
ddo.shortId(),
|
ddo.shortId(),
|
||||||
ddo.findServiceByType('metadata').attributes.main.price,
|
ddo.findServiceByType('metadata').attributes.main.price,
|
||||||
@ -145,7 +150,7 @@ export class AgreementTemplateBase {
|
|||||||
* @return {Promise<string[]>} Conditions address.
|
* @return {Promise<string[]>} Conditions address.
|
||||||
*/
|
*/
|
||||||
public async getConditionTypes(): Promise<string[]> {
|
public async getConditionTypes(): Promise<string[]> {
|
||||||
return await this.templateManager.getConditionTypes(this.getId())
|
return this.templateManager.getConditionTypes(this.getId())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,12 +191,13 @@ export class AgreementTemplateBase {
|
|||||||
* @return {Promise} Conditions status.
|
* @return {Promise} Conditions status.
|
||||||
*/
|
*/
|
||||||
public async getAgreementStatus(
|
public async getAgreementStatus(
|
||||||
agreementId: string, conditionStoreManager: ConditionStoreManager
|
agreementId: string,
|
||||||
|
conditionStoreManager: ConditionStoreManager
|
||||||
): Promise<AgreementConditionsStatus | false> {
|
): Promise<AgreementConditionsStatus | false> {
|
||||||
|
|
||||||
const dependencies = await this.getServiceAgreementTemplateDependencies()
|
const dependencies = await this.getServiceAgreementTemplateDependencies()
|
||||||
const { conditionIds } = await this.agreementStoreManager.getAgreement(agreementId)
|
const { conditionIds } = await this.agreementStoreManager.getAgreement(
|
||||||
|
agreementId
|
||||||
|
)
|
||||||
if (!conditionIds.length) {
|
if (!conditionIds.length) {
|
||||||
// this.logger.error(`Agreement not creeated yet: "${agreementId}"`)
|
// this.logger.error(`Agreement not creeated yet: "${agreementId}"`)
|
||||||
return false
|
return false
|
||||||
@ -241,9 +247,12 @@ export class AgreementTemplateBase {
|
|||||||
/**
|
/**
|
||||||
* Prints the agreement status.
|
* Prints the agreement status.
|
||||||
* @param {string} agreementId Agreement ID.
|
* @param {string} agreementId Agreement ID.
|
||||||
* @param {ConditionStoreManager} conditionStoreManager
|
* @param {ConditionStoreManager} conditionStoreManager
|
||||||
*/
|
*/
|
||||||
public async printAgreementStatus(agreementId: string, conditionStoreManager: ConditionStoreManager) {
|
public async printAgreementStatus(
|
||||||
|
agreementId: string,
|
||||||
|
conditionStoreManager: ConditionStoreManager
|
||||||
|
) {
|
||||||
const status = await this.getAgreementStatus(agreementId, conditionStoreManager)
|
const status = await this.getAgreementStatus(agreementId, conditionStoreManager)
|
||||||
|
|
||||||
this.logger.bypass('-'.repeat(80))
|
this.logger.bypass('-'.repeat(80))
|
||||||
|
@ -21,7 +21,6 @@ export class EscrowAccessSecretStoreTemplate extends AgreementTemplateBase {
|
|||||||
} = this.conditions
|
} = this.conditions
|
||||||
|
|
||||||
const publisher = await this.didRegistry.getDIDOwner(did)
|
const publisher = await this.didRegistry.getDIDOwner(did)
|
||||||
|
|
||||||
const lockRewardConditionId = await lockRewardCondition.generateIdHash(
|
const lockRewardConditionId = await lockRewardCondition.generateIdHash(
|
||||||
agreementId,
|
agreementId,
|
||||||
await escrowReward.getAddress(),
|
await escrowReward.getAddress(),
|
||||||
@ -40,11 +39,6 @@ export class EscrowAccessSecretStoreTemplate extends AgreementTemplateBase {
|
|||||||
lockRewardConditionId,
|
lockRewardConditionId,
|
||||||
accessSecretStoreConditionId
|
accessSecretStoreConditionId
|
||||||
)
|
)
|
||||||
|
return [lockRewardConditionId, accessSecretStoreConditionId, escrowRewardId]
|
||||||
return [
|
|
||||||
lockRewardConditionId,
|
|
||||||
accessSecretStoreConditionId,
|
|
||||||
escrowRewardId
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,6 @@ export class EscrowComputeExecutionTemplate extends AgreementTemplateBase {
|
|||||||
lockRewardConditionId,
|
lockRewardConditionId,
|
||||||
computeExecutionConditionId
|
computeExecutionConditionId
|
||||||
)
|
)
|
||||||
|
return [lockRewardConditionId, computeExecutionConditionId, escrowRewardId]
|
||||||
return [
|
|
||||||
lockRewardConditionId,
|
|
||||||
computeExecutionConditionId,
|
|
||||||
escrowRewardId
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,9 +87,8 @@ export default class TestContractHandler extends ContractHandler {
|
|||||||
didRegistry.options.address
|
didRegistry.options.address
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
// Conditions
|
// Conditions
|
||||||
await TestContractHandler.deployContract(
|
const lockCondition = await TestContractHandler.deployContract(
|
||||||
'LockRewardCondition',
|
'LockRewardCondition',
|
||||||
deployerAddress,
|
deployerAddress,
|
||||||
[
|
[
|
||||||
@ -98,7 +97,7 @@ export default class TestContractHandler extends ContractHandler {
|
|||||||
token.options.address
|
token.options.address
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
await TestContractHandler.deployContract(
|
const accessCondition = await TestContractHandler.deployContract(
|
||||||
'AccessSecretStoreCondition',
|
'AccessSecretStoreCondition',
|
||||||
deployerAddress,
|
deployerAddress,
|
||||||
[
|
[
|
||||||
@ -107,9 +106,8 @@ export default class TestContractHandler extends ContractHandler {
|
|||||||
agreementStoreManager.options.address
|
agreementStoreManager.options.address
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
// Conditions rewards
|
// Conditions rewards
|
||||||
await TestContractHandler.deployContract(
|
const escrowCondition = await TestContractHandler.deployContract(
|
||||||
'EscrowReward',
|
'EscrowReward',
|
||||||
deployerAddress,
|
deployerAddress,
|
||||||
[
|
[
|
||||||
@ -118,7 +116,7 @@ export default class TestContractHandler extends ContractHandler {
|
|||||||
token.options.address
|
token.options.address
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
Logger.log(lockCondition, accessCondition, escrowCondition)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async deployContract(
|
private static async deployContract(
|
||||||
|
Loading…
Reference in New Issue
Block a user