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

await chaining to Promise.all

This commit is contained in:
Jernej Pregelj 2019-04-10 12:28:51 +02:00
parent e00e6d10d6
commit 26a721f754

View File

@ -29,26 +29,40 @@ export class Keeper extends Instantiable {
// Adding keeper inside Ocean to prevent `Keeper not defined yet` error
config.ocean.keeper = keeper
const resolvedInstances = await Promise.all([
// Main contracts
Dispenser.getInstance(config),
OceanToken.getInstance(config),
DIDRegistry.getInstance(config),
// Managers
TemplateStoreManager.getInstance(config),
AgreementStoreManager.getInstance(config),
ConditionStoreManager.getInstance(config),
// Conditions
LockRewardCondition.getInstance(config),
EscrowReward.getInstance(config),
AccessSecretStoreCondition.getInstance(config),
// Conditions
EscrowAccessSecretStoreTemplate.getInstance(config)
])
// Main contracts
keeper.dispenser = await Dispenser.getInstance(config)
keeper.token = await OceanToken.getInstance(config)
keeper.didRegistry = await DIDRegistry.getInstance(config)
keeper.dispenser = resolvedInstances[0]
keeper.token = resolvedInstances[1]
keeper.didRegistry = resolvedInstances[2]
// Managers
keeper.templateStoreManager = await TemplateStoreManager.getInstance(config)
keeper.agreementStoreManager = await AgreementStoreManager.getInstance(config)
keeper.conditionStoreManager = await ConditionStoreManager.getInstance(config)
keeper.templateStoreManager = resolvedInstances[3]
keeper.agreementStoreManager = resolvedInstances[4]
keeper.conditionStoreManager = resolvedInstances[5]
// Conditions
keeper.conditions = {
lockRewardCondition: await LockRewardCondition.getInstance(config),
escrowReward: await EscrowReward.getInstance(config),
accessSecretStoreCondition: await AccessSecretStoreCondition.getInstance(config),
lockRewardCondition: resolvedInstances[6],
escrowReward: resolvedInstances[7],
accessSecretStoreCondition: resolvedInstances[8]
}
// Conditions
keeper.templates = {
escrowAccessSecretStoreTemplate: await EscrowAccessSecretStoreTemplate.getInstance(config),
escrowAccessSecretStoreTemplate: resolvedInstances[9]
}
// Utils