From aa6c74b1c4194321488ce8e670e2878dbdd0fefd Mon Sep 17 00:00:00 2001 From: nujabes403 Date: Sun, 5 Aug 2018 18:35:40 +0900 Subject: [PATCH 1/3] Fix bug: Call 'getGasPrice' rpc when tx.gasPrice is set to 0 intentionally --- packages/web3-core-method/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js index e29c776085d..48a178d36f8 100644 --- a/packages/web3-core-method/src/index.js +++ b/packages/web3-core-method/src/index.js @@ -561,7 +561,7 @@ Method.prototype.buildCall = function() { }; // Send the actual transaction - if(isSendTx && _.isObject(payload.params[0]) && !payload.params[0].gasPrice) { + if(isSendTx && _.isObject(payload.params[0]) && payload.params[0].gasPrice === undefined) { var getGasPrice = (new Method({ name: 'getGasPrice', From d034858a6d59ca2a73cb4ccd6cbfd0cf8dc13372 Mon Sep 17 00:00:00 2001 From: nujabes403 Date: Mon, 6 Aug 2018 20:45:03 +0900 Subject: [PATCH 2/3] Compare whether the value is undefined through 'typeof' operator --- packages/web3-core-method/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js index 48a178d36f8..e8012bf77c6 100644 --- a/packages/web3-core-method/src/index.js +++ b/packages/web3-core-method/src/index.js @@ -561,7 +561,7 @@ Method.prototype.buildCall = function() { }; // Send the actual transaction - if(isSendTx && _.isObject(payload.params[0]) && payload.params[0].gasPrice === undefined) { + if(isSendTx && _.isObject(payload.params[0]) && typeof payload.params[0].gasPrice === 'undefined') { var getGasPrice = (new Method({ name: 'getGasPrice', From 6966caceca0d5a45d588b0a88b7533cf7ddb18e0 Mon Sep 17 00:00:00 2001 From: nujabes403 Date: Wed, 8 Aug 2018 01:27:50 +0900 Subject: [PATCH 3/3] Support websocket reconnect on web3-providers-ws --- packages/web3-providers-ws/src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/web3-providers-ws/src/index.js b/packages/web3-providers-ws/src/index.js index 2bed2bc368f..a052812e366 100644 --- a/packages/web3-providers-ws/src/index.js +++ b/packages/web3-providers-ws/src/index.js @@ -76,6 +76,7 @@ var WebsocketProvider = function WebsocketProvider(url, options) { } this.connection = new Ws(url, protocol, undefined, headers); + this.reconnect = () => new Ws(url, protocol, undefined, headers); this.addDefaultEvents(); @@ -263,7 +264,9 @@ WebsocketProvider.prototype.send = function (payload, callback) { } else { console.error('no error callback'); } - callback(new Error('connection not open')); + // try reconnect, when connection is gone + this.reconnect(); + callback(new Error('connection not open. try reconnecting...')); return; }