You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
5586 lines
410 KiB
5586 lines
410 KiB
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file coder.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var BigNumber = require('bignumber.js');
|
|
var utils = require('../utils/utils');
|
|
var f = require('./formatters');
|
|
var SolidityParam = require('./param');
|
|
|
|
/**
|
|
* Should be used to check if a type is an array type
|
|
*
|
|
* @method isArrayType
|
|
* @param {String} type
|
|
* @return {Bool} true is the type is an array, otherwise false
|
|
*/
|
|
var isArrayType = function (type) {
|
|
return type.slice(-2) === '[]';
|
|
};
|
|
|
|
/**
|
|
* SolidityType prototype is used to encode/decode solidity params of certain type
|
|
*/
|
|
var SolidityType = function (config) {
|
|
this._name = config.name;
|
|
this._match = config.match;
|
|
this._mode = config.mode;
|
|
this._inputFormatter = config.inputFormatter;
|
|
this._outputFormatter = config.outputFormatter;
|
|
};
|
|
|
|
/**
|
|
* Should be used to determine if this SolidityType do match given type
|
|
*
|
|
* @method isType
|
|
* @param {String} name
|
|
* @return {Bool} true if type match this SolidityType, otherwise false
|
|
*/
|
|
SolidityType.prototype.isType = function (name) {
|
|
if (this._match === 'strict') {
|
|
return this._name === name || (name.indexOf(this._name) === 0 && name.slice(this._name.length) === '[]');
|
|
} else if (this._match === 'prefix') {
|
|
// TODO better type detection!
|
|
return name.indexOf(this._name) === 0;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Should be used to transform plain param to SolidityParam object
|
|
*
|
|
* @method formatInput
|
|
* @param {Object} param - plain object, or an array of objects
|
|
* @param {Bool} arrayType - true if a param should be encoded as an array
|
|
* @return {SolidityParam} encoded param wrapped in SolidityParam object
|
|
*/
|
|
SolidityType.prototype.formatInput = function (param, arrayType) {
|
|
if (utils.isArray(param) && arrayType) { // TODO: should fail if this two are not the same
|
|
var self = this;
|
|
return param.map(function (p) {
|
|
return self._inputFormatter(p);
|
|
}).reduce(function (acc, current) {
|
|
return acc.combine(current);
|
|
}, f.formatInputInt(param.length)).withOffset(32);
|
|
}
|
|
return this._inputFormatter(param);
|
|
};
|
|
|
|
/**
|
|
* Should be used to transoform SolidityParam to plain param
|
|
*
|
|
* @method formatOutput
|
|
* @param {SolidityParam} byteArray
|
|
* @param {Bool} arrayType - true if a param should be decoded as an array
|
|
* @return {Object} plain decoded param
|
|
*/
|
|
SolidityType.prototype.formatOutput = function (param, arrayType) {
|
|
if (arrayType) {
|
|
// let's assume, that we solidity will never return long arrays :P
|
|
var result = [];
|
|
var length = new BigNumber(param.dynamicPart().slice(0, 64), 16);
|
|
for (var i = 0; i < length * 64; i += 64) {
|
|
result.push(this._outputFormatter(new SolidityParam(param.dynamicPart().substr(i + 64, 64))));
|
|
}
|
|
return result;
|
|
}
|
|
return this._outputFormatter(param);
|
|
};
|
|
|
|
/**
|
|
* Should be used to slice single param from bytes
|
|
*
|
|
* @method sliceParam
|
|
* @param {String} bytes
|
|
* @param {Number} index of param to slice
|
|
* @param {String} type
|
|
* @returns {SolidityParam} param
|
|
*/
|
|
SolidityType.prototype.sliceParam = function (bytes, index, type) {
|
|
if (this._mode === 'bytes') {
|
|
return SolidityParam.decodeBytes(bytes, index);
|
|
} else if (isArrayType(type)) {
|
|
return SolidityParam.decodeArray(bytes, index);
|
|
}
|
|
return SolidityParam.decodeParam(bytes, index);
|
|
};
|
|
|
|
/**
|
|
* SolidityCoder prototype should be used to encode/decode solidity params of any type
|
|
*/
|
|
var SolidityCoder = function (types) {
|
|
this._types = types;
|
|
};
|
|
|
|
/**
|
|
* This method should be used to transform type to SolidityType
|
|
*
|
|
* @method _requireType
|
|
* @param {String} type
|
|
* @returns {SolidityType}
|
|
* @throws {Error} throws if no matching type is found
|
|
*/
|
|
SolidityCoder.prototype._requireType = function (type) {
|
|
var solidityType = this._types.filter(function (t) {
|
|
return t.isType(type);
|
|
})[0];
|
|
|
|
if (!solidityType) {
|
|
throw Error('invalid solidity type!: ' + type);
|
|
}
|
|
|
|
return solidityType;
|
|
};
|
|
|
|
/**
|
|
* Should be used to transform plain param of given type to SolidityParam
|
|
*
|
|
* @method _formatInput
|
|
* @param {String} type of param
|
|
* @param {Object} plain param
|
|
* @return {SolidityParam}
|
|
*/
|
|
SolidityCoder.prototype._formatInput = function (type, param) {
|
|
return this._requireType(type).formatInput(param, isArrayType(type));
|
|
};
|
|
|
|
/**
|
|
* Should be used to encode plain param
|
|
*
|
|
* @method encodeParam
|
|
* @param {String} type
|
|
* @param {Object} plain param
|
|
* @return {String} encoded plain param
|
|
*/
|
|
SolidityCoder.prototype.encodeParam = function (type, param) {
|
|
return this._formatInput(type, param).encode();
|
|
};
|
|
|
|
/**
|
|
* Should be used to encode list of params
|
|
*
|
|
* @method encodeParams
|
|
* @param {Array} types
|
|
* @param {Array} params
|
|
* @return {String} encoded list of params
|
|
*/
|
|
SolidityCoder.prototype.encodeParams = function (types, params) {
|
|
var self = this;
|
|
var solidityParams = types.map(function (type, index) {
|
|
return self._formatInput(type, params[index]);
|
|
});
|
|
|
|
return SolidityParam.encodeList(solidityParams);
|
|
};
|
|
|
|
/**
|
|
* Should be used to decode bytes to plain param
|
|
*
|
|
* @method decodeParam
|
|
* @param {String} type
|
|
* @param {String} bytes
|
|
* @return {Object} plain param
|
|
*/
|
|
SolidityCoder.prototype.decodeParam = function (type, bytes) {
|
|
return this.decodeParams([type], bytes)[0];
|
|
};
|
|
|
|
/**
|
|
* Should be used to decode list of params
|
|
*
|
|
* @method decodeParam
|
|
* @param {Array} types
|
|
* @param {String} bytes
|
|
* @return {Array} array of plain params
|
|
*/
|
|
SolidityCoder.prototype.decodeParams = function (types, bytes) {
|
|
var self = this;
|
|
return types.map(function (type, index) {
|
|
var solidityType = self._requireType(type);
|
|
var p = solidityType.sliceParam(bytes, index, type);
|
|
return solidityType.formatOutput(p, isArrayType(type));
|
|
});
|
|
};
|
|
|
|
var coder = new SolidityCoder([
|
|
new SolidityType({
|
|
name: 'address',
|
|
match: 'strict',
|
|
mode: 'value',
|
|
inputFormatter: f.formatInputInt,
|
|
outputFormatter: f.formatOutputAddress
|
|
}),
|
|
new SolidityType({
|
|
name: 'bool',
|
|
match: 'strict',
|
|
mode: 'value',
|
|
inputFormatter: f.formatInputBool,
|
|
outputFormatter: f.formatOutputBool
|
|
}),
|
|
new SolidityType({
|
|
name: 'int',
|
|
match: 'prefix',
|
|
mode: 'value',
|
|
inputFormatter: f.formatInputInt,
|
|
outputFormatter: f.formatOutputInt,
|
|
}),
|
|
new SolidityType({
|
|
name: 'uint',
|
|
match: 'prefix',
|
|
mode: 'value',
|
|
inputFormatter: f.formatInputInt,
|
|
outputFormatter: f.formatOutputUInt
|
|
}),
|
|
new SolidityType({
|
|
name: 'bytes',
|
|
match: 'strict',
|
|
mode: 'bytes',
|
|
inputFormatter: f.formatInputDynamicBytes,
|
|
outputFormatter: f.formatOutputDynamicBytes
|
|
}),
|
|
new SolidityType({
|
|
name: 'bytes',
|
|
match: 'prefix',
|
|
mode: 'value',
|
|
inputFormatter: f.formatInputBytes,
|
|
outputFormatter: f.formatOutputBytes
|
|
}),
|
|
new SolidityType({
|
|
name: 'real',
|
|
match: 'prefix',
|
|
mode: 'value',
|
|
inputFormatter: f.formatInputReal,
|
|
outputFormatter: f.formatOutputReal
|
|
}),
|
|
new SolidityType({
|
|
name: 'ureal',
|
|
match: 'prefix',
|
|
mode: 'value',
|
|
inputFormatter: f.formatInputReal,
|
|
outputFormatter: f.formatOutputUReal
|
|
})
|
|
]);
|
|
|
|
module.exports = coder;
|
|
|
|
|
|
},{"../utils/utils":7,"./formatters":2,"./param":3,"bignumber.js":"bignumber.js"}],2:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file formatters.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var BigNumber = require('bignumber.js');
|
|
var utils = require('../utils/utils');
|
|
var c = require('../utils/config');
|
|
var SolidityParam = require('./param');
|
|
|
|
|
|
/**
|
|
* Formats input value to byte representation of int
|
|
* If value is negative, return it's two's complement
|
|
* If the value is floating point, round it down
|
|
*
|
|
* @method formatInputInt
|
|
* @param {String|Number|BigNumber} value that needs to be formatted
|
|
* @returns {SolidityParam}
|
|
*/
|
|
var formatInputInt = function (value) {
|
|
var padding = c.ETH_PADDING * 2;
|
|
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
|
|
var result = utils.padLeft(utils.toTwosComplement(value).round().toString(16), padding);
|
|
return new SolidityParam(result);
|
|
};
|
|
|
|
/**
|
|
* Formats input value to byte representation of string
|
|
*
|
|
* @method formatInputBytes
|
|
* @param {String}
|
|
* @returns {SolidityParam}
|
|
*/
|
|
var formatInputBytes = function (value) {
|
|
var result = utils.fromAscii(value, c.ETH_PADDING).substr(2);
|
|
return new SolidityParam(result);
|
|
};
|
|
|
|
/**
|
|
* Formats input value to byte representation of string
|
|
*
|
|
* @method formatInputDynamicBytes
|
|
* @param {String}
|
|
* @returns {SolidityParam}
|
|
*/
|
|
var formatInputDynamicBytes = function (value) {
|
|
var result = utils.fromAscii(value, c.ETH_PADDING).substr(2);
|
|
return new SolidityParam(formatInputInt(value.length).value + result, 32);
|
|
};
|
|
|
|
/**
|
|
* Formats input value to byte representation of bool
|
|
*
|
|
* @method formatInputBool
|
|
* @param {Boolean}
|
|
* @returns {SolidityParam}
|
|
*/
|
|
var formatInputBool = function (value) {
|
|
var result = '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');
|
|
return new SolidityParam(result);
|
|
};
|
|
|
|
/**
|
|
* Formats input value to byte representation of real
|
|
* Values are multiplied by 2^m and encoded as integers
|
|
*
|
|
* @method formatInputReal
|
|
* @param {String|Number|BigNumber}
|
|
* @returns {SolidityParam}
|
|
*/
|
|
var formatInputReal = function (value) {
|
|
return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
|
|
};
|
|
|
|
/**
|
|
* Check if input value is negative
|
|
*
|
|
* @method signedIsNegative
|
|
* @param {String} value is hex format
|
|
* @returns {Boolean} true if it is negative, otherwise false
|
|
*/
|
|
var signedIsNegative = function (value) {
|
|
return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
|
|
};
|
|
|
|
/**
|
|
* Formats right-aligned output bytes to int
|
|
*
|
|
* @method formatOutputInt
|
|
* @param {SolidityParam} param
|
|
* @returns {BigNumber} right-aligned output bytes formatted to big number
|
|
*/
|
|
var formatOutputInt = function (param) {
|
|
var value = param.staticPart() || "0";
|
|
|
|
// check if it's negative number
|
|
// it it is, return two's complement
|
|
if (signedIsNegative(value)) {
|
|
return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
|
|
}
|
|
return new BigNumber(value, 16);
|
|
};
|
|
|
|
/**
|
|
* Formats right-aligned output bytes to uint
|
|
*
|
|
* @method formatOutputUInt
|
|
* @param {SolidityParam}
|
|
* @returns {BigNumeber} right-aligned output bytes formatted to uint
|
|
*/
|
|
var formatOutputUInt = function (param) {
|
|
var value = param.staticPart() || "0";
|
|
return new BigNumber(value, 16);
|
|
};
|
|
|
|
/**
|
|
* Formats right-aligned output bytes to real
|
|
*
|
|
* @method formatOutputReal
|
|
* @param {SolidityParam}
|
|
* @returns {BigNumber} input bytes formatted to real
|
|
*/
|
|
var formatOutputReal = function (param) {
|
|
return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
|
|
};
|
|
|
|
/**
|
|
* Formats right-aligned output bytes to ureal
|
|
*
|
|
* @method formatOutputUReal
|
|
* @param {SolidityParam}
|
|
* @returns {BigNumber} input bytes formatted to ureal
|
|
*/
|
|
var formatOutputUReal = function (param) {
|
|
return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
|
|
};
|
|
|
|
/**
|
|
* Should be used to format output bool
|
|
*
|
|
* @method formatOutputBool
|
|
* @param {SolidityParam}
|
|
* @returns {Boolean} right-aligned input bytes formatted to bool
|
|
*/
|
|
var formatOutputBool = function (param) {
|
|
return param.staticPart() === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
|
|
};
|
|
|
|
/**
|
|
* Should be used to format output string
|
|
*
|
|
* @method formatOutputBytes
|
|
* @param {SolidityParam} left-aligned hex representation of string
|
|
* @returns {String} ascii string
|
|
*/
|
|
var formatOutputBytes = function (param) {
|
|
// length might also be important!
|
|
return utils.toAscii(param.staticPart());
|
|
};
|
|
|
|
/**
|
|
* Should be used to format output string
|
|
*
|
|
* @method formatOutputDynamicBytes
|
|
* @param {SolidityParam} left-aligned hex representation of string
|
|
* @returns {String} ascii string
|
|
*/
|
|
var formatOutputDynamicBytes = function (param) {
|
|
// length might also be important!
|
|
return utils.toAscii(param.dynamicPart().slice(64));
|
|
};
|
|
|
|
/**
|
|
* Should be used to format output address
|
|
*
|
|
* @method formatOutputAddress
|
|
* @param {SolidityParam} right-aligned input bytes
|
|
* @returns {String} address
|
|
*/
|
|
var formatOutputAddress = function (param) {
|
|
var value = param.staticPart();
|
|
return "0x" + value.slice(value.length - 40, value.length);
|
|
};
|
|
|
|
module.exports = {
|
|
formatInputInt: formatInputInt,
|
|
formatInputBytes: formatInputBytes,
|
|
formatInputDynamicBytes: formatInputDynamicBytes,
|
|
formatInputBool: formatInputBool,
|
|
formatInputReal: formatInputReal,
|
|
formatOutputInt: formatOutputInt,
|
|
formatOutputUInt: formatOutputUInt,
|
|
formatOutputReal: formatOutputReal,
|
|
formatOutputUReal: formatOutputUReal,
|
|
formatOutputBool: formatOutputBool,
|
|
formatOutputBytes: formatOutputBytes,
|
|
formatOutputDynamicBytes: formatOutputDynamicBytes,
|
|
formatOutputAddress: formatOutputAddress
|
|
};
|
|
|
|
|
|
},{"../utils/config":5,"../utils/utils":7,"./param":3,"bignumber.js":"bignumber.js"}],3:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file param.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var utils = require('../utils/utils');
|
|
|
|
/**
|
|
* SolidityParam object prototype.
|
|
* Should be used when encoding, decoding solidity bytes
|
|
*/
|
|
var SolidityParam = function (value, offset) {
|
|
this.value = value || '';
|
|
this.offset = offset; // offset in bytes
|
|
};
|
|
|
|
/**
|
|
* This method should be used to get length of params's dynamic part
|
|
*
|
|
* @method dynamicPartLength
|
|
* @returns {Number} length of dynamic part (in bytes)
|
|
*/
|
|
SolidityParam.prototype.dynamicPartLength = function () {
|
|
return this.dynamicPart().length / 2;
|
|
};
|
|
|
|
/**
|
|
* This method should be used to create copy of solidity param with different offset
|
|
*
|
|
* @method withOffset
|
|
* @param {Number} offset length in bytes
|
|
* @returns {SolidityParam} new solidity param with applied offset
|
|
*/
|
|
SolidityParam.prototype.withOffset = function (offset) {
|
|
return new SolidityParam(this.value, offset);
|
|
};
|
|
|
|
/**
|
|
* This method should be used to combine solidity params together
|
|
* eg. when appending an array
|
|
*
|
|
* @method combine
|
|
* @param {SolidityParam} param with which we should combine
|
|
* @param {SolidityParam} result of combination
|
|
*/
|
|
SolidityParam.prototype.combine = function (param) {
|
|
return new SolidityParam(this.value + param.value);
|
|
};
|
|
|
|
/**
|
|
* This method should be called to check if param has dynamic size.
|
|
* If it has, it returns true, otherwise false
|
|
*
|
|
* @method isDynamic
|
|
* @returns {Boolean}
|
|
*/
|
|
SolidityParam.prototype.isDynamic = function () {
|
|
return this.value.length > 64 || this.offset !== undefined;
|
|
};
|
|
|
|
/**
|
|
* This method should be called to transform offset to bytes
|
|
*
|
|
* @method offsetAsBytes
|
|
* @returns {String} bytes representation of offset
|
|
*/
|
|
SolidityParam.prototype.offsetAsBytes = function () {
|
|
return !this.isDynamic() ? '' : utils.padLeft(utils.toTwosComplement(this.offset).toString(16), 64);
|
|
};
|
|
|
|
/**
|
|
* This method should be called to get static part of param
|
|
*
|
|
* @method staticPart
|
|
* @returns {String} offset if it is a dynamic param, otherwise value
|
|
*/
|
|
SolidityParam.prototype.staticPart = function () {
|
|
if (!this.isDynamic()) {
|
|
return this.value;
|
|
}
|
|
return this.offsetAsBytes();
|
|
};
|
|
|
|
/**
|
|
* This method should be called to get dynamic part of param
|
|
*
|
|
* @method dynamicPart
|
|
* @returns {String} returns a value if it is a dynamic param, otherwise empty string
|
|
*/
|
|
SolidityParam.prototype.dynamicPart = function () {
|
|
return this.isDynamic() ? this.value : '';
|
|
};
|
|
|
|
/**
|
|
* This method should be called to encode param
|
|
*
|
|
* @method encode
|
|
* @returns {String}
|
|
*/
|
|
SolidityParam.prototype.encode = function () {
|
|
return this.staticPart() + this.dynamicPart();
|
|
};
|
|
|
|
/**
|
|
* This method should be called to encode array of params
|
|
*
|
|
* @method encodeList
|
|
* @param {Array[SolidityParam]} params
|
|
* @returns {String}
|
|
*/
|
|
SolidityParam.encodeList = function (params) {
|
|
|
|
// updating offsets
|
|
var totalOffset = params.length * 32;
|
|
var offsetParams = params.map(function (param) {
|
|
if (!param.isDynamic()) {
|
|
return param;
|
|
}
|
|
var offset = totalOffset;
|
|
totalOffset += param.dynamicPartLength();
|
|
return param.withOffset(offset);
|
|
});
|
|
|
|
// encode everything!
|
|
return offsetParams.reduce(function (result, param) {
|
|
return result + param.dynamicPart();
|
|
}, offsetParams.reduce(function (result, param) {
|
|
return result + param.staticPart();
|
|
}, ''));
|
|
};
|
|
|
|
/**
|
|
* This method should be used to decode plain (static) solidity param at given index
|
|
*
|
|
* @method decodeParam
|
|
* @param {String} bytes
|
|
* @param {Number} index
|
|
* @returns {SolidityParam}
|
|
*/
|
|
SolidityParam.decodeParam = function (bytes, index) {
|
|
index = index || 0;
|
|
return new SolidityParam(bytes.substr(index * 64, 64));
|
|
};
|
|
|
|
/**
|
|
* This method should be called to get offset value from bytes at given index
|
|
*
|
|
* @method getOffset
|
|
* @param {String} bytes
|
|
* @param {Number} index
|
|
* @returns {Number} offset as number
|
|
*/
|
|
var getOffset = function (bytes, index) {
|
|
// we can do this cause offset is rather small
|
|
return parseInt('0x' + bytes.substr(index * 64, 64));
|
|
};
|
|
|
|
/**
|
|
* This method should be called to decode solidity bytes param at given index
|
|
*
|
|
* @method decodeBytes
|
|
* @param {String} bytes
|
|
* @param {Number} index
|
|
* @returns {SolidityParam}
|
|
*/
|
|
SolidityParam.decodeBytes = function (bytes, index) {
|
|
index = index || 0;
|
|
//TODO add support for strings longer than 32 bytes
|
|
//var length = parseInt('0x' + bytes.substr(offset * 64, 64));
|
|
|
|
var offset = getOffset(bytes, index);
|
|
|
|
// 2 * , cause we also parse length
|
|
return new SolidityParam(bytes.substr(offset * 2, 2 * 64), 0);
|
|
};
|
|
|
|
/**
|
|
* This method should be used to decode solidity array at given index
|
|
*
|
|
* @method decodeArray
|
|
* @param {String} bytes
|
|
* @param {Number} index
|
|
* @returns {SolidityParam}
|
|
*/
|
|
SolidityParam.decodeArray = function (bytes, index) {
|
|
index = index || 0;
|
|
var offset = getOffset(bytes, index);
|
|
var length = parseInt('0x' + bytes.substr(offset * 2, 64));
|
|
return new SolidityParam(bytes.substr(offset * 2, (length + 1) * 64), 0);
|
|
};
|
|
|
|
module.exports = SolidityParam;
|
|
|
|
|
|
},{"../utils/utils":7}],4:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
// go env doesn't have and need XMLHttpRequest
|
|
if (typeof XMLHttpRequest === 'undefined') {
|
|
exports.XMLHttpRequest = {};
|
|
} else {
|
|
exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
|
|
}
|
|
|
|
|
|
},{}],5:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file config.js
|
|
* @authors:
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
/**
|
|
* Utils
|
|
*
|
|
* @module utils
|
|
*/
|
|
|
|
/**
|
|
* Utility functions
|
|
*
|
|
* @class [utils] config
|
|
* @constructor
|
|
*/
|
|
|
|
/// required to define ETH_BIGNUMBER_ROUNDING_MODE
|
|
var BigNumber = require('bignumber.js');
|
|
|
|
var ETH_UNITS = [
|
|
'wei',
|
|
'kwei',
|
|
'Mwei',
|
|
'Gwei',
|
|
'szabo',
|
|
'finney',
|
|
'femtoether',
|
|
'picoether',
|
|
'nanoether',
|
|
'microether',
|
|
'milliether',
|
|
'nano',
|
|
'micro',
|
|
'milli',
|
|
'ether',
|
|
'grand',
|
|
'Mether',
|
|
'Gether',
|
|
'Tether',
|
|
'Pether',
|
|
'Eether',
|
|
'Zether',
|
|
'Yether',
|
|
'Nether',
|
|
'Dether',
|
|
'Vether',
|
|
'Uether'
|
|
];
|
|
|
|
module.exports = {
|
|
ETH_PADDING: 32,
|
|
ETH_SIGNATURE_LENGTH: 4,
|
|
ETH_UNITS: ETH_UNITS,
|
|
ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
|
|
ETH_POLLING_TIMEOUT: 1000,
|
|
defaultBlock: 'latest',
|
|
defaultAccount: undefined
|
|
};
|
|
|
|
|
|
},{"bignumber.js":"bignumber.js"}],6:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file sha3.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var utils = require('./utils');
|
|
var sha3 = require('crypto-js/sha3');
|
|
|
|
module.exports = function (str, isNew) {
|
|
if (str.substr(0, 2) === '0x' && !isNew) {
|
|
console.warn('requirement of using web3.fromAscii before sha3 is deprecated');
|
|
console.warn('new usage: \'web3.sha3("hello")\'');
|
|
console.warn('see https://github.com/ethereum/web3.js/pull/205');
|
|
console.warn('if you need to hash hex value, you can do \'sha3("0xfff", true)\'');
|
|
str = utils.toAscii(str);
|
|
}
|
|
|
|
return sha3(str, {
|
|
outputLength: 256
|
|
}).toString();
|
|
};
|
|
|
|
|
|
},{"./utils":7,"crypto-js/sha3":33}],7:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file utils.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
/**
|
|
* Utils
|
|
*
|
|
* @module utils
|
|
*/
|
|
|
|
/**
|
|
* Utility functions
|
|
*
|
|
* @class [utils] utils
|
|
* @constructor
|
|
*/
|
|
|
|
var BigNumber = require('bignumber.js');
|
|
|
|
var unitMap = {
|
|
'wei': '1',
|
|
'kwei': '1000',
|
|
'ada': '1000',
|
|
'femtoether': '1000',
|
|
'mwei': '1000000',
|
|
'babbage': '1000000',
|
|
'picoether': '1000000',
|
|
'gwei': '1000000000',
|
|
'shannon': '1000000000',
|
|
'nanoether': '1000000000',
|
|
'nano': '1000000000',
|
|
'szabo': '1000000000000',
|
|
'microether': '1000000000000',
|
|
'micro': '1000000000000',
|
|
'finney': '1000000000000000',
|
|
'milliether': '1000000000000000',
|
|
'milli': '1000000000000000',
|
|
'ether': '1000000000000000000',
|
|
'kether': '1000000000000000000000',
|
|
'grand': '1000000000000000000000',
|
|
'einstein': '1000000000000000000000',
|
|
'mether': '1000000000000000000000000',
|
|
'gether': '1000000000000000000000000000',
|
|
'tether': '1000000000000000000000000000000'
|
|
};
|
|
|
|
/**
|
|
* Should be called to pad string to expected length
|
|
*
|
|
* @method padLeft
|
|
* @param {String} string to be padded
|
|
* @param {Number} characters that result string should have
|
|
* @param {String} sign, by default 0
|
|
* @returns {String} right aligned string
|
|
*/
|
|
var padLeft = function (string, chars, sign) {
|
|
return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
|
|
};
|
|
|
|
/**
|
|
* Should be called to get sting from it's hex representation
|
|
*
|
|
* @method toAscii
|
|
* @param {String} string in hex
|
|
* @returns {String} ascii string representation of hex value
|
|
*/
|
|
var toAscii = function(hex) {
|
|
// Find termination
|
|
var str = "";
|
|
var i = 0, l = hex.length;
|
|
if (hex.substring(0, 2) === '0x') {
|
|
i = 2;
|
|
}
|
|
for (; i < l; i+=2) {
|
|
var code = parseInt(hex.substr(i, 2), 16);
|
|
if (code === 0) {
|
|
break;
|
|
}
|
|
|
|
str += String.fromCharCode(code);
|
|
}
|
|
|
|
return str;
|
|
};
|
|
|
|
/**
|
|
* Shold be called to get hex representation (prefixed by 0x) of ascii string
|
|
*
|
|
* @method toHexNative
|
|
* @param {String} string
|
|
* @returns {String} hex representation of input string
|
|
*/
|
|
var toHexNative = function(str) {
|
|
var hex = "";
|
|
for(var i = 0; i < str.length; i++) {
|
|
var n = str.charCodeAt(i).toString(16);
|
|
hex += n.length < 2 ? '0' + n : n;
|
|
}
|
|
|
|
return hex;
|
|
};
|
|
|
|
/**
|
|
* Shold be called to get hex representation (prefixed by 0x) of ascii string
|
|
*
|
|
* @method fromAscii
|
|
* @param {String} string
|
|
* @param {Number} optional padding
|
|
* @returns {String} hex representation of input string
|
|
*/
|
|
var fromAscii = function(str, pad) {
|
|
pad = pad === undefined ? 0 : pad;
|
|
var hex = toHexNative(str);
|
|
while (hex.length < pad*2)
|
|
hex += "00";
|
|
return "0x" + hex;
|
|
};
|
|
|
|
/**
|
|
* Should be used to create full function/event name from json abi
|
|
*
|
|
* @method transformToFullName
|
|
* @param {Object} json-abi
|
|
* @return {String} full fnction/event name
|
|
*/
|
|
var transformToFullName = function (json) {
|
|
if (json.name.indexOf('(') !== -1) {
|
|
return json.name;
|
|
}
|
|
|
|
var typeName = json.inputs.map(function(i){return i.type; }).join();
|
|
return json.name + '(' + typeName + ')';
|
|
};
|
|
|
|
/**
|
|
* Should be called to get display name of contract function
|
|
*
|
|
* @method extractDisplayName
|
|
* @param {String} name of function/event
|
|
* @returns {String} display name for function/event eg. multiply(uint256) -> multiply
|
|
*/
|
|
var extractDisplayName = function (name) {
|
|
var length = name.indexOf('(');
|
|
return length !== -1 ? name.substr(0, length) : name;
|
|
};
|
|
|
|
/// @returns overloaded part of function/event name
|
|
var extractTypeName = function (name) {
|
|
/// TODO: make it invulnerable
|
|
var length = name.indexOf('(');
|
|
return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
|
|
};
|
|
|
|
/**
|
|
* Converts value to it's decimal representation in string
|
|
*
|
|
* @method toDecimal
|
|
* @param {String|Number|BigNumber}
|
|
* @return {String}
|
|
*/
|
|
var toDecimal = function (value) {
|
|
return toBigNumber(value).toNumber();
|
|
};
|
|
|
|
/**
|
|
* Converts value to it's hex representation
|
|
*
|
|
* @method fromDecimal
|
|
* @param {String|Number|BigNumber}
|
|
* @return {String}
|
|
*/
|
|
var fromDecimal = function (value) {
|
|
var number = toBigNumber(value);
|
|
var result = number.toString(16);
|
|
|
|
return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
|
|
};
|
|
|
|
/**
|
|
* Auto converts any given value into it's hex representation.
|
|
*
|
|
* And even stringifys objects before.
|
|
*
|
|
* @method toHex
|
|
* @param {String|Number|BigNumber|Object}
|
|
* @return {String}
|
|
*/
|
|
var toHex = function (val) {
|
|
/*jshint maxcomplexity:7 */
|
|
|
|
if (isBoolean(val))
|
|
return fromDecimal(+val);
|
|
|
|
if (isBigNumber(val))
|
|
return fromDecimal(val);
|
|
|
|
if (isObject(val))
|
|
return fromAscii(JSON.stringify(val));
|
|
|
|
// if its a negative number, pass it through fromDecimal
|
|
if (isString(val)) {
|
|
if (val.indexOf('-0x') === 0)
|
|
return fromDecimal(val);
|
|
else if (!isFinite(val))
|
|
return fromAscii(val);
|
|
}
|
|
|
|
return fromDecimal(val);
|
|
};
|
|
|
|
/**
|
|
* Returns value of unit in Wei
|
|
*
|
|
* @method getValueOfUnit
|
|
* @param {String} unit the unit to convert to, default ether
|
|
* @returns {BigNumber} value of the unit (in Wei)
|
|
* @throws error if the unit is not correct:w
|
|
*/
|
|
var getValueOfUnit = function (unit) {
|
|
unit = unit ? unit.toLowerCase() : 'ether';
|
|
var unitValue = unitMap[unit];
|
|
if (unitValue === undefined) {
|
|
throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
|
|
}
|
|
return new BigNumber(unitValue, 10);
|
|
};
|
|
|
|
/**
|
|
* Takes a number of wei and converts it to any other ether unit.
|
|
*
|
|
* Possible units are:
|
|
* SI Short SI Full Effigy Other
|
|
* - kwei femtoether ada
|
|
* - mwei picoether babbage
|
|
* - gwei nanoether shannon nano
|
|
* - -- microether szabo micro
|
|
* - -- milliether finney milli
|
|
* - ether -- --
|
|
* - kether einstein grand
|
|
* - mether
|
|
* - gether
|
|
* - tether
|
|
*
|
|
* @method fromWei
|
|
* @param {Number|String} number can be a number, number string or a HEX of a decimal
|
|
* @param {String} unit the unit to convert to, default ether
|
|
* @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
|
|
*/
|
|
var fromWei = function(number, unit) {
|
|
var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
|
|
|
|
return isBigNumber(number) ? returnValue : returnValue.toString(10);
|
|
};
|
|
|
|
/**
|
|
* Takes a number of a unit and converts it to wei.
|
|
*
|
|
* Possible units are:
|
|
* SI Short SI Full Effigy Other
|
|
* - kwei femtoether ada
|
|
* - mwei picoether babbage
|
|
* - gwei nanoether shannon nano
|
|
* - -- microether szabo micro
|
|
* - -- milliether finney milli
|
|
* - ether -- --
|
|
* - kether einstein grand
|
|
* - mether
|
|
* - gether
|
|
* - tether
|
|
*
|
|
* @method toWei
|
|
* @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
|
|
* @param {String} unit the unit to convert from, default ether
|
|
* @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
|
|
*/
|
|
var toWei = function(number, unit) {
|
|
var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
|
|
|
|
return isBigNumber(number) ? returnValue : returnValue.toString(10);
|
|
};
|
|
|
|
/**
|
|
* Takes an input and transforms it into an bignumber
|
|
*
|
|
* @method toBigNumber
|
|
* @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
|
|
* @return {BigNumber} BigNumber
|
|
*/
|
|
var toBigNumber = function(number) {
|
|
/*jshint maxcomplexity:5 */
|
|
number = number || 0;
|
|
if (isBigNumber(number))
|
|
return number;
|
|
|
|
if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
|
|
return new BigNumber(number.replace('0x',''), 16);
|
|
}
|
|
|
|
return new BigNumber(number.toString(10), 10);
|
|
};
|
|
|
|
/**
|
|
* Takes and input transforms it into bignumber and if it is negative value, into two's complement
|
|
*
|
|
* @method toTwosComplement
|
|
* @param {Number|String|BigNumber}
|
|
* @return {BigNumber}
|
|
*/
|
|
var toTwosComplement = function (number) {
|
|
var bigNumber = toBigNumber(number);
|
|
if (bigNumber.lessThan(0)) {
|
|
return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
|
|
}
|
|
return bigNumber;
|
|
};
|
|
|
|
/**
|
|
* Checks if the given string is strictly an address
|
|
*
|
|
* @method isStrictAddress
|
|
* @param {String} address the given HEX adress
|
|
* @return {Boolean}
|
|
*/
|
|
var isStrictAddress = function (address) {
|
|
return /^0x[0-9a-f]{40}$/.test(address);
|
|
};
|
|
|
|
/**
|
|
* Checks if the given string is an address
|
|
*
|
|
* @method isAddress
|
|
* @param {String} address the given HEX adress
|
|
* @return {Boolean}
|
|
*/
|
|
var isAddress = function (address) {
|
|
return /^(0x)?[0-9a-f]{40}$/.test(address);
|
|
};
|
|
|
|
/**
|
|
* Transforms given string to valid 20 bytes-length addres with 0x prefix
|
|
*
|
|
* @method toAddress
|
|
* @param {String} address
|
|
* @return {String} formatted address
|
|
*/
|
|
var toAddress = function (address) {
|
|
if (isStrictAddress(address)) {
|
|
return address;
|
|
}
|
|
|
|
if (/^[0-9a-f]{40}$/.test(address)) {
|
|
return '0x' + address;
|
|
}
|
|
|
|
return '0x' + padLeft(toHex(address).substr(2), 40);
|
|
};
|
|
|
|
|
|
/**
|
|
* Returns true if object is BigNumber, otherwise false
|
|
*
|
|
* @method isBigNumber
|
|
* @param {Object}
|
|
* @return {Boolean}
|
|
*/
|
|
var isBigNumber = function (object) {
|
|
return object instanceof BigNumber ||
|
|
(object && object.constructor && object.constructor.name === 'BigNumber');
|
|
};
|
|
|
|
/**
|
|
* Returns true if object is string, otherwise false
|
|
*
|
|
* @method isString
|
|
* @param {Object}
|
|
* @return {Boolean}
|
|
*/
|
|
var isString = function (object) {
|
|
return typeof object === 'string' ||
|
|
(object && object.constructor && object.constructor.name === 'String');
|
|
};
|
|
|
|
/**
|
|
* Returns true if object is function, otherwise false
|
|
*
|
|
* @method isFunction
|
|
* @param {Object}
|
|
* @return {Boolean}
|
|
*/
|
|
var isFunction = function (object) {
|
|
return typeof object === 'function';
|
|
};
|
|
|
|
/**
|
|
* Returns true if object is Objet, otherwise false
|
|
*
|
|
* @method isObject
|
|
* @param {Object}
|
|
* @return {Boolean}
|
|
*/
|
|
var isObject = function (object) {
|
|
return typeof object === 'object';
|
|
};
|
|
|
|
/**
|
|
* Returns true if object is boolean, otherwise false
|
|
*
|
|
* @method isBoolean
|
|
* @param {Object}
|
|
* @return {Boolean}
|
|
*/
|
|
var isBoolean = function (object) {
|
|
return typeof object === 'boolean';
|
|
};
|
|
|
|
/**
|
|
* Returns true if object is array, otherwise false
|
|
*
|
|
* @method isArray
|
|
* @param {Object}
|
|
* @return {Boolean}
|
|
*/
|
|
var isArray = function (object) {
|
|
return object instanceof Array;
|
|
};
|
|
|
|
/**
|
|
* Returns true if given string is valid json object
|
|
*
|
|
* @method isJson
|
|
* @param {String}
|
|
* @return {Boolean}
|
|
*/
|
|
var isJson = function (str) {
|
|
try {
|
|
return !!JSON.parse(str);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* This method should be called to check if string is valid ethereum IBAN number
|
|
* Supports direct and indirect IBANs
|
|
*
|
|
* @method isIBAN
|
|
* @param {String}
|
|
* @return {Boolean}
|
|
*/
|
|
var isIBAN = function (iban) {
|
|
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30})$/.test(iban);
|
|
};
|
|
|
|
module.exports = {
|
|
padLeft: padLeft,
|
|
toHex: toHex,
|
|
toDecimal: toDecimal,
|
|
fromDecimal: fromDecimal,
|
|
toAscii: toAscii,
|
|
fromAscii: fromAscii,
|
|
transformToFullName: transformToFullName,
|
|
extractDisplayName: extractDisplayName,
|
|
extractTypeName: extractTypeName,
|
|
toWei: toWei,
|
|
fromWei: fromWei,
|
|
toBigNumber: toBigNumber,
|
|
toTwosComplement: toTwosComplement,
|
|
toAddress: toAddress,
|
|
isBigNumber: isBigNumber,
|
|
isStrictAddress: isStrictAddress,
|
|
isAddress: isAddress,
|
|
isFunction: isFunction,
|
|
isString: isString,
|
|
isObject: isObject,
|
|
isBoolean: isBoolean,
|
|
isArray: isArray,
|
|
isJson: isJson,
|
|
isIBAN: isIBAN
|
|
};
|
|
|
|
|
|
},{"bignumber.js":"bignumber.js"}],8:[function(require,module,exports){
|
|
module.exports={
|
|
"version": "0.5.0"
|
|
}
|
|
|
|
},{}],9:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file web3.js
|
|
* @authors:
|
|
* Jeffrey Wilcke <jeff@ethdev.com>
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* Marian Oancea <marian@ethdev.com>
|
|
* Fabian Vogelsteller <fabian@ethdev.com>
|
|
* Gav Wood <g@ethdev.com>
|
|
* @date 2014
|
|
*/
|
|
|
|
var version = require('./version.json');
|
|
var net = require('./web3/net');
|
|
var eth = require('./web3/eth');
|
|
var db = require('./web3/db');
|
|
var shh = require('./web3/shh');
|
|
var watches = require('./web3/watches');
|
|
var Filter = require('./web3/filter');
|
|
var utils = require('./utils/utils');
|
|
var formatters = require('./web3/formatters');
|
|
var RequestManager = require('./web3/requestmanager');
|
|
var c = require('./utils/config');
|
|
var Property = require('./web3/property');
|
|
var Batch = require('./web3/batch');
|
|
var sha3 = require('./utils/sha3');
|
|
|
|
var web3Properties = [
|
|
new Property({
|
|
name: 'version.client',
|
|
getter: 'web3_clientVersion'
|
|
}),
|
|
new Property({
|
|
name: 'version.network',
|
|
getter: 'net_version',
|
|
inputFormatter: utils.toDecimal
|
|
}),
|
|
new Property({
|
|
name: 'version.ethereum',
|
|
getter: 'eth_protocolVersion',
|
|
inputFormatter: utils.toDecimal
|
|
}),
|
|
new Property({
|
|
name: 'version.whisper',
|
|
getter: 'shh_version',
|
|
inputFormatter: utils.toDecimal
|
|
})
|
|
];
|
|
|
|
/// creates methods in a given object based on method description on input
|
|
/// setups api calls for these methods
|
|
var setupMethods = function (obj, methods) {
|
|
methods.forEach(function (method) {
|
|
method.attachToObject(obj);
|
|
});
|
|
};
|
|
|
|
/// creates properties in a given object based on properties description on input
|
|
/// setups api calls for these properties
|
|
var setupProperties = function (obj, properties) {
|
|
properties.forEach(function (property) {
|
|
property.attachToObject(obj);
|
|
});
|
|
};
|
|
|
|
/// setups web3 object, and it's in-browser executed methods
|
|
var web3 = {};
|
|
web3.providers = {};
|
|
web3.version = {};
|
|
web3.version.api = version.version;
|
|
web3.eth = {};
|
|
|
|
/*jshint maxparams:4 */
|
|
web3.eth.filter = function (fil, eventParams, options, formatter) {
|
|
|
|
// if its event, treat it differently
|
|
// TODO: simplify and remove
|
|
if (fil._isEvent) {
|
|
return fil(eventParams, options);
|
|
}
|
|
|
|
// what outputLogFormatter? that's wrong
|
|
//return new Filter(fil, watches.eth(), formatters.outputLogFormatter);
|
|
return new Filter(fil, watches.eth(), formatter || formatters.outputLogFormatter);
|
|
};
|
|
/*jshint maxparams:3 */
|
|
|
|
web3.shh = {};
|
|
web3.shh.filter = function (fil) {
|
|
return new Filter(fil, watches.shh(), formatters.outputPostFormatter);
|
|
};
|
|
web3.net = {};
|
|
web3.db = {};
|
|
web3.setProvider = function (provider) {
|
|
RequestManager.getInstance().setProvider(provider);
|
|
};
|
|
web3.reset = function () {
|
|
RequestManager.getInstance().reset();
|
|
c.defaultBlock = 'latest';
|
|
c.defaultAccount = undefined;
|
|
};
|
|
web3.toHex = utils.toHex;
|
|
web3.toAscii = utils.toAscii;
|
|
web3.fromAscii = utils.fromAscii;
|
|
web3.toDecimal = utils.toDecimal;
|
|
web3.fromDecimal = utils.fromDecimal;
|
|
web3.toBigNumber = utils.toBigNumber;
|
|
web3.toWei = utils.toWei;
|
|
web3.fromWei = utils.fromWei;
|
|
web3.isAddress = utils.isAddress;
|
|
web3.isIBAN = utils.isIBAN;
|
|
web3.sha3 = sha3;
|
|
web3.createBatch = function () {
|
|
return new Batch();
|
|
};
|
|
|
|
// ADD defaultblock
|
|
Object.defineProperty(web3.eth, 'defaultBlock', {
|
|
get: function () {
|
|
return c.defaultBlock;
|
|
},
|
|
set: function (val) {
|
|
c.defaultBlock = val;
|
|
return val;
|
|
}
|
|
});
|
|
|
|
Object.defineProperty(web3.eth, 'defaultAccount', {
|
|
get: function () {
|
|
return c.defaultAccount;
|
|
},
|
|
set: function (val) {
|
|
c.defaultAccount = val;
|
|
return val;
|
|
}
|
|
});
|
|
|
|
/// setups all api methods
|
|
setupProperties(web3, web3Properties);
|
|
setupMethods(web3.net, net.methods);
|
|
setupProperties(web3.net, net.properties);
|
|
setupMethods(web3.eth, eth.methods);
|
|
setupProperties(web3.eth, eth.properties);
|
|
setupMethods(web3.db, db.methods);
|
|
setupMethods(web3.shh, shh.methods);
|
|
|
|
module.exports = web3;
|
|
|
|
|
|
},{"./utils/config":5,"./utils/sha3":6,"./utils/utils":7,"./version.json":8,"./web3/batch":10,"./web3/db":12,"./web3/eth":14,"./web3/filter":16,"./web3/formatters":17,"./web3/net":24,"./web3/property":25,"./web3/requestmanager":27,"./web3/shh":28,"./web3/watches":30}],10:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file batch.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var RequestManager = require('./requestmanager');
|
|
|
|
var Batch = function () {
|
|
this.requests = [];
|
|
};
|
|
|
|
/**
|
|
* Should be called to add create new request to batch request
|
|
*
|
|
* @method add
|
|
* @param {Object} jsonrpc requet object
|
|
*/
|
|
Batch.prototype.add = function (request) {
|
|
this.requests.push(request);
|
|
};
|
|
|
|
/**
|
|
* Should be called to execute batch request
|
|
*
|
|
* @method execute
|
|
*/
|
|
Batch.prototype.execute = function () {
|
|
var requests = this.requests;
|
|
RequestManager.getInstance().sendBatch(requests, function (err, results) {
|
|
results = results || [];
|
|
requests.map(function (request, index) {
|
|
return results[index] || {};
|
|
}).map(function (result, index) {
|
|
return requests[index].format ? requests[index].format(result.result) : result.result;
|
|
}).forEach(function (result, index) {
|
|
if (requests[index].callback) {
|
|
requests[index].callback(err, result);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
module.exports = Batch;
|
|
|
|
|
|
},{"./requestmanager":27}],11:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file contract.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2014
|
|
*/
|
|
|
|
var web3 = require('../web3');
|
|
var utils = require('../utils/utils');
|
|
var coder = require('../solidity/coder');
|
|
var SolidityEvent = require('./event');
|
|
var SolidityFunction = require('./function');
|
|
|
|
/**
|
|
* Should be called to encode constructor params
|
|
*
|
|
* @method encodeConstructorParams
|
|
* @param {Array} abi
|
|
* @param {Array} constructor params
|
|
*/
|
|
var encodeConstructorParams = function (abi, params) {
|
|
return abi.filter(function (json) {
|
|
return json.type === 'constructor' && json.inputs.length === params.length;
|
|
}).map(function (json) {
|
|
return json.inputs.map(function (input) {
|
|
return input.type;
|
|
});
|
|
}).map(function (types) {
|
|
return coder.encodeParams(types, params);
|
|
})[0] || '';
|
|
};
|
|
|
|
/**
|
|
* Should be called to add functions to contract object
|
|
*
|
|
* @method addFunctionsToContract
|
|
* @param {Contract} contract
|
|
* @param {Array} abi
|
|
*/
|
|
var addFunctionsToContract = function (contract, abi) {
|
|
abi.filter(function (json) {
|
|
return json.type === 'function';
|
|
}).map(function (json) {
|
|
return new SolidityFunction(json, contract.address);
|
|
}).forEach(function (f) {
|
|
f.attachToContract(contract);
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Should be called to add events to contract object
|
|
*
|
|
* @method addEventsToContract
|
|
* @param {Contract} contract
|
|
* @param {Array} abi
|
|
*/
|
|
var addEventsToContract = function (contract, abi) {
|
|
abi.filter(function (json) {
|
|
return json.type === 'event';
|
|
}).map(function (json) {
|
|
return new SolidityEvent(json, contract.address);
|
|
}).forEach(function (e) {
|
|
e.attachToContract(contract);
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Should be called to create new ContractFactory
|
|
*
|
|
* @method contract
|
|
* @param {Array} abi
|
|
* @returns {ContractFactory} new contract factory
|
|
*/
|
|
var contract = function (abi) {
|
|
return new ContractFactory(abi);
|
|
};
|
|
|
|
/**
|
|
* Should be called to create new ContractFactory instance
|
|
*
|
|
* @method ContractFactory
|
|
* @param {Array} abi
|
|
*/
|
|
var ContractFactory = function (abi) {
|
|
this.abi = abi;
|
|
};
|
|
|
|
/**
|
|
* Should be called to create new contract on a blockchain
|
|
*
|
|
* @method new
|
|
* @param {Any} contract constructor param1 (optional)
|
|
* @param {Any} contract constructor param2 (optional)
|
|
* @param {Object} contract transaction object (required)
|
|
* @param {Function} callback
|
|
* @returns {Contract} returns contract if no callback was passed,
|
|
* otherwise calls callback function (err, contract)
|
|
*/
|
|
ContractFactory.prototype.new = function () {
|
|
// parse arguments
|
|
var options = {}; // required!
|
|
var callback;
|
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
if (utils.isFunction(args[args.length - 1])) {
|
|
callback = args.pop();
|
|
}
|
|
|
|
var last = args[args.length - 1];
|
|
if (utils.isObject(last) && !utils.isArray(last)) {
|
|
options = args.pop();
|
|
}
|
|
|
|
// throw an error if there are no options
|
|
|
|
var bytes = encodeConstructorParams(this.abi, args);
|
|
options.data += bytes;
|
|
|
|
if (!callback) {
|
|
var address = web3.eth.sendTransaction(options);
|
|
return this.at(address);
|
|
}
|
|
|
|
var self = this;
|
|
web3.eth.sendTransaction(options, function (err, address) {
|
|
if (err) {
|
|
callback(err);
|
|
}
|
|
self.at(address, callback);
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Should be called to get access to existing contract on a blockchain
|
|
*
|
|
* @method at
|
|
* @param {Address} contract address (required)
|
|
* @param {Function} callback {optional)
|
|
* @returns {Contract} returns contract if no callback was passed,
|
|
* otherwise calls callback function (err, contract)
|
|
*/
|
|
ContractFactory.prototype.at = function (address, callback) {
|
|
// TODO: address is required
|
|
|
|
if (callback) {
|
|
callback(null, new Contract(this.abi, address));
|
|
}
|
|
return new Contract(this.abi, address);
|
|
};
|
|
|
|
/**
|
|
* Should be called to create new contract instance
|
|
*
|
|
* @method Contract
|
|
* @param {Array} abi
|
|
* @param {Address} contract address
|
|
*/
|
|
var Contract = function (abi, address) {
|
|
this.address = address;
|
|
addFunctionsToContract(this, abi);
|
|
addEventsToContract(this, abi);
|
|
};
|
|
|
|
module.exports = contract;
|
|
|
|
|
|
},{"../solidity/coder":1,"../utils/utils":7,"../web3":9,"./event":15,"./function":18}],12:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file db.js
|
|
* @authors:
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var Method = require('./method');
|
|
|
|
var putString = new Method({
|
|
name: 'putString',
|
|
call: 'db_putString',
|
|
params: 3
|
|
});
|
|
|
|
|
|
var getString = new Method({
|
|
name: 'getString',
|
|
call: 'db_getString',
|
|
params: 2
|
|
});
|
|
|
|
var putHex = new Method({
|
|
name: 'putHex',
|
|
call: 'db_putHex',
|
|
params: 3
|
|
});
|
|
|
|
var getHex = new Method({
|
|
name: 'getHex',
|
|
call: 'db_getHex',
|
|
params: 2
|
|
});
|
|
|
|
var methods = [
|
|
putString, getString, putHex, getHex
|
|
];
|
|
|
|
module.exports = {
|
|
methods: methods
|
|
};
|
|
|
|
},{"./method":22}],13:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file errors.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
module.exports = {
|
|
InvalidNumberOfParams: function () {
|
|
return new Error('Invalid number of input parameters');
|
|
},
|
|
InvalidConnection: function (host){
|
|
return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +', is it running?');
|
|
},
|
|
InvalidProvider: function () {
|
|
return new Error('Providor not set or invalid');
|
|
},
|
|
InvalidResponse: function (result){
|
|
var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response';
|
|
return new Error(message);
|
|
}
|
|
};
|
|
|
|
|
|
},{}],14:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file eth.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @author Fabian Vogelsteller <fabian@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
/**
|
|
* Web3
|
|
*
|
|
* @module web3
|
|
*/
|
|
|
|
/**
|
|
* Eth methods and properties
|
|
*
|
|
* An example method object can look as follows:
|
|
*
|
|
* {
|
|
* name: 'getBlock',
|
|
* call: blockCall,
|
|
* params: 2,
|
|
* outputFormatter: formatters.outputBlockFormatter,
|
|
* inputFormatter: [ // can be a formatter funciton or an array of functions. Where each item in the array will be used for one parameter
|
|
* utils.toHex, // formats paramter 1
|
|
* function(param){ return !!param; } // formats paramter 2
|
|
* ]
|
|
* },
|
|
*
|
|
* @class [web3] eth
|
|
* @constructor
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var formatters = require('./formatters');
|
|
var utils = require('../utils/utils');
|
|
var Method = require('./method');
|
|
var Property = require('./property');
|
|
|
|
var blockCall = function (args) {
|
|
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
|
|
};
|
|
|
|
var transactionFromBlockCall = function (args) {
|
|
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
|
|
};
|
|
|
|
var uncleCall = function (args) {
|
|
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
|
|
};
|
|
|
|
var getBlockTransactionCountCall = function (args) {
|
|
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
|
|
};
|
|
|
|
var uncleCountCall = function (args) {
|
|
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
|
|
};
|
|
|
|
/// @returns an array of objects describing web3.eth api methods
|
|
|
|
var getBalance = new Method({
|
|
name: 'getBalance',
|
|
call: 'eth_getBalance',
|
|
params: 2,
|
|
inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter],
|
|
outputFormatter: formatters.outputBigNumberFormatter
|
|
});
|
|
|
|
var getStorageAt = new Method({
|
|
name: 'getStorageAt',
|
|
call: 'eth_getStorageAt',
|
|
params: 3,
|
|
inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
|
|
});
|
|
|
|
var getCode = new Method({
|
|
name: 'getCode',
|
|
call: 'eth_getCode',
|
|
params: 2,
|
|
inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter]
|
|
});
|
|
|
|
var getBlock = new Method({
|
|
name: 'getBlock',
|
|
call: blockCall,
|
|
params: 2,
|
|
inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
|
|
outputFormatter: formatters.outputBlockFormatter
|
|
});
|
|
|
|
var getUncle = new Method({
|
|
name: 'getUncle',
|
|
call: uncleCall,
|
|
params: 2,
|
|
inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
|
|
outputFormatter: formatters.outputBlockFormatter,
|
|
|
|
});
|
|
|
|
var getCompilers = new Method({
|
|
name: 'getCompilers',
|
|
call: 'eth_getCompilers',
|
|
params: 0
|
|
});
|
|
|
|
var getBlockTransactionCount = new Method({
|
|
name: 'getBlockTransactionCount',
|
|
call: getBlockTransactionCountCall,
|
|
params: 1,
|
|
inputFormatter: [formatters.inputBlockNumberFormatter],
|
|
outputFormatter: utils.toDecimal
|
|
});
|
|
|
|
var getBlockUncleCount = new Method({
|
|
name: 'getBlockUncleCount',
|
|
call: uncleCountCall,
|
|
params: 1,
|
|
inputFormatter: [formatters.inputBlockNumberFormatter],
|
|
outputFormatter: utils.toDecimal
|
|
});
|
|
|
|
var getTransaction = new Method({
|
|
name: 'getTransaction',
|
|
call: 'eth_getTransactionByHash',
|
|
params: 1,
|
|
outputFormatter: formatters.outputTransactionFormatter
|
|
});
|
|
|
|
var getTransactionFromBlock = new Method({
|
|
name: 'getTransactionFromBlock',
|
|
call: transactionFromBlockCall,
|
|
params: 2,
|
|
inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
|
|
outputFormatter: formatters.outputTransactionFormatter
|
|
});
|
|
|
|
var getTransactionCount = new Method({
|
|
name: 'getTransactionCount',
|
|
call: 'eth_getTransactionCount',
|
|
params: 2,
|
|
inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
|
|
outputFormatter: utils.toDecimal
|
|
});
|
|
|
|
var sendTransaction = new Method({
|
|
name: 'sendTransaction',
|
|
call: 'eth_sendTransaction',
|
|
params: 1,
|
|
inputFormatter: [formatters.inputTransactionFormatter]
|
|
});
|
|
|
|
var call = new Method({
|
|
name: 'call',
|
|
call: 'eth_call',
|
|
params: 2,
|
|
inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter]
|
|
});
|
|
|
|
var estimateGas = new Method({
|
|
name: 'estimateGas',
|
|
call: 'eth_estimateGas',
|
|
params: 1,
|
|
inputFormatter: [formatters.inputTransactionFormatter],
|
|
outputFormatter: utils.toDecimal
|
|
});
|
|
|
|
var compileSolidity = new Method({
|
|
name: 'compile.solidity',
|
|
call: 'eth_compileSolidity',
|
|
params: 1
|
|
});
|
|
|
|
var compileLLL = new Method({
|
|
name: 'compile.lll',
|
|
call: 'eth_compileLLL',
|
|
params: 1
|
|
});
|
|
|
|
var compileSerpent = new Method({
|
|
name: 'compile.serpent',
|
|
call: 'eth_compileSerpent',
|
|
params: 1
|
|
});
|
|
|
|
var submitWork = new Method({
|
|
name: 'submitWork',
|
|
call: 'eth_submitWork',
|
|
params: 3
|
|
});
|
|
|
|
var getWork = new Method({
|
|
name: 'getWork',
|
|
call: 'eth_getWork',
|
|
params: 0
|
|
});
|
|
|
|
var methods = [
|
|
getBalance,
|
|
getStorageAt,
|
|
getCode,
|
|
getBlock,
|
|
getUncle,
|
|
getCompilers,
|
|
getBlockTransactionCount,
|
|
getBlockUncleCount,
|
|
getTransaction,
|
|
getTransactionFromBlock,
|
|
getTransactionCount,
|
|
call,
|
|
estimateGas,
|
|
sendTransaction,
|
|
compileSolidity,
|
|
compileLLL,
|
|
compileSerpent,
|
|
submitWork,
|
|
getWork
|
|
];
|
|
|
|
/// @returns an array of objects describing web3.eth api properties
|
|
|
|
|
|
|
|
var properties = [
|
|
new Property({
|
|
name: 'coinbase',
|
|
getter: 'eth_coinbase'
|
|
}),
|
|
new Property({
|
|
name: 'mining',
|
|
getter: 'eth_mining'
|
|
}),
|
|
new Property({
|
|
name: 'hashrate',
|
|
getter: 'eth_hashrate',
|
|
outputFormatter: utils.toDecimal
|
|
}),
|
|
new Property({
|
|
name: 'gasPrice',
|
|
getter: 'eth_gasPrice',
|
|
outputFormatter: formatters.outputBigNumberFormatter
|
|
}),
|
|
new Property({
|
|
name: 'accounts',
|
|
getter: 'eth_accounts'
|
|
}),
|
|
new Property({
|
|
name: 'blockNumber',
|
|
getter: 'eth_blockNumber',
|
|
outputFormatter: utils.toDecimal
|
|
})
|
|
];
|
|
|
|
module.exports = {
|
|
methods: methods,
|
|
properties: properties
|
|
};
|
|
|
|
|
|
},{"../utils/utils":7,"./formatters":17,"./method":22,"./property":25}],15:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file event.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2014
|
|
*/
|
|
|
|
var utils = require('../utils/utils');
|
|
var coder = require('../solidity/coder');
|
|
var web3 = require('../web3');
|
|
var formatters = require('./formatters');
|
|
var sha3 = require('../utils/sha3');
|
|
|
|
/**
|
|
* This prototype should be used to create event filters
|
|
*/
|
|
var SolidityEvent = function (json, address) {
|
|
this._params = json.inputs;
|
|
this._name = utils.transformToFullName(json);
|
|
this._address = address;
|
|
this._anonymous = json.anonymous;
|
|
};
|
|
|
|
/**
|
|
* Should be used to get filtered param types
|
|
*
|
|
* @method types
|
|
* @param {Bool} decide if returned typed should be indexed
|
|
* @return {Array} array of types
|
|
*/
|
|
SolidityEvent.prototype.types = function (indexed) {
|
|
return this._params.filter(function (i) {
|
|
return i.indexed === indexed;
|
|
}).map(function (i) {
|
|
return i.type;
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Should be used to get event display name
|
|
*
|
|
* @method displayName
|
|
* @return {String} event display name
|
|
*/
|
|
SolidityEvent.prototype.displayName = function () {
|
|
return utils.extractDisplayName(this._name);
|
|
};
|
|
|
|
/**
|
|
* Should be used to get event type name
|
|
*
|
|
* @method typeName
|
|
* @return {String} event type name
|
|
*/
|
|
SolidityEvent.prototype.typeName = function () {
|
|
return utils.extractTypeName(this._name);
|
|
};
|
|
|
|
/**
|
|
* Should be used to get event signature
|
|
*
|
|
* @method signature
|
|
* @return {String} event signature
|
|
*/
|
|
SolidityEvent.prototype.signature = function () {
|
|
return sha3(this._name);
|
|
};
|
|
|
|
/**
|
|
* Should be used to encode indexed params and options to one final object
|
|
*
|
|
* @method encode
|
|
* @param {Object} indexed
|
|
* @param {Object} options
|
|
* @return {Object} everything combined together and encoded
|
|
*/
|
|
SolidityEvent.prototype.encode = function (indexed, options) {
|
|
indexed = indexed || {};
|
|
options = options || {};
|
|
var result = {};
|
|
|
|
['fromBlock', 'toBlock'].filter(function (f) {
|
|
return options[f] !== undefined;
|
|
}).forEach(function (f) {
|
|
result[f] = formatters.inputBlockNumberFormatter(options[f]);
|
|
});
|
|
|
|
result.topics = [];
|
|
|
|
if (!this._anonymous) {
|
|
result.address = this._address;
|
|
result.topics.push('0x' + this.signature());
|
|
}
|
|
|
|
var indexedTopics = this._params.filter(function (i) {
|
|
return i.indexed === true;
|
|
}).map(function (i) {
|
|
var value = indexed[i.name];
|
|
if (value === undefined || value === null) {
|
|
return null;
|
|
}
|
|
|
|
if (utils.isArray(value)) {
|
|
return value.map(function (v) {
|
|
return '0x' + coder.encodeParam(i.type, v);
|
|
});
|
|
}
|
|
return '0x' + coder.encodeParam(i.type, value);
|
|
});
|
|
|
|
result.topics = result.topics.concat(indexedTopics);
|
|
|
|
return result;
|
|
};
|
|
|
|
/**
|
|
* Should be used to decode indexed params and options
|
|
*
|
|
* @method decode
|
|
* @param {Object} data
|
|
* @return {Object} result object with decoded indexed && not indexed params
|
|
*/
|
|
SolidityEvent.prototype.decode = function (data) {
|
|
|
|
data.data = data.data || '';
|
|
data.topics = data.topics || [];
|
|
|
|
var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
|
|
var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
|
|
var indexedParams = coder.decodeParams(this.types(true), indexedData);
|
|
|
|
var notIndexedData = data.data.slice(2);
|
|
var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
|
|
|
|
var result = formatters.outputLogFormatter(data);
|
|
result.event = this.displayName();
|
|
result.address = data.address;
|
|
|
|
result.args = this._params.reduce(function (acc, current) {
|
|
acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
|
|
return acc;
|
|
}, {});
|
|
|
|
delete result.data;
|
|
delete result.topics;
|
|
|
|
return result;
|
|
};
|
|
|
|
/**
|
|
* Should be used to create new filter object from event
|
|
*
|
|
* @method execute
|
|
* @param {Object} indexed
|
|
* @param {Object} options
|
|
* @return {Object} filter object
|
|
*/
|
|
SolidityEvent.prototype.execute = function (indexed, options) {
|
|
var o = this.encode(indexed, options);
|
|
var formatter = this.decode.bind(this);
|
|
return web3.eth.filter(o, undefined, undefined, formatter);
|
|
};
|
|
|
|
/**
|
|
* Should be used to attach event to contract object
|
|
*
|
|
* @method attachToContract
|
|
* @param {Contract}
|
|
*/
|
|
SolidityEvent.prototype.attachToContract = function (contract) {
|
|
var execute = this.execute.bind(this);
|
|
var displayName = this.displayName();
|
|
if (!contract[displayName]) {
|
|
contract[displayName] = execute;
|
|
}
|
|
contract[displayName][this.typeName()] = this.execute.bind(this, contract);
|
|
};
|
|
|
|
module.exports = SolidityEvent;
|
|
|
|
|
|
},{"../solidity/coder":1,"../utils/sha3":6,"../utils/utils":7,"../web3":9,"./formatters":17}],16:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file filter.js
|
|
* @authors:
|
|
* Jeffrey Wilcke <jeff@ethdev.com>
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* Marian Oancea <marian@ethdev.com>
|
|
* Fabian Vogelsteller <fabian@ethdev.com>
|
|
* Gav Wood <g@ethdev.com>
|
|
* @date 2014
|
|
*/
|
|
|
|
var RequestManager = require('./requestmanager');
|
|
var formatters = require('./formatters');
|
|
var utils = require('../utils/utils');
|
|
|
|
/**
|
|
* Converts a given topic to a hex string, but also allows null values.
|
|
*
|
|
* @param {Mixed} value
|
|
* @return {String}
|
|
*/
|
|
var toTopic = function(value){
|
|
|
|
if(value === null || typeof value === 'undefined')
|
|
return null;
|
|
|
|
value = String(value);
|
|
|
|
if(value.indexOf('0x') === 0)
|
|
return value;
|
|
else
|
|
return utils.fromAscii(value);
|
|
};
|
|
|
|
/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
|
|
/// @param should be string or object
|
|
/// @returns options string or object
|
|
var getOptions = function (options) {
|
|
|
|
if (utils.isString(options)) {
|
|
return options;
|
|
}
|
|
|
|
options = options || {};
|
|
|
|
// make sure topics, get converted to hex
|
|
options.topics = options.topics || [];
|
|
options.topics = options.topics.map(function(topic){
|
|
return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
|
|
});
|
|
|
|
// lazy load
|
|
return {
|
|
topics: options.topics,
|
|
to: options.to,
|
|
address: options.address,
|
|
fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
|
|
toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
|
|
};
|
|
};
|
|
|
|
var Filter = function (options, methods, formatter) {
|
|
var implementation = {};
|
|
methods.forEach(function (method) {
|
|
method.attachToObject(implementation);
|
|
});
|
|
this.options = getOptions(options);
|
|
this.implementation = implementation;
|
|
this.callbacks = [];
|
|
this.formatter = formatter;
|
|
this.filterId = this.implementation.newFilter(this.options);
|
|
};
|
|
|
|
Filter.prototype.watch = function (callback) {
|
|
this.callbacks.push(callback);
|
|
var self = this;
|
|
|
|
var onMessage = function (error, messages) {
|
|
if (error) {
|
|
return self.callbacks.forEach(function (callback) {
|
|
callback(error);
|
|
});
|
|
}
|
|
|
|
messages.forEach(function (message) {
|
|
message = self.formatter ? self.formatter(message) : message;
|
|
self.callbacks.forEach(function (callback) {
|
|
callback(null, message);
|
|
});
|
|
});
|
|
};
|
|
|
|
// call getFilterLogs on start
|
|
if (!utils.isString(this.options)) {
|
|
this.get(function (err, messages) {
|
|
// don't send all the responses to all the watches again... just to this one
|
|
if (err) {
|
|
callback(err);
|
|
}
|
|
|
|
messages.forEach(function (message) {
|
|
callback(null, message);
|
|
});
|
|
});
|
|
}
|
|
|
|
RequestManager.getInstance().startPolling({
|
|
method: this.implementation.poll.call,
|
|
params: [this.filterId],
|
|
}, this.filterId, onMessage, this.stopWatching.bind(this));
|
|
};
|
|
|
|
Filter.prototype.stopWatching = function () {
|
|
RequestManager.getInstance().stopPolling(this.filterId);
|
|
this.implementation.uninstallFilter(this.filterId);
|
|
this.callbacks = [];
|
|
};
|
|
|
|
Filter.prototype.get = function (callback) {
|
|
var self = this;
|
|
if (utils.isFunction(callback)) {
|
|
this.implementation.getLogs(this.filterId, function(err, res){
|
|
if (err) {
|
|
callback(err);
|
|
} else {
|
|
callback(null, res.map(function (log) {
|
|
return self.formatter ? self.formatter(log) : log;
|
|
}));
|
|
}
|
|
});
|
|
} else {
|
|
var logs = this.implementation.getLogs(this.filterId);
|
|
return logs.map(function (log) {
|
|
return self.formatter ? self.formatter(log) : log;
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = Filter;
|
|
|
|
|
|
},{"../utils/utils":7,"./formatters":17,"./requestmanager":27}],17:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file formatters.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @author Fabian Vogelsteller <fabian@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var utils = require('../utils/utils');
|
|
var config = require('../utils/config');
|
|
|
|
/**
|
|
* Should the format output to a big number
|
|
*
|
|
* @method outputBigNumberFormatter
|
|
* @param {String|Number|BigNumber}
|
|
* @returns {BigNumber} object
|
|
*/
|
|
var outputBigNumberFormatter = function (number) {
|
|
return utils.toBigNumber(number);
|
|
};
|
|
|
|
var isPredefinedBlockNumber = function (blockNumber) {
|
|
return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
|
|
};
|
|
|
|
var inputDefaultBlockNumberFormatter = function (blockNumber) {
|
|
if (blockNumber === undefined) {
|
|
return config.defaultBlock;
|
|
}
|
|
return inputBlockNumberFormatter(blockNumber);
|
|
};
|
|
|
|
var inputBlockNumberFormatter = function (blockNumber) {
|
|
if (blockNumber === undefined) {
|
|
return undefined;
|
|
} else if (isPredefinedBlockNumber(blockNumber)) {
|
|
return blockNumber;
|
|
}
|
|
return utils.toHex(blockNumber);
|
|
};
|
|
|
|
/**
|
|
* Formats the input of a transaction and converts all values to HEX
|
|
*
|
|
* @method inputTransactionFormatter
|
|
* @param {Object} transaction options
|
|
* @returns object
|
|
*/
|
|
var inputTransactionFormatter = function (options){
|
|
|
|
options.from = options.from || config.defaultAccount;
|
|
|
|
// make code -> data
|
|
if (options.code) {
|
|
options.data = options.code;
|
|
delete options.code;
|
|
}
|
|
|
|
['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
|
|
return options[key] !== undefined;
|
|
}).forEach(function(key){
|
|
options[key] = utils.fromDecimal(options[key]);
|
|
});
|
|
|
|
return options;
|
|
};
|
|
|
|
/**
|
|
* Formats the output of a transaction to its proper values
|
|
*
|
|
* @method outputTransactionFormatter
|
|
* @param {Object} transaction
|
|
* @returns {Object} transaction
|
|
*/
|
|
var outputTransactionFormatter = function (tx){
|
|
tx.blockNumber = utils.toDecimal(tx.blockNumber);
|
|
tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
|
|
tx.nonce = utils.toDecimal(tx.nonce);
|
|
tx.gas = utils.toDecimal(tx.gas);
|
|
tx.gasPrice = utils.toBigNumber(tx.gasPrice);
|
|
tx.value = utils.toBigNumber(tx.value);
|
|
return tx;
|
|
};
|
|
|
|
/**
|
|
* Formats the output of a block to its proper values
|
|
*
|
|
* @method outputBlockFormatter
|
|
* @param {Object} block object
|
|
* @returns {Object} block object
|
|
*/
|
|
var outputBlockFormatter = function(block) {
|
|
|
|
// transform to number
|
|
block.gasLimit = utils.toDecimal(block.gasLimit);
|
|
block.gasUsed = utils.toDecimal(block.gasUsed);
|
|
block.size = utils.toDecimal(block.size);
|
|
block.timestamp = utils.toDecimal(block.timestamp);
|
|
block.number = utils.toDecimal(block.number);
|
|
|
|
block.difficulty = utils.toBigNumber(block.difficulty);
|
|
block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
|
|
|
|
if (utils.isArray(block.transactions)) {
|
|
block.transactions.forEach(function(item){
|
|
if(!utils.isString(item))
|
|
return outputTransactionFormatter(item);
|
|
});
|
|
}
|
|
|
|
return block;
|
|
};
|
|
|
|
/**
|
|
* Formats the output of a log
|
|
*
|
|
* @method outputLogFormatter
|
|
* @param {Object} log object
|
|
* @returns {Object} log
|
|
*/
|
|
var outputLogFormatter = function(log) {
|
|
if (log === null) { // 'pending' && 'latest' filters are nulls
|
|
return null;
|
|
}
|
|
|
|
log.blockNumber = utils.toDecimal(log.blockNumber);
|
|
log.transactionIndex = utils.toDecimal(log.transactionIndex);
|
|
log.logIndex = utils.toDecimal(log.logIndex);
|
|
|
|
return log;
|
|
};
|
|
|
|
/**
|
|
* Formats the input of a whisper post and converts all values to HEX
|
|
*
|
|
* @method inputPostFormatter
|
|
* @param {Object} transaction object
|
|
* @returns {Object}
|
|
*/
|
|
var inputPostFormatter = function(post) {
|
|
|
|
post.payload = utils.toHex(post.payload);
|
|
post.ttl = utils.fromDecimal(post.ttl);
|
|
post.workToProve = utils.fromDecimal(post.workToProve);
|
|
post.priority = utils.fromDecimal(post.priority);
|
|
|
|
// fallback
|
|
if (!utils.isArray(post.topics)) {
|
|
post.topics = post.topics ? [post.topics] : [];
|
|
}
|
|
|
|
// format the following options
|
|
post.topics = post.topics.map(function(topic){
|
|
return utils.fromAscii(topic);
|
|
});
|
|
|
|
return post;
|
|
};
|
|
|
|
/**
|
|
* Formats the output of a received post message
|
|
*
|
|
* @method outputPostFormatter
|
|
* @param {Object}
|
|
* @returns {Object}
|
|
*/
|
|
var outputPostFormatter = function(post){
|
|
|
|
post.expiry = utils.toDecimal(post.expiry);
|
|
post.sent = utils.toDecimal(post.sent);
|
|
post.ttl = utils.toDecimal(post.ttl);
|
|
post.workProved = utils.toDecimal(post.workProved);
|
|
post.payloadRaw = post.payload;
|
|
post.payload = utils.toAscii(post.payload);
|
|
|
|
if (utils.isJson(post.payload)) {
|
|
post.payload = JSON.parse(post.payload);
|
|
}
|
|
|
|
// format the following options
|
|
if (!post.topics) {
|
|
post.topics = [];
|
|
}
|
|
post.topics = post.topics.map(function(topic){
|
|
return utils.toAscii(topic);
|
|
});
|
|
|
|
return post;
|
|
};
|
|
|
|
module.exports = {
|
|
inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
|
|
inputBlockNumberFormatter: inputBlockNumberFormatter,
|
|
inputTransactionFormatter: inputTransactionFormatter,
|
|
inputPostFormatter: inputPostFormatter,
|
|
outputBigNumberFormatter: outputBigNumberFormatter,
|
|
outputTransactionFormatter: outputTransactionFormatter,
|
|
outputBlockFormatter: outputBlockFormatter,
|
|
outputLogFormatter: outputLogFormatter,
|
|
outputPostFormatter: outputPostFormatter
|
|
};
|
|
|
|
|
|
},{"../utils/config":5,"../utils/utils":7}],18:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file function.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var web3 = require('../web3');
|
|
var coder = require('../solidity/coder');
|
|
var utils = require('../utils/utils');
|
|
var sha3 = require('../utils/sha3');
|
|
|
|
/**
|
|
* This prototype should be used to call/sendTransaction to solidity functions
|
|
*/
|
|
var SolidityFunction = function (json, address) {
|
|
this._inputTypes = json.inputs.map(function (i) {
|
|
return i.type;
|
|
});
|
|
this._outputTypes = json.outputs.map(function (i) {
|
|
return i.type;
|
|
});
|
|
this._constant = json.constant;
|
|
this._name = utils.transformToFullName(json);
|
|
this._address = address;
|
|
};
|
|
|
|
SolidityFunction.prototype.extractCallback = function (args) {
|
|
if (utils.isFunction(args[args.length - 1])) {
|
|
return args.pop(); // modify the args array!
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Should be used to create payload from arguments
|
|
*
|
|
* @method toPayload
|
|
* @param {Array} solidity function params
|
|
* @param {Object} optional payload options
|
|
*/
|
|
SolidityFunction.prototype.toPayload = function (args) {
|
|
var options = {};
|
|
if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
|
|
options = args[args.length - 1];
|
|
}
|
|
options.to = this._address;
|
|
options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
|
|
return options;
|
|
};
|
|
|
|
/**
|
|
* Should be used to get function signature
|
|
*
|
|
* @method signature
|
|
* @return {String} function signature
|
|
*/
|
|
SolidityFunction.prototype.signature = function () {
|
|
return sha3(this._name).slice(0, 8);
|
|
};
|
|
|
|
|
|
SolidityFunction.prototype.unpackOutput = function (output) {
|
|
if (!output) {
|
|
return;
|
|
}
|
|
|
|
output = output.length >= 2 ? output.slice(2) : output;
|
|
var result = coder.decodeParams(this._outputTypes, output);
|
|
return result.length === 1 ? result[0] : result;
|
|
};
|
|
|
|
/**
|
|
* Calls a contract function.
|
|
*
|
|
* @method call
|
|
* @param {...Object} Contract function arguments
|
|
* @param {function} If the last argument is a function, the contract function
|
|
* call will be asynchronous, and the callback will be passed the
|
|
* error and result.
|
|
* @return {String} output bytes
|
|
*/
|
|
SolidityFunction.prototype.call = function () {
|
|
var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
|
|
var callback = this.extractCallback(args);
|
|
var payload = this.toPayload(args);
|
|
|
|
if (!callback) {
|
|
var output = web3.eth.call(payload);
|
|
return this.unpackOutput(output);
|
|
}
|
|
|
|
var self = this;
|
|
web3.eth.call(payload, function (error, output) {
|
|
callback(error, self.unpackOutput(output));
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Should be used to sendTransaction to solidity function
|
|
*
|
|
* @method sendTransaction
|
|
* @param {Object} options
|
|
*/
|
|
SolidityFunction.prototype.sendTransaction = function () {
|
|
var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
|
|
var callback = this.extractCallback(args);
|
|
var payload = this.toPayload(args);
|
|
|
|
if (!callback) {
|
|
return web3.eth.sendTransaction(payload);
|
|
}
|
|
|
|
web3.eth.sendTransaction(payload, callback);
|
|
};
|
|
|
|
/**
|
|
* Should be used to estimateGas of solidity function
|
|
*
|
|
* @method estimateGas
|
|
* @param {Object} options
|
|
*/
|
|
SolidityFunction.prototype.estimateGas = function () {
|
|
var args = Array.prototype.slice.call(arguments);
|
|
var callback = this.extractCallback(args);
|
|
var payload = this.toPayload(args);
|
|
|
|
if (!callback) {
|
|
return web3.eth.estimateGas(payload);
|
|
}
|
|
|
|
web3.eth.estimateGas(payload, callback);
|
|
};
|
|
|
|
/**
|
|
* Should be used to get function display name
|
|
*
|
|
* @method displayName
|
|
* @return {String} display name of the function
|
|
*/
|
|
SolidityFunction.prototype.displayName = function () {
|
|
return utils.extractDisplayName(this._name);
|
|
};
|
|
|
|
/**
|
|
* Should be used to get function type name
|
|
*
|
|
* @method typeName
|
|
* @return {String} type name of the function
|
|
*/
|
|
SolidityFunction.prototype.typeName = function () {
|
|
return utils.extractTypeName(this._name);
|
|
};
|
|
|
|
/**
|
|
* Should be called to get rpc requests from solidity function
|
|
*
|
|
* @method request
|
|
* @returns {Object}
|
|
*/
|
|
SolidityFunction.prototype.request = function () {
|
|
var args = Array.prototype.slice.call(arguments);
|
|
var callback = this.extractCallback(args);
|
|
var payload = this.toPayload(args);
|
|
var format = this.unpackOutput.bind(this);
|
|
|
|
return {
|
|
callback: callback,
|
|
payload: payload,
|
|
format: format
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Should be called to execute function
|
|
*
|
|
* @method execute
|
|
*/
|
|
SolidityFunction.prototype.execute = function () {
|
|
var transaction = !this._constant;
|
|
|
|
// send transaction
|
|
if (transaction) {
|
|
return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
|
|
}
|
|
|
|
// call
|
|
return this.call.apply(this, Array.prototype.slice.call(arguments));
|
|
};
|
|
|
|
/**
|
|
* Should be called to attach function to contract
|
|
*
|
|
* @method attachToContract
|
|
* @param {Contract}
|
|
*/
|
|
SolidityFunction.prototype.attachToContract = function (contract) {
|
|
var execute = this.execute.bind(this);
|
|
execute.request = this.request.bind(this);
|
|
execute.call = this.call.bind(this);
|
|
execute.sendTransaction = this.sendTransaction.bind(this);
|
|
execute.estimateGas = this.estimateGas.bind(this);
|
|
var displayName = this.displayName();
|
|
if (!contract[displayName]) {
|
|
contract[displayName] = execute;
|
|
}
|
|
contract[displayName][this.typeName()] = execute; // circular!!!!
|
|
};
|
|
|
|
module.exports = SolidityFunction;
|
|
|
|
|
|
},{"../solidity/coder":1,"../utils/sha3":6,"../utils/utils":7,"../web3":9}],19:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file httpprovider.js
|
|
* @authors:
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* Marian Oancea <marian@ethdev.com>
|
|
* Fabian Vogelsteller <fabian@ethdev.com>
|
|
* @date 2014
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
|
|
var errors = require('./errors');
|
|
|
|
var HttpProvider = function (host) {
|
|
this.host = host || 'http://localhost:8545';
|
|
};
|
|
|
|
HttpProvider.prototype.send = function (payload) {
|
|
var request = new XMLHttpRequest();
|
|
|
|
request.open('POST', this.host, false);
|
|
|
|
try {
|
|
request.send(JSON.stringify(payload));
|
|
} catch(error) {
|
|
throw errors.InvalidConnection(this.host);
|
|
}
|
|
|
|
|
|
// check request.status
|
|
// TODO: throw an error here! it cannot silently fail!!!
|
|
//if (request.status !== 200) {
|
|
//return;
|
|
//}
|
|
|
|
var result = request.responseText;
|
|
|
|
try {
|
|
result = JSON.parse(result);
|
|
} catch(e) {
|
|
throw errors.InvalidResponse(result);
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
HttpProvider.prototype.sendAsync = function (payload, callback) {
|
|
var request = new XMLHttpRequest();
|
|
request.onreadystatechange = function() {
|
|
if (request.readyState === 4) {
|
|
var result = request.responseText;
|
|
var error = null;
|
|
|
|
try {
|
|
result = JSON.parse(result);
|
|
} catch(e) {
|
|
error = errors.InvalidResponse(result);
|
|
}
|
|
|
|
callback(error, result);
|
|
}
|
|
};
|
|
|
|
request.open('POST', this.host, true);
|
|
|
|
try {
|
|
request.send(JSON.stringify(payload));
|
|
} catch(error) {
|
|
callback(errors.InvalidConnection(this.host));
|
|
}
|
|
};
|
|
|
|
module.exports = HttpProvider;
|
|
|
|
|
|
},{"./errors":13,"xmlhttprequest":4}],20:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file icap.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var utils = require('../utils/utils');
|
|
|
|
/**
|
|
* This prototype should be used to extract necessary information from iban address
|
|
*
|
|
* @param {String} iban
|
|
*/
|
|
var ICAP = function (iban) {
|
|
this._iban = iban;
|
|
};
|
|
|
|
/**
|
|
* Should be called to check if icap is correct
|
|
*
|
|
* @method isValid
|
|
* @returns {Boolean} true if it is, otherwise false
|
|
*/
|
|
ICAP.prototype.isValid = function () {
|
|
return utils.isIBAN(this._iban);
|
|
};
|
|
|
|
/**
|
|
* Should be called to check if iban number is direct
|
|
*
|
|
* @method isDirect
|
|
* @returns {Boolean} true if it is, otherwise false
|
|
*/
|
|
ICAP.prototype.isDirect = function () {
|
|
return this._iban.length === 34;
|
|
};
|
|
|
|
/**
|
|
* Should be called to check if iban number if indirect
|
|
*
|
|
* @method isIndirect
|
|
* @returns {Boolean} true if it is, otherwise false
|
|
*/
|
|
ICAP.prototype.isIndirect = function () {
|
|
return this._iban.length === 20;
|
|
};
|
|
|
|
/**
|
|
* Should be called to get iban checksum
|
|
* Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
|
|
*
|
|
* @method checksum
|
|
* @returns {String} checksum
|
|
*/
|
|
ICAP.prototype.checksum = function () {
|
|
return this._iban.substr(2, 2);
|
|
};
|
|
|
|
/**
|
|
* Should be called to get institution identifier
|
|
* eg. XREG
|
|
*
|
|
* @method institution
|
|
* @returns {String} institution identifier
|
|
*/
|
|
ICAP.prototype.institution = function () {
|
|
return this.isIndirect() ? this._iban.substr(7, 4) : '';
|
|
};
|
|
|
|
/**
|
|
* Should be called to get client identifier within institution
|
|
* eg. GAVOFYORK
|
|
*
|
|
* @method client
|
|
* @returns {String} client identifier
|
|
*/
|
|
ICAP.prototype.client = function () {
|
|
return this.isIndirect() ? this._iban.substr(11) : '';
|
|
};
|
|
|
|
/**
|
|
* Should be called to get client direct address
|
|
*
|
|
* @method address
|
|
* @returns {String} client direct address
|
|
*/
|
|
ICAP.prototype.address = function () {
|
|
return this.isDirect() ? this._iban.substr(4) : '';
|
|
};
|
|
|
|
module.exports = ICAP;
|
|
|
|
|
|
},{"../utils/utils":7}],21:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file jsonrpc.js
|
|
* @authors:
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var Jsonrpc = function () {
|
|
// singleton pattern
|
|
if (arguments.callee._singletonInstance) {
|
|
return arguments.callee._singletonInstance;
|
|
}
|
|
arguments.callee._singletonInstance = this;
|
|
|
|
this.messageId = 1;
|
|
};
|
|
|
|
/**
|
|
* @return {Jsonrpc} singleton
|
|
*/
|
|
Jsonrpc.getInstance = function () {
|
|
var instance = new Jsonrpc();
|
|
return instance;
|
|
};
|
|
|
|
/**
|
|
* Should be called to valid json create payload object
|
|
*
|
|
* @method toPayload
|
|
* @param {Function} method of jsonrpc call, required
|
|
* @param {Array} params, an array of method params, optional
|
|
* @returns {Object} valid jsonrpc payload object
|
|
*/
|
|
Jsonrpc.prototype.toPayload = function (method, params) {
|
|
if (!method)
|
|
console.error('jsonrpc method should be specified!');
|
|
|
|
return {
|
|
jsonrpc: '2.0',
|
|
method: method,
|
|
params: params || [],
|
|
id: this.messageId++
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Should be called to check if jsonrpc response is valid
|
|
*
|
|
* @method isValidResponse
|
|
* @param {Object}
|
|
* @returns {Boolean} true if response is valid, otherwise false
|
|
*/
|
|
Jsonrpc.prototype.isValidResponse = function (response) {
|
|
return !!response &&
|
|
!response.error &&
|
|
response.jsonrpc === '2.0' &&
|
|
typeof response.id === 'number' &&
|
|
response.result !== undefined; // only undefined is not valid json object
|
|
};
|
|
|
|
/**
|
|
* Should be called to create batch payload object
|
|
*
|
|
* @method toBatchPayload
|
|
* @param {Array} messages, an array of objects with method (required) and params (optional) fields
|
|
* @returns {Array} batch payload
|
|
*/
|
|
Jsonrpc.prototype.toBatchPayload = function (messages) {
|
|
var self = this;
|
|
return messages.map(function (message) {
|
|
return self.toPayload(message.method, message.params);
|
|
});
|
|
};
|
|
|
|
module.exports = Jsonrpc;
|
|
|
|
|
|
},{}],22:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file method.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var RequestManager = require('./requestmanager');
|
|
var utils = require('../utils/utils');
|
|
var errors = require('./errors');
|
|
|
|
var Method = function (options) {
|
|
this.name = options.name;
|
|
this.call = options.call;
|
|
this.params = options.params || 0;
|
|
this.inputFormatter = options.inputFormatter;
|
|
this.outputFormatter = options.outputFormatter;
|
|
};
|
|
|
|
/**
|
|
* Should be used to determine name of the jsonrpc method based on arguments
|
|
*
|
|
* @method getCall
|
|
* @param {Array} arguments
|
|
* @return {String} name of jsonrpc method
|
|
*/
|
|
Method.prototype.getCall = function (args) {
|
|
return utils.isFunction(this.call) ? this.call(args) : this.call;
|
|
};
|
|
|
|
/**
|
|
* Should be used to extract callback from array of arguments. Modifies input param
|
|
*
|
|
* @method extractCallback
|
|
* @param {Array} arguments
|
|
* @return {Function|Null} callback, if exists
|
|
*/
|
|
Method.prototype.extractCallback = function (args) {
|
|
if (utils.isFunction(args[args.length - 1])) {
|
|
return args.pop(); // modify the args array!
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Should be called to check if the number of arguments is correct
|
|
*
|
|
* @method validateArgs
|
|
* @param {Array} arguments
|
|
* @throws {Error} if it is not
|
|
*/
|
|
Method.prototype.validateArgs = function (args) {
|
|
if (args.length !== this.params) {
|
|
throw errors.InvalidNumberOfParams();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Should be called to format input args of method
|
|
*
|
|
* @method formatInput
|
|
* @param {Array}
|
|
* @return {Array}
|
|
*/
|
|
Method.prototype.formatInput = function (args) {
|
|
if (!this.inputFormatter) {
|
|
return args;
|
|
}
|
|
|
|
return this.inputFormatter.map(function (formatter, index) {
|
|
return formatter ? formatter(args[index]) : args[index];
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Should be called to format output(result) of method
|
|
*
|
|
* @method formatOutput
|
|
* @param {Object}
|
|
* @return {Object}
|
|
*/
|
|
Method.prototype.formatOutput = function (result) {
|
|
return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;
|
|
};
|
|
|
|
/**
|
|
* Should attach function to method
|
|
*
|
|
* @method attachToObject
|
|
* @param {Object}
|
|
* @param {Function}
|
|
*/
|
|
Method.prototype.attachToObject = function (obj) {
|
|
var func = this.send.bind(this);
|
|
func.request = this.request.bind(this);
|
|
func.call = this.call; // that's ugly. filter.js uses it
|
|
var name = this.name.split('.');
|
|
if (name.length > 1) {
|
|
obj[name[0]] = obj[name[0]] || {};
|
|
obj[name[0]][name[1]] = func;
|
|
} else {
|
|
obj[name[0]] = func;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Should create payload from given input args
|
|
*
|
|
* @method toPayload
|
|
* @param {Array} args
|
|
* @return {Object}
|
|
*/
|
|
Method.prototype.toPayload = function (args) {
|
|
var call = this.getCall(args);
|
|
var callback = this.extractCallback(args);
|
|
var params = this.formatInput(args);
|
|
this.validateArgs(params);
|
|
|
|
return {
|
|
method: call,
|
|
params: params,
|
|
callback: callback
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Should be called to create pure JSONRPC request which can be used in batch request
|
|
*
|
|
* @method request
|
|
* @param {...} params
|
|
* @return {Object} jsonrpc request
|
|
*/
|
|
Method.prototype.request = function () {
|
|
var payload = this.toPayload(Array.prototype.slice.call(arguments));
|
|
payload.format = this.formatOutput.bind(this);
|
|
return payload;
|
|
};
|
|
|
|
/**
|
|
* Should send request to the API
|
|
*
|
|
* @method send
|
|
* @param list of params
|
|
* @return result
|
|
*/
|
|
Method.prototype.send = function () {
|
|
var payload = this.toPayload(Array.prototype.slice.call(arguments));
|
|
if (payload.callback) {
|
|
var self = this;
|
|
return RequestManager.getInstance().sendAsync(payload, function (err, result) {
|
|
payload.callback(err, self.formatOutput(result));
|
|
});
|
|
}
|
|
return this.formatOutput(RequestManager.getInstance().send(payload));
|
|
};
|
|
|
|
module.exports = Method;
|
|
|
|
|
|
},{"../utils/utils":7,"./errors":13,"./requestmanager":27}],23:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file namereg.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var contract = require('./contract');
|
|
|
|
var address = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
|
|
|
|
var abi = [
|
|
{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"name","outputs":[{"name":"o_name","type":"bytes32"}],"type":"function"},
|
|
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},
|
|
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"content","outputs":[{"name":"","type":"bytes32"}],"type":"function"},
|
|
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"addr","outputs":[{"name":"","type":"address"}],"type":"function"},
|
|
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserve","outputs":[],"type":"function"},
|
|
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"subRegistrar","outputs":[{"name":"o_subRegistrar","type":"address"}],"type":"function"},
|
|
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"transfer","outputs":[],"type":"function"},
|
|
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_registrar","type":"address"}],"name":"setSubRegistrar","outputs":[],"type":"function"},
|
|
{"constant":false,"inputs":[],"name":"Registrar","outputs":[],"type":"function"},
|
|
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_a","type":"address"},{"name":"_primary","type":"bool"}],"name":"setAddress","outputs":[],"type":"function"},
|
|
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_content","type":"bytes32"}],"name":"setContent","outputs":[],"type":"function"},
|
|
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"disown","outputs":[],"type":"function"},
|
|
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"register","outputs":[{"name":"","type":"address"}],"type":"function"},
|
|
{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"}],"name":"Changed","type":"event"},
|
|
{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"addr","type":"address"}],"name":"PrimaryChanged","type":"event"}
|
|
];
|
|
|
|
module.exports = contract(abi).at(address);
|
|
|
|
|
|
},{"./contract":11}],24:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file eth.js
|
|
* @authors:
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var utils = require('../utils/utils');
|
|
var Property = require('./property');
|
|
|
|
/// @returns an array of objects describing web3.eth api methods
|
|
var methods = [
|
|
];
|
|
|
|
/// @returns an array of objects describing web3.eth api properties
|
|
var properties = [
|
|
new Property({
|
|
name: 'listening',
|
|
getter: 'net_listening'
|
|
}),
|
|
new Property({
|
|
name: 'peerCount',
|
|
getter: 'net_peerCount',
|
|
outputFormatter: utils.toDecimal
|
|
})
|
|
];
|
|
|
|
|
|
module.exports = {
|
|
methods: methods,
|
|
properties: properties
|
|
};
|
|
|
|
|
|
},{"../utils/utils":7,"./property":25}],25:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file property.js
|
|
* @author Fabian Vogelsteller <fabian@frozeman.de>
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var RequestManager = require('./requestmanager');
|
|
|
|
var Property = function (options) {
|
|
this.name = options.name;
|
|
this.getter = options.getter;
|
|
this.setter = options.setter;
|
|
this.outputFormatter = options.outputFormatter;
|
|
this.inputFormatter = options.inputFormatter;
|
|
};
|
|
|
|
/**
|
|
* Should be called to format input args of method
|
|
*
|
|
* @method formatInput
|
|
* @param {Array}
|
|
* @return {Array}
|
|
*/
|
|
Property.prototype.formatInput = function (arg) {
|
|
return this.inputFormatter ? this.inputFormatter(arg) : arg;
|
|
};
|
|
|
|
/**
|
|
* Should be called to format output(result) of method
|
|
*
|
|
* @method formatOutput
|
|
* @param {Object}
|
|
* @return {Object}
|
|
*/
|
|
Property.prototype.formatOutput = function (result) {
|
|
return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;
|
|
};
|
|
|
|
/**
|
|
* Should attach function to method
|
|
*
|
|
* @method attachToObject
|
|
* @param {Object}
|
|
* @param {Function}
|
|
*/
|
|
Property.prototype.attachToObject = function (obj) {
|
|
var proto = {
|
|
get: this.get.bind(this),
|
|
};
|
|
|
|
var names = this.name.split('.');
|
|
var name = names[0];
|
|
if (names.length > 1) {
|
|
obj[names[0]] = obj[names[0]] || {};
|
|
obj = obj[names[0]];
|
|
name = names[1];
|
|
}
|
|
|
|
Object.defineProperty(obj, name, proto);
|
|
|
|
var toAsyncName = function (prefix, name) {
|
|
return prefix + name.charAt(0).toUpperCase() + name.slice(1);
|
|
};
|
|
|
|
obj[toAsyncName('get', name)] = this.getAsync.bind(this);
|
|
};
|
|
|
|
/**
|
|
* Should be used to get value of the property
|
|
*
|
|
* @method get
|
|
* @return {Object} value of the property
|
|
*/
|
|
Property.prototype.get = function () {
|
|
return this.formatOutput(RequestManager.getInstance().send({
|
|
method: this.getter
|
|
}));
|
|
};
|
|
|
|
/**
|
|
* Should be used to asynchrounously get value of property
|
|
*
|
|
* @method getAsync
|
|
* @param {Function}
|
|
*/
|
|
Property.prototype.getAsync = function (callback) {
|
|
var self = this;
|
|
RequestManager.getInstance().sendAsync({
|
|
method: this.getter
|
|
}, function (err, result) {
|
|
if (err) {
|
|
return callback(err);
|
|
}
|
|
callback(err, self.formatOutput(result));
|
|
});
|
|
};
|
|
|
|
module.exports = Property;
|
|
|
|
|
|
},{"./requestmanager":27}],26:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file qtsync.js
|
|
* @authors:
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* Marian Oancea <marian@ethdev.com>
|
|
* @date 2014
|
|
*/
|
|
|
|
var QtSyncProvider = function () {
|
|
};
|
|
|
|
QtSyncProvider.prototype.send = function (payload) {
|
|
var result = navigator.qt.callMethod(JSON.stringify(payload));
|
|
return JSON.parse(result);
|
|
};
|
|
|
|
module.exports = QtSyncProvider;
|
|
|
|
|
|
},{}],27:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file requestmanager.js
|
|
* @author Jeffrey Wilcke <jeff@ethdev.com>
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @author Marian Oancea <marian@ethdev.com>
|
|
* @author Fabian Vogelsteller <fabian@ethdev.com>
|
|
* @author Gav Wood <g@ethdev.com>
|
|
* @date 2014
|
|
*/
|
|
|
|
var Jsonrpc = require('./jsonrpc');
|
|
var utils = require('../utils/utils');
|
|
var c = require('../utils/config');
|
|
var errors = require('./errors');
|
|
|
|
/**
|
|
* It's responsible for passing messages to providers
|
|
* It's also responsible for polling the ethereum node for incoming messages
|
|
* Default poll timeout is 1 second
|
|
* Singleton
|
|
*/
|
|
var RequestManager = function (provider) {
|
|
// singleton pattern
|
|
if (arguments.callee._singletonInstance) {
|
|
return arguments.callee._singletonInstance;
|
|
}
|
|
arguments.callee._singletonInstance = this;
|
|
|
|
this.provider = provider;
|
|
this.polls = [];
|
|
this.timeout = null;
|
|
this.poll();
|
|
};
|
|
|
|
/**
|
|
* @return {RequestManager} singleton
|
|
*/
|
|
RequestManager.getInstance = function () {
|
|
var instance = new RequestManager();
|
|
return instance;
|
|
};
|
|
|
|
/**
|
|
* Should be used to synchronously send request
|
|
*
|
|
* @method send
|
|
* @param {Object} data
|
|
* @return {Object}
|
|
*/
|
|
RequestManager.prototype.send = function (data) {
|
|
if (!this.provider) {
|
|
console.error(errors.InvalidProvider());
|
|
return null;
|
|
}
|
|
|
|
var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);
|
|
var result = this.provider.send(payload);
|
|
|
|
if (!Jsonrpc.getInstance().isValidResponse(result)) {
|
|
throw errors.InvalidResponse(result);
|
|
}
|
|
|
|
return result.result;
|
|
};
|
|
|
|
/**
|
|
* Should be used to asynchronously send request
|
|
*
|
|
* @method sendAsync
|
|
* @param {Object} data
|
|
* @param {Function} callback
|
|
*/
|
|
RequestManager.prototype.sendAsync = function (data, callback) {
|
|
if (!this.provider) {
|
|
return callback(errors.InvalidProvider());
|
|
}
|
|
|
|
var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);
|
|
this.provider.sendAsync(payload, function (err, result) {
|
|
if (err) {
|
|
return callback(err);
|
|
}
|
|
|
|
if (!Jsonrpc.getInstance().isValidResponse(result)) {
|
|
return callback(errors.InvalidResponse(result));
|
|
}
|
|
|
|
callback(null, result.result);
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Should be called to asynchronously send batch request
|
|
*
|
|
* @method sendBatch
|
|
* @param {Array} batch data
|
|
* @param {Function} callback
|
|
*/
|
|
RequestManager.prototype.sendBatch = function (data, callback) {
|
|
if (!this.provider) {
|
|
return callback(errors.InvalidProvider());
|
|
}
|
|
|
|
var payload = Jsonrpc.getInstance().toBatchPayload(data);
|
|
|
|
this.provider.sendAsync(payload, function (err, results) {
|
|
if (err) {
|
|
return callback(err);
|
|
}
|
|
|
|
if (!utils.isArray(results)) {
|
|
return callback(errors.InvalidResponse(results));
|
|
}
|
|
|
|
callback(err, results);
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Should be used to set provider of request manager
|
|
*
|
|
* @method setProvider
|
|
* @param {Object}
|
|
*/
|
|
RequestManager.prototype.setProvider = function (p) {
|
|
this.provider = p;
|
|
};
|
|
|
|
/*jshint maxparams:4 */
|
|
|
|
/**
|
|
* Should be used to start polling
|
|
*
|
|
* @method startPolling
|
|
* @param {Object} data
|
|
* @param {Number} pollId
|
|
* @param {Function} callback
|
|
* @param {Function} uninstall
|
|
*
|
|
* @todo cleanup number of params
|
|
*/
|
|
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
|
this.polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
|
|
};
|
|
/*jshint maxparams:3 */
|
|
|
|
/**
|
|
* Should be used to stop polling for filter with given id
|
|
*
|
|
* @method stopPolling
|
|
* @param {Number} pollId
|
|
*/
|
|
RequestManager.prototype.stopPolling = function (pollId) {
|
|
for (var i = this.polls.length; i--;) {
|
|
var poll = this.polls[i];
|
|
if (poll.id === pollId) {
|
|
this.polls.splice(i, 1);
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Should be called to reset polling mechanism of request manager
|
|
*
|
|
* @method reset
|
|
*/
|
|
RequestManager.prototype.reset = function () {
|
|
this.polls.forEach(function (poll) {
|
|
poll.uninstall(poll.id);
|
|
});
|
|
this.polls = [];
|
|
|
|
if (this.timeout) {
|
|
clearTimeout(this.timeout);
|
|
this.timeout = null;
|
|
}
|
|
this.poll();
|
|
};
|
|
|
|
/**
|
|
* Should be called to poll for changes on filter with given id
|
|
*
|
|
* @method poll
|
|
*/
|
|
RequestManager.prototype.poll = function () {
|
|
this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
|
|
|
|
if (!this.polls.length) {
|
|
return;
|
|
}
|
|
|
|
if (!this.provider) {
|
|
console.error(errors.InvalidProvider());
|
|
return;
|
|
}
|
|
|
|
var payload = Jsonrpc.getInstance().toBatchPayload(this.polls.map(function (data) {
|
|
return data.data;
|
|
}));
|
|
|
|
var self = this;
|
|
this.provider.sendAsync(payload, function (error, results) {
|
|
// TODO: console log?
|
|
if (error) {
|
|
return;
|
|
}
|
|
|
|
if (!utils.isArray(results)) {
|
|
throw errors.InvalidResponse(results);
|
|
}
|
|
|
|
results.map(function (result, index) {
|
|
result.callback = self.polls[index].callback;
|
|
return result;
|
|
}).filter(function (result) {
|
|
var valid = Jsonrpc.getInstance().isValidResponse(result);
|
|
if (!valid) {
|
|
result.callback(errors.InvalidResponse(result));
|
|
}
|
|
return valid;
|
|
}).filter(function (result) {
|
|
return utils.isArray(result.result) && result.result.length > 0;
|
|
}).forEach(function (result) {
|
|
result.callback(null, result.result);
|
|
});
|
|
});
|
|
};
|
|
|
|
module.exports = RequestManager;
|
|
|
|
|
|
},{"../utils/config":5,"../utils/utils":7,"./errors":13,"./jsonrpc":21}],28:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file shh.js
|
|
* @authors:
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var Method = require('./method');
|
|
var formatters = require('./formatters');
|
|
|
|
var post = new Method({
|
|
name: 'post',
|
|
call: 'shh_post',
|
|
params: 1,
|
|
inputFormatter: [formatters.inputPostFormatter]
|
|
});
|
|
|
|
var newIdentity = new Method({
|
|
name: 'newIdentity',
|
|
call: 'shh_newIdentity',
|
|
params: 0
|
|
});
|
|
|
|
var hasIdentity = new Method({
|
|
name: 'hasIdentity',
|
|
call: 'shh_hasIdentity',
|
|
params: 1
|
|
});
|
|
|
|
var newGroup = new Method({
|
|
name: 'newGroup',
|
|
call: 'shh_newGroup',
|
|
params: 0
|
|
});
|
|
|
|
var addToGroup = new Method({
|
|
name: 'addToGroup',
|
|
call: 'shh_addToGroup',
|
|
params: 0
|
|
});
|
|
|
|
var methods = [
|
|
post,
|
|
newIdentity,
|
|
hasIdentity,
|
|
newGroup,
|
|
addToGroup
|
|
];
|
|
|
|
module.exports = {
|
|
methods: methods
|
|
};
|
|
|
|
|
|
},{"./formatters":17,"./method":22}],29:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/**
|
|
* @file transfer.js
|
|
* @author Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var web3 = require('../web3');
|
|
var ICAP = require('./icap');
|
|
var namereg = require('./namereg');
|
|
var contract = require('./contract');
|
|
|
|
/**
|
|
* Should be used to make ICAP transfer
|
|
*
|
|
* @method transfer
|
|
* @param {String} iban number
|
|
* @param {String} from (address)
|
|
* @param {Value} value to be tranfered
|
|
* @param {Function} callback, callback
|
|
*/
|
|
var transfer = function (from, iban, value, callback) {
|
|
var icap = new ICAP(iban);
|
|
if (!icap.isValid()) {
|
|
throw new Error('invalid iban address');
|
|
}
|
|
|
|
if (icap.isDirect()) {
|
|
return transferToAddress(from, icap.address(), value, callback);
|
|
}
|
|
|
|
if (!callback) {
|
|
var address = namereg.addr(icap.institution());
|
|
return deposit(from, address, value, icap.client());
|
|
}
|
|
|
|
namereg.addr(icap.insitution(), function (err, address) {
|
|
return deposit(from, address, value, icap.client(), callback);
|
|
});
|
|
|
|
};
|
|
|
|
/**
|
|
* Should be used to transfer funds to certain address
|
|
*
|
|
* @method transferToAddress
|
|
* @param {String} address
|
|
* @param {String} from (address)
|
|
* @param {Value} value to be tranfered
|
|
* @param {Function} callback, callback
|
|
*/
|
|
var transferToAddress = function (from, address, value, callback) {
|
|
return web3.eth.sendTransaction({
|
|
address: address,
|
|
from: from,
|
|
value: value
|
|
}, callback);
|
|
};
|
|
|
|
/**
|
|
* Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
|
|
*
|
|
* @method deposit
|
|
* @param {String} address
|
|
* @param {String} from (address)
|
|
* @param {Value} value to be tranfered
|
|
* @param {String} client unique identifier
|
|
* @param {Function} callback, callback
|
|
*/
|
|
var deposit = function (from, address, value, client, callback) {
|
|
var abi = [{"constant":false,"inputs":[{"name":"name","type":"bytes32"}],"name":"deposit","outputs":[],"type":"function"}];
|
|
return contract(abi).at(address).deposit(client, {
|
|
from: from,
|
|
value: value
|
|
}, callback);
|
|
};
|
|
|
|
module.exports = transfer;
|
|
|
|
|
|
},{"../web3":9,"./contract":11,"./icap":20,"./namereg":23}],30:[function(require,module,exports){
|
|
/*
|
|
This file is part of ethereum.js.
|
|
|
|
ethereum.js is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ethereum.js is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file watches.js
|
|
* @authors:
|
|
* Marek Kotewicz <marek@ethdev.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
var Method = require('./method');
|
|
|
|
/// @returns an array of objects describing web3.eth.filter api methods
|
|
var eth = function () {
|
|
var newFilterCall = function (args) {
|
|
var type = args[0];
|
|
|
|
switch(type) {
|
|
case 'latest':
|
|
args.pop();
|
|
this.params = 0;
|
|
return 'eth_newBlockFilter';
|
|
case 'pending':
|
|
args.pop();
|
|
this.params = 0;
|
|
return 'eth_newPendingTransactionFilter';
|
|
default:
|
|
return 'eth_newFilter';
|
|
}
|
|
};
|
|
|
|
var newFilter = new Method({
|
|
name: 'newFilter',
|
|
call: newFilterCall,
|
|
params: 1
|
|
});
|
|
|
|
var uninstallFilter = new Method({
|
|
name: 'uninstallFilter',
|
|
call: 'eth_uninstallFilter',
|
|
params: 1
|
|
});
|
|
|
|
var getLogs = new Method({
|
|
name: 'getLogs',
|
|
call: 'eth_getFilterLogs',
|
|
params: 1
|
|
});
|
|
|
|
var poll = new Method({
|
|
name: 'poll',
|
|
call: 'eth_getFilterChanges',
|
|
params: 1
|
|
});
|
|
|
|
return [
|
|
newFilter,
|
|
uninstallFilter,
|
|
getLogs,
|
|
poll
|
|
];
|
|
};
|
|
|
|
/// @returns an array of objects describing web3.shh.watch api methods
|
|
var shh = function () {
|
|
var newFilter = new Method({
|
|
name: 'newFilter',
|
|
call: 'shh_newFilter',
|
|
params: 1
|
|
});
|
|
|
|
var uninstallFilter = new Method({
|
|
name: 'uninstallFilter',
|
|
call: 'shh_uninstallFilter',
|
|
params: 1
|
|
});
|
|
|
|
var getLogs = new Method({
|
|
name: 'getLogs',
|
|
call: 'shh_getMessages',
|
|
params: 1
|
|
});
|
|
|
|
var poll = new Method({
|
|
name: 'poll',
|
|
call: 'shh_getFilterChanges',
|
|
params: 1
|
|
});
|
|
|
|
return [
|
|
newFilter,
|
|
uninstallFilter,
|
|
getLogs,
|
|
poll
|
|
];
|
|
};
|
|
|
|
module.exports = {
|
|
eth: eth,
|
|
shh: shh
|
|
};
|
|
|
|
|
|
},{"./method":22}],31:[function(require,module,exports){
|
|
|
|
},{}],32:[function(require,module,exports){
|
|
;(function (root, factory) {
|
|
if (typeof exports === "object") {
|
|
// CommonJS
|
|
module.exports = exports = factory();
|
|
}
|
|
else if (typeof define === "function" && define.amd) {
|
|
// AMD
|
|
define([], factory);
|
|
}
|
|
else {
|
|
// Global (browser)
|
|
root.CryptoJS = factory();
|
|
}
|
|
}(this, function () {
|
|
|
|
/**
|
|
* CryptoJS core components.
|
|
*/
|
|
var CryptoJS = CryptoJS || (function (Math, undefined) {
|
|
/**
|
|
* CryptoJS namespace.
|
|
*/
|
|
var C = {};
|
|
|
|
/**
|
|
* Library namespace.
|
|
*/
|
|
var C_lib = C.lib = {};
|
|
|
|
/**
|
|
* Base object for prototypal inheritance.
|
|
*/
|
|
var Base = C_lib.Base = (function () {
|
|
function F() {}
|
|
|
|
return {
|
|
/**
|
|
* Creates a new object that inherits from this object.
|
|
*
|
|
* @param {Object} overrides Properties to copy into the new object.
|
|
*
|
|
* @return {Object} The new object.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var MyType = CryptoJS.lib.Base.extend({
|
|
* field: 'value',
|
|
*
|
|
* method: function () {
|
|
* }
|
|
* });
|
|
*/
|
|
extend: function (overrides) {
|
|
// Spawn
|
|
F.prototype = this;
|
|
var subtype = new F();
|
|
|
|
// Augment
|
|
if (overrides) {
|
|
subtype.mixIn(overrides);
|
|
}
|
|
|
|
// Create default initializer
|
|
if (!subtype.hasOwnProperty('init')) {
|
|
subtype.init = function () {
|
|
subtype.$super.init.apply(this, arguments);
|
|
};
|
|
}
|
|
|
|
// Initializer's prototype is the subtype object
|
|
subtype.init.prototype = subtype;
|
|
|
|
// Reference supertype
|
|
subtype.$super = this;
|
|
|
|
return subtype;
|
|
},
|
|
|
|
/**
|
|
* Extends this object and runs the init method.
|
|
* Arguments to create() will be passed to init().
|
|
*
|
|
* @return {Object} The new object.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var instance = MyType.create();
|
|
*/
|
|
create: function () {
|
|
var instance = this.extend();
|
|
instance.init.apply(instance, arguments);
|
|
|
|
return instance;
|
|
},
|
|
|
|
/**
|
|
* Initializes a newly created object.
|
|
* Override this method to add some logic when your objects are created.
|
|
*
|
|
* @example
|
|
*
|
|
* var MyType = CryptoJS.lib.Base.extend({
|
|
* init: function () {
|
|
* // ...
|
|
* }
|
|
* });
|
|
*/
|
|
init: function () {
|
|
},
|
|
|
|
/**
|
|
* Copies properties into this object.
|
|
*
|
|
* @param {Object} properties The properties to mix in.
|
|
*
|
|
* @example
|
|
*
|
|
* MyType.mixIn({
|
|
* field: 'value'
|
|
* });
|
|
*/
|
|
mixIn: function (properties) {
|
|
for (var propertyName in properties) {
|
|
if (properties.hasOwnProperty(propertyName)) {
|
|
this[propertyName] = properties[propertyName];
|
|
}
|
|
}
|
|
|
|
// IE won't copy toString using the loop above
|
|
if (properties.hasOwnProperty('toString')) {
|
|
this.toString = properties.toString;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Creates a copy of this object.
|
|
*
|
|
* @return {Object} The clone.
|
|
*
|
|
* @example
|
|
*
|
|
* var clone = instance.clone();
|
|
*/
|
|
clone: function () {
|
|
return this.init.prototype.extend(this);
|
|
}
|
|
};
|
|
}());
|
|
|
|
/**
|
|
* An array of 32-bit words.
|
|
*
|
|
* @property {Array} words The array of 32-bit words.
|
|
* @property {number} sigBytes The number of significant bytes in this word array.
|
|
*/
|
|
var WordArray = C_lib.WordArray = Base.extend({
|
|
/**
|
|
* Initializes a newly created word array.
|
|
*
|
|
* @param {Array} words (Optional) An array of 32-bit words.
|
|
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.lib.WordArray.create();
|
|
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
|
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
|
*/
|
|
init: function (words, sigBytes) {
|
|
words = this.words = words || [];
|
|
|
|
if (sigBytes != undefined) {
|
|
this.sigBytes = sigBytes;
|
|
} else {
|
|
this.sigBytes = words.length * 4;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Converts this word array to a string.
|
|
*
|
|
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
|
*
|
|
* @return {string} The stringified word array.
|
|
*
|
|
* @example
|
|
*
|
|
* var string = wordArray + '';
|
|
* var string = wordArray.toString();
|
|
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
|
*/
|
|
toString: function (encoder) {
|
|
return (encoder || Hex).stringify(this);
|
|
},
|
|
|
|
/**
|
|
* Concatenates a word array to this word array.
|
|
*
|
|
* @param {WordArray} wordArray The word array to append.
|
|
*
|
|
* @return {WordArray} This word array.
|
|
*
|
|
* @example
|
|
*
|
|
* wordArray1.concat(wordArray2);
|
|
*/
|
|
concat: function (wordArray) {
|
|
// Shortcuts
|
|
var thisWords = this.words;
|
|
var thatWords = wordArray.words;
|
|
var thisSigBytes = this.sigBytes;
|
|
var thatSigBytes = wordArray.sigBytes;
|
|
|
|
// Clamp excess bits
|
|
this.clamp();
|
|
|
|
// Concat
|
|
if (thisSigBytes % 4) {
|
|
// Copy one byte at a time
|
|
for (var i = 0; i < thatSigBytes; i++) {
|
|
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
|
|
}
|
|
} else {
|
|
// Copy one word at a time
|
|
for (var i = 0; i < thatSigBytes; i += 4) {
|
|
thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
|
|
}
|
|
}
|
|
this.sigBytes += thatSigBytes;
|
|
|
|
// Chainable
|
|
return this;
|
|
},
|
|
|
|
/**
|
|
* Removes insignificant bits.
|
|
*
|
|
* @example
|
|
*
|
|
* wordArray.clamp();
|
|
*/
|
|
clamp: function () {
|
|
// Shortcuts
|
|
var words = this.words;
|
|
var sigBytes = this.sigBytes;
|
|
|
|
// Clamp
|
|
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
|
|
words.length = Math.ceil(sigBytes / 4);
|
|
},
|
|
|
|
/**
|
|
* Creates a copy of this word array.
|
|
*
|
|
* @return {WordArray} The clone.
|
|
*
|
|
* @example
|
|
*
|
|
* var clone = wordArray.clone();
|
|
*/
|
|
clone: function () {
|
|
var clone = Base.clone.call(this);
|
|
clone.words = this.words.slice(0);
|
|
|
|
return clone;
|
|
},
|
|
|
|
/**
|
|
* Creates a word array filled with random bytes.
|
|
*
|
|
* @param {number} nBytes The number of random bytes to generate.
|
|
*
|
|
* @return {WordArray} The random word array.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
|
*/
|
|
random: function (nBytes) {
|
|
var words = [];
|
|
|
|
var r = (function (m_w) {
|
|
var m_w = m_w;
|
|
var m_z = 0x3ade68b1;
|
|
var mask = 0xffffffff;
|
|
|
|
return function () {
|
|
m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
|
|
m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
|
|
var result = ((m_z << 0x10) + m_w) & mask;
|
|
result /= 0x100000000;
|
|
result += 0.5;
|
|
return result * (Math.random() > .5 ? 1 : -1);
|
|
}
|
|
});
|
|
|
|
for (var i = 0, rcache; i < nBytes; i += 4) {
|
|
var _r = r((rcache || Math.random()) * 0x100000000);
|
|
|
|
rcache = _r() * 0x3ade67b7;
|
|
words.push((_r() * 0x100000000) | 0);
|
|
}
|
|
|
|
return new WordArray.init(words, nBytes);
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Encoder namespace.
|
|
*/
|
|
var C_enc = C.enc = {};
|
|
|
|
/**
|
|
* Hex encoding strategy.
|
|
*/
|
|
var Hex = C_enc.Hex = {
|
|
/**
|
|
* Converts a word array to a hex string.
|
|
*
|
|
* @param {WordArray} wordArray The word array.
|
|
*
|
|
* @return {string} The hex string.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
|
*/
|
|
stringify: function (wordArray) {
|
|
// Shortcuts
|
|
var words = wordArray.words;
|
|
var sigBytes = wordArray.sigBytes;
|
|
|
|
// Convert
|
|
var hexChars = [];
|
|
for (var i = 0; i < sigBytes; i++) {
|
|
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
hexChars.push((bite >>> 4).toString(16));
|
|
hexChars.push((bite & 0x0f).toString(16));
|
|
}
|
|
|
|
return hexChars.join('');
|
|
},
|
|
|
|
/**
|
|
* Converts a hex string to a word array.
|
|
*
|
|
* @param {string} hexStr The hex string.
|
|
*
|
|
* @return {WordArray} The word array.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
|
*/
|
|
parse: function (hexStr) {
|
|
// Shortcut
|
|
var hexStrLength = hexStr.length;
|
|
|
|
// Convert
|
|
var words = [];
|
|
for (var i = 0; i < hexStrLength; i += 2) {
|
|
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
|
|
}
|
|
|
|
return new WordArray.init(words, hexStrLength / 2);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Latin1 encoding strategy.
|
|
*/
|
|
var Latin1 = C_enc.Latin1 = {
|
|
/**
|
|
* Converts a word array to a Latin1 string.
|
|
*
|
|
* @param {WordArray} wordArray The word array.
|
|
*
|
|
* @return {string} The Latin1 string.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
|
*/
|
|
stringify: function (wordArray) {
|
|
// Shortcuts
|
|
var words = wordArray.words;
|
|
var sigBytes = wordArray.sigBytes;
|
|
|
|
// Convert
|
|
var latin1Chars = [];
|
|
for (var i = 0; i < sigBytes; i++) {
|
|
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
latin1Chars.push(String.fromCharCode(bite));
|
|
}
|
|
|
|
return latin1Chars.join('');
|
|
},
|
|
|
|
/**
|
|
* Converts a Latin1 string to a word array.
|
|
*
|
|
* @param {string} latin1Str The Latin1 string.
|
|
*
|
|
* @return {WordArray} The word array.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
|
*/
|
|
parse: function (latin1Str) {
|
|
// Shortcut
|
|
var latin1StrLength = latin1Str.length;
|
|
|
|
// Convert
|
|
var words = [];
|
|
for (var i = 0; i < latin1StrLength; i++) {
|
|
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
|
|
}
|
|
|
|
return new WordArray.init(words, latin1StrLength);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* UTF-8 encoding strategy.
|
|
*/
|
|
var Utf8 = C_enc.Utf8 = {
|
|
/**
|
|
* Converts a word array to a UTF-8 string.
|
|
*
|
|
* @param {WordArray} wordArray The word array.
|
|
*
|
|
* @return {string} The UTF-8 string.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
|
*/
|
|
stringify: function (wordArray) {
|
|
try {
|
|
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
|
} catch (e) {
|
|
throw new Error('Malformed UTF-8 data');
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Converts a UTF-8 string to a word array.
|
|
*
|
|
* @param {string} utf8Str The UTF-8 string.
|
|
*
|
|
* @return {WordArray} The word array.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
|
*/
|
|
parse: function (utf8Str) {
|
|
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Abstract buffered block algorithm template.
|
|
*
|
|
* The property blockSize must be implemented in a concrete subtype.
|
|
*
|
|
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
|
|
*/
|
|
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
|
/**
|
|
* Resets this block algorithm's data buffer to its initial state.
|
|
*
|
|
* @example
|
|
*
|
|
* bufferedBlockAlgorithm.reset();
|
|
*/
|
|
reset: function () {
|
|
// Initial values
|
|
this._data = new WordArray.init();
|
|
this._nDataBytes = 0;
|
|
},
|
|
|
|
/**
|
|
* Adds new data to this block algorithm's buffer.
|
|
*
|
|
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
|
*
|
|
* @example
|
|
*
|
|
* bufferedBlockAlgorithm._append('data');
|
|
* bufferedBlockAlgorithm._append(wordArray);
|
|
*/
|
|
_append: function (data) {
|
|
// Convert string to WordArray, else assume WordArray already
|
|
if (typeof data == 'string') {
|
|
data = Utf8.parse(data);
|
|
}
|
|
|
|
// Append
|
|
this._data.concat(data);
|
|
this._nDataBytes += data.sigBytes;
|
|
},
|
|
|
|
/**
|
|
* Processes available data blocks.
|
|
*
|
|
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
|
*
|
|
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
|
*
|
|
* @return {WordArray} The processed data.
|
|
*
|
|
* @example
|
|
*
|
|
* var processedData = bufferedBlockAlgorithm._process();
|
|
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
|
*/
|
|
_process: function (doFlush) {
|
|
// Shortcuts
|
|
var data = this._data;
|
|
var dataWords = data.words;
|
|
var dataSigBytes = data.sigBytes;
|
|
var blockSize = this.blockSize;
|
|
var blockSizeBytes = blockSize * 4;
|
|
|
|
// Count blocks ready
|
|
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
|
if (doFlush) {
|
|
// Round up to include partial blocks
|
|
nBlocksReady = Math.ceil(nBlocksReady);
|
|
} else {
|
|
// Round down to include only full blocks,
|
|
// less the number of blocks that must remain in the buffer
|
|
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
|
}
|
|
|
|
// Count words ready
|
|
var nWordsReady = nBlocksReady * blockSize;
|
|
|
|
// Count bytes ready
|
|
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
|
|
|
// Process blocks
|
|
if (nWordsReady) {
|
|
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
|
// Perform concrete-algorithm logic
|
|
this._doProcessBlock(dataWords, offset);
|
|
}
|
|
|
|
// Remove processed words
|
|
var processedWords = dataWords.splice(0, nWordsReady);
|
|
data.sigBytes -= nBytesReady;
|
|
}
|
|
|
|
// Return processed words
|
|
return new WordArray.init(processedWords, nBytesReady);
|
|
},
|
|
|
|
/**
|
|
* Creates a copy of this object.
|
|
*
|
|
* @return {Object} The clone.
|
|
*
|
|
* @example
|
|
*
|
|
* var clone = bufferedBlockAlgorithm.clone();
|
|
*/
|
|
clone: function () {
|
|
var clone = Base.clone.call(this);
|
|
clone._data = this._data.clone();
|
|
|
|
return clone;
|
|
},
|
|
|
|
_minBufferSize: 0
|
|
});
|
|
|
|
/**
|
|
* Abstract hasher template.
|
|
*
|
|
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
|
|
*/
|
|
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
|
/**
|
|
* Configuration options.
|
|
*/
|
|
cfg: Base.extend(),
|
|
|
|
/**
|
|
* Initializes a newly created hasher.
|
|
*
|
|
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
|
*
|
|
* @example
|
|
*
|
|
* var hasher = CryptoJS.algo.SHA256.create();
|
|
*/
|
|
init: function (cfg) {
|
|
// Apply config defaults
|
|
this.cfg = this.cfg.extend(cfg);
|
|
|
|
// Set initial values
|
|
this.reset();
|
|
},
|
|
|
|
/**
|
|
* Resets this hasher to its initial state.
|
|
*
|
|
* @example
|
|
*
|
|
* hasher.reset();
|
|
*/
|
|
reset: function () {
|
|
// Reset data buffer
|
|
BufferedBlockAlgorithm.reset.call(this);
|
|
|
|
// Perform concrete-hasher logic
|
|
this._doReset();
|
|
},
|
|
|
|
/**
|
|
* Updates this hasher with a message.
|
|
*
|
|
* @param {WordArray|string} messageUpdate The message to append.
|
|
*
|
|
* @return {Hasher} This hasher.
|
|
*
|
|
* @example
|
|
*
|
|
* hasher.update('message');
|
|
* hasher.update(wordArray);
|
|
*/
|
|
update: function (messageUpdate) {
|
|
// Append
|
|
this._append(messageUpdate);
|
|
|
|
// Update the hash
|
|
this._process();
|
|
|
|
// Chainable
|
|
return this;
|
|
},
|
|
|
|
/**
|
|
* Finalizes the hash computation.
|
|
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
*
|
|
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
*
|
|
* @return {WordArray} The hash.
|
|
*
|
|
* @example
|
|
*
|
|
* var hash = hasher.finalize();
|
|
* var hash = hasher.finalize('message');
|
|
* var hash = hasher.finalize(wordArray);
|
|
*/
|
|
finalize: function (messageUpdate) {
|
|
// Final message update
|
|
if (messageUpdate) {
|
|
this._append(messageUpdate);
|
|
}
|
|
|
|
// Perform concrete-hasher logic
|
|
var hash = this._doFinalize();
|
|
|
|
return hash;
|
|
},
|
|
|
|
blockSize: 512/32,
|
|
|
|
/**
|
|
* Creates a shortcut function to a hasher's object interface.
|
|
*
|
|
* @param {Hasher} hasher The hasher to create a helper for.
|
|
*
|
|
* @return {Function} The shortcut function.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
|
*/
|
|
_createHelper: function (hasher) {
|
|
return function (message, cfg) {
|
|
return new hasher.init(cfg).finalize(message);
|
|
};
|
|
},
|
|
|
|
/**
|
|
* Creates a shortcut function to the HMAC's object interface.
|
|
*
|
|
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
|
*
|
|
* @return {Function} The shortcut function.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
|
*/
|
|
_createHmacHelper: function (hasher) {
|
|
return function (message, key) {
|
|
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
|
};
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Algorithm namespace.
|
|
*/
|
|
var C_algo = C.algo = {};
|
|
|
|
return C;
|
|
}(Math));
|
|
|
|
|
|
return CryptoJS;
|
|
|
|
}));
|
|
},{}],33:[function(require,module,exports){
|
|
;(function (root, factory, undef) {
|
|
if (typeof exports === "object") {
|
|
// CommonJS
|
|
module.exports = exports = factory(require("./core"), require("./x64-core"));
|
|
}
|
|
else if (typeof define === "function" && define.amd) {
|
|
// AMD
|
|
define(["./core", "./x64-core"], factory);
|
|
}
|
|
else {
|
|
// Global (browser)
|
|
factory(root.CryptoJS);
|
|
}
|
|
}(this, function (CryptoJS) {
|
|
|
|
(function (Math) {
|
|
// Shortcuts
|
|
var C = CryptoJS;
|
|
var C_lib = C.lib;
|
|
var WordArray = C_lib.WordArray;
|
|
var Hasher = C_lib.Hasher;
|
|
var C_x64 = C.x64;
|
|
var X64Word = C_x64.Word;
|
|
var C_algo = C.algo;
|
|
|
|
// Constants tables
|
|
var RHO_OFFSETS = [];
|
|
var PI_INDEXES = [];
|
|
var ROUND_CONSTANTS = [];
|
|
|
|
// Compute Constants
|
|
(function () {
|
|
// Compute rho offset constants
|
|
var x = 1, y = 0;
|
|
for (var t = 0; t < 24; t++) {
|
|
RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
|
|
|
|
var newX = y % 5;
|
|
var newY = (2 * x + 3 * y) % 5;
|
|
x = newX;
|
|
y = newY;
|
|
}
|
|
|
|
// Compute pi index constants
|
|
for (var x = 0; x < 5; x++) {
|
|
for (var y = 0; y < 5; y++) {
|
|
PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
|
|
}
|
|
}
|
|
|
|
// Compute round constants
|
|
var LFSR = 0x01;
|
|
for (var i = 0; i < 24; i++) {
|
|
var roundConstantMsw = 0;
|
|
var roundConstantLsw = 0;
|
|
|
|
for (var j = 0; j < 7; j++) {
|
|
if (LFSR & 0x01) {
|
|
var bitPosition = (1 << j) - 1;
|
|
if (bitPosition < 32) {
|
|
roundConstantLsw ^= 1 << bitPosition;
|
|
} else /* if (bitPosition >= 32) */ {
|
|
roundConstantMsw ^= 1 << (bitPosition - 32);
|
|
}
|
|
}
|
|
|
|
// Compute next LFSR
|
|
if (LFSR & 0x80) {
|
|
// Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
|
|
LFSR = (LFSR << 1) ^ 0x71;
|
|
} else {
|
|
LFSR <<= 1;
|
|
}
|
|
}
|
|
|
|
ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
|
|
}
|
|
}());
|
|
|
|
// Reusable objects for temporary values
|
|
var T = [];
|
|
(function () {
|
|
for (var i = 0; i < 25; i++) {
|
|
T[i] = X64Word.create();
|
|
}
|
|
}());
|
|
|
|
/**
|
|
* SHA-3 hash algorithm.
|
|
*/
|
|
var SHA3 = C_algo.SHA3 = Hasher.extend({
|
|
/**
|
|
* Configuration options.
|
|
*
|
|
* @property {number} outputLength
|
|
* The desired number of bits in the output hash.
|
|
* Only values permitted are: 224, 256, 384, 512.
|
|
* Default: 512
|
|
*/
|
|
cfg: Hasher.cfg.extend({
|
|
outputLength: 512
|
|
}),
|
|
|
|
_doReset: function () {
|
|
var state = this._state = []
|
|
for (var i = 0; i < 25; i++) {
|
|
state[i] = new X64Word.init();
|
|
}
|
|
|
|
this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
|
|
},
|
|
|
|
_doProcessBlock: function (M, offset) {
|
|
// Shortcuts
|
|
var state = this._state;
|
|
var nBlockSizeLanes = this.blockSize / 2;
|
|
|
|
// Absorb
|
|
for (var i = 0; i < nBlockSizeLanes; i++) {
|
|
// Shortcuts
|
|
var M2i = M[offset + 2 * i];
|
|
var M2i1 = M[offset + 2 * i + 1];
|
|
|
|
// Swap endian
|
|
M2i = (
|
|
(((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
|
|
(((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
|
|
);
|
|
M2i1 = (
|
|
(((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
|
|
(((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
|
|
);
|
|
|
|
// Absorb message into state
|
|
var lane = state[i];
|
|
lane.high ^= M2i1;
|
|
lane.low ^= M2i;
|
|
}
|
|
|
|
// Rounds
|
|
for (var round = 0; round < 24; round++) {
|
|
// Theta
|
|
for (var x = 0; x < 5; x++) {
|
|
// Mix column lanes
|
|
var tMsw = 0, tLsw = 0;
|
|
for (var y = 0; y < 5; y++) {
|
|
var lane = state[x + 5 * y];
|
|
tMsw ^= lane.high;
|
|
tLsw ^= lane.low;
|
|
}
|
|
|
|
// Temporary values
|
|
var Tx = T[x];
|
|
Tx.high = tMsw;
|
|
Tx.low = tLsw;
|
|
}
|
|
for (var x = 0; x < 5; x++) {
|
|
// Shortcuts
|
|
var Tx4 = T[(x + 4) % 5];
|
|
var Tx1 = T[(x + 1) % 5];
|
|
var Tx1Msw = Tx1.high;
|
|
var Tx1Lsw = Tx1.low;
|
|
|
|
// Mix surrounding columns
|
|
var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
|
|
var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
|
|
for (var y = 0; y < 5; y++) {
|
|
var lane = state[x + 5 * y];
|
|
lane.high ^= tMsw;
|
|
lane.low ^= tLsw;
|
|
}
|
|
}
|
|
|
|
// Rho Pi
|
|
for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
|
|
// Shortcuts
|
|
var lane = state[laneIndex];
|
|
var laneMsw = lane.high;
|
|
var laneLsw = lane.low;
|
|
var rhoOffset = RHO_OFFSETS[laneIndex];
|
|
|
|
// Rotate lanes
|
|
if (rhoOffset < 32) {
|
|
var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
|
|
var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
|
|
} else /* if (rhoOffset >= 32) */ {
|
|
var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
|
|
var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
|
|
}
|
|
|
|
// Transpose lanes
|
|
var TPiLane = T[PI_INDEXES[laneIndex]];
|
|
TPiLane.high = tMsw;
|
|
TPiLane.low = tLsw;
|
|
}
|
|
|
|
// Rho pi at x = y = 0
|
|
var T0 = T[0];
|
|
var state0 = state[0];
|
|
T0.high = state0.high;
|
|
T0.low = state0.low;
|
|
|
|
// Chi
|
|
for (var x = 0; x < 5; x++) {
|
|
for (var y = 0; y < 5; y++) {
|
|
// Shortcuts
|
|
var laneIndex = x + 5 * y;
|
|
var lane = state[laneIndex];
|
|
var TLane = T[laneIndex];
|
|
var Tx1Lane = T[((x + 1) % 5) + 5 * y];
|
|
var Tx2Lane = T[((x + 2) % 5) + 5 * y];
|
|
|
|
// Mix rows
|
|
lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
|
|
lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
|
|
}
|
|
}
|
|
|
|
// Iota
|
|
var lane = state[0];
|
|
var roundConstant = ROUND_CONSTANTS[round];
|
|
lane.high ^= roundConstant.high;
|
|
lane.low ^= roundConstant.low;;
|
|
}
|
|
},
|
|
|
|
_doFinalize: function () {
|
|
// Shortcuts
|
|
var data = this._data;
|
|
var dataWords = data.words;
|
|
var nBitsTotal = this._nDataBytes * 8;
|
|
var nBitsLeft = data.sigBytes * 8;
|
|
var blockSizeBits = this.blockSize * 32;
|
|
|
|
// Add padding
|
|
dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
|
|
dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
|
|
data.sigBytes = dataWords.length * 4;
|
|
|
|
// Hash final blocks
|
|
this._process();
|
|
|
|
// Shortcuts
|
|
var state = this._state;
|
|
var outputLengthBytes = this.cfg.outputLength / 8;
|
|
var outputLengthLanes = outputLengthBytes / 8;
|
|
|
|
// Squeeze
|
|
var hashWords = [];
|
|
for (var i = 0; i < outputLengthLanes; i++) {
|
|
// Shortcuts
|
|
var lane = state[i];
|
|
var laneMsw = lane.high;
|
|
var laneLsw = lane.low;
|
|
|
|
// Swap endian
|
|
laneMsw = (
|
|
(((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
|
|
(((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
|
|
);
|
|
laneLsw = (
|
|
(((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
|
|
(((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
|
|
);
|
|
|
|
// Squeeze state to retrieve hash
|
|
hashWords.push(laneLsw);
|
|
hashWords.push(laneMsw);
|
|
}
|
|
|
|
// Return final computed hash
|
|
return new WordArray.init(hashWords, outputLengthBytes);
|
|
},
|
|
|
|
clone: function () {
|
|
var clone = Hasher.clone.call(this);
|
|
|
|
var state = clone._state = this._state.slice(0);
|
|
for (var i = 0; i < 25; i++) {
|
|
state[i] = state[i].clone();
|
|
}
|
|
|
|
return clone;
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Shortcut function to the hasher's object interface.
|
|
*
|
|
* @param {WordArray|string} message The message to hash.
|
|
*
|
|
* @return {WordArray} The hash.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var hash = CryptoJS.SHA3('message');
|
|
* var hash = CryptoJS.SHA3(wordArray);
|
|
*/
|
|
C.SHA3 = Hasher._createHelper(SHA3);
|
|
|
|
/**
|
|
* Shortcut function to the HMAC's object interface.
|
|
*
|
|
* @param {WordArray|string} message The message to hash.
|
|
* @param {WordArray|string} key The secret key.
|
|
*
|
|
* @return {WordArray} The HMAC.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var hmac = CryptoJS.HmacSHA3(message, key);
|
|
*/
|
|
C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
|
|
}(Math));
|
|
|
|
|
|
return CryptoJS.SHA3;
|
|
|
|
}));
|
|
},{"./core":32,"./x64-core":34}],34:[function(require,module,exports){
|
|
;(function (root, factory) {
|
|
if (typeof exports === "object") {
|
|
// CommonJS
|
|
module.exports = exports = factory(require("./core"));
|
|
}
|
|
else if (typeof define === "function" && define.amd) {
|
|
// AMD
|
|
define(["./core"], factory);
|
|
}
|
|
else {
|
|
// Global (browser)
|
|
factory(root.CryptoJS);
|
|
}
|
|
}(this, function (CryptoJS) {
|
|
|
|
(function (undefined) {
|
|
// Shortcuts
|
|
var C = CryptoJS;
|
|
var C_lib = C.lib;
|
|
var Base = C_lib.Base;
|
|
var X32WordArray = C_lib.WordArray;
|
|
|
|
/**
|
|
* x64 namespace.
|
|
*/
|
|
var C_x64 = C.x64 = {};
|
|
|
|
/**
|
|
* A 64-bit word.
|
|
*/
|
|
var X64Word = C_x64.Word = Base.extend({
|
|
/**
|
|
* Initializes a newly created 64-bit word.
|
|
*
|
|
* @param {number} high The high 32 bits.
|
|
* @param {number} low The low 32 bits.
|
|
*
|
|
* @example
|
|
*
|
|
* var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
|
|
*/
|
|
init: function (high, low) {
|
|
this.high = high;
|
|
this.low = low;
|
|
}
|
|
|
|
/**
|
|
* Bitwise NOTs this word.
|
|
*
|
|
* @return {X64Word} A new x64-Word object after negating.
|
|
*
|
|
* @example
|
|
*
|
|
* var negated = x64Word.not();
|
|
*/
|
|
// not: function () {
|
|
// var high = ~this.high;
|
|
// var low = ~this.low;
|
|
|
|
// return X64Word.create(high, low);
|
|
// },
|
|
|
|
/**
|
|
* Bitwise ANDs this word with the passed word.
|
|
*
|
|
* @param {X64Word} word The x64-Word to AND with this word.
|
|
*
|
|
* @return {X64Word} A new x64-Word object after ANDing.
|
|
*
|
|
* @example
|
|
*
|
|
* var anded = x64Word.and(anotherX64Word);
|
|
*/
|
|
// and: function (word) {
|
|
// var high = this.high & word.high;
|
|
// var low = this.low & word.low;
|
|
|
|
// return X64Word.create(high, low);
|
|
// },
|
|
|
|
/**
|
|
* Bitwise ORs this word with the passed word.
|
|
*
|
|
* @param {X64Word} word The x64-Word to OR with this word.
|
|
*
|
|
* @return {X64Word} A new x64-Word object after ORing.
|
|
*
|
|
* @example
|
|
*
|
|
* var ored = x64Word.or(anotherX64Word);
|
|
*/
|
|
// or: function (word) {
|
|
// var high = this.high | word.high;
|
|
// var low = this.low | word.low;
|
|
|
|
// return X64Word.create(high, low);
|
|
// },
|
|
|
|
/**
|
|
* Bitwise XORs this word with the passed word.
|
|
*
|
|
* @param {X64Word} word The x64-Word to XOR with this word.
|
|
*
|
|
* @return {X64Word} A new x64-Word object after XORing.
|
|
*
|
|
* @example
|
|
*
|
|
* var xored = x64Word.xor(anotherX64Word);
|
|
*/
|
|
// xor: function (word) {
|
|
// var high = this.high ^ word.high;
|
|
// var low = this.low ^ word.low;
|
|
|
|
// return X64Word.create(high, low);
|
|
// },
|
|
|
|
/**
|
|
* Shifts this word n bits to the left.
|
|
*
|
|
* @param {number} n The number of bits to shift.
|
|
*
|
|
* @return {X64Word} A new x64-Word object after shifting.
|
|
*
|
|
* @example
|
|
*
|
|
* var shifted = x64Word.shiftL(25);
|
|
*/
|
|
// shiftL: function (n) {
|
|
// if (n < 32) {
|
|
// var high = (this.high << n) | (this.low >>> (32 - n));
|
|
// var low = this.low << n;
|
|
// } else {
|
|
// var high = this.low << (n - 32);
|
|
// var low = 0;
|
|
// }
|
|
|
|
// return X64Word.create(high, low);
|
|
// },
|
|
|
|
/**
|
|
* Shifts this word n bits to the right.
|
|
*
|
|
* @param {number} n The number of bits to shift.
|
|
*
|
|
* @return {X64Word} A new x64-Word object after shifting.
|
|
*
|
|
* @example
|
|
*
|
|
* var shifted = x64Word.shiftR(7);
|
|
*/
|
|
// shiftR: function (n) {
|
|
// if (n < 32) {
|
|
// var low = (this.low >>> n) | (this.high << (32 - n));
|
|
// var high = this.high >>> n;
|
|
// } else {
|
|
// var low = this.high >>> (n - 32);
|
|
// var high = 0;
|
|
// }
|
|
|
|
// return X64Word.create(high, low);
|
|
// },
|
|
|
|
/**
|
|
* Rotates this word n bits to the left.
|
|
*
|
|
* @param {number} n The number of bits to rotate.
|
|
*
|
|
* @return {X64Word} A new x64-Word object after rotating.
|
|
*
|
|
* @example
|
|
*
|
|
* var rotated = x64Word.rotL(25);
|
|
*/
|
|
// rotL: function (n) {
|
|
// return this.shiftL(n).or(this.shiftR(64 - n));
|
|
// },
|
|
|
|
/**
|
|
* Rotates this word n bits to the right.
|
|
*
|
|
* @param {number} n The number of bits to rotate.
|
|
*
|
|
* @return {X64Word} A new x64-Word object after rotating.
|
|
*
|
|
* @example
|
|
*
|
|
* var rotated = x64Word.rotR(7);
|
|
*/
|
|
// rotR: function (n) {
|
|
// return this.shiftR(n).or(this.shiftL(64 - n));
|
|
// },
|
|
|
|
/**
|
|
* Adds this word with the passed word.
|
|
*
|
|
* @param {X64Word} word The x64-Word to add with this word.
|
|
*
|
|
* @return {X64Word} A new x64-Word object after adding.
|
|
*
|
|
* @example
|
|
*
|
|
* var added = x64Word.add(anotherX64Word);
|
|
*/
|
|
// add: function (word) {
|
|
// var low = (this.low + word.low) | 0;
|
|
// var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
|
|
// var high = (this.high + word.high + carry) | 0;
|
|
|
|
// return X64Word.create(high, low);
|
|
// }
|
|
});
|
|
|
|
/**
|
|
* An array of 64-bit words.
|
|
*
|
|
* @property {Array} words The array of CryptoJS.x64.Word objects.
|
|
* @property {number} sigBytes The number of significant bytes in this word array.
|
|
*/
|
|
var X64WordArray = C_x64.WordArray = Base.extend({
|
|
/**
|
|
* Initializes a newly created word array.
|
|
*
|
|
* @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
|
|
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.x64.WordArray.create();
|
|
*
|
|
* var wordArray = CryptoJS.x64.WordArray.create([
|
|
* CryptoJS.x64.Word.create(0x00010203, 0x04050607),
|
|
* CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
|
|
* ]);
|
|
*
|
|
* var wordArray = CryptoJS.x64.WordArray.create([
|
|
* CryptoJS.x64.Word.create(0x00010203, 0x04050607),
|
|
* CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
|
|
* ], 10);
|
|
*/
|
|
init: function (words, sigBytes) {
|
|
words = this.words = words || [];
|
|
|
|
if (sigBytes != undefined) {
|
|
this.sigBytes = sigBytes;
|
|
} else {
|
|
this.sigBytes = words.length * 8;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Converts this 64-bit word array to a 32-bit word array.
|
|
*
|
|
* @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
|
|
*
|
|
* @example
|
|
*
|
|
* var x32WordArray = x64WordArray.toX32();
|
|
*/
|
|
toX32: function () {
|
|
// Shortcuts
|
|
var x64Words = this.words;
|
|
var x64WordsLength = x64Words.length;
|
|
|
|
// Convert
|
|
var x32Words = [];
|
|
for (var i = 0; i < x64WordsLength; i++) {
|
|
var x64Word = x64Words[i];
|
|
x32Words.push(x64Word.high);
|
|
x32Words.push(x64Word.low);
|
|
}
|
|
|
|
return X32WordArray.create(x32Words, this.sigBytes);
|
|
},
|
|
|
|
/**
|
|
* Creates a copy of this word array.
|
|
*
|
|
* @return {X64WordArray} The clone.
|
|
*
|
|
* @example
|
|
*
|
|
* var clone = x64WordArray.clone();
|
|
*/
|
|
clone: function () {
|
|
var clone = Base.clone.call(this);
|
|
|
|
// Clone "words" array
|
|
var words = clone.words = this.words.slice(0);
|
|
|
|
// Clone each X64Word object
|
|
var wordsLength = words.length;
|
|
for (var i = 0; i < wordsLength; i++) {
|
|
words[i] = words[i].clone();
|
|
}
|
|
|
|
return clone;
|
|
}
|
|
});
|
|
}());
|
|
|
|
|
|
return CryptoJS;
|
|
|
|
}));
|
|
},{"./core":32}],"bignumber.js":[function(require,module,exports){
|
|
'use strict';
|
|
|
|
module.exports = BigNumber; // jshint ignore:line
|
|
|
|
|
|
},{}],"web3":[function(require,module,exports){
|
|
var web3 = require('./lib/web3');
|
|
web3.providers.HttpProvider = require('./lib/web3/httpprovider');
|
|
web3.providers.QtSyncProvider = require('./lib/web3/qtsync');
|
|
web3.eth.contract = require('./lib/web3/contract');
|
|
web3.eth.namereg = require('./lib/web3/namereg');
|
|
web3.eth.sendIBANTransaction = require('./lib/web3/transfer');
|
|
|
|
// dont override global variable
|
|
if (typeof window !== 'undefined' && typeof window.web3 === 'undefined') {
|
|
window.web3 = web3;
|
|
}
|
|
|
|
module.exports = web3;
|
|
|
|
|
|
},{"./lib/web3":9,"./lib/web3/contract":11,"./lib/web3/httpprovider":19,"./lib/web3/namereg":23,"./lib/web3/qtsync":26,"./lib/web3/transfer":29}]},{},["web3"])
|
|
//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvc29saWRpdHkvY29kZXIuanMiLCJsaWIvc29saWRpdHkvZm9ybWF0dGVycy5qcyIsImxpYi9zb2xpZGl0eS9wYXJhbS5qcyIsImxpYi91dGlscy9icm93c2VyLXhoci5qcyIsImxpYi91dGlscy9jb25maWcuanMiLCJsaWIvdXRpbHMvc2hhMy5qcyIsImxpYi91dGlscy91dGlscy5qcyIsImxpYi92ZXJzaW9uLmpzb24iLCJsaWIvd2ViMy5qcyIsImxpYi93ZWIzL2JhdGNoLmpzIiwibGliL3dlYjMvY29udHJhY3QuanMiLCJsaWIvd2ViMy9kYi5qcyIsImxpYi93ZWIzL2Vycm9ycy5qcyIsImxpYi93ZWIzL2V0aC5qcyIsImxpYi93ZWIzL2V2ZW50LmpzIiwibGliL3dlYjMvZmlsdGVyLmpzIiwibGliL3dlYjMvZm9ybWF0dGVycy5qcyIsImxpYi93ZWIzL2Z1bmN0aW9uLmpzIiwibGliL3dlYjMvaHR0cHByb3ZpZGVyLmpzIiwibGliL3dlYjMvaWNhcC5qcyIsImxpYi93ZWIzL2pzb25ycGMuanMiLCJsaWIvd2ViMy9tZXRob2QuanMiLCJsaWIvd2ViMy9uYW1lcmVnLmpzIiwibGliL3dlYjMvbmV0LmpzIiwibGliL3dlYjMvcHJvcGVydHkuanMiLCJsaWIvd2ViMy9xdHN5bmMuanMiLCJsaWIvd2ViMy9yZXF1ZXN0bWFuYWdlci5qcyIsImxpYi93ZWIzL3NoaC5qcyIsImxpYi93ZWIzL3RyYW5zZmVyLmpzIiwibGliL3dlYjMvd2F0Y2hl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W9uIChhYmksIHBhcmFtcykge1xuICAgIHJldHVybiBhYmkuZmlsdGVyKGZ1bmN0aW9uIChqc29uKSB7XG4gICAgICAgIHJldHVybiBqc29uLnR5cGUgPT09ICdjb25zdHJ1Y3RvcicgJiYganNvbi5pbnB1dHMubGVuZ3RoID09PSBwYXJhbXMubGVuZ3RoO1xuICAgIH0pLm1hcChmdW5jdGlvbiAoanNvbikge1xuICAgICAgICByZXR1cm4ganNvbi5pbnB1dHMubWFwKGZ1bmN0aW9uIChpbnB1dCkge1xuICAgICAgICAgICAgcmV0dXJuIGlucHV0LnR5cGU7XG4gICAgICAgIH0pO1xuICAgIH0pLm1hcChmdW5jdGlvbiAodHlwZXMpIHtcbiAgICAgICAgcmV0dXJuIGNvZGVyLmVuY29kZVBhcmFtcyh0eXBlcywgcGFyYW1zKTtcbiAgICB9KVswXSB8fCAnJztcbn07XG5cbi8qKlxuICogU2hvdWxkIGJlIGNhbGxlZCB0byBhZGQgZnVuY3Rpb25zIHRvIGNvbnRyYWN0IG9iamVjdFxuICpcbiAqIEBtZXRob2QgYWRkRnVuY3Rpb25zVG9Db250cmFjdFxuICogQHBhcmFtIHtDb250cmFjdH0gY29udHJhY3RcbiAqIEBwYXJhbSB7QXJyYXl9IGFiaVxuICovXG52YXIgYWRkRnVuY3Rpb25zVG9Db250cmFjdCA9IGZ1bmN0aW9uIChjb250cmFjdCwgYWJpKSB7XG4gICAgYWJpLmZpbHRlcihmdW5jdGlvbiAoanNvbikge1xuICAgICAgICByZXR1cm4ganNvbi50eXBlID09PSAnZnVuY3Rpb24nO1xuICAgIH0pLm1hcChmdW5jdGlvbiAoanNvbikge1xuICAgICAgICByZXR1cm4gbmV3IFNvbGlkaXR5RnVuY3Rpb24oanNvbiwgY29udHJhY3QuYWRkcmVzcyk7XG4gICAgfSkuZm9yRWFjaChmdW5jdGlvbiAoZikge1xuICAgICAgICBmLmF0dGFjaFRvQ29udHJhY3QoY29udHJhY3QpO1xuICAgIH0pO1xufTtcblxu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lvbnNbZl0pO1xuICAgIH0pO1xuXG4gICAgcmVzdWx0LnRvcGljcyA9IFtdO1xuXG4gICAgaWYgKCF0aGlzLl9hbm9ueW1vdXMpIHtcbiAgICAgICAgcmVzdWx0LmFkZHJlc3MgPSB0aGlzLl9hZGRyZXNzO1xuICAgICAgICByZXN1bHQudG9waWNzLnB1c2goJzB4JyArIHRoaXMuc2lnbmF0dXJlKCkpO1xuICAgIH1cblxuICAgIHZhciBpbmRleGVkVG9waWNzID0gdGhpcy5fcGFyYW1zLmZpbHRlcihmdW5jdGlvbiAoaSkge1xuICAgICAgICByZXR1cm4gaS5pbmRleGVkID09PSB0cnVlO1xuICAgIH0pLm1hcChmdW5jdGlvbiAoaSkge1xuICAgICAgICB2YXIgdmFsdWUgPSBpbmRleGVkW2kubmFtZV07XG4gICAgICAgIGlmICh2YWx1ZSA9PT0gdW5kZWZpbmVkIHx8IHZhbHVlID09PSBudWxsKSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgICAgICBcbiAgICAgICAgaWYgKHV0aWxzLmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgICByZXR1cm4gdmFsdWUubWFwKGZ1bmN0aW9uICh2KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuICcweCcgKyBjb2Rlci5lbmNvZGVQYXJhbShpLnR5cGUsIHYpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuICcweCcgKyBjb2Rlci5lbmNvZGVQYXJhbShpLnR5cGUsIHZhbHVlKTtcbiAgICB9KTtcblxuICAgIHJlc3VsdC50b3BpY3MgPSByZXN1bHQudG9waWNzLmNvbmNhdChpbmRleGVkVG9waWNzKTtcblxuICAgIHJldHVybiByZXN1bHQ7XG59O1xuXG4vKipcbiAqIFNob3VsZCBiZSB1c2VkIHRvIGRlY29kZSBpbmRleGVkIHBhcmFtcyBhbmQgb3B0aW9uc1xuICpcbiAqIEBtZXRob2QgZ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gICAgICAgICAgKiBAc3RhdGljXG5cdCAgICAgICAgICAgICAqXG5cdCAgICAgICAgICAgICAqIEBleGFtcGxlXG5cdCAgICAgICAgICAgICAqXG5cdCAgICAgICAgICAgICAqICAgICB2YXIgTXlUeXBlID0gQ3J5cHRvSlMubGliLkJhc2UuZXh0ZW5kKHtcblx0ICAgICAgICAgICAgICogICAgICAgICBmaWVsZDogJ3ZhbHVlJyxcblx0ICAgICAgICAgICAgICpcblx0ICAgICAgICAgICAgICogICAgICAgICBtZXRob2Q6IGZ1bmN0aW9uICgpIHtcblx0ICAgICAgICAgICAgICogICAgICAgICB9XG5cdCAgICAgICAgICAgICAqICAgICB9KTtcblx0ICAgICAgICAgICAgICovXG5cdCAgICAgICAgICAgIGV4dGVuZDogZnVuY3Rpb24gKG92ZXJyaWRlcykge1xuXHQgICAgICAgICAgICAgICAgLy8gU3Bhd25cblx0ICAgICAgICAgICAgICAgIEYucHJvdG90eXBlID0gdGhpcztcblx0ICAgICAgICAgICAgICAgIHZhciBzdWJ0eXBlID0gbmV3IEYoKTtcblxuXHQgICAgICAgICAgICAgICAgLy8gQXVnbWVudFxuXHQgICAgICAgICAgICAgICAgaWYgKG92ZXJyaWRlcykge1xuXHQgICAgICAgICAgICAgICAgICAgIHN1YnR5cGUubWl4SW4ob3ZlcnJpZGVzKTtcblx0ICAgICAgICAgICAgICAgIH1cblxuXHQgICAgICAgICAgICAgICAgLy8gQ3JlYXRlIGRlZmF1bHQgaW5pdGlhbGl6ZXJcblx0ICAgICAgICAgICAgICAgIGlmICghc3VidHlwZS5oYXNPd25Qcm9wZXJ0eSgnaW5pdCcpKSB7XG5cdCAgICAgICAgICAgICAgICAgICAgc3VidHlwZS5pbml0ID0gZnVuY3Rpb24gKCkge1xuXHQgICAgICAgICAgICAgICAgICAgICAgICBzdWJ0eXBlLiRzdXBlci5pbml0LmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7XG5cdCAgICAgICAgICAgICAgICAgICAgfTtcblx0ICAgICAgICAgICAgICAgIH1cblxuXHQgICAgICAgICAgICAgICAgLy8gSW5pdGlhbGl6ZXIncyBwcm90b3R5cGUgaXMgdGhlIHN1YnR5cGUgb2JqZWN0XG5cdCAgICAgICAgICAgICAgICBzdWJ0eXBlLmluaXQucHJvdG90eXBlID0gc3VidHlwZTtcblxuXHQgICAgICAgICAgICAgICAgLy8gUmVmZXJlbmNlIHN1cGVydHlwZVxuXHQgICAgICAgICAgICAgICAgc3VidHlwZS4kc3VwZXIgPSB0aGlzO1xuXG5cdCAgICAgICAgICAgICAgICByZXR1cm4gc3VidHlwZTtcblx0ICAgICAgICAgICAgfSxcblxuXHQgICAgICAgICAgICAvKipcblx0ICAgICAgICAgICAgICogRXh0ZW5kcyB0aGlzIG9iamVjdCBhbmQgcnVucyB0aGUgaW5pdCBtZXRob2QuXG5cdCAgICAgICAgICAgICAqIEFyZ3VtZW50cyB0byBjcmVhdGUoKSB3aWxsIGJlIHBhc3NlZCB0byBpbml0KCkuXG5cdCAgICAgICAgICAgICAqXG5cdCAgICAgICAgICAgICAqIEByZXR1cm4ge09iamVjdH0gVGhlIG5ldyBvYmplY3QuXG5cdCAgICAgICAgICAgICAqXG5cdCAgICAgICAgICAgICAqIEBzdGF0aWNcblx0ICAgICAgICAgICAgICpcblx0ICAgICAgICAgICAgICogQGV4YW1wbGVcblx0ICAgICAgICAgICAgICpcblx0ICAgICAgICAgICAgICogICAgIHZhciBpbnN0YW5jZSA9IE15VHlwZS5jcmVhdGUoKTtcblx0ICAgICAgICAgICAgICovXG5cdCAgICAgICAgICAgIGNyZWF0ZTogZnVuY3Rpb24gKCkge1xuXHQgICAgICAgICAgICAgICAgdmFyIGluc3RhbmNlID0gdGhpcy5leHRlbmQoKTtcblx0ICAgICAgICAgICAgICAgIGluc3RhbmNlLmluaXQuYXBwbHkoaW5zdGFuY2UsIGFyZ3VtZW50cyk7XG5cblx0ICAgICAgICAgICAgICAgIHJldHVybiBpbnN0YW5jZTtcblx0ICAgICAgICAgICAgfSxcblxuXHQgICAgICAgICAgICAvKipcblx0ICAgICAgICAgICAgICogSW5pdGlhbGl6ZXMgYSBuZXdseSBjcmVhdGVkIG9iamVjdC5cblx0ICAgICAgICAgICAgICogT3ZlcnJpZGUgdGhpcyBtZXRob2QgdG8gYWRkIHNvbWUgbG9naWMgd2hlbiB5b3VyIG9iamVjdHMgYXJlIGNyZWF0ZWQuXG5cdCAgICAgICAgICAgICAqXG5cdCAgICAgICAgICAgICAqIEBleGFtcGxlXG5cdCAgICAgICAgICAgICAqXG5cdCAgICAgICAgICAgICAqICAgICB2YXIgTXlUeXBlID0gQ3J5cHRvSlMubGliLkJhc2UuZXh0ZW5kKHtcblx0ICAgICAgICAgICAgICogICAgICAgICBpbml0OiBmdW5jdGlvbiAoKSB7XG5cdCAgICAgICAgICAgICAqICAgICAgICAgICAgIC8vIC4uLlxuXHQgICAgICAgICAgICAgKiAgICAgICAgIH1cblx0ICAgICAgICAgICAgICogICAgIH0pO1xuXHQgICAgICAgICAgICAgKi9cblx0ICAgICAgICAgICAgaW5pdDogZnVuY3Rpb24gKCkge1xuXHQgICAgICAgICAgICB9LFxuXG5cdCAgICAgICAgICAgIC8qKlxuXHQgICAgICAgICAgICAgKiBDb3BpZXMgcHJvcGVydGllcyBpbnRvIHRoaXMgb2JqZWN0LlxuXHQgICAgICAgICAgICAgKlxuXHQgICAgICAgICAgICAgKiBAcGFyYW0ge09iamVjdH0gcHJvcGVydGllcyBUaGUgcHJvcGVydGllcyB0byBtaXggaW4uXG5cdCAgICAgICAgICAgICAqXG5cdCAgICAgICAgICAgICAqIEBleGFtcGxlXG5cdCAgICAgICAgICAgICAqXG5cdCAgICAgICAgICAgICAqICAgICBNeVR5cGUubWl4SW4oe1xuXHQgICAgICAgICAgICAgKiAgICAgICAgIGZpZWxkOiAndmFsdWUnXG5cdCAgICAgICAgICAgICAqICAgICB9KTtcblx0ICAgICAgICAgICAgICovXG5cdCAgICAgICAgICAgIG1peEluOiBmdW5jdGlvbiAocHJvcGVydGllcykge1xuXHQgICAgICAgICAgICAgICAgZm9yICh2YXIgcHJvcGVydHlOYW1lIGluIHByb3BlcnRpZXMpIHtcblx0ICAgICAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllcy5oYXNPd25Qcm9wZXJ0eShwcm9wZXJ0eU5hbWUpKSB7XG5cdCAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbcHJvcGVydHlOYW1lXSA9IHByb3BlcnRpZXNbcHJvcGVydHlOYW1lXTtcblx0ICAgICAgICAgICAgICAgICAgICB9XG5cdCAgICAgICAgICAgICAgICB9XG5cblx0ICAgICAgICAgICAgICAgIC8vIElFIHdvbid0IGNvcHkgdG9TdHJpbmcgdXNpbmcgdGhlIGxvb3AgYWJvdmVcblx0ICAgICAgICAgICAgICAgIGlmIChwcm9wZXJ0aWVzLmhhc093blByb3BlcnR5KCd0b1N0cmluZycpKSB7XG5cdCAgICAgICAgICAgICAgICAgICAgdGhpcy50b1N0cmluZyA9IHByb3BlcnRpZXMudG9TdHJpbmc7XG5cdCAgICAgICAgICAgICAgICB9XG5cdCAgICAgICAgICAgIH0sXG5cblx0ICAgICAgICAgICAgLyoqXG5cdCAgICAgICAgICAgICAqIENyZWF0ZXMgYSBjb3B5IG9mIHRoaXMgb2JqZWN0LlxuXHQgICAgICAgICAgICAgKlxuXHQgICAgICAgICAgICAgKiBAcmV0dXJuIHtPYmplY3R9IFRoZSBjbG9uZS5cblx0ICAgICAgICAgICAgICpcblx0ICAgICAgICAgICAgICogQGV4YW1wbGVcblx0ICAgICAgICAgICAgICpcblx0ICAgICAgICAgICAgICogICAgIHZhciBjbG9uZSA9IGluc3RhbmNlLmNsb25lKCk7XG5cdCAgICAgICAgICAgICAqL1xuXHQgICAgICAgICAgICBjbG9uZTogZnVuY3Rpb24gKCkge1xuXHQgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuaW5pdC5wcm90b3R5cGUuZXh0ZW5kKHRoaXMpO1xuXHQgICAgICAgICAgICB9XG5c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4MDAwMTAyMDMsIDB4MDQwNTA2MDddLCA2KTtcblx0ICAgICAgICAgKi9cblx0ICAgICAgICBpbml0OiBmdW5jdGlvbiAod29yZHMsIHNpZ0J5dGVzKSB7XG5cdCAgICAgICAgICAgIHdvcmRzID0gdGhpcy53b3JkcyA9IHdvcmRzIHx8IFtdO1xuXG5cdCAgICAgICAgICAgIGlmIChzaWdCeXRlcyAhPSB1bmRlZmluZWQpIHtcblx0ICAgICAgICAgICAgICAgIHRoaXMuc2lnQnl0ZXMgPSBzaWdCeXRlcztcblx0ICAgICAgICAgICAgfSBlbHNlIHtcblx0ICAgICAgICAgICAgICAgIHRoaXMuc2lnQnl0ZXMgPSB3b3Jkcy5sZW5ndGggKiA0O1xuXHQgICAgICAgICAgICB9XG5cdCAgICAgICAgfSxcblxuXHQgICAgICAgIC8qKlxuXHQgICAgICAgICAqIENvbnZlcnRzIHRoaXMgd29yZCBhcnJheSB0byBhIHN0cmluZy5cblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEBwYXJhbSB7RW5jb2Rlcn0gZW5jb2RlciAoT3B0aW9uYWwpIFRoZSBlbmNvZGluZyBzdHJhdGVneSB0byB1c2UuIERlZmF1bHQ6IENyeXB0b0pTLmVuYy5IZXhcblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEByZXR1cm4ge3N0cmluZ30gVGhlIHN0cmluZ2lmaWVkIHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAZXhhbXBsZVxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogICAgIHZhciBzdHJpbmcgPSB3b3JkQXJyYXkgKyAnJztcblx0ICAgICAgICAgKiAgICAgdmFyIHN0cmluZyA9IHdvcmRBcnJheS50b1N0cmluZygpO1xuXHQgICAgICAgICAqICAgICB2YXIgc3RyaW5nID0gd29yZEFycmF5LnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtcblx0ICAgICAgICAgKi9cblx0ICAgICAgICB0b1N0cmluZzogZnVuY3Rpb24gKGVuY29kZXIpIHtcblx0ICAgICAgICAgICAgcmV0dXJuIChlbmNvZGVyIHx8IEhleCkuc3RyaW5naWZ5KHRoaXMpO1xuXHQgICAgICAgIH0sXG5cblx0ICAgICAgICAvKipcblx0ICAgICAgICAgKiBDb25jYXRlbmF0ZXMgYSB3b3JkIGFycmF5IHRvIHRoaXMgd29yZCBhcnJheS5cblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEBwYXJhbSB7V29yZEFycmF5fSB3b3JkQXJyYXkgVGhlIHdvcmQgYXJyYXkgdG8gYXBwZW5kLlxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQHJldHVybiB7V29yZEFycmF5fSBUaGlzIHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAZXhhbXBsZVxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogICAgIHdvcmRBcnJheTEuY29uY2F0KHdvcmRBcnJheTIpO1xuXHQgICAgICAgICAqL1xuXHQgICAgICAgIGNvbmNhdDogZnVuY3Rpb24gKHdvcmRBcnJheSkge1xuXHQgICAgICAgICAgICAvLyBTaG9ydGN1dHNcblx0ICAgICAgICAgICAgdmFyIHRoaXNXb3JkcyA9IHRoaXMud29yZHM7XG5cdCAgICAgICAgICAgIHZhciB0aGF0V29yZHMgPSB3b3JkQXJyYXkud29yZHM7XG5cdCAgICAgICAgICAgIHZhciB0aGlzU2lnQnl0ZXMgPSB0aGlzLnNpZ0J5dGVzO1xuXHQgICAgICAgICAgICB2YXIgdGhhdFNpZ0J5dGVzID0gd29yZEFycmF5LnNpZ0J5dGVzO1xuXG5cdCAgICAgICAgICAgIC8vIENsYW1wIGV4Y2VzcyBiaXRzXG5cdCAgICAgICAgICAgIHRoaXMuY2xhbXAoKTtcblxuXHQgICAgICAgICAgICAvLyBDb25jYXRcblx0ICAgICAgICAgICAgaWYgKHRoaXNTaWdCeXRlcyAlIDQpIHtcblx0ICAgICAgICAgICA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ICAgICAqL1xuXHQgICAgICAgIGNsYW1wOiBmdW5jdGlvbiAoKSB7XG5cdCAgICAgICAgICAgIC8vIFNob3J0Y3V0c1xuXHQgICAgICAgICAgICB2YXIgd29yZHMgPSB0aGlzLndvcmRzO1xuXHQgICAgICAgICAgICB2YXIgc2lnQnl0ZXMgPSB0aGlzLnNpZ0J5dGVzO1xuXG5cdCAgICAgICAgICAgIC8vIENsYW1wXG5cdCAgICAgICAgICAgIHdvcmRzW3NpZ0J5dGVzID4+PiAyXSAmPSAweGZmZmZmZmZmIDw8ICgzMiAtIChzaWdCeXRlcyAlIDQpICogOCk7XG5cdCAgICAgICAgICAgIHdvcmRzLmxlbmd0aCA9IE1hdGguY2VpbChzaWdCeXRlcyAvIDQpO1xuXHQgICAgICAgIH0sXG5cblx0ICAgICAgICAvKipcblx0ICAgICAgICAgKiBDcmVhdGVzIGEgY29weSBvZiB0aGlzIHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcmV0dXJuIHtXb3JkQXJyYXl9IFRoZSBjbG9uZS5cblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEBleGFtcGxlXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiAgICAgdmFyIGNsb25lID0gd29yZEFycmF5LmNsb25lKCk7XG5cdCAgICAgICAgICovXG5cdCAgICAgICAgY2xvbmU6IGZ1bmN0aW9uICgpIHtcblx0ICAgICAgICAgICAgdmFyIGNsb25lID0gQmFzZS5jbG9uZS5jYWxsKHRoaXMpO1xuXHQgICAgICAgICAgICBjbG9uZS53b3JkcyA9IHRoaXMud29yZHMuc2xpY2UoMCk7XG5cblx0ICAgICAgICAgICAgcmV0dXJuIGNsb25lO1xuXHQgICAgICAgIH0sXG5cblx0ICAgICAgICAvKipcblx0ICAgICAgICAgKiBDcmVhdGVzIGEgd29yZCBhcnJheSBmaWxsZWQgd2l0aCByYW5kb20gYnl0ZXMuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcGFyYW0ge251bWJlcn0gbkJ5dGVzIFRoZSBudW1iZXIgb2YgcmFuZG9tIGJ5dGVzIHRvIGdlbmVyYXRlLlxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQHJldHVybiB7V29yZEFycmF5fSBUaGUgcmFuZG9tIHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAc3RhdGljXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAZXhhbXBsZVxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogICAgIHZhciB3b3JkQXJyYXkgPSBDcnlwdG9KUy5saWIuV29yZEFycmF5LnJhbmRvbSgxNik7XG5cdCAgICAgICAgICovXG5cdCAgICAgICAgcmFuZG9tOiBmdW5jdGlvbiAobkJ5dGVzKSB7XG5cdCAgICAgICAgICAgIHZhciB3b3JkcyA9IFtdO1xuXG5cdCAgICAgICAgICAgIHZhciByID0gKGZ1bmN0aW9uIChtX3cpIHtcblx0ICAgICAgICAgICAgICAgIHZhciBtX3cgPSBtX3c7XG5cdCAgICAgICAgICAgICAgICB2YXIgbV96ID0gMHgzYWRlNjhiMTtcblx0ICAgICAgICAgICAgICAgIHZhciBtYXNrID0gMHhmZmZmZmZmZjtcblxuXHQgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcblx0ICAgICAgICAgICAgICAgICAgICBtX3ogPSAoMHg5MDY5ICogKG1feiAmIDB4RkZGRikgKyAobV96ID4+IDB4MTApKSAmIG1hc2s7XG5cdCAgICAgICAgICAgICAgICAgICAgbV93ID0gKDB4NDY1MCAqIChtX3cgJiAweEZGRkYpICsgKG1fdyA+PiAweDEwKSkgJiBtYXNrO1xuXHQgICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSAoKG1feiA8PCAweDEwKSArIG1fdykgJiBtYXNrO1xuXHQgICAgICAgICAgICAgICAgICAgIHJlc3VsdCAvPSAweDEwMDAwMDAwMDtcblx0ICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gMC41O1xuXHQgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQgKiAoTWF0aC5yYW5kb20oKSA+IC41ID8gMSA6IC0xKTtcblx0ICAgICAgICAgICAgICAgIH1cblx0ICAgICAgICAgICAgfSk7XG5cblx0ICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIHJjYWNoZTsgaSA8IG5CeXRlczsgaSArPSA0KSB7XG5cdCAgICAgICAgICAgICAgICB2YXIgX3IgPSByKChyY2FjaGUgfHwgTWF0aC5yYW5kb20oKSkgKiAweDEwMDAwMDAwMCk7XG5cblx0ICAgICAgICAgICAgICAgIHJjYWNoZSA9IF9yKCkgKiAweDNhZGU2N2I3O1xuXHQgICAgICAgICAgICAgICAgd29yZHMucHVzaCgoX3IoKSAqIDB4MTAwMDAwMDAwKSB8IDApO1xuXHQgICAgICAgICAgICB9XG5cblx0ICAgICAgICAgICAgcmV0dXJuIG5ldyBXb3JkQXJyYXkuaW5pdCh3b3JkcywgbkJ5dGVzKTtcblx0ICAgICAgICB9XG5cdCAgICB9KTtcblxuXHQgICAgLyoqXG5cdCAgICAgKiBFbmNvZGVyIG5hbWVzcGFjZS5cblx0ICAgICAqL1xuXHQgICAgdmFyIENfZW5jID0gQy5lbmMgPSB7fTtcblxuXHQgICAgLyoqXG5cdCAgICAgKiBIZXggZW5jb2Rpbmcgc3RyYXRlZ3kuXG5cdCAgICAgKi9cblx0ICAgIHZhciBIZXggPSBDX2VuYy5IZXggPSB7XG5cdCAgICAgICAgLyoqXG5cdCAgICAgICAgICogQ29udmVydHMgYSB3b3JkIGFycmF5IHRvIGEgaGV4IHN0cmluZy5cblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEBwYXJhbSB7V29yZEFycmF5fSB3b3JkQXJyYXkgVGhlIHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcmV0dXJuIHtzdHJpbmd9IFRoZSBoZXggc3RyaW5nLlxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQHN0YXRpY1xuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQGV4YW1wbGVcblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqICAgICB2YXIgaGV4U3RyaW5nID0gQ3J5cHRvSlMuZW5jLkhleC5zdHJpbmdpZnkod29yZEFycmF5KTtcblx0ICAgICAgICAgKi9cblx0ICAgICAgICBzdHJpbmdpZnk6IGZ1bmN0aW9uICh3b3JkQXJyYXkpIHtcblx0ICAgICAgICAgICAgLy8gU2hvcnRjdXRzXG5cdCAgICAgICAgICAgIHZhciB3b3JkcyA9IHdvcmRBcnJheS53b3Jkcztcblx0ICAgICAgICAgICAgdmFyIHNpZ0J5dGVzID0gd29yZEFycmF5LnNpZ0J5dGVzO1xuXG5cdCAgICAgICAgICAgIC8vIENvbnZlcnRcblx0ICAgICAgICAgICAgdmFyIGhleENoYXJzID0gW107XG5cdCAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgc2lnQnl0ZXM7IGkrKykge1xuXHQgICAgICAgICAgICAgICAgdmFyIGJpdGUgPSAod29yZHNbaSA+Pj4gMl0gPj4+ICgyNCAtIChpICUgNCkgKiA4KSkgJiAweGZmO1xuXHQgICAgICAgICAgICAgICAgaGV4Q2hhcnMucHVzaCgoYml0ZSA+Pj4gNCkudG9TdHJpbmcoMTYpKTtcblx0ICAgICAgICAgICAgICAgIGhleENoYXJzLnB1c2goKGJpdGUgJiAweDBmKS50b1N0cmluZygxNikpO1xuXHQgICAgICAgICAgICB9XG5cblx0ICAgICAgICAgICAgcmV0dXJuIGhleENoYXJzLmpvaW4oJycpO1xuXHQgICAgICAgIH0sXG5cblx0ICAgICAgICAvKipcblx0ICAgICAgICAgKiBDb252ZXJ0cyBhIGhleCBzdHJpbmcgdG8gYSB3b3JkIGFycmF5LlxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQHBhcmFtIHtzdHJpbmd9IGhleFN0ciBUaGUgaGV4IHN0cmluZy5cblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEByZXR1cm4ge1dvcmRBcnJheX0gVGhlIHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAc3RhdGljXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAZXhhbXBsZVxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogICAgIHZhciB3b3JkQXJyYXkgPSBDcnlwdG9KUy5lbmMuSGV4LnBhcnNlKGhleFN0cmluZyk7XG5cdCAgICAgICAgICovXG5cdCAgICAgICAgcGFyc2U6IGZ1bmN0aW9uIChoZXhTdHIpIHtcblx0ICAgICAgICAgICAgLy8gU2hvcnRjdXRcblx0ICAgICAgICAgICAgdmFyIGhleFN0ckxlbmd0aCA9IGhleFN0ci5sZW5ndGg7XG5cblx0ICAgICAgICAgICAgLy8gQ29udmVydFxuXHQgICAgICAgICAgICB2YXIgd29yZHMgPSBbXTtcblx0ICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBoZXhTdHJMZW5ndGg7IGkgKz0gMikge1xuXHQgICAgICAgICAgICAgICAgd29yZHNbaSA+Pj4gM10gfD0gcGFyc2VJbnQoaGV4U3RyLnN1YnN0cihpLCAyKSwgMTYpIDw8ICgyNCAtIChpICUgOCkgKiA0KTtcblx0ICAgICAgICAgICAgfVxuXG5cdCAgICAgICAgICAgIHJldHVybiBuZXcgV29yZEFycmF5LmluaXQod29yZHMsIGhleFN0ckxlbmd0aCAvIDIpO1xuXHQgICAgICAgIH1cblx0ICAgIH07XG5cblx0ICAgIC8qKlxuXHQgICAgICogTGF0aW4xIGVuY29kaW5nIHN0cmF0ZWd5LlxuXHQgICAgICovXG5cdCAgICB2YXIgTGF0aW4xID0gQ19lbmMuTGF0aW4xID0ge1xuXHQgICAgICAgIC8qKlxuXHQgICAgICAgICAqIENvbnZlcnRzIGEgd29yZCBhcnJheSB0byBhIExhdGluMSBzdHJpbmcuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcGFyYW0ge1dvcmRBcnJheX0gd29yZEFycmF5IFRoZSB3b3JkIGFycmF5LlxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQHJldHVybiB7c3RyaW5nfSBUaGUgTGF0aW4xIHN0cmluZy5cblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEBzdGF0aWNcblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEBleGFtcGxlXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiAgICAgdmFyIGxhdGluMVN0cmluZyA9IENyeXB0b0pTLmVuYy5MYXRpbjEuc3RyaW5naWZ5KHdvcmRBcnJheSk7XG5cdCAgICAgICAgICovXG5cdCAgICAgICAgc3RyaW5naWZ5OiBmdW5jdGlvbiAod29yZEFycmF5KSB7XG5cdCAgICAgICAgICAgIC8vIFNob3J0Y3V0c1xuXHQgICAgICAgICAgICB2YXIgd29yZHMgPSB3b3JkQXJyYXkud29yZHM7XG5cdCAgICAgICAgICAgIHZhciBzaWdCeXRlcyA9IHdvcmRBcnJheS5zaWdCeXRlcztcblxuXHQgICAgICAgICAgICAvLyBDb252ZXJ0XG5cdCAgICAgICAgICAgIHZhciBsYXRpbjFDaGFycyA9IFtdO1xuXHQgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHNpZ0J5dGVzOyBpKyspIHtcblx0ICAgICAgICAgICAgICAgIHZhciBiaXRlID0gKHdvcmRzW2kgPj4+IDJdID4+PiAoMjQgLSAoaSAlIDQpICogOCkpICYgMHhmZjtcblx0ICAgICAgICAgICAgICAgIGxhdGluMUNoYXJzLnB1c2goU3RyaW5nLmZyb21DaGFyQ29kZShiaXRlKSk7XG5cdCAgICAgICAgICAgIH1cblxuXHQgICAgICAgICAgICByZXR1cm4gbGF0aW4xQ2hhcnMuam9pbignJyk7XG5cdCAgICAgICAgfSxcblxuXHQgICAgICAgIC8qKlxuXHQgICAgICAgICAqIENvbnZlcnRzIGEgTGF0aW4xIHN0cmluZyB0byBhIHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcGFyYW0ge3N0cmluZ30gbGF0aW4xU3RyIFRoZSBMYXRpbjEgc3RyaW5nLlxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQHJldHVybiB7V29yZEFycmF5fSBUaGUgd29yZCBhcnJheS5cblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEBzdGF0aWNcblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEBleGFtcGxlXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiAgICAgdmFyIHdvcmRBcnJheSA9IENyeXB0b0pTLmVuYy5MYXRpbjEucGFyc2UobGF0aW4xU3RyaW5nKTtcblx0ICAgICAgICAgKi9cblx0ICAgICAgICBwYXJzZTogZnVuY3Rpb24gKGxhdGluMVN0cikge1xuXHQgICAgICAgICAgICAvLyBTaG9ydGN1dFxuXHQgICAgICAgICAgICB2YXIgbGF0aW4xU3RyTGVuZ3RoID0gbGF0aW4xU3RyLmxlbmd0aDtcblxuXHQgICAgICAgICAgICAvLyBDb252ZXJ0XG5cdCAgICAgICAgICAgIHZhciB3b3JkcyA9IFtdO1xuXHQgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxhdGluMVN0ckxlbmd0aDsgaSsrKSB7XG5cdCAgICAgICAgICAgICAgICB3b3Jkc1tpID4+PiAyXSB8PSAobGF0aW4xU3RyLmNoYXJDb2RlQXQoaSkgJiAweGZmKSA8PCAoMjQgLSAoaSAlIDQpICogOCk7XG5cdCAgICAgICAgICAgIH1cblxuXHQgICAgICAgICAgICByZXR1cm4gbmV3IFdvcmRBcnJheS5pbml0KHdvcmRzLCBsYXRpbjFTdHJMZW5ndGgpO1xuXHQgICAgICAgIH1cblx0ICAgIH07XG5cblx0ICAgIC8qKlxuXHQgICAgICogVVRGLTggZW5jb2Rpbmcgc3RyYXRlZ3kuXG5cdCAgICAgKi9cblx0ICAgIHZhciBVdGY4ID0gQ19lbmMuVXRmOCA9IHtcblx0ICAgICAgICAvKipcblx0ICAgICAgICAgKiBDb252ZXJ0cyBhIHdvcmQgYXJyYXkgdG8gYSBVVEYtOCBzdHJpbmcuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcGFyYW0ge1dvcmRBcnJheX0gd29yZEFycmF5IFRoZSB3b3JkIGFycmF5LlxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQHJldHVybiB7c3RyaW5nfSBUaGUgVVRGLTggc3RyaW5nLlxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQHN0YXRpY1xuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQGV4YW1wbGVcblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqICAgICB2YXIgdXRmOFN0cmluZyA9IENyeXB0b0pTLmVuYy5VdGY4LnN0cmluZ2lmeSh3b3JkQXJyYXkpO1xuXHQgICAgICAgICAqL1xuXHQgICAgICAgIHN0cmluZ2lmeTogZnVuY3Rpb24gKHdvcmRBcnJheSkge1xuXHQgICAgICAgICAgICB0cnkge1xuXHQgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZVVSSUNvbXBvbmVudChlc2NhcGUoTGF0aW4xLnN0cmluZ2lmeSh3b3JkQXJyYXkpKSk7XG5cdCAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcblx0ICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignTWFsZm9ybWVkIFVURi04IGRhdGEnKTtcblx0ICAgICAgICAgICAgfVxuXHQgICAgICAgIH0sXG5cblx0ICAgICAgICAvKipcblx0ICAgICAgICAgKiBDb252ZXJ0cyBhIFVURi04IHN0cmluZyB0byBhIHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcGFyYW0ge3N0cmluZ30gdXRmOFN0ciBUaGUgVVRGLTggc3RyaW5nLlxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogQHJldHVybiB7V29yZEFyc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XHQgICAgICAgICAgICBmb3IgKHZhciB5ID0gMDsgeSA8IDU7IHkrKykge1xuXHQgICAgICAgICAgICAgICAgUElfSU5ERVhFU1t4ICsgNSAqIHldID0geSArICgoMiAqIHggKyAzICogeSkgJSA1KSAqIDU7XG5cdCAgICAgICAgICAgIH1cblx0ICAgICAgICB9XG5cblx0ICAgICAgICAvLyBDb21wdXRlIHJvdW5kIGNvbnN0YW50c1xuXHQgICAgICAgIHZhciBMRlNSID0gMHgwMTtcblx0ICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IDI0OyBpKyspIHtcblx0ICAgICAgICAgICAgdmFyIHJvdW5kQ29uc3RhbnRNc3cgPSAwO1xuXHQgICAgICAgICAgICB2YXIgcm91bmRDb25zdGFudExzdyA9IDA7XG5cblx0ICAgICAgICAgICAgZm9yICh2YXIgaiA9IDA7IGogPCA3OyBqKyspIHtcblx0ICAgICAgICAgICAgICAgIGlmIChMRlNSICYgMHgwMSkge1xuXHQgICAgICAgICAgICAgICAgICAgIHZhciBiaXRQb3NpdGlvbiA9ICgxIDw8IGopIC0gMTtcblx0ICAgICAgICAgICAgICAgICAgICBpZiAoYml0UG9zaXRpb24gPCAzMikge1xuXHQgICAgICAgICAgICAgICAgICAgICAgICByb3VuZENvbnN0YW50THN3IF49IDEgPDwgYml0UG9zaXRpb247XG5cdCAgICAgICAgICAgICAgICAgICAgfSBlbHNlIC8qIGlmIChiaXRQb3NpdGlvbiA+PSAzMikgKi8ge1xuXHQgICAgICAgICAgICAgICAgICAgICAgICByb3VuZENvbnN0YW50TXN3IF49IDEgPDwgKGJpdFBvc2l0aW9uIC0gMzIpO1xuXHQgICAgICAgICAgICAgICAgICAgIH1cblx0ICAgICAgICAgICAgICAgIH1cblxuXHQgICAgICAgICAgICAgICAgLy8gQ29tcHV0ZSBuZXh0IExGU1Jcblx0ICAgICAgICAgICAgICAgIGlmIChMRlNSICYgMHg4MCkge1xuXHQgICAgICAgICAgICAgICAgICAgIC8vIFByaW1pdGl2ZSBwb2x5bm9taWFsIG92ZXIgR0YoMik6IHheOCArIHheNiArIHheNSArIHheNCArIDFcblx0ICAgICAgICAgICAgICAgICAgICBMRlNSID0gKExGU1IgPDwgMSkgXiAweDcxO1xuXHQgICAgICAgICAgICAgICAgfSBlbHNlIHtcblx0ICAgICAgICAgICAgICAgICAgICBMRlNSIDw8PSAxO1xuXHQgICAgICAgICAgICAgICAgfVxuXHQgICAgICAgICAgICB9XG5cblx0ICAgICAgICAgICAgUk9VTkRfQ09OU1RBTlRTW2ldID0gWDY0V29yZC5jcmVhdGUocm91bmRDb25zdGFudE1zdywgcm91bmRDb25zdGFudExzdyk7XG5cdCAgICAgICAgfVxuXHQgICAgfSgpKTtcblxuXHQgICAgLy8gUmV1c2FibGUgb2JqZWN0cyBmb3IgdGVtcG9yYXJ5IHZhbHVlc1xuXHQgICAgdmFyIFQgPSBbXTtcblx0ICAgIChmdW5jdGlvbiAoKSB7XG5cdCAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCAyNTsgaSsrKSB7XG5cdCAgICAgICAgICAgIFRbaV0gPSBYNjRXb3JkLmNyZWF0ZSgpO1xuXHQgICAgICAgIH1cblx0ICAgIH0oKSk7XG5cblx0ICAgIC8qKlxuXHQgICAgICogU0hBLTMgaGFzaCBhbGdvcml0aG0uXG5cdCAgICAgKi9cblx0ICAgIHZhciBTSEEzID0gQ19hbGdvLlNIQTMgPSBIYXNoZXIuZXh0ZW5kKHtcblx0ICAgICAgICAvKipcblx0ICAgICAgICAgKiBDb25maWd1cmF0aW9uIG9wdGlvbnMuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcHJvcGVydHkge251bWJlcn0gb3V0cHV0TGVuZ3RoXG5cdCAgICAgICAgICogICBUaGUgZGVzaXJlZCBudW1iZXIgb2YgYml0cyBpbiB0aGUgb3V0cHV0IGhhc2guXG5cdCAgICAgICAgICogICBPbmx5IHZhbHVlcyBwZXJtaXR0ZWQgYXJlOiAyMjQsIDI1Niwg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gU3dhcCBlbmRpYW5cblx0ICAgICAgICAgICAgICAgIE0yaSA9IChcblx0ICAgICAgICAgICAgICAgICAgICAoKChNMmkgPDwgOCkgIHwgKE0yaSA+Pj4gMjQpKSAmIDB4MDBmZjAwZmYpIHxcblx0ICAgICAgICAgICAgICAgICAgICAoKChNMmkgPDwgMjQpIHwgKE0yaSA+Pj4gOCkpICAmIDB4ZmYwMGZmMDApXG5cdCAgICAgICAgICAgICAgICApO1xuXHQgICAgICAgICAgICAgICAgTTJpMSA9IChcblx0ICAgICAgICAgICAgICAgICAgICAoKChNMmkxIDw8IDgpICB8IChNMmkxID4+PiAyNCkpICYgMHgwMGZmMDBmZikgfFxuXHQgICAgICAgICAgICAgICAgICAgICgoKE0yaTEgPDwgMjQpIHwgKE0yaTEgPj4+IDgpKSAgJiAweGZmMDBmZjAwKVxuXHQgICAgICAgICAgICAgICAgKTtcblxuXHQgICAgICAgICAgICAgICAgLy8gQWJzb3JiIG1lc3NhZ2UgaW50byBzdGF0ZVxuXHQgICAgICAgICAgICAgICAgdmFyIGxhbmUgPSBzdGF0ZVtpXTtcblx0ICAgICAgICAgICAgICAgIGxhbmUuaGlnaCBePSBNMmkxO1xuXHQgICAgICAgICAgICAgICAgbGFuZS5sb3cgIF49IE0yaTtcblx0ICAgICAgICAgICAgfVxuXG5cdCAgICAgICAgICAgIC8vIFJvdW5kc1xuXHQgICAgICAgICAgICBmb3IgKHZhciByb3VuZCA9IDA7IHJvdW5kIDwgMjQ7IHJvdW5kKyspIHtcblx0ICAgICAgICAgICAgICAgIC8vIFRoZXRhXG5cdCAgICAgICAgICAgICAgICBmb3IgKHZhciB4ID0gMDsgeCA8IDU7IHgrKykge1xuXHQgICAgICAgICAgICAgICAgICAgIC8vIE1peCBjb2x1bW4gbGFuZXNcblx0ICAgICAgICAgICAgICAgICAgICB2YXIgdE1zdyA9IDAsIHRMc3cgPSAwO1xuXHQgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIHkgPSAwOyB5IDwgNTsgeSsrKSB7XG5cdCAgICAgICAgICAgICAgICAgICAgICAgIHZhciBsYW5lID0gc3RhdGVbeCArIDUgKiB5XTtcblx0ICAgICAgICAgICAgICAgICAgICAgICAgdE1zdyBePSBsYW5lLmhpZ2g7XG5cdCAgICAgICAgICAgICAgICAgICAgICAgIHRMc3cgXj0gbGFuZS5sb3c7XG5cdCAgICAgICAgICAgICAgICAgICAgfVxuXG5cdCAgICAgICAgICAgICAgICAgICAgLy8gVGVtcG9yYXJ5IHZhbHVlc1xuXHQgICAgICAgICAgICAgICAgICAgIHZhciBUeCA9IFRbeF07XG5cdCAgICAgICAgICAgICAgICAgICAgVHguaGlnaCA9IHRNc3c7XG5cdCAgICAgICAgICAgICAgICAgICAgVHgubG93ICA9IHRMc3c7XG5cdCAgICAgICAgICAgICAgICB9XG5cdCAgICAgICAgICAgICAgICBmb3IgKHZhciB4ID0gMDsgeCA8IDU7IHgrKykge1xuXHQgICAgICAgICAgICAgICAgICAgIC8vIFNob3J0Y3V0c1xuXHQgICAgICAgICAgICAgICAgICAgIHZhciBUeDQgPSBUWyh4ICsgNCkgJSA1XTtcblx0ICAgICAgICAgICAgICAgICAgICB2YXIgVHgxID0gVFsoeCArIDEpICUgNV07XG5cdCAgICAgICAgICAgICAgICAgICAgdmFyIFR4MU1zdyA9IFR4MS5oaWdoO1xuXHQgICAgICAgICAgICAgICAgICAgIHZhciBUeDFMc3cgPSBUeDEubG93O1xuXG5cdCAgICAgICAgICAgICAgICAgICAgLy8gTWl4IHN1cnJvdW5kaW5nIGNvbHVtbnNcblx0ICAgICAgICAgICAgICAgICAgICB2YXIgdE1zdyA9IFR4NC5oaWdoIF4gKChUeDFNc3cgPDwgMSkgfCAoVHgxTHN3ID4+PiAzMSkpO1xuXHQgICAgICAgICAgICAgICAgICAgIHZhciB0THN3ID0gVHg0LmxvdyAgXiAoKFR4MUxzdyA8PCAxKSB8IChUeDFNc3cgPj4+IDMxKSk7XG5cdCAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgeSA9IDA7IHkgPCA1OyB5KyspIHtcblx0ICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxhbmUgPSBzdGF0ZVt4ICsgNSAqIHldO1xuXHQgICAgICAgICAgICAgICAgICAgICAgICBsYW5lLmhpZ2ggXj0gdE1zdztcblx0ICAgICAgICAgICAgICAgICAgICAgICAgbGFuZS5sb3cgIF49IHRMc3c7XG5cdCAgICAgICAgICAgICAgICAgICAgfVxuXHQgICAgICAgICAgICAgICAgfVxuXG5cdCAgICAgICAgICAgICAgICAvLyBSaG8gUGlcblx0ICAgICAgICAgICAgICAgIGZvciAodmFyIGxhbmVJbmRleCA9IDE7IGxhbmVJbmRleCA8IDI1OyBsYW5lSW5kZXgrKykge1xuXHQgICAgICAgICAgICAgICAgICAgIC8vIFNob3J0Y3V0c1xuXHQgICAgICAgICAgICAgICAgICAgIHZhciBsYW5lID0gc3RhdGVbbGFuZUluZGV4XTtcblx0ICAgICAgICAgICAgICAgICAgICB2YXIgbGFuZU1zdyA9IGxhbmUuaGlnaDtcblx0ICAgICAgICAgICAgICAgICAgICB2YXIgbGFuZUxzdyA9IGxhbmUubG93O1xuXHQgICAgICAgICAgICAgICAgICAgIHZhciByaG9PZmZzZXQgPSBSSE9fT0ZGU0VUU1tsYW5lSW5kZXhdO1xuXG5cdCAgICAgICAgICAgICAgICAgICAgLy8gUm90YXRlIGxhbmVzXG5cdCAgICAgICAgICAgICAgICAgICAgaWYgKHJob09mZnNldCA8IDMyKSB7XG5cdCAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0TXN3ID0gKGxhbmVNc3cgPDwgcmhvT2Zmc2V0KSB8IChsYW5lTHN3ID4+PiAoMzIgLSByaG9PZmZzZXQpKTtcblx0ICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRMc3cgPSAobGFuZUxzdyA8PCByaG9PZmZzZXQpIHwgKGxhbmVNc3cgPj4+ICgzMiAtIHJob09mZnNldCkpO1xuXHQgICAgICAgICAgICAgICAgICAgIH0gZWxzZSAvKiBpZiAocmhvT2Zmc2V0ID49IDMyKSAqLyB7XG5cdCAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0TXN3ID0gKGxhbmVMc3cgPDwgKHJob09mZnNldCAtIDMyKSkgfCAobGFuZU1zdyA+Pj4gKDY0IC0gcmhvT2Zmc2V0KSk7XG5cdCAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0THN3ID0gKGxhbmVNc3cgPDwgKHJob09mZnNldCAtIDMyKSkgfCAobGFuZUxzdyA+Pj4gKDY0IC0gcmhvT2Zmc2V0KSk7XG5cdCAgICAgICAgICAgICAgICAgICAgfVxuXG5cdCAgICAgICAgICAgICAgICAgICAgLy8gVHJhbnNwb3NlIGxhbmVzXG5cdCAgICAgICAgICAgICAgICAgICAgdmFyIFRQaUxhbmUgPSBUW1BJX0lOREVYRVNbbGFuZUluZGV4XV07XG5cdCAgICAgICAgICAgICAgICAgICAgVFBpTGFuZS5oaWdoID0gdE1zdztcblx0ICAgICAgICAgICAgICAgICAgICBUUGlMYW5lLmxvdyAgPSB0THN3O1xuXHQgICAgICAgICAgICAgICAgfVxuXG5cdCAgICAgICAgICAgICAgICAvLyBSaG8gcGkgYXQgeCA9IHkgPSAwXG5cdCAgICAgICAgICAgICAgICB2YXIgVDAgPSBUWzBdO1xuXHQgICAgICAgICAgICAgICAgdmFyIHN0YXRlMCA9IHN0YXRlWzBdO1xuXHQgICAgICAgICAgICAgICAgVDAuaGlnaCA9IHN0YXRlMC5oaWdoO1xuXHQgICAgICAgICAgICAgICAgVDAubG93ICA9IHN0YXRlMC5sb3c7XG5cblx0ICAgICAgICAgICAgICAgIC8vIENoaVxuXHQgICAgICAgICAgICAgICAgZm9yICh2YXIgeCA9IDA7IHggPCA1OyB4KyspIHtcblx0ICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciB5ID0gMDsgeSA8IDU7IHkrKykge1xuXHQgICAgICAgICAgICAgICAgICAgICAgICAvLyBTaG9ydGN1dHNcblx0ICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxhbmVJbmRleCA9IHggKyA1ICogeTtcblx0ICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxhbmUgPSBzdGF0ZVtsYW5lSW5kZXhdO1xuXHQgICAgICAgICAgICAgICAgICAgICAgICB2YXIgVExhbmUgPSBUW2xhbmVJbmRleF07XG5cdCAgICAgICAgICAgICAgICAgICAgICAgIHZhciBUeDFMYW5lID0gVFsoKHggKyAxKSAlIDUpICsgNSAqIHldO1xuXHQgICAgICAgICAgICAgICAgICAgICAgICB2YXIgVHgyTGFuZSA9IFRbKCh4ICsgMikgJSA1KSArIDUgKiB5XTtcblxuXHQgICAgICAgICAgICAgICAgICAgICAgICAvLyBNaXggcm93c1xuXHQgICAgICAgICAgICAgICAgICAgICAgICBsYW5lLmhpZ2ggPSBUTGFuZS5oaWdoIF4gKH5UeDFMYW5lLmhpZ2ggJiBUeDJMYW5lLmhpZ2gpO1xuXHQgICAgICAgICAgICAgICAgICAgICAgICBsYW5lLmxvdyAgPSBUTGFuZS5sb3cgIF4gKH5UeDFMYW5lLmxvdyAgJiBUeDJMYW5lLmxvdyk7XG5cdCAgICAgICAgICAgICAgICAgICAgfVxuXHQgICAgICAgICAgICAgICAgfVxuXG5cdCAgICAgICAgICAgICAgICAvLyBJb3RhXG5cdCAgICAgICAgICAgICAgICB2YXIgbGFuZSA9IHN0YXRlWzBdO1xuXHQgICAgICAgICAgICAgICAgdmFyIHJvdW5kQ29uc3RhbnQgPSBST1VORF9DT05TVEFOVFNbcm91bmRdO1xuXHQgICAgICAgICAgICAgICAgbGFuZS5oaWdoIF49IHJvdW5kQ29uc3RhbnQuaGlnaDtcblx0ICAgICAgICAgICAgICAgIGxhbmUubG93ICBePSByb3VuZENvbnN0YW50Lmxvdzs7XG5cdCAgICAgICAgICAgIH1cblx0ICAgICAgICB9LFxuXG5cdCAgICAgICAgX2RvRmluYWxpemU6IGZ1bmN0aW9uICgpIHtcblx0ICAgICAgICAgIC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xuXHQgICAgICAgICAgICB2YXIgaGFzaFdvcmRzID0gW107XG5cdCAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgb3V0cHV0TGVuZ3RoTGFuZXM7IGkrKykge1xuXHQgICAgICAgICAgICAgICAgLy8gU2hvcnRjdXRzXG5cdCAgICAgICAgICAgICAgICB2YXIgbGFuZSA9IHN0YXRlW2ldO1xuXHQgICAgICAgICAgICAgICAgdmFyIGxhbmVNc3cgPSBsYW5lLmhpZ2g7XG5cdCAgICAgICAgICAgICAgICB2YXIgbGFuZUxzdyA9IGxhbmUubG93O1xuXG5cdCAgICAgICAgICAgICAgICAvLyBTd2FwIGVuZGlhblxuXHQgICAgICAgICAgICAgICAgbGFuZU1zdyA9IChcblx0ICAgICAgICAgICAgICAgICAgICAoKChsYW5lTXN3IDw8IDgpICB8IChsYW5lTXN3ID4+PiAyNCkpICYgMHgwMGZmMDBmZikgfFxuXHQgICAgICAgICAgICAgICAgICAgICgoKGxhbmVNc3cgPDwgMjQpIHwgKGxhbmVNc3cgPj4+IDgpKSAgJiAweGZmMDBmZjAwKVxuXHQgICAgICAgICAgICAgICAgKTtcblx0ICAgICAgICAgICAgICAgIGxhbmVMc3cgPSAoXG5cdCAgICAgICAgICAgICAgICAgICAgKCgobGFuZUxzdyA8PCA4KSAgfCAobGFuZUxzdyA+Pj4gMjQpKSAmIDB4MDBmZjAwZmYpIHxcblx0ICAgICAgICAgICAgICAgICAgICAoKChsYW5lTHN3IDw8IDI0KSB8IChsYW5lTHN3ID4+PiA4KSkgICYgMHhmZjAwZmYwMClcblx0ICAgICAgICAgICAgICAgICk7XG5cblx0ICAgICAgICAgICAgICAgIC8vIFNxdWVlemUgc3RhdGUgdG8gcmV0cmlldmUgaGFzaFxuXHQgICAgICAgICAgICAgICAgaGFzaFdvcmRzLnB1c2gobGFuZUxzdyk7XG5cdCAgICAgICAgICAgICAgICBoYXNoV29yZHMucHVzaChsYW5lTXN3KTtcblx0ICAgICAgICAgICAgfVx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gICAgKiBAZXhhbXBsZVxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogICAgIHZhciB3b3JkQXJyYXkgPSBDcnlwdG9KUy54NjQuV29yZEFycmF5LmNyZWF0ZSgpO1xuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogICAgIHZhciB3b3JkQXJyYXkgPSBDcnlwdG9KUy54NjQuV29yZEFycmF5LmNyZWF0ZShbXG5cdCAgICAgICAgICogICAgICAgICBDcnlwdG9KUy54NjQuV29yZC5jcmVhdGUoMHgwMDAxMDIwMywgMHgwNDA1MDYwNyksXG5cdCAgICAgICAgICogICAgICAgICBDcnlwdG9KUy54NjQuV29yZC5jcmVhdGUoMHgxODE5MWExYiwgMHgxYzFkMWUxZilcblx0ICAgICAgICAgKiAgICAgXSk7XG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiAgICAgdmFyIHdvcmRBcnJheSA9IENyeXB0b0pTLng2NC5Xb3JkQXJyYXkuY3JlYXRlKFtcblx0ICAgICAgICAgKiAgICAgICAgIENyeXB0b0pTLng2NC5Xb3JkLmNyZWF0ZSgweDAwMDEwMjAzLCAweDA0MDUwNjA3KSxcblx0ICAgICAgICAgKiAgICAgICAgIENyeXB0b0pTLng2NC5Xb3JkLmNyZWF0ZSgweDE4MTkxYTFiLCAweDFjMWQxZTFmKVxuXHQgICAgICAgICAqICAgICBdLCAxMCk7XG5cdCAgICAgICAgICovXG5cdCAgICAgICAgaW5pdDogZnVuY3Rpb24gKHdvcmRzLCBzaWdCeXRlcykge1xuXHQgICAgICAgICAgICB3b3JkcyA9IHRoaXMud29yZHMgPSB3b3JkcyB8fCBbXTtcblxuXHQgICAgICAgICAgICBpZiAoc2lnQnl0ZXMgIT0gdW5kZWZpbmVkKSB7XG5cdCAgICAgICAgICAgICAgICB0aGlzLnNpZ0J5dGVzID0gc2lnQnl0ZXM7XG5cdCAgICAgICAgICAgIH0gZWxzZSB7XG5cdCAgICAgICAgICAgICAgICB0aGlzLnNpZ0J5dGVzID0gd29yZHMubGVuZ3RoICogODtcblx0ICAgICAgICAgICAgfVxuXHQgICAgICAgIH0sXG5cblx0ICAgICAgICAvKipcblx0ICAgICAgICAgKiBDb252ZXJ0cyB0aGlzIDY0LWJpdCB3b3JkIGFycmF5IHRvIGEgMzItYml0IHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcmV0dXJuIHtDcnlwdG9KUy5saWIuV29yZEFycmF5fSBUaGlzIHdvcmQgYXJyYXkncyBkYXRhIGFzIGEgMzItYml0IHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAZXhhbXBsZVxuXHQgICAgICAgICAqXG5cdCAgICAgICAgICogICAgIHZhciB4MzJXb3JkQXJyYXkgPSB4NjRXb3JkQXJyYXkudG9YMzIoKTtcblx0ICAgICAgICAgKi9cblx0ICAgICAgICB0b1gzMjogZnVuY3Rpb24gKCkge1xuXHQgICAgICAgICAgICAvLyBTaG9ydGN1dHNcblx0ICAgICAgICAgICAgdmFyIHg2NFdvcmRzID0gdGhpcy53b3Jkcztcblx0ICAgICAgICAgICAgdmFyIHg2NFdvcmRzTGVuZ3RoID0geDY0V29yZHMubGVuZ3RoO1xuXG5cdCAgICAgICAgICAgIC8vIENvbnZlcnRcblx0ICAgICAgICAgICAgdmFyIHgzMldvcmRzID0gW107XG5cdCAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgeDY0V29yZHNMZW5ndGg7IGkrKykge1xuXHQgICAgICAgICAgICAgICAgdmFyIHg2NFdvcmQgPSB4NjRXb3Jkc1tpXTtcblx0ICAgICAgICAgICAgICAgIHgzMldvcmRzLnB1c2goeDY0V29yZC5oaWdoKTtcblx0ICAgICAgICAgICAgICAgIHgzMldvcmRzLnB1c2goeDY0V29yZC5sb3cpO1xuXHQgICAgICAgICAgICB9XG5cblx0ICAgICAgICAgICAgcmV0dXJuIFgzMldvcmRBcnJheS5jcmVhdGUoeDMyV29yZHMsIHRoaXMuc2lnQnl0ZXMpO1xuXHQgICAgICAgIH0sXG5cblx0ICAgICAgICAvKipcblx0ICAgICAgICAgKiBDcmVhdGVzIGEgY29weSBvZiB0aGlzIHdvcmQgYXJyYXkuXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiBAcmV0dXJuIHtYNjRXb3JkQXJyYXl9IFRoZSBjbG9uZS5cblx0ICAgICAgICAgKlxuXHQgICAgICAgICAqIEBleGFtcGxlXG5cdCAgICAgICAgICpcblx0ICAgICAgICAgKiAgICAgdmFyIGNsb25lID0geDY0V29yZEFycmF5LmNsb25lKCk7XG5cdCAgICAgICAgICovXG5cdCAgICAgICAgY2xvbmU6IGZ1bmN0aW9uICgpIHtcblx0ICAgICAgICAgICAgdmFyIGNsb25lID0gQmFzZS5jbG9uZS5jYWxsKHRoaXMpO1xuXG5cdCAgICAgICAgICAgIC8vIENsb25lIFwid29yZHNcIiBhcnJheVxuXHQgICAgICAgICAgICB2YXIgd29yZHMgPSBjbG9uZS53b3JkcyA9IHRoaXMud29yZHMuc2xpY2UoMCk7XG5cblx0ICAgICAgICAgICAgLy8gQ2xvbmUgZWFjaCBYNjRXb3JkIG9iamVjdFxuXHQgICAgICAgICAgICB2YXIgd29yZHNMZW5ndGggPSB3b3Jkcy5sZW5ndGg7XG5cdCAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgd29yZHNMZW5ndGg7IGkrKykge1xuXHQgICAgICAgICAgICAgICAgd29yZHNbaV0gPSB3b3Jkc1tpXS5jbG9uZSgpO1xuXHQgICAgICAgICAgICB9XG5cblx0ICAgICAgICAgICAgcmV0dXJuIGNsb25lO1xuXHQgICAgICAgIH1cblx0ICAgIH0pO1xuXHR9KCkpO1xuXG5cblx0cmV0dXJuIENyeXB0b0pTO1xuXG59KSk7IiwiJ3VzZSBzdHJpY3QnO1xuXG5tb2R1bGUuZXhwb3J0cyA9IEJpZ051bWJlcjsgLy8ganNoaW50IGlnbm9yZTpsaW5lXG5cbiIsInZhciB3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