Skip to content

Commit

Permalink
use eth_chainId to detect chain id
Browse files Browse the repository at this point in the history
  • Loading branch information
haseebrabbani committed Jan 24, 2024
1 parent 2cc2753 commit f9d53b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cli/utils/get.network.id.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("getNetworkId", () => {
getNetworkId = provideGetNetworkId(mockWithRetry, mockEthersProviderSend);
});

it("invokes the net_version jsonrpc method and returns network id", async () => {
it("invokes the eth_chainId jsonrpc method and returns chain id", async () => {
const mockNetworkId = "0xf";
mockWithRetry.mockReturnValueOnce(mockNetworkId);

Expand All @@ -18,7 +18,7 @@ describe("getNetworkId", () => {
expect(networkId).toEqual(15);
expect(mockWithRetry).toHaveBeenCalledTimes(1);
expect(mockWithRetry).toHaveBeenCalledWith(mockEthersProviderSend, [
"net_version",
"eth_chainId",
[],
]);
});
Expand Down
4 changes: 2 additions & 2 deletions cli/utils/get.network.id.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertExists } from ".";
import { WithRetry } from "./with.retry";

// returns the network/chain id as reported by the "net_version" json-rpc method
// returns the network/chain id as reported by the "eth_chainId" json-rpc method
export type GetNetworkId = () => Promise<number>;

export default function provideGetNetworkId(
Expand All @@ -13,7 +13,7 @@ export default function provideGetNetworkId(

return async function getNetworkId() {
const networkId: string = await withRetry(ethersProviderSend, [
"net_version",
"eth_chainId",
[],
]);
return parseInt(networkId);
Expand Down

0 comments on commit f9d53b0

Please sign in to comment.