web3-core-helpers
Advanced tools
Comparing version 1.0.0-beta.29 to 1.0.0-beta.30
{ | ||
"name": "web3-core-helpers", | ||
"namespace": "ethereum", | ||
"version": "1.0.0-beta.29", | ||
"version": "1.0.0-beta.30", | ||
"description": "Web3 core tools helper for sub packages. This is an internal package.", | ||
@@ -11,5 +11,5 @@ "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-core-helpers", | ||
"underscore": "1.8.3", | ||
"web3-eth-iban": "1.0.0-beta.29", | ||
"web3-utils": "1.0.0-beta.29" | ||
"web3-eth-iban": "1.0.0-beta.30", | ||
"web3-utils": "1.0.0-beta.30" | ||
} | ||
} |
@@ -68,18 +68,25 @@ /* | ||
* | ||
* @method inputCallFormatter | ||
* @method _txInputFormatter | ||
* @param {Object} transaction options | ||
* @returns object | ||
*/ | ||
var inputCallFormatter = function (options){ | ||
*/ | ||
var _txInputFormatter = function (options){ | ||
var from = options.from || (this ? this.defaultAccount : null); | ||
if (options.to) { // it might be contract creation | ||
options.to = inputAddressFormatter(options.to); | ||
} | ||
if (from) { | ||
options.from = inputAddressFormatter(from); | ||
if (options.data && options.input) { | ||
throw new Error('You can\'t have "data" and "input" as properties of transactions at the same time, please use either "data" or "input" instead.'); | ||
} | ||
if (options.to) { // it might be contract creation | ||
options.to = inputAddressFormatter(options.to); | ||
if (!options.data && options.input) { | ||
options.data = options.input; | ||
delete options.input; | ||
} | ||
if(options.data && !utils.isHex(options.data)) { | ||
throw new Error('The data field must be HEX encoded data.'); | ||
} | ||
// allow both | ||
@@ -102,2 +109,23 @@ if (options.gas || options.gasLimit) { | ||
* | ||
* @method inputCallFormatter | ||
* @param {Object} transaction options | ||
* @returns object | ||
*/ | ||
var inputCallFormatter = function (options){ | ||
options = _txInputFormatter(options); | ||
var from = options.from || (this ? this.defaultAccount : null); | ||
if (from) { | ||
options.from = inputAddressFormatter(from); | ||
} | ||
return options; | ||
}; | ||
/** | ||
* Formats the input of a transaction and converts all values to HEX | ||
* | ||
* @method inputTransactionFormatter | ||
@@ -109,2 +137,4 @@ * @param {Object} options | ||
options = _txInputFormatter(options); | ||
// check from, only if not number, or object | ||
@@ -121,17 +151,2 @@ if (!_.isNumber(options.from) && !_.isObject(options.from)) { | ||
if (options.to) { // it might be contract creation | ||
options.to = inputAddressFormatter(options.to); | ||
} | ||
// allow both | ||
if (options.gas || options.gasLimit) { | ||
options.gas = options.gas || options.gasLimit; | ||
} | ||
['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) { | ||
return options[key] !== undefined; | ||
}).forEach(function(key){ | ||
options[key] = utils.numberToHex(options[key]); | ||
}); | ||
return options; | ||
@@ -138,0 +153,0 @@ }; |
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
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
16782
433
+ Addedweb3-eth-iban@1.0.0-beta.30(transitive)
+ Addedweb3-utils@1.0.0-beta.30(transitive)
- Removedweb3-eth-iban@1.0.0-beta.29(transitive)
- Removedweb3-utils@1.0.0-beta.29(transitive)
Updatedweb3-eth-iban@1.0.0-beta.30
Updatedweb3-utils@1.0.0-beta.30