Skip to content

Commit deca75d

Browse files
authored
Merge pull request #6857 from NomicFoundation/ignition/gas-config
Add configurable maxFeePerGas and default to it if set
2 parents 94b36b0 + 698dc70 commit deca75d

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

.changeset/eighty-pianos-wait.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@nomicfoundation/ignition-core": patch
3+
"@nomicfoundation/hardhat-ignition": patch
4+
---
5+
6+
Add configurable maxFeePerGas and default to it if set

packages/hardhat-ignition-core/src/deploy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export async function deploy<
5252
strategy,
5353
strategyConfig,
5454
maxFeePerGasLimit,
55+
maxFeePerGas,
5556
maxPriorityFeePerGas,
5657
gasPrice,
5758
disableFeeBumping,
@@ -72,6 +73,7 @@ export async function deploy<
7273
strategy?: StrategyT;
7374
strategyConfig?: StrategyConfig[StrategyT];
7475
maxFeePerGasLimit?: bigint;
76+
maxFeePerGas?: bigint;
7577
maxPriorityFeePerGas?: bigint;
7678
gasPrice?: bigint;
7779
disableFeeBumping?: boolean;
@@ -120,6 +122,7 @@ export async function deploy<
120122

121123
const jsonRpcClient = new EIP1193JsonRpcClient(provider, {
122124
maxFeePerGasLimit,
125+
maxFeePerGas,
123126
maxPriorityFeePerGas,
124127
gasPrice,
125128
});

packages/hardhat-ignition-core/src/internal/execution/jsonrpc-client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export class EIP1193JsonRpcClient implements JsonRpcClient {
193193
private readonly _provider: EIP1193Provider,
194194
private readonly _config?: {
195195
maxFeePerGasLimit?: bigint;
196+
maxFeePerGas?: bigint;
196197
maxPriorityFeePerGas?: bigint;
197198
gasPrice?: bigint;
198199
}
@@ -687,6 +688,7 @@ export class EIP1193JsonRpcClient implements JsonRpcClient {
687688

688689
// Logic copied from ethers v6
689690
const maxFeePerGas =
691+
this._config?.maxFeePerGas ??
690692
latestBlock.baseFeePerGas * 2n + maxPriorityFeePerGas;
691693

692694
return {

packages/hardhat-ignition-core/test-integrations/new-api/internal/new-execution/jsonrpc-client.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,20 @@ describe("JSON-RPC client", function () {
121121
assert.equal(fees.maxPriorityFeePerGas, 1n);
122122
});
123123

124+
it("Should use the configured maxFeePerGas", async function () {
125+
const maxFeeClient = new EIP1193JsonRpcClient(
126+
this.hre.network.provider,
127+
{
128+
maxFeePerGas: 1n,
129+
}
130+
);
131+
const fees = await maxFeeClient.getNetworkFees();
132+
133+
assert("maxFeePerGas" in fees);
134+
135+
assert.equal(fees.maxFeePerGas, 1n);
136+
});
137+
124138
it("Should use return legacy fees when deploying to polygon network (chainId 137)", async function () {
125139
const polygonClient = new EIP1193JsonRpcClient(
126140
{

packages/hardhat-ignition/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extendConfig((config, userConfig) => {
4949

5050
config.networks[networkName].ignition = {
5151
maxFeePerGasLimit: userNetworkConfig.ignition?.maxFeePerGasLimit,
52+
maxFeePerGas: userNetworkConfig.ignition?.maxFeePerGas,
5253
maxPriorityFeePerGas: userNetworkConfig.ignition?.maxPriorityFeePerGas,
5354
gasPrice: userNetworkConfig.ignition?.gasPrice,
5455
disableFeeBumping: userNetworkConfig.ignition?.disableFeeBumping,
@@ -325,6 +326,8 @@ ignitionScope
325326
strategyConfig,
326327
maxFeePerGasLimit:
327328
hre.config.networks[hre.network.name]?.ignition.maxFeePerGasLimit,
329+
maxFeePerGas:
330+
hre.config.networks[hre.network.name]?.ignition.maxFeePerGas,
328331
maxPriorityFeePerGas:
329332
hre.config.networks[hre.network.name]?.ignition
330333
.maxPriorityFeePerGas,

packages/hardhat-ignition/src/type-extensions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ declare module "hardhat/types/config" {
1616
export interface HardhatNetworkUserConfig {
1717
ignition?: {
1818
maxFeePerGasLimit?: bigint;
19+
maxFeePerGas?: bigint;
1920
maxPriorityFeePerGas?: bigint;
2021
gasPrice?: bigint;
2122
disableFeeBumping?: boolean;
@@ -26,6 +27,7 @@ declare module "hardhat/types/config" {
2627
export interface HardhatNetworkConfig {
2728
ignition: {
2829
maxFeePerGasLimit?: bigint;
30+
maxFeePerGas?: bigint;
2931
maxPriorityFeePerGas?: bigint;
3032
gasPrice?: bigint;
3133
disableFeeBumping?: boolean;
@@ -36,6 +38,7 @@ declare module "hardhat/types/config" {
3638
export interface HttpNetworkUserConfig {
3739
ignition?: {
3840
maxFeePerGasLimit?: bigint;
41+
maxFeePerGas?: bigint;
3942
maxPriorityFeePerGas?: bigint;
4043
gasPrice?: bigint;
4144
disableFeeBumping?: boolean;
@@ -46,6 +49,7 @@ declare module "hardhat/types/config" {
4649
export interface HttpNetworkConfig {
4750
ignition: {
4851
maxFeePerGasLimit?: bigint;
52+
maxFeePerGas?: bigint;
4953
maxPriorityFeePerGas?: bigint;
5054
gasPrice?: bigint;
5155
disableFeeBumping?: boolean;

0 commit comments

Comments
 (0)