Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

@0x/utils: fix wrong RPC method in getChainIdAsync() #2270

Merged
merged 5 commits into from
Oct 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/test-utils/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const constants = {
BASE_16: 16,
INVALID_OPCODE: 'invalid opcode',
TESTRPC_NETWORK_ID: 50,
TESTRPC_CHAIN_ID: 1337,
// Note(albrow): In practice V8 and most other engines limit the minimum
// interval for setInterval to 10ms. We still set it to 0 here in order to
// ensure we always use the minimum interval.
Expand Down
2 changes: 1 addition & 1 deletion contracts/test-utils/test/mocha_blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ blockchainTests('mocha blockchain extensions', env => {
});

it('initializes the test environment', async () => {
expect(await env.getChainIdAsync()).to.eq(constants.TESTRPC_NETWORK_ID);
expect(await env.getChainIdAsync()).to.eq(constants.TESTRPC_CHAIN_ID);
expect(await env.getAccountAddressesAsync()).to.be.not.empty('');
});

Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/provider_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ export const providerUtils = {
{
jsonrpc: '2.0',
id: _.random(1, RPC_ID_MAX),
method: 'net_version',
method: 'eth_chainId',
params: [],
},
(err: Error | null, result?: JSONRPCResponsePayload) => {
if (!_.isNil(err)) {
reject(err);
}
if (!result) {
throw new Error("Invalid 'net_version' response");
throw new Error("Invalid 'eth_chainId' response");
}
accept(_.toNumber(result.result));
},
Expand Down