Skip to content

Commit

Permalink
estimate gas
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jul 4, 2023
1 parent 4c89b04 commit 44bdd10
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/agents/coordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,20 @@ export class DkgCoordinatorAgent {
providers: ChecksumAddress[]
): Promise<number> {
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(
Expand Down
4 changes: 2 additions & 2 deletions src/dkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ export class DkgClient {
public static async initializeRitual(
web3Provider: ethers.providers.Web3Provider,
ursulas: ChecksumAddress[],
waitUntilEnd = false
blockUntilFinalized = false
): Promise<DkgRitual> {
const ritualId = await DkgCoordinatorAgent.initializeRitual(
web3Provider,
ursulas
);

if (waitUntilEnd) {
if (blockUntilFinalized) {
const isSuccessful = await DkgClient.waitUntilRitualEnd(
web3Provider,
ritualId
Expand Down
6 changes: 4 additions & 2 deletions src/sdk/strategy/cbd-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ export class CbdStrategy {
}

public async deploy(
web3Provider: ethers.providers.Web3Provider
web3Provider: ethers.providers.Web3Provider,
blockUntilDeployed = true
): Promise<DeployedCbdStrategy> {
const dkgRitual = await DkgClient.initializeRitual(
web3Provider,
this.cohort.ursulaAddresses
this.cohort.ursulaAddresses,
blockUntilDeployed
);
return DeployedCbdStrategy.create(this.cohort, dkgRitual);
}
Expand Down

1 comment on commit 44bdd10

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundled size for the package is listed below:

build/module/types/ethers-contracts/factories: 82.03 KB
build/module/types/ethers-contracts: 152.34 KB
build/module/types: 156.25 KB
build/module/src/policies: 19.53 KB
build/module/src/characters: 93.75 KB
build/module/src/agents: 39.06 KB
build/module/src/sdk/strategy: 31.25 KB
build/module/src/sdk: 46.88 KB
build/module/src/conditions/predefined: 19.53 KB
build/module/src/conditions/context: 42.97 KB
build/module/src/conditions/base: 54.69 KB
build/module/src/conditions: 156.25 KB
build/module/src/kits: 19.53 KB
build/module/src: 449.22 KB
build/module/test: 46.88 KB
build/module: 707.03 KB
build/main/types/ethers-contracts/factories: 82.03 KB
build/main/types/ethers-contracts: 152.34 KB
build/main/types: 156.25 KB
build/main/src/policies: 19.53 KB
build/main/src/characters: 93.75 KB
build/main/src/agents: 39.06 KB
build/main/src/sdk/strategy: 31.25 KB
build/main/src/sdk: 46.88 KB
build/main/src/conditions/predefined: 19.53 KB
build/main/src/conditions/context: 42.97 KB
build/main/src/conditions/base: 54.69 KB
build/main/src/conditions: 156.25 KB
build/main/src/kits: 19.53 KB
build/main/src: 453.13 KB
build/main/test: 46.88 KB
build/main: 710.94 KB
build: 1.39 MB

Please sign in to comment.