Skip to content

Commit 6771f00

Browse files
committed
chore: do not send hardhat_setLedgerOutputEnabled over http
1 parent 83721d9 commit 6771f00

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-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 if they reacht the HTTP Provider to prevent unwanted warnings in the local hardhat node logs

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

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

8888
public async request(args: RequestArguments): Promise<unknown> {
89+
if (args.method === "hardhat_setLedgerOutputEnabled") {
90+
const error = new ProviderError(
91+
"hardhat_setLedgerOutputEnabled - Method not supported",
92+
-32004
93+
);
94+
// eslint-disable-next-line @nomicfoundation/hardhat-internal-rules/only-hardhat-error
95+
throw error;
96+
}
97+
8998
const jsonRpcRequest = this._getJsonRpcRequest(
9099
args.method,
91100
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)