Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: Move off our fork of web3-providers in Mesh RPC Client #601

Merged
merged 3 commits into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This changelog is a work in progress and may contain notes for versions which ha

- Fixed an issue where order updates could have been missed if Mesh discovered blocks but didn't have time to process them before getting shut down. Now, blocks are only persisted to the DB once any order updates resulting from it have been processed. ([#566](https://github.com/0xProject/0x-mesh/pull/566)).
- Fixed a race-condition when adding new orders to Mesh which could result in order-relevant events being missed if they occured very soon after the order was submitted and the order validation RPC call took a long time ([#566](https://github.com/0xProject/0x-mesh/pull/566)).
- Upgraded the `web3-provider` dependency used by `@0x/mesh-rpc-client` in order to fix a bug where it was requiring either `process` OR `window` to exist in the global scope ([#601](https://github.com/0xProject/0x-mesh/pull/601)).


## v6.1.2-beta
Expand Down
2 changes: 1 addition & 1 deletion rpc/clients/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"@0x/types": "^2.4.1",
"@0x/typescript-typings": "^4.2.4",
"@0x/utils": "^4.4.2",
"@0x/web3-providers-fork": "0.0.7",
"uuid": "^3.3.2",
"web3-providers": "^2.0.0-alpha.1",
"websocket": "^1.0.29"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions rpc/clients/typescript/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export interface ClientConfig {
* passed to http.request or https.request. This can be used to pass a custom agent to enable WebSocketClient usage
* from behind an HTTP or HTTPS proxy server using koichik/node-tunnel or similar.
* clientConfig: The client configs documented here: https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketClient.md
* reconnectAfter: time in milliseconds after which to attempt to reconnect to WS server after an error occurred (default: 5000)
* reconnectDelay: time in milliseconds after which to attempt to reconnect to WS server after an error occurred (default: 5000)
*/
export interface WSOpts {
timeout?: number;
headers?: {};
protocol?: string;
clientConfig?: ClientConfig;
reconnectAfter?: number;
reconnectDelay?: number;
}

export interface StringifiedSignedOrder {
Expand Down
8 changes: 4 additions & 4 deletions rpc/clients/typescript/src/ws_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { assert } from '@0x/assert';
import { orderParsingUtils } from '@0x/order-utils';
import { ObjectMap, SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as Web3Providers from '@0x/web3-providers-fork';
import { v4 as uuid } from 'uuid';
import * as Web3Providers from 'web3-providers';
import * as WebSocket from 'websocket';

import {
Expand Down Expand Up @@ -51,7 +51,7 @@ const DEFAULT_WS_OPTS = {
// Source: https://github.com/theturtle32/WebSocket-Node/issues/359
fragmentOutgoingMessages: false,
},
reconnectAfter: DEFAULT_RECONNECT_AFTER_MS,
reconnectDelay: DEFAULT_RECONNECT_AFTER_MS,
};

/**
Expand Down Expand Up @@ -237,8 +237,8 @@ export class WSClient {
*/
constructor(url: string, wsOpts?: WSOpts) {
this._subscriptionIdToMeshSpecificId = {};
if (wsOpts !== undefined && wsOpts.reconnectAfter === undefined) {
wsOpts.reconnectAfter = DEFAULT_RECONNECT_AFTER_MS;
if (wsOpts !== undefined && wsOpts.reconnectDelay === undefined) {
wsOpts.reconnectDelay = DEFAULT_RECONNECT_AFTER_MS;
}
this._wsProvider = new Web3Providers.WebsocketProvider(
url,
Expand Down
2 changes: 1 addition & 1 deletion rpc/clients/typescript/test/ws_client_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ describe('WSClient', () => {
}) as any);
});

const client = new WSClient(`ws://localhost:${SERVER_PORT}`, { reconnectAfter: 100 });
const client = new WSClient(`ws://localhost:${SERVER_PORT}`, { reconnectDelay: 100 });
client.onReconnected(async () => {
// We need to add a sleep here so that we leave time for the client
// to get connected before destroying it.
Expand Down
134 changes: 66 additions & 68 deletions rpc/clients/typescript/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,6 @@
js-sha3 "^0.7.0"
lodash "^4.17.11"

"@0x/web3-providers-fork@0.0.7":
version "0.0.7"
resolved "https://registry.yarnpkg.com/@0x/web3-providers-fork/-/web3-providers-fork-0.0.7.tgz#9cf40ebb6a2aa230283c5accb195d92594bb0aa7"
integrity sha512-TB8Y/VY0RBXzkuP5Tzv5WdXIOjx0YMa/1tPe/7v4nP3z0CjlKWoXuD9PXUIQv1qlLx1sGR5/mf+XcjruYfnWoA==
dependencies:
"@babel/runtime" "^7.3.1"
"@types/node" "^10.12.18"
eventemitter3 "3.1.0"
lodash "^4.17.11"
url-parse "1.4.4"
web3-core "2.0.0-alpha"
web3-core-helpers "2.0.0-alpha"
web3-core-method "2.0.0-alpha"
web3-utils "2.0.0-alpha"
websocket "^1.0.28"
xhr2-cookies "1.1.0"

"@0x/web3-wrapper@^6.0.9":
version "6.0.9"
resolved "https://registry.yarnpkg.com/@0x/web3-wrapper/-/web3-wrapper-6.0.9.tgz#f5a4133ffe1cb7be3ad2decb85570122edee0176"
Expand Down Expand Up @@ -335,7 +318,7 @@
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab"
integrity sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==

"@types/node@*", "@types/node@^12.6.1":
"@types/node@*":
version "12.6.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.8.tgz#e469b4bf9d1c9832aee4907ba8a051494357c12c"
integrity sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg==
Expand All @@ -345,6 +328,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.13.tgz#ac786d623860adf39a3f51d629480aacd6a6eec7"
integrity sha512-yN/FNNW1UYsRR1wwAoyOwqvDuLDtVXnaJTZ898XIw/Q5cCaeVAlVwvsmXLX5PuiScBYwZsZU4JYSHB3TvfdwvQ==

"@types/node@^12.6.1":
version "12.12.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.21.tgz#aa44a6363291c7037111c47e4661ad210aded23f"
integrity sha512-8sRGhbpU+ck1n0PGAUgVrWrWdjSW2aqNeyC15W88GRsMpSwzv6RJGlLhE7s2RhVSOdyDmxbqlWSeThq4/7xqlA==

"@types/prop-types@*":
version "15.7.1"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.1.tgz#f1a11e7babb0c3cad68100be381d1e064c68f1f6"
Expand Down Expand Up @@ -2870,10 +2858,10 @@ eventemitter3@3.1.0:
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.0.tgz#090b4d6cdbd645ed10bf750d4b5407942d7ba163"
integrity sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==

eventemitter3@^3.1.0:
version "3.1.2"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7"
integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==
eventemitter3@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.0.tgz#d65176163887ee59f386d64c82610b696a4a74eb"
integrity sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==

events@^3.0.0:
version "3.0.0"
Expand Down Expand Up @@ -7240,16 +7228,16 @@ web3-core-helpers@1.0.0-beta.35:
web3-eth-iban "1.0.0-beta.35"
web3-utils "1.0.0-beta.35"

web3-core-helpers@2.0.0-alpha:
version "2.0.0-alpha"
resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-2.0.0-alpha.tgz#76d720e50a6d5fbf91761a350060cc155fa9e3d3"
integrity sha512-zTeVHIoa4ih7PWFWJX2giqivDMOoD/cX3XHlNcghgdfsyhuf17ktar6003c1QxrvRXmV8HMlBorcZjYzYuTsiA==
web3-core-helpers@2.0.0-alpha.1:
version "2.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-2.0.0-alpha.1.tgz#d20db557fe8740578105fb6b5790eb22097d1974"
integrity sha512-YUDECwESRI2Bw3ijEaGGkYhEAyqQF17KFtul9Y6OZLtYx6W7bJCMKbSFigLl99F3zFLZ8E/dwzCizSrD+DuWIQ==
dependencies:
"@babel/runtime" "^7.3.1"
lodash "^4.17.11"
web3-core "2.0.0-alpha"
web3-eth-iban "2.0.0-alpha"
web3-utils "2.0.0-alpha"
web3-core "2.0.0-alpha.1"
web3-eth-iban "2.0.0-alpha.1"
web3-utils "2.0.0-alpha.1"

web3-core-method@1.0.0-beta.35:
version "1.0.0-beta.35"
Expand All @@ -7262,19 +7250,19 @@ web3-core-method@1.0.0-beta.35:
web3-core-subscriptions "1.0.0-beta.35"
web3-utils "1.0.0-beta.35"

web3-core-method@2.0.0-alpha:
version "2.0.0-alpha"
resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-2.0.0-alpha.tgz#453063885ab3cdd2bf63e5e586cdb3ee7d9cdfcb"
integrity sha512-BlOumHB4Guh5/c41v20EMlyjTBhgVPJ+dqZG5o7i42KOASgJ1ZqTTR2hq16F6zqgTuBAvJ8o/AjyWSBPsU2Twg==
web3-core-method@2.0.0-alpha.1:
version "2.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-2.0.0-alpha.1.tgz#6fd59cd229550bd08cb8922c095870fc9bf35f66"
integrity sha512-RlKYn9spgKAbIU9IV5UCQBLAcblLf5O6LYCGacRk0Iyz2SE0bVMtd7CY1pcsIXegNFiT3CPk+XvcpOIehZBhVQ==
dependencies:
"@babel/runtime" "^7.3.1"
eventemitter3 "3.1.0"
lodash "^4.17.11"
rxjs "^6.4.0"
web3-core "2.0.0-alpha"
web3-core-helpers "2.0.0-alpha"
web3-core-subscriptions "2.0.0-alpha"
web3-utils "2.0.0-alpha"
web3-core "2.0.0-alpha.1"
web3-core-helpers "2.0.0-alpha.1"
web3-core-subscriptions "2.0.0-alpha.1"
web3-utils "2.0.0-alpha.1"

web3-core-promievent@1.0.0-beta.35:
version "1.0.0-beta.35"
Expand Down Expand Up @@ -7304,13 +7292,13 @@ web3-core-subscriptions@1.0.0-beta.35:
underscore "1.8.3"
web3-core-helpers "1.0.0-beta.35"

web3-core-subscriptions@2.0.0-alpha:
version "2.0.0-alpha"
resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-2.0.0-alpha.tgz#f8cb496af6e56b76bc0718213b7d777eeeacc741"
integrity sha512-xvOVyIrm5mF1iioxU+MGGWYMFftMOw5ILTqX1HQns4BVYiP1oEQu/PJ6h8wMMERC1uNkE+owNwJLCpf3BDn3EA==
web3-core-subscriptions@2.0.0-alpha.1:
version "2.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-2.0.0-alpha.1.tgz#5c2164ce8649645f6809dcdc34626ae12ec0d19b"
integrity sha512-fOr5DCz1QjwBPf/ssJ49Q0LVi5PUOkHmJ1y+5aSSJZmcuAZ9h1FJp7ANqAI7p7ssXnm9RpCDMg5vGa8tyYyAXA==
dependencies:
"@babel/runtime" "^7.3.1"
eventemitter3 "^3.1.0"
eventemitter3 "^4.0.0"
lodash "^4.17.11"

web3-core@1.0.0-beta.35:
Expand All @@ -7323,18 +7311,18 @@ web3-core@1.0.0-beta.35:
web3-core-requestmanager "1.0.0-beta.35"
web3-utils "1.0.0-beta.35"

web3-core@2.0.0-alpha:
version "2.0.0-alpha"
resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-2.0.0-alpha.tgz#79722bd65e5d9e28b47e2f43638c8994ed3f2b8e"
integrity sha512-K3DVpEv1peu/KarD/oB1DGl9h8aGj5hBecFeY3prNYVF1Ho9+2J9kKYsArW3Bss6Pa/KEv5MsVHMEYpx5wto0w==
web3-core@2.0.0-alpha.1:
version "2.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-2.0.0-alpha.1.tgz#4bb87b860a0bbf9fd19ae380a4773e12ac3b3010"
integrity sha512-7fBl1h9Z46q0n8ugjYWMZsBP1tLlt8Rp4dRDF11EUNFQo1ll60tHj9PdjQIcKqoTd9EKhjYeZUWIsLf7YuipqA==
dependencies:
"@babel/runtime" "^7.3.1"
"@types/bn.js" "^4.11.4"
"@types/node" "^12.6.1"
lodash "^4.17.11"
web3-core-method "2.0.0-alpha"
web3-providers "2.0.0-alpha"
web3-utils "2.0.0-alpha"
web3-core-method "2.0.0-alpha.1"
web3-providers "2.0.0-alpha.1"
web3-utils "2.0.0-alpha.1"

web3-eth-abi@1.0.0-beta.35:
version "1.0.0-beta.35"
Expand Down Expand Up @@ -7384,14 +7372,14 @@ web3-eth-iban@1.0.0-beta.35:
bn.js "4.11.6"
web3-utils "1.0.0-beta.35"

web3-eth-iban@2.0.0-alpha:
version "2.0.0-alpha"
resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-2.0.0-alpha.tgz#87c164d964b50c000554b1c58e46dac8e2b04787"
integrity sha512-SDSaU5QEbxaVwP/B/xl0S4xfu0UBzBD0c+rRYtB/o9NWKkRhcpnGqPnzBN9TB6C1+zbKba6/QlAbIUQsNO9WJQ==
web3-eth-iban@2.0.0-alpha.1:
version "2.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-2.0.0-alpha.1.tgz#79f1f6061b95b5bb64eb4243a6c65dadf542077c"
integrity sha512-I9oD+kjiF/RPYslndfr4UlhU/zdP67+LYG5dMx6zEM+KUmHdwQeMTp4w3NVZny7/pOtXA1w6dJJ2tL/OVfGkkw==
dependencies:
"@babel/runtime" "^7.3.1"
bn.js "4.11.8"
web3-utils "2.0.0-alpha"
web3-utils "2.0.0-alpha.1"

web3-eth-personal@1.0.0-beta.35:
version "1.0.0-beta.35"
Expand Down Expand Up @@ -7510,21 +7498,21 @@ web3-providers-ws@1.0.0-beta.35:
web3-core-helpers "1.0.0-beta.35"
websocket "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible"

web3-providers@2.0.0-alpha:
version "2.0.0-alpha"
resolved "https://registry.yarnpkg.com/web3-providers/-/web3-providers-2.0.0-alpha.tgz#6bce7f6e6d08fa874bd78214c6c54251cd7a81da"
integrity sha512-29+2xv7CRY9HNyjSc/S2S4NfqrVqJzad2py2AIW+7HigAu+S40QKVKGx66h3KGA5NZrV5uGbMaNoNnlVNIrbDw==
web3-providers@2.0.0-alpha.1, web3-providers@^2.0.0-alpha.1:
version "2.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/web3-providers/-/web3-providers-2.0.0-alpha.1.tgz#19486aed4b014ec5d7687fac4eef2042db8b338c"
integrity sha512-X7hDkLKVN1U5aWeNQeErev494VSgt4gHJpHTgXn2rxrdJYUf7+6e6Al7yvRHlDxoTzhycX+j11HQC+CZlA+uhQ==
dependencies:
"@babel/runtime" "^7.3.1"
"@types/node" "^10.12.18"
eventemitter3 "3.1.0"
lodash "^4.17.11"
url-parse "1.4.4"
web3-core "2.0.0-alpha"
web3-core-helpers "2.0.0-alpha"
web3-core-method "2.0.0-alpha"
web3-utils "2.0.0-alpha"
websocket "^1.0.28"
web3-core "2.0.0-alpha.1"
web3-core-helpers "2.0.0-alpha.1"
web3-core-method "2.0.0-alpha.1"
web3-utils "2.0.0-alpha.1"
websocket "github:web3-js/WebSocket-Node#polyfill/globalThis"
xhr2-cookies "1.1.0"

web3-shh@1.0.0-beta.35:
Expand All @@ -7550,10 +7538,10 @@ web3-utils@1.0.0-beta.35:
underscore "1.8.3"
utf8 "2.1.1"

web3-utils@2.0.0-alpha:
version "2.0.0-alpha"
resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-2.0.0-alpha.tgz#2e8b91f4887380672a270f8045826d72b58c12a4"
integrity sha512-EXPxfLdezx9nyt3dO0O0a8Er1sOvVW+lELcwoBWa+A3HwGLyc09Re0Fer+yW/NUp9UGJ9pp45bHkYAZul8tWHw==
web3-utils@2.0.0-alpha.1:
version "2.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-2.0.0-alpha.1.tgz#231442adea3b58bca0c7185ee5b7743c01938682"
integrity sha512-xZY9rPC/5S2utQV26x2oeWlBjs1cGwO+AAwv0smK2zjNi6UeTZjG9aZ/RJZJpToIapKhdtmQI6yZ8/ZQNDRGGg==
dependencies:
"@babel/runtime" "^7.3.1"
"@types/bn.js" "^4.11.4"
Expand All @@ -7579,7 +7567,7 @@ web3@1.0.0-beta.35:
web3-shh "1.0.0-beta.35"
web3-utils "1.0.0-beta.35"

websocket@1.0.29, websocket@^1.0.28, websocket@^1.0.29:
websocket@1.0.29, websocket@^1.0.29:
version "1.0.29"
resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.29.tgz#3f83e49d3279657c58b02a22d90749c806101b98"
integrity sha512-WhU8jKXC8sTh6ocLSqpZRlOKMNYGwUvjA5+XcIgIk/G3JCaDfkZUr0zA19sVSxJ0TEvm0i5IBzr54RZC4vzW7g==
Expand All @@ -7599,6 +7587,16 @@ websocket@1.0.29, websocket@^1.0.28, websocket@^1.0.29:
typedarray-to-buffer "^3.1.2"
yaeti "^0.0.6"

"websocket@github:web3-js/WebSocket-Node#polyfill/globalThis":
version "1.0.29"
resolved "https://codeload.github.com/web3-js/WebSocket-Node/tar.gz/905deb4812572b344f5801f8c9ce8bb02799d82e"
dependencies:
debug "^2.2.0"
es5-ext "^0.10.50"
nan "^2.14.0"
typedarray-to-buffer "^3.1.5"
yaeti "^0.0.6"

whatwg-fetch@2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
Expand Down