Skip to content

Commit 26ec993

Browse files
authored
Merge pull request #8153 from NomicFoundation/plugin-gas-config-resolution
Fix gas config resolution in ethers plugin and add tests
2 parents abb9c7d + d9a1f1f commit 26ec993

4 files changed

Lines changed: 661 additions & 149 deletions

File tree

.changeset/wild-spiders-grab.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nomicfoundation/hardhat-ethers": patch
3+
---
4+
5+
Fix gas config fields (gas, gasMultiplier, gasPrice) not being applied when sending transactions through the HardhatEthersSigner

packages/hardhat-ethers/src/internal/signers/signers.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ type SignerAccounts =
4242
};
4343

4444
export class HardhatEthersSigner implements HardhatEthersSignerI {
45-
readonly #gasLimit: bigint | undefined;
4645
readonly #signerAccounts: SignerAccounts;
4746
#cachedPrivateKey: string | undefined;
4847

@@ -60,29 +59,21 @@ export class HardhatEthersSigner implements HardhatEthersSignerI {
6059
this.networkName = networkName;
6160
this.networkConfig = networkConfig;
6261

63-
let gasLimit: bigint | undefined;
64-
65-
if (networkConfig.gas !== "auto") {
66-
gasLimit = networkConfig.gas;
67-
}
68-
6962
const signerAccounts: SignerAccounts =
7063
networkConfig.type === "http"
7164
? { type: "http", accounts: networkConfig.accounts }
7265
: { type: "edr-simulated", accounts: networkConfig.accounts };
7366

74-
return new HardhatEthersSigner(address, provider, signerAccounts, gasLimit);
67+
return new HardhatEthersSigner(address, provider, signerAccounts);
7568
}
7669

7770
private constructor(
7871
address: string,
7972
provider: ethers.JsonRpcProvider | HardhatEthersProvider,
8073
signerAccounts: SignerAccounts,
81-
gasLimit?: bigint | undefined,
8274
) {
8375
this.address = getAddress(address);
8476
this.provider = provider;
85-
this.#gasLimit = gasLimit;
8677

8778
this.#signerAccounts = signerAccounts;
8879
}
@@ -94,7 +85,6 @@ export class HardhatEthersSigner implements HardhatEthersSignerI {
9485
this.address,
9586
provider,
9687
this.#signerAccounts,
97-
this.#gasLimit,
9888
);
9989
}
10090

@@ -283,21 +273,6 @@ export class HardhatEthersSigner implements HardhatEthersSignerI {
283273
resolvedTx.from = this.address;
284274
}
285275

286-
if (resolvedTx.gasLimit === null || resolvedTx.gasLimit === undefined) {
287-
if (this.#gasLimit !== undefined) {
288-
resolvedTx.gasLimit = this.#gasLimit;
289-
} else {
290-
promises.push(
291-
(async () => {
292-
resolvedTx.gasLimit = await this.provider.estimateGas({
293-
...resolvedTx,
294-
from: this.address,
295-
});
296-
})(),
297-
);
298-
}
299-
}
300-
301276
// The address may be an ENS name or Addressable
302277
if (resolvedTx.to !== null && resolvedTx.to !== undefined) {
303278
const _to = resolvedTx.to;

0 commit comments

Comments
 (0)