mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
formatting updates for new prettier rules
This commit is contained in:
parent
1c884bcf09
commit
8ece01d9fa
@ -9,9 +9,7 @@ process.stdout.write(
|
||||
JSON.stringify(
|
||||
{
|
||||
version: require('../package.json').version,
|
||||
commit: execSync(`git rev-parse HEAD`)
|
||||
.toString()
|
||||
.trim()
|
||||
commit: execSync(`git rev-parse HEAD`).toString().trim()
|
||||
},
|
||||
null,
|
||||
' '
|
||||
|
@ -64,7 +64,7 @@ export class Aquarius {
|
||||
this.logger.error('Success accessing consume endpoint: ', consumptionUrl)
|
||||
return consumptionUrl
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error(
|
||||
'Error fetching the data asset consumption url: ',
|
||||
error
|
||||
@ -94,10 +94,10 @@ export class Aquarius {
|
||||
)
|
||||
return this.transformResult()
|
||||
})
|
||||
.then(results => {
|
||||
.then((results) => {
|
||||
return this.transformResult(results)
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error fetching querying metadata: ', error)
|
||||
return this.transformResult()
|
||||
})
|
||||
@ -133,10 +133,10 @@ export class Aquarius {
|
||||
)
|
||||
return this.transformResult()
|
||||
})
|
||||
.then(results => {
|
||||
.then((results) => {
|
||||
return this.transformResult(results)
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error fetching querying metadata by text: ', error)
|
||||
return this.transformResult()
|
||||
})
|
||||
@ -168,7 +168,7 @@ export class Aquarius {
|
||||
.then((response: DDO) => {
|
||||
return new DDO(response) as DDO
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error fetching querying metadata: ', error)
|
||||
return null as DDO
|
||||
})
|
||||
@ -204,7 +204,7 @@ export class Aquarius {
|
||||
.then((response: DDO) => {
|
||||
return new DDO(response) as DDO
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error fetching querying metadata: ', error)
|
||||
return null as DDO
|
||||
})
|
||||
@ -253,7 +253,7 @@ export class Aquarius {
|
||||
return null
|
||||
})
|
||||
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error transfering ownership metadata: ', error)
|
||||
return null
|
||||
})
|
||||
@ -307,7 +307,7 @@ export class Aquarius {
|
||||
return null
|
||||
})
|
||||
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error updating compute privacy: ', error)
|
||||
return null
|
||||
})
|
||||
@ -353,7 +353,7 @@ export class Aquarius {
|
||||
return null
|
||||
})
|
||||
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error transfering ownership metadata: ', error)
|
||||
return null
|
||||
})
|
||||
@ -391,7 +391,7 @@ export class Aquarius {
|
||||
return null
|
||||
})
|
||||
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
this.logger.error('Error transfering ownership metadata: ', error)
|
||||
return null
|
||||
})
|
||||
@ -412,7 +412,7 @@ export class Aquarius {
|
||||
}
|
||||
): QueryResult {
|
||||
return {
|
||||
results: (results || []).map(ddo => new DDO(ddo as DDO)),
|
||||
results: (results || []).map((ddo) => new DDO(ddo as DDO)),
|
||||
page,
|
||||
totalPages,
|
||||
totalResults
|
||||
|
@ -71,7 +71,7 @@ export class DDO {
|
||||
throw new Error('index is not set')
|
||||
}
|
||||
|
||||
const service = this.service.find(s => s.index === index)
|
||||
const service = this.service.find((s) => s.index === index)
|
||||
|
||||
return service as Service<T>
|
||||
}
|
||||
@ -86,7 +86,7 @@ export class DDO {
|
||||
throw new Error('serviceType not set')
|
||||
}
|
||||
|
||||
return this.service.find(s => s.type === serviceType) as Service<T>
|
||||
return this.service.find((s) => s.type === serviceType) as Service<T>
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,7 +98,7 @@ export class DDO {
|
||||
const { files, name, author, license } = attributes.main
|
||||
|
||||
const values = [
|
||||
...(files || []).map(({ checksum }) => checksum).filter(_ => !!_),
|
||||
...(files || []).map(({ checksum }) => checksum).filter((_) => !!_),
|
||||
name,
|
||||
author,
|
||||
license,
|
||||
|
@ -36,8 +36,8 @@ export class ContractEvent {
|
||||
}
|
||||
|
||||
public once(callback?: (events: any[]) => void) {
|
||||
return new Promise(resolve => {
|
||||
const subscription = this.subscribe(events => {
|
||||
return new Promise((resolve) => {
|
||||
const subscription = this.subscribe((events) => {
|
||||
subscription.unsubscribe()
|
||||
if (callback) {
|
||||
callback(events)
|
||||
|
@ -62,7 +62,7 @@ export class EventHandler extends Instantiable {
|
||||
}
|
||||
|
||||
if (this.lastBlock !== blockNumber) {
|
||||
this.events.forEach(fn => fn(this.lastBlock + 1))
|
||||
this.events.forEach((fn) => fn(this.lastBlock + 1))
|
||||
this.lastBlock = blockNumber
|
||||
}
|
||||
this.lastTimeout = global.setTimeout(
|
||||
|
@ -192,7 +192,7 @@ export class Keeper extends Instantiable {
|
||||
*/
|
||||
public getConditionByAddress(address: string): Condition {
|
||||
return Object.values(this.conditions).find(
|
||||
condition => condition.getAddress() === address
|
||||
(condition) => condition.getAddress() === address
|
||||
)
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ export class Keeper extends Instantiable {
|
||||
*/
|
||||
public getTemplateByName(name: string): AgreementTemplateBase {
|
||||
return Object.values(this.templates).find(
|
||||
template => template.templateName === name
|
||||
(template) => template.templateName === name
|
||||
)
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ export class Keeper extends Instantiable {
|
||||
*/
|
||||
public getTemplateById(templateId: string): AgreementTemplateBase {
|
||||
return Object.values(this.templates).find(
|
||||
template => template.getId() === templateId
|
||||
(template) => template.getId() === templateId
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ export abstract class ContractBase extends Instantiable {
|
||||
|
||||
private searchMethod(methodName: string, args: any[] = []) {
|
||||
const methods = this.contract.options.jsonInterface
|
||||
.map(method => ({
|
||||
.map((method) => ({
|
||||
...method,
|
||||
signature: (method as any).signature
|
||||
}))
|
||||
|
@ -80,7 +80,7 @@ export class TemplateStoreManager extends ContractBase {
|
||||
}
|
||||
|
||||
public getConditions(conditionTypes: string[]) {
|
||||
return conditionTypes.map(address =>
|
||||
return conditionTypes.map((address) =>
|
||||
this.ocean.keeper.getConditionByAddress(address)
|
||||
)
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ export class AgreementTemplateBase {
|
||||
({ name: conditionRef }) => conditionRef === ref
|
||||
).contractName
|
||||
return (await this.getConditions()).find(
|
||||
condition => condition.contractName === name
|
||||
(condition) => condition.contractName === name
|
||||
)
|
||||
}
|
||||
|
||||
@ -237,8 +237,8 @@ export class AgreementTemplateBase {
|
||||
|
||||
return states.reduce((acc, { contractName, ref, state }) => {
|
||||
const blockers = dependencies[ref]
|
||||
.map(dependency => states.find(_ => _.ref === dependency))
|
||||
.filter(condition => condition.state !== ConditionState.Fulfilled)
|
||||
.map((dependency) => states.find((_) => _.ref === dependency))
|
||||
.filter((condition) => condition.state !== ConditionState.Fulfilled)
|
||||
return {
|
||||
...acc,
|
||||
[ref]: {
|
||||
@ -246,7 +246,7 @@ export class AgreementTemplateBase {
|
||||
contractName,
|
||||
state,
|
||||
blocked: !!blockers.length,
|
||||
blockedBy: blockers.map(_ => _.ref)
|
||||
blockedBy: blockers.map((_) => _.ref)
|
||||
}
|
||||
}
|
||||
}, {})
|
||||
@ -309,6 +309,8 @@ export class AgreementTemplateBase {
|
||||
*/
|
||||
public async getActorTypes() {
|
||||
const actorTypeIds = await this.getActorTypeIds()
|
||||
return actorTypeIds.map(typeId => this.templateManager.getActorTypeValue(typeId))
|
||||
return actorTypeIds.map((typeId) =>
|
||||
this.templateManager.getActorTypeValue(typeId)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export class OceanAccounts extends Instantiable {
|
||||
const ethAccounts: string[] = await this.web3.eth.getAccounts()
|
||||
|
||||
const accountPromises = ethAccounts.map(
|
||||
address => new Account(address, this.instanceConfig)
|
||||
(address) => new Account(address, this.instanceConfig)
|
||||
)
|
||||
return Promise.all(accountPromises)
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ export class OceanAssets extends Instantiable {
|
||||
services: Service[] = []
|
||||
): SubscribablePromise<CreateProgressStep, DDO> {
|
||||
this.logger.log('Creating asset')
|
||||
return new SubscribablePromise(async observer => {
|
||||
return new SubscribablePromise(async (observer) => {
|
||||
const { secretStoreUri } = this.config
|
||||
const { didRegistry, templates } = this.ocean.keeper
|
||||
|
||||
@ -147,7 +147,7 @@ export class OceanAssets extends Instantiable {
|
||||
)
|
||||
.reverse()
|
||||
// Adding index
|
||||
.map(_ => ({
|
||||
.map((_) => ({
|
||||
..._,
|
||||
index: indexCount++
|
||||
})) as Service[]
|
||||
@ -287,7 +287,7 @@ export class OceanAssets extends Instantiable {
|
||||
consumerAccount: Account,
|
||||
provider?: string
|
||||
): SubscribablePromise<OrderProgressStep, string> {
|
||||
return new SubscribablePromise(async observer => {
|
||||
return new SubscribablePromise(async (observer) => {
|
||||
const { keeper, utils } = this.ocean
|
||||
const ddo: DDO = await this.resolve(did)
|
||||
const condition = keeper.conditions.accessSecretStoreCondition
|
||||
|
@ -81,7 +81,7 @@ export class OceanCompute extends Instantiable {
|
||||
algorithmMeta?: MetaDataAlgorithm,
|
||||
provider?: string
|
||||
): SubscribablePromise<OrderProgressStep, string> {
|
||||
return new SubscribablePromise(async observer => {
|
||||
return new SubscribablePromise(async (observer) => {
|
||||
const { assets, keeper, utils } = this.ocean
|
||||
const ddo: DDO = await assets.resolve(datasetDid)
|
||||
const service: Service = ddo.findServiceByType('compute')
|
||||
|
@ -61,7 +61,7 @@ export class OceanVersions extends Instantiable {
|
||||
network: (await this.ocean.keeper.getNetworkName()).toLowerCase(),
|
||||
keeperVersion: keeperPackageJson.version,
|
||||
contracts: Object.values(await this.ocean.keeper.getAllInstances())
|
||||
.filter(_ => !!_)
|
||||
.filter((_) => !!_)
|
||||
.reduce(
|
||||
(acc, { contractName, address }) => ({
|
||||
...acc,
|
||||
@ -115,19 +115,19 @@ export class OceanVersions extends Instantiable {
|
||||
|
||||
const networks = techs
|
||||
.map(({ network }) => network)
|
||||
.filter(_ => !!_)
|
||||
.filter((_) => !!_)
|
||||
.reduce((acc, network) => ({ ...acc, [network]: true }), {})
|
||||
|
||||
let contractStatus = true
|
||||
const contractList = techs.map(({ contracts }) => contracts).filter(_ => !!_)
|
||||
const contractList = techs.map(({ contracts }) => contracts).filter((_) => !!_)
|
||||
Array.from(contractList.map(Object.keys))
|
||||
.reduce((acc, _) => [...acc, ..._], [])
|
||||
.filter((_, i, list) => list.indexOf(_) === i)
|
||||
.forEach(name => {
|
||||
.forEach((name) => {
|
||||
let address
|
||||
contractList
|
||||
.map(_ => _[name])
|
||||
.forEach(_ => {
|
||||
.map((_) => _[name])
|
||||
.forEach((_) => {
|
||||
if (!address) {
|
||||
address = _
|
||||
return
|
||||
|
@ -8,7 +8,7 @@ function fillParameterWithDDO(
|
||||
parameter: ServiceAgreementTemplateParameter,
|
||||
ddo: DDO
|
||||
): ServiceAgreementTemplateParameter {
|
||||
const getValue = name => {
|
||||
const getValue = (name) => {
|
||||
switch (name) {
|
||||
case 'amount':
|
||||
case 'price':
|
||||
@ -38,9 +38,9 @@ export function fillConditionsWithDDO(
|
||||
conditions: ServiceAgreementTemplateCondition[],
|
||||
ddo: DDO
|
||||
): ServiceAgreementTemplateCondition[] {
|
||||
return conditions.map(condition => ({
|
||||
return conditions.map((condition) => ({
|
||||
...condition,
|
||||
parameters: condition.parameters.map(parameter => ({
|
||||
parameters: condition.parameters.map((parameter) => ({
|
||||
...fillParameterWithDDO(parameter, ddo)
|
||||
}))
|
||||
}))
|
||||
|
@ -39,7 +39,7 @@ export class SubscribableObserver<T, P> {
|
||||
|
||||
private emit(type: 'onNext' | 'onComplete' | 'onError', value: any) {
|
||||
Array.from(this.subscriptions)
|
||||
.map(subscription => subscription[type])
|
||||
.map((subscription) => subscription[type])
|
||||
.filter((callback: any) => callback && typeof callback === 'function')
|
||||
.forEach((callback: any) => callback(value))
|
||||
}
|
||||
|
@ -42,12 +42,12 @@ export class SubscribablePromise<T extends any, P extends any> {
|
||||
const execution = executor(this.observer)
|
||||
|
||||
Promise.resolve(execution as any)
|
||||
.then(result => {
|
||||
.then((result) => {
|
||||
if (typeof (execution as any).then === 'function') {
|
||||
this.observer.complete(result)
|
||||
}
|
||||
})
|
||||
.catch(result => {
|
||||
.catch((result) => {
|
||||
if (typeof (execution as any).then === 'function') {
|
||||
this.observer.error(result)
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ describe('Compute', () => {
|
||||
)
|
||||
dataset = await ocean.assets
|
||||
.create(metadataAsset as MetaData, account, [computeService])
|
||||
.next(step => stepsAsset.push(step))
|
||||
.next((step) => stepsAsset.push(step))
|
||||
|
||||
assert.instanceOf(dataset, DDO)
|
||||
assert.isDefined(
|
||||
@ -92,7 +92,7 @@ describe('Compute', () => {
|
||||
)
|
||||
datasetNoRawAlgo = await ocean.assets
|
||||
.create(metadataAsset as MetaData, account, [computeService])
|
||||
.next(step => stepsAsset.push(step))
|
||||
.next((step) => stepsAsset.push(step))
|
||||
|
||||
assert.instanceOf(datasetNoRawAlgo, DDO)
|
||||
assert.isDefined(
|
||||
@ -118,7 +118,7 @@ describe('Compute', () => {
|
||||
)
|
||||
datasetWithTrustedAlgo = await ocean.assets
|
||||
.create(metadataAsset as MetaData, account, [computeService])
|
||||
.next(step => stepsAsset.push(step))
|
||||
.next((step) => stepsAsset.push(step))
|
||||
|
||||
assert.instanceOf(datasetWithTrustedAlgo, DDO)
|
||||
assert.isDefined(
|
||||
@ -132,7 +132,7 @@ describe('Compute', () => {
|
||||
const stepsAlgorithm = []
|
||||
algorithm = await ocean.assets
|
||||
.create(metadataAlgorithm as MetaData, account)
|
||||
.next(step => stepsAlgorithm.push(step))
|
||||
.next((step) => stepsAlgorithm.push(step))
|
||||
|
||||
assert.instanceOf(algorithm, DDO)
|
||||
assert.deepEqual(stepsAlgorithm, [0, 1, 2, 3, 4, 5, 6, 7])
|
||||
@ -143,7 +143,7 @@ describe('Compute', () => {
|
||||
|
||||
agreementId = await ocean.compute
|
||||
.order(account, datasetNoRawAlgo.id, null, rawAlgoMeta)
|
||||
.next(step => steps.push(step))
|
||||
.next((step) => steps.push(step))
|
||||
|
||||
assert.equal(agreementId, null)
|
||||
})
|
||||
@ -153,7 +153,7 @@ describe('Compute', () => {
|
||||
|
||||
agreementId = await ocean.compute
|
||||
.order(account, datasetWithTrustedAlgo.id, 'did:op:233454', null)
|
||||
.next(step => steps.push(step))
|
||||
.next((step) => steps.push(step))
|
||||
|
||||
assert.equal(agreementId, null)
|
||||
})
|
||||
@ -172,7 +172,7 @@ describe('Compute', () => {
|
||||
|
||||
agreementId = await ocean.compute
|
||||
.order(account, dataset.id)
|
||||
.next(step => steps.push(step))
|
||||
.next((step) => steps.push(step))
|
||||
|
||||
console.log(agreementId)
|
||||
assert.isDefined(agreementId)
|
||||
|
@ -170,7 +170,7 @@ describe('Consume Asset', () => {
|
||||
|
||||
assert.include(path, folder, 'The storage path is not correct.')
|
||||
|
||||
const files = await new Promise<string[]>(resolve => {
|
||||
const files = await new Promise<string[]>((resolve) => {
|
||||
fs.readdir(path, (e, fileList) => {
|
||||
resolve(fileList)
|
||||
})
|
||||
@ -195,7 +195,7 @@ describe('Consume Asset', () => {
|
||||
|
||||
assert.include(path, folder, 'The storage path is not correct.')
|
||||
|
||||
const files = await new Promise<string[]>(resolve => {
|
||||
const files = await new Promise<string[]>((resolve) => {
|
||||
fs.readdir(path, (e, fileList) => {
|
||||
resolve(fileList)
|
||||
})
|
||||
|
@ -43,7 +43,7 @@ describe('Consume Asset (Brizo)', () => {
|
||||
const steps = []
|
||||
ddo = await ocean.assets
|
||||
.create(metadata as any, publisher)
|
||||
.next(step => steps.push(step))
|
||||
.next((step) => steps.push(step))
|
||||
|
||||
assert.instanceOf(ddo, DDO)
|
||||
assert.deepEqual(steps, [0, 1, 2, 3, 4, 5, 6, 7])
|
||||
@ -64,7 +64,7 @@ describe('Consume Asset (Brizo)', () => {
|
||||
|
||||
agreementId = await ocean.assets
|
||||
.order(ddo.id, consumer)
|
||||
.next(step => steps.push(step))
|
||||
.next((step) => steps.push(step))
|
||||
} catch {}
|
||||
|
||||
assert.isDefined(agreementId)
|
||||
@ -77,7 +77,7 @@ describe('Consume Asset (Brizo)', () => {
|
||||
|
||||
assert.include(path, folder, 'The storage path is not correct.')
|
||||
|
||||
const files = await new Promise<string[]>(resolve => {
|
||||
const files = await new Promise<string[]>((resolve) => {
|
||||
fs.readdir(path, (e, fileList) => {
|
||||
resolve(fileList)
|
||||
})
|
||||
|
@ -72,7 +72,7 @@ xdescribe('Consume Asset (Large size)', () => {
|
||||
|
||||
assert.include(path, folder, 'The storage path is not correct.')
|
||||
|
||||
const files = await new Promise<string[]>(resolve => {
|
||||
const files = await new Promise<string[]>((resolve) => {
|
||||
fs.readdir(path, (e, fileList) => {
|
||||
resolve(fileList)
|
||||
})
|
||||
|
@ -53,7 +53,7 @@ describe('Register Escrow Access Secret Store Template', () => {
|
||||
true
|
||||
)
|
||||
// TODO: Use a event to detect template mined
|
||||
await new Promise(resolve => setTimeout(resolve, 2 * 1000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2 * 1000))
|
||||
})
|
||||
|
||||
it('should approve the template', async () => {
|
||||
@ -63,7 +63,7 @@ describe('Register Escrow Access Secret Store Template', () => {
|
||||
true
|
||||
)
|
||||
// TODO: Use a event to detect template mined
|
||||
await new Promise(resolve => setTimeout(resolve, 2 * 1000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2 * 1000))
|
||||
})
|
||||
})
|
||||
|
||||
@ -122,9 +122,9 @@ describe('Register Escrow Access Secret Store Template', () => {
|
||||
})
|
||||
|
||||
it('should have condition instances asociated', async () => {
|
||||
const conditionInstances = (await template.getConditionTypes()).map(address =>
|
||||
keeper.getConditionByAddress(address)
|
||||
)
|
||||
const conditionInstances = (
|
||||
await template.getConditionTypes()
|
||||
).map((address) => keeper.getConditionByAddress(address))
|
||||
|
||||
assert.equal(conditionInstances.length, 3, 'Expected 3 conditions.')
|
||||
|
||||
@ -133,10 +133,10 @@ describe('Register Escrow Access Secret Store Template', () => {
|
||||
EscrowReward,
|
||||
LockRewardCondition
|
||||
]
|
||||
conditionClasses.forEach(conditionClass => {
|
||||
conditionClasses.forEach((conditionClass) => {
|
||||
if (
|
||||
!conditionInstances.find(
|
||||
condition => condition instanceof conditionClass
|
||||
(condition) => condition instanceof conditionClass
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
|
@ -55,7 +55,7 @@ describe('Register Escrow Compute Execution Template', () => {
|
||||
true
|
||||
)
|
||||
// TODO: Use a event to detect template mined
|
||||
await new Promise(resolve => setTimeout(resolve, 2 * 1000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2 * 1000))
|
||||
})
|
||||
|
||||
it('should approve the template', async () => {
|
||||
@ -65,7 +65,7 @@ describe('Register Escrow Compute Execution Template', () => {
|
||||
true
|
||||
)
|
||||
// TODO: Use a event to detect template mined
|
||||
await new Promise(resolve => setTimeout(resolve, 2 * 1000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2 * 1000))
|
||||
})
|
||||
})
|
||||
|
||||
@ -133,10 +133,10 @@ describe('Register Escrow Compute Execution Template', () => {
|
||||
EscrowReward,
|
||||
LockRewardCondition
|
||||
]
|
||||
conditionClasses.forEach(conditionClass => {
|
||||
conditionClasses.forEach((conditionClass) => {
|
||||
if (
|
||||
!conditionInstances.find(
|
||||
condition => condition instanceof conditionClass
|
||||
(condition) => condition instanceof conditionClass
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
|
@ -11,9 +11,7 @@ describe('Search Asset', () => {
|
||||
|
||||
let publisher: Account
|
||||
|
||||
const testHash = Math.random()
|
||||
.toString(36)
|
||||
.substr(2)
|
||||
const testHash = Math.random().toString(36).substr(2)
|
||||
let price
|
||||
const metadataGenerator = (name: string) =>
|
||||
generateMetadata(`${name}${testHash}`, price)
|
||||
@ -83,7 +81,7 @@ describe('Search Asset', () => {
|
||||
1,
|
||||
'Something was wrong searching the assets'
|
||||
)
|
||||
ddos.map(ddo =>
|
||||
ddos.map((ddo) =>
|
||||
assert.instanceOf(ddo, DDO, 'The DDO is not an instance of a DDO')
|
||||
)
|
||||
})
|
||||
@ -101,7 +99,7 @@ describe('Search Asset', () => {
|
||||
})
|
||||
|
||||
assert.equal(ddos.length, 1, 'Something was wrong searching the assets')
|
||||
ddos.map(ddo =>
|
||||
ddos.map((ddo) =>
|
||||
assert.instanceOf(ddo, DDO, 'The DDO is not an instance of a DDO')
|
||||
)
|
||||
})
|
||||
|
@ -9,7 +9,7 @@ import { LoggerInstance } from '../../../src/utils'
|
||||
|
||||
use(spies)
|
||||
|
||||
const reponsify = async data => ({
|
||||
const reponsify = async (data) => ({
|
||||
ok: true,
|
||||
json: () => Promise.resolve(data)
|
||||
})
|
||||
|
@ -17,25 +17,25 @@ describe('ContractWrapperBase', () => {
|
||||
})
|
||||
|
||||
describe('#call()', () => {
|
||||
it('should fail to call on an unknown contract function', done => {
|
||||
it('should fail to call on an unknown contract function', (done) => {
|
||||
wrappedContract.callMock('balanceOfxxx', []).catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should fail to call on an contract function with wrong set of parameters', done => {
|
||||
it('should fail to call on an contract function with wrong set of parameters', (done) => {
|
||||
wrappedContract.callMock('balanceOf', []).catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should fail to call on an unknown contract function', done => {
|
||||
it('should fail to call on an unknown contract function', (done) => {
|
||||
wrappedContract.sendMock('balanceOfxxx', '0x00', ['0x00']).catch(() => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should fail to call on an contract function with wrong set of parameters', done => {
|
||||
it('should fail to call on an contract function with wrong set of parameters', (done) => {
|
||||
wrappedContract.sendMock('approve', '0x000', []).catch(() => {
|
||||
done()
|
||||
})
|
||||
@ -43,7 +43,7 @@ describe('ContractWrapperBase', () => {
|
||||
})
|
||||
|
||||
describe('#send()', () => {
|
||||
it('should fail to call on an unknown contract function', done => {
|
||||
it('should fail to call on an unknown contract function', (done) => {
|
||||
wrappedContract.sendMock('transferxxx', accounts[0].getId(), []).catch(() => {
|
||||
done()
|
||||
})
|
||||
@ -60,7 +60,7 @@ describe('ContractWrapperBase', () => {
|
||||
})
|
||||
|
||||
describe('#getEventData()', () => {
|
||||
it('should fail on unknown event', done => {
|
||||
it('should fail on unknown event', (done) => {
|
||||
wrappedContract.getEventData('crazyevent', {}).catch(() => {
|
||||
done()
|
||||
})
|
||||
|
@ -28,8 +28,8 @@ describe('ContractEvent', () => {
|
||||
let validResolve = false
|
||||
let subscription: ContractEventSubscription
|
||||
|
||||
const waitUntilEvent = new Promise(resolve => {
|
||||
subscription = event.subscribe(events => {
|
||||
const waitUntilEvent = new Promise((resolve) => {
|
||||
subscription = event.subscribe((events) => {
|
||||
assert.isDefined(events)
|
||||
assert.lengthOf(events, 2)
|
||||
if (validResolve) {
|
||||
@ -40,7 +40,7 @@ describe('ContractEvent', () => {
|
||||
|
||||
await Promise.all([executeTransaction(), executeTransaction()])
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 2000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000))
|
||||
validResolve = true
|
||||
|
||||
await Promise.all([executeTransaction(), executeTransaction()])
|
||||
@ -68,7 +68,7 @@ describe('ContractEvent', () => {
|
||||
|
||||
await executeTransaction()
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 2000))
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000))
|
||||
canBeRejected = true
|
||||
|
||||
await executeTransaction()
|
||||
@ -82,7 +82,7 @@ describe('ContractEvent', () => {
|
||||
|
||||
const waitUntilEvent = event.once()
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 400))
|
||||
await new Promise((resolve) => setTimeout(resolve, 400))
|
||||
|
||||
await executeTransaction()
|
||||
|
||||
|
@ -17,7 +17,7 @@ describe('ContractHandler', () => {
|
||||
assert(await contractHandler.get('OceanToken'))
|
||||
})
|
||||
|
||||
it('should fail to load an unknown contract', done => {
|
||||
it('should fail to load an unknown contract', (done) => {
|
||||
contractHandler.get('OceanXXX').catch(() => {
|
||||
done()
|
||||
})
|
||||
|
@ -67,12 +67,12 @@ describe('EventHandler', () => {
|
||||
|
||||
const subscription = eventHandler.subscribe(callbackSpy)
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 300))
|
||||
await new Promise((resolve) => setTimeout(resolve, 300))
|
||||
|
||||
expect(callbackSpy).not.to.has.been.called()
|
||||
blockNumber++
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 300))
|
||||
await new Promise((resolve) => setTimeout(resolve, 300))
|
||||
|
||||
expect(callbackSpy).to.has.been.called.with(blockNumber)
|
||||
|
||||
|
@ -18,7 +18,7 @@ describe('DID', () => {
|
||||
assert(did.getId() === id, did.getId())
|
||||
})
|
||||
|
||||
it('should throw if prefix does not match', done => {
|
||||
it('should throw if prefix does not match', (done) => {
|
||||
const id = '1234'
|
||||
try {
|
||||
const did: DID = DID.parse(`did:xxx:${id}`)
|
||||
@ -28,7 +28,7 @@ describe('DID', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('should throw if id does not match', done => {
|
||||
it('should throw if id does not match', (done) => {
|
||||
const id = 'xyz'
|
||||
try {
|
||||
const did: DID = DID.parse(`did:op:${id}`)
|
||||
|
@ -23,7 +23,7 @@ describe('OceanAccounts', () => {
|
||||
it('should return the list of accounts', async () => {
|
||||
const accounts = await oceanAccounts.list()
|
||||
|
||||
accounts.map(account => assert.instanceOf(account, Account))
|
||||
accounts.map((account) => assert.instanceOf(account, Account))
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -22,9 +22,9 @@ describe('SubscribablePromise', () => {
|
||||
assert.typeOf(subscription.unsubscribe, 'function')
|
||||
})
|
||||
|
||||
it('should listen the next values', done => {
|
||||
it('should listen the next values', (done) => {
|
||||
const onNextSpy = spy()
|
||||
const subscribable = new SubscribablePromise(observer => {
|
||||
const subscribable = new SubscribablePromise((observer) => {
|
||||
setTimeout(() => observer.next('test'), 10)
|
||||
setTimeout(() => observer.next('test'), 20)
|
||||
})
|
||||
@ -39,10 +39,10 @@ describe('SubscribablePromise', () => {
|
||||
})
|
||||
|
||||
describe('#then()', () => {
|
||||
it('should resolve', done => {
|
||||
it('should resolve', (done) => {
|
||||
const onCompleteSpy = spy()
|
||||
const onFinallySpy = spy()
|
||||
const subscribable = new SubscribablePromise(observer => {
|
||||
const subscribable = new SubscribablePromise((observer) => {
|
||||
setTimeout(() => observer.next('test'), 10)
|
||||
setTimeout(() => observer.complete('test'), 20)
|
||||
})
|
||||
@ -59,10 +59,10 @@ describe('SubscribablePromise', () => {
|
||||
})
|
||||
|
||||
describe('#error()', () => {
|
||||
it('should catch the error', done => {
|
||||
it('should catch the error', (done) => {
|
||||
const onErrorSpy = spy()
|
||||
const onFinallySpy = spy()
|
||||
const subscribable = new SubscribablePromise(observer => {
|
||||
const subscribable = new SubscribablePromise((observer) => {
|
||||
setTimeout(() => observer.next('test'), 10)
|
||||
setTimeout(() => observer.error('test'), 20)
|
||||
})
|
||||
@ -80,7 +80,7 @@ describe('SubscribablePromise', () => {
|
||||
|
||||
it('should be able to subscribe and wait for a promise', async () => {
|
||||
const onNextSpy = spy()
|
||||
const subscribable = new SubscribablePromise(observer => {
|
||||
const subscribable = new SubscribablePromise((observer) => {
|
||||
setTimeout(() => observer.next('test'), 10)
|
||||
setTimeout(() => observer.next('test'), 20)
|
||||
setTimeout(() => observer.complete('completed'), 30)
|
||||
@ -96,12 +96,12 @@ describe('SubscribablePromise', () => {
|
||||
|
||||
it('should use the result of a the promise as executor to complete the observer', async () => {
|
||||
const onNextSpy = spy()
|
||||
const subscribable = new SubscribablePromise(async observer => {
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
const subscribable = new SubscribablePromise(async (observer) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 10))
|
||||
observer.next('test')
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
await new Promise((resolve) => setTimeout(resolve, 10))
|
||||
observer.next('test')
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
await new Promise((resolve) => setTimeout(resolve, 10))
|
||||
return 'completed'
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user