fix contracts loading; add warning for whisper version; update web3.js

This commit is contained in:
Iuri Matias 2017-06-25 12:56:14 -04:00
parent 955aab35de
commit 84f7149aaf
4 changed files with 2898 additions and 2758 deletions

View File

@ -372,6 +372,8 @@ var EmbarkJS =
web3.version.getWhisper(function(err, res) {
if (err) {
console.log("whisper not available");
} else if (web3.version.whisper >= 5) {
console.log("this version of whisper is not supported yet; try a version of geth bellow 1.6.1");
} else {
self.currentMessages.identity = web3.shh.newIdentity();
}

View File

@ -325,6 +325,8 @@ EmbarkJS.Messages.setProvider = function(provider, options) {
web3.version.getWhisper(function(err, res) {
if (err) {
console.log("whisper not available");
} else if (web3.version.whisper >= 5) {
console.log("this version of whisper is not supported yet; try a version of geth bellow 1.6.1");
} else {
self.currentMessages.identity = web3.shh.newIdentity();
}

View File

@ -1842,7 +1842,7 @@ module.exports = function (value, options) {
};
},{"crypto-js":59,"crypto-js/sha3":80}],20:[function(require,module,exports){
},{"crypto-js":58,"crypto-js/sha3":79}],20:[function(require,module,exports){
/*
This file is part of web3.js.
@ -2104,7 +2104,7 @@ var toHex = function (val) {
if (isBigNumber(val))
return fromDecimal(val);
if (isObject(val))
if (typeof val === 'object')
return fromUtf8(JSON.stringify(val));
// if its a negative number, pass it through fromDecimal
@ -2258,8 +2258,6 @@ var isAddress = function (address) {
}
};
/**
* Checks if the given string is a checksummed address
*
@ -2370,7 +2368,7 @@ var isFunction = function (object) {
* @return {Boolean}
*/
var isObject = function (object) {
return typeof object === 'object';
return object !== null && !(object instanceof Array) && typeof object === 'object';
};
/**
@ -2410,6 +2408,38 @@ var isJson = function (str) {
}
};
/**
* Returns true if given string is a valid Ethereum block header bloom.
*
* @method isBloom
* @param {String} hex encoded bloom filter
* @return {Boolean}
*/
var isBloom = function (bloom) {
if (!/^(0x)?[0-9a-f]{512}$/i.test(bloom)) {
return false;
} else if (/^(0x)?[0-9a-f]{512}$/.test(bloom) || /^(0x)?[0-9A-F]{512}$/.test(bloom)) {
return true;
}
return false;
};
/**
* Returns true if given string is a valid log topic.
*
* @method isTopic
* @param {String} hex encoded topic
* @return {Boolean}
*/
var isTopic = function (topic) {
if (!/^(0x)?[0-9a-f]{64}$/i.test(topic)) {
return false;
} else if (/^(0x)?[0-9a-f]{64}$/.test(topic) || /^(0x)?[0-9A-F]{64}$/.test(topic)) {
return true;
}
return false;
};
module.exports = {
padLeft: padLeft,
padRight: padRight,
@ -2438,12 +2468,14 @@ module.exports = {
isObject: isObject,
isBoolean: isBoolean,
isArray: isArray,
isJson: isJson
isJson: isJson,
isBloom: isBloom,
isTopic: isTopic,
};
},{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":85}],21:[function(require,module,exports){
},{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":84}],21:[function(require,module,exports){
module.exports={
"version": "0.18.2"
"version": "0.19.0"
}
},{}],22:[function(require,module,exports){
@ -2549,6 +2581,8 @@ Web3.prototype.isAddress = utils.isAddress;
Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
Web3.prototype.isIBAN = utils.isIBAN;
Web3.prototype.padLeft = utils.padLeft;
Web3.prototype.padRight = utils.padRight;
Web3.prototype.sha3 = function(string, options) {
@ -2957,7 +2991,7 @@ var ContractFactory = function (eth, abi) {
if (options.value > 0) {
var constructorAbi = abi.filter(function (json) {
return json.type === 'constructor' && json.inputs.length === args.length;
})[0] || {};
})[0] || {};
if (!constructorAbi.payable) {
throw new Error('Cannot send value to non-payable constructor');
@ -3092,8 +3126,11 @@ module.exports = ContractFactory;
*/
module.exports = {
InvalidNumberOfParams: function () {
return new Error('Invalid number of input parameters');
InvalidNumberOfSolidityArgs: function () {
return new Error('Invalid number of arguments to Solidity function');
},
InvalidNumberOfRPCParams: function () {
return new Error('Invalid number of input parameters to RPC method');
},
InvalidConnection: function (host){
return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
@ -3523,7 +3560,9 @@ var Filter = function (requestManager, options, methods, formatter, callback, fi
self.callbacks.forEach(function(cb){
cb(error);
});
filterCreationErrorCallback(error);
if (typeof filterCreationErrorCallback === 'function') {
filterCreationErrorCallback(error);
}
} else {
self.filterId = id;
@ -3937,6 +3976,7 @@ module.exports = {
var coder = require('../solidity/coder');
var utils = require('../utils/utils');
var errors = require('./errors');
var formatters = require('./formatters');
var sha3 = require('../utils/sha3');
@ -3969,6 +4009,23 @@ SolidityFunction.prototype.extractDefaultBlock = function (args) {
}
};
/**
* Should be called to check if the number of arguments is correct
*
* @method validateArgs
* @param {Array} arguments
* @throws {Error} if it is not
*/
SolidityFunction.prototype.validateArgs = function (args) {
var inputArgs = args.filter(function (a) {
// filter the options object but not arguments that are arrays
return !(utils.isObject(a) === true && utils.isArray(a) === false);
});
if (inputArgs.length !== this._inputTypes.length) {
throw errors.InvalidNumberOfSolidityArgs();
}
};
/**
* Should be used to create payload from arguments
*
@ -3981,6 +4038,7 @@ SolidityFunction.prototype.toPayload = function (args) {
if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
options = args[args.length - 1];
}
this.validateArgs(args);
options.to = this._address;
options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
return options;
@ -4175,8 +4233,7 @@ SolidityFunction.prototype.attachToContract = function (contract) {
module.exports = SolidityFunction;
},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./formatters":30}],32:[function(require,module,exports){
},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./errors":26,"./formatters":30}],32:[function(require,module,exports){
/*
This file is part of web3.js.
@ -4331,7 +4388,7 @@ HttpProvider.prototype.isConnected = function() {
module.exports = HttpProvider;
},{"./errors":26,"xhr2":86,"xmlhttprequest":17}],33:[function(require,module,exports){
},{"./errors":26,"xhr2":85,"xmlhttprequest":17}],33:[function(require,module,exports){
/*
This file is part of web3.js.
@ -4928,7 +4985,7 @@ Method.prototype.extractCallback = function (args) {
*/
Method.prototype.validateArgs = function (args) {
if (args.length !== this.params) {
throw errors.InvalidNumberOfParams();
throw errors.InvalidNumberOfRPCParams();
}
};
@ -5022,7 +5079,6 @@ Method.prototype.request = function () {
module.exports = Method;
},{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
/*
This file is part of web3.js.
@ -5296,6 +5352,13 @@ var methods = function () {
inputFormatter: [formatters.inputTransactionFormatter]
});
var signTransaction = new Method({
name: 'signTransaction',
call: 'eth_signTransaction',
params: 1,
inputFormatter: [formatters.inputTransactionFormatter]
});
var sign = new Method({
name: 'sign',
call: 'eth_sign',
@ -5364,6 +5427,7 @@ var methods = function () {
call,
estimateGas,
sendRawTransaction,
signTransaction,
sendTransaction,
sign,
compileSolidity,
@ -5421,8 +5485,8 @@ Eth.prototype.contract = function (abi) {
return factory;
};
Eth.prototype.filter = function (fil, callback) {
return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback);
Eth.prototype.filter = function (fil, callback, filterCreationErrorCallback) {
return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
};
Eth.prototype.namereg = function () {
@ -5439,7 +5503,6 @@ Eth.prototype.isSyncing = function (callback) {
module.exports = Eth;
},{"../../utils/config":18,"../../utils/utils":20,"../contract":25,"../filter":29,"../formatters":30,"../iban":33,"../method":36,"../namereg":44,"../property":45,"../syncing":48,"../transfer":49,"./watches":43}],39:[function(require,module,exports){
/*
This file is part of web3.js.
@ -5548,6 +5611,25 @@ var methods = function () {
inputFormatter: [null]
});
var importRawKey = new Method({
name: 'importRawKey',
call: 'personal_importRawKey',
params: 2
});
var sign = new Method({
name: 'sign',
call: 'personal_sign',
params: 3,
inputFormatter: [null, formatters.inputAddressFormatter, null]
});
var ecRecover = new Method({
name: 'ecRecover',
call: 'personal_ecRecover',
params: 2
});
var unlockAccount = new Method({
name: 'unlockAccount',
call: 'personal_unlockAccount',
@ -5571,7 +5653,10 @@ var methods = function () {
return [
newAccount,
importRawKey,
unlockAccount,
ecRecover,
sign,
sendTransaction,
lockAccount
];
@ -6595,8 +6680,6 @@ module.exports = transfer;
},{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(require,module,exports){
},{}],51:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -6829,7 +6912,7 @@ module.exports = transfer;
return CryptoJS.AES;
}));
},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(require,module,exports){
},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],51:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -7705,7 +7788,7 @@ module.exports = transfer;
}));
},{"./core":53}],53:[function(require,module,exports){
},{"./core":52}],52:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -8466,7 +8549,7 @@ module.exports = transfer;
return CryptoJS;
}));
},{}],54:[function(require,module,exports){
},{}],53:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -8602,7 +8685,7 @@ module.exports = transfer;
return CryptoJS.enc.Base64;
}));
},{"./core":53}],55:[function(require,module,exports){
},{"./core":52}],54:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -8752,7 +8835,7 @@ module.exports = transfer;
return CryptoJS.enc.Utf16;
}));
},{"./core":53}],56:[function(require,module,exports){
},{"./core":52}],55:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -8885,7 +8968,7 @@ module.exports = transfer;
return CryptoJS.EvpKDF;
}));
},{"./core":53,"./hmac":58,"./sha1":77}],57:[function(require,module,exports){
},{"./core":52,"./hmac":57,"./sha1":76}],56:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -8952,7 +9035,7 @@ module.exports = transfer;
return CryptoJS.format.Hex;
}));
},{"./cipher-core":52,"./core":53}],58:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],57:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -9096,7 +9179,7 @@ module.exports = transfer;
}));
},{"./core":53}],59:[function(require,module,exports){
},{"./core":52}],58:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9115,7 +9198,7 @@ module.exports = transfer;
return CryptoJS;
}));
},{"./aes":51,"./cipher-core":52,"./core":53,"./enc-base64":54,"./enc-utf16":55,"./evpkdf":56,"./format-hex":57,"./hmac":58,"./lib-typedarrays":60,"./md5":61,"./mode-cfb":62,"./mode-ctr":64,"./mode-ctr-gladman":63,"./mode-ecb":65,"./mode-ofb":66,"./pad-ansix923":67,"./pad-iso10126":68,"./pad-iso97971":69,"./pad-nopadding":70,"./pad-zeropadding":71,"./pbkdf2":72,"./rabbit":74,"./rabbit-legacy":73,"./rc4":75,"./ripemd160":76,"./sha1":77,"./sha224":78,"./sha256":79,"./sha3":80,"./sha384":81,"./sha512":82,"./tripledes":83,"./x64-core":84}],60:[function(require,module,exports){
},{"./aes":50,"./cipher-core":51,"./core":52,"./enc-base64":53,"./enc-utf16":54,"./evpkdf":55,"./format-hex":56,"./hmac":57,"./lib-typedarrays":59,"./md5":60,"./mode-cfb":61,"./mode-ctr":63,"./mode-ctr-gladman":62,"./mode-ecb":64,"./mode-ofb":65,"./pad-ansix923":66,"./pad-iso10126":67,"./pad-iso97971":68,"./pad-nopadding":69,"./pad-zeropadding":70,"./pbkdf2":71,"./rabbit":73,"./rabbit-legacy":72,"./rc4":74,"./ripemd160":75,"./sha1":76,"./sha224":77,"./sha256":78,"./sha3":79,"./sha384":80,"./sha512":81,"./tripledes":82,"./x64-core":83}],59:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -9192,7 +9275,7 @@ module.exports = transfer;
return CryptoJS.lib.WordArray;
}));
},{"./core":53}],61:[function(require,module,exports){
},{"./core":52}],60:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -9461,7 +9544,7 @@ module.exports = transfer;
return CryptoJS.MD5;
}));
},{"./core":53}],62:[function(require,module,exports){
},{"./core":52}],61:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9540,7 +9623,7 @@ module.exports = transfer;
return CryptoJS.mode.CFB;
}));
},{"./cipher-core":52,"./core":53}],63:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],62:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9657,7 +9740,7 @@ module.exports = transfer;
return CryptoJS.mode.CTRGladman;
}));
},{"./cipher-core":52,"./core":53}],64:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],63:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9716,7 +9799,7 @@ module.exports = transfer;
return CryptoJS.mode.CTR;
}));
},{"./cipher-core":52,"./core":53}],65:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],64:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9757,7 +9840,7 @@ module.exports = transfer;
return CryptoJS.mode.ECB;
}));
},{"./cipher-core":52,"./core":53}],66:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],65:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9812,7 +9895,7 @@ module.exports = transfer;
return CryptoJS.mode.OFB;
}));
},{"./cipher-core":52,"./core":53}],67:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],66:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9862,7 +9945,7 @@ module.exports = transfer;
return CryptoJS.pad.Ansix923;
}));
},{"./cipher-core":52,"./core":53}],68:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],67:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9907,7 +9990,7 @@ module.exports = transfer;
return CryptoJS.pad.Iso10126;
}));
},{"./cipher-core":52,"./core":53}],69:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],68:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9948,7 +10031,7 @@ module.exports = transfer;
return CryptoJS.pad.Iso97971;
}));
},{"./cipher-core":52,"./core":53}],70:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],69:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -9979,7 +10062,7 @@ module.exports = transfer;
return CryptoJS.pad.NoPadding;
}));
},{"./cipher-core":52,"./core":53}],71:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],70:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -10025,7 +10108,7 @@ module.exports = transfer;
return CryptoJS.pad.ZeroPadding;
}));
},{"./cipher-core":52,"./core":53}],72:[function(require,module,exports){
},{"./cipher-core":51,"./core":52}],71:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -10171,7 +10254,7 @@ module.exports = transfer;
return CryptoJS.PBKDF2;
}));
},{"./core":53,"./hmac":58,"./sha1":77}],73:[function(require,module,exports){
},{"./core":52,"./hmac":57,"./sha1":76}],72:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -10362,7 +10445,7 @@ module.exports = transfer;
return CryptoJS.RabbitLegacy;
}));
},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(require,module,exports){
},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],73:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -10555,7 +10638,7 @@ module.exports = transfer;
return CryptoJS.Rabbit;
}));
},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(require,module,exports){
},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],74:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -10695,7 +10778,7 @@ module.exports = transfer;
return CryptoJS.RC4;
}));
},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(require,module,exports){
},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],75:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -10963,7 +11046,7 @@ module.exports = transfer;
return CryptoJS.RIPEMD160;
}));
},{"./core":53}],77:[function(require,module,exports){
},{"./core":52}],76:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -11114,7 +11197,7 @@ module.exports = transfer;
return CryptoJS.SHA1;
}));
},{"./core":53}],78:[function(require,module,exports){
},{"./core":52}],77:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -11195,7 +11278,7 @@ module.exports = transfer;
return CryptoJS.SHA224;
}));
},{"./core":53,"./sha256":79}],79:[function(require,module,exports){
},{"./core":52,"./sha256":78}],78:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -11395,7 +11478,7 @@ module.exports = transfer;
return CryptoJS.SHA256;
}));
},{"./core":53}],80:[function(require,module,exports){
},{"./core":52}],79:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -11719,7 +11802,7 @@ module.exports = transfer;
return CryptoJS.SHA3;
}));
},{"./core":53,"./x64-core":84}],81:[function(require,module,exports){
},{"./core":52,"./x64-core":83}],80:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -11803,7 +11886,7 @@ module.exports = transfer;
return CryptoJS.SHA384;
}));
},{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(require,module,exports){
},{"./core":52,"./sha512":81,"./x64-core":83}],81:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -12127,7 +12210,7 @@ module.exports = transfer;
return CryptoJS.SHA512;
}));
},{"./core":53,"./x64-core":84}],83:[function(require,module,exports){
},{"./core":52,"./x64-core":83}],82:[function(require,module,exports){
;(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
@ -12898,7 +12981,7 @@ module.exports = transfer;
return CryptoJS.TripleDES;
}));
},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(require,module,exports){
},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],83:[function(require,module,exports){
;(function (root, factory) {
if (typeof exports === "object") {
// CommonJS
@ -13203,7 +13286,7 @@ module.exports = transfer;
return CryptoJS;
}));
},{"./core":53}],85:[function(require,module,exports){
},{"./core":52}],84:[function(require,module,exports){
/*! https://mths.be/utf8js v2.1.2 by @mathias */
;(function(root) {
@ -13449,25 +13532,25 @@ module.exports = transfer;
}(this));
},{}],86:[function(require,module,exports){
},{}],85:[function(require,module,exports){
module.exports = XMLHttpRequest;
},{}],"bignumber.js":[function(require,module,exports){
/*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
/*! bignumber.js v4.0.2 https://github.com/MikeMcl/bignumber.js/LICENCE */
;(function (global) {
;(function (globalObj) {
'use strict';
/*
bignumber.js v2.0.7
bignumber.js v4.0.2
A JavaScript library for arbitrary-precision arithmetic.
https://github.com/MikeMcl/bignumber.js
Copyright (c) 2015 Michael Mclaughlin <M8ch88l@gmail.com>
Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>
MIT Expat Licence
*/
var BigNumber, crypto, parseNumeric,
var BigNumber,
isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
mathceil = Math.ceil,
mathfloor = Math.floor,
@ -13493,8 +13576,8 @@ module.exports = XMLHttpRequest;
/*
* Create and return a BigNumber constructor.
*/
function another(configObj) {
var div,
function constructorFactory(config) {
var div, parseNumeric,
// id tracks the caller function, so its name can be included in error messages.
id = 0,
@ -13580,7 +13663,7 @@ module.exports = XMLHttpRequest;
// The maximum number of significant digits of the result of the toPower operation.
// If POW_PRECISION is 0, there will be unlimited significant digits.
POW_PRECISION = 100, // 0 to MAX
POW_PRECISION = 0, // 0 to MAX
// The format specification used by the BigNumber.prototype.toFormat method.
FORMAT = {
@ -13713,7 +13796,9 @@ module.exports = XMLHttpRequest;
// Disallow numbers with over 15 significant digits if number type.
// 'new BigNumber() number type has more than 15 significant digits: {n}'
if ( num && ERRORS && len > 15 ) raise( id, tooManyDigits, x.s * n );
if ( num && ERRORS && len > 15 && ( n > MAX_SAFE_INTEGER || n !== mathfloor(n) ) ) {
raise( id, tooManyDigits, x.s * n );
}
e = e - i - 1;
@ -13768,7 +13853,7 @@ module.exports = XMLHttpRequest;
// CONSTRUCTOR PROPERTIES
BigNumber.another = another;
BigNumber.another = constructorFactory;
BigNumber.ROUND_UP = 0;
BigNumber.ROUND_DOWN = 1;
@ -13815,7 +13900,7 @@ module.exports = XMLHttpRequest;
* Ignore properties/parameters set to null or undefined.
* Return an object with the properties current values.
*/
BigNumber.config = function () {
BigNumber.config = BigNumber.set = function () {
var v, p,
i = 0,
r = {},
@ -13895,9 +13980,19 @@ module.exports = XMLHttpRequest;
// 'config() crypto unavailable: {crypto}'
if ( has( p = 'CRYPTO' ) ) {
if ( v === !!v || v === 1 || v === 0 ) {
CRYPTO = !!( v && crypto && typeof crypto == 'object' );
if ( v && !CRYPTO && ERRORS ) raise( 2, 'crypto unavailable', crypto );
if ( v === true || v === false || v === 1 || v === 0 ) {
if (v) {
v = typeof crypto == 'undefined';
if ( !v && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
CRYPTO = true;
} else if (ERRORS) {
raise( 2, 'crypto unavailable', v ? void 0 : crypto );
} else {
CRYPTO = false;
}
} else {
CRYPTO = false;
}
} else if (ERRORS) {
raise( 2, p + notBool, v );
}
@ -13987,7 +14082,7 @@ module.exports = XMLHttpRequest;
if (CRYPTO) {
// Browsers supporting crypto.getRandomValues.
if ( crypto && crypto.getRandomValues ) {
if (crypto.getRandomValues) {
a = crypto.getRandomValues( new Uint32Array( k *= 2 ) );
@ -14020,7 +14115,7 @@ module.exports = XMLHttpRequest;
i = k / 2;
// Node.js supporting crypto.randomBytes.
} else if ( crypto && crypto.randomBytes ) {
} else if (crypto.randomBytes) {
// buffer
a = crypto.randomBytes( k *= 7 );
@ -14045,13 +14140,14 @@ module.exports = XMLHttpRequest;
}
}
i = k / 7;
} else if (ERRORS) {
raise( 14, 'crypto unavailable', crypto );
} else {
CRYPTO = false;
if (ERRORS) raise( 14, 'crypto unavailable', crypto );
}
}
// Use Math.random: CRYPTO is false or crypto is unavailable and ERRORS is false.
if (!i) {
// Use Math.random.
if (!CRYPTO) {
for ( ; i < k; ) {
v = random53bitInt();
@ -14077,7 +14173,7 @@ module.exports = XMLHttpRequest;
} else {
// Remove leading elements which are zero and adjust exponent accordingly.
for ( e = -1 ; c[0] === 0; c.shift(), e -= LOG_BASE);
for ( e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
// Count the digits of the first element of c to determine leading zeros, and...
for ( i = 1, v = c[0]; v >= 10; v /= 10, i++);
@ -14170,7 +14266,7 @@ module.exports = XMLHttpRequest;
if ( !d ) {
++e;
xc.unshift(1);
xc = [1].concat(xc);
}
}
}
@ -14208,7 +14304,7 @@ module.exports = XMLHttpRequest;
x[i] = temp % base;
}
if (carry) x.unshift(carry);
if (carry) x = [carry].concat(x);
return x;
}
@ -14242,7 +14338,7 @@ module.exports = XMLHttpRequest;
}
// Remove leading zeros.
for ( ; !a[0] && a.length > 1; a.shift() );
for ( ; !a[0] && a.length > 1; a.splice(0, 1) );
}
// x: dividend, y: divisor.
@ -14311,7 +14407,7 @@ module.exports = XMLHttpRequest;
// Add zeros to make remainder as long as divisor.
for ( ; remL < yL; rem[remL++] = 0 );
yz = yc.slice();
yz.unshift(0);
yz = [0].concat(yz);
yc0 = yc[0];
if ( yc[1] >= base / 2 ) yc0++;
// Not necessary, but to prevent trial digit n > base, when using base 3.
@ -14382,7 +14478,7 @@ module.exports = XMLHttpRequest;
prodL = prod.length;
}
if ( prodL < remL ) prod.unshift(0);
if ( prodL < remL ) prod = [0].concat(prod);
// Subtract product from remainder.
subtract( rem, prod, remL, base );
@ -14423,7 +14519,7 @@ module.exports = XMLHttpRequest;
more = rem[0] != null;
// Leading zero?
if ( !qc[0] ) qc.shift();
if ( !qc[0] ) qc.splice(0, 1);
}
if ( base == BASE ) {
@ -14583,11 +14679,11 @@ module.exports = XMLHttpRequest;
// Handle values that fail the validity test in BigNumber.
parseNumeric = (function () {
var basePrefix = /^(-?)0([xbo])/i,
var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
dotAfter = /^([^.]+)\.$/,
dotBefore = /^\.([^.]+)$/,
isInfinityOrNaN = /^-?(Infinity|NaN)$/,
whitespaceOrPlus = /^\s*\+|^\s+|\s+$/g;
whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
return function ( x, str, num, b ) {
var base,
@ -14755,7 +14851,7 @@ module.exports = XMLHttpRequest;
sd -= x.e + 1;
// 1, 0.1, 0.01, 0.001, 0.0001 etc.
xc[0] = pows10[ sd % LOG_BASE ];
xc[0] = pows10[ ( LOG_BASE - sd % LOG_BASE ) % LOG_BASE ];
x.e = -sd || 0;
} else {
@ -15133,7 +15229,7 @@ module.exports = XMLHttpRequest;
}
// Remove leading zeros and adjust exponent accordingly.
for ( ; xc[0] == 0; xc.shift(), --ye );
for ( ; xc[0] == 0; xc.splice(0, 1), --ye );
// Zero?
if ( !xc[0] ) {
@ -15297,11 +15393,11 @@ module.exports = XMLHttpRequest;
// Only start adding at yc.length - 1 as the further digits of xc can be ignored.
for ( a = 0; b; ) {
a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
xc[b] %= BASE;
xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
}
if (a) {
xc.unshift(a);
xc = [a].concat(xc);
++ye;
}
@ -15590,7 +15686,7 @@ module.exports = XMLHttpRequest;
if (c) {
++e;
} else {
zc.shift();
zc.splice(0, 1);
}
return normalise( y, zc, e );
@ -15808,59 +15904,91 @@ module.exports = XMLHttpRequest;
* Return the value of this BigNumber converted to a number primitive.
*/
P.toNumber = function () {
var x = this;
// Ensure zero has correct sign.
return +x || ( x.s ? x.s * 0 : NaN );
return +this;
};
/*
* Return a BigNumber whose value is the value of this BigNumber raised to the power n.
* If m is present, return the result modulo m.
* If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
* If POW_PRECISION is not 0, round to POW_PRECISION using ROUNDING_MODE.
* If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using
* ROUNDING_MODE.
*
* n {number} Integer, -9007199254740992 to 9007199254740992 inclusive.
* (Performs 54 loop iterations for n of 9007199254740992.)
* The modular power operation works efficiently when x, n, and m are positive integers,
* otherwise it is equivalent to calculating x.toPower(n).modulo(m) (with POW_PRECISION 0).
*
* n {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
* [m] {number|string|BigNumber} The modulus.
*
* 'pow() exponent not an integer: {n}'
* 'pow() exponent out of range: {n}'
*
* Performs 54 loop iterations for n of 9007199254740991.
*/
P.toPower = P.pow = function (n) {
var k, y,
P.toPower = P.pow = function ( n, m ) {
var k, y, z,
i = mathfloor( n < 0 ? -n : +n ),
x = this;
if ( m != null ) {
id = 23;
m = new BigNumber(m);
}
// Pass ±Infinity to Math.pow if exponent is out of range.
if ( !isValidInt( n, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 23, 'exponent' ) &&
( !isFinite(n) || i > MAX_SAFE_INTEGER && ( n /= 0 ) ||
parseFloat(n) != n && !( n = NaN ) ) ) {
return new BigNumber( Math.pow( +x, n ) );
parseFloat(n) != n && !( n = NaN ) ) || n == 0 ) {
k = Math.pow( +x, n );
return new BigNumber( m ? k % m : k );
}
if (m) {
if ( n > 1 && x.gt(ONE) && x.isInt() && m.gt(ONE) && m.isInt() ) {
x = x.mod(m);
} else {
z = m;
// Nullify m so only a single mod operation is performed at the end.
m = null;
}
} else if (POW_PRECISION) {
// Truncating each coefficient array to a length of k after each multiplication
// equates to truncating significant digits to POW_PRECISION + [28, 41],
// i.e. there will be a minimum of 28 guard digits retained.
// (Using + 1.5 would give [9, 21] guard digits.)
k = mathceil( POW_PRECISION / LOG_BASE + 2 );
}
// Truncating each coefficient array to a length of k after each multiplication equates
// to truncating significant digits to POW_PRECISION + [28, 41], i.e. there will be a
// minimum of 28 guard digits retained. (Using + 1.5 would give [9, 21] guard digits.)
k = POW_PRECISION ? mathceil( POW_PRECISION / LOG_BASE + 2 ) : 0;
y = new BigNumber(ONE);
for ( ; ; ) {
if ( i % 2 ) {
y = y.times(x);
if ( !y.c ) break;
if ( k && y.c.length > k ) y.c.length = k;
if (k) {
if ( y.c.length > k ) y.c.length = k;
} else if (m) {
y = y.mod(m);
}
}
i = mathfloor( i / 2 );
if ( !i ) break;
x = x.times(x);
if ( k && x.c && x.c.length > k ) x.c.length = k;
if (k) {
if ( x.c && x.c.length > k ) x.c.length = k;
} else if (m) {
x = x.mod(m);
}
}
if (m) return y;
if ( n < 0 ) y = ONE.div(y);
return k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
return z ? y.mod(z) : k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
};
@ -15938,26 +16066,30 @@ module.exports = XMLHttpRequest;
};
/*
* Return as toString, but do not accept a base argument.
* Return as toString, but do not accept a base argument, and include the minus sign for
* negative zero.
*/
P.valueOf = P.toJSON = function () {
return this.toString();
var str,
n = this,
e = n.e;
if ( e === null ) return n.toString();
str = coeffToString( n.c );
str = e <= TO_EXP_NEG || e >= TO_EXP_POS
? toExponential( str, e )
: toFixedPoint( str, e );
return n.s < 0 ? '-' + str : str;
};
// Aliases for BigDecimal methods.
//P.add = P.plus; // P.add included above
//P.subtract = P.minus; // P.sub included above
//P.multiply = P.times; // P.mul included above
//P.divide = P.div;
//P.remainder = P.mod;
//P.compareTo = P.cmp;
//P.negate = P.neg;
P.isBigNumber = true;
if ( configObj != null ) BigNumber.config(configObj);
if ( config != null ) BigNumber.config(config);
return BigNumber;
}
@ -16120,24 +16252,26 @@ module.exports = XMLHttpRequest;
// EXPORT
BigNumber = another();
BigNumber = constructorFactory();
BigNumber['default'] = BigNumber.BigNumber = BigNumber;
// AMD.
if ( typeof define == 'function' && define.amd ) {
define( function () { return BigNumber; } );
// Node and other environments that support module.exports.
// Node.js and other environments that support module.exports.
} else if ( typeof module != 'undefined' && module.exports ) {
module.exports = BigNumber;
if ( !crypto ) try { crypto = require('crypto'); } catch (e) {}
// Browser.
} else {
global.BigNumber = BigNumber;
if ( !globalObj ) globalObj = typeof self != 'undefined' ? self : Function('return this')();
globalObj.BigNumber = BigNumber;
}
})(this);
},{"crypto":50}],"web3":[function(require,module,exports){
},{}],"web3":[function(require,module,exports){
var Web3 = require('./lib/web3');
// dont override global variable

View File

@ -19,8 +19,8 @@ class ABIGenerator {
}
result += "\nvar whenEnvIsLoaded = function(cb) {";
result += "\n if (typeof window !== 'undefined' && window !== null) {";
result += "\n window.addEventListener('load', cb);";
result += "\n if (typeof document !== 'undefined' && document !== null) {";
result += "\n document.addEventListener('DOMContentLoaded', cb);";
result += "\n } else {";
result += "\n cb();";
result += "\n }";
@ -73,11 +73,13 @@ class ABIGenerator {
let gasEstimates = JSON.stringify(contract.gasEstimates);
// TODO: refactor this
result += "\nvar whenEnvIsLoaded = function(cb) {";
result += "\n if (typeof window !== 'undefined' && window !== null) {";
result += "\n window.addEventListener('load', cb);";
result += "\n } else {";
result += "\n cb();";
result += "\nif (whenEnvIsLoaded === undefined) {";
result += "\n var whenEnvIsLoaded = function(cb) {";
result += "\n if (typeof document !== 'undefined' && document !== null) {";
result += "\n document.addEventListener('DOMContentLoaded', cb);";
result += "\n } else {";
result += "\n cb();";
result += "\n }";
result += "\n }";
result += "\n}";