Skip to content

Commit

Permalink
Allow gasLimit overrides in the SDK/CLI for deploy txs (#3622)
Browse files Browse the repository at this point in the history
### Description

Small PR to actually allow overrides of gasLimit

---------

Co-authored-by: Yorke Rhodes <yorke@hyperlane.xyz>
  • Loading branch information
nambrot and yorhodes authored Apr 22, 2024
1 parent 450e8e0 commit 2e43942
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-days-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperlane-xyz/sdk": patch
---

Allow gasLimit overrides in the SDK/CLI for deploy txs
6 changes: 4 additions & 2 deletions typescript/sdk/src/providers/MultiProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,17 @@ export class MultiProvider<MetaExt = {}> extends ChainMetadataManager<MetaExt> {
const contractFactory = await factory.connect(signer);

// estimate gas
const deployTx = contractFactory.getDeployTransaction(...params, overrides);
const deployTx = contractFactory.getDeployTransaction(...params);
const gasEstimated = await signer.estimateGas(deployTx);

// deploy with 10% buffer on gas limit
const contract = await contractFactory.deploy(...params, {
...overrides,
gasLimit: gasEstimated.add(gasEstimated.div(10)), // 10% buffer
...overrides,
});

this.logger.trace({ transaction: deployTx }, `Deploying contract`);

// wait for deploy tx to be confirmed
await this.handleTx(chainNameOrId, contract.deployTransaction);

Expand Down

0 comments on commit 2e43942

Please sign in to comment.