web3-eth-contract
Advanced tools
Comparing version 1.4.0 to 1.5.0-rc.0
@@ -30,3 +30,2 @@ /* | ||
"use strict"; | ||
var _ = require('underscore'); | ||
var core = require('web3-core'); | ||
@@ -67,6 +66,6 @@ var Method = require('web3-core-method'); | ||
var lastArg = args[args.length - 1]; | ||
if (_.isObject(lastArg) && !_.isArray(lastArg)) { | ||
if (!!lastArg && typeof lastArg === 'object' && !Array.isArray(lastArg)) { | ||
options = lastArg; | ||
this.options = _.extend(this.options, this._getOrSetDefaultOptions(options)); | ||
if (_.isObject(address)) { | ||
this.options = { ...this.options, ...this._getOrSetDefaultOptions(options) }; | ||
if (!!address && typeof address === 'object') { | ||
address = null; | ||
@@ -280,3 +279,3 @@ } | ||
Contract.prototype._getCallback = function getCallback(args) { | ||
if (args && _.isFunction(args[args.length - 1])) { | ||
if (args && !!args[args.length - 1] && typeof args[args.length - 1] === 'function') { | ||
return args.pop(); // modify the args array! | ||
@@ -333,3 +332,3 @@ } | ||
// use given topics | ||
if (_.isArray(options.topics)) { | ||
if (Array.isArray(options.topics)) { | ||
result.topics = options.topics; | ||
@@ -355,3 +354,3 @@ // create topics based on filter | ||
// TODO: deal properly with components | ||
if (_.isArray(value)) { | ||
if (Array.isArray(value)) { | ||
return value.map(function (v) { | ||
@@ -435,3 +434,3 @@ return abi.encodeParameter(i.type, v); | ||
}).map(function (json) { | ||
var inputLength = (_.isArray(json.inputs)) ? json.inputs.length : 0; | ||
var inputLength = (Array.isArray(json.inputs)) ? json.inputs.length : 0; | ||
if (inputLength !== args.length) { | ||
@@ -443,3 +442,3 @@ throw new Error('The number of arguments is not matching the methods required number. You need to pass ' + inputLength + ' arguments.'); | ||
} | ||
return _.isArray(json.inputs) ? json.inputs : []; | ||
return Array.isArray(json.inputs) ? json.inputs : []; | ||
}).map(function (inputs) { | ||
@@ -505,3 +504,3 @@ return abi.encodeParameters(inputs, args).replace('0x', ''); | ||
} | ||
var constructor = _.find(this.options.jsonInterface, function (method) { | ||
var constructor = this.options.jsonInterface.find((method) => { | ||
return (method.type === 'constructor'); | ||
@@ -531,4 +530,4 @@ }) || {}; | ||
// get the options | ||
var options = (_.isObject(args[args.length - 1])) ? args.pop() : {}; | ||
var eventName = (_.isString(args[0])) ? args[0] : 'allevents'; | ||
var options = (!!args[args.length - 1] && typeof args[args.length - 1]) === 'object' ? args.pop() : {}; | ||
var eventName = (typeof args[0] === 'string') ? args[0] : 'allevents'; | ||
var event = (eventName.toLowerCase() === 'allevents') ? { | ||
@@ -583,3 +582,3 @@ name: 'ALLEVENTS', | ||
sub.unsubscribe(); | ||
if (_.isFunction(callback)) { | ||
if (typeof callback === 'function') { | ||
callback(err, res, sub); | ||
@@ -625,3 +624,3 @@ } | ||
} | ||
if (_.isFunction(this.callback)) { | ||
if (typeof this.callback === 'function') { | ||
this.callback(null, output, this); | ||
@@ -705,6 +704,6 @@ } | ||
// get block number to use for call | ||
if (processedArgs.type === 'call' && args[args.length - 1] !== true && (_.isString(args[args.length - 1]) || isFinite(args[args.length - 1]))) | ||
if (processedArgs.type === 'call' && args[args.length - 1] !== true && (typeof args[args.length - 1] === 'string' || isFinite(args[args.length - 1]))) | ||
processedArgs.defaultBlock = args.pop(); | ||
// get the options | ||
processedArgs.options = (_.isObject(args[args.length - 1])) ? args.pop() : {}; | ||
processedArgs.options = (!!args[args.length - 1] && typeof args[args.length - 1]) === 'object' ? args.pop() : {}; | ||
// get the generateRequest argument for batch requests | ||
@@ -787,3 +786,3 @@ processedArgs.generateRequest = (args[args.length - 1] === true) ? args.pop() : false; | ||
} | ||
if (_.isBoolean(this._method.payable) && !this._method.payable && args.options.value && args.options.value > 0) { | ||
if (typeof this._method.payable === 'boolean' && !this._method.payable && args.options.value && args.options.value > 0) { | ||
return utils._fireError(new Error('Can not send value to non-payable contract method or constructor'), defer.eventEmitter, defer.reject, args.callback); | ||
@@ -794,5 +793,5 @@ } | ||
receiptFormatter: function (receipt) { | ||
if (_.isArray(receipt.logs)) { | ||
if (Array.isArray(receipt.logs)) { | ||
// decode logs | ||
var events = _.map(receipt.logs, function (log) { | ||
var events = receipt.logs.map((log) => { | ||
return _this._parent._decodeEventABI.call({ | ||
@@ -799,0 +798,0 @@ name: 'ALLEVENTS', |
{ | ||
"name": "web3-eth-contract", | ||
"version": "1.4.0", | ||
"version": "1.5.0-rc.0", | ||
"description": "Web3 module to interact with Ethereum smart contracts.", | ||
@@ -18,10 +18,9 @@ "repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth-contract", | ||
"@types/bn.js": "^4.11.5", | ||
"underscore": "1.12.1", | ||
"web3-core": "1.4.0", | ||
"web3-core-helpers": "1.4.0", | ||
"web3-core-method": "1.4.0", | ||
"web3-core-promievent": "1.4.0", | ||
"web3-core-subscriptions": "1.4.0", | ||
"web3-eth-abi": "1.4.0", | ||
"web3-utils": "1.4.0" | ||
"web3-core": "1.5.0-rc.0", | ||
"web3-core-helpers": "1.5.0-rc.0", | ||
"web3-core-method": "1.5.0-rc.0", | ||
"web3-core-promievent": "1.5.0-rc.0", | ||
"web3-core-subscriptions": "1.5.0-rc.0", | ||
"web3-eth-abi": "1.5.0-rc.0", | ||
"web3-utils": "1.5.0-rc.0" | ||
}, | ||
@@ -32,3 +31,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "511e72642599fd62542acff1b14a6bbb664003b2" | ||
"gitHead": "fb3af4b93edfcb5928c40f0ac490c463608cf033" | ||
} |
@@ -33,4 +33,2 @@ /* | ||
var _ = require('underscore'); | ||
var core = require('web3-core'); | ||
@@ -82,7 +80,7 @@ var Method = require('web3-core-method'); | ||
var lastArg = args[args.length - 1]; | ||
if(_.isObject(lastArg) && !_.isArray(lastArg)) { | ||
if(!!lastArg && typeof lastArg === 'object' && !Array.isArray(lastArg)) { | ||
options = lastArg; | ||
this.options = _.extend(this.options, this._getOrSetDefaultOptions(options)); | ||
if(_.isObject(address)) { | ||
this.options = { ...this.options, ...this._getOrSetDefaultOptions(options)}; | ||
if(!!address && typeof address === 'object') { | ||
address = null; | ||
@@ -332,3 +330,3 @@ } | ||
Contract.prototype._getCallback = function getCallback(args) { | ||
if (args && _.isFunction(args[args.length - 1])) { | ||
if (args && !!args[args.length- 1 ] && typeof args[args.length - 1] === 'function') { | ||
return args.pop(); // modify the args array! | ||
@@ -397,3 +395,3 @@ } | ||
// use given topics | ||
if(_.isArray(options.topics)) { | ||
if(Array.isArray(options.topics)) { | ||
result.topics = options.topics; | ||
@@ -424,3 +422,3 @@ | ||
if (_.isArray(value)) { | ||
if (Array.isArray(value)) { | ||
return value.map(function (v) { | ||
@@ -525,3 +523,3 @@ return abi.encodeParameter(i.type, v); | ||
}).map(function (json) { | ||
var inputLength = (_.isArray(json.inputs)) ? json.inputs.length : 0; | ||
var inputLength = (Array.isArray(json.inputs)) ? json.inputs.length : 0; | ||
@@ -535,3 +533,3 @@ if (inputLength !== args.length) { | ||
} | ||
return _.isArray(json.inputs) ? json.inputs : []; | ||
return Array.isArray(json.inputs) ? json.inputs : []; | ||
}).map(function (inputs) { | ||
@@ -616,3 +614,3 @@ return abi.encodeParameters(inputs, args).replace('0x',''); | ||
var constructor = _.find(this.options.jsonInterface, function (method) { | ||
var constructor = this.options.jsonInterface.find((method) => { | ||
return (method.type === 'constructor'); | ||
@@ -647,5 +645,5 @@ }) || {}; | ||
// get the options | ||
var options = (_.isObject(args[args.length - 1])) ? args.pop() : {}; | ||
var options = (!!args[args.length - 1] && typeof args[args.length - 1]) === 'object' ? args.pop() : {}; | ||
var eventName = (_.isString(args[0])) ? args[0] : 'allevents'; | ||
var eventName = (typeof args[0] === 'string') ? args[0] : 'allevents'; | ||
var event = (eventName.toLowerCase() === 'allevents') ? { | ||
@@ -710,3 +708,3 @@ name: 'ALLEVENTS', | ||
sub.unsubscribe(); | ||
if(_.isFunction(callback)){ | ||
if(typeof callback === 'function'){ | ||
callback(err, res, sub); | ||
@@ -758,3 +756,3 @@ } | ||
if (_.isFunction(this.callback)) { | ||
if (typeof this.callback === 'function') { | ||
this.callback(null, output, this); | ||
@@ -859,7 +857,7 @@ } | ||
// get block number to use for call | ||
if(processedArgs.type === 'call' && args[args.length - 1] !== true && (_.isString(args[args.length - 1]) || isFinite(args[args.length - 1]))) | ||
if(processedArgs.type === 'call' && args[args.length - 1] !== true && (typeof args[args.length - 1] === 'string' || isFinite(args[args.length - 1]))) | ||
processedArgs.defaultBlock = args.pop(); | ||
// get the options | ||
processedArgs.options = (_.isObject(args[args.length - 1])) ? args.pop() : {}; | ||
processedArgs.options = (!!args[args.length - 1] && typeof args[args.length - 1]) === 'object' ? args.pop() : {}; | ||
@@ -966,3 +964,3 @@ // get the generateRequest argument for batch requests | ||
if (_.isBoolean(this._method.payable) && !this._method.payable && args.options.value && args.options.value > 0) { | ||
if (typeof this._method.payable === 'boolean' && !this._method.payable && args.options.value && args.options.value > 0) { | ||
return utils._fireError(new Error('Can not send value to non-payable contract method or constructor'), defer.eventEmitter, defer.reject, args.callback); | ||
@@ -975,6 +973,6 @@ } | ||
receiptFormatter: function (receipt) { | ||
if (_.isArray(receipt.logs)) { | ||
if (Array.isArray(receipt.logs)) { | ||
// decode logs | ||
var events = _.map(receipt.logs, function(log) { | ||
var events = receipt.logs.map((log) => { | ||
return _this._parent._decodeEventABI.call({ | ||
@@ -981,0 +979,0 @@ name: 'ALLEVENTS', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80644
8
2011
2
+ Addedweb3-core@1.5.0-rc.0(transitive)
+ Addedweb3-core-helpers@1.5.0-rc.0(transitive)
+ Addedweb3-core-method@1.5.0-rc.0(transitive)
+ Addedweb3-core-promievent@1.5.0-rc.0(transitive)
+ Addedweb3-core-requestmanager@1.5.0-rc.0(transitive)
+ Addedweb3-core-subscriptions@1.5.0-rc.0(transitive)
+ Addedweb3-eth-abi@1.5.0-rc.0(transitive)
+ Addedweb3-eth-iban@1.5.0-rc.0(transitive)
+ Addedweb3-providers-http@1.5.0-rc.0(transitive)
+ Addedweb3-providers-ipc@1.5.0-rc.0(transitive)
+ Addedweb3-providers-ws@1.5.0-rc.0(transitive)
+ Addedweb3-utils@1.5.0-rc.0(transitive)
- Removedunderscore@1.12.1
- Removedunderscore@1.12.1(transitive)
- Removedweb3-core@1.4.0(transitive)
- Removedweb3-core-helpers@1.4.0(transitive)
- Removedweb3-core-method@1.4.0(transitive)
- Removedweb3-core-promievent@1.4.0(transitive)
- Removedweb3-core-requestmanager@1.4.0(transitive)
- Removedweb3-core-subscriptions@1.4.0(transitive)
- Removedweb3-eth-abi@1.4.0(transitive)
- Removedweb3-eth-iban@1.4.0(transitive)
- Removedweb3-providers-http@1.4.0(transitive)
- Removedweb3-providers-ipc@1.4.0(transitive)
- Removedweb3-providers-ws@1.4.0(transitive)
- Removedweb3-utils@1.4.0(transitive)
Updatedweb3-core@1.5.0-rc.0
Updatedweb3-core-helpers@1.5.0-rc.0
Updatedweb3-core-method@1.5.0-rc.0
Updatedweb3-eth-abi@1.5.0-rc.0
Updatedweb3-utils@1.5.0-rc.0