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 3 commits
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
9 changes: 9 additions & 0 deletions packages/migrations/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "4.4.0-beta.1",
"changes": [
{
"note": "Update all contract deployments to pass the actual chain ID (rather than the network ID) via the newly modified @0x/utils/provider_utils",
"pr": 2270
}
]
},
{
"version": "4.4.0-beta.0",
"changes": [
Expand Down
4 changes: 4 additions & 0 deletions packages/utils/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{
"note": "Consolidated FixedMathRevertErrors",
"pr": 2255
},
{
"note": "Changed provider_utils.providerUtils.getChainIdAsync() to invoke RPC method eth_chainId rather than net_version",
"pr": 2270
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0x/utils",
"version": "4.6.0-beta.0",
"version": "4.6.0-beta.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't bump the version here, this is done by Lerna at publish time.

"engines": {
"node": ">=6.12"
},
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