This repository has been archived by the owner on Oct 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #455 from autonomoussoftware/fix-deps
Fix dependencies and patches
- Loading branch information
Showing
12 changed files
with
713 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,3 @@ ppa/metronome-desktop-walle* | |
|
||
# Certificates | ||
*.p12 | ||
|
||
# Web3 patches | ||
/patches/web3-*.patch |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
patch-package | ||
--- a/node_modules/web3-core-helpers/src/formatters.js | ||
+++ b/node_modules/web3-core-helpers/src/formatters.js | ||
@@ -216,7 +216,7 @@ var outputTransactionReceiptFormatter = function (receipt){ | ||
receipt.contractAddress = utils.toChecksumAddress(receipt.contractAddress); | ||
} | ||
|
||
- if(typeof receipt.status !== 'undefined') { | ||
+ if(typeof receipt.status === 'string') { | ||
receipt.status = Boolean(parseInt(receipt.status)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
patch-package | ||
--- a/node_modules/web3-core-method/src/index.js | ||
+++ b/node_modules/web3-core-method/src/index.js | ||
@@ -200,6 +200,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { | ||
intervalId = null, | ||
receiptJSON = '', | ||
gasProvided = (_.isObject(payload.params[0]) && payload.params[0].gas) ? payload.params[0].gas : null, | ||
+ isContractCall = _.isObject(payload.params[0]) && !!payload.params[0].data, | ||
isContractDeployment = _.isObject(payload.params[0]) && | ||
payload.params[0].data && | ||
payload.params[0].from && | ||
@@ -348,8 +349,8 @@ Method.prototype._confirmTransaction = function (defer, result, payload) { | ||
if (!isContractDeployment && !promiseResolved) { | ||
|
||
if(!receipt.outOfGas && | ||
- (!gasProvided || gasProvided !== receipt.gasUsed) && | ||
- (receipt.status === true || receipt.status === '0x1' || typeof receipt.status === 'undefined')) { | ||
+ (!gasProvided || gasProvided !== utils.numberToHex(receipt.gasUsed) || !isContractCall || (isContractCall && receipt.events)) && | ||
+ (receipt.status === true || receipt.status === '0x1' || receipt.status === null || typeof receipt.status === 'undefined')) { | ||
defer.eventEmitter.emit('receipt', receipt); | ||
defer.resolve(receipt); | ||
|
||
@@ -533,7 +534,16 @@ Method.prototype.buildCall = function() { | ||
|
||
// If wallet was found, sign tx, and send using sendRawTransaction | ||
if (wallet && wallet.privateKey) { | ||
- return method.accounts.signTransaction(_.omit(tx, 'from'), wallet.privateKey).then(sendSignedTx); | ||
+ return method.accounts.signTransaction(_.omit(tx, 'from'), wallet.privateKey) | ||
+ .then(sendSignedTx) | ||
+ .catch(function (err) { | ||
+ if (_.isFunction(defer.eventEmitter.listeners) && defer.eventEmitter.listeners('error').length) { | ||
+ defer.eventEmitter.emit('error', err); | ||
+ defer.eventEmitter.removeAllListeners(); | ||
+ defer.eventEmitter.catch(function () {}); | ||
+ } | ||
+ defer.reject(err); | ||
+ }); | ||
} | ||
|
||
// ETH_SIGN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
patch-package | ||
--- a/node_modules/web3-core-requestmanager/src/index.js | ||
+++ b/node_modules/web3-core-requestmanager/src/index.js | ||
@@ -103,13 +103,16 @@ RequestManager.prototype.setProvider = function (p, net) { | ||
_this.subscriptions[result.params.subscription].callback(null, result.params.result); | ||
} | ||
}); | ||
- // TODO add error, end, timeout, connect?? | ||
- // this.provider.on('error', function requestManagerNotification(result){ | ||
- // Object.keys(_this.subscriptions).forEach(function(id){ | ||
- // if(_this.subscriptions[id].callback) | ||
- // _this.subscriptions[id].callback(err); | ||
- // }); | ||
- // } | ||
+ | ||
+ // notify all subscriptions about the error condition | ||
+ this.provider.on('error', function (event) { | ||
+ Object.keys(_this.subscriptions).forEach(function(id){ | ||
+ if(_this.subscriptions[id] && _this.subscriptions[id].callback) | ||
+ _this.subscriptions[id].callback(event.code || new Error('Provider error')); | ||
+ }); | ||
+ }); | ||
+ | ||
+ // TODO add end, timeout, connect?? | ||
} | ||
}; | ||
|
||
@@ -205,17 +208,20 @@ RequestManager.prototype.addSubscription = function (id, name, type, callback) { | ||
* @param {Function} callback fired once the subscription is removed | ||
*/ | ||
RequestManager.prototype.removeSubscription = function (id, callback) { | ||
- var _this = this; | ||
- | ||
if(this.subscriptions[id]) { | ||
+ var type = this.subscriptions[id].type; | ||
+ | ||
+ // remove subscription first to avoid reentry | ||
+ delete this.subscriptions[id]; | ||
|
||
+ // then, try to actually unsubscribe | ||
this.send({ | ||
- method: this.subscriptions[id].type + '_unsubscribe', | ||
+ method: type + '_unsubscribe', | ||
params: [id] | ||
}, callback); | ||
- | ||
- // remove subscription | ||
- delete _this.subscriptions[id]; | ||
+ } else if (typeof callback === 'function') { | ||
+ // call the callback if the subscription was already removed | ||
+ callback(null); | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
patch-package | ||
--- a/node_modules/web3-core-subscriptions/src/subscription.js | ||
+++ b/node_modules/web3-core-subscriptions/src/subscription.js | ||
@@ -271,32 +271,18 @@ Subscription.prototype.subscribe = function() { | ||
_this.callback(null, output, _this); | ||
}); | ||
} else { | ||
- // unsubscribe, but keep listeners | ||
- _this.options.requestManager.removeSubscription(_this.id); | ||
- | ||
- // re-subscribe, if connection fails | ||
- if(_this.options.requestManager.provider.once) { | ||
- _this._reconnectIntervalId = setInterval(function () { | ||
- // TODO check if that makes sense! | ||
- if (_this.options.requestManager.provider.reconnect) { | ||
- _this.options.requestManager.provider.reconnect(); | ||
- } | ||
- }, 500); | ||
- | ||
- _this.options.requestManager.provider.once('connect', function () { | ||
- clearInterval(_this._reconnectIntervalId); | ||
- _this.subscribe(_this.callback); | ||
- }); | ||
- } | ||
- _this.emit('error', err); | ||
- | ||
- // call the callback, last so that unsubscribe there won't affect the emit above | ||
- _this.callback(err, null, _this); | ||
+ _this._resubscribe(err); | ||
} | ||
}); | ||
+ | ||
+ // just in case the provider reconnects silently, resubscribe over the new connection | ||
+ if (_this.options.requestManager.provider.once) { | ||
+ _this.options.requestManager.provider.once('connect', function () { | ||
+ _this._resubscribe() | ||
+ }) | ||
+ } | ||
} else { | ||
- _this.callback(err, null, _this); | ||
- _this.emit('error', err); | ||
+ _this._resubscribe(err); | ||
} | ||
}); | ||
|
||
@@ -304,4 +290,38 @@ Subscription.prototype.subscribe = function() { | ||
return this; | ||
}; | ||
|
||
+Subscription.prototype._resubscribe = function (err) { | ||
+ var _this = this; | ||
+ | ||
+ // unsubscribe | ||
+ this.options.requestManager.removeSubscription(this.id); | ||
+ | ||
+ // re-subscribe, if connection fails | ||
+ if(this.options.requestManager.provider.once && !_this._reconnectIntervalId) { | ||
+ this._reconnectIntervalId = setInterval(function () { | ||
+ // TODO check if that makes sense! | ||
+ if (_this.options.requestManager.provider.reconnect) { | ||
+ _this.options.requestManager.provider.reconnect(); | ||
+ } | ||
+ }, 500); | ||
+ | ||
+ this.options.requestManager.provider.once('connect', function () { | ||
+ clearInterval(_this._reconnectIntervalId); | ||
+ _this._reconnectIntervalId = null; | ||
+ | ||
+ // delete id to keep the listeners on subscribe | ||
+ _this.id = null; | ||
+ | ||
+ _this.subscribe(_this.callback); | ||
+ }); | ||
+ } | ||
+ | ||
+ if (err) { | ||
+ this.emit('error', err); | ||
+ } | ||
+ | ||
+ // call the callback, last so that unsubscribe there won't affect the emit above | ||
+ this.callback(err, null, this); | ||
+}; | ||
+ | ||
module.exports = Subscription; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
patch-package | ||
--- a/node_modules/web3-eth/src/index.js | ||
+++ b/node_modules/web3-eth/src/index.js | ||
@@ -368,6 +368,12 @@ var Eth = function Eth() { | ||
inputFormatter: [formatter.inputLogFormatter], | ||
outputFormatter: formatter.outputLogFormatter | ||
}), | ||
+ new Method({ | ||
+ name: 'getChainId', | ||
+ call: 'eth_chainId', | ||
+ params: 0, | ||
+ outputFormatter: utils.hexToNumber | ||
+ }), | ||
|
||
// subscriptions | ||
new Subscriptions({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
patch-package | ||
--- a/node_modules/web3-eth-accounts/node_modules/eth-lib/lib/bytes.js | ||
+++ b/node_modules/web3-eth-accounts/node_modules/eth-lib/lib/bytes.js | ||
@@ -6,7 +6,7 @@ var at = function at(bytes, index) { | ||
|
||
var random = function random(bytes) { | ||
var rnd = void 0; | ||
- if (typeof window !== "undefined" && window.crypto && window.crypto.getRandomValues) rnd = window.crypto.getRandomValues(new Uint8Array(bytes));else if (typeof require !== "undefined") rnd = require("c" + "rypto").randomBytes(bytes);else throw "Safe random numbers not available."; | ||
+ if (typeof window !== "undefined" && window.crypto && window.crypto.getRandomValues) rnd = window.crypto.getRandomValues(new Uint8Array(bytes));else if (typeof require !== "undefined") rnd = require("crypto").randomBytes(bytes);else throw "Safe random numbers not available."; | ||
var hex = "0x"; | ||
for (var i = 0; i < bytes; ++i) { | ||
hex += ("00" + rnd[i].toString(16)).slice(-2); | ||
--- a/node_modules/web3-eth-accounts/src/index.js | ||
+++ b/node_modules/web3-eth-accounts/src/index.js | ||
@@ -68,8 +68,8 @@ var Accounts = function Accounts() { | ||
|
||
var _ethereumCall = [ | ||
new Method({ | ||
- name: 'getId', | ||
- call: 'net_version', | ||
+ name: 'getChainId', | ||
+ call: 'eth_chainId', | ||
params: 0, | ||
outputFormatter: utils.hexToNumber | ||
}), | ||
@@ -220,7 +220,7 @@ Accounts.prototype.signTransaction = function signTransaction(tx, privateKey, ca | ||
|
||
// Otherwise, get the missing info from the Ethereum Node | ||
return Promise.all([ | ||
- isNot(tx.chainId) ? _this._ethereumCall.getId() : tx.chainId, | ||
+ isNot(tx.chainId) ? _this._ethereumCall.getChainId() : tx.chainId, | ||
isNot(tx.gasPrice) ? _this._ethereumCall.getGasPrice() : tx.gasPrice, | ||
isNot(tx.nonce) ? _this._ethereumCall.getTransactionCount(_this.privateKeyToAccount(privateKey).address) : tx.nonce | ||
]).then(function (args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
patch-package | ||
--- a/node_modules/web3-providers-ws/src/index.js | ||
+++ b/node_modules/web3-providers-ws/src/index.js | ||
@@ -25,6 +25,8 @@ | ||
var _ = require('underscore'); | ||
var errors = require('web3-core-helpers').errors; | ||
|
||
+var WsReconnector = require('websocket-reconnector'); | ||
+ | ||
var Ws = null; | ||
var _btoa = null; | ||
var parseURL = null; | ||
@@ -80,6 +82,11 @@ var WebsocketProvider = function WebsocketProvider(url, options) { | ||
// Allow a custom client configuration | ||
var clientConfig = options.clientConfig || undefined; | ||
|
||
+ // Enable automatic reconnection wrapping `Ws` with reconnector | ||
+ if (options.autoReconnect) { | ||
+ Ws = WsReconnector(Ws); | ||
+ } | ||
+ | ||
// When all node core implementations that do not have the | ||
// WHATWG compatible URL parser go out of service this line can be removed. | ||
if (parsedURL.auth) { | ||
@@ -232,7 +239,13 @@ WebsocketProvider.prototype._addResponseCallback = function(payload, callback) { | ||
setTimeout(function () { | ||
if (_this.responseCallbacks[id]) { | ||
_this.responseCallbacks[id](errors.ConnectionTimeout(_this._customTimeout)); | ||
+ | ||
delete _this.responseCallbacks[id]; | ||
+ | ||
+ // try to reconnect | ||
+ if (_this.connection.reconnect) { | ||
+ _this.connection.reconnect(); | ||
+ } | ||
} | ||
}, this._customTimeout); | ||
} | ||
@@ -267,11 +280,11 @@ WebsocketProvider.prototype.send = function (payload, callback) { | ||
// if(!this.connection.writable) | ||
// this.connection.connect({url: this.url}); | ||
if (this.connection.readyState !== this.connection.OPEN) { | ||
- console.error('connection not open on send()'); | ||
+ // console.error('connection not open on send()'); | ||
if (typeof this.connection.onerror === 'function') { | ||
this.connection.onerror(new Error('connection not open')); | ||
} else { | ||
- console.error('no error callback'); | ||
+ // console.error('no error callback'); | ||
} | ||
callback(new Error('connection not open')); | ||
return; | ||
@@ -299,15 +312,15 @@ WebsocketProvider.prototype.on = function (type, callback) { | ||
break; | ||
|
||
case 'connect': | ||
- this.connection.onopen = callback; | ||
+ this.connection.addEventListener('open', callback); | ||
break; | ||
|
||
case 'end': | ||
- this.connection.onclose = callback; | ||
+ this.connection.addEventListener('close', callback); | ||
break; | ||
|
||
case 'error': | ||
- this.connection.onerror = callback; | ||
+ this.connection.addEventListener('error', callback); | ||
break; | ||
|
||
// default: | ||
@@ -316,7 +329,26 @@ WebsocketProvider.prototype.on = function (type, callback) { | ||
} | ||
}; | ||
|
||
-// TODO add once | ||
+/** | ||
+ Subscribes to provider only once | ||
+ | ||
+ @method once | ||
+ @param {String} type 'notifcation', 'connect', 'error', 'end' or 'data' | ||
+ @param {Function} callback the callback to call | ||
+ */ | ||
+WebsocketProvider.prototype.once = function (type, callback) { | ||
+ var _this = this; | ||
+ | ||
+ function onceCallback(event) { | ||
+ setTimeout(function () { | ||
+ _this.removeListener(type, onceCallback); | ||
+ }, 0) | ||
+ | ||
+ callback(event); | ||
+ } | ||
+ | ||
+ this.on(type, onceCallback); | ||
+}; | ||
|
||
/** | ||
Removes event listener | ||
@@ -336,7 +368,17 @@ WebsocketProvider.prototype.removeListener = function (type, callback) { | ||
}); | ||
break; | ||
|
||
- // TODO remvoving connect missing | ||
+ case 'connect': | ||
+ this.connection.removeEventListener('open', callback); | ||
+ break; | ||
+ | ||
+ case 'end': | ||
+ this.connection.removeEventListener('close', callback); | ||
+ break; | ||
+ | ||
+ case 'error': | ||
+ this.connection.removeEventListener('error', callback); | ||
+ break; | ||
|
||
// default: | ||
// this.connection.removeListener(type, callback); |
Oops, something went wrong.