diff --git a/src/agents/coordinator.ts b/src/agents/coordinator.ts index ccab3cf26..ef963e3f3 100644 --- a/src/agents/coordinator.ts +++ b/src/agents/coordinator.ts @@ -63,13 +63,20 @@ export class DkgCoordinatorAgent { providers: ChecksumAddress[] ): Promise { const Coordinator = await this.connectReadWrite(provider); - const tx = await Coordinator.initiateRitual(providers); + + const estimatedGas = await Coordinator.estimateGas.initiateRitual( + providers + ); + const tx = await Coordinator.initiateRitual(providers, { + gasLimit: estimatedGas, + }); const txReceipt = await tx.wait(DEFAULT_WAIT_N_CONFIRMATIONS); + const [ritualStartEvent] = txReceipt.events ?? []; if (!ritualStartEvent) { throw new Error('Ritual start event not found'); } - return ritualStartEvent.args?.ritualId.toNumber(); + return ritualStartEvent.args?.ritualId; } public static async getRitual( diff --git a/src/dkg.ts b/src/dkg.ts index 5de7ee4cd..0dbb1d8eb 100644 --- a/src/dkg.ts +++ b/src/dkg.ts @@ -114,14 +114,14 @@ export class DkgClient { public static async initializeRitual( web3Provider: ethers.providers.Web3Provider, ursulas: ChecksumAddress[], - waitUntilEnd = false + blockUntilFinalized = false ): Promise { const ritualId = await DkgCoordinatorAgent.initializeRitual( web3Provider, ursulas ); - if (waitUntilEnd) { + if (blockUntilFinalized) { const isSuccessful = await DkgClient.waitUntilRitualEnd( web3Provider, ritualId diff --git a/src/sdk/strategy/cbd-strategy.ts b/src/sdk/strategy/cbd-strategy.ts index 2b6887371..0b2c7391d 100644 --- a/src/sdk/strategy/cbd-strategy.ts +++ b/src/sdk/strategy/cbd-strategy.ts @@ -30,11 +30,13 @@ export class CbdStrategy { } public async deploy( - web3Provider: ethers.providers.Web3Provider + web3Provider: ethers.providers.Web3Provider, + blockUntilDeployed = true ): Promise { const dkgRitual = await DkgClient.initializeRitual( web3Provider, - this.cohort.ursulaAddresses + this.cohort.ursulaAddresses, + blockUntilDeployed ); return DeployedCbdStrategy.create(this.cohort, dkgRitual); }