Skip to content

Commit 5aa1774

Browse files
authored
Merge pull request #5578 from NomicFoundation/galargh/set-ledger-output-enabled
chore: do not send hardhat_setLedgerOutputEnabled over http
2 parents fcd70ca + d144d83 commit 5aa1774

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

.changeset/shaggy-bags-work.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"hardhat": patch
3+
---
4+
5+
Do not send `http_setLedgerOutputEnabled` messages beyond the HTTP Provider to prevent unwanted warnings in the logs of the local hardhat node

packages/hardhat-core/src/internal/core/providers/http.ts

+11
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ export class HttpProvider extends EventEmitter implements EIP1193Provider {
8686
}
8787

8888
public async request(args: RequestArguments): Promise<unknown> {
89+
// This is a temporary fix to an issue with noisy warnings in the logs
90+
// of a local node (#5406). This will be fixed in the next major release.
91+
if (args.method === "hardhat_setLedgerOutputEnabled") {
92+
const error = new ProviderError(
93+
"hardhat_setLedgerOutputEnabled - Method not supported",
94+
-32004
95+
);
96+
// eslint-disable-next-line @nomicfoundation/hardhat-internal-rules/only-hardhat-error
97+
throw error;
98+
}
99+
89100
const jsonRpcRequest = this._getJsonRpcRequest(
90101
args.method,
91102
args.params as any[]

packages/hardhat-core/test/internal/core/providers/http.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { assert } from "chai";
1+
import { assert, expect } from "chai";
22
import { MockAgent, MockPool } from "undici";
33

44
import { HttpProvider } from "../../../../src/internal/core/providers/http";
55
import { ERRORS } from "../../../../src/internal/core/errors-list";
66
import { SuccessfulJsonRpcResponse } from "../../../../src/internal/util/jsonrpc";
77
import { expectHardhatError } from "../../../helpers/errors";
8+
import { ProviderError } from "../../../../src/internal/core/providers/errors";
89

910
const TOO_MANY_REQUEST_STATUS = 429;
1011

@@ -93,5 +94,19 @@ describe("HttpProvider", function () {
9394
assert.equal(result, successResponse.result);
9495
assert(tooManyRequestsReturned);
9596
});
97+
98+
it("should throw an error if it receives hardhat_setLedgerOutputEnabled as a method", async function () {
99+
const mockPool = makeMockPool(url);
100+
mockPool
101+
.intercept({ method: "POST", path: "/" })
102+
.reply(200, successResponse);
103+
const provider = new HttpProvider(url, networkName, {}, 20000, mockPool);
104+
await expect(
105+
provider.request({ method: "hardhat_setLedgerOutputEnabled" })
106+
).to.be.eventually.rejectedWith(
107+
ProviderError,
108+
"hardhat_setLedgerOutputEnabled - Method not supported"
109+
);
110+
});
96111
});
97112
});

0 commit comments

Comments
 (0)