diff --git a/.gitignore b/.gitignore index cc78f5d..6692f52 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,13 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. -# -# If you find yourself ignoring temporary files generated by your text editor -# or operating system, you probably want to add a global ignore instead: -# git config --global core.excludesfile ~/.gitignore_global - +.DS_Store *.swp -/coverage -/tmp */**/*un~ *un~ -.DS_Store */**/.DS_Store -ethereum/ethereum -ethereal/ethereal +npm-debug.log +.npm/ +/coverage +/tmp example/js node_modules bower_components -npm-debug.log /bower -.npm/ diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 0000000..42bb00f --- /dev/null +++ b/.jshintignore @@ -0,0 +1,2 @@ +node_modules +packages/**/node_modules/ diff --git a/.jshintrc b/.jshintrc index 9ceda61..94605a2 100644 --- a/.jshintrc +++ b/.jshintrc @@ -5,7 +5,7 @@ "eqeqeq": true, "freeze": true, "funcscope": false, - "maxcomplexity": 9, + "maxcomplexity": 8, "maxdepth": 3, "maxerr": 50, /*"maxlen": 80*/ /*this should be our goal*/ diff --git a/.npmignore b/.npmignore index 5bbffe4..c53d8f2 100644 --- a/.npmignore +++ b/.npmignore @@ -1,9 +1,5 @@ -example/js -node_modules test .gitignore .editorconfig .travis.yml .npmignore -component.json -testling.html \ No newline at end of file diff --git a/dist/web3-light.js b/dist/web3-light.js index 85f758a..febaac1 100644 --- a/dist/web3-light.js +++ b/dist/web3-light.js @@ -2475,7 +2475,11 @@ module.exports = { },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":86}],21:[function(require,module,exports){ module.exports={ +<<<<<<< HEAD "version": "1.0.0" +======= + "version": "0.18.3" +>>>>>>> develop } },{}],22:[function(require,module,exports){ diff --git a/dist/web3-light.min.js b/dist/web3-light.min.js index 4d4c4f2..308dba4 100644 --- a/dist/web3-light.min.js +++ b/dist/web3-light.min.js @@ -1,3 +1,4 @@ +<<<<<<< HEAD require=function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a2&&"0x"===t.substr(0,2)&&(t=t.substr(2)),t=r.enc.Hex.parse(t)),i(t,{outputLength:256}).toString()}},{"crypto-js":58,"crypto-js/sha3":79}],20:[function(t,e,n){var r=t("bignumber.js"),i=t("./sha3.js"),o=t("utf8"),a={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",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",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"},s=function(t,e,n,r){return setTimeout(function(){O(r)&&r(t),O(n)&&n(t),e&&O(e.emit)&&(e.emit("error",t),e.removeAllListeners())},0),e},u=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},c=function(t,e,n){return t+new Array(e-t.length+1).join(n?n:"0")},l=function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);n7&&t[n].toUpperCase()!==t[n]||parseInt(e[n],16)<=7&&t[n].toLowerCase()!==t[n])return!1;return!0},S=function(t){if("undefined"==typeof t)return"";t=t.toLowerCase().replace("0x","");for(var e=i(t),n="0x",r=0;r7?t[r].toUpperCase():t[r];return n},A=function(t){return j(t)?t:/^[0-9a-f]{40}$/.test(t)?"0x"+t:"0x"+u(g(t).substr(2),40)},B=function(t){return t instanceof r||t&&t.constructor&&"BigNumber"===t.constructor.name},T=function(t){return"string"==typeof t||t&&t.constructor&&"String"===t.constructor.name},O=function(t){return"function"==typeof t},R=function(t){return"object"==typeof t},P=function(t){return"boolean"==typeof t},I=function(t){return t instanceof Array},D=function(t){try{return!!JSON.parse(t)}catch(t){return!1}};e.exports={_fireError:s,padLeft:u,padRight:c,toHex:g,toDecimal:y,fromDecimal:m,toUtf8:l,toAscii:f,fromUtf8:p,fromAscii:h,transformToFullName:d,extractDisplayName:_,extractTypeName:v,toWei:k,fromWei:w,toBigNumber:x,toTwosComplement:C,toAddress:A,isBigNumber:B,isStrictAddress:j,isAddress:E,isChecksumAddress:F,toChecksumAddress:S,isFunction:O,isString:T,isObject:R,isBoolean:P,isArray:I,isJson:D}},{"./sha3.js":19,"bignumber.js":"bignumber.js",utf8:86}],21:[function(t,e,n){e.exports={version:"1.0.0"}},{}],22:[function(t,e,n){function r(t){this._requestManager=new i(t),this.currentProvider=t,this.eth=new a(this),this.db=new s(this),this.shh=new u(this),this.net=new c(this),this.personal=new l(this),this.bzz=new f(this),this.settings=new p,this.version={api:h.version},this.providers={HttpProvider:g,IpcProvider:b,WebsocketProvider:w},this._extend=v(this),this._extend({properties:x()})}var i=t("./web3/requestmanager"),o=t("./web3/iban"),a=t("./web3/methods/eth"),s=t("./web3/methods/db"),u=t("./web3/methods/shh"),c=t("./web3/methods/net"),l=t("./web3/methods/personal"),f=t("./web3/methods/swarm"),p=t("./web3/settings"),h=t("./version.json"),d=t("./utils/utils"),_=t("./utils/sha3"),v=t("./web3/extend"),y=t("./web3/batch"),m=t("./web3/property"),g=t("./web3/providers/httpprovider"),b=t("./web3/providers/ipcprovider"),w=t("./web3/providers/websocketprovider"),k=t("bignumber.js");r.providers={HttpProvider:g,IpcProvider:b,WebsocketProvider:w},r.prototype.setProvider=function(t){this._requestManager.setProvider(t),this.currentProvider=t},r.prototype.reset=function(t){this._requestManager.reset(t),this.settings=new p},r.prototype.BigNumber=k,r.prototype.toHex=d.toHex,r.prototype.toAscii=d.toAscii,r.prototype.toUtf8=d.toUtf8,r.prototype.fromAscii=d.fromAscii,r.prototype.fromUtf8=d.fromUtf8,r.prototype.toDecimal=d.toDecimal,r.prototype.fromDecimal=d.fromDecimal,r.prototype.toBigNumber=d.toBigNumber,r.prototype.toWei=d.toWei,r.prototype.fromWei=d.fromWei,r.prototype.isAddress=d.isAddress,r.prototype.isChecksumAddress=d.isChecksumAddress,r.prototype.toChecksumAddress=d.toChecksumAddress,r.prototype.isIBAN=d.isIBAN,r.prototype.sha3=function(t,e){return"0x"+_(t,e)},r.prototype.fromICAP=function(t){var e=new o(t);return e.address()};var x=function(){return[new m({name:"version.node",getter:"web3_clientVersion"}),new m({name:"version.network",getter:"net_version",inputFormatter:d.toDecimal}),new m({name:"version.ethereum",getter:"eth_protocolVersion",inputFormatter:d.toDecimal}),new m({name:"version.whisper",getter:"shh_version",inputFormatter:d.toDecimal})]};r.prototype.isConnected=function(){return this.currentProvider&&this.currentProvider.isConnected()},r.prototype.createBatch=function(){return new y(this)},e.exports=r},{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":23,"./web3/extend":27,"./web3/iban":29,"./web3/methods/db":32,"./web3/methods/eth":33,"./web3/methods/net":34,"./web3/methods/personal":35,"./web3/methods/shh":36,"./web3/methods/swarm":37,"./web3/property":39,"./web3/providers/httpprovider":40,"./web3/providers/ipcprovider":41,"./web3/providers/websocketprovider":42,"./web3/requestmanager":43,"./web3/settings":44,"bignumber.js":"bignumber.js"}],23:[function(t,e,n){var r=t("./jsonrpc"),i=t("./errors"),o=function(t){this.requestManager=t._requestManager,this.requests=[]};o.prototype.add=function(t){this.requests.push(t)},o.prototype.execute=function(){var t=this.requests;this.requestManager.sendBatch(t,function(e,n){n=n||[],t.map(function(t,e){return n[e]||{}}).forEach(function(e,n){if(t[n].callback){if(!r.isValidResponse(e))return t[n].callback(i.InvalidResponse(e));t[n].callback(null,t[n].format?t[n].format(e.result):e.result)}})})},e.exports=o},{"./errors":25,"./jsonrpc":30}],24:[function(t,e,n){var r=t("lodash"),i=t("../utils/utils"),o=t("./eventifiedPromise.js"),a=t("./method.js"),s=t("../solidity/coder"),u=t("./formatters"),c=t("../utils/sha3"),l=t("./subscription.js"),f=function(t,e,n){var r=this,o=Array.prototype.slice.call(arguments);if(!(this instanceof f))throw new Error('Please use the "new" keyword to instantiate a web3.eth.contract() object!');if(!(t&&t instanceof Array))throw new Error("You must provide the json interface of the contract when instatiating a contract object.");this.options={},i.isObject(o[o.length-1])&&(n=o[o.length-1],this.options.data=n.data,this.options.from=n.from,this.options.gasPrice=n.gasPrice,this.options.gas=n.gas||n.gasLimit,i.isObject(e)&&(e=null)),Object.defineProperty(this.options,"address",{set:function(t){if(i.isAddress(t))this._address=t.toLowerCase();else if(t)throw new Error("The provided contract address is not a valid address.")},get:function(){return this._address},enumerable:!0}),Object.defineProperty(this.options,"jsonInterface",{set:function(t){return r.methods={},r.events={},r._jsonInterface=t.map(function(t){var e,n,o=t.inputs?t.inputs.map(function(t){return t.type}).join(","):"";if(t.name&&(n=t.name+"("+o+")"),"function"===t.type)t.signature="0x"+c(i.transformToFullName(t)).slice(0,8),e=r._createTxObject.bind({method:t,parent:r}),r.methods[t.name]||(r.methods[t.name]=e),r.methods[t.signature]=e,r.methods[n]=e;else if("event"===t.type){t.signature="0x"+c(i.transformToFullName(t));var a=r._on.bind(r,t.signature);r.events[t.name]&&"bound "!==r.events[t.name].name||(r.events[t.name]=a),r.events[t.signature]=a,r.events[n]=a}return t}),r.events.allEvents=r._on.bind(r,"allevents"),r._jsonInterface},get:function(){return r._jsonInterface},enumerable:!0}),this.methods={},this.events={},this._address=null,this._jsonInterface=[],this.options.address=e,this.options.jsonInterface=t};f.prototype._web3={},f.prototype._getCallback=function(t){if(i.isFunction(t[t.length-1]))return t.pop()},f.prototype._checkListener=function(t,e){if(e===t)throw new Error('The event "'+t+"\" is a reserved event name, you can't use it.")},f.prototype._fillWithDefaultOptions=function(t){return t.data=t.data||this.options.data,t.from=t.from||this.options.from,i.isAddress(t.from)&&(t.from=t.from.toLowerCase()),t.gasPrice=t.gasPrice||this.options.gasPrice,t.gas=t.gas||t.gasLimit||this.options.gas,delete t.gasLimit,t},f.prototype._encodeEventABI=function(t,e){e=e||{};var n=e.filter||{},r={};if(["fromBlock","toBlock"].filter(function(t){return void 0!==e[t]}).forEach(function(t){r[t]=u.inputBlockNumberFormatter(e[t])}),i.isArray(e.topics))r.topics=e.topics;else{if(r.topics=[],t&&!t.anonymous&&"ALLEVENTS"!==t.name&&r.topics.push(t.signature),"ALLEVENTS"!==t.name){var o=t.inputs.filter(function(t){return t.indexed===!0}).map(function(t){var e=n[t.name];return e?i.isArray(e)?e.map(function(e){return"0x"+s.encodeParam(t.type,e)}):"0x"+s.encodeParam(t.type,e):null});r.topics=r.topics.concat(o)}r.topics.length||delete r.topics}return r.address=this.options.address,r},f.prototype._decodeEventABI=function(t){var e=this;t.data=t.data||"",t.topics=t.topics||[];var n=u.outputLogFormatter(t);"ALLEVENTS"===e.name&&(e=e.jsonInterface.find(function(e){return e.signature===t.topics[0]})||{anonymous:!0}),e.inputs=e.inputs||[];var r=e.anonymous?t.topics:t.topics.slice(1),i=e.inputs.filter(function(t){return t.indexed===!0}).map(function(t){return t.type}),o=e.inputs.filter(function(t){return t.indexed===!1}).map(function(t){return t.type}),a=r.map(function(t){return t.slice(2)}).join(""),c=s.decodeParams(i,a),l=s.decodeParams(o,t.data.slice(2)),f=0;return n.returnValues=e.inputs.reduce(function(t,e){var n=e.name||f++;return t[n]=e.indexed?c.shift():l.shift(),t},{}),n.event=e.name,n},f.prototype._encodeMethodABI=function(){var t=this._method.signature,e=this.arguments,n=!1,r=this._parent.options.jsonInterface.filter(function(e){return"constructor"===t&&e.type===t||(e.signature===t||e.signature==="0x"+t.replace("0x","")||e.name===t)&&"function"===e.type}).map(function(t){if(t.inputs.length!==e.length)throw new Error("The number of arguments is not matching the methods required number. You need to pass "+t.inputs.length+" arguments.");return"function"===t.type&&(n=t.signature),t.inputs.map(function(t){return t.type})}).map(function(t){return s.encodeParams(t,e)})[0]||"";if("constructor"===t){if(!this._deployData)throw new Error("The contract has no contract data option set. This is necessary to append the constructor parameters.");return this._deployData+r}var i=n?n+r:r;if(i)return i;throw new Error("Couldn't find a matching contract method named \""+this._method.name+'".')},f.prototype._decodeMethodReturn=function(t,e){if(e){var n=t.map(function(t){return t.type});e=e.length>=2?e.slice(2):e;var r=s.decodeParams(n,e);return r=1===r.length?r[0]:r,"0x"===r&&(r=null),r}},f.prototype.deploy=function(t,e){if(t=t||{},t.arguments=t.arguments||[],t=this._fillWithDefaultOptions(t),!t.data)return i._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),defer.promise,defer.reject,e);var n=r.find(this.options.jsonInterface,function(t){return"constructor"===t.type})||{};return n.signature="constructor",this._createTxObject.apply({method:n,parent:this,deployData:t.data},t.arguments)},f.prototype._generateEventOptions=function(){var t=Array.prototype.slice.call(arguments),e=this._getCallback(t),n=i.isObject(t[t.length-1])?t.pop():{},r=i.isString(t[0])?t[0]:"allevents";if(r="allevents"===r.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(t){return"event"===t.type&&(t.name===r||t.signature==="0x"+r.replace("0x",""))}),!r)throw new Error('Event "'+r.name+"\" doesn't exist in this contract.");if(!i.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(r,n),event:r,callback:e}},f.prototype.once=function(t,e,n){var r=Array.prototype.slice.call(arguments);return n=this._getCallback(r),e&&delete e.fromBlock,this._on(t,e,function(t,e,r){r.unsubscribe(),i.isFunction(n)&&n(t,e)})},f.prototype._on=function(){var t=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",t.event.name,t.callback),this._checkListener("removeListener",t.event.name,t.callback);var e=new l({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(t.event)},subscribeMethod:"eth_subscribe",unsubscribeMethod:"eth_unsubscribe",requestManager:this._web3._requestManager});return e.subscribe("logs",t.params,t.callback||function(){}),e},f.prototype.getPastEvents=function(){var t=this._generateEventOptions.apply(this,arguments),e=new a({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(t.event)});e.setRequestManager(this._web3._requestManager);var n=e.buildCall();return e=null,n(t.params,t.callback)},f.prototype._createTxObject=function(){var t={};return"function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),t.arguments=arguments,t._method=this.method,t._parent=this.parent,this.deployData&&(t._deployData=this.deployData),t},f.prototype._methodReturnCallback=function(t,e,n,r,o){var a=this,s=new Error("Failed to check for transaction receipt."),u=!1;return"call"===n&&(o=a._parent._decodeMethodReturn(a._method.outputs,o)),r?i._fireError(r,t.promise,t.reject,e):(e&&e(null,o),void("send"===n?(t.promise.emit("transactionHash",o),a._parent._web3.eth.subscribe("newBlocks",{},function(e,n,r){ return e?(r.unsubscribe(),u=!0,i._fireError(s,t.promise,t.reject)):void a._parent._web3.eth.getTransactionReceipt(o,function(e,n){if(e)return r.unsubscribe(),u=!0,i._fireError(s,t.promise,t.reject);if(!u&&n)if(a._deployData){if(!n.contractAddress)return u=!0,i._fireError(new Error("The transaction receipt didn't contain a contract address."),t.promise,t.reject);a._parent._web3.eth.getCode(n.contractAddress,function(e,o){if(o)return r.unsubscribe(),u=!0,o.length>2?(t.promise.emit("receipt",n),t.resolve(n),t.promise.removeAllListeners(),void 0):i._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),t.promise,t.reject)})}else{if(r.unsubscribe(),u=!0,n.outOfGas)return i._fireError(new Error("Transaction ran out of gas."),t.promise,t.reject);t.promise.emit("receipt",n),t.resolve(n),t.promise.removeAllListeners()}})})):t.resolve(o)))},f.prototype._processExecuteArguments=function(t,e){var n={};if(n.type=t.shift(),n.callback=this._parent._getCallback(t),"call"===n.type&&t[t.length-1]!==!0&&(i.isString(t[t.length-1])||isFinite(t[t.length-1]))&&(n.defaultBlock=t.pop()),n.options=i.isObject(t[t.length-1])?t.pop():{},n.generateRequest=t[t.length-1]===!0&&t.pop(),n.options=this._parent._fillWithDefaultOptions(n.options),n.options.data=this.encodeABI(),!this._deployData&&!i.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(n.options.to=this._parent.options.address),n.options.data?n:i._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),e.promise,e.reject,n.callback)},f.prototype._executeMethod=function(){var t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),e),e=o("send"!==t.type);if(t.generateRequest){var n={params:[u.inputCallFormatter(t.options),u.inputDefaultBlockNumberFormatter(t.defaultBlock)],callback:t.callback};return"call"===t.type?(n.method="eth_call",n.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):n.method="eth_sendTransaction",n}var a=this._parent._methodReturnCallback.bind(this,e,t.callback,t.type);switch(t.type){case"estimate":this._parent._web3.eth.estimateGas(t.options,a);break;case"call":this._parent._web3.eth.call(t.options,t.defaultBlock,a);break;case"send":if(!i.isAddress(t.options.from))return i._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),e.promise,e.reject,t.callback);if(r.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return i._fireError(new Error("Can not send value to non-payable contract method or constructor"),e.promise,e.reject,t.callback);this._parent._web3.eth.sendTransaction(t.options,a)}return e.promise},e.exports=f},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./eventifiedPromise.js":26,"./formatters":28,"./method.js":31,"./subscription.js":45,lodash:85}],25:[function(t,e,n){e.exports={InvalidNumberOfParams:function(){return new Error("Invalid number of input parameters")},InvalidConnection:function(t){return new Error("CONNECTION ERROR: Couldn't connect to node "+t+".")},InvalidProvider:function(){return new Error("Provider not set or invalid")},InvalidResponse:function(t){var e=t&&t.error&&t.error.message?t.error.message:"Invalid JSON RPC response: "+JSON.stringify(t);return new Error(e)},ConnectionTimeout:function(t){return new Error("CONNECTION TIMEOUT: timeout of "+t+" ms achived")}}},{}],26:[function(t,e,n){var r=t("eventemitter3"),i=t("bluebird"),o=function(t){var e,n,o=new i(function(){e=arguments[0],n=arguments[1]});if(t)return{resolve:e,reject:n,promise:o};var a=new r;return o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:e,reject:n,promise:o}};e.exports=o},{bluebird:48,eventemitter3:84}],27:[function(t,e,n){var r=t("./formatters"),i=t("./../utils/utils"),o=t("./method"),a=t("./property"),s=function(t){var e=function(e){var n;e.property?(t[e.property]||(t[e.property]={}),n=t[e.property]):n=t,e.methods&&e.methods.forEach(function(e){e.attachToObject(n),e.setRequestManager(t._requestManager)}),e.properties&&e.properties.forEach(function(e){e.attachToObject(n),e.setRequestManager(t._requestManager)})};return e.formatters=r,e.utils=i,e.Method=o,e.Property=a,e};e.exports=s},{"./../utils/utils":20,"./formatters":28,"./method":31,"./property":39}],28:[function(t,e,n){var r=t("../utils/utils"),i=t("../utils/config"),o=t("./iban"),a=t("../utils/sha3"),s=function(t){return r.toBigNumber(t)},u=function(t){return"latest"===t||"pending"===t||"earliest"===t},c=function(t){return t?l(t):i.defaultBlock},l=function(t){if(void 0!==t)return u(t)?t:r.toHex(t)},f=function(t){return t.from=t.from||i.defaultAccount,t.from&&(t.from=b(t.from)),t.to&&(t.to=b(t.to)),["gasPrice","gas","gasLimit","value","nonce"].filter(function(e){return void 0!==t[e]}).forEach(function(e){t[e]=r.fromDecimal(t[e])}),t},p=function(t){if(t.from=t.from||i.defaultAccount,!t.from)throw new Error('The send transactions "from" field must be defined!');return t.from=b(t.from),t.to&&(t.to=b(t.to)),["gasPrice","gas","value","nonce"].filter(function(e){return void 0!==t[e]}).forEach(function(e){t[e]=r.fromDecimal(t[e])}),t},h=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),t.nonce=r.toDecimal(t.nonce),t.gas=r.toDecimal(t.gas),t.gasPrice=r.toBigNumber(t.gasPrice),t.value=r.toBigNumber(t.value),t},d=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),t.cumulativeGasUsed=r.toDecimal(t.cumulativeGasUsed),t.gasUsed=r.toDecimal(t.gasUsed),r.isArray(t.logs)&&(t.logs=t.logs.map(function(t){return y(t)})),t},_=function(t){return t.gasLimit=r.toDecimal(t.gasLimit),t.gasUsed=r.toDecimal(t.gasUsed),t.size=r.toDecimal(t.size),t.timestamp=r.toDecimal(t.timestamp),null!==t.number&&(t.number=r.toDecimal(t.number)),t.difficulty=r.toBigNumber(t.difficulty),t.totalDifficulty=r.toBigNumber(t.totalDifficulty),r.isArray(t.transactions)&&t.transactions.forEach(function(t){if(!r.isString(t))return h(t)}),t},v=function(t){var e=function(t){return null===t||"undefined"==typeof t?null:(t=String(t),0===t.indexOf("0x")?t:r.fromUtf8(t))};if(t.topics=t.topics||[],t.topics=t.topics.map(function(t){return r.isArray(t)?t.map(e):e(t)}),e=null,t.address&&!r.isAddress(t.address))throw new Error("The given address is not valid!");return t},y=function(t){return t.id="log_"+a(t.blockHash.replace("0x","")+t.transactionHash.replace("0x","")+t.logIndex.replace("0x","")).substr(0,8),null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),null!==t.logIndex&&(t.logIndex=r.toDecimal(t.logIndex)),t},m=function(t){return t.ttl=r.fromDecimal(t.ttl),t.workToProve=r.fromDecimal(t.workToProve),t.priority=r.fromDecimal(t.priority),r.isArray(t.topics)||(t.topics=t.topics?[t.topics]:[]),t.topics=t.topics.map(function(t){return 0===t.indexOf("0x")?t:r.fromUtf8(t)}),t},g=function(t){return t.expiry=r.toDecimal(t.expiry),t.sent=r.toDecimal(t.sent),t.ttl=r.toDecimal(t.ttl),t.workProved=r.toDecimal(t.workProved),t.topics||(t.topics=[]),t.topics=t.topics.map(function(t){return r.toAscii(t)}),t},b=function(t){var e=new o(t);if(e.isValid()&&e.isDirect())return"0x"+e.address();if(r.isStrictAddress(t))return t;if(r.isAddress(t))return"0x"+t;throw new Error("invalid address")},w=function(t){return t.startingBlock=r.toDecimal(t.startingBlock),t.currentBlock=r.toDecimal(t.currentBlock),t.highestBlock=r.toDecimal(t.highestBlock),t.knownStates&&(t.knownStates=r.toDecimal(t.knownStates),t.pulledStates=r.toDecimal(t.pulledStates)),t};e.exports={inputDefaultBlockNumberFormatter:c,inputBlockNumberFormatter:l,inputCallFormatter:f,inputTransactionFormatter:p,inputAddressFormatter:b,inputPostFormatter:m,inputLogFormatter:v,outputBigNumberFormatter:s,outputTransactionFormatter:h,outputTransactionReceiptFormatter:d,outputBlockFormatter:_,outputLogFormatter:y,outputPostFormatter:g,outputSyncingFormatter:w}},{"../utils/config":18,"../utils/sha3":19,"../utils/utils":20,"./iban":29}],29:[function(t,e,n){var r=t("bignumber.js"),i=function(t,e){for(var n=t;n.length<2*e;)n="0"+n;return n},o=function(t){var e="A".charCodeAt(0),n="Z".charCodeAt(0);return t=t.toUpperCase(),t=t.substr(4)+t.substr(0,4),t.split("").map(function(t){var r=t.charCodeAt(0);return r>=e&&r<=n?r-e+10:t}).join("")},a=function(t){for(var e,n=t;n.length>2;)e=n.slice(0,9),n=parseInt(e,10)%97+n.slice(e.length);return parseInt(n,10)%97},s=function(t){this._iban=t};s.fromAddress=function(t){var e=new r(t,16),n=e.toString(36),o=i(n,15);return s.fromBban(o.toUpperCase())},s.fromBban=function(t){var e="XE",n=a(o(e+"00"+t)),r=("0"+(98-n)).slice(-2);return new s(e+r+t)},s.createIndirect=function(t){return s.fromBban("ETH"+t.institution+t.identifier)},s.isValid=function(t){var e=new s(t);return e.isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.address=function(){if(this.isDirect()){var t=this._iban.substr(4),e=new r(t,36);return i(e.toString(16),20)}return""},s.prototype.toString=function(){return this._iban},e.exports=s},{"bignumber.js":"bignumber.js"}],30:[function(t,e,n){var r={messageId:0};r.toPayload=function(t,e){return t||console.error("jsonrpc method should be specified!"),r.messageId++,{jsonrpc:"2.0",id:r.messageId,method:t,params:e||[]}},r.isValidResponse=function(t){function e(t){return!!t&&!t.error&&"2.0"===t.jsonrpc&&"number"==typeof t.id&&void 0!==t.result}return Array.isArray(t)?t.every(e):e(t)},r.toBatchPayload=function(t){return t.map(function(t){return r.toPayload(t.method,t.params)})},e.exports=r},{}],31:[function(t,e,n){var r=t("../utils/utils"),i=t("./errors"),o=t("bluebird"),a=function(t){this.name=t.name,this.call=t.call,this.params=t.params||0,this.inputFormatter=t.inputFormatter,this.outputFormatter=t.outputFormatter,this.requestManager=null};a.prototype.setRequestManager=function(t){this.requestManager=t},a.prototype.getCall=function(t){return r.isFunction(this.call)?this.call(t):this.call},a.prototype.extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},a.prototype.validateArgs=function(t){if(t.length!==this.params)throw i.InvalidNumberOfParams()},a.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter.map(function(e,n){return e?e(t[n]):t[n]}):t},a.prototype.formatOutput=function(t){var e=this;return r.isArray(t)?t.map(function(t){return e.outputFormatter&&t?e.outputFormatter(t):t}):this.outputFormatter&&t?this.outputFormatter(t):t},a.prototype.toPayload=function(t){var e=this.getCall(t),n=this.extractCallback(t),r=this.formatInput(t);return this.validateArgs(r),{method:e,params:r,callback:n}},a.prototype.attachToObject=function(t){var e=this.buildCall();e.call=this.call;var n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},t[n[0]][n[1]]=e):t[n[0]]=e},a.prototype.buildCall=function(){var t=this,e=function(){var e,n,i=new o(function(){e=arguments[0],n=arguments[1]}),a=t.toPayload(Array.prototype.slice.call(arguments));return t.requestManager.send(a,function(i,o){return o=t.formatOutput(o),i?r._fireError(i,null,n,a.callback):(a.callback&&a.callback(null,o),void e(o))}),i};return e.request=this.request.bind(this),e},a.prototype.request=function(){var t=this.toPayload(Array.prototype.slice.call(arguments));return t.format=this.formatOutput.bind(this),t},e.exports=a},{"../utils/utils":20,"./errors":25,bluebird:48}],32:[function(t,e,n){var r=t("../method"),i=function(t){this._requestManager=t._requestManager;var e=this;o().forEach(function(n){n.attachToObject(e),n.setRequestManager(t._requestManager)})},o=function(){var t=new r({name:"putString",call:"db_putString",params:3}),e=new r({name:"getString",call:"db_getString",params:2}),n=new r({name:"putHex",call:"db_putHex",params:3}),i=new r({name:"getHex",call:"db_getHex",params:2});return[t,e,n,i]};e.exports=i},{"../method":31}],33:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;g().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),b().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),this.contract=l,this.contract.prototype._web3=t,this.iban=p,this.sendIBANTransaction=h.bind(null,this),this.namereg=function(){return this.contract(f.global.abi).at(f.global.address)},this.icapNamereg=function(){return this.contract(f.icap.abi).at(f.icap.address)}}var i=t("../formatters"),o=t("../../utils/utils"),a=t("../../utils/config"),s=t("../method"),u=t("../property"),c=t("../subscriptions"),l=t("../contract"),f=t("../namereg"),p=t("../iban"),h=t("../transfer"),d=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},_=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},v=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},y=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},m=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"};Object.defineProperty(r.prototype,"defaultBlock",{get:function(){return a.defaultBlock},set:function(t){return a.defaultBlock=t,t}}),Object.defineProperty(r.prototype,"defaultAccount",{get:function(){return a.defaultAccount},set:function(t){return a.defaultAccount=t,t}});var g=function(){var t=new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[i.inputAddressFormatter,i.inputDefaultBlockNumberFormatter],outputFormatter:i.outputBigNumberFormatter}),e=new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[null,o.toHex,i.inputDefaultBlockNumberFormatter]}),n=new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[i.inputAddressFormatter,i.inputDefaultBlockNumberFormatter]}),r=new s({name:"getBlock",call:d,params:2,inputFormatter:[i.inputBlockNumberFormatter,function(t){return!!t}],outputFormatter:i.outputBlockFormatter}),a=new s({name:"getUncle",call:v,params:2,inputFormatter:[i.inputBlockNumberFormatter,o.toHex],outputFormatter:i.outputBlockFormatter}),u=new s({name:"getBlockTransactionCount",call:y,params:1,inputFormatter:[i.inputBlockNumberFormatter],outputFormatter:o.toDecimal}),l=new s({name:"getBlockUncleCount",call:m,params:1,inputFormatter:[i.inputBlockNumberFormatter],outputFormatter:o.toDecimal}),f=new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,outputFormatter:i.outputTransactionFormatter}),p=new s({name:"getTransactionFromBlock",call:_,params:2,inputFormatter:[i.inputBlockNumberFormatter,o.toHex],outputFormatter:i.outputTransactionFormatter}),h=new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,outputFormatter:i.outputTransactionReceiptFormatter}),g=new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[null,i.inputDefaultBlockNumberFormatter],outputFormatter:o.toDecimal}),b=new s({name:"sendRawTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),w=new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[i.inputTransactionFormatter]}),k=new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[i.inputAddressFormatter,null]}),x=new s({name:"call",call:"eth_call",params:2,inputFormatter:[i.inputCallFormatter,i.inputDefaultBlockNumberFormatter]}),C=new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[i.inputCallFormatter],outputFormatter:o.toDecimal}),j=new s({name:"getCompilers",call:"eth_getCompilers",params:0}),E=new s({name:"compile.solidity",call:"eth_compileSolidity",params:1}),F=new s({name:"compile.lll",call:"eth_compileLLL",params:1}),S=new s({name:"compile.serpent",call:"eth_compileSerpent",params:1}),A=new s({name:"submitWork",call:"eth_submitWork",params:3}),B=new s({name:"getWork",call:"eth_getWork",params:0}),T=new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[i.inputLogFormatter],outputFormatter:i.outputLogFormatter}),O=new c({name:"subscribe",subscribe:"eth_subscribe",unsubscribe:"eth_unsubscribe",subscriptions:{newBlocks:{params:1,outputFormatter:i.outputBlockFormatter},pendingTransactions:{params:0,outputFormatter:i.outputTransactionFormatter},logs:{params:1,inputFormatter:[i.inputLogFormatter],outputFormatter:i.outputLogFormatter},syncing:{params:0,outputFormatter:i.outputSyncingFormatter}}});return[t,e,n,r,a,j,u,l,f,p,h,g,x,C,b,w,k,E,F,S,A,B,O,T]},b=function(){return[new u({name:"coinbase",getter:"eth_coinbase"}),new u({name:"mining",getter:"eth_mining"}),new u({name:"hashrate",getter:"eth_hashrate",outputFormatter:o.toDecimal}),new u({name:"syncing",getter:"eth_syncing",outputFormatter:i.outputSyncingFormatter}),new u({name:"gasPrice",getter:"eth_gasPrice",outputFormatter:i.outputBigNumberFormatter}),new u({name:"accounts",getter:"eth_accounts"}),new u({name:"blockNumber",getter:"eth_blockNumber",outputFormatter:o.toDecimal}),new u({name:"protocolVersion",getter:"eth_protocolVersion"})]};e.exports=r},{"../../utils/config":18,"../../utils/utils":20,"../contract":24,"../formatters":28,"../iban":29,"../method":31,"../namereg":38,"../property":39,"../subscriptions":46,"../transfer":47}],34:[function(t,e,n){var r=t("../../utils/utils"),i=t("../property"),o=function(t){this._requestManager=t._requestManager;var e=this;a().forEach(function(n){n.attachToObject(e),n.setRequestManager(t._requestManager)})},a=function(){return[new i({name:"listening",getter:"net_listening"}),new i({name:"peerCount",getter:"net_peerCount",outputFormatter:r.toDecimal})]};e.exports=o},{"../../utils/utils":20,"../property":39}],35:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),u().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})}var i=t("../method"),o=t("../property"),a=t("../formatters"),s=function(){var t=new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null]}),e=new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[a.inputAddressFormatter,null,null]}),n=new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[a.inputTransactionFormatter,null]}),r=new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[a.inputAddressFormatter]});return[t,e,n,r]},u=function(){return[new o({name:"listAccounts",getter:"personal_listAccounts"})]};e.exports=r},{"../formatters":28,"../method":31,"../property":39}],36:[function(t,e,n){var r=t("../method"),i=t("../formatters"),o=t("../subscriptions"),a=function(t){this._requestManager=t._requestManager;var e=this;s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})},s=function(){var t=new r({name:"post",call:"shh_post",params:1,inputFormatter:[i.inputPostFormatter]}),e=new r({name:"newIdentity",call:"shh_newIdentity",params:0}),n=new r({name:"hasIdentity",call:"shh_hasIdentity",params:1}),a=new r({name:"newGroup",call:"shh_newGroup",params:0}),s=new r({name:"addToGroup",call:"shh_addToGroup",params:0}),u=new r({name:"getPastMessages",call:"shh_getMessages",params:1,inputFormatter:[i.inputLogFormatter],outputFormatter:i.outputPostFormatter}),c=new o({name:"subscribe",subscribe:"shh_subscribe",unsubscribe:"shh_unsubscribe",subscriptions:{messages:{params:1,inputFormatter:[i.inputLogFormatter],outputFormatter:i.outputPostFormatter}}});return[t,e,n,a,s,u,c]};e.exports=a},{"../formatters":28,"../method":31,"../subscriptions":46}],37:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;a().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})}var i=t("../method"),o=t("../property"),a=function(){var t=new i({name:"blockNetworkRead",call:"bzz_blockNetworkRead",params:1,inputFormatter:[null]}),e=new i({name:"syncEnabled",call:"bzz_syncEnabled",params:1,inputFormatter:[null]}),n=new i({name:"swapEnabled",call:"bzz_swapEnabled",params:1,inputFormatter:[null]}),r=new i({name:"download",call:"bzz_download",params:2,inputFormatter:[null,null]}),o=new i({name:"upload",call:"bzz_upload",params:2,inputFormatter:[null,null]}),a=new i({name:"retrieve",call:"bzz_retrieve",params:1,inputFormatter:[null]}),s=new i({name:"store",call:"bzz_store",params:2,inputFormatter:[null,null]}),u=new i({name:"get",call:"bzz_get",params:1,inputFormatter:[null]}),c=new i({name:"put",call:"bzz_put",params:2,inputFormatter:[null,null]}),l=new i({name:"modify",call:"bzz_modify",params:4,inputFormatter:[null,null,null,null]});return[t,e,n,r,o,a,s,u,c,l]},s=function(){return[new o({name:"hive",getter:"bzz_hive"}),new o({name:"info",getter:"bzz_info"})]};e.exports=r},{"../method":31,"../property":39}],38:[function(t,e,n){var r=t("../contracts/GlobalRegistrar.json"),i=t("../contracts/ICAPRegistrar.json"),o="0xc6d9d2cd449a754c494264e1809c50e34d64562b",a="0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00";e.exports={global:{abi:r,address:o},icap:{abi:i,address:a}}},{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],39:[function(t,e,n){var r=t("../utils/utils"),i=function(t){this.name=t.name,this.getter=t.getter,this.setter=t.setter,this.outputFormatter=t.outputFormatter,this.inputFormatter=t.inputFormatter,this.requestManager=null};i.prototype.setRequestManager=function(t){this.requestManager=t},i.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter(t):t},i.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t&&void 0!==t?this.outputFormatter(t):t},i.prototype.extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},i.prototype.attachToObject=function(t){var e={get:this.buildGet(),enumerable:!0},n=this.name.split("."),r=n[0];n.length>1&&(t[n[0]]=t[n[0]]||{},t=t[n[0]],r=n[1]),Object.defineProperty(t,r,e),t[o(r)]=this.buildAsyncGet()};var o=function(t){return"get"+t.charAt(0).toUpperCase()+t.slice(1)};i.prototype.buildGet=function(){var t=this;return function(){return t.formatOutput(t.requestManager.sendSync({method:t.getter}))}},i.prototype.buildAsyncGet=function(){var t=this,e=function(e){t.requestManager.send({method:t.getter},function(n,r){e(n,t.formatOutput(r))})};return e.request=this.request.bind(this),e},i.prototype.request=function(){var t={method:this.getter,params:[],callback:this.extractCallback(Array.prototype.slice.call(arguments))};return t.format=this.formatOutput.bind(this),t},e.exports=i},{"../utils/utils":20}],40:[function(t,e,n){var r=t("../errors");"undefined"!=typeof window&&window.XMLHttpRequest?XMLHttpRequest=window.XMLHttpRequest:XMLHttpRequest=t("xmlhttprequest").XMLHttpRequest;var i=t("xhr2"),o=function(t,e){this.host=t||"http://localhost:8545",this.timeout=e||0};o.prototype.prepareRequest=function(t){var e;return t?(e=new i,e.timeout=this.timeout):e=new XMLHttpRequest,e.open("POST",this.host,t),e.setRequestHeader("Content-Type","application/json"),e},o.prototype.sendSync=function(t){var e=this.prepareRequest(!1);try{e.send(JSON.stringify(t))}catch(t){throw r.InvalidConnection(this.host)}var n=e.responseText;try{n=JSON.parse(n)}catch(t){throw r.InvalidResponse(e.responseText)}return n},o.prototype.send=function(t,e){var n=this.prepareRequest(!0);n.onreadystatechange=function(){if(4===n.readyState&&1!==n.timeout){var t=n.responseText,i=null;try{t=JSON.parse(t)}catch(t){i=r.InvalidResponse(n.responseText)}e(i,t)}},n.ontimeout=function(){e(r.ConnectionTimeout(this.timeout))};try{n.send(JSON.stringify(t))}catch(t){e(r.InvalidConnection(this.host))}},o.prototype.isConnected=function(){try{return this.sendSync({id:9999999999,jsonrpc:"2.0",method:"net_listening",params:[]}),!0}catch(t){return!1}},e.exports=o},{"../errors":25,xhr2:87,xmlhttprequest:17}],41:[function(t,e,n){"use strict";var r=t("../../utils/utils"),i=t("../errors"),o=function(t,e){var n=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=t,this.connection=e.connect({path:this.path}),this.addDefaultEvents(),this.connection.on("data",function(t){n._parseResponse(t.toString()).forEach(function(t){var e=null;r.isArray(t)?t.forEach(function(t){n.responseCallbacks[t.id]&&(e=t.id)}):e=t.id,e||"eth_subscription"!==t.method?n.responseCallbacks[e]&&(n.responseCallbacks[e](null,t),delete n.responseCallbacks[e]):n.notificationCallbacks.forEach(function(e){r.isFunction(e)&&e(null,t)})})})};o.prototype.addDefaultEvents=function(){var t=this;this.connection.on("connect",function(){}),this.connection.on("error",function(){t._timeout()}),this.connection.on("end",function(){t._timeout(),t.notificationCallbacks.forEach(function(t){r.isFunction(t)&&t(new Error("IPC socket connection closed"))})}),this.connection.on("timeout",function(){t._timeout()})},o.prototype._parseResponse=function(t){var e=this,n=[],r=t.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|");return r.forEach(function(t){e.lastChunk&&(t=e.lastChunk+t);var r=null;try{r=JSON.parse(t)}catch(n){return e.lastChunk=t,clearTimeout(e.lastChunkTimeout),void(e.lastChunkTimeout=setTimeout(function(){throw e._timeout(),i.InvalidResponse(t)},15e3))}clearTimeout(e.lastChunkTimeout),e.lastChunk=null,r&&n.push(r)}),n},o.prototype._addResponseCallback=function(t,e){var n=t.id||t[0].id,r=t.method||t[0].method;this.responseCallbacks[n]=e,this.responseCallbacks[n].method=r},o.prototype._timeout=function(){for(var t in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(t)&&(this.responseCallbacks[t](i.InvalidConnection("on IPC")),delete this.responseCallbacks[t])},o.prototype.reconnect=function(){this.connection.connect({path:this.path})},o.prototype.isConnected=function(){var t=this;return t.connection.writable||t.connection.connect({path:t.path}),!!this.connection.writable},o.prototype.sendSync=function(t){if(this.connection.writeSync){var e;this.connection.writable||this.connection.connect({path:this.path});var n=this.connection.writeSync(JSON.stringify(t));try{e=JSON.parse(n)}catch(t){throw i.InvalidResponse(n)}return e}throw new Error('You tried to send "'+t.method+'" synchronously. Synchronous requests are not supported by the IPC provider.')},o.prototype.send=function(t,e){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(t)),this._addResponseCallback(t,e)},o.prototype.on=function(t,e){if("function"!=typeof e)throw new Error("The second parameter callback must be a function.");switch(t){case"notification":this.notificationCallbacks.push(e);break;default:this.connection.on(t,e)}},o.prototype.once=function(t,e){if("function"!=typeof e)throw new Error("The second parameter callback must be a function.");this.connection.once(t,e)},o.prototype.removeListener=function(t,e){var n=this;switch(t){case"notification":this.notificationCallbacks.forEach(function(t,r){t===e&&n.notificationCallbacks.splice(r,1)});break;default:this.connection.removeListener(t,e)}},o.prototype.removeAllListeners=function(t){switch(t){case"notification":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(t)}},o.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},e.exports=o},{"../../utils/utils":20,"../errors":25}],42:[function(t,e,n){"use strict";var r=t("../../utils/utils"),i=t("../errors"),o=function(t){var e=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=t,this.connection=new WebSocket(t),this.addDefaultEvents(),this.connection.onmessage=function(t){var n="string"==typeof t.data?t.data:"";e._parseResponse(n).forEach(function(t){var n=null;r.isArray(t)?t.forEach(function(t){e.responseCallbacks[t.id]&&(n=t.id)}):n=t.id,n||"eth_subscription"!==t.method?e.responseCallbacks[n]&&(e.responseCallbacks[n](null,t),delete e.responseCallbacks[n]):e.notificationCallbacks.forEach(function(e){r.isFunction(e)&&e(null,t)})})}};o.prototype.addDefaultEvents=function(){var t=this;this.connection.onerror=function(){t._timeout()},this.connection.onclose=function(e){t._timeout();var n=t.notificationCallbacks;t.reset(),n.forEach(function(t){r.isFunction(t)&&t(e)})}},o.prototype._parseResponse=function(t){var e=this,n=[],r=t.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|");return r.forEach(function(t){e.lastChunk&&(t=e.lastChunk+t);var r=null;try{r=JSON.parse(t)}catch(n){return e.lastChunk=t,clearTimeout(e.lastChunkTimeout),void(e.lastChunkTimeout=setTimeout(function(){throw e._timeout(),i.InvalidResponse(t)},15e3))}clearTimeout(e.lastChunkTimeout),e.lastChunk=null,r&&n.push(r)}),n},o.prototype._addResponseCallback=function(t,e){var n=t.id||t[0].id,r=t.method||t[0].method;this.responseCallbacks[n]=e,this.responseCallbacks[n].method=r},o.prototype._timeout=function(){for(var t in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(t)&&(this.responseCallbacks[t](i.InvalidConnection("on IPC")),delete this.responseCallbacks[t])},o.prototype.isConnected=function(){console.log(this.connection)},o.prototype.sendSync=function(t){throw new Error('You tried to send "'+t.method+'" synchronously. Synchronous requests are not supported by the Websocket provider.')},o.prototype.send=function(t,e){this.connection.send(JSON.stringify(t)),this._addResponseCallback(t,e)},o.prototype.on=function(t,e){if("function"!=typeof e)throw new Error("The second parameter callback must be a function.");switch(t){case"notification":this.notificationCallbacks.push(e);break;case"connect":this.connection.onopen=e}},o.prototype.removeListener=function(t,e){var n=this;switch(t){case"notification":this.notificationCallbacks.forEach(function(t,r){t===e&&n.notificationCallbacks.splice(r,1)})}},o.prototype.removeAllListeners=function(t){switch(t){case"notification":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null}},o.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},e.exports=o},{"../../utils/utils":20,"../errors":25}],43:[function(t,e,n){var r=t("./jsonrpc"),i=t("../utils/utils"),o=t("./errors"),a=function(t){this.setProvider(t),this.subscriptions={}};a.prototype.sendSync=function(t){if(!this.provider)return console.error(o.InvalidProvider()),null;var e=r.toPayload(t.method,t.params),n=this.provider.sendSync(e);if(!r.isValidResponse(n))throw o.InvalidResponse(n);return n.result},a.prototype.send=function(t,e){if(e=e||function(){},!this.provider)return e(o.InvalidProvider());var n=r.toPayload(t.method,t.params);this.provider.send(n,function(t,i){return n.id!==i.id?e(new Error('Wrong response id "'+i.id+'" (expected: "'+n.id+'") in '+JSON.stringify(n))):t?e(t):r.isValidResponse(i)?void e(null,i.result):e(o.InvalidResponse(i)); })},a.prototype.sendBatch=function(t,e){if(!this.provider)return e(o.InvalidProvider());var n=r.toBatchPayload(t);this.provider.send(n,function(t,n){return t?e(t):i.isArray(n)?void e(t,n):e(o.InvalidResponse(n))})},a.prototype.addSubscription=function(t,e,n,r){if(!this.provider.on)throw new Error("This provider doesn't support subscriptions",this.provider);this.subscriptions[t]={callback:r,type:n,name:e}},a.prototype.removeSubscription=function(t,e){var n=this;this.subscriptions[t]&&(this.send({method:this.subscriptions[t].type+"_unsubscribe",params:[t]},e),delete n.subscriptions[t])},a.prototype.setProvider=function(t){var e=this;this.provider&&this.reset(),this.provider=t,this.provider&&this.provider.on&&this.provider.on("notification",function(t,n){t?Object.keys(e.subscriptions).forEach(function(n){e.subscriptions[n].callback&&e.subscriptions[n].callback(t)}):e.subscriptions[n.params.subscription]&&e.subscriptions[n.params.subscription].callback&&e.subscriptions[n.params.subscription].callback(null,n.params.result)})},a.prototype.reset=function(t){var e=this;Object.keys(this.subscriptions).forEach(function(n){t&&"syncing"===e.subscriptions[n].name||e.removeSubscription(n)}),this.provider.reset&&this.provider.reset()},e.exports=a},{"../utils/utils":20,"./errors":25,"./jsonrpc":30}],44:[function(t,e,n){var r=function(){this.defaultBlock="latest",this.defaultAccount=void 0};e.exports=r},{}],45:[function(t,e,n){var r=t("../utils/utils"),i=t("./errors"),o=t("eventemitter3"),a=function(t){var e=new o;this.id=null,this.callback=null,this._reconnectIntervalId=null,this.options={subscription:t.subscription,subscribeMethod:t.subscribeMethod,unsubscribeMethod:t.unsubscribeMethod,requestManager:t.requestManager},this.emit=e.emit,this.on=e.on,this.once=e.once,this.off=e.off,this.listeners=e.listeners,this.listenerCount=e.listenerCount,this.addListener=e.addListener,this.removeListener=e.removeListener,this.removeAllListeners=e.removeAllListeners,this.setMaxListeners=e.setMaxListeners,this.getMaxListeners=e.getMaxListeners};a.prototype._extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},a.prototype._validateArgs=function(t){var e=this.options.subscription;if(e||(e={}),e.params||(e.params=0),t.length!==e.params+1)throw i.InvalidNumberOfParams()},a.prototype._formatInput=function(t){var e=this.options.subscription;if(!e||!e.inputFormatter)return t;var n=e.inputFormatter.map(function(e,n){return e?e(t[n+1]):t[n+1]});return n.unshift(t[0]),n},a.prototype._formatOutput=function(t){var e=this.options.subscription;return e&&e.outputFormatter&&t?e.outputFormatter(t):t},a.prototype._toPayload=function(t){this.callback=this._extractCallback(t);var e=this._formatInput(t);return this._validateArgs(e),{method:this.options.subscribeMethod,params:e}},a.prototype.unsubscribe=function(t){this.options.requestManager.removeSubscription(this.id,t),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var t=this,e=arguments,n=this._toPayload(Array.prototype.slice.call(arguments));if(!this.options.requestManager.provider.on)throw new Error("The current provider doesn't support subscriptions",this.options.requestManager.provider);if(this.options.params=n.params[1],"logs"===n.params[0]&&r.isObject(n.params[1])&&n.params[1].hasOwnProperty("fromBlock")&&isFinite(n.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[n.params[1]]},function(e,n){e?(t.callback(e,null,t),t.emit("error",e)):n.forEach(function(e){var n=t._formatOutput(e);t.callback(null,n,t),t.emit("data",n)})}),t.callback)return"object"==typeof n.params[1]&&delete n.params[1].fromBlock,this.options.requestManager.send(n,function(i,o){!i&&o?(t.id=o,t.options.requestManager.addSubscription(t.id,n.params[0],"eth",function(n,i){r.isArray(i)&&(i=i[0]);var o=t._formatOutput(i);n?(t.options.requestManager.removeSubscription(t.id),t.options.requestManager.provider.once&&(t._reconnectIntervalId=setInterval(function(){t.options.requestManager.provider.reconnect()},500),t.options.requestManager.provider.once("connect",function(){clearInterval(t._reconnectIntervalId),t.subscribe.apply(t,e)})),t.emit("error",n)):o.removed?t.emit("changed",o):t.emit("data",o),t.callback(n,o,t)})):t.callback(i,null,t)}),this;throw new Error("Subscriptions require a callback as the last parameter!")},e.exports=a},{"../utils/utils":20,"./errors":25,eventemitter3:84}],46:[function(t,e,n){var r=t("./subscription.js"),i=function(t){this.name=t.name,this.subscribe=t.subscribe,this.unsubscribe=t.unsubscribe,this.subscriptions=t.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(t){this.requestManager=t},i.prototype.attachToObject=function(t){var e=this.buildCall();e.call=this.call;var n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},t[n[0]][n[1]]=e):t[n[0]]=e},i.prototype.buildCall=function(){var t=this;return function(){var e=new r({subscription:t.subscriptions[arguments[0]],subscribeMethod:t.subscribe,unsubscribeMethod:t.unsubscribe,requestManager:t.requestManager});return e.subscribe.apply(e,arguments)}},e.exports=i},{"./subscription.js":45}],47:[function(t,e,n){var r=t("./iban"),i=t("../contracts/SmartExchange.json"),o=function(t,e,n,i,o){var u=new r(n);if(!u.isValid())throw new Error("invalid iban address");if(u.isDirect())return a(t,e,u.address(),i,o);if(!o){var c=t.icapNamereg().addr(u.institution());return s(t,e,c,i,u.client())}t.icapNamereg().addr(u.institution(),function(n,r){return s(t,e,r,i,u.client(),o)})},a=function(t,e,n,r,i){return t.sendTransaction({address:n,from:e,value:r},i)},s=function(t,e,n,r,o,a){var s=i;return t.contract(s).at(n).deposit(o,{from:e,value:r},a)};e.exports=o},{"../contracts/SmartExchange.json":3,"./iban":29}],48:[function(t,e,n){!function(t){if("object"==typeof n&&"undefined"!=typeof e)e.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;"undefined"!=typeof window?r=window:"undefined"!=typeof global?r=global:"undefined"!=typeof self&&(r=self),r.Promise=t()}}(function(){var t,e,n;return function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof _dereq_&&_dereq_;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof _dereq_&&_dereq_,a=0;a0;){var e=t.shift();if("function"==typeof e){var n=t.shift(),r=t.shift();e.call(n,r)}else e._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=s},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,o=function(t,e){this._reject(e)},a=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},s=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},u=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var c=n(o),l=new t(e);l._propagateFrom(this,1);var f=this._target();if(l._setBoundTo(c),c instanceof t){var p={promiseRejectionQueued:!1,promise:l,target:f,bindingPromise:c};f._then(e,a,void 0,l,p),c._then(s,u,void 0,l,p),l._setOnCancel(c)}else l._resolveCallback(f);return l},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=this._bitField&-2097153},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],4:[function(t,e,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=r,e.exports=o},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var i=r(null),o=r(null);i[" size"]=o[" size"]=0}e.exports=function(e){function n(t,n){var r;if(null!=t&&(r=t[n]),"function"!=typeof r){var i="Object "+s.classString(t)+" has no method '"+s.toString(n)+"'";throw new e.TypeError(i)}return r}function r(t){var e=this.pop(),r=n(t,e);return r.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return e<0&&(e=Math.max(0,e+t.length)),t[e]}var a,s=t("./util"),u=s.canEvaluate;s.isIdentifier;e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(r,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e,n="number"==typeof t;if(n)e=o;else if(u){var r=a(t);e=null!==r?r:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util"),a=o.tryCatch,s=o.errorObj,u=e._async;e.prototype.break=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),!!this._enoughBranchesHaveCancelled()&&(this._invokeOnCancel(),!0))},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),u.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var n=0;n=0)return o[t]}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=n,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var n=t.prototype._pushContext,o=t.prototype._popContext,a=t._peekContext,s=t.prototype._peekContext,u=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=o,t._peekContext=a,t.prototype._peekContext=s,t.prototype._promiseCreated=u,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=r,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],9:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,e){return{promise:e}}function i(){return!1}function o(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+L.toString(t));r._attachCancellationCallback(t)})}catch(t){return t}}function a(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?L.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function s(){return this._onCancelField}function u(t){this._onCancelField=t}function c(){this._cancellationParent=void 0,this._onCancelField=void 0}function l(t,e){if(0!==(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function f(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function p(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function h(){this._trace=new T(this._peekContext())}function d(t,e){if(N(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=x(t);L.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),L.notEnumerableProp(t,"__stackCleaned__",!0)}}}function _(t,e,n,r,i){if(void 0===t&&null!==e&&X){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var o="",a="";if(e._trace){for(var s=e._trace.stack.split("\n"),u=w(s),c=u.length-1;c>=0;--c){var l=u[c];if(!z.test(l)){var f=l.match(q);f&&(o="at "+f[1]+":"+f[2]+":"+f[3]+" ");break}}if(u.length>0)for(var p=u[0],c=0;c0&&(a="\n"+s[c-1]);break}}var h="a promise was created in a "+n+"handler "+o+"but was not returned from it, see http://goo.gl/rRqMUw"+a;r._warn(h,!0,e)}}function v(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),y(n)}function y(t,n,r){if(ot.warnings){var i,o=new M(t);if(n)r._attachExtraTrace(o);else if(ot.longStackTraces&&(i=e._peekContext()))i.attachExtraTrace(o);else{var a=x(o);o.stack=a.message+"\n"+a.stack.join("\n")}tt("warning",o)||C(o,"",!0)}}function m(t,e){for(var n=0;n=0;--s)if(r[s]===o){a=s;break}for(var s=a;s>=0;--s){var u=r[s];if(e[i]!==u)break;e.pop(),i--}e=r}}function w(t){for(var e=[],n=0;n0&&"SyntaxError"!=t.name&&(e=e.slice(n)),e}function x(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&e.length>0?k(t):[" (No stack trace)"],{message:n,stack:"SyntaxError"==t.name?e:w(e)}}function C(t,e,n){if("undefined"!=typeof console){var r;if(L.isObject(t)){var i=t.stack;r=e+W(i,t)}else r=e+String(t);"function"==typeof P?P(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function j(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(t){D.throwLater(t)}"unhandledRejection"===t?tt(t,n,r)||i||C(n,"Unhandled rejection "):tt(t,r)}function E(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():L.toString(t);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(e))try{var r=JSON.stringify(t);e=r}catch(t){}0===e.length&&(e="(empty array)")}return"(<"+F(e)+">, no stack trace)"}function F(t){var e=41;return t.length=s||(nt=function(t){if(H.test(t))return!0;var e=A(t);return!!(e&&e.fileName===n&&a<=e.line&&e.line<=s)})}}function T(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);it(this,T),e>32&&this.uncycle()}var O,R,P,I=e._getDomain,D=e._async,M=t("./errors").Warning,L=t("./util"),N=L.canAttachTrace,H=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,z=/\((?:timers\.js):\d+:\d+\)/,q=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,U=null,W=null,V=!1,$=!(0==L.env("BLUEBIRD_DEBUG")),J=!(0==L.env("BLUEBIRD_WARNINGS")||!$&&!L.env("BLUEBIRD_WARNINGS")),G=!(0==L.env("BLUEBIRD_LONG_STACK_TRACES")||!$&&!L.env("BLUEBIRD_LONG_STACK_TRACES")),X=0!=L.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(J||!!L.env("BLUEBIRD_W_FORGOTTEN_RETURN"));e.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=t._bitField&-1048577|524288},e.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),D.invokeLater(this._notifyUnhandledRejection,this,void 0))},e.prototype._notifyUnhandledRejectionIsHandled=function(){j("rejectionHandled",O,void 0,this)},e.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},e.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),j("unhandledRejection",R,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=this._bitField&-262145},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=this._bitField&-1048577,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(t,e,n){return y(t,e,n||this)},e.onPossiblyUnhandledRejection=function(t){var e=I();R="function"==typeof t?null===e?t:L.domainBind(e,t):void 0},e.onUnhandledRejectionHandled=function(t){var e=I();O="function"==typeof t?null===e?t:L.domainBind(e,t):void 0};var K=function(){};e.longStackTraces=function(){if(D.haveItemsQueued()&&!ot.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!ot.longStackTraces&&S()){var t=e.prototype._captureStackTrace,r=e.prototype._attachExtraTrace;ot.longStackTraces=!0,K=function(){if(D.haveItemsQueued()&&!ot.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=t,e.prototype._attachExtraTrace=r,n.deactivateLongStackTraces(),D.enableTrampoline(),ot.longStackTraces=!1},e.prototype._captureStackTrace=h,e.prototype._attachExtraTrace=d,n.activateLongStackTraces(),D.disableTrampolineIfNecessary()}},e.hasLongStackTraces=function(){return ot.longStackTraces&&S()};var Q=function(){try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return L.global.dispatchEvent(t),function(t,e){var n=new CustomEvent(t.toLowerCase(),{detail:e,cancelable:!0});return!L.global.dispatchEvent(n)}}if("function"==typeof Event){var t=new Event("CustomEvent");return L.global.dispatchEvent(t),function(t,e){var n=new Event(t.toLowerCase(),{cancelable:!0});return n.detail=e,!L.global.dispatchEvent(n)}}var t=document.createEvent("CustomEvent");return t.initCustomEvent("testingtheevent",!1,!0,{}),L.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!L.global.dispatchEvent(n)}}catch(t){}return function(){return!1}}(),Z=function(){return L.isNode?function(){return process.emit.apply(process,arguments)}:L.global?function(t){var e="on"+t.toLowerCase(),n=L.global[e];return!!n&&(n.apply(L.global,[].slice.call(arguments,1)),!0)}:function(){return!1}}(),Y={promiseCreated:r,promiseFulfilled:r,promiseRejected:r,promiseResolved:r,promiseCancelled:r,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:r},tt=function(t){var e=!1;try{e=Z.apply(null,arguments)}catch(t){D.throwLater(t),e=!0}var n=!1;try{n=Q(t,Y[t].apply(null,arguments))}catch(t){D.throwLater(t),n=!0}return n||e};e.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&K()),"warnings"in t){var n=t.warnings;ot.warnings=!!n,X=ot.warnings,L.isObject(n)&&"wForgottenReturn"in n&&(X=!!n.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!ot.cancellation){if(D.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=c,e.prototype._propagateFrom=l,e.prototype._onCancel=s,e.prototype._setOnCancel=u,e.prototype._attachCancellationCallback=a,e.prototype._execute=o,et=l,ot.cancellation=!0}return"monitoring"in t&&(t.monitoring&&!ot.monitoring?(ot.monitoring=!0,e.prototype._fireEvent=tt):!t.monitoring&&ot.monitoring&&(ot.monitoring=!1,e.prototype._fireEvent=i)),e},e.prototype._fireEvent=i,e.prototype._execute=function(t,e,n){try{t(e,n)}catch(t){return t}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(t){},e.prototype._attachCancellationCallback=function(t){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(t,e){};var et=f,nt=function(){return!1},rt=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;L.inherits(T,Error),n.CapturedTrace=T,T.prototype.uncycle=function(){var t=this._length;if(!(t<2)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;t=this._length=r;for(var r=t-1;r>=0;--r){var o=e[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;r0&&(e[s-1]._parent=void 0,e[s-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var u=r>0?e[r-1]:this;s=0;--l)e[l]._length=c,c++;return}}}},T.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=x(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(w(i.stack.split("\n"))),i=i._parent;b(r),g(r),L.notEnumerableProp(t,"stack",m(n,r)),L.notEnumerableProp(t,"__stackCleaned__",!0)}};var it=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():E(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,U=t,W=e;var n=Error.captureStackTrace;return nt=function(t){return H.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return U=/@/,W=e,V=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(t){i="stack"in t}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(W=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?E(e):e.toString()},null):(U=t,W=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(P=function(t){console.warn(t)},L.isNode&&process.stderr.isTTY?P=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:L.isNode||"string"!=typeof(new Error).stack||(P=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var ot={warnings:J,longStackTraces:!1,cancellation:!1,monitoring:!1};return G&&e.longStackTraces(),{longStackTraces:function(){return ot.longStackTraces},warnings:function(){return ot.warnings},cancellation:function(){return ot.cancellation},monitoring:function(){return ot.monitoring},propagateFromFunction:function(){return et},boundValueFunction:function(){return p},checkForgottenReturns:_,setBounds:B,warn:y,deprecated:v,CapturedTrace:T,fireDomEvent:Q,fireGlobalEvent:Z}}},{"./errors":12,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype.return=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype.throw=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1],r=function(){throw e};return this.caught(t,r)},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();var i=function(){return r};return this.caught(n,i)}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){function n(){return o(this)}function r(t,n){return i(t,n,e,e)}var i=t.reduce,o=t.all;t.prototype.each=function(t){return i(this,t,e,0)._then(n,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return i(this,t,e,e)},t.each=function(t,r){return i(t,r,e,0)._then(n,void 0,void 0,t,void 0)},t.mapSeries=r}},{}],12:[function(t,e,n){"use strict";function r(t,e){function n(r){return this instanceof n?(f(this,"message","string"==typeof r?r:e),f(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return l(n,Error),n}function i(t){return this instanceof i?(f(this,"name","OperationalError"),f(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(f(this,"message",t.message),f(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,a,s=t("./es5"),u=s.freeze,c=t("./util"),l=c.inherits,f=c.notEnumerableProp,p=r("Warning","warning"),h=r("CancellationError","cancellation error"),d=r("TimeoutError","timeout error"),_=r("AggregateError","aggregate error");try{o=TypeError,a=RangeError}catch(t){o=r("TypeError","type error"),a=r("RangeError","range error")}for(var v="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),y=0;yr&&(e=t.finalize(e)),e.clamp();for(var i=this._oKey=e.clone(),a=this._iKey=e.clone(),s=i.words,u=a.words,c=0;c>>2]|=t[r]<<24-r%4*8;i.call(this,n,e)}else i.apply(this,arguments)};o.prototype=r}}(),t.lib.WordArray})},{"./core":52}],60:[function(t,e,n){!function(r,i){"object"==typeof n?e.exports=n=i(t("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(r.CryptoJS)}(this,function(t){return function(e){function n(t,e,n,r,i,o,a){var s=t+(e&n|~e&r)+i+a;return(s<>>32-o)+e}function r(t,e,n,r,i,o,a){var s=t+(e&r|n&~r)+i+a;return(s<>>32-o)+e}function i(t,e,n,r,i,o,a){var s=t+(e^n^r)+i+a;return(s<>>32-o)+e}function o(t,e,n,r,i,o,a){var s=t+(n^(e|~r))+i+a;return(s<>>32-o)+e}var a=t,s=a.lib,u=s.WordArray,c=s.Hasher,l=a.algo,f=[];!function(){for(var t=0;t<64;t++)f[t]=4294967296*e.abs(e.sin(t+1))|0}();var p=l.MD5=c.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var a=0;a<16;a++){var s=e+a,u=t[s];t[s]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var c=this._hash.words,l=t[e+0],p=t[e+1],h=t[e+2],d=t[e+3],_=t[e+4],v=t[e+5],y=t[e+6],m=t[e+7],g=t[e+8],b=t[e+9],w=t[e+10],k=t[e+11],x=t[e+12],C=t[e+13],j=t[e+14],E=t[e+15],F=c[0],S=c[1],A=c[2],B=c[3];F=n(F,S,A,B,l,7,f[0]),B=n(B,F,S,A,p,12,f[1]),A=n(A,B,F,S,h,17,f[2]),S=n(S,A,B,F,d,22,f[3]),F=n(F,S,A,B,_,7,f[4]),B=n(B,F,S,A,v,12,f[5]),A=n(A,B,F,S,y,17,f[6]),S=n(S,A,B,F,m,22,f[7]),F=n(F,S,A,B,g,7,f[8]),B=n(B,F,S,A,b,12,f[9]),A=n(A,B,F,S,w,17,f[10]),S=n(S,A,B,F,k,22,f[11]),F=n(F,S,A,B,x,7,f[12]),B=n(B,F,S,A,C,12,f[13]),A=n(A,B,F,S,j,17,f[14]),S=n(S,A,B,F,E,22,f[15]),F=r(F,S,A,B,p,5,f[16]),B=r(B,F,S,A,y,9,f[17]),A=r(A,B,F,S,k,14,f[18]),S=r(S,A,B,F,l,20,f[19]),F=r(F,S,A,B,v,5,f[20]),B=r(B,F,S,A,w,9,f[21]),A=r(A,B,F,S,E,14,f[22]),S=r(S,A,B,F,_,20,f[23]),F=r(F,S,A,B,b,5,f[24]),B=r(B,F,S,A,j,9,f[25]),A=r(A,B,F,S,d,14,f[26]),S=r(S,A,B,F,g,20,f[27]),F=r(F,S,A,B,C,5,f[28]),B=r(B,F,S,A,h,9,f[29]),A=r(A,B,F,S,m,14,f[30]),S=r(S,A,B,F,x,20,f[31]),F=i(F,S,A,B,v,4,f[32]),B=i(B,F,S,A,g,11,f[33]),A=i(A,B,F,S,k,16,f[34]),S=i(S,A,B,F,j,23,f[35]),F=i(F,S,A,B,p,4,f[36]),B=i(B,F,S,A,_,11,f[37]),A=i(A,B,F,S,m,16,f[38]),S=i(S,A,B,F,w,23,f[39]),F=i(F,S,A,B,C,4,f[40]),B=i(B,F,S,A,l,11,f[41]),A=i(A,B,F,S,d,16,f[42]),S=i(S,A,B,F,y,23,f[43]),F=i(F,S,A,B,b,4,f[44]),B=i(B,F,S,A,x,11,f[45]),A=i(A,B,F,S,E,16,f[46]),S=i(S,A,B,F,h,23,f[47]),F=o(F,S,A,B,l,6,f[48]),B=o(B,F,S,A,m,10,f[49]),A=o(A,B,F,S,j,15,f[50]),S=o(S,A,B,F,v,21,f[51]),F=o(F,S,A,B,x,6,f[52]),B=o(B,F,S,A,d,10,f[53]),A=o(A,B,F,S,w,15,f[54]),S=o(S,A,B,F,p,21,f[55]),F=o(F,S,A,B,g,6,f[56]),B=o(B,F,S,A,E,10,f[57]),A=o(A,B,F,S,y,15,f[58]),S=o(S,A,B,F,C,21,f[59]),F=o(F,S,A,B,_,6,f[60]),B=o(B,F,S,A,k,10,f[61]),A=o(A,B,F,S,h,15,f[62]),S=o(S,A,B,F,b,21,f[63]),c[0]=c[0]+F|0,c[1]=c[1]+S|0,c[2]=c[2]+A|0,c[3]=c[3]+B|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296),a=r;n[(i+64>>>9<<4)+15]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[(i+64>>>9<<4)+14]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(n.length+1),this._process();for(var s=this._hash,u=s.words,c=0;c<4;c++){var l=u[c];u[c]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return s},clone:function(){var t=c.clone.call(this);return t._hash=this._hash.clone(),t}});a.MD5=c._createHelper(p),a.HmacMD5=c._createHmacHelper(p)}(Math),t.MD5})},{"./core":52}],61:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(r.CryptoJS)}(this,function(t){return t.mode.CFB=function(){function e(t,e,n,r){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else var o=this._prevBlock;r.encryptBlock(o,0);for(var a=0;a>24&255)){var e=t>>16&255,n=t>>8&255,r=255&t;255===e?(e=0,255===n?(n=0,255===r?r=0:++r):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=r}else t+=1<<24;return t}function n(t){return 0===(t[0]=e(t[0]))&&(t[1]=e(t[1])),t}var r=t.lib.BlockCipherMode.extend(),i=r.Encryptor=r.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,o=this._iv,a=this._counter;o&&(a=this._counter=o.slice(0),this._iv=void 0),n(a);var s=a.slice(0);r.encryptBlock(s,0);for(var u=0;u>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923})},{"./cipher-core":51,"./core":52}],67:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(r.CryptoJS)}(this,function(t){return t.pad.Iso10126={pad:function(e,n){var r=4*n,i=r-e.sigBytes%r;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126})},{"./cipher-core":51,"./core":52}],68:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(r.CryptoJS)}(this,function(t){return t.pad.Iso97971={pad:function(e,n){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,n)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971})},{"./cipher-core":51,"./core":52}],69:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(r.CryptoJS)}(this,function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding})},{"./cipher-core":51,"./core":52}],70:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(r.CryptoJS)}(this,function(t){return t.pad.ZeroPadding={pad:function(t,e){var n=4*e;t.clamp(),t.sigBytes+=n-(t.sigBytes%n||n)},unpad:function(t){for(var e=t.words,n=t.sigBytes-1;!(e[n>>>2]>>>24-n%4*8&255);)n--;t.sigBytes=n+1}},t.pad.ZeroPadding})},{"./cipher-core":51,"./core":52}],71:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./sha1"),t("./hmac")):"function"==typeof define&&define.amd?define(["./core","./sha1","./hmac"],i):i(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.Base,i=n.WordArray,o=e.algo,a=o.SHA1,s=o.HMAC,u=o.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:a,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var n=this.cfg,r=s.create(n.hasher,t),o=i.create(),a=i.create([1]),u=o.words,c=a.words,l=n.keySize,f=n.iterations;u.length>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(var n=0;n<8;n++){var r=t[n]+e[n],i=65535&r,o=r>>>16,a=((i*i>>>17)+i*o>>>15)+o*o,c=((4294901760&r)*r|0)+((65535&r)*r|0);u[n]=a^c}t[0]=u[0]+(u[7]<<16|u[7]>>>16)+(u[6]<<16|u[6]>>>16)|0,t[1]=u[1]+(u[0]<<8|u[0]>>>24)+u[7]|0,t[2]=u[2]+(u[1]<<16|u[1]>>>16)+(u[0]<<16|u[0]>>>16)|0,t[3]=u[3]+(u[2]<<8|u[2]>>>24)+u[1]|0,t[4]=u[4]+(u[3]<<16|u[3]>>>16)+(u[2]<<16|u[2]>>>16)|0,t[5]=u[5]+(u[4]<<8|u[4]>>>24)+u[3]|0,t[6]=u[6]+(u[5]<<16|u[5]>>>16)+(u[4]<<16|u[4]>>>16)|0,t[7]=u[7]+(u[6]<<8|u[6]>>>24)+u[5]|0}var n=t,r=n.lib,i=r.StreamCipher,o=n.algo,a=[],s=[],u=[],c=o.RabbitLegacy=i.extend({_doReset:function(){var t=this._key.words,n=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var o=0;o<4;o++)e.call(this);for(var o=0;o<8;o++)i[o]^=r[o+4&7];if(n){var a=n.words,s=a[0],u=a[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),l=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),f=c>>>16|4294901760&l,p=l<<16|65535&c;i[0]^=c,i[1]^=f,i[2]^=l,i[3]^=p,i[4]^=c,i[5]^=f,i[6]^=l,i[7]^=p;for(var o=0;o<4;o++)e.call(this)}},_doProcessBlock:function(t,n){var r=this._X;e.call(this),a[0]=r[0]^r[5]>>>16^r[3]<<16,a[1]=r[2]^r[7]>>>16^r[5]<<16,a[2]=r[4]^r[1]>>>16^r[7]<<16,a[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)a[i]=16711935&(a[i]<<8|a[i]>>>24)|4278255360&(a[i]<<24|a[i]>>>8),t[n+i]^=a[i]},blockSize:4,ivSize:2});n.RabbitLegacy=i._createHelper(c)}(),t.RabbitLegacy})},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],73:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(r.CryptoJS)}(this,function(t){return function(){function e(){for(var t=this._X,e=this._C,n=0;n<8;n++)s[n]=e[n];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(var n=0;n<8;n++){var r=t[n]+e[n],i=65535&r,o=r>>>16,a=((i*i>>>17)+i*o>>>15)+o*o,c=((4294901760&r)*r|0)+((65535&r)*r|0);u[n]=a^c}t[0]=u[0]+(u[7]<<16|u[7]>>>16)+(u[6]<<16|u[6]>>>16)|0,t[1]=u[1]+(u[0]<<8|u[0]>>>24)+u[7]|0,t[2]=u[2]+(u[1]<<16|u[1]>>>16)+(u[0]<<16|u[0]>>>16)|0,t[3]=u[3]+(u[2]<<8|u[2]>>>24)+u[1]|0,t[4]=u[4]+(u[3]<<16|u[3]>>>16)+(u[2]<<16|u[2]>>>16)|0,t[5]=u[5]+(u[4]<<8|u[4]>>>24)+u[3]|0,t[6]=u[6]+(u[5]<<16|u[5]>>>16)+(u[4]<<16|u[4]>>>16)|0,t[7]=u[7]+(u[6]<<8|u[6]>>>24)+u[5]|0}var n=t,r=n.lib,i=r.StreamCipher,o=n.algo,a=[],s=[],u=[],c=o.Rabbit=i.extend({_doReset:function(){for(var t=this._key.words,n=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var i=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],o=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var r=0;r<4;r++)e.call(this);for(var r=0;r<8;r++)o[r]^=i[r+4&7];if(n){var a=n.words,s=a[0],u=a[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),l=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),f=c>>>16|4294901760&l,p=l<<16|65535&c;o[0]^=c,o[1]^=f,o[2]^=l,o[3]^=p,o[4]^=c,o[5]^=f,o[6]^=l,o[7]^=p;for(var r=0;r<4;r++)e.call(this)}},_doProcessBlock:function(t,n){var r=this._X;e.call(this),a[0]=r[0]^r[5]>>>16^r[3]<<16,a[1]=r[2]^r[7]>>>16^r[5]<<16,a[2]=r[4]^r[1]>>>16^r[7]<<16,a[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)a[i]=16711935&(a[i]<<8|a[i]>>>24)|4278255360&(a[i]<<24|a[i]>>>8),t[n+i]^=a[i]},blockSize:4,ivSize:2});n.Rabbit=i._createHelper(c)}(),t.Rabbit})},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],74:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(r.CryptoJS)}(this,function(t){return function(){function e(){for(var t=this._S,e=this._i,n=this._j,r=0,i=0;i<4;i++){e=(e+1)%256,n=(n+t[e])%256;var o=t[e];t[e]=t[n],t[n]=o,r|=t[(t[e]+t[n])%256]<<24-8*i}return this._i=e,this._j=n,r}var n=t,r=n.lib,i=r.StreamCipher,o=n.algo,a=o.RC4=i.extend({_doReset:function(){for(var t=this._key,e=t.words,n=t.sigBytes,r=this._S=[],i=0;i<256;i++)r[i]=i;for(var i=0,o=0;i<256;i++){var a=i%n,s=e[a>>>2]>>>24-a%4*8&255;o=(o+r[i]+s)%256;var u=r[i];r[i]=r[o],r[o]=u}this._i=this._j=0},_doProcessBlock:function(t,n){t[n]^=e.call(this)},keySize:8,ivSize:0});n.RC4=i._createHelper(a);var s=o.RC4Drop=a.extend({cfg:a.cfg.extend({drop:192}),_doReset:function(){a._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)e.call(this)}});n.RC4Drop=i._createHelper(s)}(),t.RC4})},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],75:[function(t,e,n){!function(r,i){"object"==typeof n?e.exports=n=i(t("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(r.CryptoJS)}(this,function(t){return function(e){function n(t,e,n){return t^e^n}function r(t,e,n){return t&e|~t&n}function i(t,e,n){return(t|~e)^n}function o(t,e,n){return t&n|e&~n}function a(t,e,n){return t^(e|~n)}function s(t,e){return t<>>32-e}var u=t,c=u.lib,l=c.WordArray,f=c.Hasher,p=u.algo,h=l.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),d=l.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),_=l.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),v=l.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),y=l.create([0,1518500249,1859775393,2400959708,2840853838]),m=l.create([1352829926,1548603684,1836072691,2053994217,0]),g=p.RIPEMD160=f.extend({_doReset:function(){this._hash=l.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var u=0;u<16;u++){var c=e+u,l=t[c];t[c]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}var f,p,g,b,w,k,x,C,j,E,F=this._hash.words,S=y.words,A=m.words,B=h.words,T=d.words,O=_.words,R=v.words;k=f=F[0],x=p=F[1],C=g=F[2],j=b=F[3],E=w=F[4];for(var P,u=0;u<80;u+=1)P=f+t[e+B[u]]|0,P+=u<16?n(p,g,b)+S[0]:u<32?r(p,g,b)+S[1]:u<48?i(p,g,b)+S[2]:u<64?o(p,g,b)+S[3]:a(p,g,b)+S[4],P=0|P,P=s(P,O[u]),P=P+w|0,f=w,w=b,b=s(g,10),g=p,p=P,P=k+t[e+T[u]]|0,P+=u<16?a(x,C,j)+A[0]:u<32?o(x,C,j)+A[1]:u<48?i(x,C,j)+A[2]:u<64?r(x,C,j)+A[3]:n(x,C,j)+A[4],P=0|P,P=s(P,R[u]),P=P+E|0,k=E,E=j,j=s(C,10),C=x,x=P;P=F[1]+g+j|0,F[1]=F[2]+b+E|0,F[2]=F[3]+w+k|0,F[3]=F[4]+f+x|0,F[4]=F[0]+p+C|0,F[0]=P},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;e[r>>>5]|=128<<24-r%32,e[(r+64>>>9<<4)+14]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,a=0;a<5;a++){var s=o[a];o[a]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return i},clone:function(){var t=f.clone.call(this);return t._hash=this._hash.clone(),t}});u.RIPEMD160=f._createHelper(g),u.HmacRIPEMD160=f._createHmacHelper(g)}(Math),t.RIPEMD160})},{"./core":52}],76:[function(t,e,n){!function(r,i){"object"==typeof n?e.exports=n=i(t("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.WordArray,i=n.Hasher,o=e.algo,a=[],s=o.SHA1=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],u=n[4],c=0;c<80;c++){if(c<16)a[c]=0|t[e+c];else{var l=a[c-3]^a[c-8]^a[c-14]^a[c-16];a[c]=l<<1|l>>>31}var f=(r<<5|r>>>27)+u+a[c];f+=c<20?(i&o|~i&s)+1518500249:c<40?(i^o^s)+1859775393:c<60?(i&o|i&s|o&s)-1894007588:(i^o^s)-899497514,u=s,s=o,o=i<<30|i>>>2,i=r,r=f}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[(r+64>>>9<<4)+14]=Math.floor(n/4294967296),e[(r+64>>>9<<4)+15]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s)}(),t.SHA1})},{"./core":52}],77:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./sha256")):"function"==typeof define&&define.amd?define(["./core","./sha256"],i):i(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.WordArray,i=e.algo,o=i.SHA256,a=i.SHA224=o.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=o._doFinalize.call(this);return t.sigBytes-=4,t}});e.SHA224=o._createHelper(a),e.HmacSHA224=o._createHmacHelper(a)}(),t.SHA224})},{"./core":52,"./sha256":78}],78:[function(t,e,n){!function(r,i){"object"==typeof n?e.exports=n=i(t("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,i=r.WordArray,o=r.Hasher,a=n.algo,s=[],u=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,i=0;i<64;)t(r)&&(i<8&&(s[i]=n(e.pow(r,.5))),u[i]=n(e.pow(r,1/3)),i++),r++}();var c=[],l=a.SHA256=o.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],f=n[6],p=n[7],h=0;h<64;h++){if(h<16)c[h]=0|t[e+h];else{var d=c[h-15],_=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,v=c[h-2],y=(v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10;c[h]=_+c[h-7]+y+c[h-16]}var m=s&l^~s&f,g=r&i^r&o^i&o,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),w=(s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25),k=p+w+m+u[h]+c[h],x=b+g;p=f,f=l,l=s,s=a+k|0,a=o,o=i,i=r,r=k+x|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+s|0,n[5]=n[5]+l|0,n[6]=n[6]+f|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[(i+64>>>9<<4)+14]=e.floor(r/4294967296),n[(i+64>>>9<<4)+15]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});n.SHA256=o._createHelper(l),n.HmacSHA256=o._createHmacHelper(l)}(Math),t.SHA256})},{"./core":52}],79:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],i):i(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,i=r.WordArray,o=r.Hasher,a=n.x64,s=a.Word,u=n.algo,c=[],l=[],f=[];!function(){for(var t=1,e=0,n=0;n<24;n++){c[t+5*e]=(n+1)*(n+2)/2%64;var r=e%5,i=(2*t+3*e)%5;t=r,e=i}for(var t=0;t<5;t++)for(var e=0;e<5;e++)l[t+5*e]=e+(2*t+3*e)%5*5;for(var o=1,a=0;a<24;a++){for(var u=0,p=0,h=0;h<7;h++){if(1&o){var d=(1<>>24)|4278255360&(o<<24|o>>>8),a=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8);var s=n[i];s.high^=a,s.low^=o}for(var u=0;u<24;u++){for(var h=0;h<5;h++){for(var d=0,_=0,v=0;v<5;v++){var s=n[h+5*v];d^=s.high,_^=s.low}var y=p[h];y.high=d,y.low=_}for(var h=0;h<5;h++)for(var m=p[(h+4)%5],g=p[(h+1)%5],b=g.high,w=g.low,d=m.high^(b<<1|w>>>31),_=m.low^(w<<1|b>>>31),v=0;v<5;v++){var s=n[h+5*v];s.high^=d,s.low^=_}for(var k=1;k<25;k++){var s=n[k],x=s.high,C=s.low,j=c[k];if(j<32)var d=x<>>32-j,_=C<>>32-j;else var d=C<>>64-j,_=x<>>64-j;var E=p[l[k]];E.high=d,E.low=_}var F=p[0],S=n[0];F.high=S.high,F.low=S.low;for(var h=0;h<5;h++)for(var v=0;v<5;v++){var k=h+5*v,s=n[k],A=p[k],B=p[(h+1)%5+5*v],T=p[(h+2)%5+5*v];s.high=A.high^~B.high&T.high,s.low=A.low^~B.low&T.low}var s=n[0],O=f[u];s.high^=O.high,s.low^=O.low}},_doFinalize:function(){var t=this._data,n=t.words,r=(8*this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;n[r>>>5]|=1<<24-r%32,n[(e.ceil((r+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*n.length,this._process();for(var a=this._state,s=this.cfg.outputLength/8,u=s/8,c=[],l=0;l>>24)|4278255360&(p<<24|p>>>8),h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),c.push(h),c.push(p)}return new i.init(c,s)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),n=0;n<25;n++)e[n]=e[n].clone();return t}});n.SHA3=o._createHelper(h),n.HmacSHA3=o._createHmacHelper(h)}(Math),t.SHA3})},{"./core":52,"./x64-core":83}],80:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./x64-core"),t("./sha512")):"function"==typeof define&&define.amd?define(["./core","./x64-core","./sha512"],i):i(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.x64,r=n.Word,i=n.WordArray,o=e.algo,a=o.SHA512,s=o.SHA384=a.extend({_doReset:function(){this._hash=new i.init([new r.init(3418070365,3238371032),new r.init(1654270250,914150663),new r.init(2438529370,812702999),new r.init(355462360,4144912697),new r.init(1731405415,4290775857),new r.init(2394180231,1750603025),new r.init(3675008525,1694076839),new r.init(1203062813,3204075428)])},_doFinalize:function(){var t=a._doFinalize.call(this);return t.sigBytes-=16,t}});e.SHA384=a._createHelper(s),e.HmacSHA384=a._createHmacHelper(s)}(),t.SHA384})},{"./core":52,"./sha512":81,"./x64-core":83}],81:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],i):i(r.CryptoJS)}(this,function(t){return function(){function e(){return a.create.apply(a,arguments)}var n=t,r=n.lib,i=r.Hasher,o=n.x64,a=o.Word,s=o.WordArray,u=n.algo,c=[e(1116352408,3609767458),e(1899447441,602891725),e(3049323471,3964484399),e(3921009573,2173295548),e(961987163,4081628472),e(1508970993,3053834265),e(2453635748,2937671579),e(2870763221,3664609560),e(3624381080,2734883394),e(310598401,1164996542),e(607225278,1323610764),e(1426881987,3590304994),e(1925078388,4068182383),e(2162078206,991336113),e(2614888103,633803317),e(3248222580,3479774868),e(3835390401,2666613458),e(4022224774,944711139),e(264347078,2341262773),e(604807628,2007800933),e(770255983,1495990901),e(1249150122,1856431235),e(1555081692,3175218132),e(1996064986,2198950837),e(2554220882,3999719339),e(2821834349,766784016),e(2952996808,2566594879),e(3210313671,3203337956),e(3336571891,1034457026),e(3584528711,2466948901),e(113926993,3758326383),e(338241895,168717936),e(666307205,1188179964),e(773529912,1546045734),e(1294757372,1522805485),e(1396182291,2643833823),e(1695183700,2343527390),e(1986661051,1014477480),e(2177026350,1206759142),e(2456956037,344077627),e(2730485921,1290863460),e(2820302411,3158454273),e(3259730800,3505952657),e(3345764771,106217008),e(3516065817,3606008344),e(3600352804,1432725776),e(4094571909,1467031594),e(275423344,851169720),e(430227734,3100823752),e(506948616,1363258195),e(659060556,3750685593),e(883997877,3785050280),e(958139571,3318307427),e(1322822218,3812723403),e(1537002063,2003034995),e(1747873779,3602036899),e(1955562222,1575990012),e(2024104815,1125592928),e(2227730452,2716904306),e(2361852424,442776044),e(2428436474,593698344),e(2756734187,3733110249),e(3204031479,2999351573),e(3329325298,3815920427),e(3391569614,3928383900),e(3515267271,566280711),e(3940187606,3454069534),e(4118630271,4000239992),e(116418474,1914138554),e(174292421,2731055270),e(289380356,3203993006),e(460393269,320620315),e(685471733,587496836),e(852142971,1086792851),e(1017036298,365543100),e(1126000580,2618297676),e(1288033470,3409855158),e(1501505948,4234509866),e(1607167915,987167468),e(1816402316,1246189591)],l=[];!function(){for(var t=0;t<80;t++)l[t]=e()}();var f=u.SHA512=i.extend({_doReset:function(){this._hash=new s.init([new a.init(1779033703,4089235720),new a.init(3144134277,2227873595),new a.init(1013904242,4271175723),new a.init(2773480762,1595750129),new a.init(1359893119,2917565137),new a.init(2600822924,725511199),new a.init(528734635,4215389547),new a.init(1541459225,327033209)])},_doProcessBlock:function(t,e){ for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],u=n[5],f=n[6],p=n[7],h=r.high,d=r.low,_=i.high,v=i.low,y=o.high,m=o.low,g=a.high,b=a.low,w=s.high,k=s.low,x=u.high,C=u.low,j=f.high,E=f.low,F=p.high,S=p.low,A=h,B=d,T=_,O=v,R=y,P=m,I=g,D=b,M=w,L=k,N=x,H=C,z=j,q=E,U=F,W=S,V=0;V<80;V++){var $=l[V];if(V<16)var J=$.high=0|t[e+2*V],G=$.low=0|t[e+2*V+1];else{var X=l[V-15],K=X.high,Q=X.low,Z=(K>>>1|Q<<31)^(K>>>8|Q<<24)^K>>>7,Y=(Q>>>1|K<<31)^(Q>>>8|K<<24)^(Q>>>7|K<<25),tt=l[V-2],et=tt.high,nt=tt.low,rt=(et>>>19|nt<<13)^(et<<3|nt>>>29)^et>>>6,it=(nt>>>19|et<<13)^(nt<<3|et>>>29)^(nt>>>6|et<<26),ot=l[V-7],at=ot.high,st=ot.low,ut=l[V-16],ct=ut.high,lt=ut.low,G=Y+st,J=Z+at+(G>>>0>>0?1:0),G=G+it,J=J+rt+(G>>>0>>0?1:0),G=G+lt,J=J+ct+(G>>>0>>0?1:0);$.high=J,$.low=G}var ft=M&N^~M&z,pt=L&H^~L&q,ht=A&T^A&R^T&R,dt=B&O^B&P^O&P,_t=(A>>>28|B<<4)^(A<<30|B>>>2)^(A<<25|B>>>7),vt=(B>>>28|A<<4)^(B<<30|A>>>2)^(B<<25|A>>>7),yt=(M>>>14|L<<18)^(M>>>18|L<<14)^(M<<23|L>>>9),mt=(L>>>14|M<<18)^(L>>>18|M<<14)^(L<<23|M>>>9),gt=c[V],bt=gt.high,wt=gt.low,kt=W+mt,xt=U+yt+(kt>>>0>>0?1:0),kt=kt+pt,xt=xt+ft+(kt>>>0>>0?1:0),kt=kt+wt,xt=xt+bt+(kt>>>0>>0?1:0),kt=kt+G,xt=xt+J+(kt>>>0>>0?1:0),Ct=vt+dt,jt=_t+ht+(Ct>>>0>>0?1:0);U=z,W=q,z=N,q=H,N=M,H=L,L=D+kt|0,M=I+xt+(L>>>0>>0?1:0)|0,I=R,D=P,R=T,P=O,T=A,O=B,B=kt+Ct|0,A=xt+jt+(B>>>0>>0?1:0)|0}d=r.low=d+B,r.high=h+A+(d>>>0>>0?1:0),v=i.low=v+O,i.high=_+T+(v>>>0>>0?1:0),m=o.low=m+P,o.high=y+R+(m>>>0

>>0?1:0),b=a.low=b+D,a.high=g+I+(b>>>0>>0?1:0),k=s.low=k+L,s.high=w+M+(k>>>0>>0?1:0),C=u.low=C+H,u.high=x+N+(C>>>0>>0?1:0),E=f.low=E+q,f.high=j+z+(E>>>0>>0?1:0),S=p.low=S+W,p.high=F+U+(S>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;e[r>>>5]|=128<<24-r%32,e[(r+128>>>10<<5)+30]=Math.floor(n/4294967296),e[(r+128>>>10<<5)+31]=n,t.sigBytes=4*e.length,this._process();var i=this._hash.toX32();return i},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});n.SHA512=i._createHelper(f),n.HmacSHA512=i._createHmacHelper(f)}(),t.SHA512})},{"./core":52,"./x64-core":83}],82:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(r.CryptoJS)}(this,function(t){return function(){function e(t,e){var n=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=n,this._lBlock^=n<>>t^this._lBlock)&e;this._lBlock^=n,this._rBlock^=n<>>5]>>>31-i%32&1}for(var o=this._subKeys=[],a=0;a<16;a++){for(var s=o[a]=[],f=l[a],r=0;r<24;r++)s[r/6|0]|=n[(c[r]-1+f)%28]<<31-r%6,s[4+(r/6|0)]|=n[28+(c[r+24]-1+f)%28]<<31-r%6;s[0]=s[0]<<1|s[0]>>>31;for(var r=1;r<7;r++)s[r]=s[r]>>>4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}for(var p=this._invSubKeys=[],r=0;r<16;r++)p[r]=o[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,r,i){this._lBlock=t[r],this._rBlock=t[r+1],e.call(this,4,252645135),e.call(this,16,65535),n.call(this,2,858993459),n.call(this,8,16711935),e.call(this,1,1431655765);for(var o=0;o<16;o++){for(var a=i[o],s=this._lBlock,u=this._rBlock,c=0,l=0;l<8;l++)c|=f[l][((u^a[l])&p[l])>>>0];this._lBlock=u,this._rBlock=s^c}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,e.call(this,1,1431655765),n.call(this,8,16711935),n.call(this,2,858993459),e.call(this,16,65535),e.call(this,4,252645135),t[r]=this._lBlock,t[r+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=a._createHelper(h);var d=s.TripleDES=a.extend({_doReset:function(){var t=this._key,e=t.words;this._des1=h.createEncryptor(o.create(e.slice(0,2))),this._des2=h.createEncryptor(o.create(e.slice(2,4))),this._des3=h.createEncryptor(o.create(e.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2});r.TripleDES=a._createHelper(d)}(),t.TripleDES})},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],83:[function(t,e,n){!function(r,i){"object"==typeof n?e.exports=n=i(t("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,i=r.Base,o=r.WordArray,a=n.x64={};a.Word=i.extend({init:function(t,e){this.high=t,this.low=e}}),a.WordArray=i.extend({init:function(t,n){t=this.words=t||[],n!=e?this.sigBytes=n:this.sigBytes=8*t.length},toX32:function(){for(var t=this.words,e=t.length,n=[],r=0;r-1}function f(t,e,n){for(var r=-1,i=null==t?0:t.length;++r-1;);return n}function D(t,e){for(var n=t.length;n--&&w(e,t[n],0)>-1;);return n}function M(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}function L(t){return"\\"+Yn[t]}function N(t,e){return null==t?et:t[e]}function H(t){return Wn.test(t)}function z(t){return Vn.test(t)}function q(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function U(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function W(t,e){return function(n){return t(e(n))}}function V(t,e){for(var n=-1,r=t.length,i=0,o=[];++n>>1,Lt=[["ary",wt],["bind",dt],["bindKey",_t],["curry",yt],["curryRight",mt],["flip",xt],["partial",gt],["partialRight",bt],["rearg",kt]],Nt="[object Arguments]",Ht="[object Array]",zt="[object AsyncFunction]",qt="[object Boolean]",Ut="[object Date]",Wt="[object DOMException]",Vt="[object Error]",$t="[object Function]",Jt="[object GeneratorFunction]",Gt="[object Map]",Xt="[object Number]",Kt="[object Null]",Qt="[object Object]",Zt="[object Promise]",Yt="[object Proxy]",te="[object RegExp]",ee="[object Set]",ne="[object String]",re="[object Symbol]",ie="[object Undefined]",oe="[object WeakMap]",ae="[object WeakSet]",se="[object ArrayBuffer]",ue="[object DataView]",ce="[object Float32Array]",le="[object Float64Array]",fe="[object Int8Array]",pe="[object Int16Array]",he="[object Int32Array]",de="[object Uint8Array]",_e="[object Uint8ClampedArray]",ve="[object Uint16Array]",ye="[object Uint32Array]",me=/\b__p \+= '';/g,ge=/\b(__p \+=) '' \+/g,be=/(__e\(.*?\)|\b__t\)) \+\n'';/g,we=/&(?:amp|lt|gt|quot|#39);/g,ke=/[&<>"']/g,xe=RegExp(we.source),Ce=RegExp(ke.source),je=/<%-([\s\S]+?)%>/g,Ee=/<%([\s\S]+?)%>/g,Fe=/<%=([\s\S]+?)%>/g,Se=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ae=/^\w*$/,Be=/^\./,Te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Oe=/[\\^$.*+?()[\]{}|]/g,Re=RegExp(Oe.source),Pe=/^\s+|\s+$/g,Ie=/^\s+/,De=/\s+$/,Me=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Le=/\{\n\/\* \[wrapped with (.+)\] \*/,Ne=/,? & /,He=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ze=/\\(\\)?/g,qe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ue=/\w*$/,We=/^[-+]0x[0-9a-f]+$/i,Ve=/^0b[01]+$/i,$e=/^\[object .+?Constructor\]$/,Je=/^0o[0-7]+$/i,Ge=/^(?:0|[1-9]\d*)$/,Xe=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ke=/($^)/,Qe=/['\n\r\u2028\u2029\\]/g,Ze="\\ud800-\\udfff",Ye="\\u0300-\\u036f",tn="\\ufe20-\\ufe2f",en="\\u20d0-\\u20ff",nn=Ye+tn+en,rn="\\u2700-\\u27bf",on="a-z\\xdf-\\xf6\\xf8-\\xff",an="\\xac\\xb1\\xd7\\xf7",sn="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",un="\\u2000-\\u206f",cn=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ln="A-Z\\xc0-\\xd6\\xd8-\\xde",fn="\\ufe0e\\ufe0f",pn=an+sn+un+cn,hn="['’]",dn="["+Ze+"]",_n="["+pn+"]",vn="["+nn+"]",yn="\\d+",mn="["+rn+"]",gn="["+on+"]",bn="[^"+Ze+pn+yn+rn+on+ln+"]",wn="\\ud83c[\\udffb-\\udfff]",kn="(?:"+vn+"|"+wn+")",xn="[^"+Ze+"]",Cn="(?:\\ud83c[\\udde6-\\uddff]){2}",jn="[\\ud800-\\udbff][\\udc00-\\udfff]",En="["+ln+"]",Fn="\\u200d",Sn="(?:"+gn+"|"+bn+")",An="(?:"+En+"|"+bn+")",Bn="(?:"+hn+"(?:d|ll|m|re|s|t|ve))?",Tn="(?:"+hn+"(?:D|LL|M|RE|S|T|VE))?",On=kn+"?",Rn="["+fn+"]?",Pn="(?:"+Fn+"(?:"+[xn,Cn,jn].join("|")+")"+Rn+On+")*",In="\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",Dn="\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)",Mn=Rn+On+Pn,Ln="(?:"+[mn,Cn,jn].join("|")+")"+Mn,Nn="(?:"+[xn+vn+"?",vn,Cn,jn,dn].join("|")+")",Hn=RegExp(hn,"g"),zn=RegExp(vn,"g"),qn=RegExp(wn+"(?="+wn+")|"+Nn+Mn,"g"),Un=RegExp([En+"?"+gn+"+"+Bn+"(?="+[_n,En,"$"].join("|")+")",An+"+"+Tn+"(?="+[_n,En+Sn,"$"].join("|")+")",En+"?"+Sn+"+"+Bn,En+"+"+Tn,Dn,In,yn,Ln].join("|"),"g"),Wn=RegExp("["+Fn+Ze+nn+fn+"]"),Vn=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,$n=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Jn=-1,Gn={};Gn[ce]=Gn[le]=Gn[fe]=Gn[pe]=Gn[he]=Gn[de]=Gn[_e]=Gn[ve]=Gn[ye]=!0,Gn[Nt]=Gn[Ht]=Gn[se]=Gn[qt]=Gn[ue]=Gn[Ut]=Gn[Vt]=Gn[$t]=Gn[Gt]=Gn[Xt]=Gn[Qt]=Gn[te]=Gn[ee]=Gn[ne]=Gn[oe]=!1;var Xn={};Xn[Nt]=Xn[Ht]=Xn[se]=Xn[ue]=Xn[qt]=Xn[Ut]=Xn[ce]=Xn[le]=Xn[fe]=Xn[pe]=Xn[he]=Xn[Gt]=Xn[Xt]=Xn[Qt]=Xn[te]=Xn[ee]=Xn[ne]=Xn[re]=Xn[de]=Xn[_e]=Xn[ve]=Xn[ye]=!0,Xn[Vt]=Xn[$t]=Xn[oe]=!1;var Kn={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},Qn={"&":"&","<":"<",">":">",'"':""","'":"'"},Zn={"&":"&","<":"<",">":">",""":'"',"'":"'"},Yn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},tr=parseFloat,er=parseInt,nr="object"==typeof global&&global&&global.Object===Object&&global,rr="object"==typeof self&&self&&self.Object===Object&&self,ir=nr||rr||Function("return this")(),or="object"==typeof n&&n&&!n.nodeType&&n,ar=or&&"object"==typeof e&&e&&!e.nodeType&&e,sr=ar&&ar.exports===or,ur=sr&&nr.process,cr=function(){try{return ur&&ur.binding&&ur.binding("util")}catch(t){}}(),lr=cr&&cr.isArrayBuffer,fr=cr&&cr.isDate,pr=cr&&cr.isMap,hr=cr&&cr.isRegExp,dr=cr&&cr.isSet,_r=cr&&cr.isTypedArray,vr=j("length"),yr=E(Kn),mr=E(Qn),gr=E(Zn),br=function e(n){function y(t){if(cu(t)&&!wp(t)&&!(t instanceof Z)){if(t instanceof G)return t;if(bl.call(t,"__wrapped__"))return aa(t)}return new G(t)}function E(){}function G(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=et}function Z(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=It,this.__views__=[]}function Y(){var t=new Z(this.__wrapped__);return t.__actions__=Hi(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Hi(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Hi(this.__views__),t}function He(){if(this.__filtered__){var t=new Z(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function Ze(){var t=this.__wrapped__.value(),e=this.__dir__,n=wp(t),r=e<0,i=n?t.length:0,o=Bo(0,i,this.__views__),a=o.start,s=o.end,u=s-a,c=r?s:a-1,l=this.__iteratees__,f=l.length,p=0,h=Kl(u,this.__takeCount__);if(!n||!r&&i==u&&h==u)return wi(t,this.__actions__);var d=[];t:for(;u--&&p-1}function fn(t,e){var n=this.__data__,r=Rn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}function pn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function qn(t,e,n,r,i,o){var s,u=e&ct,c=e<,l=e&ft;if(n&&(s=i?n(t,r,i,o):n(t)),s!==et)return s;if(!uu(t))return t;var f=wp(t);if(f){if(s=Ro(t),!u)return Hi(t,s)}else{var p=Tf(t),h=p==$t||p==Jt;if(xp(t))return Si(t,u);if(p==Qt||p==Nt||h&&!i){if(s=c||h?{}:Po(t),!u)return c?Ui(t,Dn(s,t)):qi(t,In(s,t))}else{if(!Xn[p])return i?t:{};s=Io(t,p,qn,u)}}o||(o=new wn);var d=o.get(t);if(d)return d;o.set(t,s);var _=l?c?ko:wo:c?Vu:Wu,v=f?et:_(t);return a(v||t,function(r,i){v&&(i=r,r=t[i]),On(s,i,qn(r,e,n,i,t,o))}),s}function Un(t){var e=Wu(t);return function(n){return Wn(n,t,e)}}function Wn(t,e,n){var r=n.length;if(null==t)return!r;for(t=fl(t);r--;){var i=n[r],o=e[i],a=t[i];if(a===et&&!(i in t)||!o(a))return!1}return!0}function Vn(t,e,n){if("function"!=typeof t)throw new dl(ot);return Pf(function(){t.apply(et,n)},e)}function Kn(t,e,n,r){var i=-1,o=l,a=!0,s=t.length,u=[],c=e.length;if(!s)return u;n&&(e=p(e,O(n))),r?(o=f,a=!1):e.length>=rt&&(o=P,a=!1,e=new mn(e));t:for(;++ii?0:i+n),r=r===et||r>i?i:Eu(r),r<0&&(r+=i),r=n>r?0:Fu(r);n0&&n(s)?e>1?rr(s,e-1,n,r,i):h(i,s):r||(i[i.length]=s)}return i}function or(t,e){return t&&wf(t,e,Wu)}function ar(t,e){return t&&kf(t,e,Wu)}function ur(t,e){return c(e,function(e){return ou(t[e])})}function cr(t,e){e=Ei(e,t);for(var n=0,r=e.length;null!=t&&ne}function xr(t,e){return null!=t&&bl.call(t,e)}function Cr(t,e){return null!=t&&e in fl(t)}function jr(t,e,n){return t>=Kl(e,n)&&t=120&&h.length>=120)?new mn(a&&h):et}h=t[0];var d=-1,_=s[0];t:for(;++d-1;)s!==t&&Pl.call(s,u,1),Pl.call(t,u,1);return t}function ei(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==o){var o=i;Lo(i)?Pl.call(t,i,1):mi(t,i)}}return t}function ni(t,e){return t+Ul(Yl()*(e-t+1))}function ri(t,e,n,r){for(var i=-1,o=Xl(ql((e-t)/(n||1)),0),a=al(o);o--;)a[r?o:++i]=t,t+=n;return a}function ii(t,e){var n="";if(!t||e<1||e>Ot)return n;do e%2&&(n+=t),e=Ul(e/2),e&&(t+=t);while(e);return n}function oi(t,e){return If(Qo(t,e,Pc),t+"")}function ai(t){return Sn(rc(t))}function si(t,e){var n=rc(t);return na(n,Nn(e,0,n.length))}function ui(t,e,n,r){if(!uu(t))return t;e=Ei(e,t);for(var i=-1,o=e.length,a=o-1,s=t;null!=s&&++ii?0:i+e),n=n>i?i:n,n<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=al(i);++r>>1,a=t[o];null!==a&&!bu(a)&&(n?a<=e:a=rt){var c=e?null:Ff(t);if(c)return $(c);a=!1,i=P,u=new mn}else u=e?[]:s;t:for(;++r=r?t:li(t,e,n)}function Si(t,e){if(e)return t.slice();var n=t.length,r=Bl?Bl(n):new t.constructor(n);return t.copy(r),r}function Ai(t){var e=new t.constructor(t.byteLength);return new Al(e).set(new Al(t)),e}function Bi(t,e){var n=e?Ai(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}function Ti(e,n,r){var i=n?r(U(e),ct):U(e);return d(i,t,new e.constructor)}function Oi(t){var e=new t.constructor(t.source,Ue.exec(t));return e.lastIndex=t.lastIndex,e}function Ri(t,e,n){var i=e?n($(t),ct):$(t);return d(i,r,new t.constructor)}function Pi(t){return vf?fl(vf.call(t)):{}}function Ii(t,e){var n=e?Ai(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Di(t,e){if(t!==e){var n=t!==et,r=null===t,i=t===t,o=bu(t),a=e!==et,s=null===e,u=e===e,c=bu(e);if(!s&&!c&&!o&&t>e||o&&a&&u&&!s&&!c||r&&a&&u||!n&&u||!i)return 1;if(!r&&!o&&!c&&t=s)return u;var c=n[r];return u*("desc"==c?-1:1)}}return t.index-e.index}function Li(t,e,n,r){for(var i=-1,o=t.length,a=n.length,s=-1,u=e.length,c=Xl(o-a,0),l=al(u+c),f=!r;++s1?n[i-1]:et,a=i>2?n[2]:et;for(o=t.length>3&&"function"==typeof o?(i--,o):et,a&&No(n[0],n[1],a)&&(o=i<3?et:o,i=1),e=fl(e);++r-1?i[o?e[a]:a]:et}}function to(t){return bo(function(e){var n=e.length,r=n,i=G.prototype.thru;for(t&&e.reverse();r--;){var o=e[r];if("function"!=typeof o)throw new dl(ot);if(i&&!a&&"wrapper"==xo(o))var a=new G([],(!0))}for(r=a?r:n;++r1&&m.reverse(),f&&us))return!1;var c=o.get(t);if(c&&o.get(e))return c==e;var l=-1,f=!0,p=n&ht?new mn:et;for(o.set(t,e),o.set(e,t);++l1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(Me,"{\n/* [wrapped with "+e+"] */\n")}function Mo(t){return wp(t)||bp(t)||!!(Il&&t&&t[Il])}function Lo(t,e){return e=null==e?Ot:e,!!e&&("number"==typeof t||Ge.test(t))&&t>-1&&t%1==0&&t0){if(++e>=Et)return arguments[0]}else e=0;return t.apply(et,arguments)}}function na(t,e){var n=-1,r=t.length,i=r-1;for(e=e===et?r:e;++n=this.__values__.length,e=t?et:this.__values__[this.__index__++];return{done:t,value:e}}function as(){return this}function ss(t){for(var e,n=this;n instanceof E;){var r=aa(n);r.__index__=0,r.__values__=et,e?i.__wrapped__=r:e=r;var i=r;n=n.__wrapped__}return i.__wrapped__=t,e}function us(){var t=this.__wrapped__;if(t instanceof Z){var e=t;return this.__actions__.length&&(e=new Z(this)),e=e.reverse(),e.__actions__.push({func:ns,args:[Oa],thisArg:et}),new G(e,this.__chain__)}return this.thru(Oa)}function cs(){return wi(this.__wrapped__,this.__actions__)}function ls(t,e,n){var r=wp(t)?u:Qn;return n&&No(t,e,n)&&(e=et),r(t,jo(e,3))}function fs(t,e){var n=wp(t)?c:nr;return n(t,jo(e,3))}function ps(t,e){return rr(ms(t,e),1)}function hs(t,e){return rr(ms(t,e),Tt)}function ds(t,e,n){return n=n===et?1:Eu(n),rr(ms(t,e),n)}function _s(t,e){var n=wp(t)?a:gf;return n(t,jo(e,3))}function vs(t,e){var n=wp(t)?s:bf;return n(t,jo(e,3))}function ys(t,e,n,r){t=Ks(t)?t:rc(t),n=n&&!r?Eu(n):0;var i=t.length;return n<0&&(n=Xl(i+n,0)),gu(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&w(t,e,n)>-1}function ms(t,e){var n=wp(t)?p:Wr;return n(t,jo(e,3))}function gs(t,e,n,r){return null==t?[]:(wp(e)||(e=null==e?[]:[e]),n=r?et:n,wp(n)||(n=null==n?[]:[n]),Kr(t,e,n))}function bs(t,e,n){var r=wp(t)?d:F,i=arguments.length<3;return r(t,jo(e,4),n,i,gf)}function ws(t,e,n){var r=wp(t)?_:F,i=arguments.length<3;return r(t,jo(e,4),n,i,bf)}function ks(t,e){var n=wp(t)?c:nr;return n(t,Ds(jo(e,3)))}function xs(t){var e=wp(t)?Sn:ai;return e(t)}function Cs(t,e,n){e=(n?No(t,e,n):e===et)?1:Eu(e);var r=wp(t)?An:si;return r(t,e)}function js(t){var e=wp(t)?Bn:ci;return e(t)}function Es(t){if(null==t)return 0;if(Ks(t))return gu(t)?K(t):t.length;var e=Tf(t);return e==Gt||e==ee?t.size:zr(t).length}function Fs(t,e,n){var r=wp(t)?v:fi;return n&&No(t,e,n)&&(e=et),r(t,jo(e,3))}function Ss(t,e){if("function"!=typeof e)throw new dl(ot);return t=Eu(t),function(){if(--t<1)return e.apply(this,arguments)}}function As(t,e,n){return e=n?et:e,e=t&&null==e?t.length:e,po(t,wt,et,et,et,et,e)}function Bs(t,e){var n;if("function"!=typeof e)throw new dl(ot);return t=Eu(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=et),n}}function Ts(t,e,n){e=n?et:e;var r=po(t,yt,et,et,et,et,et,e);return r.placeholder=Ts.placeholder,r}function Os(t,e,n){e=n?et:e;var r=po(t,mt,et,et,et,et,et,e);return r.placeholder=Os.placeholder,r}function Rs(t,e,n){function r(e){var n=p,r=h;return p=h=et,m=e,_=t.apply(r,n)}function i(t){return m=t,v=Pf(s,e),g?r(t):_}function o(t){var n=t-y,r=t-m,i=e-n;return b?Kl(i,d-r):i}function a(t){var n=t-y,r=t-m;return y===et||n>=e||n<0||b&&r>=d}function s(){var t=cp();return a(t)?u(t):void(v=Pf(s,o(t)))}function u(t){return v=et,w&&p?r(t):(p=h=et,_)}function c(){v!==et&&Ef(v),m=0,p=y=h=v=et}function l(){return v===et?_:u(cp())}function f(){var t=cp(),n=a(t);if(p=arguments,h=this,y=t,n){if(v===et)return i(y);if(b)return v=Pf(s,e),r(y)}return v===et&&(v=Pf(s,e)),_}var p,h,d,_,v,y,m=0,g=!1,b=!1,w=!0;if("function"!=typeof t)throw new dl(ot);return e=Su(e)||0,uu(n)&&(g=!!n.leading,b="maxWait"in n,d=b?Xl(Su(n.maxWait)||0,e):d,w="trailing"in n?!!n.trailing:w),f.cancel=c,f.flush=l,f}function Ps(t){return po(t,xt)}function Is(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new dl(ot);var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=t.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Is.Cache||pn),n}function Ds(t){if("function"!=typeof t)throw new dl(ot);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Ms(t){return Bs(2,t)}function Ls(t,e){if("function"!=typeof t)throw new dl(ot);return e=e===et?e:Eu(e),oi(t,e)}function Ns(t,e){if("function"!=typeof t)throw new dl(ot);return e=null==e?0:Xl(Eu(e),0),oi(function(n){var r=n[e],o=Fi(n,0,e);return r&&h(o,r),i(t,this,o)})}function Hs(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new dl(ot);return uu(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Rs(t,e,{leading:r,maxWait:e,trailing:i})}function zs(t){return As(t,1)}function qs(t,e){return _p(ji(e),t)}function Us(){if(!arguments.length)return[];var t=arguments[0];return wp(t)?t:[t]}function Ws(t){return qn(t,ft)}function Vs(t,e){return e="function"==typeof e?e:et,qn(t,ft,e)}function $s(t){return qn(t,ct|ft)}function Js(t,e){return e="function"==typeof e?e:et,qn(t,ct|ft,e)}function Gs(t,e){return null==e||Wn(t,e,Wu(e))}function Xs(t,e){return t===e||t!==t&&e!==e}function Ks(t){return null!=t&&su(t.length)&&!ou(t)}function Qs(t){return cu(t)&&Ks(t)}function Zs(t){return t===!0||t===!1||cu(t)&&br(t)==qt}function Ys(t){return cu(t)&&1===t.nodeType&&!yu(t)}function tu(t){if(null==t)return!0;if(Ks(t)&&(wp(t)||"string"==typeof t||"function"==typeof t.splice||xp(t)||Sp(t)||bp(t)))return!t.length;var e=Tf(t);if(e==Gt||e==ee)return!t.size;if(Wo(t))return!zr(t).length;for(var n in t)if(bl.call(t,n))return!1;return!0}function eu(t,e){return Or(t,e)}function nu(t,e,n){n="function"==typeof n?n:et;var r=n?n(t,e):et;return r===et?Or(t,e,et,n):!!r}function ru(t){if(!cu(t))return!1;var e=br(t);return e==Vt||e==Wt||"string"==typeof t.message&&"string"==typeof t.name&&!yu(t)}function iu(t){return"number"==typeof t&&$l(t)}function ou(t){if(!uu(t))return!1;var e=br(t);return e==$t||e==Jt||e==zt||e==Yt}function au(t){return"number"==typeof t&&t==Eu(t)}function su(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Ot}function uu(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function cu(t){return null!=t&&"object"==typeof t}function lu(t,e){return t===e||Ir(t,e,Fo(e))}function fu(t,e,n){return n="function"==typeof n?n:et,Ir(t,e,Fo(e),n)}function pu(t){return vu(t)&&t!=+t}function hu(t){if(Of(t))throw new ul(it);return Dr(t)}function du(t){return null===t}function _u(t){return null==t}function vu(t){return"number"==typeof t||cu(t)&&br(t)==Xt}function yu(t){if(!cu(t)||br(t)!=Qt)return!1;var e=Tl(t);if(null===e)return!0;var n=bl.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&gl.call(n)==Cl}function mu(t){return au(t)&&t>=-Ot&&t<=Ot}function gu(t){return"string"==typeof t||!wp(t)&&cu(t)&&br(t)==ne}function bu(t){return"symbol"==typeof t||cu(t)&&br(t)==re}function wu(t){return t===et}function ku(t){return cu(t)&&Tf(t)==oe}function xu(t){return cu(t)&&br(t)==ae}function Cu(t){if(!t)return[];if(Ks(t))return gu(t)?Q(t):Hi(t);if(Dl&&t[Dl])return q(t[Dl]());var e=Tf(t),n=e==Gt?U:e==ee?$:rc;return n(t)}function ju(t){if(!t)return 0===t?t:0;if(t=Su(t),t===Tt||t===-Tt){var e=t<0?-1:1;return e*Rt}return t===t?t:0}function Eu(t){var e=ju(t),n=e%1;return e===e?n?e-n:e:0}function Fu(t){return t?Nn(Eu(t),0,It):0}function Su(t){if("number"==typeof t)return t;if(bu(t))return Pt;if(uu(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=uu(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Pe,"");var n=Ve.test(t); -return n||Je.test(t)?er(t.slice(2),n?2:8):We.test(t)?Pt:+t}function Au(t){return zi(t,Vu(t))}function Bu(t){return t?Nn(Eu(t),-Ot,Ot):0===t?t:0}function Tu(t){return null==t?"":vi(t)}function Ou(t,e){var n=mf(t);return null==e?n:In(n,e)}function Ru(t,e){return g(t,jo(e,3),or)}function Pu(t,e){return g(t,jo(e,3),ar)}function Iu(t,e){return null==t?t:wf(t,jo(e,3),Vu)}function Du(t,e){return null==t?t:kf(t,jo(e,3),Vu)}function Mu(t,e){return t&&or(t,jo(e,3))}function Lu(t,e){return t&&ar(t,jo(e,3))}function Nu(t){return null==t?[]:ur(t,Wu(t))}function Hu(t){return null==t?[]:ur(t,Vu(t))}function zu(t,e,n){var r=null==t?et:cr(t,e);return r===et?n:r}function qu(t,e){return null!=t&&Oo(t,e,xr)}function Uu(t,e){return null!=t&&Oo(t,e,Cr)}function Wu(t){return Ks(t)?Fn(t):zr(t)}function Vu(t){return Ks(t)?Fn(t,!0):qr(t)}function $u(t,e){var n={};return e=jo(e,3),or(t,function(t,r,i){Mn(n,e(t,r,i),t)}),n}function Ju(t,e){var n={};return e=jo(e,3),or(t,function(t,r,i){Mn(n,r,e(t,r,i))}),n}function Gu(t,e){return Xu(t,Ds(jo(e)))}function Xu(t,e){if(null==t)return{};var n=p(ko(t),function(t){return[t]});return e=jo(e),Zr(t,n,function(t,n){return e(t,n[0])})}function Ku(t,e,n){e=Ei(e,t);var r=-1,i=e.length;for(i||(i=1,t=et);++re){var r=t;t=e,e=r}if(n||t%1||e%1){var i=Yl();return Kl(t+i*(e-t+tr("1e-"+((i+"").length-1))),e)}return ni(t,e)}function uc(t){return th(Tu(t).toLowerCase())}function cc(t){return t=Tu(t),t&&t.replace(Xe,yr).replace(zn,"")}function lc(t,e,n){t=Tu(t),e=vi(e);var r=t.length;n=n===et?r:Nn(Eu(n),0,r);var i=n;return n-=e.length,n>=0&&t.slice(n,i)==e}function fc(t){return t=Tu(t),t&&Ce.test(t)?t.replace(ke,mr):t}function pc(t){return t=Tu(t),t&&Re.test(t)?t.replace(Oe,"\\$&"):t}function hc(t,e,n){t=Tu(t),e=Eu(e);var r=e?K(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return oo(Ul(i),n)+t+oo(ql(i),n)}function dc(t,e,n){t=Tu(t),e=Eu(e);var r=e?K(t):0;return e&&r>>0)?(t=Tu(t),t&&("string"==typeof e||null!=e&&!Ep(e))&&(e=vi(e),!e&&H(t))?Fi(Q(t),0,n):t.split(e,n)):[]}function bc(t,e,n){return t=Tu(t),n=null==n?0:Nn(Eu(n),0,t.length),e=vi(e),t.slice(n,n+e.length)==e}function wc(t,e,n){var r=y.templateSettings;n&&No(t,e,n)&&(e=et),t=Tu(t),e=Rp({},e,r,ho);var i,o,a=Rp({},e.imports,r.imports,ho),s=Wu(a),u=R(a,s),c=0,l=e.interpolate||Ke,f="__p += '",p=pl((e.escape||Ke).source+"|"+l.source+"|"+(l===Fe?qe:Ke).source+"|"+(e.evaluate||Ke).source+"|$","g"),h="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++Jn+"]")+"\n";t.replace(p,function(e,n,r,a,s,u){return r||(r=a),f+=t.slice(c,u).replace(Qe,L),n&&(i=!0,f+="' +\n__e("+n+") +\n'"),s&&(o=!0,f+="';\n"+s+";\n__p += '"),r&&(f+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),c=u+e.length,e}),f+="';\n";var d=e.variable;d||(f="with (obj) {\n"+f+"\n}\n"),f=(o?f.replace(me,""):f).replace(ge,"$1").replace(be,"$1;"),f="function("+(d||"obj")+") {\n"+(d?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var _=eh(function(){return cl(s,h+"return "+f).apply(et,u)});if(_.source=f,ru(_))throw _;return _}function kc(t){return Tu(t).toLowerCase()}function xc(t){return Tu(t).toUpperCase()}function Cc(t,e,n){if(t=Tu(t),t&&(n||e===et))return t.replace(Pe,"");if(!t||!(e=vi(e)))return t;var r=Q(t),i=Q(e),o=I(r,i),a=D(r,i)+1;return Fi(r,o,a).join("")}function jc(t,e,n){if(t=Tu(t),t&&(n||e===et))return t.replace(De,"");if(!t||!(e=vi(e)))return t;var r=Q(t),i=D(r,Q(e))+1;return Fi(r,0,i).join("")}function Ec(t,e,n){if(t=Tu(t),t&&(n||e===et))return t.replace(Ie,"");if(!t||!(e=vi(e)))return t;var r=Q(t),i=I(r,Q(e));return Fi(r,i).join("")}function Fc(t,e){var n=Ct,r=jt;if(uu(e)){var i="separator"in e?e.separator:i;n="length"in e?Eu(e.length):n,r="omission"in e?vi(e.omission):r}t=Tu(t);var o=t.length;if(H(t)){var a=Q(t);o=a.length}if(n>=o)return t;var s=n-K(r);if(s<1)return r;var u=a?Fi(a,0,s).join(""):t.slice(0,s);if(i===et)return u+r;if(a&&(s+=u.length-s),Ep(i)){if(t.slice(s).search(i)){var c,l=u;for(i.global||(i=pl(i.source,Tu(Ue.exec(i))+"g")),i.lastIndex=0;c=i.exec(l);)var f=c.index;u=u.slice(0,f===et?s:f)}}else if(t.indexOf(vi(i),s)!=s){var p=u.lastIndexOf(i);p>-1&&(u=u.slice(0,p))}return u+r}function Sc(t){return t=Tu(t),t&&xe.test(t)?t.replace(we,gr):t}function Ac(t,e,n){return t=Tu(t),e=n?et:e,e===et?z(t)?tt(t):m(t):t.match(e)||[]}function Bc(t){var e=null==t?0:t.length,n=jo();return t=e?p(t,function(t){if("function"!=typeof t[1])throw new dl(ot);return[n(t[0]),t[1]]}):[],oi(function(n){for(var r=-1;++rOt)return[];var n=It,r=Kl(t,It);e=jo(e),t-=It;for(var i=B(r,e);++n1?t[e-1]:et;return n="function"==typeof n?(t.pop(),n):et,Qa(t,n)}),tp=bo(function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,i=function(e){return Ln(e,t)};return!(e>1||this.__actions__.length)&&r instanceof Z&&Lo(n)?(r=r.slice(n,+n+(e?1:0)),r.__actions__.push({func:ns,args:[i],thisArg:et}),new G(r,this.__chain__).thru(function(t){return e&&!t.length&&t.push(et),t})):this.thru(i)}),ep=Wi(function(t,e,n){bl.call(t,n)?++t[n]:Mn(t,n,1)}),np=Yi(_a),rp=Yi(va),ip=Wi(function(t,e,n){bl.call(t,n)?t[n].push(e):Mn(t,n,[e])}),op=oi(function(t,e,n){var r=-1,o="function"==typeof e,a=Ks(t)?al(t.length):[];return gf(t,function(t){a[++r]=o?i(e,t,n):Sr(t,e,n)}),a}),ap=Wi(function(t,e,n){Mn(t,n,e)}),sp=Wi(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]}),up=oi(function(t,e){if(null==t)return[];var n=e.length;return n>1&&No(t,e[0],e[1])?e=[]:n>2&&No(e[0],e[1],e[2])&&(e=[e[0]]),Kr(t,rr(e,1),[])}),cp=Hl||function(){return ir.Date.now()},lp=oi(function(t,e,n){var r=dt;if(n.length){var i=V(n,Co(lp));r|=gt}return po(t,r,e,n,i)}),fp=oi(function(t,e,n){var r=dt|_t;if(n.length){var i=V(n,Co(fp));r|=gt}return po(e,r,t,n,i)}),pp=oi(function(t,e){return Vn(t,1,e)}),hp=oi(function(t,e,n){return Vn(t,Su(e)||0,n)});Is.Cache=pn;var dp=jf(function(t,e){e=1==e.length&&wp(e[0])?p(e[0],O(jo())):p(rr(e,1),O(jo()));var n=e.length;return oi(function(r){for(var o=-1,a=Kl(r.length,n);++o=e}),bp=Ar(function(){return arguments}())?Ar:function(t){return cu(t)&&bl.call(t,"callee")&&!Rl.call(t,"callee")},wp=al.isArray,kp=lr?O(lr):Br,xp=Vl||Vc,Cp=fr?O(fr):Tr,jp=pr?O(pr):Pr,Ep=hr?O(hr):Mr,Fp=dr?O(dr):Lr,Sp=_r?O(_r):Nr,Ap=uo(Ur),Bp=uo(function(t,e){return t<=e}),Tp=Vi(function(t,e){if(Wo(e)||Ks(e))return void zi(e,Wu(e),t);for(var n in e)bl.call(e,n)&&On(t,n,e[n])}),Op=Vi(function(t,e){zi(e,Vu(e),t)}),Rp=Vi(function(t,e,n,r){zi(e,Vu(e),t,r)}),Pp=Vi(function(t,e,n,r){zi(e,Wu(e),t,r)}),Ip=bo(Ln),Dp=oi(function(t){return t.push(et,ho),i(Rp,et,t)}),Mp=oi(function(t){return t.push(et,_o),i(qp,et,t)}),Lp=no(function(t,e,n){t[e]=n},Oc(Pc)),Np=no(function(t,e,n){bl.call(t,e)?t[e].push(n):t[e]=[n]},jo),Hp=oi(Sr),zp=Vi(function(t,e,n){Jr(t,e,n)}),qp=Vi(function(t,e,n,r){Jr(t,e,n,r)}),Up=bo(function(t,e){var n={};if(null==t)return n;var r=!1;e=p(e,function(e){return e=Ei(e,t),r||(r=e.length>1),e}),zi(t,ko(t),n),r&&(n=qn(n,ct|lt|ft,vo));for(var i=e.length;i--;)mi(n,e[i]);return n}),Wp=bo(function(t,e){return null==t?{}:Qr(t,e)}),Vp=fo(Wu),$p=fo(Vu),Jp=Ki(function(t,e,n){return e=e.toLowerCase(),t+(n?uc(e):e)}),Gp=Ki(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()}),Xp=Ki(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()}),Kp=Xi("toLowerCase"),Qp=Ki(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()}),Zp=Ki(function(t,e,n){return t+(n?" ":"")+th(e)}),Yp=Ki(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()}),th=Xi("toUpperCase"),eh=oi(function(t,e){try{return i(t,et,e)}catch(t){return ru(t)?t:new ul(t)}}),nh=bo(function(t,e){return a(e,function(e){e=ra(e),Mn(t,e,lp(t[e],t))}),t}),rh=to(),ih=to(!0),oh=oi(function(t,e){return function(n){return Sr(n,t,e)}}),ah=oi(function(t,e){return function(n){return Sr(t,n,e)}}),sh=io(p),uh=io(u),ch=io(v),lh=so(),fh=so(!0),ph=ro(function(t,e){return t+e},0),hh=lo("ceil"),dh=ro(function(t,e){return t/e},1),_h=lo("floor"),vh=ro(function(t,e){return t*e},1),yh=lo("round"),mh=ro(function(t,e){return t-e},0);return y.after=Ss,y.ary=As,y.assign=Tp,y.assignIn=Op,y.assignInWith=Rp,y.assignWith=Pp,y.at=Ip,y.before=Bs,y.bind=lp,y.bindAll=nh,y.bindKey=fp,y.castArray=Us,y.chain=ts,y.chunk=sa,y.compact=ua,y.concat=ca,y.cond=Bc,y.conforms=Tc,y.constant=Oc,y.countBy=ep,y.create=Ou,y.curry=Ts,y.curryRight=Os,y.debounce=Rs,y.defaults=Dp,y.defaultsDeep=Mp,y.defer=pp,y.delay=hp,y.difference=Mf,y.differenceBy=Lf,y.differenceWith=Nf,y.drop=la,y.dropRight=fa,y.dropRightWhile=pa,y.dropWhile=ha,y.fill=da,y.filter=fs,y.flatMap=ps,y.flatMapDeep=hs,y.flatMapDepth=ds,y.flatten=ya,y.flattenDeep=ma,y.flattenDepth=ga,y.flip=Ps,y.flow=rh,y.flowRight=ih,y.fromPairs=ba,y.functions=Nu,y.functionsIn=Hu,y.groupBy=ip,y.initial=xa,y.intersection=Hf,y.intersectionBy=zf,y.intersectionWith=qf,y.invert=Lp,y.invertBy=Np,y.invokeMap=op,y.iteratee=Ic,y.keyBy=ap,y.keys=Wu,y.keysIn=Vu,y.map=ms,y.mapKeys=$u,y.mapValues=Ju,y.matches=Dc,y.matchesProperty=Mc,y.memoize=Is,y.merge=zp,y.mergeWith=qp,y.method=oh,y.methodOf=ah,y.mixin=Lc,y.negate=Ds,y.nthArg=zc,y.omit=Up,y.omitBy=Gu,y.once=Ms,y.orderBy=gs,y.over=sh,y.overArgs=dp,y.overEvery=uh,y.overSome=ch,y.partial=_p,y.partialRight=vp,y.partition=sp,y.pick=Wp,y.pickBy=Xu,y.property=qc,y.propertyOf=Uc,y.pull=Uf,y.pullAll=Sa,y.pullAllBy=Aa,y.pullAllWith=Ba,y.pullAt=Wf,y.range=lh,y.rangeRight=fh,y.rearg=yp,y.reject=ks,y.remove=Ta,y.rest=Ls,y.reverse=Oa,y.sampleSize=Cs,y.set=Qu,y.setWith=Zu,y.shuffle=js,y.slice=Ra,y.sortBy=up,y.sortedUniq=Ha,y.sortedUniqBy=za,y.split=gc,y.spread=Ns,y.tail=qa,y.take=Ua,y.takeRight=Wa,y.takeRightWhile=Va,y.takeWhile=$a,y.tap=es,y.throttle=Hs,y.thru=ns,y.toArray=Cu,y.toPairs=Vp,y.toPairsIn=$p,y.toPath=Kc,y.toPlainObject=Au,y.transform=Yu,y.unary=zs,y.union=Vf,y.unionBy=$f,y.unionWith=Jf,y.uniq=Ja,y.uniqBy=Ga,y.uniqWith=Xa,y.unset=tc,y.unzip=Ka,y.unzipWith=Qa,y.update=ec,y.updateWith=nc,y.values=rc,y.valuesIn=ic,y.without=Gf,y.words=Ac,y.wrap=qs,y.xor=Xf,y.xorBy=Kf,y.xorWith=Qf,y.zip=Zf,y.zipObject=Za,y.zipObjectDeep=Ya,y.zipWith=Yf,y.entries=Vp,y.entriesIn=$p,y.extend=Op,y.extendWith=Rp,Lc(y,y),y.add=ph,y.attempt=eh,y.camelCase=Jp,y.capitalize=uc,y.ceil=hh,y.clamp=oc,y.clone=Ws,y.cloneDeep=$s,y.cloneDeepWith=Js,y.cloneWith=Vs,y.conformsTo=Gs,y.deburr=cc,y.defaultTo=Rc,y.divide=dh,y.endsWith=lc,y.eq=Xs,y.escape=fc,y.escapeRegExp=pc,y.every=ls,y.find=np,y.findIndex=_a,y.findKey=Ru,y.findLast=rp,y.findLastIndex=va,y.findLastKey=Pu,y.floor=_h,y.forEach=_s,y.forEachRight=vs,y.forIn=Iu,y.forInRight=Du,y.forOwn=Mu,y.forOwnRight=Lu,y.get=zu,y.gt=mp,y.gte=gp,y.has=qu,y.hasIn=Uu,y.head=wa,y.identity=Pc,y.includes=ys,y.indexOf=ka,y.inRange=ac,y.invoke=Hp,y.isArguments=bp,y.isArray=wp,y.isArrayBuffer=kp,y.isArrayLike=Ks,y.isArrayLikeObject=Qs,y.isBoolean=Zs,y.isBuffer=xp,y.isDate=Cp,y.isElement=Ys,y.isEmpty=tu,y.isEqual=eu,y.isEqualWith=nu,y.isError=ru,y.isFinite=iu,y.isFunction=ou,y.isInteger=au,y.isLength=su,y.isMap=jp,y.isMatch=lu,y.isMatchWith=fu,y.isNaN=pu,y.isNative=hu,y.isNil=_u,y.isNull=du,y.isNumber=vu,y.isObject=uu,y.isObjectLike=cu,y.isPlainObject=yu,y.isRegExp=Ep,y.isSafeInteger=mu,y.isSet=Fp,y.isString=gu,y.isSymbol=bu,y.isTypedArray=Sp,y.isUndefined=wu,y.isWeakMap=ku,y.isWeakSet=xu,y.join=Ca,y.kebabCase=Gp,y.last=ja,y.lastIndexOf=Ea,y.lowerCase=Xp,y.lowerFirst=Kp,y.lt=Ap,y.lte=Bp,y.max=Zc,y.maxBy=Yc,y.mean=tl,y.meanBy=el,y.min=nl,y.minBy=rl,y.stubArray=Wc,y.stubFalse=Vc,y.stubObject=$c,y.stubString=Jc,y.stubTrue=Gc,y.multiply=vh,y.nth=Fa,y.noConflict=Nc,y.noop=Hc,y.now=cp,y.pad=hc,y.padEnd=dc,y.padStart=_c,y.parseInt=vc,y.random=sc,y.reduce=bs,y.reduceRight=ws,y.repeat=yc,y.replace=mc,y.result=Ku,y.round=yh,y.runInContext=e,y.sample=xs,y.size=Es,y.snakeCase=Qp,y.some=Fs,y.sortedIndex=Pa,y.sortedIndexBy=Ia,y.sortedIndexOf=Da,y.sortedLastIndex=Ma,y.sortedLastIndexBy=La,y.sortedLastIndexOf=Na,y.startCase=Zp,y.startsWith=bc,y.subtract=mh,y.sum=il,y.sumBy=ol,y.template=wc,y.times=Xc,y.toFinite=ju,y.toInteger=Eu,y.toLength=Fu,y.toLower=kc,y.toNumber=Su,y.toSafeInteger=Bu,y.toString=Tu,y.toUpper=xc,y.trim=Cc,y.trimEnd=jc,y.trimStart=Ec,y.truncate=Fc,y.unescape=Sc,y.uniqueId=Qc,y.upperCase=Yp,y.upperFirst=th,y.each=_s,y.eachRight=vs,y.first=wa,Lc(y,function(){var t={};return or(y,function(e,n){bl.call(y.prototype,n)||(t[n]=e)}),t}(),{chain:!1}),y.VERSION=nt,a(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){y[t].placeholder=y}),a(["drop","take"],function(t,e){Z.prototype[t]=function(n){n=n===et?1:Xl(Eu(n),0);var r=this.__filtered__&&!e?new Z(this):this.clone();return r.__filtered__?r.__takeCount__=Kl(n,r.__takeCount__):r.__views__.push({size:Kl(n,It),type:t+(r.__dir__<0?"Right":"")}),r},Z.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),a(["filter","map","takeWhile"],function(t,e){var n=e+1,r=n==St||n==Bt;Z.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:jo(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}}),a(["head","last"],function(t,e){var n="take"+(e?"Right":"");Z.prototype[t]=function(){return this[n](1).value()[0]}}),a(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");Z.prototype[t]=function(){return this.__filtered__?new Z(this):this[n](1)}}),Z.prototype.compact=function(){return this.filter(Pc)},Z.prototype.find=function(t){return this.filter(t).head()},Z.prototype.findLast=function(t){return this.reverse().find(t)},Z.prototype.invokeMap=oi(function(t,e){return"function"==typeof t?new Z(this):this.map(function(n){return Sr(n,t,e)})}),Z.prototype.reject=function(t){return this.filter(Ds(jo(t)))},Z.prototype.slice=function(t,e){t=Eu(t);var n=this;return n.__filtered__&&(t>0||e<0)?new Z(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==et&&(e=Eu(e),n=e<0?n.dropRight(-e):n.take(e-t)),n)},Z.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Z.prototype.toArray=function(){return this.take(It)},or(Z.prototype,function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=y[r?"take"+("last"==e?"Right":""):e],o=r||/^find/.test(e);i&&(y.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,s=e instanceof Z,u=a[0],c=s||wp(e),l=function(t){var e=i.apply(y,h([t],a));return r&&f?e[0]:e};c&&n&&"function"==typeof u&&1!=u.length&&(s=c=!1);var f=this.__chain__,p=!!this.__actions__.length,d=o&&!f,_=s&&!p;if(!o&&c){e=_?e:new Z(this);var v=t.apply(e,a);return v.__actions__.push({func:ns,args:[l],thisArg:et}),new G(v,f)}return d&&_?t.apply(this,a):(v=this.thru(l),d?r?v.value()[0]:v.value():v)})}),a(["pop","push","shift","sort","splice","unshift"],function(t){var e=_l[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);y.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(wp(i)?i:[],t)}return this[n](function(n){return e.apply(wp(n)?n:[],t)})}}),or(Z.prototype,function(t,e){var n=y[e];if(n){var r=n.name+"",i=cf[r]||(cf[r]=[]);i.push({name:e,func:n})}}),cf[eo(et,_t).name]=[{name:"wrapper",func:et}],Z.prototype.clone=Y,Z.prototype.reverse=He,Z.prototype.value=Ze,y.prototype.at=tp,y.prototype.chain=rs,y.prototype.commit=is,y.prototype.next=os,y.prototype.plant=ss,y.prototype.reverse=us,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=cs,y.prototype.first=y.prototype.head,Dl&&(y.prototype[Dl]=as),y},wr=br();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(ir._=wr,define(function(){return wr})):ar?((ar.exports=wr)._=wr,or._=wr):ir._=wr}).call(this)},{}],86:[function(t,e,n){!function(t){function r(t){for(var e,n,r=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e-=65536,i+=m(e>>>10&1023|55296),e=56320|1023&e),i+=m(e);return i}function o(t){if(t>=55296&&t<=57343)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value")}function a(t,e){return m(t>>e&63|128)}function s(t){if(0==(4294967168&t))return m(t);var e="";return 0==(4294965248&t)?e=m(t>>6&31|192):0==(4294901760&t)?(o(t),e=m(t>>12&15|224),e+=a(t,6)):0==(4292870144&t)&&(e=m(t>>18&7|240),e+=a(t,12),e+=a(t,6)),e+=m(63&t|128)}function u(t){for(var e,n=r(t),i=n.length,o=-1,a="";++o=v)throw Error("Invalid byte index");var t=255&_[y];if(y++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function l(){var t,e,n,r,i;if(y>v)throw Error("Invalid byte index");if(y==v)return!1;if(t=255&_[y],y++,0==(128&t))return t;if(192==(224&t)){if(e=c(),i=(31&t)<<6|e,i>=128)return i;throw Error("Invalid continuation byte")}if(224==(240&t)){if(e=c(),n=c(),i=(15&t)<<12|e<<6|n,i>=2048)return o(i),i;throw Error("Invalid continuation byte")}if(240==(248&t)&&(e=c(),n=c(),r=c(),i=(7&t)<<18|e<<12|n<<6|r,i>=65536&&i<=1114111))return i;throw Error("Invalid UTF-8 detected")}function f(t){_=r(t),v=_.length,y=0;for(var e,n=[];(e=l())!==!1;)n.push(e);return i(n)}var p="object"==typeof n&&n,h="object"==typeof e&&e&&e.exports==p&&e,d="object"==typeof global&&global;d.global!==d&&d.window!==d||(t=d);var _,v,y,m=String.fromCharCode,g={version:"2.1.2",encode:u,decode:f};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return g});else if(p&&!p.nodeType)if(h)h.exports=g;else{var b={},w=b.hasOwnProperty;for(var k in g)w.call(g,k)&&(p[k]=g[k])}else t.utf8=g}(this)},{}],87:[function(t,e,n){e.exports=XMLHttpRequest},{}],"bignumber.js":[function(t,e,n){"use strict";e.exports=BigNumber},{}],web3:[function(t,e,n){var r=t("./lib/web3");"undefined"!=typeof window&&"undefined"==typeof window.Web3&&(window.Web3=r),e.exports=r},{"./lib/web3":22}]},{},["web3"]); \ No newline at end of file +return n||Je.test(t)?er(t.slice(2),n?2:8):We.test(t)?Pt:+t}function Au(t){return zi(t,Vu(t))}function Bu(t){return t?Nn(Eu(t),-Ot,Ot):0===t?t:0}function Tu(t){return null==t?"":vi(t)}function Ou(t,e){var n=mf(t);return null==e?n:In(n,e)}function Ru(t,e){return g(t,jo(e,3),or)}function Pu(t,e){return g(t,jo(e,3),ar)}function Iu(t,e){return null==t?t:wf(t,jo(e,3),Vu)}function Du(t,e){return null==t?t:kf(t,jo(e,3),Vu)}function Mu(t,e){return t&&or(t,jo(e,3))}function Lu(t,e){return t&&ar(t,jo(e,3))}function Nu(t){return null==t?[]:ur(t,Wu(t))}function Hu(t){return null==t?[]:ur(t,Vu(t))}function zu(t,e,n){var r=null==t?et:cr(t,e);return r===et?n:r}function qu(t,e){return null!=t&&Oo(t,e,xr)}function Uu(t,e){return null!=t&&Oo(t,e,Cr)}function Wu(t){return Ks(t)?Fn(t):zr(t)}function Vu(t){return Ks(t)?Fn(t,!0):qr(t)}function $u(t,e){var n={};return e=jo(e,3),or(t,function(t,r,i){Mn(n,e(t,r,i),t)}),n}function Ju(t,e){var n={};return e=jo(e,3),or(t,function(t,r,i){Mn(n,r,e(t,r,i))}),n}function Gu(t,e){return Xu(t,Ds(jo(e)))}function Xu(t,e){if(null==t)return{};var n=p(ko(t),function(t){return[t]});return e=jo(e),Zr(t,n,function(t,n){return e(t,n[0])})}function Ku(t,e,n){e=Ei(e,t);var r=-1,i=e.length;for(i||(i=1,t=et);++re){var r=t;t=e,e=r}if(n||t%1||e%1){var i=Yl();return Kl(t+i*(e-t+tr("1e-"+((i+"").length-1))),e)}return ni(t,e)}function uc(t){return th(Tu(t).toLowerCase())}function cc(t){return t=Tu(t),t&&t.replace(Xe,yr).replace(zn,"")}function lc(t,e,n){t=Tu(t),e=vi(e);var r=t.length;n=n===et?r:Nn(Eu(n),0,r);var i=n;return n-=e.length,n>=0&&t.slice(n,i)==e}function fc(t){return t=Tu(t),t&&Ce.test(t)?t.replace(ke,mr):t}function pc(t){return t=Tu(t),t&&Re.test(t)?t.replace(Oe,"\\$&"):t}function hc(t,e,n){t=Tu(t),e=Eu(e);var r=e?K(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return oo(Ul(i),n)+t+oo(ql(i),n)}function dc(t,e,n){t=Tu(t),e=Eu(e);var r=e?K(t):0;return e&&r>>0)?(t=Tu(t),t&&("string"==typeof e||null!=e&&!Ep(e))&&(e=vi(e),!e&&H(t))?Fi(Q(t),0,n):t.split(e,n)):[]}function bc(t,e,n){return t=Tu(t),n=null==n?0:Nn(Eu(n),0,t.length),e=vi(e),t.slice(n,n+e.length)==e}function wc(t,e,n){var r=y.templateSettings;n&&No(t,e,n)&&(e=et),t=Tu(t),e=Rp({},e,r,ho);var i,o,a=Rp({},e.imports,r.imports,ho),s=Wu(a),u=R(a,s),c=0,l=e.interpolate||Ke,f="__p += '",p=pl((e.escape||Ke).source+"|"+l.source+"|"+(l===Fe?qe:Ke).source+"|"+(e.evaluate||Ke).source+"|$","g"),h="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++Jn+"]")+"\n";t.replace(p,function(e,n,r,a,s,u){return r||(r=a),f+=t.slice(c,u).replace(Qe,L),n&&(i=!0,f+="' +\n__e("+n+") +\n'"),s&&(o=!0,f+="';\n"+s+";\n__p += '"),r&&(f+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),c=u+e.length,e}),f+="';\n";var d=e.variable;d||(f="with (obj) {\n"+f+"\n}\n"),f=(o?f.replace(me,""):f).replace(ge,"$1").replace(be,"$1;"),f="function("+(d||"obj")+") {\n"+(d?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var _=eh(function(){return cl(s,h+"return "+f).apply(et,u)});if(_.source=f,ru(_))throw _;return _}function kc(t){return Tu(t).toLowerCase()}function xc(t){return Tu(t).toUpperCase()}function Cc(t,e,n){if(t=Tu(t),t&&(n||e===et))return t.replace(Pe,"");if(!t||!(e=vi(e)))return t;var r=Q(t),i=Q(e),o=I(r,i),a=D(r,i)+1;return Fi(r,o,a).join("")}function jc(t,e,n){if(t=Tu(t),t&&(n||e===et))return t.replace(De,"");if(!t||!(e=vi(e)))return t;var r=Q(t),i=D(r,Q(e))+1;return Fi(r,0,i).join("")}function Ec(t,e,n){if(t=Tu(t),t&&(n||e===et))return t.replace(Ie,"");if(!t||!(e=vi(e)))return t;var r=Q(t),i=I(r,Q(e));return Fi(r,i).join("")}function Fc(t,e){var n=Ct,r=jt;if(uu(e)){var i="separator"in e?e.separator:i;n="length"in e?Eu(e.length):n,r="omission"in e?vi(e.omission):r}t=Tu(t);var o=t.length;if(H(t)){var a=Q(t);o=a.length}if(n>=o)return t;var s=n-K(r);if(s<1)return r;var u=a?Fi(a,0,s).join(""):t.slice(0,s);if(i===et)return u+r;if(a&&(s+=u.length-s),Ep(i)){if(t.slice(s).search(i)){var c,l=u;for(i.global||(i=pl(i.source,Tu(Ue.exec(i))+"g")),i.lastIndex=0;c=i.exec(l);)var f=c.index;u=u.slice(0,f===et?s:f)}}else if(t.indexOf(vi(i),s)!=s){var p=u.lastIndexOf(i);p>-1&&(u=u.slice(0,p))}return u+r}function Sc(t){return t=Tu(t),t&&xe.test(t)?t.replace(we,gr):t}function Ac(t,e,n){return t=Tu(t),e=n?et:e,e===et?z(t)?tt(t):m(t):t.match(e)||[]}function Bc(t){var e=null==t?0:t.length,n=jo();return t=e?p(t,function(t){if("function"!=typeof t[1])throw new dl(ot);return[n(t[0]),t[1]]}):[],oi(function(n){for(var r=-1;++rOt)return[];var n=It,r=Kl(t,It);e=jo(e),t-=It;for(var i=B(r,e);++n1?t[e-1]:et;return n="function"==typeof n?(t.pop(),n):et,Qa(t,n)}),tp=bo(function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,i=function(e){return Ln(e,t)};return!(e>1||this.__actions__.length)&&r instanceof Z&&Lo(n)?(r=r.slice(n,+n+(e?1:0)),r.__actions__.push({func:ns,args:[i],thisArg:et}),new G(r,this.__chain__).thru(function(t){return e&&!t.length&&t.push(et),t})):this.thru(i)}),ep=Wi(function(t,e,n){bl.call(t,n)?++t[n]:Mn(t,n,1)}),np=Yi(_a),rp=Yi(va),ip=Wi(function(t,e,n){bl.call(t,n)?t[n].push(e):Mn(t,n,[e])}),op=oi(function(t,e,n){var r=-1,o="function"==typeof e,a=Ks(t)?al(t.length):[];return gf(t,function(t){a[++r]=o?i(e,t,n):Sr(t,e,n)}),a}),ap=Wi(function(t,e,n){Mn(t,n,e)}),sp=Wi(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]}),up=oi(function(t,e){if(null==t)return[];var n=e.length;return n>1&&No(t,e[0],e[1])?e=[]:n>2&&No(e[0],e[1],e[2])&&(e=[e[0]]),Kr(t,rr(e,1),[])}),cp=Hl||function(){return ir.Date.now()},lp=oi(function(t,e,n){var r=dt;if(n.length){var i=V(n,Co(lp));r|=gt}return po(t,r,e,n,i)}),fp=oi(function(t,e,n){var r=dt|_t;if(n.length){var i=V(n,Co(fp));r|=gt}return po(e,r,t,n,i)}),pp=oi(function(t,e){return Vn(t,1,e)}),hp=oi(function(t,e,n){return Vn(t,Su(e)||0,n)});Is.Cache=pn;var dp=jf(function(t,e){e=1==e.length&&wp(e[0])?p(e[0],O(jo())):p(rr(e,1),O(jo()));var n=e.length;return oi(function(r){for(var o=-1,a=Kl(r.length,n);++o=e}),bp=Ar(function(){return arguments}())?Ar:function(t){return cu(t)&&bl.call(t,"callee")&&!Rl.call(t,"callee")},wp=al.isArray,kp=lr?O(lr):Br,xp=Vl||Vc,Cp=fr?O(fr):Tr,jp=pr?O(pr):Pr,Ep=hr?O(hr):Mr,Fp=dr?O(dr):Lr,Sp=_r?O(_r):Nr,Ap=uo(Ur),Bp=uo(function(t,e){return t<=e}),Tp=Vi(function(t,e){if(Wo(e)||Ks(e))return void zi(e,Wu(e),t);for(var n in e)bl.call(e,n)&&On(t,n,e[n])}),Op=Vi(function(t,e){zi(e,Vu(e),t)}),Rp=Vi(function(t,e,n,r){zi(e,Vu(e),t,r)}),Pp=Vi(function(t,e,n,r){zi(e,Wu(e),t,r)}),Ip=bo(Ln),Dp=oi(function(t){return t.push(et,ho),i(Rp,et,t)}),Mp=oi(function(t){return t.push(et,_o),i(qp,et,t)}),Lp=no(function(t,e,n){t[e]=n},Oc(Pc)),Np=no(function(t,e,n){bl.call(t,e)?t[e].push(n):t[e]=[n]},jo),Hp=oi(Sr),zp=Vi(function(t,e,n){Jr(t,e,n)}),qp=Vi(function(t,e,n,r){Jr(t,e,n,r)}),Up=bo(function(t,e){var n={};if(null==t)return n;var r=!1;e=p(e,function(e){return e=Ei(e,t),r||(r=e.length>1),e}),zi(t,ko(t),n),r&&(n=qn(n,ct|lt|ft,vo));for(var i=e.length;i--;)mi(n,e[i]);return n}),Wp=bo(function(t,e){return null==t?{}:Qr(t,e)}),Vp=fo(Wu),$p=fo(Vu),Jp=Ki(function(t,e,n){return e=e.toLowerCase(),t+(n?uc(e):e)}),Gp=Ki(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()}),Xp=Ki(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()}),Kp=Xi("toLowerCase"),Qp=Ki(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()}),Zp=Ki(function(t,e,n){return t+(n?" ":"")+th(e)}),Yp=Ki(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()}),th=Xi("toUpperCase"),eh=oi(function(t,e){try{return i(t,et,e)}catch(t){return ru(t)?t:new ul(t)}}),nh=bo(function(t,e){return a(e,function(e){e=ra(e),Mn(t,e,lp(t[e],t))}),t}),rh=to(),ih=to(!0),oh=oi(function(t,e){return function(n){return Sr(n,t,e)}}),ah=oi(function(t,e){return function(n){return Sr(t,n,e)}}),sh=io(p),uh=io(u),ch=io(v),lh=so(),fh=so(!0),ph=ro(function(t,e){return t+e},0),hh=lo("ceil"),dh=ro(function(t,e){return t/e},1),_h=lo("floor"),vh=ro(function(t,e){return t*e},1),yh=lo("round"),mh=ro(function(t,e){return t-e},0);return y.after=Ss,y.ary=As,y.assign=Tp,y.assignIn=Op,y.assignInWith=Rp,y.assignWith=Pp,y.at=Ip,y.before=Bs,y.bind=lp,y.bindAll=nh,y.bindKey=fp,y.castArray=Us,y.chain=ts,y.chunk=sa,y.compact=ua,y.concat=ca,y.cond=Bc,y.conforms=Tc,y.constant=Oc,y.countBy=ep,y.create=Ou,y.curry=Ts,y.curryRight=Os,y.debounce=Rs,y.defaults=Dp,y.defaultsDeep=Mp,y.defer=pp,y.delay=hp,y.difference=Mf,y.differenceBy=Lf,y.differenceWith=Nf,y.drop=la,y.dropRight=fa,y.dropRightWhile=pa,y.dropWhile=ha,y.fill=da,y.filter=fs,y.flatMap=ps,y.flatMapDeep=hs,y.flatMapDepth=ds,y.flatten=ya,y.flattenDeep=ma,y.flattenDepth=ga,y.flip=Ps,y.flow=rh,y.flowRight=ih,y.fromPairs=ba,y.functions=Nu,y.functionsIn=Hu,y.groupBy=ip,y.initial=xa,y.intersection=Hf,y.intersectionBy=zf,y.intersectionWith=qf,y.invert=Lp,y.invertBy=Np,y.invokeMap=op,y.iteratee=Ic,y.keyBy=ap,y.keys=Wu,y.keysIn=Vu,y.map=ms,y.mapKeys=$u,y.mapValues=Ju,y.matches=Dc,y.matchesProperty=Mc,y.memoize=Is,y.merge=zp,y.mergeWith=qp,y.method=oh,y.methodOf=ah,y.mixin=Lc,y.negate=Ds,y.nthArg=zc,y.omit=Up,y.omitBy=Gu,y.once=Ms,y.orderBy=gs,y.over=sh,y.overArgs=dp,y.overEvery=uh,y.overSome=ch,y.partial=_p,y.partialRight=vp,y.partition=sp,y.pick=Wp,y.pickBy=Xu,y.property=qc,y.propertyOf=Uc,y.pull=Uf,y.pullAll=Sa,y.pullAllBy=Aa,y.pullAllWith=Ba,y.pullAt=Wf,y.range=lh,y.rangeRight=fh,y.rearg=yp,y.reject=ks,y.remove=Ta,y.rest=Ls,y.reverse=Oa,y.sampleSize=Cs,y.set=Qu,y.setWith=Zu,y.shuffle=js,y.slice=Ra,y.sortBy=up,y.sortedUniq=Ha,y.sortedUniqBy=za,y.split=gc,y.spread=Ns,y.tail=qa,y.take=Ua,y.takeRight=Wa,y.takeRightWhile=Va,y.takeWhile=$a,y.tap=es,y.throttle=Hs,y.thru=ns,y.toArray=Cu,y.toPairs=Vp,y.toPairsIn=$p,y.toPath=Kc,y.toPlainObject=Au,y.transform=Yu,y.unary=zs,y.union=Vf,y.unionBy=$f,y.unionWith=Jf,y.uniq=Ja,y.uniqBy=Ga,y.uniqWith=Xa,y.unset=tc,y.unzip=Ka,y.unzipWith=Qa,y.update=ec,y.updateWith=nc,y.values=rc,y.valuesIn=ic,y.without=Gf,y.words=Ac,y.wrap=qs,y.xor=Xf,y.xorBy=Kf,y.xorWith=Qf,y.zip=Zf,y.zipObject=Za,y.zipObjectDeep=Ya,y.zipWith=Yf,y.entries=Vp,y.entriesIn=$p,y.extend=Op,y.extendWith=Rp,Lc(y,y),y.add=ph,y.attempt=eh,y.camelCase=Jp,y.capitalize=uc,y.ceil=hh,y.clamp=oc,y.clone=Ws,y.cloneDeep=$s,y.cloneDeepWith=Js,y.cloneWith=Vs,y.conformsTo=Gs,y.deburr=cc,y.defaultTo=Rc,y.divide=dh,y.endsWith=lc,y.eq=Xs,y.escape=fc,y.escapeRegExp=pc,y.every=ls,y.find=np,y.findIndex=_a,y.findKey=Ru,y.findLast=rp,y.findLastIndex=va,y.findLastKey=Pu,y.floor=_h,y.forEach=_s,y.forEachRight=vs,y.forIn=Iu,y.forInRight=Du,y.forOwn=Mu,y.forOwnRight=Lu,y.get=zu,y.gt=mp,y.gte=gp,y.has=qu,y.hasIn=Uu,y.head=wa,y.identity=Pc,y.includes=ys,y.indexOf=ka,y.inRange=ac,y.invoke=Hp,y.isArguments=bp,y.isArray=wp,y.isArrayBuffer=kp,y.isArrayLike=Ks,y.isArrayLikeObject=Qs,y.isBoolean=Zs,y.isBuffer=xp,y.isDate=Cp,y.isElement=Ys,y.isEmpty=tu,y.isEqual=eu,y.isEqualWith=nu,y.isError=ru,y.isFinite=iu,y.isFunction=ou,y.isInteger=au,y.isLength=su,y.isMap=jp,y.isMatch=lu,y.isMatchWith=fu,y.isNaN=pu,y.isNative=hu,y.isNil=_u,y.isNull=du,y.isNumber=vu,y.isObject=uu,y.isObjectLike=cu,y.isPlainObject=yu,y.isRegExp=Ep,y.isSafeInteger=mu,y.isSet=Fp,y.isString=gu,y.isSymbol=bu,y.isTypedArray=Sp,y.isUndefined=wu,y.isWeakMap=ku,y.isWeakSet=xu,y.join=Ca,y.kebabCase=Gp,y.last=ja,y.lastIndexOf=Ea,y.lowerCase=Xp,y.lowerFirst=Kp,y.lt=Ap,y.lte=Bp,y.max=Zc,y.maxBy=Yc,y.mean=tl,y.meanBy=el,y.min=nl,y.minBy=rl,y.stubArray=Wc,y.stubFalse=Vc,y.stubObject=$c,y.stubString=Jc,y.stubTrue=Gc,y.multiply=vh,y.nth=Fa,y.noConflict=Nc,y.noop=Hc,y.now=cp,y.pad=hc,y.padEnd=dc,y.padStart=_c,y.parseInt=vc,y.random=sc,y.reduce=bs,y.reduceRight=ws,y.repeat=yc,y.replace=mc,y.result=Ku,y.round=yh,y.runInContext=e,y.sample=xs,y.size=Es,y.snakeCase=Qp,y.some=Fs,y.sortedIndex=Pa,y.sortedIndexBy=Ia,y.sortedIndexOf=Da,y.sortedLastIndex=Ma,y.sortedLastIndexBy=La,y.sortedLastIndexOf=Na,y.startCase=Zp,y.startsWith=bc,y.subtract=mh,y.sum=il,y.sumBy=ol,y.template=wc,y.times=Xc,y.toFinite=ju,y.toInteger=Eu,y.toLength=Fu,y.toLower=kc,y.toNumber=Su,y.toSafeInteger=Bu,y.toString=Tu,y.toUpper=xc,y.trim=Cc,y.trimEnd=jc,y.trimStart=Ec,y.truncate=Fc,y.unescape=Sc,y.uniqueId=Qc,y.upperCase=Yp,y.upperFirst=th,y.each=_s,y.eachRight=vs,y.first=wa,Lc(y,function(){var t={};return or(y,function(e,n){bl.call(y.prototype,n)||(t[n]=e)}),t}(),{chain:!1}),y.VERSION=nt,a(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){y[t].placeholder=y}),a(["drop","take"],function(t,e){Z.prototype[t]=function(n){n=n===et?1:Xl(Eu(n),0);var r=this.__filtered__&&!e?new Z(this):this.clone();return r.__filtered__?r.__takeCount__=Kl(n,r.__takeCount__):r.__views__.push({size:Kl(n,It),type:t+(r.__dir__<0?"Right":"")}),r},Z.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),a(["filter","map","takeWhile"],function(t,e){var n=e+1,r=n==St||n==Bt;Z.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:jo(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}}),a(["head","last"],function(t,e){var n="take"+(e?"Right":"");Z.prototype[t]=function(){return this[n](1).value()[0]}}),a(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");Z.prototype[t]=function(){return this.__filtered__?new Z(this):this[n](1)}}),Z.prototype.compact=function(){return this.filter(Pc)},Z.prototype.find=function(t){return this.filter(t).head()},Z.prototype.findLast=function(t){return this.reverse().find(t)},Z.prototype.invokeMap=oi(function(t,e){return"function"==typeof t?new Z(this):this.map(function(n){return Sr(n,t,e)})}),Z.prototype.reject=function(t){return this.filter(Ds(jo(t)))},Z.prototype.slice=function(t,e){t=Eu(t);var n=this;return n.__filtered__&&(t>0||e<0)?new Z(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==et&&(e=Eu(e),n=e<0?n.dropRight(-e):n.take(e-t)),n)},Z.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Z.prototype.toArray=function(){return this.take(It)},or(Z.prototype,function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=y[r?"take"+("last"==e?"Right":""):e],o=r||/^find/.test(e);i&&(y.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,s=e instanceof Z,u=a[0],c=s||wp(e),l=function(t){var e=i.apply(y,h([t],a));return r&&f?e[0]:e};c&&n&&"function"==typeof u&&1!=u.length&&(s=c=!1);var f=this.__chain__,p=!!this.__actions__.length,d=o&&!f,_=s&&!p;if(!o&&c){e=_?e:new Z(this);var v=t.apply(e,a);return v.__actions__.push({func:ns,args:[l],thisArg:et}),new G(v,f)}return d&&_?t.apply(this,a):(v=this.thru(l),d?r?v.value()[0]:v.value():v)})}),a(["pop","push","shift","sort","splice","unshift"],function(t){var e=_l[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);y.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(wp(i)?i:[],t)}return this[n](function(n){return e.apply(wp(n)?n:[],t)})}}),or(Z.prototype,function(t,e){var n=y[e];if(n){var r=n.name+"",i=cf[r]||(cf[r]=[]);i.push({name:e,func:n})}}),cf[eo(et,_t).name]=[{name:"wrapper",func:et}],Z.prototype.clone=Y,Z.prototype.reverse=He,Z.prototype.value=Ze,y.prototype.at=tp,y.prototype.chain=rs,y.prototype.commit=is,y.prototype.next=os,y.prototype.plant=ss,y.prototype.reverse=us,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=cs,y.prototype.first=y.prototype.head,Dl&&(y.prototype[Dl]=as),y},wr=br();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(ir._=wr,define(function(){return wr})):ar?((ar.exports=wr)._=wr,or._=wr):ir._=wr}).call(this)},{}],86:[function(t,e,n){!function(t){function r(t){for(var e,n,r=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e-=65536,i+=m(e>>>10&1023|55296),e=56320|1023&e),i+=m(e);return i}function o(t){if(t>=55296&&t<=57343)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value")}function a(t,e){return m(t>>e&63|128)}function s(t){if(0==(4294967168&t))return m(t);var e="";return 0==(4294965248&t)?e=m(t>>6&31|192):0==(4294901760&t)?(o(t),e=m(t>>12&15|224),e+=a(t,6)):0==(4292870144&t)&&(e=m(t>>18&7|240),e+=a(t,12),e+=a(t,6)),e+=m(63&t|128)}function u(t){for(var e,n=r(t),i=n.length,o=-1,a="";++o=v)throw Error("Invalid byte index");var t=255&_[y];if(y++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function l(){var t,e,n,r,i;if(y>v)throw Error("Invalid byte index");if(y==v)return!1;if(t=255&_[y],y++,0==(128&t))return t;if(192==(224&t)){if(e=c(),i=(31&t)<<6|e,i>=128)return i;throw Error("Invalid continuation byte")}if(224==(240&t)){if(e=c(),n=c(),i=(15&t)<<12|e<<6|n,i>=2048)return o(i),i;throw Error("Invalid continuation byte")}if(240==(248&t)&&(e=c(),n=c(),r=c(),i=(7&t)<<18|e<<12|n<<6|r,i>=65536&&i<=1114111))return i;throw Error("Invalid UTF-8 detected")}function f(t){_=r(t),v=_.length,y=0;for(var e,n=[];(e=l())!==!1;)n.push(e);return i(n)}var p="object"==typeof n&&n,h="object"==typeof e&&e&&e.exports==p&&e,d="object"==typeof global&&global;d.global!==d&&d.window!==d||(t=d);var _,v,y,m=String.fromCharCode,g={version:"2.1.2",encode:u,decode:f};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return g});else if(p&&!p.nodeType)if(h)h.exports=g;else{var b={},w=b.hasOwnProperty;for(var k in g)w.call(g,k)&&(p[k]=g[k])}else t.utf8=g}(this)},{}],87:[function(t,e,n){e.exports=XMLHttpRequest},{}],"bignumber.js":[function(t,e,n){"use strict";e.exports=BigNumber},{}],web3:[function(t,e,n){var r=t("./lib/web3");"undefined"!=typeof window&&"undefined"==typeof window.Web3&&(window.Web3=r),e.exports=r},{"./lib/web3":22}]},{},["web3"]); +======= +require=function t(e,n,r){function o(a,s){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[a]={exports:{}};e[a][0].call(f.exports,function(t){var n=e[a][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a2&&"0x"===t.substr(0,2)&&(t=t.substr(2)),t=r.enc.Hex.parse(t)),o(t,{outputLength:256}).toString()}},{"crypto-js":59,"crypto-js/sha3":80}],20:[function(t,e,n){var r=t("bignumber.js"),o=t("./sha3.js"),i=t("utf8"),a={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",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",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"},s=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},c=function(t,e,n){return t+new Array(e-t.length+1).join(n?n:"0")},u=function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);n7&&t[n].toUpperCase()!==t[n]||parseInt(e[n],16)<=7&&t[n].toLowerCase()!==t[n])return!1;return!0},A=function(t){if("undefined"==typeof t)return"";t=t.toLowerCase().replace("0x","");for(var e=o(t),n="0x",r=0;r7?t[r].toUpperCase():t[r];return n},F=function(t){return B(t)?t:/^[0-9a-f]{40}$/.test(t)?"0x"+t:"0x"+s(g(t).substr(2),40)},I=function(t){return t instanceof r||t&&t.constructor&&"BigNumber"===t.constructor.name},T=function(t){return"string"==typeof t||t&&t.constructor&&"String"===t.constructor.name},D=function(t){return"function"==typeof t},P=function(t){return"object"==typeof t},O=function(t){return"boolean"==typeof t},E=function(t){return t instanceof Array},M=function(t){try{return!!JSON.parse(t)}catch(t){return!1}};e.exports={padLeft:s,padRight:c,toHex:g,toDecimal:y,fromDecimal:v,toUtf8:u,toAscii:f,fromUtf8:p,fromAscii:l,transformToFullName:h,extractDisplayName:d,extractTypeName:m,toWei:w,fromWei:_,toBigNumber:x,toTwosComplement:k,toAddress:F,isBigNumber:I,isStrictAddress:B,isAddress:S,isChecksumAddress:C,toChecksumAddress:A,isFunction:D,isString:T,isObject:P,isBoolean:O,isArray:E,isJson:M}},{"./sha3.js":19,"bignumber.js":"bignumber.js",utf8:85}],21:[function(t,e,n){e.exports={version:"0.18.3"}},{}],22:[function(t,e,n){function r(t){this._requestManager=new o(t),this.currentProvider=t,this.eth=new a(this),this.db=new s(this),this.shh=new c(this),this.net=new u(this),this.personal=new f(this),this.bzz=new p(this),this.settings=new l,this.version={api:h.version},this.providers={HttpProvider:b,IpcProvider:_},this._extend=y(this),this._extend({properties:x()})}var o=t("./web3/requestmanager"),i=t("./web3/iban"),a=t("./web3/methods/eth"),s=t("./web3/methods/db"),c=t("./web3/methods/shh"),u=t("./web3/methods/net"),f=t("./web3/methods/personal"),p=t("./web3/methods/swarm"),l=t("./web3/settings"),h=t("./version.json"),d=t("./utils/utils"),m=t("./utils/sha3"),y=t("./web3/extend"),v=t("./web3/batch"),g=t("./web3/property"),b=t("./web3/httpprovider"),_=t("./web3/ipcprovider"),w=t("bignumber.js");r.providers={HttpProvider:b,IpcProvider:_},r.prototype.setProvider=function(t){this._requestManager.setProvider(t),this.currentProvider=t},r.prototype.reset=function(t){this._requestManager.reset(t),this.settings=new l},r.prototype.BigNumber=w,r.prototype.toHex=d.toHex,r.prototype.toAscii=d.toAscii,r.prototype.toUtf8=d.toUtf8,r.prototype.fromAscii=d.fromAscii,r.prototype.fromUtf8=d.fromUtf8,r.prototype.toDecimal=d.toDecimal,r.prototype.fromDecimal=d.fromDecimal,r.prototype.toBigNumber=d.toBigNumber,r.prototype.toWei=d.toWei,r.prototype.fromWei=d.fromWei,r.prototype.isAddress=d.isAddress,r.prototype.isChecksumAddress=d.isChecksumAddress,r.prototype.toChecksumAddress=d.toChecksumAddress,r.prototype.isIBAN=d.isIBAN,r.prototype.sha3=function(t,e){return"0x"+m(t,e)},r.prototype.fromICAP=function(t){var e=new i(t);return e.address()};var x=function(){return[new g({name:"version.node",getter:"web3_clientVersion"}),new g({name:"version.network",getter:"net_version",inputFormatter:d.toDecimal}),new g({name:"version.ethereum",getter:"eth_protocolVersion",inputFormatter:d.toDecimal}),new g({name:"version.whisper",getter:"shh_version",inputFormatter:d.toDecimal})]};r.prototype.isConnected=function(){return this.currentProvider&&this.currentProvider.isConnected()},r.prototype.createBatch=function(){return new v(this)},e.exports=r},{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/methods/swarm":42,"./web3/property":45,"./web3/requestmanager":46,"./web3/settings":47,"bignumber.js":"bignumber.js"}],23:[function(t,e,n){var r=t("../utils/sha3"),o=t("./event"),i=t("./formatters"),a=t("../utils/utils"),s=t("./filter"),c=t("./methods/watches"),u=function(t,e,n){this._requestManager=t,this._json=e,this._address=n};u.prototype.encode=function(t){t=t||{};var e={};return["fromBlock","toBlock"].filter(function(e){return void 0!==t[e]}).forEach(function(n){e[n]=i.inputBlockNumberFormatter(t[n])}),e.address=this._address,e},u.prototype.decode=function(t){t.data=t.data||"",t.topics=t.topics||[];var e=t.topics[0].slice(2),n=this._json.filter(function(t){return e===r(a.transformToFullName(t))})[0];if(!n)return console.warn("cannot find event for log"),t;var i=new o(this._requestManager,n,this._address);return i.decode(t)},u.prototype.execute=function(t,e){a.isFunction(arguments[arguments.length-1])&&(e=arguments[arguments.length-1],1===arguments.length&&(t=null));var n=this.encode(t),r=this.decode.bind(this);return new s(this._requestManager,n,c.eth(),r,e)},u.prototype.attachToContract=function(t){var e=this.execute.bind(this);t.allEvents=e},e.exports=u},{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":43}],24:[function(t,e,n){var r=t("./jsonrpc"),o=t("./errors"),i=function(t){this.requestManager=t._requestManager,this.requests=[]};i.prototype.add=function(t){this.requests.push(t)},i.prototype.execute=function(){var t=this.requests;this.requestManager.sendBatch(t,function(e,n){n=n||[],t.map(function(t,e){return n[e]||{}}).forEach(function(e,n){if(t[n].callback){if(!r.isValidResponse(e))return t[n].callback(o.InvalidResponse(e));t[n].callback(null,t[n].format?t[n].format(e.result):e.result)}})})},e.exports=i},{"./errors":26,"./jsonrpc":35}],25:[function(t,e,n){var r=t("../utils/utils"),o=t("../solidity/coder"),i=t("./event"),a=t("./function"),s=t("./allevents"),c=function(t,e){return t.filter(function(t){return"constructor"===t.type&&t.inputs.length===e.length}).map(function(t){return t.inputs.map(function(t){return t.type})}).map(function(t){return o.encodeParams(t,e)})[0]||""},u=function(t){t.abi.filter(function(t){return"function"===t.type}).map(function(e){return new a(t._eth,e,t.address)}).forEach(function(e){e.attachToContract(t)})},f=function(t){var e=t.abi.filter(function(t){return"event"===t.type}),n=new s(t._eth._requestManager,e,t.address);n.attachToContract(t),e.map(function(e){return new i(t._eth._requestManager,e,t.address)}).forEach(function(e){e.attachToContract(t)})},p=function(t,e){var n=0,r=!1,o=t._eth.filter("latest",function(i){if(!i&&!r)if(n++,n>50){if(o.stopWatching(function(){}),r=!0,!e)throw new Error("Contract transaction couldn't be found after 50 blocks");e(new Error("Contract transaction couldn't be found after 50 blocks"))}else t._eth.getTransactionReceipt(t.transactionHash,function(n,i){i&&!r&&t._eth.getCode(i.contractAddress,function(n,a){if(!r&&a)if(o.stopWatching(function(){}),r=!0,a.length>3)t.address=i.contractAddress,u(t),f(t),e&&e(null,t);else{if(!e)throw new Error("The contract code couldn't be stored, please check your gas amount.");e(new Error("The contract code couldn't be stored, please check your gas amount."))}})})})},l=function(t,e){this.eth=t,this.abi=e,this.new=function(){var t,n=new h(this.eth,this.abi),o={},i=Array.prototype.slice.call(arguments);r.isFunction(i[i.length-1])&&(t=i.pop());var a=i[i.length-1];if(r.isObject(a)&&!r.isArray(a)&&(o=i.pop()),o.value>0){var s=e.filter(function(t){return"constructor"===t.type&&t.inputs.length===i.length})[0]||{};if(!s.payable)throw new Error("Cannot send value to non-payable constructor")}var u=c(this.abi,i);if(o.data+=u,t)this.eth.sendTransaction(o,function(e,r){e?t(e):(n.transactionHash=r,t(null,n),p(n,t))});else{var f=this.eth.sendTransaction(o);n.transactionHash=f,p(n)}return n},this.new.getData=this.getData.bind(this)};l.prototype.at=function(t,e){var n=new h(this.eth,this.abi,t);return u(n),f(n),e&&e(null,n),n},l.prototype.getData=function(){var t={},e=Array.prototype.slice.call(arguments),n=e[e.length-1];r.isObject(n)&&!r.isArray(n)&&(t=e.pop());var o=c(this.abi,e);return t.data+=o,t.data};var h=function(t,e,n){this._eth=t,this.transactionHash=null,this.address=n,this.abi=e};e.exports=l},{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(t,e,n){e.exports={InvalidNumberOfParams:function(){return new Error("Invalid number of input parameters")},InvalidConnection:function(t){return new Error("CONNECTION ERROR: Couldn't connect to node "+t+".")},InvalidProvider:function(){return new Error("Provider not set or invalid")},InvalidResponse:function(t){var e=t&&t.error&&t.error.message?t.error.message:"Invalid JSON RPC response: "+JSON.stringify(t);return new Error(e)},ConnectionTimeout:function(t){return new Error("CONNECTION TIMEOUT: timeout of "+t+" ms achived")}}},{}],27:[function(t,e,n){var r=t("../utils/utils"),o=t("../solidity/coder"),i=t("./formatters"),a=t("../utils/sha3"),s=t("./filter"),c=t("./methods/watches"),u=function(t,e,n){this._requestManager=t,this._params=e.inputs,this._name=r.transformToFullName(e),this._address=n,this._anonymous=e.anonymous};u.prototype.types=function(t){return this._params.filter(function(e){return e.indexed===t}).map(function(t){return t.type})},u.prototype.displayName=function(){return r.extractDisplayName(this._name)},u.prototype.typeName=function(){return r.extractTypeName(this._name)},u.prototype.signature=function(){return a(this._name)},u.prototype.encode=function(t,e){t=t||{},e=e||{};var n={};["fromBlock","toBlock"].filter(function(t){return void 0!==e[t]}).forEach(function(t){n[t]=i.inputBlockNumberFormatter(e[t])}),n.topics=[],n.address=this._address,this._anonymous||n.topics.push("0x"+this.signature());var a=this._params.filter(function(t){return t.indexed===!0}).map(function(e){var n=t[e.name];return void 0===n||null===n?null:r.isArray(n)?n.map(function(t){return"0x"+o.encodeParam(e.type,t)}):"0x"+o.encodeParam(e.type,n)});return n.topics=n.topics.concat(a),n},u.prototype.decode=function(t){t.data=t.data||"",t.topics=t.topics||[];var e=this._anonymous?t.topics:t.topics.slice(1),n=e.map(function(t){return t.slice(2)}).join(""),r=o.decodeParams(this.types(!0),n),a=t.data.slice(2),s=o.decodeParams(this.types(!1),a),c=i.outputLogFormatter(t);return c.event=this.displayName(),c.address=t.address,c.args=this._params.reduce(function(t,e){return t[e.name]=e.indexed?r.shift():s.shift(),t},{}),delete c.data,delete c.topics,c},u.prototype.execute=function(t,e,n){r.isFunction(arguments[arguments.length-1])&&(n=arguments[arguments.length-1],2===arguments.length&&(e=null),1===arguments.length&&(e=null,t={}));var o=this.encode(t,e),i=this.decode.bind(this);return new s(this._requestManager,o,c.eth(),i,n)},u.prototype.attachToContract=function(t){var e=this.execute.bind(this),n=this.displayName();t[n]||(t[n]=e),t[n][this.typeName()]=this.execute.bind(this,t)},e.exports=u},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":43}],28:[function(t,e,n){var r=t("./formatters"),o=t("./../utils/utils"),i=t("./method"),a=t("./property"),s=function(t){var e=function(e){var n;e.property?(t[e.property]||(t[e.property]={}),n=t[e.property]):n=t,e.methods&&e.methods.forEach(function(e){e.attachToObject(n),e.setRequestManager(t._requestManager)}),e.properties&&e.properties.forEach(function(e){e.attachToObject(n),e.setRequestManager(t._requestManager)})};return e.formatters=r,e.utils=o,e.Method=i,e.Property=a,e};e.exports=s},{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":45}],29:[function(t,e,n){var r=t("./formatters"),o=t("../utils/utils"),i=function(t){return null===t||"undefined"==typeof t?null:(t=String(t),0===t.indexOf("0x")?t:o.fromUtf8(t))},a=function(t){return o.isString(t)?t:(t=t||{},t.topics=t.topics||[],t.topics=t.topics.map(function(t){return o.isArray(t)?t.map(i):i(t)}),{topics:t.topics,from:t.from,to:t.to,address:t.address,fromBlock:r.inputBlockNumberFormatter(t.fromBlock),toBlock:r.inputBlockNumberFormatter(t.toBlock)})},s=function(t,e){o.isString(t.options)||t.get(function(t,n){t&&e(t),o.isArray(n)&&n.forEach(function(t){e(null,t)})})},c=function(t){var e=function(e,n){return e?t.callbacks.forEach(function(t){t(e)}):void(o.isArray(n)&&n.forEach(function(e){e=t.formatter?t.formatter(e):e,t.callbacks.forEach(function(t){t(null,e)})}))};t.requestManager.startPolling({method:t.implementation.poll.call,params:[t.filterId]},t.filterId,e,t.stopWatching.bind(t))},u=function(t,e,n,r,o,i){var u=this,f={};return n.forEach(function(e){e.setRequestManager(t),e.attachToObject(f)}),this.requestManager=t,this.options=a(e),this.implementation=f,this.filterId=null,this.callbacks=[],this.getLogsCallbacks=[],this.pollFilters=[],this.formatter=r,this.implementation.newFilter(this.options,function(t,e){ +if(t)u.callbacks.forEach(function(e){e(t)}),i(t);else if(u.filterId=e,u.getLogsCallbacks.forEach(function(t){u.get(t)}),u.getLogsCallbacks=[],u.callbacks.forEach(function(t){s(u,t)}),u.callbacks.length>0&&c(u),"function"==typeof o)return u.watch(o)}),this};u.prototype.watch=function(t){return this.callbacks.push(t),this.filterId&&(s(this,t),c(this)),this},u.prototype.stopWatching=function(t){return this.requestManager.stopPolling(this.filterId),this.callbacks=[],t?void this.implementation.uninstallFilter(this.filterId,t):this.implementation.uninstallFilter(this.filterId)},u.prototype.get=function(t){var e=this;if(!o.isFunction(t)){if(null===this.filterId)throw new Error("Filter ID Error: filter().get() can't be chained synchronous, please provide a callback for the get() method.");var n=this.implementation.getLogs(this.filterId);return n.map(function(t){return e.formatter?e.formatter(t):t})}return null===this.filterId?this.getLogsCallbacks.push(t):this.implementation.getLogs(this.filterId,function(n,r){n?t(n):t(null,r.map(function(t){return e.formatter?e.formatter(t):t}))}),this},e.exports=u},{"../utils/utils":20,"./formatters":30}],30:[function(t,e,n){var r=t("../utils/utils"),o=t("../utils/config"),i=t("./iban"),a=function(t){return r.toBigNumber(t)},s=function(t){return"latest"===t||"pending"===t||"earliest"===t},c=function(t){return void 0===t?o.defaultBlock:u(t)},u=function(t){if(void 0!==t)return s(t)?t:r.toHex(t)},f=function(t){return t.from=t.from||o.defaultAccount,t.from&&(t.from=g(t.from)),t.to&&(t.to=g(t.to)),["gasPrice","gas","value","nonce"].filter(function(e){return void 0!==t[e]}).forEach(function(e){t[e]=r.fromDecimal(t[e])}),t},p=function(t){return t.from=t.from||o.defaultAccount,t.from=g(t.from),t.to&&(t.to=g(t.to)),["gasPrice","gas","value","nonce"].filter(function(e){return void 0!==t[e]}).forEach(function(e){t[e]=r.fromDecimal(t[e])}),t},l=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),t.nonce=r.toDecimal(t.nonce),t.gas=r.toDecimal(t.gas),t.gasPrice=r.toBigNumber(t.gasPrice),t.value=r.toBigNumber(t.value),t},h=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),t.cumulativeGasUsed=r.toDecimal(t.cumulativeGasUsed),t.gasUsed=r.toDecimal(t.gasUsed),r.isArray(t.logs)&&(t.logs=t.logs.map(function(t){return m(t)})),t},d=function(t){return t.gasLimit=r.toDecimal(t.gasLimit),t.gasUsed=r.toDecimal(t.gasUsed),t.size=r.toDecimal(t.size),t.timestamp=r.toDecimal(t.timestamp),null!==t.number&&(t.number=r.toDecimal(t.number)),t.difficulty=r.toBigNumber(t.difficulty),t.totalDifficulty=r.toBigNumber(t.totalDifficulty),r.isArray(t.transactions)&&t.transactions.forEach(function(t){if(!r.isString(t))return l(t)}),t},m=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),null!==t.logIndex&&(t.logIndex=r.toDecimal(t.logIndex)),t},y=function(t){return t.ttl=r.fromDecimal(t.ttl),t.workToProve=r.fromDecimal(t.workToProve),t.priority=r.fromDecimal(t.priority),r.isArray(t.topics)||(t.topics=t.topics?[t.topics]:[]),t.topics=t.topics.map(function(t){return 0===t.indexOf("0x")?t:r.fromUtf8(t)}),t},v=function(t){return t.expiry=r.toDecimal(t.expiry),t.sent=r.toDecimal(t.sent),t.ttl=r.toDecimal(t.ttl),t.workProved=r.toDecimal(t.workProved),t.topics||(t.topics=[]),t.topics=t.topics.map(function(t){return r.toAscii(t)}),t},g=function(t){var e=new i(t);if(e.isValid()&&e.isDirect())return"0x"+e.address();if(r.isStrictAddress(t))return t;if(r.isAddress(t))return"0x"+t;throw new Error("invalid address")},b=function(t){return t.startingBlock=r.toDecimal(t.startingBlock),t.currentBlock=r.toDecimal(t.currentBlock),t.highestBlock=r.toDecimal(t.highestBlock),t.knownStates&&(t.knownStates=r.toDecimal(t.knownStates),t.pulledStates=r.toDecimal(t.pulledStates)),t};e.exports={inputDefaultBlockNumberFormatter:c,inputBlockNumberFormatter:u,inputCallFormatter:f,inputTransactionFormatter:p,inputAddressFormatter:g,inputPostFormatter:y,outputBigNumberFormatter:a,outputTransactionFormatter:l,outputTransactionReceiptFormatter:h,outputBlockFormatter:d,outputLogFormatter:m,outputPostFormatter:v,outputSyncingFormatter:b}},{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(t,e,n){var r=t("../solidity/coder"),o=t("../utils/utils"),i=t("./formatters"),a=t("../utils/sha3"),s=function(t,e,n){this._eth=t,this._inputTypes=e.inputs.map(function(t){return t.type}),this._outputTypes=e.outputs.map(function(t){return t.type}),this._constant=e.constant,this._payable=e.payable,this._name=o.transformToFullName(e),this._address=n};s.prototype.extractCallback=function(t){if(o.isFunction(t[t.length-1]))return t.pop()},s.prototype.extractDefaultBlock=function(t){if(t.length>this._inputTypes.length&&!o.isObject(t[t.length-1]))return i.inputDefaultBlockNumberFormatter(t.pop())},s.prototype.toPayload=function(t){var e={};return t.length>this._inputTypes.length&&o.isObject(t[t.length-1])&&(e=t[t.length-1]),e.to=this._address,e.data="0x"+this.signature()+r.encodeParams(this._inputTypes,t),e},s.prototype.signature=function(){return a(this._name).slice(0,8)},s.prototype.unpackOutput=function(t){if(t){t=t.length>=2?t.slice(2):t;var e=r.decodeParams(this._outputTypes,t);return 1===e.length?e[0]:e}},s.prototype.call=function(){var t=Array.prototype.slice.call(arguments).filter(function(t){return void 0!==t}),e=this.extractCallback(t),n=this.extractDefaultBlock(t),r=this.toPayload(t);if(!e){var o=this._eth.call(r,n);return this.unpackOutput(o)}var i=this;this._eth.call(r,n,function(t,n){if(t)return e(t,null);var r=null;try{r=i.unpackOutput(n)}catch(e){t=e}e(t,r)})},s.prototype.sendTransaction=function(){var t=Array.prototype.slice.call(arguments).filter(function(t){return void 0!==t}),e=this.extractCallback(t),n=this.toPayload(t);if(n.value>0&&!this._payable)throw new Error("Cannot send value to non-payable function");return e?void this._eth.sendTransaction(n,e):this._eth.sendTransaction(n)},s.prototype.estimateGas=function(){var t=Array.prototype.slice.call(arguments),e=this.extractCallback(t),n=this.toPayload(t);return e?void this._eth.estimateGas(n,e):this._eth.estimateGas(n)},s.prototype.getData=function(){var t=Array.prototype.slice.call(arguments),e=this.toPayload(t);return e.data},s.prototype.displayName=function(){return o.extractDisplayName(this._name)},s.prototype.typeName=function(){return o.extractTypeName(this._name)},s.prototype.request=function(){var t=Array.prototype.slice.call(arguments),e=this.extractCallback(t),n=this.toPayload(t),r=this.unpackOutput.bind(this);return{method:this._constant?"eth_call":"eth_sendTransaction",callback:e,params:[n],format:r}},s.prototype.execute=function(){var t=!this._constant;return t?this.sendTransaction.apply(this,Array.prototype.slice.call(arguments)):this.call.apply(this,Array.prototype.slice.call(arguments))},s.prototype.attachToContract=function(t){var e=this.execute.bind(this);e.request=this.request.bind(this),e.call=this.call.bind(this),e.sendTransaction=this.sendTransaction.bind(this),e.estimateGas=this.estimateGas.bind(this),e.getData=this.getData.bind(this);var n=this.displayName();t[n]||(t[n]=e),t[n][this.typeName()]=e},e.exports=s},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./formatters":30}],32:[function(t,e,n){var r=t("./errors");"undefined"!=typeof window&&window.XMLHttpRequest?XMLHttpRequest=window.XMLHttpRequest:XMLHttpRequest=t("xmlhttprequest").XMLHttpRequest;var o=t("xhr2"),i=function(t,e){this.host=t||"http://localhost:8545",this.timeout=e||0};i.prototype.prepareRequest=function(t){var e;return t?(e=new o,e.timeout=this.timeout):e=new XMLHttpRequest,e.open("POST",this.host,t),e.setRequestHeader("Content-Type","application/json"),e},i.prototype.send=function(t){var e=this.prepareRequest(!1);try{e.send(JSON.stringify(t))}catch(t){throw r.InvalidConnection(this.host)}var n=e.responseText;try{n=JSON.parse(n)}catch(t){throw r.InvalidResponse(e.responseText)}return n},i.prototype.sendAsync=function(t,e){var n=this.prepareRequest(!0);n.onreadystatechange=function(){if(4===n.readyState&&1!==n.timeout){var t=n.responseText,o=null;try{t=JSON.parse(t)}catch(t){o=r.InvalidResponse(n.responseText)}e(o,t)}},n.ontimeout=function(){e(r.ConnectionTimeout(this.timeout))};try{n.send(JSON.stringify(t))}catch(t){e(r.InvalidConnection(this.host))}},i.prototype.isConnected=function(){try{return this.send({id:9999999999,jsonrpc:"2.0",method:"net_listening",params:[]}),!0}catch(t){return!1}},e.exports=i},{"./errors":26,xhr2:86,xmlhttprequest:17}],33:[function(t,e,n){var r=t("bignumber.js"),o=function(t,e){for(var n=t;n.length<2*e;)n="0"+n;return n},i=function(t){var e="A".charCodeAt(0),n="Z".charCodeAt(0);return t=t.toUpperCase(),t=t.substr(4)+t.substr(0,4),t.split("").map(function(t){var r=t.charCodeAt(0);return r>=e&&r<=n?r-e+10:t}).join("")},a=function(t){for(var e,n=t;n.length>2;)e=n.slice(0,9),n=parseInt(e,10)%97+n.slice(e.length);return parseInt(n,10)%97},s=function(t){this._iban=t};s.fromAddress=function(t){var e=new r(t,16),n=e.toString(36),i=o(n,15);return s.fromBban(i.toUpperCase())},s.fromBban=function(t){var e="XE",n=a(i(e+"00"+t)),r=("0"+(98-n)).slice(-2);return new s(e+r+t)},s.createIndirect=function(t){return s.fromBban("ETH"+t.institution+t.identifier)},s.isValid=function(t){var e=new s(t);return e.isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(i(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.address=function(){if(this.isDirect()){var t=this._iban.substr(4),e=new r(t,36);return o(e.toString(16),20)}return""},s.prototype.toString=function(){return this._iban},e.exports=s},{"bignumber.js":"bignumber.js"}],34:[function(t,e,n){"use strict";var r=t("../utils/utils"),o=t("./errors"),i=function(t,e){var n=this;this.responseCallbacks={},this.path=t,this.connection=e.connect({path:this.path}),this.connection.on("error",function(t){console.error("IPC Connection Error",t),n._timeout()}),this.connection.on("end",function(){n._timeout()}),this.connection.on("data",function(t){n._parseResponse(t.toString()).forEach(function(t){var e=null;r.isArray(t)?t.forEach(function(t){n.responseCallbacks[t.id]&&(e=t.id)}):e=t.id,n.responseCallbacks[e]&&(n.responseCallbacks[e](null,t),delete n.responseCallbacks[e])})})};i.prototype._parseResponse=function(t){var e=this,n=[],r=t.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|");return r.forEach(function(t){e.lastChunk&&(t=e.lastChunk+t);var r=null;try{r=JSON.parse(t)}catch(n){return e.lastChunk=t,clearTimeout(e.lastChunkTimeout),void(e.lastChunkTimeout=setTimeout(function(){throw e._timeout(),o.InvalidResponse(t)},15e3))}clearTimeout(e.lastChunkTimeout),e.lastChunk=null,r&&n.push(r)}),n},i.prototype._addResponseCallback=function(t,e){var n=t.id||t[0].id,r=t.method||t[0].method;this.responseCallbacks[n]=e,this.responseCallbacks[n].method=r},i.prototype._timeout=function(){for(var t in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(t)&&(this.responseCallbacks[t](o.InvalidConnection("on IPC")),delete this.responseCallbacks[t])},i.prototype.isConnected=function(){var t=this;return t.connection.writable||t.connection.connect({path:t.path}),!!this.connection.writable},i.prototype.send=function(t){if(this.connection.writeSync){var e;this.connection.writable||this.connection.connect({path:this.path});var n=this.connection.writeSync(JSON.stringify(t));try{e=JSON.parse(n)}catch(t){throw o.InvalidResponse(n)}return e}throw new Error('You tried to send "'+t.method+'" synchronously. Synchronous requests are not supported by the IPC provider.')},i.prototype.sendAsync=function(t,e){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(t)),this._addResponseCallback(t,e)},e.exports=i},{"../utils/utils":20,"./errors":26}],35:[function(t,e,n){var r={messageId:0};r.toPayload=function(t,e){return t||console.error("jsonrpc method should be specified!"),r.messageId++,{jsonrpc:"2.0",id:r.messageId,method:t,params:e||[]}},r.isValidResponse=function(t){function e(t){return!!t&&!t.error&&"2.0"===t.jsonrpc&&"number"==typeof t.id&&void 0!==t.result}return Array.isArray(t)?t.every(e):e(t)},r.toBatchPayload=function(t){return t.map(function(t){return r.toPayload(t.method,t.params)})},e.exports=r},{}],36:[function(t,e,n){var r=t("../utils/utils"),o=t("./errors"),i=function(t){this.name=t.name,this.call=t.call,this.params=t.params||0,this.inputFormatter=t.inputFormatter,this.outputFormatter=t.outputFormatter,this.requestManager=null};i.prototype.setRequestManager=function(t){this.requestManager=t},i.prototype.getCall=function(t){return r.isFunction(this.call)?this.call(t):this.call},i.prototype.extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},i.prototype.validateArgs=function(t){if(t.length!==this.params)throw o.InvalidNumberOfParams()},i.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter.map(function(e,n){return e?e(t[n]):t[n]}):t},i.prototype.formatOutput=function(t){return this.outputFormatter&&t?this.outputFormatter(t):t},i.prototype.toPayload=function(t){var e=this.getCall(t),n=this.extractCallback(t),r=this.formatInput(t);return this.validateArgs(r),{method:e,params:r,callback:n}},i.prototype.attachToObject=function(t){var e=this.buildCall();e.call=this.call;var n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},t[n[0]][n[1]]=e):t[n[0]]=e},i.prototype.buildCall=function(){var t=this,e=function(){var e=t.toPayload(Array.prototype.slice.call(arguments));return e.callback?t.requestManager.sendAsync(e,function(n,r){e.callback(n,t.formatOutput(r))}):t.formatOutput(t.requestManager.send(e))};return e.request=this.request.bind(this),e},i.prototype.request=function(){var t=this.toPayload(Array.prototype.slice.call(arguments));return t.format=this.formatOutput.bind(this),t},e.exports=i},{"../utils/utils":20,"./errors":26}],37:[function(t,e,n){var r=t("../method"),o=function(t){this._requestManager=t._requestManager;var e=this;i().forEach(function(n){n.attachToObject(e),n.setRequestManager(t._requestManager)})},i=function(){var t=new r({name:"putString",call:"db_putString",params:3}),e=new r({name:"getString",call:"db_getString",params:2}),n=new r({name:"putHex",call:"db_putHex",params:3}),o=new r({name:"getHex",call:"db_getHex",params:2});return[t,e,n,o]};e.exports=o},{"../method":36}],38:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;w().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),x().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),this.iban=d,this.sendIBANTransaction=m.bind(null,this)}var o=t("../formatters"),i=t("../../utils/utils"),a=t("../method"),s=t("../property"),c=t("../../utils/config"),u=t("../contract"),f=t("./watches"),p=t("../filter"),l=t("../syncing"),h=t("../namereg"),d=t("../iban"),m=t("../transfer"),y=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},v=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},g=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},b=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},_=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"};Object.defineProperty(r.prototype,"defaultBlock",{get:function(){return c.defaultBlock},set:function(t){return c.defaultBlock=t,t}}),Object.defineProperty(r.prototype,"defaultAccount",{get:function(){return c.defaultAccount},set:function(t){return c.defaultAccount=t,t}});var w=function(){var t=new a({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter],outputFormatter:o.outputBigNumberFormatter}),e=new a({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[null,i.toHex,o.inputDefaultBlockNumberFormatter]}),n=new a({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),r=new a({name:"getBlock",call:y,params:2,inputFormatter:[o.inputBlockNumberFormatter,function(t){return!!t}],outputFormatter:o.outputBlockFormatter}),s=new a({name:"getUncle",call:g,params:2,inputFormatter:[o.inputBlockNumberFormatter,i.toHex],outputFormatter:o.outputBlockFormatter}),c=new a({name:"getCompilers",call:"eth_getCompilers",params:0}),u=new a({name:"getBlockTransactionCount",call:b,params:1,inputFormatter:[o.inputBlockNumberFormatter],outputFormatter:i.toDecimal}),f=new a({name:"getBlockUncleCount",call:_,params:1,inputFormatter:[o.inputBlockNumberFormatter],outputFormatter:i.toDecimal}),p=new a({name:"getTransaction",call:"eth_getTransactionByHash",params:1,outputFormatter:o.outputTransactionFormatter}),l=new a({name:"getTransactionFromBlock",call:v,params:2,inputFormatter:[o.inputBlockNumberFormatter,i.toHex],outputFormatter:o.outputTransactionFormatter}),h=new a({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,outputFormatter:o.outputTransactionReceiptFormatter}),d=new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[null,o.inputDefaultBlockNumberFormatter],outputFormatter:i.toDecimal}),m=new a({name:"sendRawTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),w=new a({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[o.inputTransactionFormatter]}),x=new a({name:"sign",call:"eth_sign",params:2,inputFormatter:[o.inputAddressFormatter,null]}),k=new a({name:"call",call:"eth_call",params:2,inputFormatter:[o.inputCallFormatter,o.inputDefaultBlockNumberFormatter]}),B=new a({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[o.inputCallFormatter],outputFormatter:i.toDecimal}),S=new a({name:"compile.solidity",call:"eth_compileSolidity",params:1}),C=new a({name:"compile.lll",call:"eth_compileLLL",params:1}),A=new a({name:"compile.serpent",call:"eth_compileSerpent",params:1}),F=new a({name:"submitWork",call:"eth_submitWork",params:3}),I=new a({name:"getWork",call:"eth_getWork",params:0});return[t,e,n,r,s,c,u,f,p,l,h,d,k,B,m,w,x,S,C,A,F,I]},x=function(){return[new s({name:"coinbase",getter:"eth_coinbase"}),new s({name:"mining",getter:"eth_mining"}),new s({name:"hashrate",getter:"eth_hashrate",outputFormatter:i.toDecimal}),new s({name:"syncing",getter:"eth_syncing",outputFormatter:o.outputSyncingFormatter}),new s({name:"gasPrice",getter:"eth_gasPrice",outputFormatter:o.outputBigNumberFormatter}),new s({name:"accounts",getter:"eth_accounts"}),new s({name:"blockNumber",getter:"eth_blockNumber",outputFormatter:i.toDecimal}),new s({name:"protocolVersion",getter:"eth_protocolVersion"})]};r.prototype.contract=function(t){var e=new u(this,t);return e},r.prototype.filter=function(t,e){return new p(this._requestManager,t,f.eth(),o.outputLogFormatter,e)},r.prototype.namereg=function(){return this.contract(h.global.abi).at(h.global.address)},r.prototype.icapNamereg=function(){return this.contract(h.icap.abi).at(h.icap.address)},r.prototype.isSyncing=function(t){return new l(this._requestManager,t)},e.exports=r},{"../../utils/config":18,"../../utils/utils":20,"../contract":25,"../filter":29,"../formatters":30,"../iban":33,"../method":36,"../namereg":44,"../property":45,"../syncing":48,"../transfer":49,"./watches":43}],39:[function(t,e,n){var r=t("../../utils/utils"),o=t("../property"),i=function(t){this._requestManager=t._requestManager;var e=this;a().forEach(function(n){n.attachToObject(e),n.setRequestManager(t._requestManager)})},a=function(){return[new o({name:"listening",getter:"net_listening"}),new o({name:"peerCount",getter:"net_peerCount",outputFormatter:r.toDecimal})]};e.exports=i},{"../../utils/utils":20,"../property":45}],40:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),c().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})}var o=t("../method"),i=t("../property"),a=t("../formatters"),s=function(){var t=new o({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null]}),e=new o({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[a.inputAddressFormatter,null,null]}),n=new o({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[a.inputTransactionFormatter,null]}),r=new o({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[a.inputAddressFormatter]});return[t,e,n,r]},c=function(){return[new i({name:"listAccounts",getter:"personal_listAccounts"})]};e.exports=r},{"../formatters":30,"../method":36,"../property":45}],41:[function(t,e,n){var r=t("../method"),o=t("../formatters"),i=t("../filter"),a=t("./watches"),s=function(t){this._requestManager=t._requestManager;var e=this;c().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};s.prototype.filter=function(t,e){return new i(this._requestManager,t,a.shh(),o.outputPostFormatter,e)};var c=function(){var t=new r({name:"post",call:"shh_post",params:1,inputFormatter:[o.inputPostFormatter]}),e=new r({name:"newIdentity",call:"shh_newIdentity",params:0}),n=new r({name:"hasIdentity",call:"shh_hasIdentity",params:1}),i=new r({name:"newGroup",call:"shh_newGroup",params:0}),a=new r({name:"addToGroup",call:"shh_addToGroup",params:0});return[t,e,n,i,a]};e.exports=s},{"../filter":29,"../formatters":30,"../method":36,"./watches":43}],42:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;a().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})}var o=t("../method"),i=t("../property"),a=function(){var t=new o({name:"blockNetworkRead",call:"bzz_blockNetworkRead",params:1,inputFormatter:[null]}),e=new o({name:"syncEnabled",call:"bzz_syncEnabled",params:1,inputFormatter:[null]}),n=new o({name:"swapEnabled",call:"bzz_swapEnabled",params:1,inputFormatter:[null]}),r=new o({name:"download",call:"bzz_download",params:2,inputFormatter:[null,null]}),i=new o({name:"upload",call:"bzz_upload",params:2,inputFormatter:[null,null]}),a=new o({name:"retrieve",call:"bzz_retrieve",params:1,inputFormatter:[null]}),s=new o({name:"store",call:"bzz_store",params:2,inputFormatter:[null,null]}),c=new o({name:"get",call:"bzz_get",params:1,inputFormatter:[null]}),u=new o({name:"put",call:"bzz_put",params:2,inputFormatter:[null,null]}),f=new o({name:"modify",call:"bzz_modify",params:4,inputFormatter:[null,null,null,null]});return[t,e,n,r,i,a,s,c,u,f]},s=function(){return[new i({name:"hive",getter:"bzz_hive"}),new i({name:"info",getter:"bzz_info"})]};e.exports=r},{"../method":36,"../property":45}],43:[function(t,e,n){var r=t("../method"),o=function(){var t=function(t){var e=t[0];switch(e){case"latest":return t.shift(),this.params=0,"eth_newBlockFilter";case"pending":return t.shift(),this.params=0,"eth_newPendingTransactionFilter";default:return"eth_newFilter"}},e=new r({name:"newFilter",call:t,params:1}),n=new r({name:"uninstallFilter",call:"eth_uninstallFilter",params:1}),o=new r({name:"getLogs",call:"eth_getFilterLogs",params:1}),i=new r({name:"poll",call:"eth_getFilterChanges",params:1});return[e,n,o,i]},i=function(){var t=new r({name:"newFilter",call:"shh_newFilter",params:1}),e=new r({name:"uninstallFilter",call:"shh_uninstallFilter",params:1}),n=new r({name:"getLogs",call:"shh_getMessages",params:1}),o=new r({name:"poll",call:"shh_getFilterChanges",params:1});return[t,e,n,o]};e.exports={eth:o,shh:i}},{"../method":36}],44:[function(t,e,n){var r=t("../contracts/GlobalRegistrar.json"),o=t("../contracts/ICAPRegistrar.json"),i="0xc6d9d2cd449a754c494264e1809c50e34d64562b",a="0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00";e.exports={global:{abi:r,address:i},icap:{abi:o,address:a}}},{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],45:[function(t,e,n){var r=t("../utils/utils"),o=function(t){this.name=t.name,this.getter=t.getter,this.setter=t.setter,this.outputFormatter=t.outputFormatter,this.inputFormatter=t.inputFormatter,this.requestManager=null};o.prototype.setRequestManager=function(t){this.requestManager=t},o.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter(t):t},o.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t&&void 0!==t?this.outputFormatter(t):t},o.prototype.extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},o.prototype.attachToObject=function(t){var e={get:this.buildGet(),enumerable:!0},n=this.name.split("."),r=n[0];n.length>1&&(t[n[0]]=t[n[0]]||{},t=t[n[0]],r=n[1]),Object.defineProperty(t,r,e),t[i(r)]=this.buildAsyncGet()};var i=function(t){return"get"+t.charAt(0).toUpperCase()+t.slice(1)};o.prototype.buildGet=function(){var t=this;return function(){return t.formatOutput(t.requestManager.send({method:t.getter}))}},o.prototype.buildAsyncGet=function(){var t=this,e=function(e){t.requestManager.sendAsync({method:t.getter},function(n,r){e(n,t.formatOutput(r))})};return e.request=this.request.bind(this),e},o.prototype.request=function(){var t={method:this.getter,params:[],callback:this.extractCallback(Array.prototype.slice.call(arguments))};return t.format=this.formatOutput.bind(this),t},e.exports=o},{"../utils/utils":20}],46:[function(t,e,n){var r=t("./jsonrpc"),o=t("../utils/utils"),i=t("../utils/config"),a=t("./errors"),s=function(t){this.provider=t,this.polls={},this.timeout=null};s.prototype.send=function(t){if(!this.provider)return console.error(a.InvalidProvider()),null;var e=r.toPayload(t.method,t.params),n=this.provider.send(e);if(!r.isValidResponse(n))throw a.InvalidResponse(n);return n.result},s.prototype.sendAsync=function(t,e){if(!this.provider)return e(a.InvalidProvider());var n=r.toPayload(t.method,t.params);this.provider.sendAsync(n,function(t,n){return t?e(t):r.isValidResponse(n)?void e(null,n.result):e(a.InvalidResponse(n))})},s.prototype.sendBatch=function(t,e){if(!this.provider)return e(a.InvalidProvider());var n=r.toBatchPayload(t);this.provider.sendAsync(n,function(t,n){return t?e(t):o.isArray(n)?void e(t,n):e(a.InvalidResponse(n))})},s.prototype.setProvider=function(t){this.provider=t},s.prototype.startPolling=function(t,e,n,r){this.polls[e]={data:t,id:e,callback:n,uninstall:r},this.timeout||this.poll()},s.prototype.stopPolling=function(t){delete this.polls[t],0===Object.keys(this.polls).length&&this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},s.prototype.reset=function(t){for(var e in this.polls)t&&e.indexOf("syncPoll_")!==-1||(this.polls[e].uninstall(),delete this.polls[e]);0===Object.keys(this.polls).length&&this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},s.prototype.poll=function(){if(this.timeout=setTimeout(this.poll.bind(this),i.ETH_POLLING_TIMEOUT),0!==Object.keys(this.polls).length){if(!this.provider)return void console.error(a.InvalidProvider());var t=[],e=[];for(var n in this.polls)t.push(this.polls[n].data),e.push(n);if(0!==t.length){var s=r.toBatchPayload(t),c={};s.forEach(function(t,n){c[t.id]=e[n]});var u=this;this.provider.sendAsync(s,function(t,e){if(!t){if(!o.isArray(e))throw a.InvalidResponse(e);e.map(function(t){var e=c[t.id];return!!u.polls[e]&&(t.callback=u.polls[e].callback,t)}).filter(function(t){return!!t}).filter(function(t){var e=r.isValidResponse(t);return e||t.callback(a.InvalidResponse(t)),e}).forEach(function(t){t.callback(null,t.result)})}})}}},e.exports=s},{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],47:[function(t,e,n){var r=function(){this.defaultBlock="latest",this.defaultAccount=void 0};e.exports=r},{}],48:[function(t,e,n){var r=t("./formatters"),o=t("../utils/utils"),i=1,a=function(t){var e=function(e,n){return e?t.callbacks.forEach(function(t){t(e)}):(o.isObject(n)&&n.startingBlock&&(n=r.outputSyncingFormatter(n)),void t.callbacks.forEach(function(e){t.lastSyncState!==n&&(!t.lastSyncState&&o.isObject(n)&&e(null,!0),setTimeout(function(){e(null,n)},0),t.lastSyncState=n)}))};t.requestManager.startPolling({method:"eth_syncing",params:[]},t.pollId,e,t.stopWatching.bind(t))},s=function(t,e){return this.requestManager=t,this.pollId="syncPoll_"+i++,this.callbacks=[],this.addCallback(e),this.lastSyncState=!1,a(this),this};s.prototype.addCallback=function(t){return t&&this.callbacks.push(t),this},s.prototype.stopWatching=function(){this.requestManager.stopPolling(this.pollId),this.callbacks=[]},e.exports=s},{"../utils/utils":20,"./formatters":30}],49:[function(t,e,n){var r=t("./iban"),o=t("../contracts/SmartExchange.json"),i=function(t,e,n,o,i){var c=new r(n);if(!c.isValid())throw new Error("invalid iban address");if(c.isDirect())return a(t,e,c.address(),o,i);if(!i){var u=t.icapNamereg().addr(c.institution());return s(t,e,u,o,c.client())}t.icapNamereg().addr(c.institution(),function(n,r){return s(t,e,r,o,c.client(),i)})},a=function(t,e,n,r,o){return t.sendTransaction({address:n,from:e,value:r},o)},s=function(t,e,n,r,i,a){var s=o;return t.contract(s).at(n).deposit(i,{from:e,value:r},a)};e.exports=i},{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(t,e,n){},{}],51:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.BlockCipher,o=e.algo,i=[],a=[],s=[],c=[],u=[],f=[],p=[],l=[],h=[],d=[];!function(){for(var t=[],e=0;e<256;e++)e<128?t[e]=e<<1:t[e]=e<<1^283;for(var n=0,r=0,e=0;e<256;e++){var o=r^r<<1^r<<2^r<<3^r<<4;o=o>>>8^255&o^99,i[n]=o,a[o]=n;var m=t[n],y=t[m],v=t[y],g=257*t[o]^16843008*o;s[n]=g<<24|g>>>8,c[n]=g<<16|g>>>16,u[n]=g<<8|g>>>24,f[n]=g;var g=16843009*v^65537*y^257*m^16843008*n;p[o]=g<<24|g>>>8,l[o]=g<<16|g>>>16,h[o]=g<<8|g>>>24,d[o]=g,n?(n=m^t[t[t[v^m]]],r^=t[t[r]]):n=r=1}}();var m=[0,1,2,4,8,16,32,64,128,27,54],y=o.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,n=t.sigBytes/4,r=this._nRounds=n+6,o=4*(r+1),a=this._keySchedule=[],s=0;s6&&s%n==4&&(c=i[c>>>24]<<24|i[c>>>16&255]<<16|i[c>>>8&255]<<8|i[255&c]):(c=c<<8|c>>>24,c=i[c>>>24]<<24|i[c>>>16&255]<<16|i[c>>>8&255]<<8|i[255&c],c^=m[s/n|0]<<24),a[s]=a[s-n]^c}for(var u=this._invKeySchedule=[],f=0;f>>24]]^l[i[c>>>16&255]]^h[i[c>>>8&255]]^d[i[255&c]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,c,u,f,i)},decryptBlock:function(t,e){var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n,this._doCryptBlock(t,e,this._invKeySchedule,p,l,h,d,a);var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n},_doCryptBlock:function(t,e,n,r,o,i,a,s){for(var c=this._nRounds,u=t[e]^n[0],f=t[e+1]^n[1],p=t[e+2]^n[2],l=t[e+3]^n[3],h=4,d=1;d>>24]^o[f>>>16&255]^i[p>>>8&255]^a[255&l]^n[h++],y=r[f>>>24]^o[p>>>16&255]^i[l>>>8&255]^a[255&u]^n[h++],v=r[p>>>24]^o[l>>>16&255]^i[u>>>8&255]^a[255&f]^n[h++],g=r[l>>>24]^o[u>>>16&255]^i[f>>>8&255]^a[255&p]^n[h++];u=m,f=y,p=v,l=g}var m=(s[u>>>24]<<24|s[f>>>16&255]<<16|s[p>>>8&255]<<8|s[255&l])^n[h++],y=(s[f>>>24]<<24|s[p>>>16&255]<<16|s[l>>>8&255]<<8|s[255&u])^n[h++],v=(s[p>>>24]<<24|s[l>>>16&255]<<16|s[u>>>8&255]<<8|s[255&f])^n[h++],g=(s[l>>>24]<<24|s[u>>>16&255]<<16|s[f>>>8&255]<<8|s[255&p])^n[h++];t[e]=m,t[e+1]=y,t[e+2]=v,t[e+3]=g},keySize:8});e.AES=r._createHelper(y)}(),t.AES})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){t.lib.Cipher||function(e){var n=t,r=n.lib,o=r.Base,i=r.WordArray,a=r.BufferedBlockAlgorithm,s=n.enc,c=(s.Utf8,s.Base64),u=n.algo,f=u.EvpKDF,p=r.Cipher=a.extend({cfg:o.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,n){this.cfg=this.cfg.extend(n),this._xformMode=t,this._key=e,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){t&&this._append(t);var e=this._doFinalize();return e},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?k:_}return function(e){return{encrypt:function(n,r,o){return t(r).encrypt(e,n,r,o)},decrypt:function(n,r,o){return t(r).decrypt(e,n,r,o)}}}}()}),l=(r.StreamCipher=p.extend({_doFinalize:function(){var t=this._process(!0);return t},blockSize:1}),n.mode={}),h=r.BlockCipherMode=o.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=l.CBC=function(){function t(t,n,r){var o=this._iv;if(o){var i=o;this._iv=e}else var i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},v=(r.BlockCipher=p.extend({cfg:p.cfg.extend({mode:d,padding:y}),reset:function(){p.reset.call(this);var t=this.cfg,e=t.iv,n=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=n.createEncryptor;else{var r=n.createDecryptor;this._minBufferSize=1}this._mode=r.call(n,this,e&&e.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{var e=this._process(!0);t.unpad(e)}return e},blockSize:4}),r.CipherParams=o.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),g=n.format={},b=g.OpenSSL={stringify:function(t){var e=t.ciphertext,n=t.salt;if(n)var r=i.create([1398893684,1701076831]).concat(n).concat(e);else var r=e;return r.toString(c)},parse:function(t){var e=c.parse(t),n=e.words;if(1398893684==n[0]&&1701076831==n[1]){var r=i.create(n.slice(2,4));n.splice(0,4),e.sigBytes-=16}return v.create({ciphertext:e,salt:r})}},_=r.SerializableCipher=o.extend({cfg:o.extend({format:b}),encrypt:function(t,e,n,r){r=this.cfg.extend(r);var o=t.createEncryptor(n,r),i=o.finalize(e),a=o.cfg;return v.create({ciphertext:i,key:n,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:r.format})},decrypt:function(t,e,n,r){r=this.cfg.extend(r),e=this._parse(e,r.format);var o=t.createDecryptor(n,r).finalize(e.ciphertext);return o},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),w=n.kdf={},x=w.OpenSSL={execute:function(t,e,n,r){r||(r=i.random(8));var o=f.create({keySize:e+n}).compute(t,r),a=i.create(o.words.slice(e),4*n);return o.sigBytes=4*e,v.create({key:o,iv:a,salt:r})}},k=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:x}),encrypt:function(t,e,n,r){r=this.cfg.extend(r);var o=r.kdf.execute(n,t.keySize,t.ivSize);r.iv=o.iv;var i=_.encrypt.call(this,t,e,o.key,r);return i.mixIn(o),i},decrypt:function(t,e,n,r){r=this.cfg.extend(r),e=this._parse(e,r.format);var o=r.kdf.execute(n,t.keySize,t.ivSize,e.salt);r.iv=o.iv;var i=_.decrypt.call(this,t,e,o.key,r);return i}})}()})},{"./core":53}],53:[function(t,e,n){!function(t,r){"object"==typeof n?e.exports=n=r():"function"==typeof define&&define.amd?define([],r):t.CryptoJS=r()}(this,function(){var t=t||function(t,e){var n=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),r={},o=r.lib={},i=o.Base=function(){return{extend:function(t){var e=n(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=o.WordArray=i.extend({init:function(t,n){t=this.words=t||[],n!=e?this.sigBytes=n:this.sigBytes=4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i>>2]>>>24-i%4*8&255;e[r+i>>>2]|=a<<24-(r+i)%4*8}else for(var i=0;i>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n,r=[],o=function(e){var e=e,n=987654321,r=4294967295;return function(){n=36969*(65535&n)+(n>>16)&r,e=18e3*(65535&e)+(e>>16)&r;var o=(n<<16)+e&r;return o/=4294967296,o+=.5,o*(t.random()>.5?1:-1)}},i=0;i>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(n,e/2)}},u=s.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(n,e)}},f=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},p=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=4*i,c=o/s;c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0);var u=c*i,f=t.min(4*u,o);if(u){for(var p=0;p>>6-a%4*2;r[i>>>2]|=(s|c)<<24-i%4*8,i++}return o.create(r,i)}var n=t,r=n.lib,o=r.WordArray,i=n.enc;i.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var o=[],i=0;i>>2]>>>24-i%4*8&255,s=e[i+1>>>2]>>>24-(i+1)%4*8&255,c=e[i+2>>>2]>>>24-(i+2)%4*8&255,u=a<<16|s<<8|c,f=0;f<4&&i+.75*f>>6*(3-f)&63));var p=r.charAt(64);if(p)for(;o.length%4;)o.push(p);return o.join("")},parse:function(t){var n=t.length,r=this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var i=0;i>>8&16711935}var n=t,r=n.lib,o=r.WordArray,i=n.enc;i.Utf16=i.Utf16BE={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o>>2]>>>16-o%4*8&65535;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>1]|=t.charCodeAt(r)<<16-r%2*16;return o.create(n,2*e)}};i.Utf16LE={stringify:function(t){for(var n=t.words,r=t.sigBytes,o=[],i=0;i>>2]>>>16-i%4*8&65535);o.push(String.fromCharCode(a))}return o.join("")},parse:function(t){for(var n=t.length,r=[],i=0;i>>1]|=e(t.charCodeAt(i)<<16-i%2*16);return o.create(r,2*n)}}}(),t.enc.Utf16})},{"./core":53}],56:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./sha1"),t("./hmac")):"function"==typeof define&&define.amd?define(["./core","./sha1","./hmac"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.Base,o=n.WordArray,i=e.algo,a=i.MD5,s=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:a,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var n=this.cfg,r=n.hasher.create(),i=o.create(),a=i.words,s=n.keySize,c=n.iterations;a.lengthr&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),a=this._iKey=e.clone(),s=o.words,c=a.words,u=0;u>>2]|=t[r]<<24-r%4*8;o.call(this,n,e)}else o.apply(this,arguments)};i.prototype=r}}(),t.lib.WordArray})},{"./core":53}],61:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(e){function n(t,e,n,r,o,i,a){var s=t+(e&n|~e&r)+o+a;return(s<>>32-i)+e}function r(t,e,n,r,o,i,a){var s=t+(e&r|n&~r)+o+a;return(s<>>32-i)+e}function o(t,e,n,r,o,i,a){var s=t+(e^n^r)+o+a;return(s<>>32-i)+e}function i(t,e,n,r,o,i,a){var s=t+(n^(e|~r))+o+a;return(s<>>32-i)+e}var a=t,s=a.lib,c=s.WordArray,u=s.Hasher,f=a.algo,p=[];!function(){for(var t=0;t<64;t++)p[t]=4294967296*e.abs(e.sin(t+1))|0}();var l=f.MD5=u.extend({_doReset:function(){this._hash=new c.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var a=0;a<16;a++){var s=e+a,c=t[s];t[s]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}var u=this._hash.words,f=t[e+0],l=t[e+1],h=t[e+2],d=t[e+3],m=t[e+4],y=t[e+5],v=t[e+6],g=t[e+7],b=t[e+8],_=t[e+9],w=t[e+10],x=t[e+11],k=t[e+12],B=t[e+13],S=t[e+14],C=t[e+15],A=u[0],F=u[1],I=u[2],T=u[3];A=n(A,F,I,T,f,7,p[0]),T=n(T,A,F,I,l,12,p[1]),I=n(I,T,A,F,h,17,p[2]),F=n(F,I,T,A,d,22,p[3]),A=n(A,F,I,T,m,7,p[4]),T=n(T,A,F,I,y,12,p[5]),I=n(I,T,A,F,v,17,p[6]),F=n(F,I,T,A,g,22,p[7]),A=n(A,F,I,T,b,7,p[8]),T=n(T,A,F,I,_,12,p[9]),I=n(I,T,A,F,w,17,p[10]),F=n(F,I,T,A,x,22,p[11]),A=n(A,F,I,T,k,7,p[12]),T=n(T,A,F,I,B,12,p[13]),I=n(I,T,A,F,S,17,p[14]),F=n(F,I,T,A,C,22,p[15]),A=r(A,F,I,T,l,5,p[16]),T=r(T,A,F,I,v,9,p[17]),I=r(I,T,A,F,x,14,p[18]),F=r(F,I,T,A,f,20,p[19]),A=r(A,F,I,T,y,5,p[20]),T=r(T,A,F,I,w,9,p[21]),I=r(I,T,A,F,C,14,p[22]),F=r(F,I,T,A,m,20,p[23]),A=r(A,F,I,T,_,5,p[24]),T=r(T,A,F,I,S,9,p[25]),I=r(I,T,A,F,d,14,p[26]),F=r(F,I,T,A,b,20,p[27]),A=r(A,F,I,T,B,5,p[28]),T=r(T,A,F,I,h,9,p[29]),I=r(I,T,A,F,g,14,p[30]),F=r(F,I,T,A,k,20,p[31]),A=o(A,F,I,T,y,4,p[32]),T=o(T,A,F,I,b,11,p[33]),I=o(I,T,A,F,x,16,p[34]),F=o(F,I,T,A,S,23,p[35]),A=o(A,F,I,T,l,4,p[36]),T=o(T,A,F,I,m,11,p[37]),I=o(I,T,A,F,g,16,p[38]),F=o(F,I,T,A,w,23,p[39]),A=o(A,F,I,T,B,4,p[40]),T=o(T,A,F,I,f,11,p[41]),I=o(I,T,A,F,d,16,p[42]),F=o(F,I,T,A,v,23,p[43]),A=o(A,F,I,T,_,4,p[44]),T=o(T,A,F,I,k,11,p[45]),I=o(I,T,A,F,C,16,p[46]),F=o(F,I,T,A,h,23,p[47]),A=i(A,F,I,T,f,6,p[48]),T=i(T,A,F,I,g,10,p[49]),I=i(I,T,A,F,S,15,p[50]),F=i(F,I,T,A,y,21,p[51]),A=i(A,F,I,T,k,6,p[52]),T=i(T,A,F,I,d,10,p[53]),I=i(I,T,A,F,w,15,p[54]),F=i(F,I,T,A,l,21,p[55]),A=i(A,F,I,T,b,6,p[56]),T=i(T,A,F,I,C,10,p[57]),I=i(I,T,A,F,v,15,p[58]),F=i(F,I,T,A,B,21,p[59]),A=i(A,F,I,T,m,6,p[60]),T=i(T,A,F,I,x,10,p[61]),I=i(I,T,A,F,h,15,p[62]),F=i(F,I,T,A,_,21,p[63]),u[0]=u[0]+A|0,u[1]=u[1]+F|0,u[2]=u[2]+I|0,u[3]=u[3]+T|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296),a=r;n[(o+64>>>9<<4)+15]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[(o+64>>>9<<4)+14]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(n.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var f=c[u];c[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return s},clone:function(){var t=u.clone.call(this);return t._hash=this._hash.clone(),t}});a.MD5=u._createHelper(l),a.HmacMD5=u._createHmacHelper(l)}(Math),t.MD5})},{"./core":53}],62:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.mode.CFB=function(){function e(t,e,n,r){var o=this._iv;if(o){var i=o.slice(0);this._iv=void 0}else var i=this._prevBlock;r.encryptBlock(i,0);for(var a=0;a>24&255)){var e=t>>16&255,n=t>>8&255,r=255&t;255===e?(e=0,255===n?(n=0,255===r?r=0:++r):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=r}else t+=1<<24;return t}function n(t){return 0===(t[0]=e(t[0]))&&(t[1]=e(t[1])),t}var r=t.lib.BlockCipherMode.extend(),o=r.Encryptor=r.extend({processBlock:function(t,e){var r=this._cipher,o=r.blockSize,i=this._iv,a=this._counter;i&&(a=this._counter=i.slice(0),this._iv=void 0),n(a);var s=a.slice(0);r.encryptBlock(s,0);for(var c=0;c>>2]|=o<<24-i%4*8,t.sigBytes+=o},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923})},{"./cipher-core":52,"./core":53}],68:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.pad.Iso10126={pad:function(e,n){var r=4*n,o=r-e.sigBytes%r;e.concat(t.lib.WordArray.random(o-1)).concat(t.lib.WordArray.create([o<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126})},{"./cipher-core":52,"./core":53}],69:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.pad.Iso97971={pad:function(e,n){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,n)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971})},{"./cipher-core":52,"./core":53}],70:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding})},{"./cipher-core":52,"./core":53}],71:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.pad.ZeroPadding={pad:function(t,e){var n=4*e;t.clamp(),t.sigBytes+=n-(t.sigBytes%n||n)},unpad:function(t){for(var e=t.words,n=t.sigBytes-1;!(e[n>>>2]>>>24-n%4*8&255);)n--;t.sigBytes=n+1}},t.pad.ZeroPadding})},{"./cipher-core":52,"./core":53}],72:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./sha1"),t("./hmac")):"function"==typeof define&&define.amd?define(["./core","./sha1","./hmac"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.Base,o=n.WordArray,i=e.algo,a=i.SHA1,s=i.HMAC,c=i.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:a,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var n=this.cfg,r=s.create(n.hasher,t),i=o.create(),a=o.create([1]),c=i.words,u=a.words,f=n.keySize,p=n.iterations;c.length>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(var n=0;n<8;n++){var r=t[n]+e[n],o=65535&r,i=r>>>16,a=((o*o>>>17)+o*i>>>15)+i*i,u=((4294901760&r)*r|0)+((65535&r)*r|0);c[n]=a^u}t[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,t[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,t[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,t[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,t[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,t[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,t[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,t[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}var n=t,r=n.lib,o=r.StreamCipher,i=n.algo,a=[],s=[],c=[],u=i.RabbitLegacy=o.extend({_doReset:function(){var t=this._key.words,n=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],o=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)e.call(this);for(var i=0;i<8;i++)o[i]^=r[i+4&7];if(n){var a=n.words,s=a[0],c=a[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),p=u>>>16|4294901760&f,l=f<<16|65535&u;o[0]^=u,o[1]^=p,o[2]^=f,o[3]^=l,o[4]^=u,o[5]^=p,o[6]^=f,o[7]^=l;for(var i=0;i<4;i++)e.call(this)}},_doProcessBlock:function(t,n){var r=this._X;e.call(this),a[0]=r[0]^r[5]>>>16^r[3]<<16,a[1]=r[2]^r[7]>>>16^r[5]<<16,a[2]=r[4]^r[1]>>>16^r[7]<<16,a[3]=r[6]^r[3]>>>16^r[1]<<16;for(var o=0;o<4;o++)a[o]=16711935&(a[o]<<8|a[o]>>>24)|4278255360&(a[o]<<24|a[o]>>>8),t[n+o]^=a[o]},blockSize:4,ivSize:2});n.RabbitLegacy=o._createHelper(u)}(),t.RabbitLegacy})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return function(){function e(){for(var t=this._X,e=this._C,n=0;n<8;n++)s[n]=e[n];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(var n=0;n<8;n++){var r=t[n]+e[n],o=65535&r,i=r>>>16,a=((o*o>>>17)+o*i>>>15)+i*i,u=((4294901760&r)*r|0)+((65535&r)*r|0);c[n]=a^u}t[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,t[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,t[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,t[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,t[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,t[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,t[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,t[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}var n=t,r=n.lib,o=r.StreamCipher,i=n.algo,a=[],s=[],c=[],u=i.Rabbit=o.extend({_doReset:function(){for(var t=this._key.words,n=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var o=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var r=0;r<4;r++)e.call(this);for(var r=0;r<8;r++)i[r]^=o[r+4&7];if(n){var a=n.words,s=a[0],c=a[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),p=u>>>16|4294901760&f,l=f<<16|65535&u;i[0]^=u,i[1]^=p,i[2]^=f,i[3]^=l,i[4]^=u,i[5]^=p,i[6]^=f,i[7]^=l;for(var r=0;r<4;r++)e.call(this)}},_doProcessBlock:function(t,n){var r=this._X;e.call(this),a[0]=r[0]^r[5]>>>16^r[3]<<16,a[1]=r[2]^r[7]>>>16^r[5]<<16,a[2]=r[4]^r[1]>>>16^r[7]<<16,a[3]=r[6]^r[3]>>>16^r[1]<<16;for(var o=0;o<4;o++)a[o]=16711935&(a[o]<<8|a[o]>>>24)|4278255360&(a[o]<<24|a[o]>>>8),t[n+o]^=a[o]},blockSize:4,ivSize:2});n.Rabbit=o._createHelper(u)}(),t.Rabbit})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return function(){function e(){for(var t=this._S,e=this._i,n=this._j,r=0,o=0;o<4;o++){e=(e+1)%256,n=(n+t[e])%256;var i=t[e];t[e]=t[n],t[n]=i,r|=t[(t[e]+t[n])%256]<<24-8*o}return this._i=e,this._j=n,r}var n=t,r=n.lib,o=r.StreamCipher,i=n.algo,a=i.RC4=o.extend({_doReset:function(){for(var t=this._key,e=t.words,n=t.sigBytes,r=this._S=[],o=0;o<256;o++)r[o]=o;for(var o=0,i=0;o<256;o++){var a=o%n,s=e[a>>>2]>>>24-a%4*8&255;i=(i+r[o]+s)%256;var c=r[o];r[o]=r[i],r[i]=c}this._i=this._j=0},_doProcessBlock:function(t,n){t[n]^=e.call(this)},keySize:8,ivSize:0});n.RC4=o._createHelper(a);var s=i.RC4Drop=a.extend({cfg:a.cfg.extend({drop:192}),_doReset:function(){a._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)e.call(this)}});n.RC4Drop=o._createHelper(s)}(),t.RC4})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(e){function n(t,e,n){return t^e^n}function r(t,e,n){return t&e|~t&n}function o(t,e,n){return(t|~e)^n}function i(t,e,n){return t&n|e&~n}function a(t,e,n){return t^(e|~n)}function s(t,e){return t<>>32-e}var c=t,u=c.lib,f=u.WordArray,p=u.Hasher,l=c.algo,h=f.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),d=f.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),m=f.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),y=f.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),v=f.create([0,1518500249,1859775393,2400959708,2840853838]),g=f.create([1352829926,1548603684,1836072691,2053994217,0]),b=l.RIPEMD160=p.extend({ +_doReset:function(){this._hash=f.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var c=0;c<16;c++){var u=e+c,f=t[u];t[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}var p,l,b,_,w,x,k,B,S,C,A=this._hash.words,F=v.words,I=g.words,T=h.words,D=d.words,P=m.words,O=y.words;x=p=A[0],k=l=A[1],B=b=A[2],S=_=A[3],C=w=A[4];for(var E,c=0;c<80;c+=1)E=p+t[e+T[c]]|0,E+=c<16?n(l,b,_)+F[0]:c<32?r(l,b,_)+F[1]:c<48?o(l,b,_)+F[2]:c<64?i(l,b,_)+F[3]:a(l,b,_)+F[4],E=0|E,E=s(E,P[c]),E=E+w|0,p=w,w=_,_=s(b,10),b=l,l=E,E=x+t[e+D[c]]|0,E+=c<16?a(k,B,S)+I[0]:c<32?i(k,B,S)+I[1]:c<48?o(k,B,S)+I[2]:c<64?r(k,B,S)+I[3]:n(k,B,S)+I[4],E=0|E,E=s(E,O[c]),E=E+C|0,x=C,C=S,S=s(B,10),B=k,k=E;E=A[1]+b+S|0,A[1]=A[2]+_+C|0,A[2]=A[3]+w+x|0,A[3]=A[4]+p+k|0,A[4]=A[0]+l+B|0,A[0]=E},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;e[r>>>5]|=128<<24-r%32,e[(r+64>>>9<<4)+14]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(e.length+1),this._process();for(var o=this._hash,i=o.words,a=0;a<5;a++){var s=i[a];i[a]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return o},clone:function(){var t=p.clone.call(this);return t._hash=this._hash.clone(),t}});c.RIPEMD160=p._createHelper(b),c.HmacRIPEMD160=p._createHmacHelper(b)}(Math),t.RIPEMD160})},{"./core":53}],77:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.WordArray,o=n.Hasher,i=e.algo,a=[],s=i.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],c=n[4],u=0;u<80;u++){if(u<16)a[u]=0|t[e+u];else{var f=a[u-3]^a[u-8]^a[u-14]^a[u-16];a[u]=f<<1|f>>>31}var p=(r<<5|r>>>27)+c+a[u];p+=u<20?(o&i|~o&s)+1518500249:u<40?(o^i^s)+1859775393:u<60?(o&i|o&s|i&s)-1894007588:(o^i^s)-899497514,c=s,s=i,i=o<<30|o>>>2,o=r,r=p}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+c|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[(r+64>>>9<<4)+14]=Math.floor(n/4294967296),e[(r+64>>>9<<4)+15]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA1=o._createHelper(s),e.HmacSHA1=o._createHmacHelper(s)}(),t.SHA1})},{"./core":53}],78:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./sha256")):"function"==typeof define&&define.amd?define(["./core","./sha256"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.WordArray,o=e.algo,i=o.SHA256,a=o.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});e.SHA224=i._createHelper(a),e.HmacSHA224=i._createHmacHelper(a)}(),t.SHA224})},{"./core":53,"./sha256":79}],79:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,o=r.WordArray,i=r.Hasher,a=n.algo,s=[],c=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)t(r)&&(o<8&&(s[o]=n(e.pow(r,.5))),c[o]=n(e.pow(r,1/3)),o++),r++}();var u=[],f=a.SHA256=i.extend({_doReset:function(){this._hash=new o.init(s.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],a=n[3],s=n[4],f=n[5],p=n[6],l=n[7],h=0;h<64;h++){if(h<16)u[h]=0|t[e+h];else{var d=u[h-15],m=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=u[h-2],v=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[h]=m+u[h-7]+v+u[h-16]}var g=s&f^~s&p,b=r&o^r&i^o&i,_=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),w=(s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25),x=l+w+g+c[h]+u[h],k=_+b;l=p,p=f,f=s,s=a+x|0,a=i,i=o,o=r,r=x+k|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+a|0,n[4]=n[4]+s|0,n[5]=n[5]+f|0,n[6]=n[6]+p|0,n[7]=n[7]+l|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[(o+64>>>9<<4)+14]=e.floor(r/4294967296),n[(o+64>>>9<<4)+15]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});n.SHA256=i._createHelper(f),n.HmacSHA256=i._createHmacHelper(f)}(Math),t.SHA256})},{"./core":53}],80:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],o):o(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,o=r.WordArray,i=r.Hasher,a=n.x64,s=a.Word,c=n.algo,u=[],f=[],p=[];!function(){for(var t=1,e=0,n=0;n<24;n++){u[t+5*e]=(n+1)*(n+2)/2%64;var r=e%5,o=(2*t+3*e)%5;t=r,e=o}for(var t=0;t<5;t++)for(var e=0;e<5;e++)f[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,a=0;a<24;a++){for(var c=0,l=0,h=0;h<7;h++){if(1&i){var d=(1<>>24)|4278255360&(i<<24|i>>>8),a=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8);var s=n[o];s.high^=a,s.low^=i}for(var c=0;c<24;c++){for(var h=0;h<5;h++){for(var d=0,m=0,y=0;y<5;y++){var s=n[h+5*y];d^=s.high,m^=s.low}var v=l[h];v.high=d,v.low=m}for(var h=0;h<5;h++)for(var g=l[(h+4)%5],b=l[(h+1)%5],_=b.high,w=b.low,d=g.high^(_<<1|w>>>31),m=g.low^(w<<1|_>>>31),y=0;y<5;y++){var s=n[h+5*y];s.high^=d,s.low^=m}for(var x=1;x<25;x++){var s=n[x],k=s.high,B=s.low,S=u[x];if(S<32)var d=k<>>32-S,m=B<>>32-S;else var d=B<>>64-S,m=k<>>64-S;var C=l[f[x]];C.high=d,C.low=m}var A=l[0],F=n[0];A.high=F.high,A.low=F.low;for(var h=0;h<5;h++)for(var y=0;y<5;y++){var x=h+5*y,s=n[x],I=l[x],T=l[(h+1)%5+5*y],D=l[(h+2)%5+5*y];s.high=I.high^~T.high&D.high,s.low=I.low^~T.low&D.low}var s=n[0],P=p[c];s.high^=P.high,s.low^=P.low}},_doFinalize:function(){var t=this._data,n=t.words,r=(8*this._nDataBytes,8*t.sigBytes),i=32*this.blockSize;n[r>>>5]|=1<<24-r%32,n[(e.ceil((r+1)/i)*i>>>5)-1]|=128,t.sigBytes=4*n.length,this._process();for(var a=this._state,s=this.cfg.outputLength/8,c=s/8,u=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),u.push(h),u.push(l)}return new o.init(u,s)},clone:function(){for(var t=i.clone.call(this),e=t._state=this._state.slice(0),n=0;n<25;n++)e[n]=e[n].clone();return t}});n.SHA3=i._createHelper(h),n.HmacSHA3=i._createHmacHelper(h)}(Math),t.SHA3})},{"./core":53,"./x64-core":84}],81:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./x64-core"),t("./sha512")):"function"==typeof define&&define.amd?define(["./core","./x64-core","./sha512"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.x64,r=n.Word,o=n.WordArray,i=e.algo,a=i.SHA512,s=i.SHA384=a.extend({_doReset:function(){this._hash=new o.init([new r.init(3418070365,3238371032),new r.init(1654270250,914150663),new r.init(2438529370,812702999),new r.init(355462360,4144912697),new r.init(1731405415,4290775857),new r.init(2394180231,1750603025),new r.init(3675008525,1694076839),new r.init(1203062813,3204075428)])},_doFinalize:function(){var t=a._doFinalize.call(this);return t.sigBytes-=16,t}});e.SHA384=a._createHelper(s),e.HmacSHA384=a._createHmacHelper(s)}(),t.SHA384})},{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],o):o(r.CryptoJS)}(this,function(t){return function(){function e(){return a.create.apply(a,arguments)}var n=t,r=n.lib,o=r.Hasher,i=n.x64,a=i.Word,s=i.WordArray,c=n.algo,u=[e(1116352408,3609767458),e(1899447441,602891725),e(3049323471,3964484399),e(3921009573,2173295548),e(961987163,4081628472),e(1508970993,3053834265),e(2453635748,2937671579),e(2870763221,3664609560),e(3624381080,2734883394),e(310598401,1164996542),e(607225278,1323610764),e(1426881987,3590304994),e(1925078388,4068182383),e(2162078206,991336113),e(2614888103,633803317),e(3248222580,3479774868),e(3835390401,2666613458),e(4022224774,944711139),e(264347078,2341262773),e(604807628,2007800933),e(770255983,1495990901),e(1249150122,1856431235),e(1555081692,3175218132),e(1996064986,2198950837),e(2554220882,3999719339),e(2821834349,766784016),e(2952996808,2566594879),e(3210313671,3203337956),e(3336571891,1034457026),e(3584528711,2466948901),e(113926993,3758326383),e(338241895,168717936),e(666307205,1188179964),e(773529912,1546045734),e(1294757372,1522805485),e(1396182291,2643833823),e(1695183700,2343527390),e(1986661051,1014477480),e(2177026350,1206759142),e(2456956037,344077627),e(2730485921,1290863460),e(2820302411,3158454273),e(3259730800,3505952657),e(3345764771,106217008),e(3516065817,3606008344),e(3600352804,1432725776),e(4094571909,1467031594),e(275423344,851169720),e(430227734,3100823752),e(506948616,1363258195),e(659060556,3750685593),e(883997877,3785050280),e(958139571,3318307427),e(1322822218,3812723403),e(1537002063,2003034995),e(1747873779,3602036899),e(1955562222,1575990012),e(2024104815,1125592928),e(2227730452,2716904306),e(2361852424,442776044),e(2428436474,593698344),e(2756734187,3733110249),e(3204031479,2999351573),e(3329325298,3815920427),e(3391569614,3928383900),e(3515267271,566280711),e(3940187606,3454069534),e(4118630271,4000239992),e(116418474,1914138554),e(174292421,2731055270),e(289380356,3203993006),e(460393269,320620315),e(685471733,587496836),e(852142971,1086792851),e(1017036298,365543100),e(1126000580,2618297676),e(1288033470,3409855158),e(1501505948,4234509866),e(1607167915,987167468),e(1816402316,1246189591)],f=[];!function(){for(var t=0;t<80;t++)f[t]=e()}();var p=c.SHA512=o.extend({_doReset:function(){this._hash=new s.init([new a.init(1779033703,4089235720),new a.init(3144134277,2227873595),new a.init(1013904242,4271175723),new a.init(2773480762,1595750129),new a.init(1359893119,2917565137),new a.init(2600822924,725511199),new a.init(528734635,4215389547),new a.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],a=n[3],s=n[4],c=n[5],p=n[6],l=n[7],h=r.high,d=r.low,m=o.high,y=o.low,v=i.high,g=i.low,b=a.high,_=a.low,w=s.high,x=s.low,k=c.high,B=c.low,S=p.high,C=p.low,A=l.high,F=l.low,I=h,T=d,D=m,P=y,O=v,E=g,M=b,R=_,H=w,N=x,j=k,z=B,q=S,L=C,U=A,W=F,J=0;J<80;J++){var G=f[J];if(J<16)var X=G.high=0|t[e+2*J],K=G.low=0|t[e+2*J+1];else{var V=f[J-15],$=V.high,Z=V.low,Y=($>>>1|Z<<31)^($>>>8|Z<<24)^$>>>7,Q=(Z>>>1|$<<31)^(Z>>>8|$<<24)^(Z>>>7|$<<25),tt=f[J-2],et=tt.high,nt=tt.low,rt=(et>>>19|nt<<13)^(et<<3|nt>>>29)^et>>>6,ot=(nt>>>19|et<<13)^(nt<<3|et>>>29)^(nt>>>6|et<<26),it=f[J-7],at=it.high,st=it.low,ct=f[J-16],ut=ct.high,ft=ct.low,K=Q+st,X=Y+at+(K>>>0>>0?1:0),K=K+ot,X=X+rt+(K>>>0>>0?1:0),K=K+ft,X=X+ut+(K>>>0>>0?1:0);G.high=X,G.low=K}var pt=H&j^~H&q,lt=N&z^~N&L,ht=I&D^I&O^D&O,dt=T&P^T&E^P&E,mt=(I>>>28|T<<4)^(I<<30|T>>>2)^(I<<25|T>>>7),yt=(T>>>28|I<<4)^(T<<30|I>>>2)^(T<<25|I>>>7),vt=(H>>>14|N<<18)^(H>>>18|N<<14)^(H<<23|N>>>9),gt=(N>>>14|H<<18)^(N>>>18|H<<14)^(N<<23|H>>>9),bt=u[J],_t=bt.high,wt=bt.low,xt=W+gt,kt=U+vt+(xt>>>0>>0?1:0),xt=xt+lt,kt=kt+pt+(xt>>>0>>0?1:0),xt=xt+wt,kt=kt+_t+(xt>>>0>>0?1:0),xt=xt+K,kt=kt+X+(xt>>>0>>0?1:0),Bt=yt+dt,St=mt+ht+(Bt>>>0>>0?1:0);U=q,W=L,q=j,L=z,j=H,z=N,N=R+xt|0,H=M+kt+(N>>>0>>0?1:0)|0,M=O,R=E,O=D,E=P,D=I,P=T,T=xt+Bt|0,I=kt+St+(T>>>0>>0?1:0)|0}d=r.low=d+T,r.high=h+I+(d>>>0>>0?1:0),y=o.low=y+P,o.high=m+D+(y>>>0

>>0?1:0),g=i.low=g+E,i.high=v+O+(g>>>0>>0?1:0),_=a.low=_+R,a.high=b+M+(_>>>0>>0?1:0),x=s.low=x+N,s.high=w+H+(x>>>0>>0?1:0),B=c.low=B+z,c.high=k+j+(B>>>0>>0?1:0),C=p.low=C+L,p.high=S+q+(C>>>0>>0?1:0),F=l.low=F+W,l.high=A+U+(F>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;e[r>>>5]|=128<<24-r%32,e[(r+128>>>10<<5)+30]=Math.floor(n/4294967296),e[(r+128>>>10<<5)+31]=n,t.sigBytes=4*e.length,this._process();var o=this._hash.toX32();return o},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});n.SHA512=o._createHelper(p),n.HmacSHA512=o._createHmacHelper(p)}(),t.SHA512})},{"./core":53,"./x64-core":84}],83:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return function(){function e(t,e){var n=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=n,this._lBlock^=n<>>t^this._lBlock)&e;this._lBlock^=n,this._rBlock^=n<>>5]>>>31-o%32&1}for(var i=this._subKeys=[],a=0;a<16;a++){for(var s=i[a]=[],p=f[a],r=0;r<24;r++)s[r/6|0]|=n[(u[r]-1+p)%28]<<31-r%6,s[4+(r/6|0)]|=n[28+(u[r+24]-1+p)%28]<<31-r%6;s[0]=s[0]<<1|s[0]>>>31;for(var r=1;r<7;r++)s[r]=s[r]>>>4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}for(var l=this._invSubKeys=[],r=0;r<16;r++)l[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,r,o){this._lBlock=t[r],this._rBlock=t[r+1],e.call(this,4,252645135),e.call(this,16,65535),n.call(this,2,858993459),n.call(this,8,16711935),e.call(this,1,1431655765);for(var i=0;i<16;i++){for(var a=o[i],s=this._lBlock,c=this._rBlock,u=0,f=0;f<8;f++)u|=p[f][((c^a[f])&l[f])>>>0];this._lBlock=c,this._rBlock=s^u}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,e.call(this,1,1431655765),n.call(this,8,16711935),n.call(this,2,858993459),e.call(this,16,65535),e.call(this,4,252645135),t[r]=this._lBlock,t[r+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=a._createHelper(h);var d=s.TripleDES=a.extend({_doReset:function(){var t=this._key,e=t.words;this._des1=h.createEncryptor(i.create(e.slice(0,2))),this._des2=h.createEncryptor(i.create(e.slice(2,4))),this._des3=h.createEncryptor(i.create(e.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2});r.TripleDES=a._createHelper(d)}(),t.TripleDES})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,o=r.Base,i=r.WordArray,a=n.x64={};a.Word=o.extend({init:function(t,e){this.high=t,this.low=e}}),a.WordArray=o.extend({init:function(t,n){t=this.words=t||[],n!=e?this.sigBytes=n:this.sigBytes=8*t.length},toX32:function(){for(var t=this.words,e=t.length,n=[],r=0;r=55296&&e<=56319&&o65535&&(e-=65536,o+=g(e>>>10&1023|55296),e=56320|1023&e),o+=g(e);return o}function i(t){if(t>=55296&&t<=57343)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value")}function a(t,e){return g(t>>e&63|128)}function s(t){if(0==(4294967168&t))return g(t);var e="";return 0==(4294965248&t)?e=g(t>>6&31|192):0==(4294901760&t)?(i(t),e=g(t>>12&15|224),e+=a(t,6)):0==(4292870144&t)&&(e=g(t>>18&7|240),e+=a(t,12),e+=a(t,6)),e+=g(63&t|128)}function c(t){for(var e,n=r(t),o=n.length,i=-1,a="";++i=y)throw Error("Invalid byte index");var t=255&m[v];if(v++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function f(){var t,e,n,r,o;if(v>y)throw Error("Invalid byte index");if(v==y)return!1;if(t=255&m[v],v++,0==(128&t))return t;if(192==(224&t)){if(e=u(),o=(31&t)<<6|e,o>=128)return o;throw Error("Invalid continuation byte")}if(224==(240&t)){if(e=u(),n=u(),o=(15&t)<<12|e<<6|n,o>=2048)return i(o),o;throw Error("Invalid continuation byte")}if(240==(248&t)&&(e=u(),n=u(),r=u(),o=(7&t)<<18|e<<12|n<<6|r,o>=65536&&o<=1114111))return o;throw Error("Invalid UTF-8 detected")}function p(t){m=r(t),y=m.length,v=0;for(var e,n=[];(e=f())!==!1;)n.push(e);return o(n)}var l="object"==typeof n&&n,h="object"==typeof e&&e&&e.exports==l&&e,d="object"==typeof global&&global;d.global!==d&&d.window!==d||(t=d);var m,y,v,g=String.fromCharCode,b={version:"2.1.2",encode:c,decode:p};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return b});else if(l&&!l.nodeType)if(h)h.exports=b;else{var _={},w=_.hasOwnProperty;for(var x in b)w.call(b,x)&&(l[x]=b[x])}else t.utf8=b}(this)},{}],86:[function(t,e,n){e.exports=XMLHttpRequest},{}],"bignumber.js":[function(t,e,n){"use strict";e.exports=BigNumber},{}],web3:[function(t,e,n){var r=t("./lib/web3");"undefined"!=typeof window&&"undefined"==typeof window.Web3&&(window.Web3=r),e.exports=r},{"./lib/web3":22}]},{},["web3"]); +>>>>>>> develop diff --git a/dist/web3.js b/dist/web3.js index 9871141..4dee226 100644 --- a/dist/web3.js +++ b/dist/web3.js @@ -2475,7 +2475,11 @@ module.exports = { },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":86}],21:[function(require,module,exports){ module.exports={ +<<<<<<< HEAD "version": "1.0.0" +======= + "version": "0.18.3" +>>>>>>> develop } },{}],22:[function(require,module,exports){ diff --git a/dist/web3.js.map b/dist/web3.js.map index a724f7d..bec6ac2 100644 --- a/dist/web3.js.map +++ b/dist/web3.js.map @@ -117,9 +117,16 @@ "'use strict';\n\n// go env doesn't have and need XMLHttpRequest\nif (typeof XMLHttpRequest === 'undefined') {\n exports.XMLHttpRequest = {};\n} else {\n exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line\n}\n\n", "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/** @file config.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\n/**\n * Utils\n * \n * @module utils\n */\n\n/**\n * Utility functions\n * \n * @class [utils] config\n * @constructor\n */\n\n\n/// required to define ETH_BIGNUMBER_ROUNDING_MODE\nvar BigNumber = require('bignumber.js');\n\nvar ETH_UNITS = [\n 'wei',\n 'kwei',\n 'Mwei',\n 'Gwei',\n 'szabo',\n 'finney',\n 'femtoether',\n 'picoether',\n 'nanoether',\n 'microether',\n 'milliether',\n 'nano',\n 'micro',\n 'milli',\n 'ether',\n 'grand',\n 'Mether',\n 'Gether',\n 'Tether',\n 'Pether',\n 'Eether',\n 'Zether',\n 'Yether',\n 'Nether',\n 'Dether',\n 'Vether',\n 'Uether'\n];\n\nmodule.exports = {\n ETH_PADDING: 32,\n ETH_SIGNATURE_LENGTH: 4,\n ETH_UNITS: ETH_UNITS,\n ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },\n ETH_POLLING_TIMEOUT: 1000/2,\n defaultBlock: 'latest',\n defaultAccount: undefined\n};\n\n", "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/** \n * @file sha3.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\nvar CryptoJS = require('crypto-js');\nvar sha3 = require('crypto-js/sha3');\n\nmodule.exports = function (value, options) {\n if (options && options.encoding === 'hex') {\n if (value.length > 2 && value.substr(0, 2) === '0x') {\n value = value.substr(2);\n }\n value = CryptoJS.enc.Hex.parse(value);\n }\n\n return sha3(value, {\n outputLength: 256\n }).toString();\n};\n\n", +<<<<<<< HEAD "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file utils.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\n/**\n * Utils\n *\n * @module utils\n */\n\n/**\n * Utility functions\n *\n * @class [utils] utils\n * @constructor\n */\n\n\nvar BigNumber = require('bignumber.js');\nvar sha3 = require('./sha3.js');\nvar utf8 = require('utf8');\n\nvar unitMap = {\n 'noether': '0',\n 'wei': '1',\n 'kwei': '1000',\n 'Kwei': '1000',\n 'babbage': '1000',\n 'femtoether': '1000',\n 'mwei': '1000000',\n 'Mwei': '1000000',\n 'lovelace': '1000000',\n 'picoether': '1000000',\n 'gwei': '1000000000',\n 'Gwei': '1000000000',\n 'shannon': '1000000000',\n 'nanoether': '1000000000',\n 'nano': '1000000000',\n 'szabo': '1000000000000',\n 'microether': '1000000000000',\n 'micro': '1000000000000',\n 'finney': '1000000000000000',\n 'milliether': '1000000000000000',\n 'milli': '1000000000000000',\n 'ether': '1000000000000000000',\n 'kether': '1000000000000000000000',\n 'grand': '1000000000000000000000',\n 'mether': '1000000000000000000000000',\n 'gether': '1000000000000000000000000000',\n 'tether': '1000000000000000000000000000000'\n};\n\n/**\n * Fires an error in an event emitter and callback and returns the eventemitter\n *\n * @method _fireError\n * @param {Object} error\n * @param {Object} emitter\n * @param {Function} reject\n * @param {Function} callback\n * @return {Object} the emitter\n */\nvar _fireError = function (error, emitter, reject, callback) {\n setTimeout(function(){\n if(isFunction(callback)) {\n callback(error);\n }\n if(isFunction(reject)) {\n reject(error);\n }\n if(emitter && isFunction(emitter.emit)) {\n emitter.emit('error', error);\n emitter.removeAllListeners();\n }\n }, 0);\n return emitter;\n};\n\n/**\n * Should be called to pad string to expected length\n *\n * @method padLeft\n * @param {String} string to be padded\n * @param {Number} characters that result string should have\n * @param {String} sign, by default 0\n * @returns {String} right aligned string\n */\nvar padLeft = function (string, chars, sign) {\n return new Array(chars - string.length + 1).join(sign ? sign : \"0\") + string;\n};\n\n/**\n * Should be called to pad string to expected length\n *\n * @method padRight\n * @param {String} string to be padded\n * @param {Number} characters that result string should have\n * @param {String} sign, by default 0\n * @returns {String} right aligned string\n */\nvar padRight = function (string, chars, sign) {\n return string + (new Array(chars - string.length + 1).join(sign ? sign : \"0\"));\n};\n\n/**\n * Should be called to get utf8 from it's hex representation\n *\n * @method toUtf8\n * @param {String} string in hex\n * @returns {String} ascii string representation of hex value\n */\nvar toUtf8 = function(hex) {\n// Find termination\n var str = \"\";\n var i = 0, l = hex.length;\n if (hex.substring(0, 2) === '0x') {\n i = 2;\n }\n for (; i < l; i+=2) {\n var code = parseInt(hex.substr(i, 2), 16);\n if (code === 0)\n break;\n str += String.fromCharCode(code);\n }\n\n return utf8.decode(str);\n};\n\n/**\n * Should be called to get ascii from it's hex representation\n *\n * @method toAscii\n * @param {String} string in hex\n * @returns {String} ascii string representation of hex value\n */\nvar toAscii = function(hex) {\n// Find termination\n var str = \"\";\n var i = 0, l = hex.length;\n if (hex.substring(0, 2) === '0x') {\n i = 2;\n }\n for (; i < l; i+=2) {\n var code = parseInt(hex.substr(i, 2), 16);\n str += String.fromCharCode(code);\n }\n\n return str;\n};\n\n/**\n * Should be called to get hex representation (prefixed by 0x) of utf8 string\n *\n * @method fromUtf8\n * @param {String} string\n * @param {Number} optional padding\n * @returns {String} hex representation of input string\n */\nvar fromUtf8 = function(str) {\n str = utf8.encode(str);\n var hex = \"\";\n for(var i = 0; i < str.length; i++) {\n var code = str.charCodeAt(i);\n if (code === 0)\n break;\n var n = code.toString(16);\n hex += n.length < 2 ? '0' + n : n;\n }\n\n return \"0x\" + hex;\n};\n\n/**\n * Should be called to get hex representation (prefixed by 0x) of ascii string\n *\n * @method fromAscii\n * @param {String} string\n * @param {Number} optional padding\n * @returns {String} hex representation of input string\n */\nvar fromAscii = function(str) {\n var hex = \"\";\n for(var i = 0; i < str.length; i++) {\n var code = str.charCodeAt(i);\n var n = code.toString(16);\n hex += n.length < 2 ? '0' + n : n;\n }\n\n return \"0x\" + hex;\n};\n\n/**\n * Should be used to create full function/event name from json abi\n *\n * @method transformToFullName\n * @param {Object} json-abi\n * @return {String} full fnction/event name\n */\nvar transformToFullName = function (json) {\n if (json.name.indexOf('(') !== -1) {\n return json.name;\n }\n\n var typeName = json.inputs.map(function(i){return i.type; }).join();\n return json.name + '(' + typeName + ')';\n};\n\n/**\n * Should be called to get display name of contract function\n *\n * @method extractDisplayName\n * @param {String} name of function/event\n * @returns {String} display name for function/event eg. multiply(uint256) -> multiply\n */\nvar extractDisplayName = function (name) {\n var length = name.indexOf('(');\n return length !== -1 ? name.substr(0, length) : name;\n};\n\n/// @returns overloaded part of function/event name\nvar extractTypeName = function (name) {\n /// TODO: make it invulnerable\n var length = name.indexOf('(');\n return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : \"\";\n};\n\n/**\n * Converts value to it's decimal representation in string\n *\n * @method toDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar toDecimal = function (value) {\n return toBigNumber(value).toNumber();\n};\n\n/**\n * Converts value to it's hex representation\n *\n * @method fromDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar fromDecimal = function (value) {\n var number = toBigNumber(value);\n var result = number.toString(16);\n\n return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;\n};\n\n/**\n * Auto converts any given value into it's hex representation.\n *\n * And even stringifys objects before.\n *\n * @method toHex\n * @param {String|Number|BigNumber|Object}\n * @return {String}\n */\nvar toHex = function (val) {\n /*jshint maxcomplexity: 8 */\n\n if (isBoolean(val))\n return fromDecimal(+val);\n\n if (isBigNumber(val))\n return fromDecimal(val);\n\n if (isObject(val))\n return fromUtf8(JSON.stringify(val));\n\n // if its a negative number, pass it through fromDecimal\n if (isString(val)) {\n if (val.indexOf('-0x') === 0)\n return fromDecimal(val);\n else if(val.indexOf('0x') === 0)\n return val;\n else if (!isFinite(val))\n return fromAscii(val);\n }\n\n return fromDecimal(val);\n};\n\n/**\n * Returns value of unit in Wei\n *\n * @method getValueOfUnit\n * @param {String} unit the unit to convert to, default ether\n * @returns {BigNumber} value of the unit (in Wei)\n * @throws error if the unit is not correct:w\n */\nvar getValueOfUnit = function (unit) {\n unit = unit ? unit.toLowerCase() : 'ether';\n var unitValue = unitMap[unit];\n if (unitValue === undefined) {\n throw new Error('This unit doesn\\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));\n }\n return new BigNumber(unitValue, 10);\n};\n\n/**\n * Takes a number of wei and converts it to any other ether unit.\n *\n * Possible units are:\n * SI Short SI Full Effigy Other\n * - kwei femtoether babbage\n * - mwei picoether lovelace\n * - gwei nanoether shannon nano\n * - -- microether szabo micro\n * - -- milliether finney milli\n * - ether -- --\n * - kether -- grand\n * - mether\n * - gether\n * - tether\n *\n * @method fromWei\n * @param {Number|String} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert to, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar fromWei = function(number, unit) {\n var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10);\n};\n\n/**\n * Takes a number of a unit and converts it to wei.\n *\n * Possible units are:\n * SI Short SI Full Effigy Other\n * - kwei femtoether babbage\n * - mwei picoether lovelace\n * - gwei nanoether shannon nano\n * - -- microether szabo micro\n * - -- microether szabo micro\n * - -- milliether finney milli\n * - ether -- --\n * - kether -- grand\n * - mether\n * - gether\n * - tether\n *\n * @method toWei\n * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert from, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar toWei = function(number, unit) {\n var returnValue = toBigNumber(number).times(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10);\n};\n\n/**\n * Takes an input and transforms it into an bignumber\n *\n * @method toBigNumber\n * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber\n * @return {BigNumber} BigNumber\n*/\nvar toBigNumber = function(number) {\n /*jshint maxcomplexity:5 */\n number = number || 0;\n if (isBigNumber(number))\n return number;\n\n if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {\n return new BigNumber(number.replace('0x',''), 16);\n }\n\n return new BigNumber(number.toString(10), 10);\n};\n\n/**\n * Takes and input transforms it into bignumber and if it is negative value, into two's complement\n *\n * @method toTwosComplement\n * @param {Number|String|BigNumber}\n * @return {BigNumber}\n */\nvar toTwosComplement = function (number) {\n var bigNumber = toBigNumber(number).round();\n if (bigNumber.lessThan(0)) {\n return new BigNumber(\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\", 16).plus(bigNumber).plus(1);\n }\n return bigNumber;\n};\n\n/**\n * Checks if the given string is strictly an address\n *\n * @method isStrictAddress\n * @param {String} address the given HEX adress\n * @return {Boolean}\n*/\nvar isStrictAddress = function (address) {\n return /^0x[0-9a-f]{40}$/i.test(address);\n};\n\n/**\n * Checks if the given string is an address\n *\n * @method isAddress\n * @param {String} address the given HEX adress\n * @return {Boolean}\n*/\nvar isAddress = function (address) {\n if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {\n // check if it has the basic requirements of an address\n return false;\n } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {\n // If it's all small caps or all all caps, return true\n return true;\n } else {\n // Otherwise check each case\n return isChecksumAddress(address);\n }\n};\n\n\n\n/**\n * Checks if the given string is a checksummed address\n *\n * @method isChecksumAddress\n * @param {String} address the given HEX adress\n * @return {Boolean}\n*/\nvar isChecksumAddress = function (address) {\n // Check each case\n address = address.replace('0x','');\n var addressHash = sha3(address.toLowerCase());\n\n for (var i = 0; i < 40; i++ ) {\n // the nth letter should be uppercase if the nth digit of casemap is 1\n if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {\n return false;\n }\n }\n return true;\n};\n\n\n\n/**\n * Makes a checksum address\n *\n * @method toChecksumAddress\n * @param {String} address the given HEX adress\n * @return {String}\n*/\nvar toChecksumAddress = function (address) {\n if (typeof address === 'undefined') return '';\n\n address = address.toLowerCase().replace('0x','');\n var addressHash = sha3(address);\n var checksumAddress = '0x';\n\n for (var i = 0; i < address.length; i++ ) {\n // If ith character is 9 to f then make it uppercase\n if (parseInt(addressHash[i], 16) > 7) {\n checksumAddress += address[i].toUpperCase();\n } else {\n checksumAddress += address[i];\n }\n }\n return checksumAddress;\n};\n\n/**\n * Transforms given string to valid 20 bytes-length addres with 0x prefix\n *\n * @method toAddress\n * @param {String} address\n * @return {String} formatted address\n */\nvar toAddress = function (address) {\n if (isStrictAddress(address)) {\n return address;\n }\n\n if (/^[0-9a-f]{40}$/.test(address)) {\n return '0x' + address;\n }\n\n return '0x' + padLeft(toHex(address).substr(2), 40);\n};\n\n/**\n * Returns true if object is BigNumber, otherwise false\n *\n * @method isBigNumber\n * @param {Object}\n * @return {Boolean}\n */\nvar isBigNumber = function (object) {\n return object instanceof BigNumber ||\n (object && object.constructor && object.constructor.name === 'BigNumber');\n};\n\n/**\n * Returns true if object is string, otherwise false\n *\n * @method isString\n * @param {Object}\n * @return {Boolean}\n */\nvar isString = function (object) {\n return typeof object === 'string' ||\n (object && object.constructor && object.constructor.name === 'String');\n};\n\n/**\n * Returns true if object is function, otherwise false\n *\n * @method isFunction\n * @param {Object}\n * @return {Boolean}\n */\nvar isFunction = function (object) {\n return typeof object === 'function';\n};\n\n/**\n * Returns true if object is Objet, otherwise false\n *\n * @method isObject\n * @param {Object}\n * @return {Boolean}\n */\nvar isObject = function (object) {\n return typeof object === 'object';\n};\n\n/**\n * Returns true if object is boolean, otherwise false\n *\n * @method isBoolean\n * @param {Object}\n * @return {Boolean}\n */\nvar isBoolean = function (object) {\n return typeof object === 'boolean';\n};\n\n/**\n * Returns true if object is array, otherwise false\n *\n * @method isArray\n * @param {Object}\n * @return {Boolean}\n */\nvar isArray = function (object) {\n return object instanceof Array;\n};\n\n/**\n * Returns true if given string is valid json object\n *\n * @method isJson\n * @param {String}\n * @return {Boolean}\n */\nvar isJson = function (str) {\n try {\n return !!JSON.parse(str);\n } catch (e) {\n return false;\n }\n};\n\nmodule.exports = {\n _fireError: _fireError,\n padLeft: padLeft,\n padRight: padRight,\n toHex: toHex,\n toDecimal: toDecimal,\n fromDecimal: fromDecimal,\n toUtf8: toUtf8,\n toAscii: toAscii,\n fromUtf8: fromUtf8,\n fromAscii: fromAscii,\n transformToFullName: transformToFullName,\n extractDisplayName: extractDisplayName,\n extractTypeName: extractTypeName,\n toWei: toWei,\n fromWei: fromWei,\n toBigNumber: toBigNumber,\n toTwosComplement: toTwosComplement,\n toAddress: toAddress,\n isBigNumber: isBigNumber,\n isStrictAddress: isStrictAddress,\n isAddress: isAddress,\n isChecksumAddress: isChecksumAddress,\n toChecksumAddress: toChecksumAddress,\n isFunction: isFunction,\n isString: isString,\n isObject: isObject,\n isBoolean: isBoolean,\n isArray: isArray,\n isJson: isJson\n};\n", "module.exports={\n \"version\": \"1.0.0\"\n}\n", "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file web3.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * Gav Wood \n * @date 2016\n */\n\nvar RequestManager = require('./web3/requestmanager');\nvar Iban = require('./web3/iban');\nvar Eth = require('./web3/methods/eth');\nvar DB = require('./web3/methods/db');\nvar Shh = require('./web3/methods/shh');\nvar Net = require('./web3/methods/net');\nvar Personal = require('./web3/methods/personal');\nvar Swarm = require('./web3/methods/swarm');\nvar Settings = require('./web3/settings');\nvar version = require('./version.json');\nvar utils = require('./utils/utils');\nvar sha3 = require('./utils/sha3');\nvar extend = require('./web3/extend');\nvar Batch = require('./web3/batch');\nvar Property = require('./web3/property');\nvar HttpProvider = require('./web3/providers/httpprovider');\nvar IpcProvider = require('./web3/providers/ipcprovider');\nvar WebsocketProvider = require('./web3/providers/websocketprovider');\nvar BigNumber = require('bignumber.js');\n\n\n\nfunction Web3 (provider) {\n this._requestManager = new RequestManager(provider);\n this.currentProvider = provider;\n this.eth = new Eth(this);\n this.db = new DB(this);\n this.shh = new Shh(this);\n this.net = new Net(this);\n this.personal = new Personal(this);\n this.bzz = new Swarm(this);\n this.settings = new Settings();\n this.version = {\n api: version.version\n };\n this.providers = {\n HttpProvider: HttpProvider,\n IpcProvider: IpcProvider,\n WebsocketProvider: WebsocketProvider\n };\n this._extend = extend(this);\n this._extend({\n properties: properties()\n });\n}\n\n// expose providers on the class\nWeb3.providers = {\n HttpProvider: HttpProvider,\n IpcProvider: IpcProvider,\n WebsocketProvider: WebsocketProvider\n};\n\nWeb3.prototype.setProvider = function (provider) {\n this._requestManager.setProvider(provider);\n this.currentProvider = provider;\n};\n\nWeb3.prototype.reset = function (keepIsSyncing) {\n this._requestManager.reset(keepIsSyncing);\n this.settings = new Settings();\n};\n\nWeb3.prototype.BigNumber = BigNumber;\nWeb3.prototype.toHex = utils.toHex;\nWeb3.prototype.toAscii = utils.toAscii;\nWeb3.prototype.toUtf8 = utils.toUtf8;\nWeb3.prototype.fromAscii = utils.fromAscii;\nWeb3.prototype.fromUtf8 = utils.fromUtf8;\nWeb3.prototype.toDecimal = utils.toDecimal;\nWeb3.prototype.fromDecimal = utils.fromDecimal;\nWeb3.prototype.toBigNumber = utils.toBigNumber;\nWeb3.prototype.toWei = utils.toWei;\nWeb3.prototype.fromWei = utils.fromWei;\nWeb3.prototype.isAddress = utils.isAddress;\nWeb3.prototype.isChecksumAddress = utils.isChecksumAddress;\nWeb3.prototype.toChecksumAddress = utils.toChecksumAddress;\nWeb3.prototype.isIBAN = utils.isIBAN;\n\n\nWeb3.prototype.sha3 = function(string, options) {\n return '0x' + sha3(string, options);\n};\n\n/**\n * Transforms direct icap to address\n */\nWeb3.prototype.fromICAP = function (icap) {\n var iban = new Iban(icap);\n return iban.address();\n};\n\nvar properties = function () {\n return [\n new Property({\n name: 'version.node',\n getter: 'web3_clientVersion'\n }),\n new Property({\n name: 'version.network',\n getter: 'net_version',\n inputFormatter: utils.toDecimal\n }),\n new Property({\n name: 'version.ethereum',\n getter: 'eth_protocolVersion',\n inputFormatter: utils.toDecimal\n }),\n new Property({\n name: 'version.whisper',\n getter: 'shh_version',\n inputFormatter: utils.toDecimal\n })\n ];\n};\n\nWeb3.prototype.isConnected = function(){\n return (this.currentProvider && this.currentProvider.isConnected());\n};\n\nWeb3.prototype.createBatch = function () {\n return new Batch(this);\n};\n\nmodule.exports = Web3;\n\n", +======= + "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file utils.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\n/**\n * Utils\n *\n * @module utils\n */\n\n/**\n * Utility functions\n *\n * @class [utils] utils\n * @constructor\n */\n\n\nvar BigNumber = require('bignumber.js');\nvar sha3 = require('./sha3.js');\nvar utf8 = require('utf8');\n\nvar unitMap = {\n 'noether': '0', \n 'wei': '1',\n 'kwei': '1000',\n 'Kwei': '1000',\n 'babbage': '1000',\n 'femtoether': '1000',\n 'mwei': '1000000',\n 'Mwei': '1000000',\n 'lovelace': '1000000',\n 'picoether': '1000000',\n 'gwei': '1000000000',\n 'Gwei': '1000000000',\n 'shannon': '1000000000',\n 'nanoether': '1000000000',\n 'nano': '1000000000',\n 'szabo': '1000000000000',\n 'microether': '1000000000000',\n 'micro': '1000000000000',\n 'finney': '1000000000000000',\n 'milliether': '1000000000000000',\n 'milli': '1000000000000000',\n 'ether': '1000000000000000000',\n 'kether': '1000000000000000000000',\n 'grand': '1000000000000000000000',\n 'mether': '1000000000000000000000000',\n 'gether': '1000000000000000000000000000',\n 'tether': '1000000000000000000000000000000'\n};\n\n/**\n * Should be called to pad string to expected length\n *\n * @method padLeft\n * @param {String} string to be padded\n * @param {Number} characters that result string should have\n * @param {String} sign, by default 0\n * @returns {String} right aligned string\n */\nvar padLeft = function (string, chars, sign) {\n return new Array(chars - string.length + 1).join(sign ? sign : \"0\") + string;\n};\n\n/**\n * Should be called to pad string to expected length\n *\n * @method padRight\n * @param {String} string to be padded\n * @param {Number} characters that result string should have\n * @param {String} sign, by default 0\n * @returns {String} right aligned string\n */\nvar padRight = function (string, chars, sign) {\n return string + (new Array(chars - string.length + 1).join(sign ? sign : \"0\"));\n};\n\n/**\n * Should be called to get utf8 from it's hex representation\n *\n * @method toUtf8\n * @param {String} string in hex\n * @returns {String} ascii string representation of hex value\n */\nvar toUtf8 = function(hex) {\n// Find termination\n var str = \"\";\n var i = 0, l = hex.length;\n if (hex.substring(0, 2) === '0x') {\n i = 2;\n }\n for (; i < l; i+=2) {\n var code = parseInt(hex.substr(i, 2), 16);\n if (code === 0)\n break;\n str += String.fromCharCode(code);\n }\n\n return utf8.decode(str);\n};\n\n/**\n * Should be called to get ascii from it's hex representation\n *\n * @method toAscii\n * @param {String} string in hex\n * @returns {String} ascii string representation of hex value\n */\nvar toAscii = function(hex) {\n// Find termination\n var str = \"\";\n var i = 0, l = hex.length;\n if (hex.substring(0, 2) === '0x') {\n i = 2;\n }\n for (; i < l; i+=2) {\n var code = parseInt(hex.substr(i, 2), 16);\n str += String.fromCharCode(code);\n }\n\n return str;\n};\n\n/**\n * Should be called to get hex representation (prefixed by 0x) of utf8 string\n *\n * @method fromUtf8\n * @param {String} string\n * @param {Number} optional padding\n * @returns {String} hex representation of input string\n */\nvar fromUtf8 = function(str) {\n str = utf8.encode(str);\n var hex = \"\";\n for(var i = 0; i < str.length; i++) {\n var code = str.charCodeAt(i);\n if (code === 0)\n break;\n var n = code.toString(16);\n hex += n.length < 2 ? '0' + n : n;\n }\n\n return \"0x\" + hex;\n};\n\n/**\n * Should be called to get hex representation (prefixed by 0x) of ascii string\n *\n * @method fromAscii\n * @param {String} string\n * @param {Number} optional padding\n * @returns {String} hex representation of input string\n */\nvar fromAscii = function(str) {\n var hex = \"\";\n for(var i = 0; i < str.length; i++) {\n var code = str.charCodeAt(i);\n var n = code.toString(16);\n hex += n.length < 2 ? '0' + n : n;\n }\n\n return \"0x\" + hex;\n};\n\n/**\n * Should be used to create full function/event name from json abi\n *\n * @method transformToFullName\n * @param {Object} json-abi\n * @return {String} full fnction/event name\n */\nvar transformToFullName = function (json) {\n if (json.name.indexOf('(') !== -1) {\n return json.name;\n }\n\n var typeName = json.inputs.map(function(i){return i.type; }).join();\n return json.name + '(' + typeName + ')';\n};\n\n/**\n * Should be called to get display name of contract function\n *\n * @method extractDisplayName\n * @param {String} name of function/event\n * @returns {String} display name for function/event eg. multiply(uint256) -> multiply\n */\nvar extractDisplayName = function (name) {\n var length = name.indexOf('(');\n return length !== -1 ? name.substr(0, length) : name;\n};\n\n/// @returns overloaded part of function/event name\nvar extractTypeName = function (name) {\n /// TODO: make it invulnerable\n var length = name.indexOf('(');\n return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : \"\";\n};\n\n/**\n * Converts value to it's decimal representation in string\n *\n * @method toDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar toDecimal = function (value) {\n return toBigNumber(value).toNumber();\n};\n\n/**\n * Converts value to it's hex representation\n *\n * @method fromDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar fromDecimal = function (value) {\n var number = toBigNumber(value);\n var result = number.toString(16);\n\n return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;\n};\n\n/**\n * Auto converts any given value into it's hex representation.\n *\n * And even stringifys objects before.\n *\n * @method toHex\n * @param {String|Number|BigNumber|Object}\n * @return {String}\n */\nvar toHex = function (val) {\n /*jshint maxcomplexity: 8 */\n\n if (isBoolean(val))\n return fromDecimal(+val);\n\n if (isBigNumber(val))\n return fromDecimal(val);\n\n if (isObject(val))\n return fromUtf8(JSON.stringify(val));\n\n // if its a negative number, pass it through fromDecimal\n if (isString(val)) {\n if (val.indexOf('-0x') === 0)\n return fromDecimal(val);\n else if(val.indexOf('0x') === 0)\n return val;\n else if (!isFinite(val))\n return fromAscii(val);\n }\n\n return fromDecimal(val);\n};\n\n/**\n * Returns value of unit in Wei\n *\n * @method getValueOfUnit\n * @param {String} unit the unit to convert to, default ether\n * @returns {BigNumber} value of the unit (in Wei)\n * @throws error if the unit is not correct:w\n */\nvar getValueOfUnit = function (unit) {\n unit = unit ? unit.toLowerCase() : 'ether';\n var unitValue = unitMap[unit];\n if (unitValue === undefined) {\n throw new Error('This unit doesn\\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));\n }\n return new BigNumber(unitValue, 10);\n};\n\n/**\n * Takes a number of wei and converts it to any other ether unit.\n *\n * Possible units are:\n * SI Short SI Full Effigy Other\n * - kwei femtoether babbage\n * - mwei picoether lovelace\n * - gwei nanoether shannon nano\n * - -- microether szabo micro\n * - -- milliether finney milli\n * - ether -- --\n * - kether -- grand\n * - mether\n * - gether\n * - tether\n *\n * @method fromWei\n * @param {Number|String} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert to, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar fromWei = function(number, unit) {\n var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10);\n};\n\n/**\n * Takes a number of a unit and converts it to wei.\n *\n * Possible units are:\n * SI Short SI Full Effigy Other\n * - kwei femtoether babbage\n * - mwei picoether lovelace\n * - gwei nanoether shannon nano\n * - -- microether szabo micro\n * - -- microether szabo micro\n * - -- milliether finney milli\n * - ether -- --\n * - kether -- grand\n * - mether\n * - gether\n * - tether\n *\n * @method toWei\n * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert from, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar toWei = function(number, unit) {\n var returnValue = toBigNumber(number).times(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10);\n};\n\n/**\n * Takes an input and transforms it into an bignumber\n *\n * @method toBigNumber\n * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber\n * @return {BigNumber} BigNumber\n*/\nvar toBigNumber = function(number) {\n /*jshint maxcomplexity:5 */\n number = number || 0;\n if (isBigNumber(number))\n return number;\n\n if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {\n return new BigNumber(number.replace('0x',''), 16);\n }\n\n return new BigNumber(number.toString(10), 10);\n};\n\n/**\n * Takes and input transforms it into bignumber and if it is negative value, into two's complement\n *\n * @method toTwosComplement\n * @param {Number|String|BigNumber}\n * @return {BigNumber}\n */\nvar toTwosComplement = function (number) {\n var bigNumber = toBigNumber(number).round();\n if (bigNumber.lessThan(0)) {\n return new BigNumber(\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\", 16).plus(bigNumber).plus(1);\n }\n return bigNumber;\n};\n\n/**\n * Checks if the given string is strictly an address\n *\n * @method isStrictAddress\n * @param {String} address the given HEX adress\n * @return {Boolean}\n*/\nvar isStrictAddress = function (address) {\n return /^0x[0-9a-f]{40}$/i.test(address);\n};\n\n/**\n * Checks if the given string is an address\n *\n * @method isAddress\n * @param {String} address the given HEX adress\n * @return {Boolean}\n*/\nvar isAddress = function (address) {\n if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {\n // check if it has the basic requirements of an address\n return false;\n } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {\n // If it's all small caps or all all caps, return true\n return true;\n } else {\n // Otherwise check each case\n return isChecksumAddress(address);\n }\n};\n\n\n\n/**\n * Checks if the given string is a checksummed address\n *\n * @method isChecksumAddress\n * @param {String} address the given HEX adress\n * @return {Boolean}\n*/\nvar isChecksumAddress = function (address) { \n // Check each case\n address = address.replace('0x','');\n var addressHash = sha3(address.toLowerCase());\n\n for (var i = 0; i < 40; i++ ) { \n // the nth letter should be uppercase if the nth digit of casemap is 1\n if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {\n return false;\n }\n }\n return true; \n};\n\n\n\n/**\n * Makes a checksum address\n *\n * @method toChecksumAddress\n * @param {String} address the given HEX adress\n * @return {String}\n*/\nvar toChecksumAddress = function (address) { \n if (typeof address === 'undefined') return '';\n\n address = address.toLowerCase().replace('0x','');\n var addressHash = sha3(address);\n var checksumAddress = '0x';\n\n for (var i = 0; i < address.length; i++ ) { \n // If ith character is 9 to f then make it uppercase \n if (parseInt(addressHash[i], 16) > 7) {\n checksumAddress += address[i].toUpperCase();\n } else {\n checksumAddress += address[i];\n }\n }\n return checksumAddress;\n};\n\n/**\n * Transforms given string to valid 20 bytes-length addres with 0x prefix\n *\n * @method toAddress\n * @param {String} address\n * @return {String} formatted address\n */\nvar toAddress = function (address) {\n if (isStrictAddress(address)) {\n return address;\n }\n\n if (/^[0-9a-f]{40}$/.test(address)) {\n return '0x' + address;\n }\n\n return '0x' + padLeft(toHex(address).substr(2), 40);\n};\n\n/**\n * Returns true if object is BigNumber, otherwise false\n *\n * @method isBigNumber\n * @param {Object}\n * @return {Boolean}\n */\nvar isBigNumber = function (object) {\n return object instanceof BigNumber ||\n (object && object.constructor && object.constructor.name === 'BigNumber');\n};\n\n/**\n * Returns true if object is string, otherwise false\n *\n * @method isString\n * @param {Object}\n * @return {Boolean}\n */\nvar isString = function (object) {\n return typeof object === 'string' ||\n (object && object.constructor && object.constructor.name === 'String');\n};\n\n/**\n * Returns true if object is function, otherwise false\n *\n * @method isFunction\n * @param {Object}\n * @return {Boolean}\n */\nvar isFunction = function (object) {\n return typeof object === 'function';\n};\n\n/**\n * Returns true if object is Objet, otherwise false\n *\n * @method isObject\n * @param {Object}\n * @return {Boolean}\n */\nvar isObject = function (object) {\n return typeof object === 'object';\n};\n\n/**\n * Returns true if object is boolean, otherwise false\n *\n * @method isBoolean\n * @param {Object}\n * @return {Boolean}\n */\nvar isBoolean = function (object) {\n return typeof object === 'boolean';\n};\n\n/**\n * Returns true if object is array, otherwise false\n *\n * @method isArray\n * @param {Object}\n * @return {Boolean}\n */\nvar isArray = function (object) {\n return object instanceof Array;\n};\n\n/**\n * Returns true if given string is valid json object\n *\n * @method isJson\n * @param {String}\n * @return {Boolean}\n */\nvar isJson = function (str) {\n try {\n return !!JSON.parse(str);\n } catch (e) {\n return false;\n }\n};\n\nmodule.exports = {\n padLeft: padLeft,\n padRight: padRight,\n toHex: toHex,\n toDecimal: toDecimal,\n fromDecimal: fromDecimal,\n toUtf8: toUtf8,\n toAscii: toAscii,\n fromUtf8: fromUtf8,\n fromAscii: fromAscii,\n transformToFullName: transformToFullName,\n extractDisplayName: extractDisplayName,\n extractTypeName: extractTypeName,\n toWei: toWei,\n fromWei: fromWei,\n toBigNumber: toBigNumber,\n toTwosComplement: toTwosComplement,\n toAddress: toAddress,\n isBigNumber: isBigNumber,\n isStrictAddress: isStrictAddress,\n isAddress: isAddress,\n isChecksumAddress: isChecksumAddress,\n toChecksumAddress: toChecksumAddress,\n isFunction: isFunction,\n isString: isString,\n isObject: isObject,\n isBoolean: isBoolean,\n isArray: isArray,\n isJson: isJson\n};\n", + "module.exports={\n \"version\": \"0.18.3\"\n}\n", + "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file web3.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * Gav Wood \n * @date 2014\n */\n\nvar RequestManager = require('./web3/requestmanager');\nvar Iban = require('./web3/iban');\nvar Eth = require('./web3/methods/eth');\nvar DB = require('./web3/methods/db');\nvar Shh = require('./web3/methods/shh');\nvar Net = require('./web3/methods/net');\nvar Personal = require('./web3/methods/personal');\nvar Swarm = require('./web3/methods/swarm');\nvar Settings = require('./web3/settings');\nvar version = require('./version.json');\nvar utils = require('./utils/utils');\nvar sha3 = require('./utils/sha3');\nvar extend = require('./web3/extend');\nvar Batch = require('./web3/batch');\nvar Property = require('./web3/property');\nvar HttpProvider = require('./web3/httpprovider');\nvar IpcProvider = require('./web3/ipcprovider');\nvar BigNumber = require('bignumber.js');\n\n\n\nfunction Web3 (provider) {\n this._requestManager = new RequestManager(provider);\n this.currentProvider = provider;\n this.eth = new Eth(this);\n this.db = new DB(this);\n this.shh = new Shh(this);\n this.net = new Net(this);\n this.personal = new Personal(this);\n this.bzz = new Swarm(this);\n this.settings = new Settings();\n this.version = {\n api: version.version\n };\n this.providers = {\n HttpProvider: HttpProvider,\n IpcProvider: IpcProvider\n };\n this._extend = extend(this);\n this._extend({\n properties: properties()\n });\n}\n\n// expose providers on the class\nWeb3.providers = {\n HttpProvider: HttpProvider,\n IpcProvider: IpcProvider\n};\n\nWeb3.prototype.setProvider = function (provider) {\n this._requestManager.setProvider(provider);\n this.currentProvider = provider;\n};\n\nWeb3.prototype.reset = function (keepIsSyncing) {\n this._requestManager.reset(keepIsSyncing);\n this.settings = new Settings();\n};\n\nWeb3.prototype.BigNumber = BigNumber;\nWeb3.prototype.toHex = utils.toHex;\nWeb3.prototype.toAscii = utils.toAscii;\nWeb3.prototype.toUtf8 = utils.toUtf8;\nWeb3.prototype.fromAscii = utils.fromAscii;\nWeb3.prototype.fromUtf8 = utils.fromUtf8;\nWeb3.prototype.toDecimal = utils.toDecimal;\nWeb3.prototype.fromDecimal = utils.fromDecimal;\nWeb3.prototype.toBigNumber = utils.toBigNumber;\nWeb3.prototype.toWei = utils.toWei;\nWeb3.prototype.fromWei = utils.fromWei;\nWeb3.prototype.isAddress = utils.isAddress;\nWeb3.prototype.isChecksumAddress = utils.isChecksumAddress;\nWeb3.prototype.toChecksumAddress = utils.toChecksumAddress;\nWeb3.prototype.isIBAN = utils.isIBAN;\n\n\nWeb3.prototype.sha3 = function(string, options) {\n return '0x' + sha3(string, options);\n};\n\n/**\n * Transforms direct icap to address\n */\nWeb3.prototype.fromICAP = function (icap) {\n var iban = new Iban(icap);\n return iban.address();\n};\n\nvar properties = function () {\n return [\n new Property({\n name: 'version.node',\n getter: 'web3_clientVersion'\n }),\n new Property({\n name: 'version.network',\n getter: 'net_version',\n inputFormatter: utils.toDecimal\n }),\n new Property({\n name: 'version.ethereum',\n getter: 'eth_protocolVersion',\n inputFormatter: utils.toDecimal\n }),\n new Property({\n name: 'version.whisper',\n getter: 'shh_version',\n inputFormatter: utils.toDecimal\n })\n ];\n};\n\nWeb3.prototype.isConnected = function(){\n return (this.currentProvider && this.currentProvider.isConnected());\n};\n\nWeb3.prototype.createBatch = function () {\n return new Batch(this);\n};\n\nmodule.exports = Web3;\n\n", + "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/** \n * @file allevents.js\n * @author Marek Kotewicz \n * @date 2014\n */\n\nvar sha3 = require('../utils/sha3');\nvar SolidityEvent = require('./event');\nvar formatters = require('./formatters');\nvar utils = require('../utils/utils');\nvar Filter = require('./filter');\nvar watches = require('./methods/watches');\n\nvar AllSolidityEvents = function (requestManager, json, address) {\n this._requestManager = requestManager;\n this._json = json;\n this._address = address;\n};\n\nAllSolidityEvents.prototype.encode = function (options) {\n options = options || {};\n var result = {};\n\n ['fromBlock', 'toBlock'].filter(function (f) {\n return options[f] !== undefined;\n }).forEach(function (f) {\n result[f] = formatters.inputBlockNumberFormatter(options[f]);\n });\n\n result.address = this._address;\n\n return result;\n};\n\nAllSolidityEvents.prototype.decode = function (data) {\n data.data = data.data || '';\n data.topics = data.topics || [];\n\n var eventTopic = data.topics[0].slice(2);\n var match = this._json.filter(function (j) {\n return eventTopic === sha3(utils.transformToFullName(j));\n })[0];\n\n if (!match) { // cannot find matching event?\n console.warn('cannot find event for log');\n return data;\n }\n\n var event = new SolidityEvent(this._requestManager, match, this._address);\n return event.decode(data);\n};\n\nAllSolidityEvents.prototype.execute = function (options, callback) {\n\n if (utils.isFunction(arguments[arguments.length - 1])) {\n callback = arguments[arguments.length - 1];\n if(arguments.length === 1)\n options = null;\n }\n\n var o = this.encode(options);\n var formatter = this.decode.bind(this);\n return new Filter(this._requestManager, o, watches.eth(), formatter, callback);\n};\n\nAllSolidityEvents.prototype.attachToContract = function (contract) {\n var execute = this.execute.bind(this);\n contract.allEvents = execute;\n};\n\nmodule.exports = AllSolidityEvents;\n\n", +>>>>>>> develop "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/** \n * @file batch.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\nvar Jsonrpc = require('./jsonrpc');\nvar errors = require('./errors');\n\nvar Batch = function (web3) {\n this.requestManager = web3._requestManager;\n this.requests = [];\n};\n\n/**\n * Should be called to add create new request to batch request\n *\n * @method add\n * @param {Object} jsonrpc requet object\n */\nBatch.prototype.add = function (request) {\n this.requests.push(request);\n};\n\n/**\n * Should be called to execute batch request\n *\n * @method execute\n */\nBatch.prototype.execute = function () {\n var requests = this.requests;\n this.requestManager.sendBatch(requests, function (err, results) {\n results = results || [];\n requests.map(function (request, index) {\n return results[index] || {};\n }).forEach(function (result, index) {\n if (requests[index].callback) {\n\n if (!Jsonrpc.isValidResponse(result)) {\n return requests[index].callback(errors.InvalidResponse(result));\n }\n\n requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));\n }\n });\n }); \n};\n\nmodule.exports = Batch;\n\n", "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file contract.js\n * @author Fabian Vogelsteller \n * @date 2016\n */\n\nvar _ = require('lodash');\nvar utils = require('../utils/utils');\nvar eventifiedPromise = require('./eventifiedPromise.js');\nvar Method = require('./method.js');\nvar coder = require('../solidity/coder');\nvar formatters = require('./formatters');\nvar sha3 = require('../utils/sha3');\nvar Subscription = require('./subscription.js');\n\n\n/**\n * Should be called to create new contract instance\n *\n * @method Contract\n * @constructor\n * @param {Array} jsonInterface\n * @param {String} address\n * @param {Object} options\n */\nvar Contract = function(jsonInterface, address, options) {\n var _this = this,\n args = Array.prototype.slice.call(arguments);\n\n if(!(this instanceof Contract))\n throw new Error('Please use the \"new\" keyword to instantiate a web3.eth.contract() object!');\n\n if(!jsonInterface || !(jsonInterface instanceof Array))\n throw new Error('You must provide the json interface of the contract when instatiating a contract object.');\n\n // get the options object\n this.options = {};\n if(utils.isObject(args[args.length - 1])) {\n options = args[args.length - 1];\n this.options.data = options.data;\n this.options.from = options.from;\n this.options.gasPrice = options.gasPrice;\n this.options.gas = options.gas || options.gasLimit;\n\n if(utils.isObject(address)) {\n address = null;\n }\n }\n\n\n // set address\n Object.defineProperty(this.options, 'address', {\n set: function(value){\n if(utils.isAddress(value))\n this._address = value.toLowerCase();\n else if(value)\n throw new Error('The provided contract address is not a valid address.');\n },\n get: function(){\n return this._address;\n },\n enumerable: true\n });\n\n // add method and event signatures, when the jsonInterface gets set\n Object.defineProperty(this.options, 'jsonInterface', {\n set: function(value){\n _this.methods = {};\n _this.events = {};\n\n _this._jsonInterface = value.map(function(method) {\n var func,\n funcName,\n inputs = method.inputs ? method.inputs.map(function(key){ return key.type; }).join(',') : '';\n\n if(method.name)\n funcName = method.name +'('+ inputs +')';\n\n\n // function\n if (method.type === 'function') {\n method.signature = '0x'+ sha3(utils.transformToFullName(method)).slice(0, 8);\n func = _this._createTxObject.bind({\n method: method,\n parent: _this\n });\n\n\n // add method only if not one already exists\n if(!_this.methods[method.name])\n _this.methods[method.name] = func;\n\n // definitely add the method based on its signature\n _this.methods[method.signature] = func;\n\n // add method by name\n _this.methods[funcName] = func;\n\n // also add to the main contract object\n // if(!_this[method.name] || _this[method.name].name === 'bound _createTxObject')\n // _this[method.name] = _this.methods[method.name];\n // _this[method.signature] = _this.methods[method.signature];\n\n // event\n } else if (method.type === 'event') {\n method.signature = '0x'+ sha3(utils.transformToFullName(method));\n var event = _this._on.bind(_this, method.signature);\n\n // add method only if not already exists\n if(!_this.events[method.name] || _this.events[method.name].name === 'bound ')\n _this.events[method.name] = event;\n\n // definitely add the method based on its signature\n _this.events[method.signature] = event;\n\n // add event by name\n _this.events[funcName] = event;\n }\n\n\n return method;\n });\n\n // add allEvents\n _this.events.allEvents = _this._on.bind(_this, 'allevents');\n\n return _this._jsonInterface;\n },\n get: function(){\n return _this._jsonInterface;\n },\n enumerable: true\n });\n\n // properties\n this.methods = {};\n this.events = {};\n\n this._address = null;\n this._jsonInterface = [];\n\n // set getter/setter properties\n this.options.address = address;\n this.options.jsonInterface = jsonInterface;\n\n};\n\nContract.prototype._web3 = {}; // web3 is attached here in eth.js\n\n\n/**\n * Get the callback and modiufy the array if necessary\n *\n * @method _getCallback\n * @param {Array} args\n * @return {Function} the callback\n */\nContract.prototype._getCallback = function getCallback(args) {\n if (utils.isFunction(args[args.length - 1])) {\n return args.pop(); // modify the args array!\n }\n};\n\n/**\n * Checks that no listener with name \"newListener\" or \"removeListener\" is added.\n *\n * @method _checkListener\n * @param {String} type\n * @param {String} event\n * @return {Object} the contract instance\n */\nContract.prototype._checkListener = function(type, event){\n if(event === type) {\n throw new Error('The event \"'+ type +'\" is a reserved event name, you can\\'t use it.');\n }\n};\n\n\n/**\n * Use default values, if options are not available\n *\n * @method _fillWithDefaultOptions\n * @param {Object} options the options gived by the user\n * @return {Object} the options with gaps filled by defaults\n */\nContract.prototype._fillWithDefaultOptions = function fillWithDefaultOptions(options) {\n\n options.data = options.data || this.options.data;\n options.from = options.from || this.options.from;\n\n if(utils.isAddress(options.from))\n options.from = options.from.toLowerCase();\n\n options.gasPrice = options.gasPrice || this.options.gasPrice;\n options.gas = options.gas || options.gasLimit || this.options.gas;\n // TODO replace with only gasLimit?\n delete options.gasLimit;\n\n return options;\n};\n\n\n/**\n * Should be used to encode indexed params and options to one final object\n *\n * @method _encodeEventABI\n * @param {Object} event\n * @param {Object} options\n * @return {Object} everything combined together and encoded\n */\nContract.prototype._encodeEventABI = function (event, options) {\n options = options || {};\n var filter = options.filter || {},\n result = {};\n\n ['fromBlock', 'toBlock'].filter(function (f) {\n return options[f] !== undefined;\n }).forEach(function (f) {\n result[f] = formatters.inputBlockNumberFormatter(options[f]);\n });\n\n // use given topics\n if(utils.isArray(options.topics)) {\n result.topics = options.topics;\n\n // create topics based on filter\n } else {\n\n result.topics = [];\n\n // add event signature\n if (event && !event.anonymous && event.name !== 'ALLEVENTS') {\n result.topics.push(event.signature);\n }\n\n // add event topics (indexed arguments)\n if (event.name !== 'ALLEVENTS') {\n var indexedTopics = event.inputs.filter(function (i) {\n return i.indexed === true;\n }).map(function (i) {\n var value = filter[i.name];\n if (!value) {\n return null;\n }\n\n if (utils.isArray(value)) {\n return value.map(function (v) {\n return '0x' + coder.encodeParam(i.type, v);\n });\n }\n return '0x' + coder.encodeParam(i.type, value);\n });\n\n result.topics = result.topics.concat(indexedTopics);\n }\n\n if(!result.topics.length)\n delete result.topics;\n }\n\n result.address = this.options.address;\n\n return result;\n};\n\n/**\n * Should be used to decode indexed params and options\n *\n * @method _decodeEventABI\n * @param {Object} data\n * @return {Object} result object with decoded indexed && not indexed params\n */\nContract.prototype._decodeEventABI = function (data) {\n var event = this;\n\n data.data = data.data || '';\n data.topics = data.topics || [];\n var result = formatters.outputLogFormatter(data);\n\n // if allEvents get the right event\n if(event.name === 'ALLEVENTS') {\n event = event.jsonInterface.find(function (interface) {\n return (interface.signature === data.topics[0]);\n }) || {anonymous: true};\n }\n\n // create empty inputs if none are present (e.g. anonymous events on allEvents)\n event.inputs = event.inputs || [];\n\n\n var argTopics = event.anonymous ? data.topics : data.topics.slice(1);\n var indexedTypes = event.inputs.filter(function (i) {\n return i.indexed === true;\n }).map(function (i) {\n return i.type;\n });\n var notIndexedTypes = event.inputs.filter(function (i) {\n return i.indexed === false;\n }).map(function (i) {\n return i.type;\n });\n\n var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join('');\n // console.log('INDEXED', indexedTypes, indexedData);\n var indexedParams = coder.decodeParams(indexedTypes, indexedData);\n\n // console.log('NOT INDEXED', notIndexedTypes, data.data.slice(2));\n var notIndexedParams = coder.decodeParams(notIndexedTypes, data.data.slice(2));\n\n\n var count = 0;\n result.returnValues = event.inputs.reduce(function (acc, current) {\n var name = current.name || count++;\n acc[name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();\n return acc;\n }, {});\n\n result.event = event.name;\n\n //delete result.data;\n //delete result.topics;\n\n return result;\n};\n\n/**\n * Encodes an ABI for a method, including signature or the method.\n * Or when constructor encodes only the constructor parameters.\n *\n * @method _encodeMethodABI\n * @param {Mixed} args the arguments to encode\n * @param {String} the encoded ABI\n */\nContract.prototype._encodeMethodABI = function _encodeMethodABI() {\n var methodSignature = this._method.signature,\n args = this.arguments;\n\n var signature = false,\n paramsABI = this._parent.options.jsonInterface.filter(function (json) {\n return ((methodSignature === 'constructor' && json.type === methodSignature) ||\n ((json.signature === methodSignature || json.signature === '0x'+ methodSignature.replace('0x','') || json.name === methodSignature) && json.type === 'function'));\n }).map(function (json) {\n if(json.inputs.length !== args.length) {\n throw new Error('The number of arguments is not matching the methods required number. You need to pass '+ json.inputs.length +' arguments.');\n }\n\n if(json.type === 'function') {\n signature = json.signature;\n }\n return json.inputs.map(function (input) {\n return input.type;\n });\n }).map(function (types) {\n return coder.encodeParams(types, args);\n })[0] || '';\n\n // return constructor\n if(methodSignature === 'constructor') {\n if(!this._deployData)\n throw new Error('The contract has no contract data option set. This is necessary to append the constructor parameters.');\n\n return this._deployData + paramsABI;\n\n // return method\n } else {\n\n var returnValue = (signature) ? signature + paramsABI : paramsABI;\n\n if(!returnValue)\n throw new Error('Couldn\\'t find a matching contract method named \"'+ this._method.name +'\".');\n else\n return returnValue;\n }\n\n};\n\n/**\n * Decode method return values\n *\n * @method _decodeMethodReturn\n * @param {Array} outputs\n * @param {String} returnValues\n * @param {Array} decoded output return values\n */\nContract.prototype._decodeMethodReturn = function (outputs, returnValues) {\n if (!returnValues) {\n return;\n }\n\n var types = outputs.map(function (i) {\n return i.type;\n });\n\n returnValues = returnValues.length >= 2 ? returnValues.slice(2) : returnValues;\n var result = coder.decodeParams(types, returnValues);\n result = result.length === 1 ? result[0] : result;\n if(result === '0x')\n result = null;\n return result;\n};\n\n\n/**\n * Deploys a contract and fire events based on its state: transactionHash, receipt\n *\n * All event listeners will be removed, once the last possible event is fired (\"error\", or \"receipt\")\n *\n * @method deploy\n * @param {Object} options\n * @param {Function} callback\n * @return {Object} EventEmitter possible events are \"error\", \"transactionHash\" and \"receipt\"\n */\nContract.prototype.deploy = function(options, callback){\n\n options = options || {};\n\n options.arguments = options.arguments || [];\n options = this._fillWithDefaultOptions(options);\n\n\n // return error, if no \"data\" is specified\n if(!options.data) {\n return utils._fireError(new Error('No \"data\" specified in neither the given options, nor the default options.'), defer.promise, defer.reject, callback);\n }\n\n // return defer.promise;\n var constructor = _.find(this.options.jsonInterface, function (method) {\n return (method.type === 'constructor');\n }) || {};\n constructor.signature = 'constructor';\n\n return this._createTxObject.apply({\n method: constructor,\n parent: this,\n deployData: options.data\n }, options.arguments);\n\n};\n\n\n/**\n * Gets the event signature and outputformatters\n *\n * @method _generateEventOptions\n * @param {Object} event\n * @param {Object} options\n * @param {Function} callback\n * @return {Object} the event options object\n */\nContract.prototype._generateEventOptions = function() {\n var args = Array.prototype.slice.call(arguments);\n\n // get the callback\n var callback = this._getCallback(args);\n\n // get the options\n var options = (utils.isObject(args[args.length - 1])) ? args.pop() : {};\n\n var event = (utils.isString(args[0])) ? args[0] : 'allevents';\n event = (event.toLowerCase() === 'allevents') ? {\n name: 'ALLEVENTS',\n jsonInterface: this.options.jsonInterface\n } : this.options.jsonInterface.find(function (json) {\n return (json.type === 'event' && (json.name === event || json.signature === '0x'+ event.replace('0x','')));\n });\n\n if (!event) {\n throw new Error('Event \"' + event.name + '\" doesn\\'t exist in this contract.');\n }\n\n if (!utils.isAddress(this.options.address)) {\n throw new Error('This contract object doesn\\'t have address set yet, please set an address first.');\n }\n\n return {\n params: this._encodeEventABI(event, options),\n event: event,\n callback: callback\n };\n};\n\n/**\n * Adds event listeners and creates a subscription, and remove it once its fired.\n *\n * @method on\n * @param {String} event\n * @param {Object} options\n * @param {Function} callback\n * @return {Object} the event subscription\n */\nContract.prototype.once = function(event, options, callback) {\n var args = Array.prototype.slice.call(arguments);\n\n // get the callback\n callback = this._getCallback(args);\n\n // don't allow fromBlock\n if(options)\n delete options.fromBlock;\n\n return this._on(event, options, function (err, res, sub) {\n sub.unsubscribe();\n if(utils.isFunction(callback)){\n callback(err, res);\n }\n });\n};\n\n/**\n * Adds event listeners and creates a subscription.\n *\n * @method on\n * @param {String} event\n * @param {Object} options\n * @param {Function} callback\n * @return {Object} the event subscription\n */\nContract.prototype._on = function(){\n var subOptions = this._generateEventOptions.apply(this, arguments);\n\n\n // prevent the event \"newListener\" and \"removeListener\" from being overwritten\n this._checkListener('newListener', subOptions.event.name, subOptions.callback);\n this._checkListener('removeListener', subOptions.event.name, subOptions.callback);\n\n // TODO check if listener already exists? and reuse subscription if options are the same.\n\n // create new subscription\n var subscription = new Subscription({\n subscription: {\n params: 1,\n inputFormatter: [formatters.inputLogFormatter],\n outputFormatter: this._decodeEventABI.bind(subOptions.event)\n },\n subscribeMethod: 'eth_subscribe',\n unsubscribeMethod: 'eth_unsubscribe',\n requestManager: this._web3._requestManager\n });\n subscription.subscribe('logs', subOptions.params, subOptions.callback || function () {});\n\n return subscription;\n};\n\n/**\n * Get past events from contracts\n *\n * @method getPastEvents\n * @param {String} event\n * @param {Object} options\n * @param {Function} callback\n * @return {Object} the promievent\n */\nContract.prototype.getPastEvents = function(){\n var subOptions = this._generateEventOptions.apply(this, arguments);\n\n var getPastLogs = new Method({\n name: 'getPastLogs',\n call: 'eth_getLogs',\n params: 1,\n inputFormatter: [formatters.inputLogFormatter],\n outputFormatter: this._decodeEventABI.bind(subOptions.event)\n });\n getPastLogs.setRequestManager(this._web3._requestManager);\n var call = getPastLogs.buildCall();\n\n getPastLogs = null;\n\n return call(subOptions.params, subOptions.callback);\n};\n\n\n/**\n * returns the an object with call, send, estimate funcitons\n *\n * @method _createTxObject\n * @returns {Object} an object with functions to call the methods\n */\nContract.prototype._createTxObject = function _createTxObject(){\n var txObject = {};\n\n if(this.method.type === 'function') {\n\n txObject.call = this.parent._executeMethod.bind(txObject, 'call');\n txObject.call.request = this.parent._executeMethod.bind(txObject, 'call', true); // to make batch requests\n\n }\n\n txObject.send = this.parent._executeMethod.bind(txObject, 'send');\n txObject.send.request = this.parent._executeMethod.bind(txObject, 'send', true); // to make batch requests\n txObject.encodeABI = this.parent._encodeMethodABI.bind(txObject);\n txObject.estimateGas = this.parent._executeMethod.bind(txObject, 'estimate');\n\n txObject.arguments = arguments;\n txObject._method = this.method;\n txObject._parent = this.parent;\n\n if(this.deployData)\n txObject._deployData = this.deployData;\n\n return txObject;\n};\n\n\n\n/**\n * The callback called when executing a method\n *\n * @method _methodReturnCallback\n * @param {Object} err\n * @param {Mixed} returnValue\n */\nContract.prototype._methodReturnCallback = function methodReturnCallback(defer, callback, type, err, returnValue) {\n var _this = this,\n error = new Error('Failed to check for transaction receipt.'),\n callbackFired = false;\n\n if(type === 'call') {\n returnValue = _this._parent._decodeMethodReturn(_this._method.outputs, returnValue);\n }\n\n\n if (err) {\n return utils._fireError(err, defer.promise, defer.reject, callback);\n } else {\n\n // send immediate returnValue (see end of the function for resolve event of call and estimateGas)\n if(callback) {\n callback(null, returnValue);\n }\n\n // check for receipt on send\n if(type === 'send') {\n\n defer.promise.emit('transactionHash', returnValue);\n\n // fire \"receipt\" event and resolve after\n _this._parent._web3.eth.subscribe('newBlocks', {}, function (err, block, sub) {\n if(!err) {\n\n _this._parent._web3.eth.getTransactionReceipt(returnValue, function (err, receipt) {\n if(!err) {\n if(!callbackFired && receipt) {\n\n // CHECK for contract deployment\n if(_this._deployData) {\n\n if(!receipt.contractAddress) {\n callbackFired = true;\n return utils._fireError(new Error('The transaction receipt didn\\'t contain a contract address.'), defer.promise, defer.reject);\n }\n\n _this._parent._web3.eth.getCode(receipt.contractAddress, function(e, code){\n\n if(!code)\n return;\n\n sub.unsubscribe();\n callbackFired = true;\n\n if(code.length > 2) {\n defer.promise.emit('receipt', receipt);\n defer.resolve(receipt);\n defer.promise.removeAllListeners();\n } else {\n return utils._fireError(new Error('The contract code couldn\\'t be stored, please check your gas limit.'), defer.promise, defer.reject);\n }\n });\n\n\n\n // CHECK for normal tx check for receipt only\n } else {\n sub.unsubscribe();\n callbackFired = true;\n\n if(!receipt.outOfGas) {\n defer.promise.emit('receipt', receipt);\n defer.resolve(receipt);\n defer.promise.removeAllListeners();\n\n } else {\n return utils._fireError(new Error('Transaction ran out of gas.'), defer.promise, defer.reject);\n }\n }\n\n }\n } else {\n sub.unsubscribe();\n callbackFired = true;\n return utils._fireError(error, defer.promise, defer.reject);\n }\n });\n\n\n } else {\n sub.unsubscribe();\n callbackFired = true;\n return utils._fireError(error, defer.promise, defer.reject);\n }\n });\n\n } else {\n\n // remove all listeners on the end, as no event will ever fire again\n defer.resolve(returnValue);\n }\n }\n};\n\n/**\n * Generates the options for the execute call\n *\n * @method _processExecuteArguments\n * @param {Array} args\n * @param {Promise} defer\n */\nContract.prototype._processExecuteArguments = function _processExecuteArguments(args, defer) {\n var processedArgs = {};\n\n processedArgs.type = args.shift();\n\n // get the callback\n processedArgs.callback = this._parent._getCallback(args);\n\n // get block number to use for call\n if(processedArgs.type === 'call' && args[args.length - 1] !== true && (utils.isString(args[args.length - 1]) || isFinite(args[args.length - 1])))\n processedArgs.defaultBlock = args.pop();\n\n // get the options\n processedArgs.options = (utils.isObject(args[args.length - 1])) ? args.pop() : {};\n\n // get the generateRequest argument\n processedArgs.generateRequest = (args[args.length - 1] === true)? args.pop() : false;\n\n processedArgs.options = this._parent._fillWithDefaultOptions(processedArgs.options);\n processedArgs.options.data = this.encodeABI();\n\n // add contract address\n if(!this._deployData && !utils.isAddress(this._parent.options.address))\n throw new Error('This contract object doesn\\'t have address set yet, please set an address first.');\n\n if(!this._deployData)\n processedArgs.options.to = this._parent.options.address;\n\n // return error, if no \"data\" is specified\n if(!processedArgs.options.data)\n return utils._fireError(new Error('Couldn\\'t find a matching contract method, or the number of parameters is wrong.'), defer.promise, defer.reject, processedArgs.callback);\n\n return processedArgs;\n};\n\n/**\n * Executes a call, transact or estimateGas on a contract function\n *\n * @method _executeMethod\n * @param {String} type the type this execute function should execute\n * @param {Boolean} makeRequest if true, it simply returns the request parameters, rather than executing it\n */\nContract.prototype._executeMethod = function _executeMethod(){\n var args = this._parent._processExecuteArguments.call(this, Array.prototype.slice.call(arguments), defer),\n defer = eventifiedPromise((args.type !== 'send'));\n\n\n // simple return request\n if(args.generateRequest) {\n\n var payload = {\n params: [formatters.inputCallFormatter(args.options), formatters.inputDefaultBlockNumberFormatter(args.defaultBlock)],\n callback: args.callback\n };\n\n if(args.type === 'call') {\n payload.method = 'eth_call';\n payload.format = this._parent._decodeMethodReturn.bind(null, this._method.outputs);\n } else {\n payload.method = 'eth_sendTransaction';\n }\n\n return payload;\n\n } else {\n\n var methodReturnCallback = this._parent._methodReturnCallback.bind(this, defer, args.callback, args.type);\n\n switch (args.type) {\n case 'estimate':\n\n this._parent._web3.eth.estimateGas(args.options, methodReturnCallback);\n\n break;\n case 'call':\n\n // TODO check errors: missing \"from\" should give error on deploy and send, call ?\n\n this._parent._web3.eth.call(args.options, args.defaultBlock, methodReturnCallback);\n\n break;\n case 'send':\n\n // return error, if no \"from\" is specified\n if(!utils.isAddress(args.options.from)) {\n return utils._fireError(new Error('No \"from\" address specified in neither the given options, nor the default options.'), defer.promise, defer.reject, args.callback);\n }\n\n if (_.isBoolean(this._method.payable) && !this._method.payable && args.options.value && args.options.value > 0) {\n return utils._fireError(new Error('Can not send value to non-payable contract method or constructor'), defer.promise, defer.reject, args.callback);\n }\n\n this._parent._web3.eth.sendTransaction(args.options, methodReturnCallback);\n\n break;\n }\n\n }\n\n return defer.promise;\n};\n\nmodule.exports = Contract;\n", "/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/** \n * @file errors.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\nmodule.exports = {\n InvalidNumberOfParams: function () {\n return new Error('Invalid number of input parameters');\n },\n InvalidConnection: function (host){\n return new Error('CONNECTION ERROR: Couldn\\'t connect to node '+ host +'.');\n },\n InvalidProvider: function () {\n return new Error('Provider not set or invalid');\n },\n InvalidResponse: function (result){\n var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);\n return new Error(message);\n },\n ConnectionTimeout: function (ms){\n return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');\n }\n};\n", diff --git a/dist/web3.min.js b/dist/web3.min.js index d5b406e..1d46b1b 100644 --- a/dist/web3.min.js +++ b/dist/web3.min.js @@ -1,3 +1,4 @@ +<<<<<<< HEAD require=function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a2&&"0x"===t.substr(0,2)&&(t=t.substr(2)),t=r.enc.Hex.parse(t)),i(t,{outputLength:256}).toString()}},{"crypto-js":58,"crypto-js/sha3":79}],20:[function(t,e,n){var r=t("bignumber.js"),i=t("./sha3.js"),o=t("utf8"),a={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",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",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"},s=function(t,e,n,r){return setTimeout(function(){T(r)&&r(t),T(n)&&n(t),e&&T(e.emit)&&(e.emit("error",t),e.removeAllListeners())},0),e},u=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},c=function(t,e,n){return t+new Array(e-t.length+1).join(n?n:"0")},l=function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);n7&&t[n].toUpperCase()!==t[n]||parseInt(e[n],16)<=7&&t[n].toLowerCase()!==t[n])return!1;return!0},S=function(t){if("undefined"==typeof t)return"";t=t.toLowerCase().replace("0x","");for(var e=i(t),n="0x",r=0;r7?t[r].toUpperCase():t[r];return n},A=function(t){return j(t)?t:/^[0-9a-f]{40}$/.test(t)?"0x"+t:"0x"+u(g(t).substr(2),40)},B=function(t){return t instanceof r||t&&t.constructor&&"BigNumber"===t.constructor.name},O=function(t){return"string"==typeof t||t&&t.constructor&&"String"===t.constructor.name},T=function(t){return"function"==typeof t},R=function(t){return"object"==typeof t},P=function(t){return"boolean"==typeof t},I=function(t){return t instanceof Array},D=function(t){try{return!!JSON.parse(t)}catch(t){return!1}};e.exports={_fireError:s,padLeft:u,padRight:c,toHex:g,toDecimal:y,fromDecimal:m,toUtf8:l,toAscii:f,fromUtf8:p,fromAscii:h,transformToFullName:d,extractDisplayName:v,extractTypeName:_,toWei:k,fromWei:w,toBigNumber:x,toTwosComplement:C,toAddress:A,isBigNumber:B,isStrictAddress:j,isAddress:E,isChecksumAddress:F,toChecksumAddress:S,isFunction:T,isString:O,isObject:R,isBoolean:P,isArray:I,isJson:D}},{"./sha3.js":19,"bignumber.js":"bignumber.js",utf8:86}],21:[function(t,e,n){e.exports={version:"1.0.0"}},{}],22:[function(t,e,n){function r(t){this._requestManager=new i(t),this.currentProvider=t,this.eth=new a(this),this.db=new s(this),this.shh=new u(this),this.net=new c(this),this.personal=new l(this),this.bzz=new f(this),this.settings=new p,this.version={api:h.version},this.providers={HttpProvider:g,IpcProvider:b,WebsocketProvider:w},this._extend=_(this),this._extend({properties:x()})}var i=t("./web3/requestmanager"),o=t("./web3/iban"),a=t("./web3/methods/eth"),s=t("./web3/methods/db"),u=t("./web3/methods/shh"),c=t("./web3/methods/net"),l=t("./web3/methods/personal"),f=t("./web3/methods/swarm"),p=t("./web3/settings"),h=t("./version.json"),d=t("./utils/utils"),v=t("./utils/sha3"),_=t("./web3/extend"),y=t("./web3/batch"),m=t("./web3/property"),g=t("./web3/providers/httpprovider"),b=t("./web3/providers/ipcprovider"),w=t("./web3/providers/websocketprovider"),k=t("bignumber.js");r.providers={HttpProvider:g,IpcProvider:b,WebsocketProvider:w},r.prototype.setProvider=function(t){this._requestManager.setProvider(t),this.currentProvider=t},r.prototype.reset=function(t){this._requestManager.reset(t),this.settings=new p},r.prototype.BigNumber=k,r.prototype.toHex=d.toHex,r.prototype.toAscii=d.toAscii,r.prototype.toUtf8=d.toUtf8,r.prototype.fromAscii=d.fromAscii,r.prototype.fromUtf8=d.fromUtf8,r.prototype.toDecimal=d.toDecimal,r.prototype.fromDecimal=d.fromDecimal,r.prototype.toBigNumber=d.toBigNumber,r.prototype.toWei=d.toWei,r.prototype.fromWei=d.fromWei,r.prototype.isAddress=d.isAddress,r.prototype.isChecksumAddress=d.isChecksumAddress,r.prototype.toChecksumAddress=d.toChecksumAddress,r.prototype.isIBAN=d.isIBAN,r.prototype.sha3=function(t,e){return"0x"+v(t,e)},r.prototype.fromICAP=function(t){var e=new o(t);return e.address()};var x=function(){return[new m({name:"version.node",getter:"web3_clientVersion"}),new m({name:"version.network",getter:"net_version",inputFormatter:d.toDecimal}),new m({name:"version.ethereum",getter:"eth_protocolVersion",inputFormatter:d.toDecimal}),new m({name:"version.whisper",getter:"shh_version",inputFormatter:d.toDecimal})]};r.prototype.isConnected=function(){return this.currentProvider&&this.currentProvider.isConnected()},r.prototype.createBatch=function(){return new y(this)},e.exports=r},{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":23,"./web3/extend":27,"./web3/iban":29,"./web3/methods/db":32,"./web3/methods/eth":33,"./web3/methods/net":34,"./web3/methods/personal":35,"./web3/methods/shh":36,"./web3/methods/swarm":37,"./web3/property":39,"./web3/providers/httpprovider":40,"./web3/providers/ipcprovider":41,"./web3/providers/websocketprovider":42,"./web3/requestmanager":43,"./web3/settings":44,"bignumber.js":"bignumber.js"}],23:[function(t,e,n){var r=t("./jsonrpc"),i=t("./errors"),o=function(t){this.requestManager=t._requestManager,this.requests=[]};o.prototype.add=function(t){this.requests.push(t)},o.prototype.execute=function(){var t=this.requests;this.requestManager.sendBatch(t,function(e,n){n=n||[],t.map(function(t,e){return n[e]||{}}).forEach(function(e,n){if(t[n].callback){if(!r.isValidResponse(e))return t[n].callback(i.InvalidResponse(e));t[n].callback(null,t[n].format?t[n].format(e.result):e.result)}})})},e.exports=o},{"./errors":25,"./jsonrpc":30}],24:[function(t,e,n){var r=t("lodash"),i=t("../utils/utils"),o=t("./eventifiedPromise.js"),a=t("./method.js"),s=t("../solidity/coder"),u=t("./formatters"),c=t("../utils/sha3"),l=t("./subscription.js"),f=function(t,e,n){var r=this,o=Array.prototype.slice.call(arguments);if(!(this instanceof f))throw new Error('Please use the "new" keyword to instantiate a web3.eth.contract() object!');if(!(t&&t instanceof Array))throw new Error("You must provide the json interface of the contract when instatiating a contract object.");this.options={},i.isObject(o[o.length-1])&&(n=o[o.length-1],this.options.data=n.data,this.options.from=n.from,this.options.gasPrice=n.gasPrice,this.options.gas=n.gas||n.gasLimit,i.isObject(e)&&(e=null)),Object.defineProperty(this.options,"address",{set:function(t){if(i.isAddress(t))this._address=t.toLowerCase();else if(t)throw new Error("The provided contract address is not a valid address.")},get:function(){return this._address},enumerable:!0}),Object.defineProperty(this.options,"jsonInterface",{set:function(t){return r.methods={},r.events={},r._jsonInterface=t.map(function(t){var e,n,o=t.inputs?t.inputs.map(function(t){return t.type}).join(","):"";if(t.name&&(n=t.name+"("+o+")"),"function"===t.type)t.signature="0x"+c(i.transformToFullName(t)).slice(0,8),e=r._createTxObject.bind({method:t,parent:r}),r.methods[t.name]||(r.methods[t.name]=e),r.methods[t.signature]=e,r.methods[n]=e;else if("event"===t.type){t.signature="0x"+c(i.transformToFullName(t));var a=r._on.bind(r,t.signature);r.events[t.name]&&"bound "!==r.events[t.name].name||(r.events[t.name]=a),r.events[t.signature]=a,r.events[n]=a}return t}),r.events.allEvents=r._on.bind(r,"allevents"),r._jsonInterface},get:function(){return r._jsonInterface},enumerable:!0}),this.methods={},this.events={},this._address=null,this._jsonInterface=[],this.options.address=e,this.options.jsonInterface=t};f.prototype._web3={},f.prototype._getCallback=function(t){if(i.isFunction(t[t.length-1]))return t.pop()},f.prototype._checkListener=function(t,e){if(e===t)throw new Error('The event "'+t+"\" is a reserved event name, you can't use it.")},f.prototype._fillWithDefaultOptions=function(t){return t.data=t.data||this.options.data,t.from=t.from||this.options.from,i.isAddress(t.from)&&(t.from=t.from.toLowerCase()),t.gasPrice=t.gasPrice||this.options.gasPrice,t.gas=t.gas||t.gasLimit||this.options.gas,delete t.gasLimit,t},f.prototype._encodeEventABI=function(t,e){e=e||{};var n=e.filter||{},r={};if(["fromBlock","toBlock"].filter(function(t){return void 0!==e[t]}).forEach(function(t){r[t]=u.inputBlockNumberFormatter(e[t])}),i.isArray(e.topics))r.topics=e.topics;else{if(r.topics=[],t&&!t.anonymous&&"ALLEVENTS"!==t.name&&r.topics.push(t.signature),"ALLEVENTS"!==t.name){var o=t.inputs.filter(function(t){return t.indexed===!0}).map(function(t){var e=n[t.name];return e?i.isArray(e)?e.map(function(e){return"0x"+s.encodeParam(t.type,e)}):"0x"+s.encodeParam(t.type,e):null});r.topics=r.topics.concat(o)}r.topics.length||delete r.topics}return r.address=this.options.address,r},f.prototype._decodeEventABI=function(t){var e=this;t.data=t.data||"",t.topics=t.topics||[];var n=u.outputLogFormatter(t);"ALLEVENTS"===e.name&&(e=e.jsonInterface.find(function(e){return e.signature===t.topics[0]})||{anonymous:!0}),e.inputs=e.inputs||[];var r=e.anonymous?t.topics:t.topics.slice(1),i=e.inputs.filter(function(t){return t.indexed===!0}).map(function(t){return t.type}),o=e.inputs.filter(function(t){return t.indexed===!1}).map(function(t){return t.type}),a=r.map(function(t){return t.slice(2)}).join(""),c=s.decodeParams(i,a),l=s.decodeParams(o,t.data.slice(2)),f=0;return n.returnValues=e.inputs.reduce(function(t,e){var n=e.name||f++;return t[n]=e.indexed?c.shift():l.shift(),t},{}),n.event=e.name,n},f.prototype._encodeMethodABI=function(){var t=this._method.signature,e=this.arguments,n=!1,r=this._parent.options.jsonInterface.filter(function(e){return"constructor"===t&&e.type===t||(e.signature===t||e.signature==="0x"+t.replace("0x","")||e.name===t)&&"function"===e.type}).map(function(t){if(t.inputs.length!==e.length)throw new Error("The number of arguments is not matching the methods required number. You need to pass "+t.inputs.length+" arguments.");return"function"===t.type&&(n=t.signature),t.inputs.map(function(t){return t.type})}).map(function(t){return s.encodeParams(t,e)})[0]||"";if("constructor"===t){if(!this._deployData)throw new Error("The contract has no contract data option set. This is necessary to append the constructor parameters.");return this._deployData+r}var i=n?n+r:r;if(i)return i;throw new Error("Couldn't find a matching contract method named \""+this._method.name+'".')},f.prototype._decodeMethodReturn=function(t,e){if(e){var n=t.map(function(t){return t.type});e=e.length>=2?e.slice(2):e;var r=s.decodeParams(n,e);return r=1===r.length?r[0]:r,"0x"===r&&(r=null),r}},f.prototype.deploy=function(t,e){if(t=t||{},t.arguments=t.arguments||[],t=this._fillWithDefaultOptions(t),!t.data)return i._fireError(new Error('No "data" specified in neither the given options, nor the default options.'),defer.promise,defer.reject,e);var n=r.find(this.options.jsonInterface,function(t){return"constructor"===t.type})||{};return n.signature="constructor",this._createTxObject.apply({method:n,parent:this,deployData:t.data},t.arguments)},f.prototype._generateEventOptions=function(){var t=Array.prototype.slice.call(arguments),e=this._getCallback(t),n=i.isObject(t[t.length-1])?t.pop():{},r=i.isString(t[0])?t[0]:"allevents";if(r="allevents"===r.toLowerCase()?{name:"ALLEVENTS",jsonInterface:this.options.jsonInterface}:this.options.jsonInterface.find(function(t){return"event"===t.type&&(t.name===r||t.signature==="0x"+r.replace("0x",""))}),!r)throw new Error('Event "'+r.name+"\" doesn't exist in this contract.");if(!i.isAddress(this.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return{params:this._encodeEventABI(r,n),event:r,callback:e}},f.prototype.once=function(t,e,n){var r=Array.prototype.slice.call(arguments);return n=this._getCallback(r),e&&delete e.fromBlock,this._on(t,e,function(t,e,r){r.unsubscribe(),i.isFunction(n)&&n(t,e)})},f.prototype._on=function(){var t=this._generateEventOptions.apply(this,arguments);this._checkListener("newListener",t.event.name,t.callback),this._checkListener("removeListener",t.event.name,t.callback);var e=new l({subscription:{params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(t.event)},subscribeMethod:"eth_subscribe",unsubscribeMethod:"eth_unsubscribe",requestManager:this._web3._requestManager});return e.subscribe("logs",t.params,t.callback||function(){}),e},f.prototype.getPastEvents=function(){var t=this._generateEventOptions.apply(this,arguments),e=new a({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[u.inputLogFormatter],outputFormatter:this._decodeEventABI.bind(t.event)});e.setRequestManager(this._web3._requestManager);var n=e.buildCall();return e=null,n(t.params,t.callback)},f.prototype._createTxObject=function(){var t={};return"function"===this.method.type&&(t.call=this.parent._executeMethod.bind(t,"call"),t.call.request=this.parent._executeMethod.bind(t,"call",!0)),t.send=this.parent._executeMethod.bind(t,"send"),t.send.request=this.parent._executeMethod.bind(t,"send",!0),t.encodeABI=this.parent._encodeMethodABI.bind(t),t.estimateGas=this.parent._executeMethod.bind(t,"estimate"),t.arguments=arguments,t._method=this.method,t._parent=this.parent,this.deployData&&(t._deployData=this.deployData),t},f.prototype._methodReturnCallback=function(t,e,n,r,o){var a=this,s=new Error("Failed to check for transaction receipt."),u=!1;return"call"===n&&(o=a._parent._decodeMethodReturn(a._method.outputs,o)),r?i._fireError(r,t.promise,t.reject,e):(e&&e(null,o),void("send"===n?(t.promise.emit("transactionHash",o),a._parent._web3.eth.subscribe("newBlocks",{},function(e,n,r){ return e?(r.unsubscribe(),u=!0,i._fireError(s,t.promise,t.reject)):void a._parent._web3.eth.getTransactionReceipt(o,function(e,n){if(e)return r.unsubscribe(),u=!0,i._fireError(s,t.promise,t.reject);if(!u&&n)if(a._deployData){if(!n.contractAddress)return u=!0,i._fireError(new Error("The transaction receipt didn't contain a contract address."),t.promise,t.reject);a._parent._web3.eth.getCode(n.contractAddress,function(e,o){if(o)return r.unsubscribe(),u=!0,o.length>2?(t.promise.emit("receipt",n),t.resolve(n),t.promise.removeAllListeners(),void 0):i._fireError(new Error("The contract code couldn't be stored, please check your gas limit."),t.promise,t.reject)})}else{if(r.unsubscribe(),u=!0,n.outOfGas)return i._fireError(new Error("Transaction ran out of gas."),t.promise,t.reject);t.promise.emit("receipt",n),t.resolve(n),t.promise.removeAllListeners()}})})):t.resolve(o)))},f.prototype._processExecuteArguments=function(t,e){var n={};if(n.type=t.shift(),n.callback=this._parent._getCallback(t),"call"===n.type&&t[t.length-1]!==!0&&(i.isString(t[t.length-1])||isFinite(t[t.length-1]))&&(n.defaultBlock=t.pop()),n.options=i.isObject(t[t.length-1])?t.pop():{},n.generateRequest=t[t.length-1]===!0&&t.pop(),n.options=this._parent._fillWithDefaultOptions(n.options),n.options.data=this.encodeABI(),!this._deployData&&!i.isAddress(this._parent.options.address))throw new Error("This contract object doesn't have address set yet, please set an address first.");return this._deployData||(n.options.to=this._parent.options.address),n.options.data?n:i._fireError(new Error("Couldn't find a matching contract method, or the number of parameters is wrong."),e.promise,e.reject,n.callback)},f.prototype._executeMethod=function(){var t=this._parent._processExecuteArguments.call(this,Array.prototype.slice.call(arguments),e),e=o("send"!==t.type);if(t.generateRequest){var n={params:[u.inputCallFormatter(t.options),u.inputDefaultBlockNumberFormatter(t.defaultBlock)],callback:t.callback};return"call"===t.type?(n.method="eth_call",n.format=this._parent._decodeMethodReturn.bind(null,this._method.outputs)):n.method="eth_sendTransaction",n}var a=this._parent._methodReturnCallback.bind(this,e,t.callback,t.type);switch(t.type){case"estimate":this._parent._web3.eth.estimateGas(t.options,a);break;case"call":this._parent._web3.eth.call(t.options,t.defaultBlock,a);break;case"send":if(!i.isAddress(t.options.from))return i._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'),e.promise,e.reject,t.callback);if(r.isBoolean(this._method.payable)&&!this._method.payable&&t.options.value&&t.options.value>0)return i._fireError(new Error("Can not send value to non-payable contract method or constructor"),e.promise,e.reject,t.callback);this._parent._web3.eth.sendTransaction(t.options,a)}return e.promise},e.exports=f},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./eventifiedPromise.js":26,"./formatters":28,"./method.js":31,"./subscription.js":45,lodash:85}],25:[function(t,e,n){e.exports={InvalidNumberOfParams:function(){return new Error("Invalid number of input parameters")},InvalidConnection:function(t){return new Error("CONNECTION ERROR: Couldn't connect to node "+t+".")},InvalidProvider:function(){return new Error("Provider not set or invalid")},InvalidResponse:function(t){var e=t&&t.error&&t.error.message?t.error.message:"Invalid JSON RPC response: "+JSON.stringify(t);return new Error(e)},ConnectionTimeout:function(t){return new Error("CONNECTION TIMEOUT: timeout of "+t+" ms achived")}}},{}],26:[function(t,e,n){var r=t("eventemitter3"),i=t("bluebird"),o=function(t){var e,n,o=new i(function(){e=arguments[0],n=arguments[1]});if(t)return{resolve:e,reject:n,promise:o};var a=new r;return o.emit=a.emit,o.on=a.on,o.once=a.once,o.off=a.off,o.listeners=a.listeners,o.addListener=a.addListener,o.removeListener=a.removeListener,o.removeAllListeners=a.removeAllListeners,{resolve:e,reject:n,promise:o}};e.exports=o},{bluebird:48,eventemitter3:84}],27:[function(t,e,n){var r=t("./formatters"),i=t("./../utils/utils"),o=t("./method"),a=t("./property"),s=function(t){var e=function(e){var n;e.property?(t[e.property]||(t[e.property]={}),n=t[e.property]):n=t,e.methods&&e.methods.forEach(function(e){e.attachToObject(n),e.setRequestManager(t._requestManager)}),e.properties&&e.properties.forEach(function(e){e.attachToObject(n),e.setRequestManager(t._requestManager)})};return e.formatters=r,e.utils=i,e.Method=o,e.Property=a,e};e.exports=s},{"./../utils/utils":20,"./formatters":28,"./method":31,"./property":39}],28:[function(t,e,n){var r=t("../utils/utils"),i=t("../utils/config"),o=t("./iban"),a=t("../utils/sha3"),s=function(t){return r.toBigNumber(t)},u=function(t){return"latest"===t||"pending"===t||"earliest"===t},c=function(t){return t?l(t):i.defaultBlock},l=function(t){if(void 0!==t)return u(t)?t:r.toHex(t)},f=function(t){return t.from=t.from||i.defaultAccount,t.from&&(t.from=b(t.from)),t.to&&(t.to=b(t.to)),["gasPrice","gas","gasLimit","value","nonce"].filter(function(e){return void 0!==t[e]}).forEach(function(e){t[e]=r.fromDecimal(t[e])}),t},p=function(t){if(t.from=t.from||i.defaultAccount,!t.from)throw new Error('The send transactions "from" field must be defined!');return t.from=b(t.from),t.to&&(t.to=b(t.to)),["gasPrice","gas","value","nonce"].filter(function(e){return void 0!==t[e]}).forEach(function(e){t[e]=r.fromDecimal(t[e])}),t},h=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),t.nonce=r.toDecimal(t.nonce),t.gas=r.toDecimal(t.gas),t.gasPrice=r.toBigNumber(t.gasPrice),t.value=r.toBigNumber(t.value),t},d=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),t.cumulativeGasUsed=r.toDecimal(t.cumulativeGasUsed),t.gasUsed=r.toDecimal(t.gasUsed),r.isArray(t.logs)&&(t.logs=t.logs.map(function(t){return y(t)})),t},v=function(t){return t.gasLimit=r.toDecimal(t.gasLimit),t.gasUsed=r.toDecimal(t.gasUsed),t.size=r.toDecimal(t.size),t.timestamp=r.toDecimal(t.timestamp),null!==t.number&&(t.number=r.toDecimal(t.number)),t.difficulty=r.toBigNumber(t.difficulty),t.totalDifficulty=r.toBigNumber(t.totalDifficulty),r.isArray(t.transactions)&&t.transactions.forEach(function(t){if(!r.isString(t))return h(t)}),t},_=function(t){var e=function(t){return null===t||"undefined"==typeof t?null:(t=String(t),0===t.indexOf("0x")?t:r.fromUtf8(t))};if(t.topics=t.topics||[],t.topics=t.topics.map(function(t){return r.isArray(t)?t.map(e):e(t)}),e=null,t.address&&!r.isAddress(t.address))throw new Error("The given address is not valid!");return t},y=function(t){return t.id="log_"+a(t.blockHash.replace("0x","")+t.transactionHash.replace("0x","")+t.logIndex.replace("0x","")).substr(0,8),null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),null!==t.logIndex&&(t.logIndex=r.toDecimal(t.logIndex)),t},m=function(t){return t.ttl=r.fromDecimal(t.ttl),t.workToProve=r.fromDecimal(t.workToProve),t.priority=r.fromDecimal(t.priority),r.isArray(t.topics)||(t.topics=t.topics?[t.topics]:[]),t.topics=t.topics.map(function(t){return 0===t.indexOf("0x")?t:r.fromUtf8(t)}),t},g=function(t){return t.expiry=r.toDecimal(t.expiry),t.sent=r.toDecimal(t.sent),t.ttl=r.toDecimal(t.ttl),t.workProved=r.toDecimal(t.workProved),t.topics||(t.topics=[]),t.topics=t.topics.map(function(t){return r.toAscii(t)}),t},b=function(t){var e=new o(t);if(e.isValid()&&e.isDirect())return"0x"+e.address();if(r.isStrictAddress(t))return t;if(r.isAddress(t))return"0x"+t;throw new Error("invalid address")},w=function(t){return t.startingBlock=r.toDecimal(t.startingBlock),t.currentBlock=r.toDecimal(t.currentBlock),t.highestBlock=r.toDecimal(t.highestBlock),t.knownStates&&(t.knownStates=r.toDecimal(t.knownStates),t.pulledStates=r.toDecimal(t.pulledStates)),t};e.exports={inputDefaultBlockNumberFormatter:c,inputBlockNumberFormatter:l,inputCallFormatter:f,inputTransactionFormatter:p,inputAddressFormatter:b,inputPostFormatter:m,inputLogFormatter:_,outputBigNumberFormatter:s,outputTransactionFormatter:h,outputTransactionReceiptFormatter:d,outputBlockFormatter:v,outputLogFormatter:y,outputPostFormatter:g,outputSyncingFormatter:w}},{"../utils/config":18,"../utils/sha3":19,"../utils/utils":20,"./iban":29}],29:[function(t,e,n){var r=t("bignumber.js"),i=function(t,e){for(var n=t;n.length<2*e;)n="0"+n;return n},o=function(t){var e="A".charCodeAt(0),n="Z".charCodeAt(0);return t=t.toUpperCase(),t=t.substr(4)+t.substr(0,4),t.split("").map(function(t){var r=t.charCodeAt(0);return r>=e&&r<=n?r-e+10:t}).join("")},a=function(t){for(var e,n=t;n.length>2;)e=n.slice(0,9),n=parseInt(e,10)%97+n.slice(e.length);return parseInt(n,10)%97},s=function(t){this._iban=t};s.fromAddress=function(t){var e=new r(t,16),n=e.toString(36),o=i(n,15);return s.fromBban(o.toUpperCase())},s.fromBban=function(t){var e="XE",n=a(o(e+"00"+t)),r=("0"+(98-n)).slice(-2);return new s(e+r+t)},s.createIndirect=function(t){return s.fromBban("ETH"+t.institution+t.identifier)},s.isValid=function(t){var e=new s(t);return e.isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(o(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.address=function(){if(this.isDirect()){var t=this._iban.substr(4),e=new r(t,36);return i(e.toString(16),20)}return""},s.prototype.toString=function(){return this._iban},e.exports=s},{"bignumber.js":"bignumber.js"}],30:[function(t,e,n){var r={messageId:0};r.toPayload=function(t,e){return t||console.error("jsonrpc method should be specified!"),r.messageId++,{jsonrpc:"2.0",id:r.messageId,method:t,params:e||[]}},r.isValidResponse=function(t){function e(t){return!!t&&!t.error&&"2.0"===t.jsonrpc&&"number"==typeof t.id&&void 0!==t.result}return Array.isArray(t)?t.every(e):e(t)},r.toBatchPayload=function(t){return t.map(function(t){return r.toPayload(t.method,t.params)})},e.exports=r},{}],31:[function(t,e,n){var r=t("../utils/utils"),i=t("./errors"),o=t("bluebird"),a=function(t){this.name=t.name,this.call=t.call,this.params=t.params||0,this.inputFormatter=t.inputFormatter,this.outputFormatter=t.outputFormatter,this.requestManager=null};a.prototype.setRequestManager=function(t){this.requestManager=t},a.prototype.getCall=function(t){return r.isFunction(this.call)?this.call(t):this.call},a.prototype.extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},a.prototype.validateArgs=function(t){if(t.length!==this.params)throw i.InvalidNumberOfParams()},a.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter.map(function(e,n){return e?e(t[n]):t[n]}):t},a.prototype.formatOutput=function(t){var e=this;return r.isArray(t)?t.map(function(t){return e.outputFormatter&&t?e.outputFormatter(t):t}):this.outputFormatter&&t?this.outputFormatter(t):t},a.prototype.toPayload=function(t){var e=this.getCall(t),n=this.extractCallback(t),r=this.formatInput(t);return this.validateArgs(r),{method:e,params:r,callback:n}},a.prototype.attachToObject=function(t){var e=this.buildCall();e.call=this.call;var n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},t[n[0]][n[1]]=e):t[n[0]]=e},a.prototype.buildCall=function(){var t=this,e=function(){var e,n,i=new o(function(){e=arguments[0],n=arguments[1]}),a=t.toPayload(Array.prototype.slice.call(arguments));return t.requestManager.send(a,function(i,o){return o=t.formatOutput(o),i?r._fireError(i,null,n,a.callback):(a.callback&&a.callback(null,o),void e(o))}),i};return e.request=this.request.bind(this),e},a.prototype.request=function(){var t=this.toPayload(Array.prototype.slice.call(arguments));return t.format=this.formatOutput.bind(this),t},e.exports=a},{"../utils/utils":20,"./errors":25,bluebird:48}],32:[function(t,e,n){var r=t("../method"),i=function(t){this._requestManager=t._requestManager;var e=this;o().forEach(function(n){n.attachToObject(e),n.setRequestManager(t._requestManager)})},o=function(){var t=new r({name:"putString",call:"db_putString",params:3}),e=new r({name:"getString",call:"db_getString",params:2}),n=new r({name:"putHex",call:"db_putHex",params:3}),i=new r({name:"getHex",call:"db_getHex",params:2});return[t,e,n,i]};e.exports=i},{"../method":31}],33:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;g().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),b().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),this.contract=l,this.contract.prototype._web3=t,this.iban=p,this.sendIBANTransaction=h.bind(null,this),this.namereg=function(){return this.contract(f.global.abi).at(f.global.address)},this.icapNamereg=function(){return this.contract(f.icap.abi).at(f.icap.address)}}var i=t("../formatters"),o=t("../../utils/utils"),a=t("../../utils/config"),s=t("../method"),u=t("../property"),c=t("../subscriptions"),l=t("../contract"),f=t("../namereg"),p=t("../iban"),h=t("../transfer"),d=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},v=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},_=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},y=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},m=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"};Object.defineProperty(r.prototype,"defaultBlock",{get:function(){return a.defaultBlock},set:function(t){return a.defaultBlock=t,t}}),Object.defineProperty(r.prototype,"defaultAccount",{get:function(){return a.defaultAccount},set:function(t){return a.defaultAccount=t,t}});var g=function(){var t=new s({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[i.inputAddressFormatter,i.inputDefaultBlockNumberFormatter],outputFormatter:i.outputBigNumberFormatter}),e=new s({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[null,o.toHex,i.inputDefaultBlockNumberFormatter]}),n=new s({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[i.inputAddressFormatter,i.inputDefaultBlockNumberFormatter]}),r=new s({name:"getBlock",call:d,params:2,inputFormatter:[i.inputBlockNumberFormatter,function(t){return!!t}],outputFormatter:i.outputBlockFormatter}),a=new s({name:"getUncle",call:_,params:2,inputFormatter:[i.inputBlockNumberFormatter,o.toHex],outputFormatter:i.outputBlockFormatter}),u=new s({name:"getBlockTransactionCount",call:y,params:1,inputFormatter:[i.inputBlockNumberFormatter],outputFormatter:o.toDecimal}),l=new s({name:"getBlockUncleCount",call:m,params:1,inputFormatter:[i.inputBlockNumberFormatter],outputFormatter:o.toDecimal}),f=new s({name:"getTransaction",call:"eth_getTransactionByHash",params:1,outputFormatter:i.outputTransactionFormatter}),p=new s({name:"getTransactionFromBlock",call:v,params:2,inputFormatter:[i.inputBlockNumberFormatter,o.toHex],outputFormatter:i.outputTransactionFormatter}),h=new s({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,outputFormatter:i.outputTransactionReceiptFormatter}),g=new s({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[null,i.inputDefaultBlockNumberFormatter],outputFormatter:o.toDecimal}),b=new s({name:"sendRawTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),w=new s({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[i.inputTransactionFormatter]}),k=new s({name:"sign",call:"eth_sign",params:2,inputFormatter:[i.inputAddressFormatter,null]}),x=new s({name:"call",call:"eth_call",params:2,inputFormatter:[i.inputCallFormatter,i.inputDefaultBlockNumberFormatter]}),C=new s({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[i.inputCallFormatter],outputFormatter:o.toDecimal}),j=new s({name:"getCompilers",call:"eth_getCompilers",params:0}),E=new s({name:"compile.solidity",call:"eth_compileSolidity",params:1}),F=new s({name:"compile.lll",call:"eth_compileLLL",params:1}),S=new s({name:"compile.serpent",call:"eth_compileSerpent",params:1}),A=new s({name:"submitWork",call:"eth_submitWork",params:3}),B=new s({name:"getWork",call:"eth_getWork",params:0}),O=new s({name:"getPastLogs",call:"eth_getLogs",params:1,inputFormatter:[i.inputLogFormatter],outputFormatter:i.outputLogFormatter}),T=new c({name:"subscribe",subscribe:"eth_subscribe",unsubscribe:"eth_unsubscribe",subscriptions:{newBlocks:{params:1,outputFormatter:i.outputBlockFormatter},pendingTransactions:{params:0,outputFormatter:i.outputTransactionFormatter},logs:{params:1,inputFormatter:[i.inputLogFormatter],outputFormatter:i.outputLogFormatter},syncing:{params:0,outputFormatter:i.outputSyncingFormatter}}});return[t,e,n,r,a,j,u,l,f,p,h,g,x,C,b,w,k,E,F,S,A,B,T,O]},b=function(){return[new u({name:"coinbase",getter:"eth_coinbase"}),new u({name:"mining",getter:"eth_mining"}),new u({name:"hashrate",getter:"eth_hashrate",outputFormatter:o.toDecimal}),new u({name:"syncing",getter:"eth_syncing",outputFormatter:i.outputSyncingFormatter}),new u({name:"gasPrice",getter:"eth_gasPrice",outputFormatter:i.outputBigNumberFormatter}),new u({name:"accounts",getter:"eth_accounts"}),new u({name:"blockNumber",getter:"eth_blockNumber",outputFormatter:o.toDecimal}),new u({name:"protocolVersion",getter:"eth_protocolVersion"})]};e.exports=r},{"../../utils/config":18,"../../utils/utils":20,"../contract":24,"../formatters":28,"../iban":29,"../method":31,"../namereg":38,"../property":39,"../subscriptions":46,"../transfer":47}],34:[function(t,e,n){var r=t("../../utils/utils"),i=t("../property"),o=function(t){this._requestManager=t._requestManager;var e=this;a().forEach(function(n){n.attachToObject(e),n.setRequestManager(t._requestManager)})},a=function(){return[new i({name:"listening",getter:"net_listening"}),new i({name:"peerCount",getter:"net_peerCount",outputFormatter:r.toDecimal})]};e.exports=o},{"../../utils/utils":20,"../property":39}],35:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),u().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})}var i=t("../method"),o=t("../property"),a=t("../formatters"),s=function(){var t=new i({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null]}),e=new i({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[a.inputAddressFormatter,null,null]}),n=new i({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[a.inputTransactionFormatter,null]}),r=new i({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[a.inputAddressFormatter]});return[t,e,n,r]},u=function(){return[new o({name:"listAccounts",getter:"personal_listAccounts"})]};e.exports=r},{"../formatters":28,"../method":31,"../property":39}],36:[function(t,e,n){var r=t("../method"),i=t("../formatters"),o=t("../subscriptions"),a=function(t){this._requestManager=t._requestManager;var e=this;s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})},s=function(){var t=new r({name:"post",call:"shh_post",params:1,inputFormatter:[i.inputPostFormatter]}),e=new r({name:"newIdentity",call:"shh_newIdentity",params:0}),n=new r({name:"hasIdentity",call:"shh_hasIdentity",params:1}),a=new r({name:"newGroup",call:"shh_newGroup",params:0}),s=new r({name:"addToGroup",call:"shh_addToGroup",params:0}),u=new r({name:"getPastMessages",call:"shh_getMessages",params:1,inputFormatter:[i.inputLogFormatter],outputFormatter:i.outputPostFormatter}),c=new o({name:"subscribe",subscribe:"shh_subscribe",unsubscribe:"shh_unsubscribe",subscriptions:{messages:{params:1,inputFormatter:[i.inputLogFormatter],outputFormatter:i.outputPostFormatter}}});return[t,e,n,a,s,u,c]};e.exports=a},{"../formatters":28,"../method":31,"../subscriptions":46}],37:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;a().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})}var i=t("../method"),o=t("../property"),a=function(){var t=new i({name:"blockNetworkRead",call:"bzz_blockNetworkRead",params:1,inputFormatter:[null]}),e=new i({name:"syncEnabled",call:"bzz_syncEnabled",params:1,inputFormatter:[null]}),n=new i({name:"swapEnabled",call:"bzz_swapEnabled",params:1,inputFormatter:[null]}),r=new i({name:"download",call:"bzz_download",params:2,inputFormatter:[null,null]}),o=new i({name:"upload",call:"bzz_upload",params:2,inputFormatter:[null,null]}),a=new i({name:"retrieve",call:"bzz_retrieve",params:1,inputFormatter:[null]}),s=new i({name:"store",call:"bzz_store",params:2,inputFormatter:[null,null]}),u=new i({name:"get",call:"bzz_get",params:1,inputFormatter:[null]}),c=new i({name:"put",call:"bzz_put",params:2,inputFormatter:[null,null]}),l=new i({name:"modify",call:"bzz_modify",params:4,inputFormatter:[null,null,null,null]});return[t,e,n,r,o,a,s,u,c,l]},s=function(){return[new o({name:"hive",getter:"bzz_hive"}),new o({name:"info",getter:"bzz_info"})]};e.exports=r},{"../method":31,"../property":39}],38:[function(t,e,n){var r=t("../contracts/GlobalRegistrar.json"),i=t("../contracts/ICAPRegistrar.json"),o="0xc6d9d2cd449a754c494264e1809c50e34d64562b",a="0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00";e.exports={global:{abi:r,address:o},icap:{abi:i,address:a}}},{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],39:[function(t,e,n){var r=t("../utils/utils"),i=function(t){this.name=t.name,this.getter=t.getter,this.setter=t.setter,this.outputFormatter=t.outputFormatter,this.inputFormatter=t.inputFormatter,this.requestManager=null};i.prototype.setRequestManager=function(t){this.requestManager=t},i.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter(t):t},i.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t&&void 0!==t?this.outputFormatter(t):t},i.prototype.extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},i.prototype.attachToObject=function(t){var e={get:this.buildGet(),enumerable:!0},n=this.name.split("."),r=n[0];n.length>1&&(t[n[0]]=t[n[0]]||{},t=t[n[0]],r=n[1]),Object.defineProperty(t,r,e),t[o(r)]=this.buildAsyncGet()};var o=function(t){return"get"+t.charAt(0).toUpperCase()+t.slice(1)};i.prototype.buildGet=function(){var t=this;return function(){return t.formatOutput(t.requestManager.sendSync({method:t.getter}))}},i.prototype.buildAsyncGet=function(){var t=this,e=function(e){t.requestManager.send({method:t.getter},function(n,r){e(n,t.formatOutput(r))})};return e.request=this.request.bind(this),e},i.prototype.request=function(){var t={method:this.getter,params:[],callback:this.extractCallback(Array.prototype.slice.call(arguments))};return t.format=this.formatOutput.bind(this),t},e.exports=i},{"../utils/utils":20}],40:[function(t,e,n){var r=t("../errors");"undefined"!=typeof window&&window.XMLHttpRequest?XMLHttpRequest=window.XMLHttpRequest:XMLHttpRequest=t("xmlhttprequest").XMLHttpRequest;var i=t("xhr2"),o=function(t,e){this.host=t||"http://localhost:8545",this.timeout=e||0};o.prototype.prepareRequest=function(t){var e;return t?(e=new i,e.timeout=this.timeout):e=new XMLHttpRequest,e.open("POST",this.host,t),e.setRequestHeader("Content-Type","application/json"),e},o.prototype.sendSync=function(t){var e=this.prepareRequest(!1);try{e.send(JSON.stringify(t))}catch(t){throw r.InvalidConnection(this.host)}var n=e.responseText;try{n=JSON.parse(n)}catch(t){throw r.InvalidResponse(e.responseText)}return n},o.prototype.send=function(t,e){var n=this.prepareRequest(!0);n.onreadystatechange=function(){if(4===n.readyState&&1!==n.timeout){var t=n.responseText,i=null;try{t=JSON.parse(t)}catch(t){i=r.InvalidResponse(n.responseText)}e(i,t)}},n.ontimeout=function(){e(r.ConnectionTimeout(this.timeout))};try{n.send(JSON.stringify(t))}catch(t){e(r.InvalidConnection(this.host))}},o.prototype.isConnected=function(){try{return this.sendSync({id:9999999999,jsonrpc:"2.0",method:"net_listening",params:[]}),!0}catch(t){return!1}},e.exports=o},{"../errors":25,xhr2:87,xmlhttprequest:17}],41:[function(t,e,n){"use strict";var r=t("../../utils/utils"),i=t("../errors"),o=function(t,e){var n=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=t,this.connection=e.connect({path:this.path}),this.addDefaultEvents(),this.connection.on("data",function(t){n._parseResponse(t.toString()).forEach(function(t){var e=null;r.isArray(t)?t.forEach(function(t){n.responseCallbacks[t.id]&&(e=t.id)}):e=t.id,e||"eth_subscription"!==t.method?n.responseCallbacks[e]&&(n.responseCallbacks[e](null,t),delete n.responseCallbacks[e]):n.notificationCallbacks.forEach(function(e){r.isFunction(e)&&e(null,t)})})})};o.prototype.addDefaultEvents=function(){var t=this;this.connection.on("connect",function(){}),this.connection.on("error",function(){t._timeout()}),this.connection.on("end",function(){t._timeout(),t.notificationCallbacks.forEach(function(t){r.isFunction(t)&&t(new Error("IPC socket connection closed"))})}),this.connection.on("timeout",function(){t._timeout()})},o.prototype._parseResponse=function(t){var e=this,n=[],r=t.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|");return r.forEach(function(t){e.lastChunk&&(t=e.lastChunk+t);var r=null;try{r=JSON.parse(t)}catch(n){return e.lastChunk=t,clearTimeout(e.lastChunkTimeout),void(e.lastChunkTimeout=setTimeout(function(){throw e._timeout(),i.InvalidResponse(t)},15e3))}clearTimeout(e.lastChunkTimeout),e.lastChunk=null,r&&n.push(r)}),n},o.prototype._addResponseCallback=function(t,e){var n=t.id||t[0].id,r=t.method||t[0].method;this.responseCallbacks[n]=e,this.responseCallbacks[n].method=r},o.prototype._timeout=function(){for(var t in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(t)&&(this.responseCallbacks[t](i.InvalidConnection("on IPC")),delete this.responseCallbacks[t])},o.prototype.reconnect=function(){this.connection.connect({path:this.path})},o.prototype.isConnected=function(){var t=this;return t.connection.writable||t.connection.connect({path:t.path}),!!this.connection.writable},o.prototype.sendSync=function(t){if(this.connection.writeSync){var e;this.connection.writable||this.connection.connect({path:this.path});var n=this.connection.writeSync(JSON.stringify(t));try{e=JSON.parse(n)}catch(t){throw i.InvalidResponse(n)}return e}throw new Error('You tried to send "'+t.method+'" synchronously. Synchronous requests are not supported by the IPC provider.')},o.prototype.send=function(t,e){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(t)),this._addResponseCallback(t,e)},o.prototype.on=function(t,e){if("function"!=typeof e)throw new Error("The second parameter callback must be a function.");switch(t){case"notification":this.notificationCallbacks.push(e);break;default:this.connection.on(t,e)}},o.prototype.once=function(t,e){if("function"!=typeof e)throw new Error("The second parameter callback must be a function.");this.connection.once(t,e)},o.prototype.removeListener=function(t,e){var n=this;switch(t){case"notification":this.notificationCallbacks.forEach(function(t,r){t===e&&n.notificationCallbacks.splice(r,1)});break;default:this.connection.removeListener(t,e)}},o.prototype.removeAllListeners=function(t){switch(t){case"notification":this.notificationCallbacks=[];break;default:this.connection.removeAllListeners(t)}},o.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.connection.removeAllListeners("error"),this.connection.removeAllListeners("end"),this.connection.removeAllListeners("timeout"),this.addDefaultEvents()},e.exports=o},{"../../utils/utils":20,"../errors":25}],42:[function(t,e,n){"use strict";var r=t("../../utils/utils"),i=t("../errors"),o=function(t){var e=this;this.responseCallbacks={},this.notificationCallbacks=[],this.path=t,this.connection=new WebSocket(t),this.addDefaultEvents(),this.connection.onmessage=function(t){var n="string"==typeof t.data?t.data:"";e._parseResponse(n).forEach(function(t){var n=null;r.isArray(t)?t.forEach(function(t){e.responseCallbacks[t.id]&&(n=t.id)}):n=t.id,n||"eth_subscription"!==t.method?e.responseCallbacks[n]&&(e.responseCallbacks[n](null,t),delete e.responseCallbacks[n]):e.notificationCallbacks.forEach(function(e){r.isFunction(e)&&e(null,t)})})}};o.prototype.addDefaultEvents=function(){var t=this;this.connection.onerror=function(){t._timeout()},this.connection.onclose=function(e){t._timeout();var n=t.notificationCallbacks;t.reset(),n.forEach(function(t){r.isFunction(t)&&t(e)})}},o.prototype._parseResponse=function(t){var e=this,n=[],r=t.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|");return r.forEach(function(t){e.lastChunk&&(t=e.lastChunk+t);var r=null;try{r=JSON.parse(t)}catch(n){return e.lastChunk=t,clearTimeout(e.lastChunkTimeout),void(e.lastChunkTimeout=setTimeout(function(){throw e._timeout(),i.InvalidResponse(t)},15e3))}clearTimeout(e.lastChunkTimeout),e.lastChunk=null,r&&n.push(r)}),n},o.prototype._addResponseCallback=function(t,e){var n=t.id||t[0].id,r=t.method||t[0].method;this.responseCallbacks[n]=e,this.responseCallbacks[n].method=r},o.prototype._timeout=function(){for(var t in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(t)&&(this.responseCallbacks[t](i.InvalidConnection("on IPC")),delete this.responseCallbacks[t])},o.prototype.isConnected=function(){console.log(this.connection)},o.prototype.sendSync=function(t){throw new Error('You tried to send "'+t.method+'" synchronously. Synchronous requests are not supported by the Websocket provider.')},o.prototype.send=function(t,e){this.connection.send(JSON.stringify(t)),this._addResponseCallback(t,e)},o.prototype.on=function(t,e){if("function"!=typeof e)throw new Error("The second parameter callback must be a function.");switch(t){case"notification":this.notificationCallbacks.push(e);break;case"connect":this.connection.onopen=e}},o.prototype.removeListener=function(t,e){var n=this;switch(t){case"notification":this.notificationCallbacks.forEach(function(t,r){t===e&&n.notificationCallbacks.splice(r,1)})}},o.prototype.removeAllListeners=function(t){switch(t){case"notification":this.notificationCallbacks=[];break;case"connect":this.connection.onopen=null}},o.prototype.reset=function(){this._timeout(),this.notificationCallbacks=[],this.addDefaultEvents()},e.exports=o},{"../../utils/utils":20,"../errors":25}],43:[function(t,e,n){var r=t("./jsonrpc"),i=t("../utils/utils"),o=t("./errors"),a=function(t){this.setProvider(t),this.subscriptions={}};a.prototype.sendSync=function(t){if(!this.provider)return console.error(o.InvalidProvider()),null;var e=r.toPayload(t.method,t.params),n=this.provider.sendSync(e);if(!r.isValidResponse(n))throw o.InvalidResponse(n);return n.result},a.prototype.send=function(t,e){if(e=e||function(){},!this.provider)return e(o.InvalidProvider());var n=r.toPayload(t.method,t.params);this.provider.send(n,function(t,i){return n.id!==i.id?e(new Error('Wrong response id "'+i.id+'" (expected: "'+n.id+'") in '+JSON.stringify(n))):t?e(t):r.isValidResponse(i)?void e(null,i.result):e(o.InvalidResponse(i)); })},a.prototype.sendBatch=function(t,e){if(!this.provider)return e(o.InvalidProvider());var n=r.toBatchPayload(t);this.provider.send(n,function(t,n){return t?e(t):i.isArray(n)?void e(t,n):e(o.InvalidResponse(n))})},a.prototype.addSubscription=function(t,e,n,r){if(!this.provider.on)throw new Error("This provider doesn't support subscriptions",this.provider);this.subscriptions[t]={callback:r,type:n,name:e}},a.prototype.removeSubscription=function(t,e){var n=this;this.subscriptions[t]&&(this.send({method:this.subscriptions[t].type+"_unsubscribe",params:[t]},e),delete n.subscriptions[t])},a.prototype.setProvider=function(t){var e=this;this.provider&&this.reset(),this.provider=t,this.provider&&this.provider.on&&this.provider.on("notification",function(t,n){t?Object.keys(e.subscriptions).forEach(function(n){e.subscriptions[n].callback&&e.subscriptions[n].callback(t)}):e.subscriptions[n.params.subscription]&&e.subscriptions[n.params.subscription].callback&&e.subscriptions[n.params.subscription].callback(null,n.params.result)})},a.prototype.reset=function(t){var e=this;Object.keys(this.subscriptions).forEach(function(n){t&&"syncing"===e.subscriptions[n].name||e.removeSubscription(n)}),this.provider.reset&&this.provider.reset()},e.exports=a},{"../utils/utils":20,"./errors":25,"./jsonrpc":30}],44:[function(t,e,n){var r=function(){this.defaultBlock="latest",this.defaultAccount=void 0};e.exports=r},{}],45:[function(t,e,n){var r=t("../utils/utils"),i=t("./errors"),o=t("eventemitter3"),a=function(t){var e=new o;this.id=null,this.callback=null,this._reconnectIntervalId=null,this.options={subscription:t.subscription,subscribeMethod:t.subscribeMethod,unsubscribeMethod:t.unsubscribeMethod,requestManager:t.requestManager},this.emit=e.emit,this.on=e.on,this.once=e.once,this.off=e.off,this.listeners=e.listeners,this.listenerCount=e.listenerCount,this.addListener=e.addListener,this.removeListener=e.removeListener,this.removeAllListeners=e.removeAllListeners,this.setMaxListeners=e.setMaxListeners,this.getMaxListeners=e.getMaxListeners};a.prototype._extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},a.prototype._validateArgs=function(t){var e=this.options.subscription;if(e||(e={}),e.params||(e.params=0),t.length!==e.params+1)throw i.InvalidNumberOfParams()},a.prototype._formatInput=function(t){var e=this.options.subscription;if(!e||!e.inputFormatter)return t;var n=e.inputFormatter.map(function(e,n){return e?e(t[n+1]):t[n+1]});return n.unshift(t[0]),n},a.prototype._formatOutput=function(t){var e=this.options.subscription;return e&&e.outputFormatter&&t?e.outputFormatter(t):t},a.prototype._toPayload=function(t){this.callback=this._extractCallback(t);var e=this._formatInput(t);return this._validateArgs(e),{method:this.options.subscribeMethod,params:e}},a.prototype.unsubscribe=function(t){this.options.requestManager.removeSubscription(this.id,t),this.id=null,this.removeAllListeners(),clearInterval(this._reconnectIntervalId)},a.prototype.subscribe=function(){var t=this,e=arguments,n=this._toPayload(Array.prototype.slice.call(arguments));if(!this.options.requestManager.provider.on)throw new Error("The current provider doesn't support subscriptions",this.options.requestManager.provider);if(this.options.params=n.params[1],"logs"===n.params[0]&&r.isObject(n.params[1])&&n.params[1].hasOwnProperty("fromBlock")&&isFinite(n.params[1].fromBlock)&&this.options.requestManager.send({method:"eth_getLogs",params:[n.params[1]]},function(e,n){e?(t.callback(e,null,t),t.emit("error",e)):n.forEach(function(e){var n=t._formatOutput(e);t.callback(null,n,t),t.emit("data",n)})}),t.callback)return"object"==typeof n.params[1]&&delete n.params[1].fromBlock,this.options.requestManager.send(n,function(i,o){!i&&o?(t.id=o,t.options.requestManager.addSubscription(t.id,n.params[0],"eth",function(n,i){r.isArray(i)&&(i=i[0]);var o=t._formatOutput(i);n?(t.options.requestManager.removeSubscription(t.id),t.options.requestManager.provider.once&&(t._reconnectIntervalId=setInterval(function(){t.options.requestManager.provider.reconnect()},500),t.options.requestManager.provider.once("connect",function(){clearInterval(t._reconnectIntervalId),t.subscribe.apply(t,e)})),t.emit("error",n)):o.removed?t.emit("changed",o):t.emit("data",o),t.callback(n,o,t)})):t.callback(i,null,t)}),this;throw new Error("Subscriptions require a callback as the last parameter!")},e.exports=a},{"../utils/utils":20,"./errors":25,eventemitter3:84}],46:[function(t,e,n){var r=t("./subscription.js"),i=function(t){this.name=t.name,this.subscribe=t.subscribe,this.unsubscribe=t.unsubscribe,this.subscriptions=t.subscriptions||{},this.requestManager=null};i.prototype.setRequestManager=function(t){this.requestManager=t},i.prototype.attachToObject=function(t){var e=this.buildCall();e.call=this.call;var n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},t[n[0]][n[1]]=e):t[n[0]]=e},i.prototype.buildCall=function(){var t=this;return function(){var e=new r({subscription:t.subscriptions[arguments[0]],subscribeMethod:t.subscribe,unsubscribeMethod:t.unsubscribe,requestManager:t.requestManager});return e.subscribe.apply(e,arguments)}},e.exports=i},{"./subscription.js":45}],47:[function(t,e,n){var r=t("./iban"),i=t("../contracts/SmartExchange.json"),o=function(t,e,n,i,o){var u=new r(n);if(!u.isValid())throw new Error("invalid iban address");if(u.isDirect())return a(t,e,u.address(),i,o);if(!o){var c=t.icapNamereg().addr(u.institution());return s(t,e,c,i,u.client())}t.icapNamereg().addr(u.institution(),function(n,r){return s(t,e,r,i,u.client(),o)})},a=function(t,e,n,r,i){return t.sendTransaction({address:n,from:e,value:r},i)},s=function(t,e,n,r,o,a){var s=i;return t.contract(s).at(n).deposit(o,{from:e,value:r},a)};e.exports=o},{"../contracts/SmartExchange.json":3,"./iban":29}],48:[function(t,e,n){!function(t){if("object"==typeof n&&"undefined"!=typeof e)e.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;"undefined"!=typeof window?r=window:"undefined"!=typeof global?r=global:"undefined"!=typeof self&&(r=self),r.Promise=t()}}(function(){var t,e,n;return function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof _dereq_&&_dereq_;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof _dereq_&&_dereq_,a=0;a0;){var e=t.shift();if("function"==typeof e){var n=t.shift(),r=t.shift();e.call(n,r)}else e._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=s},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,o=function(t,e){this._reject(e)},a=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},s=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},u=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var c=n(o),l=new t(e);l._propagateFrom(this,1);var f=this._target();if(l._setBoundTo(c),c instanceof t){var p={promiseRejectionQueued:!1,promise:l,target:f,bindingPromise:c};f._then(e,a,void 0,l,p),c._then(s,u,void 0,l,p),l._setOnCancel(c)}else l._resolveCallback(f);return l},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=this._bitField&-2097153},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],4:[function(t,e,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=r,e.exports=o},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var i=r(null),o=r(null);i[" size"]=o[" size"]=0}e.exports=function(e){function n(t,n){var r;if(null!=t&&(r=t[n]),"function"!=typeof r){var i="Object "+s.classString(t)+" has no method '"+s.toString(n)+"'";throw new e.TypeError(i)}return r}function r(t){var e=this.pop(),r=n(t,e);return r.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return e<0&&(e=Math.max(0,e+t.length)),t[e]}var a,s=t("./util"),u=s.canEvaluate;s.isIdentifier;e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(r,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e,n="number"==typeof t;if(n)e=o;else if(u){var r=a(t);e=null!==r?r:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util"),a=o.tryCatch,s=o.errorObj,u=e._async;e.prototype.break=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),!!this._enoughBranchesHaveCancelled()&&(this._invokeOnCancel(),!0))},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),u.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var n=0;n=0)return o[t]}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=n,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var n=t.prototype._pushContext,o=t.prototype._popContext,a=t._peekContext,s=t.prototype._peekContext,u=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=o,t._peekContext=a,t.prototype._peekContext=s,t.prototype._promiseCreated=u,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=r,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],9:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,e){return{promise:e}}function i(){return!1}function o(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+N.toString(t));r._attachCancellationCallback(t)})}catch(t){return t}}function a(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?N.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function s(){return this._onCancelField}function u(t){this._onCancelField=t}function c(){this._cancellationParent=void 0,this._onCancelField=void 0}function l(t,e){if(0!==(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function f(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function p(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function h(){this._trace=new O(this._peekContext())}function d(t,e){if(L(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=x(t);N.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),N.notEnumerableProp(t,"__stackCleaned__",!0)}}}function v(t,e,n,r,i){if(void 0===t&&null!==e&&X){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var o="",a="";if(e._trace){for(var s=e._trace.stack.split("\n"),u=w(s),c=u.length-1;c>=0;--c){var l=u[c];if(!z.test(l)){var f=l.match(q);f&&(o="at "+f[1]+":"+f[2]+":"+f[3]+" ");break}}if(u.length>0)for(var p=u[0],c=0;c0&&(a="\n"+s[c-1]);break}}var h="a promise was created in a "+n+"handler "+o+"but was not returned from it, see http://goo.gl/rRqMUw"+a;r._warn(h,!0,e)}}function _(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),y(n)}function y(t,n,r){if(ot.warnings){var i,o=new M(t);if(n)r._attachExtraTrace(o);else if(ot.longStackTraces&&(i=e._peekContext()))i.attachExtraTrace(o);else{var a=x(o);o.stack=a.message+"\n"+a.stack.join("\n")}tt("warning",o)||C(o,"",!0)}}function m(t,e){for(var n=0;n=0;--s)if(r[s]===o){a=s;break}for(var s=a;s>=0;--s){var u=r[s];if(e[i]!==u)break;e.pop(),i--}e=r}}function w(t){for(var e=[],n=0;n0&&"SyntaxError"!=t.name&&(e=e.slice(n)),e}function x(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&e.length>0?k(t):[" (No stack trace)"],{message:n,stack:"SyntaxError"==t.name?e:w(e)}}function C(t,e,n){if("undefined"!=typeof console){var r;if(N.isObject(t)){var i=t.stack;r=e+W(i,t)}else r=e+String(t);"function"==typeof P?P(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function j(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(t){D.throwLater(t)}"unhandledRejection"===t?tt(t,n,r)||i||C(n,"Unhandled rejection "):tt(t,r)}function E(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():N.toString(t);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(e))try{var r=JSON.stringify(t);e=r}catch(t){}0===e.length&&(e="(empty array)")}return"(<"+F(e)+">, no stack trace)"}function F(t){var e=41;return t.length=s||(nt=function(t){if(H.test(t))return!0;var e=A(t);return!!(e&&e.fileName===n&&a<=e.line&&e.line<=s)})}}function O(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);it(this,O),e>32&&this.uncycle()}var T,R,P,I=e._getDomain,D=e._async,M=t("./errors").Warning,N=t("./util"),L=N.canAttachTrace,H=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,z=/\((?:timers\.js):\d+:\d+\)/,q=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,U=null,W=null,V=!1,$=!(0==N.env("BLUEBIRD_DEBUG")),G=!(0==N.env("BLUEBIRD_WARNINGS")||!$&&!N.env("BLUEBIRD_WARNINGS")),J=!(0==N.env("BLUEBIRD_LONG_STACK_TRACES")||!$&&!N.env("BLUEBIRD_LONG_STACK_TRACES")),X=0!=N.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(G||!!N.env("BLUEBIRD_W_FORGOTTEN_RETURN"));e.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=t._bitField&-1048577|524288},e.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),D.invokeLater(this._notifyUnhandledRejection,this,void 0))},e.prototype._notifyUnhandledRejectionIsHandled=function(){j("rejectionHandled",T,void 0,this)},e.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},e.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),j("unhandledRejection",R,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=this._bitField&-262145},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=this._bitField&-1048577,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(t,e,n){return y(t,e,n||this)},e.onPossiblyUnhandledRejection=function(t){var e=I();R="function"==typeof t?null===e?t:N.domainBind(e,t):void 0},e.onUnhandledRejectionHandled=function(t){var e=I();T="function"==typeof t?null===e?t:N.domainBind(e,t):void 0};var K=function(){};e.longStackTraces=function(){if(D.haveItemsQueued()&&!ot.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!ot.longStackTraces&&S()){var t=e.prototype._captureStackTrace,r=e.prototype._attachExtraTrace;ot.longStackTraces=!0,K=function(){if(D.haveItemsQueued()&&!ot.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=t,e.prototype._attachExtraTrace=r,n.deactivateLongStackTraces(),D.enableTrampoline(),ot.longStackTraces=!1},e.prototype._captureStackTrace=h,e.prototype._attachExtraTrace=d,n.activateLongStackTraces(),D.disableTrampolineIfNecessary()}},e.hasLongStackTraces=function(){return ot.longStackTraces&&S()};var Q=function(){try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return N.global.dispatchEvent(t),function(t,e){var n=new CustomEvent(t.toLowerCase(),{detail:e,cancelable:!0});return!N.global.dispatchEvent(n)}}if("function"==typeof Event){var t=new Event("CustomEvent");return N.global.dispatchEvent(t),function(t,e){var n=new Event(t.toLowerCase(),{cancelable:!0});return n.detail=e,!N.global.dispatchEvent(n)}}var t=document.createEvent("CustomEvent");return t.initCustomEvent("testingtheevent",!1,!0,{}),N.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!N.global.dispatchEvent(n)}}catch(t){}return function(){return!1}}(),Z=function(){return N.isNode?function(){return process.emit.apply(process,arguments)}:N.global?function(t){var e="on"+t.toLowerCase(),n=N.global[e];return!!n&&(n.apply(N.global,[].slice.call(arguments,1)),!0)}:function(){return!1}}(),Y={promiseCreated:r,promiseFulfilled:r,promiseRejected:r,promiseResolved:r,promiseCancelled:r,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:r},tt=function(t){var e=!1;try{e=Z.apply(null,arguments)}catch(t){D.throwLater(t),e=!0}var n=!1;try{n=Q(t,Y[t].apply(null,arguments))}catch(t){D.throwLater(t),n=!0}return n||e};e.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&K()),"warnings"in t){var n=t.warnings;ot.warnings=!!n,X=ot.warnings,N.isObject(n)&&"wForgottenReturn"in n&&(X=!!n.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!ot.cancellation){if(D.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=c,e.prototype._propagateFrom=l,e.prototype._onCancel=s,e.prototype._setOnCancel=u,e.prototype._attachCancellationCallback=a,e.prototype._execute=o,et=l,ot.cancellation=!0}return"monitoring"in t&&(t.monitoring&&!ot.monitoring?(ot.monitoring=!0,e.prototype._fireEvent=tt):!t.monitoring&&ot.monitoring&&(ot.monitoring=!1,e.prototype._fireEvent=i)),e},e.prototype._fireEvent=i,e.prototype._execute=function(t,e,n){try{t(e,n)}catch(t){return t}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(t){},e.prototype._attachCancellationCallback=function(t){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(t,e){};var et=f,nt=function(){return!1},rt=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;N.inherits(O,Error),n.CapturedTrace=O,O.prototype.uncycle=function(){var t=this._length;if(!(t<2)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;t=this._length=r;for(var r=t-1;r>=0;--r){var o=e[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;r0&&(e[s-1]._parent=void 0,e[s-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var u=r>0?e[r-1]:this;s=0;--l)e[l]._length=c,c++;return}}}},O.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=x(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(w(i.stack.split("\n"))),i=i._parent;b(r),g(r),N.notEnumerableProp(t,"stack",m(n,r)),N.notEnumerableProp(t,"__stackCleaned__",!0)}};var it=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():E(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,U=t,W=e;var n=Error.captureStackTrace;return nt=function(t){return H.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return U=/@/,W=e,V=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(t){i="stack"in t}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(W=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?E(e):e.toString()},null):(U=t,W=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(P=function(t){console.warn(t)},N.isNode&&process.stderr.isTTY?P=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:N.isNode||"string"!=typeof(new Error).stack||(P=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var ot={warnings:G,longStackTraces:!1,cancellation:!1,monitoring:!1};return J&&e.longStackTraces(),{longStackTraces:function(){return ot.longStackTraces},warnings:function(){return ot.warnings},cancellation:function(){return ot.cancellation},monitoring:function(){return ot.monitoring},propagateFromFunction:function(){return et},boundValueFunction:function(){return p},checkForgottenReturns:v,setBounds:B,warn:y,deprecated:_,CapturedTrace:O,fireDomEvent:Q,fireGlobalEvent:Z}}},{"./errors":12,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype.return=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype.throw=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1],r=function(){throw e};return this.caught(t,r)},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();var i=function(){return r};return this.caught(n,i)}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){function n(){return o(this)}function r(t,n){return i(t,n,e,e)}var i=t.reduce,o=t.all;t.prototype.each=function(t){return i(this,t,e,0)._then(n,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return i(this,t,e,e)},t.each=function(t,r){return i(t,r,e,0)._then(n,void 0,void 0,t,void 0)},t.mapSeries=r}},{}],12:[function(t,e,n){"use strict";function r(t,e){function n(r){return this instanceof n?(f(this,"message","string"==typeof r?r:e),f(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return l(n,Error),n}function i(t){return this instanceof i?(f(this,"name","OperationalError"),f(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(f(this,"message",t.message),f(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,a,s=t("./es5"),u=s.freeze,c=t("./util"),l=c.inherits,f=c.notEnumerableProp,p=r("Warning","warning"),h=r("CancellationError","cancellation error"),d=r("TimeoutError","timeout error"),v=r("AggregateError","aggregate error");try{o=TypeError,a=RangeError}catch(t){o=r("TypeError","type error"),a=r("RangeError","range error")}for(var _="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),y=0;y<_.length;++y)"function"==typeof Array.prototype[_[y]]&&(v.prototype[_[y]]=Array.prototype[_[y]]);s.defineProperty(v.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),v.prototype.isOperational=!0;var m=0;v.prototype.toString=function(){var t=Array(4*m+1).join(" "),e="\n"+t+"AggregateError of:\n";m++,t=Array(4*m+1).join(" ");for(var n=0;n>>1|Q<<31)^(K>>>8|Q<<24)^K>>>7,Y=(Q>>>1|K<<31)^(Q>>>8|K<<24)^(Q>>>7|K<<25),tt=l[V-2],et=tt.high,nt=tt.low,rt=(et>>>19|nt<<13)^(et<<3|nt>>>29)^et>>>6,it=(nt>>>19|et<<13)^(nt<<3|et>>>29)^(nt>>>6|et<<26),ot=l[V-7],at=ot.high,st=ot.low,ut=l[V-16],ct=ut.high,lt=ut.low,J=Y+st,G=Z+at+(J>>>0>>0?1:0),J=J+it,G=G+rt+(J>>>0>>0?1:0),J=J+lt,G=G+ct+(J>>>0>>0?1:0);$.high=G,$.low=J}var ft=M&L^~M&z,pt=N&H^~N&q,ht=A&O^A&R^O&R,dt=B&T^B&P^T&P,vt=(A>>>28|B<<4)^(A<<30|B>>>2)^(A<<25|B>>>7),_t=(B>>>28|A<<4)^(B<<30|A>>>2)^(B<<25|A>>>7),yt=(M>>>14|N<<18)^(M>>>18|N<<14)^(M<<23|N>>>9),mt=(N>>>14|M<<18)^(N>>>18|M<<14)^(N<<23|M>>>9),gt=c[V],bt=gt.high,wt=gt.low,kt=W+mt,xt=U+yt+(kt>>>0>>0?1:0),kt=kt+pt,xt=xt+ft+(kt>>>0>>0?1:0),kt=kt+wt,xt=xt+bt+(kt>>>0>>0?1:0),kt=kt+J,xt=xt+G+(kt>>>0>>0?1:0),Ct=_t+dt,jt=vt+ht+(Ct>>>0<_t>>>0?1:0);U=z,W=q,z=L,q=H,L=M,H=N,N=D+kt|0,M=I+xt+(N>>>0>>0?1:0)|0,I=R,D=P,R=O,P=T,O=A,T=B,B=kt+Ct|0,A=xt+jt+(B>>>0>>0?1:0)|0}d=r.low=d+B,r.high=h+A+(d>>>0>>0?1:0),_=i.low=_+T,i.high=v+O+(_>>>0>>0?1:0),m=o.low=m+P,o.high=y+R+(m>>>0

>>0?1:0),b=a.low=b+D,a.high=g+I+(b>>>0>>0?1:0),k=s.low=k+N,s.high=w+M+(k>>>0>>0?1:0),C=u.low=C+H,u.high=x+L+(C>>>0>>0?1:0),E=f.low=E+q,f.high=j+z+(E>>>0>>0?1:0),S=p.low=S+W,p.high=F+U+(S>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;e[r>>>5]|=128<<24-r%32,e[(r+128>>>10<<5)+30]=Math.floor(n/4294967296),e[(r+128>>>10<<5)+31]=n,t.sigBytes=4*e.length,this._process();var i=this._hash.toX32();return i},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});n.SHA512=i._createHelper(f),n.HmacSHA512=i._createHmacHelper(f)}(),t.SHA512})},{"./core":52,"./x64-core":83}],82:[function(t,e,n){!function(r,i,o){"object"==typeof n?e.exports=n=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(r.CryptoJS)}(this,function(t){return function(){function e(t,e){var n=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=n,this._lBlock^=n<>>t^this._lBlock)&e;this._lBlock^=n,this._rBlock^=n<>>5]>>>31-i%32&1}for(var o=this._subKeys=[],a=0;a<16;a++){for(var s=o[a]=[],f=l[a],r=0;r<24;r++)s[r/6|0]|=n[(c[r]-1+f)%28]<<31-r%6,s[4+(r/6|0)]|=n[28+(c[r+24]-1+f)%28]<<31-r%6;s[0]=s[0]<<1|s[0]>>>31;for(var r=1;r<7;r++)s[r]=s[r]>>>4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}for(var p=this._invSubKeys=[],r=0;r<16;r++)p[r]=o[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,r,i){this._lBlock=t[r],this._rBlock=t[r+1],e.call(this,4,252645135),e.call(this,16,65535),n.call(this,2,858993459),n.call(this,8,16711935),e.call(this,1,1431655765);for(var o=0;o<16;o++){for(var a=i[o],s=this._lBlock,u=this._rBlock,c=0,l=0;l<8;l++)c|=f[l][((u^a[l])&p[l])>>>0];this._lBlock=u,this._rBlock=s^c}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,e.call(this,1,1431655765),n.call(this,8,16711935),n.call(this,2,858993459),e.call(this,16,65535),e.call(this,4,252645135),t[r]=this._lBlock,t[r+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=a._createHelper(h);var d=s.TripleDES=a.extend({_doReset:function(){var t=this._key,e=t.words;this._des1=h.createEncryptor(o.create(e.slice(0,2))),this._des2=h.createEncryptor(o.create(e.slice(2,4))),this._des3=h.createEncryptor(o.create(e.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2});r.TripleDES=a._createHelper(d)}(),t.TripleDES})},{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],83:[function(t,e,n){!function(r,i){"object"==typeof n?e.exports=n=i(t("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,i=r.Base,o=r.WordArray,a=n.x64={};a.Word=i.extend({init:function(t,e){this.high=t,this.low=e}}),a.WordArray=i.extend({init:function(t,n){t=this.words=t||[],n!=e?this.sigBytes=n:this.sigBytes=8*t.length},toX32:function(){for(var t=this.words,e=t.length,n=[],r=0;r-1}function f(t,e,n){for(var r=-1,i=null==t?0:t.length;++r-1;);return n}function D(t,e){for(var n=t.length;n--&&w(e,t[n],0)>-1;);return n}function M(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}function N(t){return"\\"+Yn[t]}function L(t,e){return null==t?et:t[e]}function H(t){return Wn.test(t)}function z(t){return Vn.test(t)}function q(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function U(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function W(t,e){return function(n){return t(e(n))}}function V(t,e){for(var n=-1,r=t.length,i=0,o=[];++n>>1,Nt=[["ary",wt],["bind",dt],["bindKey",vt],["curry",yt],["curryRight",mt],["flip",xt],["partial",gt],["partialRight",bt],["rearg",kt]],Lt="[object Arguments]",Ht="[object Array]",zt="[object AsyncFunction]",qt="[object Boolean]",Ut="[object Date]",Wt="[object DOMException]",Vt="[object Error]",$t="[object Function]",Gt="[object GeneratorFunction]",Jt="[object Map]",Xt="[object Number]",Kt="[object Null]",Qt="[object Object]",Zt="[object Promise]",Yt="[object Proxy]",te="[object RegExp]",ee="[object Set]",ne="[object String]",re="[object Symbol]",ie="[object Undefined]",oe="[object WeakMap]",ae="[object WeakSet]",se="[object ArrayBuffer]",ue="[object DataView]",ce="[object Float32Array]",le="[object Float64Array]",fe="[object Int8Array]",pe="[object Int16Array]",he="[object Int32Array]",de="[object Uint8Array]",ve="[object Uint8ClampedArray]",_e="[object Uint16Array]",ye="[object Uint32Array]",me=/\b__p \+= '';/g,ge=/\b(__p \+=) '' \+/g,be=/(__e\(.*?\)|\b__t\)) \+\n'';/g,we=/&(?:amp|lt|gt|quot|#39);/g,ke=/[&<>"']/g,xe=RegExp(we.source),Ce=RegExp(ke.source),je=/<%-([\s\S]+?)%>/g,Ee=/<%([\s\S]+?)%>/g,Fe=/<%=([\s\S]+?)%>/g,Se=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ae=/^\w*$/,Be=/^\./,Oe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Te=/[\\^$.*+?()[\]{}|]/g,Re=RegExp(Te.source),Pe=/^\s+|\s+$/g,Ie=/^\s+/,De=/\s+$/,Me=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ne=/\{\n\/\* \[wrapped with (.+)\] \*/,Le=/,? & /,He=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ze=/\\(\\)?/g,qe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ue=/\w*$/,We=/^[-+]0x[0-9a-f]+$/i,Ve=/^0b[01]+$/i,$e=/^\[object .+?Constructor\]$/,Ge=/^0o[0-7]+$/i,Je=/^(?:0|[1-9]\d*)$/,Xe=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ke=/($^)/,Qe=/['\n\r\u2028\u2029\\]/g,Ze="\\ud800-\\udfff",Ye="\\u0300-\\u036f",tn="\\ufe20-\\ufe2f",en="\\u20d0-\\u20ff",nn=Ye+tn+en,rn="\\u2700-\\u27bf",on="a-z\\xdf-\\xf6\\xf8-\\xff",an="\\xac\\xb1\\xd7\\xf7",sn="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",un="\\u2000-\\u206f",cn=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ln="A-Z\\xc0-\\xd6\\xd8-\\xde",fn="\\ufe0e\\ufe0f",pn=an+sn+un+cn,hn="['’]",dn="["+Ze+"]",vn="["+pn+"]",_n="["+nn+"]",yn="\\d+",mn="["+rn+"]",gn="["+on+"]",bn="[^"+Ze+pn+yn+rn+on+ln+"]",wn="\\ud83c[\\udffb-\\udfff]",kn="(?:"+_n+"|"+wn+")",xn="[^"+Ze+"]",Cn="(?:\\ud83c[\\udde6-\\uddff]){2}",jn="[\\ud800-\\udbff][\\udc00-\\udfff]",En="["+ln+"]",Fn="\\u200d",Sn="(?:"+gn+"|"+bn+")",An="(?:"+En+"|"+bn+")",Bn="(?:"+hn+"(?:d|ll|m|re|s|t|ve))?",On="(?:"+hn+"(?:D|LL|M|RE|S|T|VE))?",Tn=kn+"?",Rn="["+fn+"]?",Pn="(?:"+Fn+"(?:"+[xn,Cn,jn].join("|")+")"+Rn+Tn+")*",In="\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",Dn="\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)",Mn=Rn+Tn+Pn,Nn="(?:"+[mn,Cn,jn].join("|")+")"+Mn,Ln="(?:"+[xn+_n+"?",_n,Cn,jn,dn].join("|")+")",Hn=RegExp(hn,"g"),zn=RegExp(_n,"g"),qn=RegExp(wn+"(?="+wn+")|"+Ln+Mn,"g"),Un=RegExp([En+"?"+gn+"+"+Bn+"(?="+[vn,En,"$"].join("|")+")",An+"+"+On+"(?="+[vn,En+Sn,"$"].join("|")+")",En+"?"+Sn+"+"+Bn,En+"+"+On,Dn,In,yn,Nn].join("|"),"g"),Wn=RegExp("["+Fn+Ze+nn+fn+"]"),Vn=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,$n=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Gn=-1,Jn={};Jn[ce]=Jn[le]=Jn[fe]=Jn[pe]=Jn[he]=Jn[de]=Jn[ve]=Jn[_e]=Jn[ye]=!0,Jn[Lt]=Jn[Ht]=Jn[se]=Jn[qt]=Jn[ue]=Jn[Ut]=Jn[Vt]=Jn[$t]=Jn[Jt]=Jn[Xt]=Jn[Qt]=Jn[te]=Jn[ee]=Jn[ne]=Jn[oe]=!1;var Xn={};Xn[Lt]=Xn[Ht]=Xn[se]=Xn[ue]=Xn[qt]=Xn[Ut]=Xn[ce]=Xn[le]=Xn[fe]=Xn[pe]=Xn[he]=Xn[Jt]=Xn[Xt]=Xn[Qt]=Xn[te]=Xn[ee]=Xn[ne]=Xn[re]=Xn[de]=Xn[ve]=Xn[_e]=Xn[ye]=!0,Xn[Vt]=Xn[$t]=Xn[oe]=!1;var Kn={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},Qn={"&":"&","<":"<",">":">",'"':""","'":"'"},Zn={"&":"&","<":"<",">":">",""":'"',"'":"'"},Yn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},tr=parseFloat,er=parseInt,nr="object"==typeof global&&global&&global.Object===Object&&global,rr="object"==typeof self&&self&&self.Object===Object&&self,ir=nr||rr||Function("return this")(),or="object"==typeof n&&n&&!n.nodeType&&n,ar=or&&"object"==typeof e&&e&&!e.nodeType&&e,sr=ar&&ar.exports===or,ur=sr&&nr.process,cr=function(){try{return ur&&ur.binding&&ur.binding("util")}catch(t){}}(),lr=cr&&cr.isArrayBuffer,fr=cr&&cr.isDate,pr=cr&&cr.isMap,hr=cr&&cr.isRegExp,dr=cr&&cr.isSet,vr=cr&&cr.isTypedArray,_r=j("length"),yr=E(Kn),mr=E(Qn),gr=E(Zn),br=function e(n){function y(t){if(cu(t)&&!wp(t)&&!(t instanceof Z)){if(t instanceof J)return t;if(bl.call(t,"__wrapped__"))return aa(t)}return new J(t)}function E(){}function J(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=et}function Z(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=It,this.__views__=[]}function Y(){var t=new Z(this.__wrapped__);return t.__actions__=Hi(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Hi(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Hi(this.__views__),t}function He(){if(this.__filtered__){var t=new Z(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function Ze(){var t=this.__wrapped__.value(),e=this.__dir__,n=wp(t),r=e<0,i=n?t.length:0,o=Bo(0,i,this.__views__),a=o.start,s=o.end,u=s-a,c=r?s:a-1,l=this.__iteratees__,f=l.length,p=0,h=Kl(u,this.__takeCount__);if(!n||!r&&i==u&&h==u)return wi(t,this.__actions__);var d=[];t:for(;u--&&p-1}function fn(t,e){var n=this.__data__,r=Rn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}function pn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function qn(t,e,n,r,i,o){var s,u=e&ct,c=e<,l=e&ft;if(n&&(s=i?n(t,r,i,o):n(t)),s!==et)return s;if(!uu(t))return t;var f=wp(t);if(f){if(s=Ro(t),!u)return Hi(t,s)}else{var p=Of(t),h=p==$t||p==Gt;if(xp(t))return Si(t,u);if(p==Qt||p==Lt||h&&!i){if(s=c||h?{}:Po(t),!u)return c?Ui(t,Dn(s,t)):qi(t,In(s,t))}else{if(!Xn[p])return i?t:{};s=Io(t,p,qn,u)}}o||(o=new wn);var d=o.get(t);if(d)return d;o.set(t,s);var v=l?c?ko:wo:c?Vu:Wu,_=f?et:v(t);return a(_||t,function(r,i){_&&(i=r,r=t[i]),Tn(s,i,qn(r,e,n,i,t,o))}),s}function Un(t){var e=Wu(t);return function(n){return Wn(n,t,e)}}function Wn(t,e,n){var r=n.length;if(null==t)return!r;for(t=fl(t);r--;){var i=n[r],o=e[i],a=t[i];if(a===et&&!(i in t)||!o(a))return!1}return!0}function Vn(t,e,n){if("function"!=typeof t)throw new dl(ot);return Pf(function(){t.apply(et,n)},e)}function Kn(t,e,n,r){var i=-1,o=l,a=!0,s=t.length,u=[],c=e.length;if(!s)return u;n&&(e=p(e,T(n))),r?(o=f,a=!1):e.length>=rt&&(o=P,a=!1,e=new mn(e));t:for(;++ii?0:i+n),r=r===et||r>i?i:Eu(r),r<0&&(r+=i),r=n>r?0:Fu(r);n0&&n(s)?e>1?rr(s,e-1,n,r,i):h(i,s):r||(i[i.length]=s)}return i}function or(t,e){return t&&wf(t,e,Wu)}function ar(t,e){return t&&kf(t,e,Wu)}function ur(t,e){return c(e,function(e){return ou(t[e])})}function cr(t,e){e=Ei(e,t);for(var n=0,r=e.length;null!=t&&ne}function xr(t,e){return null!=t&&bl.call(t,e)}function Cr(t,e){return null!=t&&e in fl(t)}function jr(t,e,n){return t>=Kl(e,n)&&t=120&&h.length>=120)?new mn(a&&h):et}h=t[0];var d=-1,v=s[0];t:for(;++d-1;)s!==t&&Pl.call(s,u,1),Pl.call(t,u,1);return t}function ei(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==o){var o=i;No(i)?Pl.call(t,i,1):mi(t,i)}}return t}function ni(t,e){return t+Ul(Yl()*(e-t+1))}function ri(t,e,n,r){for(var i=-1,o=Xl(ql((e-t)/(n||1)),0),a=al(o);o--;)a[r?o:++i]=t,t+=n;return a}function ii(t,e){var n="";if(!t||e<1||e>Tt)return n;do e%2&&(n+=t),e=Ul(e/2),e&&(t+=t);while(e);return n}function oi(t,e){return If(Qo(t,e,Pc),t+"")}function ai(t){return Sn(rc(t))}function si(t,e){var n=rc(t);return na(n,Ln(e,0,n.length))}function ui(t,e,n,r){if(!uu(t))return t;e=Ei(e,t);for(var i=-1,o=e.length,a=o-1,s=t;null!=s&&++ii?0:i+e),n=n>i?i:n,n<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=al(i);++r>>1,a=t[o];null!==a&&!bu(a)&&(n?a<=e:a=rt){var c=e?null:Ff(t);if(c)return $(c);a=!1,i=P,u=new mn}else u=e?[]:s;t:for(;++r=r?t:li(t,e,n)}function Si(t,e){if(e)return t.slice();var n=t.length,r=Bl?Bl(n):new t.constructor(n);return t.copy(r),r}function Ai(t){var e=new t.constructor(t.byteLength);return new Al(e).set(new Al(t)),e}function Bi(t,e){var n=e?Ai(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}function Oi(e,n,r){var i=n?r(U(e),ct):U(e);return d(i,t,new e.constructor)}function Ti(t){var e=new t.constructor(t.source,Ue.exec(t));return e.lastIndex=t.lastIndex,e}function Ri(t,e,n){var i=e?n($(t),ct):$(t);return d(i,r,new t.constructor)}function Pi(t){return _f?fl(_f.call(t)):{}}function Ii(t,e){var n=e?Ai(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Di(t,e){if(t!==e){var n=t!==et,r=null===t,i=t===t,o=bu(t),a=e!==et,s=null===e,u=e===e,c=bu(e);if(!s&&!c&&!o&&t>e||o&&a&&u&&!s&&!c||r&&a&&u||!n&&u||!i)return 1;if(!r&&!o&&!c&&t=s)return u;var c=n[r];return u*("desc"==c?-1:1)}}return t.index-e.index}function Ni(t,e,n,r){for(var i=-1,o=t.length,a=n.length,s=-1,u=e.length,c=Xl(o-a,0),l=al(u+c),f=!r;++s1?n[i-1]:et,a=i>2?n[2]:et;for(o=t.length>3&&"function"==typeof o?(i--,o):et,a&&Lo(n[0],n[1],a)&&(o=i<3?et:o,i=1),e=fl(e);++r-1?i[o?e[a]:a]:et}}function to(t){return bo(function(e){var n=e.length,r=n,i=J.prototype.thru;for(t&&e.reverse();r--;){var o=e[r];if("function"!=typeof o)throw new dl(ot);if(i&&!a&&"wrapper"==xo(o))var a=new J([],(!0))}for(r=a?r:n;++r1&&m.reverse(),f&&us))return!1;var c=o.get(t);if(c&&o.get(e))return c==e;var l=-1,f=!0,p=n&ht?new mn:et;for(o.set(t,e),o.set(e,t);++l1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(Me,"{\n/* [wrapped with "+e+"] */\n")}function Mo(t){return wp(t)||bp(t)||!!(Il&&t&&t[Il])}function No(t,e){return e=null==e?Tt:e,!!e&&("number"==typeof t||Je.test(t))&&t>-1&&t%1==0&&t0){if(++e>=Et)return arguments[0]}else e=0;return t.apply(et,arguments)}}function na(t,e){var n=-1,r=t.length,i=r-1;for(e=e===et?r:e;++n=this.__values__.length,e=t?et:this.__values__[this.__index__++];return{done:t,value:e}}function as(){return this}function ss(t){for(var e,n=this;n instanceof E;){var r=aa(n);r.__index__=0,r.__values__=et,e?i.__wrapped__=r:e=r;var i=r;n=n.__wrapped__}return i.__wrapped__=t,e}function us(){var t=this.__wrapped__;if(t instanceof Z){var e=t;return this.__actions__.length&&(e=new Z(this)),e=e.reverse(),e.__actions__.push({func:ns,args:[Ta],thisArg:et}),new J(e,this.__chain__)}return this.thru(Ta)}function cs(){return wi(this.__wrapped__,this.__actions__)}function ls(t,e,n){var r=wp(t)?u:Qn;return n&&Lo(t,e,n)&&(e=et),r(t,jo(e,3))}function fs(t,e){var n=wp(t)?c:nr;return n(t,jo(e,3))}function ps(t,e){return rr(ms(t,e),1)}function hs(t,e){return rr(ms(t,e),Ot)}function ds(t,e,n){return n=n===et?1:Eu(n),rr(ms(t,e),n)}function vs(t,e){var n=wp(t)?a:gf;return n(t,jo(e,3))}function _s(t,e){var n=wp(t)?s:bf;return n(t,jo(e,3))}function ys(t,e,n,r){t=Ks(t)?t:rc(t),n=n&&!r?Eu(n):0;var i=t.length;return n<0&&(n=Xl(i+n,0)),gu(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&w(t,e,n)>-1}function ms(t,e){var n=wp(t)?p:Wr;return n(t,jo(e,3))}function gs(t,e,n,r){return null==t?[]:(wp(e)||(e=null==e?[]:[e]),n=r?et:n,wp(n)||(n=null==n?[]:[n]),Kr(t,e,n))}function bs(t,e,n){var r=wp(t)?d:F,i=arguments.length<3;return r(t,jo(e,4),n,i,gf)}function ws(t,e,n){var r=wp(t)?v:F,i=arguments.length<3;return r(t,jo(e,4),n,i,bf)}function ks(t,e){var n=wp(t)?c:nr;return n(t,Ds(jo(e,3)))}function xs(t){var e=wp(t)?Sn:ai;return e(t)}function Cs(t,e,n){e=(n?Lo(t,e,n):e===et)?1:Eu(e);var r=wp(t)?An:si;return r(t,e)}function js(t){var e=wp(t)?Bn:ci;return e(t)}function Es(t){if(null==t)return 0;if(Ks(t))return gu(t)?K(t):t.length;var e=Of(t);return e==Jt||e==ee?t.size:zr(t).length}function Fs(t,e,n){var r=wp(t)?_:fi;return n&&Lo(t,e,n)&&(e=et),r(t,jo(e,3))}function Ss(t,e){if("function"!=typeof e)throw new dl(ot);return t=Eu(t),function(){if(--t<1)return e.apply(this,arguments)}}function As(t,e,n){return e=n?et:e,e=t&&null==e?t.length:e,po(t,wt,et,et,et,et,e)}function Bs(t,e){var n;if("function"!=typeof e)throw new dl(ot);return t=Eu(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=et),n}}function Os(t,e,n){e=n?et:e;var r=po(t,yt,et,et,et,et,et,e);return r.placeholder=Os.placeholder,r}function Ts(t,e,n){e=n?et:e;var r=po(t,mt,et,et,et,et,et,e);return r.placeholder=Ts.placeholder,r}function Rs(t,e,n){function r(e){var n=p,r=h;return p=h=et,m=e,v=t.apply(r,n)}function i(t){return m=t,_=Pf(s,e),g?r(t):v}function o(t){var n=t-y,r=t-m,i=e-n;return b?Kl(i,d-r):i}function a(t){var n=t-y,r=t-m;return y===et||n>=e||n<0||b&&r>=d}function s(){var t=cp();return a(t)?u(t):void(_=Pf(s,o(t)))}function u(t){return _=et,w&&p?r(t):(p=h=et,v)}function c(){_!==et&&Ef(_),m=0,p=y=h=_=et}function l(){return _===et?v:u(cp())}function f(){var t=cp(),n=a(t);if(p=arguments,h=this,y=t,n){if(_===et)return i(y);if(b)return _=Pf(s,e),r(y)}return _===et&&(_=Pf(s,e)),v}var p,h,d,v,_,y,m=0,g=!1,b=!1,w=!0;if("function"!=typeof t)throw new dl(ot);return e=Su(e)||0,uu(n)&&(g=!!n.leading,b="maxWait"in n,d=b?Xl(Su(n.maxWait)||0,e):d,w="trailing"in n?!!n.trailing:w),f.cancel=c,f.flush=l,f}function Ps(t){return po(t,xt)}function Is(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new dl(ot);var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=t.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Is.Cache||pn),n}function Ds(t){if("function"!=typeof t)throw new dl(ot);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Ms(t){return Bs(2,t)}function Ns(t,e){if("function"!=typeof t)throw new dl(ot);return e=e===et?e:Eu(e),oi(t,e)}function Ls(t,e){if("function"!=typeof t)throw new dl(ot);return e=null==e?0:Xl(Eu(e),0),oi(function(n){var r=n[e],o=Fi(n,0,e);return r&&h(o,r),i(t,this,o)})}function Hs(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new dl(ot);return uu(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Rs(t,e,{leading:r,maxWait:e,trailing:i})}function zs(t){return As(t,1)}function qs(t,e){return vp(ji(e),t)}function Us(){if(!arguments.length)return[];var t=arguments[0];return wp(t)?t:[t]}function Ws(t){return qn(t,ft)}function Vs(t,e){return e="function"==typeof e?e:et,qn(t,ft,e)}function $s(t){return qn(t,ct|ft)}function Gs(t,e){return e="function"==typeof e?e:et,qn(t,ct|ft,e)}function Js(t,e){return null==e||Wn(t,e,Wu(e))}function Xs(t,e){return t===e||t!==t&&e!==e}function Ks(t){return null!=t&&su(t.length)&&!ou(t)}function Qs(t){return cu(t)&&Ks(t)}function Zs(t){return t===!0||t===!1||cu(t)&&br(t)==qt}function Ys(t){return cu(t)&&1===t.nodeType&&!yu(t)}function tu(t){if(null==t)return!0;if(Ks(t)&&(wp(t)||"string"==typeof t||"function"==typeof t.splice||xp(t)||Sp(t)||bp(t)))return!t.length;var e=Of(t);if(e==Jt||e==ee)return!t.size;if(Wo(t))return!zr(t).length;for(var n in t)if(bl.call(t,n))return!1;return!0}function eu(t,e){return Tr(t,e)}function nu(t,e,n){n="function"==typeof n?n:et;var r=n?n(t,e):et;return r===et?Tr(t,e,et,n):!!r}function ru(t){if(!cu(t))return!1;var e=br(t);return e==Vt||e==Wt||"string"==typeof t.message&&"string"==typeof t.name&&!yu(t)}function iu(t){return"number"==typeof t&&$l(t)}function ou(t){if(!uu(t))return!1;var e=br(t);return e==$t||e==Gt||e==zt||e==Yt}function au(t){return"number"==typeof t&&t==Eu(t)}function su(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Tt}function uu(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function cu(t){return null!=t&&"object"==typeof t}function lu(t,e){return t===e||Ir(t,e,Fo(e))}function fu(t,e,n){return n="function"==typeof n?n:et,Ir(t,e,Fo(e),n)}function pu(t){return _u(t)&&t!=+t}function hu(t){if(Tf(t))throw new ul(it);return Dr(t)}function du(t){return null===t}function vu(t){return null==t}function _u(t){return"number"==typeof t||cu(t)&&br(t)==Xt}function yu(t){if(!cu(t)||br(t)!=Qt)return!1;var e=Ol(t);if(null===e)return!0;var n=bl.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&gl.call(n)==Cl}function mu(t){return au(t)&&t>=-Tt&&t<=Tt}function gu(t){return"string"==typeof t||!wp(t)&&cu(t)&&br(t)==ne}function bu(t){return"symbol"==typeof t||cu(t)&&br(t)==re}function wu(t){return t===et}function ku(t){return cu(t)&&Of(t)==oe}function xu(t){return cu(t)&&br(t)==ae}function Cu(t){if(!t)return[];if(Ks(t))return gu(t)?Q(t):Hi(t);if(Dl&&t[Dl])return q(t[Dl]());var e=Of(t),n=e==Jt?U:e==ee?$:rc;return n(t)}function ju(t){if(!t)return 0===t?t:0;if(t=Su(t),t===Ot||t===-Ot){var e=t<0?-1:1;return e*Rt}return t===t?t:0}function Eu(t){var e=ju(t),n=e%1;return e===e?n?e-n:e:0}function Fu(t){return t?Ln(Eu(t),0,It):0}function Su(t){if("number"==typeof t)return t;if(bu(t))return Pt;if(uu(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=uu(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Pe,"");var n=Ve.test(t); return n||Ge.test(t)?er(t.slice(2),n?2:8):We.test(t)?Pt:+t}function Au(t){return zi(t,Vu(t))}function Bu(t){return t?Ln(Eu(t),-Tt,Tt):0===t?t:0}function Ou(t){return null==t?"":_i(t)}function Tu(t,e){var n=mf(t);return null==e?n:In(n,e)}function Ru(t,e){return g(t,jo(e,3),or)}function Pu(t,e){return g(t,jo(e,3),ar)}function Iu(t,e){return null==t?t:wf(t,jo(e,3),Vu)}function Du(t,e){return null==t?t:kf(t,jo(e,3),Vu)}function Mu(t,e){return t&&or(t,jo(e,3))}function Nu(t,e){return t&&ar(t,jo(e,3))}function Lu(t){return null==t?[]:ur(t,Wu(t))}function Hu(t){return null==t?[]:ur(t,Vu(t))}function zu(t,e,n){var r=null==t?et:cr(t,e);return r===et?n:r}function qu(t,e){return null!=t&&To(t,e,xr)}function Uu(t,e){return null!=t&&To(t,e,Cr)}function Wu(t){return Ks(t)?Fn(t):zr(t)}function Vu(t){return Ks(t)?Fn(t,!0):qr(t)}function $u(t,e){var n={};return e=jo(e,3),or(t,function(t,r,i){Mn(n,e(t,r,i),t)}),n}function Gu(t,e){var n={};return e=jo(e,3),or(t,function(t,r,i){Mn(n,r,e(t,r,i))}),n}function Ju(t,e){return Xu(t,Ds(jo(e)))}function Xu(t,e){if(null==t)return{};var n=p(ko(t),function(t){return[t]});return e=jo(e),Zr(t,n,function(t,n){return e(t,n[0])})}function Ku(t,e,n){e=Ei(e,t);var r=-1,i=e.length;for(i||(i=1,t=et);++re){var r=t;t=e,e=r}if(n||t%1||e%1){var i=Yl();return Kl(t+i*(e-t+tr("1e-"+((i+"").length-1))),e)}return ni(t,e)}function uc(t){return th(Ou(t).toLowerCase())}function cc(t){return t=Ou(t),t&&t.replace(Xe,yr).replace(zn,"")}function lc(t,e,n){t=Ou(t),e=_i(e);var r=t.length;n=n===et?r:Ln(Eu(n),0,r);var i=n;return n-=e.length,n>=0&&t.slice(n,i)==e}function fc(t){return t=Ou(t),t&&Ce.test(t)?t.replace(ke,mr):t}function pc(t){return t=Ou(t),t&&Re.test(t)?t.replace(Te,"\\$&"):t}function hc(t,e,n){t=Ou(t),e=Eu(e);var r=e?K(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return oo(Ul(i),n)+t+oo(ql(i),n)}function dc(t,e,n){t=Ou(t),e=Eu(e);var r=e?K(t):0;return e&&r>>0)?(t=Ou(t),t&&("string"==typeof e||null!=e&&!Ep(e))&&(e=_i(e),!e&&H(t))?Fi(Q(t),0,n):t.split(e,n)):[]}function bc(t,e,n){return t=Ou(t),n=null==n?0:Ln(Eu(n),0,t.length),e=_i(e),t.slice(n,n+e.length)==e}function wc(t,e,n){var r=y.templateSettings;n&&Lo(t,e,n)&&(e=et),t=Ou(t),e=Rp({},e,r,ho);var i,o,a=Rp({},e.imports,r.imports,ho),s=Wu(a),u=R(a,s),c=0,l=e.interpolate||Ke,f="__p += '",p=pl((e.escape||Ke).source+"|"+l.source+"|"+(l===Fe?qe:Ke).source+"|"+(e.evaluate||Ke).source+"|$","g"),h="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++Gn+"]")+"\n";t.replace(p,function(e,n,r,a,s,u){return r||(r=a),f+=t.slice(c,u).replace(Qe,N),n&&(i=!0,f+="' +\n__e("+n+") +\n'"),s&&(o=!0,f+="';\n"+s+";\n__p += '"),r&&(f+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),c=u+e.length,e}),f+="';\n";var d=e.variable;d||(f="with (obj) {\n"+f+"\n}\n"),f=(o?f.replace(me,""):f).replace(ge,"$1").replace(be,"$1;"),f="function("+(d||"obj")+") {\n"+(d?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var v=eh(function(){return cl(s,h+"return "+f).apply(et,u)});if(v.source=f,ru(v))throw v;return v}function kc(t){return Ou(t).toLowerCase()}function xc(t){return Ou(t).toUpperCase()}function Cc(t,e,n){if(t=Ou(t),t&&(n||e===et))return t.replace(Pe,"");if(!t||!(e=_i(e)))return t;var r=Q(t),i=Q(e),o=I(r,i),a=D(r,i)+1;return Fi(r,o,a).join("")}function jc(t,e,n){if(t=Ou(t),t&&(n||e===et))return t.replace(De,"");if(!t||!(e=_i(e)))return t;var r=Q(t),i=D(r,Q(e))+1;return Fi(r,0,i).join("")}function Ec(t,e,n){if(t=Ou(t),t&&(n||e===et))return t.replace(Ie,"");if(!t||!(e=_i(e)))return t;var r=Q(t),i=I(r,Q(e));return Fi(r,i).join("")}function Fc(t,e){var n=Ct,r=jt;if(uu(e)){var i="separator"in e?e.separator:i;n="length"in e?Eu(e.length):n,r="omission"in e?_i(e.omission):r}t=Ou(t);var o=t.length;if(H(t)){var a=Q(t);o=a.length}if(n>=o)return t;var s=n-K(r);if(s<1)return r;var u=a?Fi(a,0,s).join(""):t.slice(0,s);if(i===et)return u+r;if(a&&(s+=u.length-s),Ep(i)){if(t.slice(s).search(i)){var c,l=u;for(i.global||(i=pl(i.source,Ou(Ue.exec(i))+"g")),i.lastIndex=0;c=i.exec(l);)var f=c.index;u=u.slice(0,f===et?s:f)}}else if(t.indexOf(_i(i),s)!=s){var p=u.lastIndexOf(i);p>-1&&(u=u.slice(0,p))}return u+r}function Sc(t){return t=Ou(t),t&&xe.test(t)?t.replace(we,gr):t}function Ac(t,e,n){return t=Ou(t),e=n?et:e,e===et?z(t)?tt(t):m(t):t.match(e)||[]}function Bc(t){var e=null==t?0:t.length,n=jo();return t=e?p(t,function(t){if("function"!=typeof t[1])throw new dl(ot);return[n(t[0]),t[1]]}):[],oi(function(n){for(var r=-1;++rTt)return[];var n=It,r=Kl(t,It);e=jo(e),t-=It;for(var i=B(r,e);++n1?t[e-1]:et;return n="function"==typeof n?(t.pop(),n):et,Qa(t,n)}),tp=bo(function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,i=function(e){return Nn(e,t)};return!(e>1||this.__actions__.length)&&r instanceof Z&&No(n)?(r=r.slice(n,+n+(e?1:0)),r.__actions__.push({func:ns,args:[i],thisArg:et}),new J(r,this.__chain__).thru(function(t){return e&&!t.length&&t.push(et),t})):this.thru(i)}),ep=Wi(function(t,e,n){bl.call(t,n)?++t[n]:Mn(t,n,1)}),np=Yi(va),rp=Yi(_a),ip=Wi(function(t,e,n){bl.call(t,n)?t[n].push(e):Mn(t,n,[e])}),op=oi(function(t,e,n){var r=-1,o="function"==typeof e,a=Ks(t)?al(t.length):[];return gf(t,function(t){a[++r]=o?i(e,t,n):Sr(t,e,n)}),a}),ap=Wi(function(t,e,n){Mn(t,n,e)}),sp=Wi(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]}),up=oi(function(t,e){if(null==t)return[];var n=e.length;return n>1&&Lo(t,e[0],e[1])?e=[]:n>2&&Lo(e[0],e[1],e[2])&&(e=[e[0]]),Kr(t,rr(e,1),[])}),cp=Hl||function(){return ir.Date.now()},lp=oi(function(t,e,n){var r=dt;if(n.length){var i=V(n,Co(lp));r|=gt}return po(t,r,e,n,i)}),fp=oi(function(t,e,n){var r=dt|vt;if(n.length){var i=V(n,Co(fp));r|=gt}return po(e,r,t,n,i)}),pp=oi(function(t,e){return Vn(t,1,e)}),hp=oi(function(t,e,n){return Vn(t,Su(e)||0,n)});Is.Cache=pn;var dp=jf(function(t,e){e=1==e.length&&wp(e[0])?p(e[0],T(jo())):p(rr(e,1),T(jo()));var n=e.length;return oi(function(r){for(var o=-1,a=Kl(r.length,n);++o=e}),bp=Ar(function(){return arguments}())?Ar:function(t){return cu(t)&&bl.call(t,"callee")&&!Rl.call(t,"callee")},wp=al.isArray,kp=lr?T(lr):Br,xp=Vl||Vc,Cp=fr?T(fr):Or,jp=pr?T(pr):Pr,Ep=hr?T(hr):Mr,Fp=dr?T(dr):Nr,Sp=vr?T(vr):Lr,Ap=uo(Ur),Bp=uo(function(t,e){return t<=e}),Op=Vi(function(t,e){if(Wo(e)||Ks(e))return void zi(e,Wu(e),t);for(var n in e)bl.call(e,n)&&Tn(t,n,e[n])}),Tp=Vi(function(t,e){zi(e,Vu(e),t)}),Rp=Vi(function(t,e,n,r){zi(e,Vu(e),t,r)}),Pp=Vi(function(t,e,n,r){zi(e,Wu(e),t,r)}),Ip=bo(Nn),Dp=oi(function(t){return t.push(et,ho),i(Rp,et,t)}),Mp=oi(function(t){return t.push(et,vo),i(qp,et,t)}),Np=no(function(t,e,n){t[e]=n},Tc(Pc)),Lp=no(function(t,e,n){bl.call(t,e)?t[e].push(n):t[e]=[n]},jo),Hp=oi(Sr),zp=Vi(function(t,e,n){Gr(t,e,n)}),qp=Vi(function(t,e,n,r){Gr(t,e,n,r)}),Up=bo(function(t,e){var n={};if(null==t)return n;var r=!1;e=p(e,function(e){return e=Ei(e,t),r||(r=e.length>1),e}),zi(t,ko(t),n),r&&(n=qn(n,ct|lt|ft,_o));for(var i=e.length;i--;)mi(n,e[i]);return n}),Wp=bo(function(t,e){return null==t?{}:Qr(t,e)}),Vp=fo(Wu),$p=fo(Vu),Gp=Ki(function(t,e,n){return e=e.toLowerCase(),t+(n?uc(e):e)}),Jp=Ki(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()}),Xp=Ki(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()}),Kp=Xi("toLowerCase"),Qp=Ki(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()}),Zp=Ki(function(t,e,n){return t+(n?" ":"")+th(e)}),Yp=Ki(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()}),th=Xi("toUpperCase"),eh=oi(function(t,e){try{return i(t,et,e)}catch(t){return ru(t)?t:new ul(t)}}),nh=bo(function(t,e){return a(e,function(e){e=ra(e),Mn(t,e,lp(t[e],t))}),t}),rh=to(),ih=to(!0),oh=oi(function(t,e){return function(n){return Sr(n,t,e)}}),ah=oi(function(t,e){return function(n){return Sr(t,n,e)}}),sh=io(p),uh=io(u),ch=io(_),lh=so(),fh=so(!0),ph=ro(function(t,e){return t+e},0),hh=lo("ceil"),dh=ro(function(t,e){return t/e},1),vh=lo("floor"),_h=ro(function(t,e){return t*e},1),yh=lo("round"),mh=ro(function(t,e){return t-e},0);return y.after=Ss,y.ary=As,y.assign=Op,y.assignIn=Tp,y.assignInWith=Rp,y.assignWith=Pp,y.at=Ip,y.before=Bs,y.bind=lp,y.bindAll=nh,y.bindKey=fp,y.castArray=Us,y.chain=ts,y.chunk=sa,y.compact=ua,y.concat=ca,y.cond=Bc,y.conforms=Oc,y.constant=Tc,y.countBy=ep,y.create=Tu,y.curry=Os,y.curryRight=Ts,y.debounce=Rs,y.defaults=Dp,y.defaultsDeep=Mp,y.defer=pp,y.delay=hp,y.difference=Mf,y.differenceBy=Nf,y.differenceWith=Lf,y.drop=la,y.dropRight=fa,y.dropRightWhile=pa,y.dropWhile=ha,y.fill=da,y.filter=fs,y.flatMap=ps,y.flatMapDeep=hs,y.flatMapDepth=ds,y.flatten=ya,y.flattenDeep=ma,y.flattenDepth=ga,y.flip=Ps,y.flow=rh,y.flowRight=ih,y.fromPairs=ba,y.functions=Lu,y.functionsIn=Hu,y.groupBy=ip,y.initial=xa,y.intersection=Hf,y.intersectionBy=zf,y.intersectionWith=qf,y.invert=Np,y.invertBy=Lp,y.invokeMap=op,y.iteratee=Ic,y.keyBy=ap,y.keys=Wu,y.keysIn=Vu,y.map=ms,y.mapKeys=$u,y.mapValues=Gu,y.matches=Dc,y.matchesProperty=Mc,y.memoize=Is,y.merge=zp,y.mergeWith=qp,y.method=oh,y.methodOf=ah,y.mixin=Nc,y.negate=Ds,y.nthArg=zc,y.omit=Up,y.omitBy=Ju,y.once=Ms,y.orderBy=gs,y.over=sh,y.overArgs=dp,y.overEvery=uh,y.overSome=ch,y.partial=vp,y.partialRight=_p,y.partition=sp,y.pick=Wp,y.pickBy=Xu,y.property=qc,y.propertyOf=Uc,y.pull=Uf,y.pullAll=Sa,y.pullAllBy=Aa,y.pullAllWith=Ba,y.pullAt=Wf,y.range=lh,y.rangeRight=fh,y.rearg=yp,y.reject=ks,y.remove=Oa,y.rest=Ns,y.reverse=Ta,y.sampleSize=Cs,y.set=Qu,y.setWith=Zu,y.shuffle=js,y.slice=Ra,y.sortBy=up,y.sortedUniq=Ha,y.sortedUniqBy=za,y.split=gc,y.spread=Ls,y.tail=qa,y.take=Ua,y.takeRight=Wa,y.takeRightWhile=Va,y.takeWhile=$a,y.tap=es,y.throttle=Hs,y.thru=ns,y.toArray=Cu,y.toPairs=Vp,y.toPairsIn=$p,y.toPath=Kc,y.toPlainObject=Au,y.transform=Yu,y.unary=zs,y.union=Vf,y.unionBy=$f,y.unionWith=Gf,y.uniq=Ga,y.uniqBy=Ja,y.uniqWith=Xa,y.unset=tc,y.unzip=Ka,y.unzipWith=Qa,y.update=ec,y.updateWith=nc,y.values=rc,y.valuesIn=ic,y.without=Jf,y.words=Ac,y.wrap=qs,y.xor=Xf,y.xorBy=Kf,y.xorWith=Qf,y.zip=Zf,y.zipObject=Za,y.zipObjectDeep=Ya,y.zipWith=Yf,y.entries=Vp,y.entriesIn=$p,y.extend=Tp,y.extendWith=Rp,Nc(y,y),y.add=ph,y.attempt=eh,y.camelCase=Gp,y.capitalize=uc,y.ceil=hh,y.clamp=oc,y.clone=Ws,y.cloneDeep=$s,y.cloneDeepWith=Gs,y.cloneWith=Vs,y.conformsTo=Js,y.deburr=cc,y.defaultTo=Rc,y.divide=dh,y.endsWith=lc,y.eq=Xs,y.escape=fc,y.escapeRegExp=pc,y.every=ls,y.find=np,y.findIndex=va,y.findKey=Ru,y.findLast=rp,y.findLastIndex=_a,y.findLastKey=Pu,y.floor=vh,y.forEach=vs,y.forEachRight=_s,y.forIn=Iu,y.forInRight=Du,y.forOwn=Mu,y.forOwnRight=Nu,y.get=zu,y.gt=mp,y.gte=gp,y.has=qu,y.hasIn=Uu,y.head=wa,y.identity=Pc,y.includes=ys,y.indexOf=ka,y.inRange=ac,y.invoke=Hp,y.isArguments=bp,y.isArray=wp,y.isArrayBuffer=kp,y.isArrayLike=Ks,y.isArrayLikeObject=Qs,y.isBoolean=Zs,y.isBuffer=xp,y.isDate=Cp,y.isElement=Ys,y.isEmpty=tu,y.isEqual=eu,y.isEqualWith=nu,y.isError=ru,y.isFinite=iu,y.isFunction=ou,y.isInteger=au,y.isLength=su,y.isMap=jp,y.isMatch=lu,y.isMatchWith=fu,y.isNaN=pu,y.isNative=hu,y.isNil=vu,y.isNull=du,y.isNumber=_u,y.isObject=uu,y.isObjectLike=cu,y.isPlainObject=yu,y.isRegExp=Ep,y.isSafeInteger=mu,y.isSet=Fp,y.isString=gu,y.isSymbol=bu,y.isTypedArray=Sp,y.isUndefined=wu,y.isWeakMap=ku,y.isWeakSet=xu,y.join=Ca,y.kebabCase=Jp,y.last=ja,y.lastIndexOf=Ea,y.lowerCase=Xp,y.lowerFirst=Kp,y.lt=Ap,y.lte=Bp,y.max=Zc,y.maxBy=Yc,y.mean=tl,y.meanBy=el,y.min=nl,y.minBy=rl,y.stubArray=Wc,y.stubFalse=Vc,y.stubObject=$c,y.stubString=Gc,y.stubTrue=Jc,y.multiply=_h,y.nth=Fa,y.noConflict=Lc,y.noop=Hc,y.now=cp,y.pad=hc,y.padEnd=dc,y.padStart=vc,y.parseInt=_c,y.random=sc,y.reduce=bs,y.reduceRight=ws,y.repeat=yc,y.replace=mc,y.result=Ku,y.round=yh,y.runInContext=e,y.sample=xs,y.size=Es,y.snakeCase=Qp,y.some=Fs,y.sortedIndex=Pa,y.sortedIndexBy=Ia,y.sortedIndexOf=Da,y.sortedLastIndex=Ma,y.sortedLastIndexBy=Na,y.sortedLastIndexOf=La,y.startCase=Zp,y.startsWith=bc,y.subtract=mh,y.sum=il,y.sumBy=ol,y.template=wc,y.times=Xc,y.toFinite=ju,y.toInteger=Eu,y.toLength=Fu,y.toLower=kc,y.toNumber=Su,y.toSafeInteger=Bu,y.toString=Ou,y.toUpper=xc,y.trim=Cc,y.trimEnd=jc,y.trimStart=Ec,y.truncate=Fc,y.unescape=Sc,y.uniqueId=Qc,y.upperCase=Yp,y.upperFirst=th,y.each=vs,y.eachRight=_s,y.first=wa,Nc(y,function(){var t={};return or(y,function(e,n){bl.call(y.prototype,n)||(t[n]=e)}),t}(),{chain:!1}),y.VERSION=nt,a(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){y[t].placeholder=y}),a(["drop","take"],function(t,e){Z.prototype[t]=function(n){n=n===et?1:Xl(Eu(n),0);var r=this.__filtered__&&!e?new Z(this):this.clone();return r.__filtered__?r.__takeCount__=Kl(n,r.__takeCount__):r.__views__.push({size:Kl(n,It),type:t+(r.__dir__<0?"Right":"")}),r},Z.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),a(["filter","map","takeWhile"],function(t,e){var n=e+1,r=n==St||n==Bt;Z.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:jo(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}}),a(["head","last"],function(t,e){var n="take"+(e?"Right":"");Z.prototype[t]=function(){return this[n](1).value()[0]}}),a(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");Z.prototype[t]=function(){return this.__filtered__?new Z(this):this[n](1)}}),Z.prototype.compact=function(){return this.filter(Pc)},Z.prototype.find=function(t){return this.filter(t).head()},Z.prototype.findLast=function(t){return this.reverse().find(t)},Z.prototype.invokeMap=oi(function(t,e){return"function"==typeof t?new Z(this):this.map(function(n){return Sr(n,t,e)})}),Z.prototype.reject=function(t){return this.filter(Ds(jo(t)))},Z.prototype.slice=function(t,e){t=Eu(t);var n=this;return n.__filtered__&&(t>0||e<0)?new Z(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==et&&(e=Eu(e),n=e<0?n.dropRight(-e):n.take(e-t)),n)},Z.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Z.prototype.toArray=function(){return this.take(It)},or(Z.prototype,function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=y[r?"take"+("last"==e?"Right":""):e],o=r||/^find/.test(e);i&&(y.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,s=e instanceof Z,u=a[0],c=s||wp(e),l=function(t){var e=i.apply(y,h([t],a));return r&&f?e[0]:e};c&&n&&"function"==typeof u&&1!=u.length&&(s=c=!1);var f=this.__chain__,p=!!this.__actions__.length,d=o&&!f,v=s&&!p;if(!o&&c){e=v?e:new Z(this);var _=t.apply(e,a);return _.__actions__.push({func:ns,args:[l],thisArg:et}),new J(_,f)}return d&&v?t.apply(this,a):(_=this.thru(l),d?r?_.value()[0]:_.value():_)})}),a(["pop","push","shift","sort","splice","unshift"],function(t){var e=vl[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);y.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(wp(i)?i:[],t)}return this[n](function(n){return e.apply(wp(n)?n:[],t)})}}),or(Z.prototype,function(t,e){var n=y[e];if(n){var r=n.name+"",i=cf[r]||(cf[r]=[]);i.push({name:e,func:n})}}),cf[eo(et,vt).name]=[{name:"wrapper",func:et}],Z.prototype.clone=Y,Z.prototype.reverse=He,Z.prototype.value=Ze,y.prototype.at=tp,y.prototype.chain=rs,y.prototype.commit=is,y.prototype.next=os,y.prototype.plant=ss,y.prototype.reverse=us,y.prototype.toJSON=y.prototype.valueOf=y.prototype.value=cs,y.prototype.first=y.prototype.head,Dl&&(y.prototype[Dl]=as),y},wr=br();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(ir._=wr,define(function(){return wr})):ar?((ar.exports=wr)._=wr,or._=wr):ir._=wr}).call(this)},{}],86:[function(t,e,n){!function(t){function r(t){for(var e,n,r=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e-=65536,i+=m(e>>>10&1023|55296),e=56320|1023&e),i+=m(e);return i}function o(t){if(t>=55296&&t<=57343)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value")}function a(t,e){return m(t>>e&63|128)}function s(t){if(0==(4294967168&t))return m(t);var e="";return 0==(4294965248&t)?e=m(t>>6&31|192):0==(4294901760&t)?(o(t),e=m(t>>12&15|224),e+=a(t,6)):0==(4292870144&t)&&(e=m(t>>18&7|240),e+=a(t,12),e+=a(t,6)),e+=m(63&t|128)}function u(t){for(var e,n=r(t),i=n.length,o=-1,a="";++o=_)throw Error("Invalid byte index");var t=255&v[y];if(y++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function l(){var t,e,n,r,i;if(y>_)throw Error("Invalid byte index");if(y==_)return!1;if(t=255&v[y],y++,0==(128&t))return t;if(192==(224&t)){if(e=c(),i=(31&t)<<6|e,i>=128)return i;throw Error("Invalid continuation byte")}if(224==(240&t)){if(e=c(),n=c(),i=(15&t)<<12|e<<6|n,i>=2048)return o(i),i;throw Error("Invalid continuation byte")}if(240==(248&t)&&(e=c(),n=c(),r=c(),i=(7&t)<<18|e<<12|n<<6|r,i>=65536&&i<=1114111))return i;throw Error("Invalid UTF-8 detected")}function f(t){v=r(t),_=v.length,y=0;for(var e,n=[];(e=l())!==!1;)n.push(e);return i(n)}var p="object"==typeof n&&n,h="object"==typeof e&&e&&e.exports==p&&e,d="object"==typeof global&&global;d.global!==d&&d.window!==d||(t=d);var v,_,y,m=String.fromCharCode,g={version:"2.1.2",encode:u,decode:f};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return g});else if(p&&!p.nodeType)if(h)h.exports=g;else{var b={},w=b.hasOwnProperty;for(var k in g)w.call(g,k)&&(p[k]=g[k])}else t.utf8=g}(this)},{}],87:[function(t,e,n){e.exports=XMLHttpRequest},{}],"bignumber.js":[function(t,e,n){!function(n){"use strict";function r(t){function e(t,r){var i,o,a,s,u,c,l=this;if(!(l instanceof e))return W&&T(26,"constructor call without new",t),new e(t,r);if(null!=r&&V(r,2,64,I,"base")){if(r=0|r,c=t+"",10==r)return l=new e(t instanceof e?t:c),R(l,N+l.e+1,L);if((s="number"==typeof t)&&0*t!=0||!new RegExp("^-?"+(i="["+k.slice(0,r)+"]+")+"(?:\\."+i+")?$",r<37?"i":"").test(c))return v(l,c,s,r);s?(l.s=1/t<0?(c=c.slice(1),-1):1,W&&c.replace(/^0\.0*|\./,"").length>15&&T(I,w,t),s=!1):l.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1,c=n(c,10,r,l.s)}else{if(t instanceof e)return l.s=t.s,l.e=t.e,l.c=(t=t.c)?t.slice():t,void(I=0);if((s="number"==typeof t)&&0*t==0){if(l.s=1/t<0?(t=-t,-1):1,t===~~t){for(o=0,a=t;a>=10;a/=10,o++);return l.e=o,l.c=[t],void(I=0)}c=t+""}else{if(!_.test(c=t+""))return v(l,c,s);l.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1}}for((o=c.indexOf("."))>-1&&(c=c.replace(".","")),(a=c.search(/e/i))>0?(o<0&&(o=a),o+=+c.slice(a+1),c=c.substring(0,a)):o<0&&(o=c.length),a=0;48===c.charCodeAt(a);a++);for(u=c.length;48===c.charCodeAt(--u););if(c=c.slice(a,u+1))if(u=c.length,s&&W&&u>15&&T(I,w,l.s*t),o=o-a-1,o>U)l.c=l.e=null;else if(o=0&&(u=J,J=0,t=t.replace(".",""),d=new e(r),p=d.pow(t.length-v),J=u,d.c=c(f(o(p.c),p.e),10,n),d.e=d.c.length),h=c(t,r,n),s=u=h.length;0==h[--u];h.pop());if(!h[0])return"0";if(v<0?--s:(p.c=h,p.e=s,p.s=i,p=P(p,d,_,y,n),h=p.c,l=p.r,s=p.e),a=s+_+1,v=h[a],u=n/2,l=l||a<0||null!=h[a+1],l=y<4?(null!=v||l)&&(0==y||y==(p.s<0?3:2)):v>u||v==u&&(4==y||l||6==y&&1&h[a-1]||y==(p.s<0?8:7)),a<1||!h[0])t=l?f("1",-_):"0";else{if(h.length=a,l)for(--n;++h[--a]>n;)h[a]=0,a||(++s,h.unshift(1));for(u=h.length;!h[--u];);for(v=0,t="";v<=u;t+=k.charAt(h[v++]));t=f(t,s)}return t}function h(t,n,r,i){var a,s,u,c,p;if(r=null!=r&&V(r,0,8,i,b)?0|r:L,!t.c)return t.toString();if(a=t.c[0],u=t.e,null==n)p=o(t.c),p=19==i||24==i&&u<=H?l(p,u):f(p,u);else if(t=R(new e(t),n,r),s=t.e,p=o(t.c),c=p.length,19==i||24==i&&(n<=s||s<=H)){for(;cc){if(--n>0)for(p+=".";n--;p+="0");}else if(n+=s-c,n>0)for(s+1==c&&(p+=".");n--;p+="0");return t.s<0&&a?"-"+p:p}function A(t,n){var r,i,o=0;for(u(t[0])&&(t=t[0]),r=new e(t[0]);++on||t!=p(t))&&T(r,(i||"decimal places")+(tn?" out of range":" not an integer"),t),!0}function O(t,e,n){for(var r=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,r++);return(n=r+n*C-1)>U?t.c=t.e=null:n=10;s/=10,i++);if(o=e-i,o<0)o+=C,a=e,u=f[c=0],l=u/p[i-a-1]%10|0;else if(c=y((o+1)/C),c>=f.length){if(!r)break t;for(;f.length<=c;f.push(0));u=l=0,i=1,o%=C,a=o-C+1}else{for(u=s=f[c],i=1;s>=10;s/=10,i++);o%=C,a=o-C+i,l=a<0?0:u/p[i-a-1]%10|0}if(r=r||e<0||null!=f[c+1]||(a<0?u:u%p[i-a-1]),r=n<4?(l||r)&&(0==n||n==(t.s<0?3:2)):l>5||5==l&&(4==n||r||6==n&&(o>0?a>0?u/p[i-a]:0:f[c-1])%10&1||n==(t.s<0?8:7)),e<1||!f[0])return f.length=0,r?(e-=t.e+1,f[0]=p[e%C],t.e=-e||0):f[0]=t.e=0,t;if(0==o?(f.length=c,s=1,c--):(f.length=c+1,s=p[C-o],f[c]=a>0?m(u/p[i-a]%p[a])*s:0),r)for(;;){if(0==c){for(o=1,a=f[0];a>=10;a/=10,o++);for(a=f[0]+=s,s=1;a>=10;a/=10,s++);o!=s&&(t.e++,f[0]==x&&(f[0]=1));break}if(f[c]+=s,f[c]!=x)break;f[c--]=0,s=1}for(o=f.length;0===f[--o];f.pop());}t.e>U?t.c=t.e=null:t.en)return null!=(t=i[n++])};return a(e="DECIMAL_PLACES")&&V(t,0,S,2,e)&&(N=0|t),r[e]=N,a(e="ROUNDING_MODE")&&V(t,0,8,2,e)&&(L=0|t),r[e]=L,a(e="EXPONENTIAL_AT")&&(u(t)?V(t[0],-S,0,2,e)&&V(t[1],0,S,2,e)&&(H=0|t[0],z=0|t[1]):V(t,-S,S,2,e)&&(H=-(z=0|(t<0?-t:t)))),r[e]=[H,z],a(e="RANGE")&&(u(t)?V(t[0],-S,-1,2,e)&&V(t[1],1,S,2,e)&&(q=0|t[0],U=0|t[1]):V(t,-S,S,2,e)&&(0|t?q=-(U=0|(t<0?-t:t)):W&&T(2,e+" cannot be zero",t))),r[e]=[q,U],a(e="ERRORS")&&(t===!!t||1===t||0===t?(I=0,V=(W=!!t)?B:s):W&&T(2,e+g,t)),r[e]=W,a(e="CRYPTO")&&(t===!!t||1===t||0===t?($=!(!t||!d||"object"!=typeof d),t&&!$&&W&&T(2,"crypto unavailable",d)):W&&T(2,e+g,t)),r[e]=$,a(e="MODULO_MODE")&&V(t,0,9,2,e)&&(G=0|t),r[e]=G,a(e="POW_PRECISION")&&V(t,0,S,2,e)&&(J=0|t),r[e]=J,a(e="FORMAT")&&("object"==typeof t?X=t:W&&T(2,e+" not an object",t)),r[e]=X,r},e.max=function(){return A(arguments,D.lt)},e.min=function(){return A(arguments,D.gt)},e.random=function(){var t=9007199254740992,n=Math.random()*t&2097151?function(){return m(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,i,o,a,s,u=0,c=[],l=new e(M);if(t=null!=t&&V(t,0,S,14)?0|t:N,a=y(t/C),$)if(d&&d.getRandomValues){for(r=d.getRandomValues(new Uint32Array(a*=2));u>>11),s>=9e15?(i=d.getRandomValues(new Uint32Array(2)),r[u]=i[0],r[u+1]=i[1]):(c.push(s%1e14),u+=2);u=a/2}else if(d&&d.randomBytes){for(r=d.randomBytes(a*=7);u=9e15?d.randomBytes(7).copy(r,u):(c.push(s%1e14),u+=7);u=a/7}else W&&T(14,"crypto unavailable",d);if(!u)for(;u=10;s/=10,u++);ur?1:-1;else for(i=o=0;ie[i]?1:-1;break}return o}function r(t,e,n,r){for(var i=0;n--;)t[n]-=i,i=t[n]1;t.shift());}return function(o,a,s,u,c){var l,f,p,h,d,v,_,y,g,b,w,k,j,E,F,S,A,B=o.s==a.s?1:-1,O=o.c,T=a.c;if(!(O&&O[0]&&T&&T[0]))return new e(o.s&&a.s&&(O?!T||O[0]!=T[0]:T)?O&&0==O[0]||!T?0*B:B/0:NaN);for(y=new e(B),g=y.c=[],f=o.e-a.e,B=s+f+1,c||(c=x,f=i(o.e/C)-i(a.e/C),B=B/C|0),p=0;T[p]==(O[p]||0);p++);if(T[p]>(O[p]||0)&&f--,B<0)g.push(1),h=!0;else{for(E=O.length,S=T.length,p=0,B+=2,d=m(c/(T[0]+1)),d>1&&(T=t(T,d,c),O=t(O,d,c),S=T.length,E=O.length),j=S,b=O.slice(0,S),w=b.length;w=c/2&&F++;do{if(d=0,l=n(T,b,S,w),l<0){if(k=b[0],S!=w&&(k=k*c+(b[1]||0)),d=m(k/F),d>1)for(d>=c&&(d=c-1),v=t(T,d,c),_=v.length,w=b.length;1==n(v,b,_,w);)d--,r(v,S<_?A:T,_,c),_=v.length,l=1;else 0==d&&(l=d=1),v=T.slice(),_=v.length;if(_=10;B/=10,p++);R(y,s+(y.e=p+f*C-1)+1,u,h)}else y.e=f,y.r=+h;return y}}(),v=function(){var t=/^(-?)0([xbo])/i,n=/^([^.]+)\.$/,r=/^\.([^.]+)$/,i=/^-?(Infinity|NaN)$/,o=/^\s*\+|^\s+|\s+$/g;return function(a,s,u,c){var l,f=u?s:s.replace(o,"");if(i.test(f))a.s=isNaN(f)?null:f<0?-1:1;else{if(!u&&(f=f.replace(t,function(t,e,n){return l="x"==(n=n.toLowerCase())?16:"b"==n?2:8,c&&c!=l?t:e}),c&&(l=c,f=f.replace(n,"$1").replace(r,"0.$1")),s!=f))return new e(f,l);W&&T(I,"not a"+(c?" base "+c:"")+" number",s),a.s=null}a.c=a.e=null,I=0}}(),D.absoluteValue=D.abs=function(){var t=new e(this);return t.s<0&&(t.s=1),t},D.ceil=function(){return R(new e(this),this.e+1,2)},D.comparedTo=D.cmp=function(t,n){return I=1,a(this,new e(t,n))},D.decimalPlaces=D.dp=function(){var t,e,n=this.c;if(!n)return null;if(t=((e=n.length-1)-i(this.e/C))*C,e=n[e])for(;e%10==0;e/=10,t--);return t<0&&(t=0),t},D.dividedBy=D.div=function(t,n){return I=3,P(this,new e(t,n),N,L)},D.dividedToIntegerBy=D.divToInt=function(t,n){return I=4,P(this,new e(t,n),0,1)},D.equals=D.eq=function(t,n){return I=5,0===a(this,new e(t,n))},D.floor=function(){return R(new e(this),this.e+1,3)},D.greaterThan=D.gt=function(t,n){return I=6,a(this,new e(t,n))>0},D.greaterThanOrEqualTo=D.gte=function(t,n){return I=7,1===(n=a(this,new e(t,n)))||0===n},D.isFinite=function(){return!!this.c},D.isInteger=D.isInt=function(){return!!this.c&&i(this.e/C)>this.c.length-2},D.isNaN=function(){return!this.s},D.isNegative=D.isNeg=function(){return this.s<0},D.isZero=function(){return!!this.c&&0==this.c[0]},D.lessThan=D.lt=function(t,n){return I=8,a(this,new e(t,n))<0},D.lessThanOrEqualTo=D.lte=function(t,n){return I=9,(n=a(this,new e(t,n)))===-1||0===n},D.minus=D.sub=function(t,n){var r,o,a,s,u=this,c=u.s;if(I=10,t=new e(t,n),n=t.s,!c||!n)return new e(NaN);if(c!=n)return t.s=-n,u.plus(t);var l=u.e/C,f=t.e/C,p=u.c,h=t.c;if(!l||!f){if(!p||!h)return p?(t.s=-n,t):new e(h?u:NaN);if(!p[0]||!h[0])return h[0]?(t.s=-n,t):new e(p[0]?u:3==L?-0:0)}if(l=i(l),f=i(f),p=p.slice(),c=l-f){for((s=c<0)?(c=-c,a=p):(f=l,a=h),a.reverse(),n=c;n--;a.push(0));a.reverse()}else for(o=(s=(c=p.length)<(n=h.length))?c:n,c=n=0;n0)for(;n--;p[r++]=0);for(n=x-1;o>c;){if(p[--o]0?(u=s,r=l):(a=-a,r=c),r.reverse();a--;r.push(0));r.reverse()}for(a=c.length,n=l.length,a-n<0&&(r=l,l=c,c=r,n=a),a=0;n;)a=(c[--n]=c[n]+l[n]+a)/x|0,c[n]%=x;return a&&(c.unshift(a),++u),O(t,c,u)},D.precision=D.sd=function(t){var e,n,r=this,i=r.c;if(null!=t&&t!==!!t&&1!==t&&0!==t&&(W&&T(13,"argument"+g,t),t!=!!t&&(t=null)),!i)return null;if(n=i.length-1,e=n*C+1,n=i[n]){for(;n%10==0;n/=10,e--);for(n=i[0];n>=10;n/=10,e++);}return t&&r.e+1>e&&(e=r.e+1),e},D.round=function(t,n){var r=new e(this);return(null==t||V(t,0,S,15))&&R(r,~~t+this.e+1,null!=n&&V(n,0,8,15,b)?0|n:L),r},D.shift=function(t){var n=this;return V(t,-j,j,16,"argument")?n.times("1e"+p(t)):new e(n.c&&n.c[0]&&(t<-j||t>j)?n.s*(t<0?0:1/0):n)},D.squareRoot=D.sqrt=function(){var t,n,r,a,s,u=this,c=u.c,l=u.s,f=u.e,p=N+4,h=new e("0.5");if(1!==l||!c||!c[0])return new e(!l||l<0&&(!c||c[0])?NaN:c?u:1/0);if(l=Math.sqrt(+u),0==l||l==1/0?(n=o(c),(n.length+f)%2==0&&(n+="0"),l=Math.sqrt(n),f=i((f+1)/2)-(f<0||f%2),l==1/0?n="1e"+f:(n=l.toExponential(),n=n.slice(0,n.indexOf("e")+1)+f),r=new e(n)):r=new e(l+""),r.c[0])for(f=r.e,l=f+p,l<3&&(l=0);;)if(s=r,r=h.times(s.plus(P(u,s,p,1))),o(s.c).slice(0,l)===(n=o(r.c)).slice(0,l)){if(r.e=0;){for(r=0,d=w[a]%m,v=w[a]/m|0,u=l,s=a+u;s>a;)f=b[--u]%m,p=b[u]/m|0,c=v*f+p*d,f=d*f+c%m*m+_[s]+r,r=(f/y|0)+(c/m|0)+v*p,_[s--]=f%y;_[s]=r}return r?++o:_.shift(),O(t,_,o)},D.toDigits=function(t,n){var r=new e(this);return t=null!=t&&V(t,1,S,18,"precision")?0|t:null,n=null!=n&&V(n,0,8,18,b)?0|n:L,t?R(r,t,n):r},D.toExponential=function(t,e){return h(this,null!=t&&V(t,0,S,19)?~~t+1:null,e,19)},D.toFixed=function(t,e){return h(this,null!=t&&V(t,0,S,20)?~~t+this.e+1:null,e,20)},D.toFormat=function(t,e){var n=h(this,null!=t&&V(t,0,S,21)?~~t+this.e+1:null,e,21);if(this.c){var r,i=n.split("."),o=+X.groupSize,a=+X.secondaryGroupSize,s=X.groupSeparator,u=i[0],c=i[1],l=this.s<0,f=l?u.slice(1):u,p=f.length;if(a&&(r=o,o=a,a=r,p-=r),o>0&&p>0){for(r=p%o||o,u=f.substr(0,r);r0&&(u+=s+f.slice(r)),l&&(u="-"+u)}n=c?u+X.decimalSeparator+((a=+X.fractionGroupSize)?c.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+X.fractionGroupSeparator):c):u}return n},D.toFraction=function(t){var n,r,i,a,s,u,c,l,f,p=W,h=this,d=h.c,v=new e(M),_=r=new e(M),y=c=new e(M);if(null!=t&&(W=!1,u=new e(t),W=p,(p=u.isInt())&&!u.lt(M)||(W&&T(22,"max denominator "+(p?"out of range":"not an integer"),t),t=!p&&u.c&&R(u,u.e+1,1).gte(M)?u:null)),!d)return h.toString();for(f=o(d),a=v.e=f.length-h.e-1,v.c[0]=E[(s=a%C)<0?C+s:s],t=!t||u.cmp(v)>0?a>0?v:_:u,s=U,U=1/0,u=new e(f),c.c[0]=0;l=P(u,v,0,1),i=r.plus(l.times(y)),1!=i.cmp(t);)r=y,y=i,_=c.plus(l.times(i=_)),c=i,v=u.minus(l.times(i=v)),u=i;return i=P(t.minus(r),y,0,1),c=c.plus(i.times(_)),r=r.plus(i.times(y)),c.s=_.s=h.s,a*=2,n=P(_,y,a,L).minus(h).abs().cmp(P(c,r,a,L).minus(h).abs())<1?[_.toString(),y.toString()]:[c.toString(),r.toString()],U=s,n},D.toNumber=function(){var t=this;return+t||(t.s?0*t.s:NaN)},D.toPower=D.pow=function(t){var n,r,i=m(t<0?-t:+t),o=this;if(!V(t,-j,j,23,"exponent")&&(!isFinite(t)||i>j&&(t/=0)||parseFloat(t)!=t&&!(t=NaN)))return new e(Math.pow(+o,t));for(n=J?y(J/C+2):0,r=new e(M);;){if(i%2){if(r=r.times(o),!r.c)break;n&&r.c.length>n&&(r.c.length=n)}if(i=m(i/2),!i)break;o=o.times(o),n&&o.c&&o.c.length>n&&(o.c.length=n)}return t<0&&(r=M.div(r)),n?R(r,J,L):r},D.toPrecision=function(t,e){return h(this,null!=t&&V(t,1,S,24,"precision")?0|t:null,e,24)},D.toString=function(t){var e,r=this,i=r.s,a=r.e;return null===a?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(e=o(r.c),e=null!=t&&V(t,2,64,25,"base")?n(f(e,a),0|t,10,i):a<=H||a>=z?l(e,a):f(e,a),i<0&&r.c[0]&&(e="-"+e)),e},D.truncated=D.trunc=function(){return R(new e(this),this.e+1,1)},D.valueOf=D.toJSON=function(){return this.toString()},null!=t&&e.config(t),e}function i(t){var e=0|t;return t>0||t===e?e:e-1}function o(t){for(var e,n,r=1,i=t.length,o=t[0]+"";rc^n?1:-1;for(s=(u=i.length)<(c=o.length)?u:c,a=0;ao[a]^n?1:-1;return u==c?0:u>c^n?1:-1}function s(t,e,n){return(t=p(t))>=e&&t<=n}function u(t){return"[object Array]"==Object.prototype.toString.call(t)}function c(t,e,n){for(var r,i,o=[0],a=0,s=t.length;an-1&&(null==o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}function l(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function f(t,e){var n,r;if(e<0){for(r="0.";++e;r+="0");t=r+t}else if(n=t.length,++e>n){for(r="0",e-=n;--e;r+="0");t+=r}else er?1:-1;else for(i=o=0;ie[i]?1:-1;break}return o}function r(t,e,n,r){for(var i=0;n--;)t[n]-=i,i=t[n]1;t.shift());}return function(o,a,s,u,c){var l,f,p,h,d,v,_,y,g,b,w,k,j,E,F,S,A,B=o.s==a.s?1:-1,O=o.c,T=a.c;if(!(O&&O[0]&&T&&T[0]))return new e(o.s&&a.s&&(O?!T||O[0]!=T[0]:T)?O&&0==O[0]||!T?0*B:B/0:NaN);for(y=new e(B),g=y.c=[],f=o.e-a.e,B=s+f+1,c||(c=x,f=i(o.e/C)-i(a.e/C),B=B/C|0),p=0;T[p]==(O[p]||0);p++);if(T[p]>(O[p]||0)&&f--,B<0)g.push(1),h=!0;else{for(E=O.length,S=T.length,p=0,B+=2,d=m(c/(T[0]+1)),d>1&&(T=t(T,d,c),O=t(O,d,c),S=T.length,E=O.length),j=S,b=O.slice(0,S),w=b.length;w=c/2&&F++;do{if(d=0,l=n(T,b,S,w),l<0){if(k=b[0],S!=w&&(k=k*c+(b[1]||0)),d=m(k/F),d>1)for(d>=c&&(d=c-1),v=t(T,d,c),_=v.length,w=b.length;1==n(v,b,_,w);)d--,r(v,S<_?A:T,_,c),_=v.length,l=1;else 0==d&&(l=d=1),v=T.slice(),_=v.length;if(_=10;B/=10,p++);R(y,s+(y.e=p+f*C-1)+1,u,h)}else y.e=f,y.r=+h;return y}}(),v=function(){var t=/^(-?)0([xbo])/i,n=/^([^.]+)\.$/,r=/^\.([^.]+)$/,i=/^-?(Infinity|NaN)$/,o=/^\s*\+|^\s+|\s+$/g;return function(a,s,u,c){var l,f=u?s:s.replace(o,"");if(i.test(f))a.s=isNaN(f)?null:f<0?-1:1;else{if(!u&&(f=f.replace(t,function(t,e,n){return l="x"==(n=n.toLowerCase())?16:"b"==n?2:8,c&&c!=l?t:e}),c&&(l=c,f=f.replace(n,"$1").replace(r,"0.$1")),s!=f))return new e(f,l);W&&T(I,"not a"+(c?" base "+c:"")+" number",s),a.s=null}a.c=a.e=null,I=0}}(),D.absoluteValue=D.abs=function(){var t=new e(this);return t.s<0&&(t.s=1),t},D.ceil=function(){return R(new e(this),this.e+1,2)},D.comparedTo=D.cmp=function(t,n){return I=1,a(this,new e(t,n))},D.decimalPlaces=D.dp=function(){var t,e,n=this.c;if(!n)return null;if(t=((e=n.length-1)-i(this.e/C))*C,e=n[e])for(;e%10==0;e/=10,t--);return t<0&&(t=0),t},D.dividedBy=D.div=function(t,n){return I=3,P(this,new e(t,n),N,L)},D.dividedToIntegerBy=D.divToInt=function(t,n){return I=4,P(this,new e(t,n),0,1)},D.equals=D.eq=function(t,n){return I=5,0===a(this,new e(t,n))},D.floor=function(){return R(new e(this),this.e+1,3)},D.greaterThan=D.gt=function(t,n){return I=6,a(this,new e(t,n))>0},D.greaterThanOrEqualTo=D.gte=function(t,n){return I=7,1===(n=a(this,new e(t,n)))||0===n},D.isFinite=function(){return!!this.c},D.isInteger=D.isInt=function(){return!!this.c&&i(this.e/C)>this.c.length-2},D.isNaN=function(){return!this.s},D.isNegative=D.isNeg=function(){return this.s<0},D.isZero=function(){return!!this.c&&0==this.c[0]},D.lessThan=D.lt=function(t,n){return I=8,a(this,new e(t,n))<0},D.lessThanOrEqualTo=D.lte=function(t,n){return I=9,(n=a(this,new e(t,n)))===-1||0===n},D.minus=D.sub=function(t,n){var r,o,a,s,u=this,c=u.s;if(I=10,t=new e(t,n),n=t.s,!c||!n)return new e(NaN);if(c!=n)return t.s=-n,u.plus(t);var l=u.e/C,f=t.e/C,p=u.c,h=t.c;if(!l||!f){if(!p||!h)return p?(t.s=-n,t):new e(h?u:NaN);if(!p[0]||!h[0])return h[0]?(t.s=-n,t):new e(p[0]?u:3==L?-0:0)}if(l=i(l),f=i(f),p=p.slice(),c=l-f){for((s=c<0)?(c=-c,a=p):(f=l,a=h),a.reverse(),n=c;n--;a.push(0));a.reverse()}else for(o=(s=(c=p.length)<(n=h.length))?c:n,c=n=0;n0)for(;n--;p[r++]=0);for(n=x-1;o>c;){if(p[--o]0?(u=s,r=l):(a=-a,r=c),r.reverse();a--;r.push(0));r.reverse()}for(a=c.length,n=l.length,a-n<0&&(r=l,l=c,c=r,n=a),a=0;n;)a=(c[--n]=c[n]+l[n]+a)/x|0,c[n]%=x;return a&&(c.unshift(a),++u),O(t,c,u)},D.precision=D.sd=function(t){var e,n,r=this,i=r.c;if(null!=t&&t!==!!t&&1!==t&&0!==t&&(W&&T(13,"argument"+g,t),t!=!!t&&(t=null)),!i)return null;if(n=i.length-1,e=n*C+1,n=i[n]){for(;n%10==0;n/=10,e--);for(n=i[0];n>=10;n/=10,e++);}return t&&r.e+1>e&&(e=r.e+1),e},D.round=function(t,n){var r=new e(this);return(null==t||V(t,0,S,15))&&R(r,~~t+this.e+1,null!=n&&V(n,0,8,15,b)?0|n:L),r},D.shift=function(t){var n=this;return V(t,-j,j,16,"argument")?n.times("1e"+p(t)):new e(n.c&&n.c[0]&&(t<-j||t>j)?n.s*(t<0?0:1/0):n)},D.squareRoot=D.sqrt=function(){var t,n,r,a,s,u=this,c=u.c,l=u.s,f=u.e,p=N+4,h=new e("0.5");if(1!==l||!c||!c[0])return new e(!l||l<0&&(!c||c[0])?NaN:c?u:1/0);if(l=Math.sqrt(+u),0==l||l==1/0?(n=o(c),(n.length+f)%2==0&&(n+="0"),l=Math.sqrt(n),f=i((f+1)/2)-(f<0||f%2),l==1/0?n="1e"+f:(n=l.toExponential(),n=n.slice(0,n.indexOf("e")+1)+f),r=new e(n)):r=new e(l+""),r.c[0])for(f=r.e,l=f+p,l<3&&(l=0);;)if(s=r,r=h.times(s.plus(P(u,s,p,1))),o(s.c).slice(0,l)===(n=o(r.c)).slice(0,l)){if(r.e=0;){for(r=0,d=w[a]%m,v=w[a]/m|0,u=l,s=a+u;s>a;)f=b[--u]%m,p=b[u]/m|0,c=v*f+p*d,f=d*f+c%m*m+_[s]+r,r=(f/y|0)+(c/m|0)+v*p,_[s--]=f%y;_[s]=r}return r?++o:_.shift(),O(t,_,o)},D.toDigits=function(t,n){var r=new e(this);return t=null!=t&&V(t,1,S,18,"precision")?0|t:null,n=null!=n&&V(n,0,8,18,b)?0|n:L,t?R(r,t,n):r},D.toExponential=function(t,e){return h(this,null!=t&&V(t,0,S,19)?~~t+1:null,e,19)},D.toFixed=function(t,e){return h(this,null!=t&&V(t,0,S,20)?~~t+this.e+1:null,e,20)},D.toFormat=function(t,e){var n=h(this,null!=t&&V(t,0,S,21)?~~t+this.e+1:null,e,21);if(this.c){var r,i=n.split("."),o=+X.groupSize,a=+X.secondaryGroupSize,s=X.groupSeparator,u=i[0],c=i[1],l=this.s<0,f=l?u.slice(1):u,p=f.length;if(a&&(r=o,o=a,a=r,p-=r),o>0&&p>0){for(r=p%o||o,u=f.substr(0,r);r0&&(u+=s+f.slice(r)),l&&(u="-"+u)}n=c?u+X.decimalSeparator+((a=+X.fractionGroupSize)?c.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+X.fractionGroupSeparator):c):u}return n},D.toFraction=function(t){var n,r,i,a,s,u,c,l,f,p=W,h=this,d=h.c,v=new e(M),_=r=new e(M),y=c=new e(M);if(null!=t&&(W=!1,u=new e(t),W=p,(p=u.isInt())&&!u.lt(M)||(W&&T(22,"max denominator "+(p?"out of range":"not an integer"),t),t=!p&&u.c&&R(u,u.e+1,1).gte(M)?u:null)),!d)return h.toString();for(f=o(d),a=v.e=f.length-h.e-1,v.c[0]=E[(s=a%C)<0?C+s:s],t=!t||u.cmp(v)>0?a>0?v:_:u,s=U,U=1/0,u=new e(f),c.c[0]=0;l=P(u,v,0,1),i=r.plus(l.times(y)),1!=i.cmp(t);)r=y,y=i,_=c.plus(l.times(i=_)),c=i,v=u.minus(l.times(i=v)),u=i;return i=P(t.minus(r),y,0,1),c=c.plus(i.times(_)),r=r.plus(i.times(y)),c.s=_.s=h.s,a*=2,n=P(_,y,a,L).minus(h).abs().cmp(P(c,r,a,L).minus(h).abs())<1?[_.toString(),y.toString()]:[c.toString(),r.toString()],U=s,n},D.toNumber=function(){var t=this;return+t||(t.s?0*t.s:NaN)},D.toPower=D.pow=function(t){var n,r,i=m(t<0?-t:+t),o=this;if(!V(t,-j,j,23,"exponent")&&(!isFinite(t)||i>j&&(t/=0)||parseFloat(t)!=t&&!(t=NaN)))return new e(Math.pow(+o,t));for(n=J?y(J/C+2):0,r=new e(M);;){if(i%2){if(r=r.times(o),!r.c)break;n&&r.c.length>n&&(r.c.length=n)}if(i=m(i/2),!i)break;o=o.times(o),n&&o.c&&o.c.length>n&&(o.c.length=n)}return t<0&&(r=M.div(r)),n?R(r,J,L):r},D.toPrecision=function(t,e){return h(this,null!=t&&V(t,1,S,24,"precision")?0|t:null,e,24)},D.toString=function(t){var e,r=this,i=r.s,a=r.e;return null===a?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(e=o(r.c),e=null!=t&&V(t,2,64,25,"base")?n(f(e,a),0|t,10,i):a<=H||a>=z?l(e,a):f(e,a),i<0&&r.c[0]&&(e="-"+e)),e},D.truncated=D.trunc=function(){return R(new e(this),this.e+1,1)},D.valueOf=D.toJSON=function(){return this.toString()},null!=t&&e.config(t),e}function i(t){var e=0|t;return t>0||t===e?e:e-1}function o(t){for(var e,n,r=1,i=t.length,o=t[0]+"";rc^n?1:-1;for(s=(u=i.length)<(c=o.length)?u:c,a=0;ao[a]^n?1:-1;return u==c?0:u>c^n?1:-1}function s(t,e,n){return(t=p(t))>=e&&t<=n}function u(t){return"[object Array]"==Object.prototype.toString.call(t)}function c(t,e,n){for(var r,i,o=[0],a=0,s=t.length;an-1&&(null==o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}function l(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function f(t,e){var n,r;if(e<0){for(r="0.";++e;r+="0");t=r+t}else if(n=t.length,++e>n){for(r="0",e-=n;--e;r+="0");t+=r}else e2&&"0x"===t.substr(0,2)&&(t=t.substr(2)),t=r.enc.Hex.parse(t)),o(t,{outputLength:256}).toString()}},{"crypto-js":59,"crypto-js/sha3":80}],20:[function(t,e,n){var r=t("bignumber.js"),o=t("./sha3.js"),i=t("utf8"),a={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",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",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"},s=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},c=function(t,e,n){return t+new Array(e-t.length+1).join(n?n:"0")},u=function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);n7&&t[n].toUpperCase()!==t[n]||parseInt(e[n],16)<=7&&t[n].toLowerCase()!==t[n])return!1;return!0},A=function(t){if("undefined"==typeof t)return"";t=t.toLowerCase().replace("0x","");for(var e=o(t),n="0x",r=0;r7?t[r].toUpperCase():t[r];return n},F=function(t){return B(t)?t:/^[0-9a-f]{40}$/.test(t)?"0x"+t:"0x"+s(v(t).substr(2),40)},I=function(t){return t instanceof r||t&&t.constructor&&"BigNumber"===t.constructor.name},O=function(t){return"string"==typeof t||t&&t.constructor&&"String"===t.constructor.name},N=function(t){return"function"==typeof t},T=function(t){return"object"==typeof t},D=function(t){return"boolean"==typeof t},E=function(t){return t instanceof Array},P=function(t){try{return!!JSON.parse(t)}catch(t){return!1}};e.exports={padLeft:s,padRight:c,toHex:v,toDecimal:y,fromDecimal:g,toUtf8:u,toAscii:f,fromUtf8:l,fromAscii:p,transformToFullName:h,extractDisplayName:d,extractTypeName:m,toWei:w,fromWei:_,toBigNumber:x,toTwosComplement:k,toAddress:F,isBigNumber:I,isStrictAddress:B,isAddress:S,isChecksumAddress:C,toChecksumAddress:A,isFunction:N,isString:O,isObject:T,isBoolean:D,isArray:E,isJson:P}},{"./sha3.js":19,"bignumber.js":"bignumber.js",utf8:85}],21:[function(t,e,n){e.exports={version:"0.18.3"}},{}],22:[function(t,e,n){function r(t){this._requestManager=new o(t),this.currentProvider=t,this.eth=new a(this),this.db=new s(this),this.shh=new c(this),this.net=new u(this),this.personal=new f(this),this.bzz=new l(this),this.settings=new p,this.version={api:h.version},this.providers={HttpProvider:b,IpcProvider:_},this._extend=y(this),this._extend({properties:x()})}var o=t("./web3/requestmanager"),i=t("./web3/iban"),a=t("./web3/methods/eth"),s=t("./web3/methods/db"),c=t("./web3/methods/shh"),u=t("./web3/methods/net"),f=t("./web3/methods/personal"),l=t("./web3/methods/swarm"),p=t("./web3/settings"),h=t("./version.json"),d=t("./utils/utils"),m=t("./utils/sha3"),y=t("./web3/extend"),g=t("./web3/batch"),v=t("./web3/property"),b=t("./web3/httpprovider"),_=t("./web3/ipcprovider"),w=t("bignumber.js");r.providers={HttpProvider:b,IpcProvider:_},r.prototype.setProvider=function(t){this._requestManager.setProvider(t),this.currentProvider=t},r.prototype.reset=function(t){this._requestManager.reset(t),this.settings=new p},r.prototype.BigNumber=w,r.prototype.toHex=d.toHex,r.prototype.toAscii=d.toAscii,r.prototype.toUtf8=d.toUtf8,r.prototype.fromAscii=d.fromAscii,r.prototype.fromUtf8=d.fromUtf8,r.prototype.toDecimal=d.toDecimal,r.prototype.fromDecimal=d.fromDecimal,r.prototype.toBigNumber=d.toBigNumber,r.prototype.toWei=d.toWei,r.prototype.fromWei=d.fromWei,r.prototype.isAddress=d.isAddress,r.prototype.isChecksumAddress=d.isChecksumAddress,r.prototype.toChecksumAddress=d.toChecksumAddress,r.prototype.isIBAN=d.isIBAN,r.prototype.sha3=function(t,e){return"0x"+m(t,e)},r.prototype.fromICAP=function(t){var e=new i(t);return e.address()};var x=function(){return[new v({name:"version.node",getter:"web3_clientVersion"}),new v({name:"version.network",getter:"net_version",inputFormatter:d.toDecimal}),new v({name:"version.ethereum",getter:"eth_protocolVersion",inputFormatter:d.toDecimal}),new v({name:"version.whisper",getter:"shh_version",inputFormatter:d.toDecimal})]};r.prototype.isConnected=function(){return this.currentProvider&&this.currentProvider.isConnected()},r.prototype.createBatch=function(){return new g(this)},e.exports=r},{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/methods/swarm":42,"./web3/property":45,"./web3/requestmanager":46,"./web3/settings":47,"bignumber.js":"bignumber.js"}],23:[function(t,e,n){var r=t("../utils/sha3"),o=t("./event"),i=t("./formatters"),a=t("../utils/utils"),s=t("./filter"),c=t("./methods/watches"),u=function(t,e,n){this._requestManager=t,this._json=e,this._address=n};u.prototype.encode=function(t){t=t||{};var e={};return["fromBlock","toBlock"].filter(function(e){return void 0!==t[e]}).forEach(function(n){e[n]=i.inputBlockNumberFormatter(t[n])}),e.address=this._address,e},u.prototype.decode=function(t){t.data=t.data||"",t.topics=t.topics||[];var e=t.topics[0].slice(2),n=this._json.filter(function(t){return e===r(a.transformToFullName(t))})[0];if(!n)return console.warn("cannot find event for log"),t;var i=new o(this._requestManager,n,this._address);return i.decode(t)},u.prototype.execute=function(t,e){a.isFunction(arguments[arguments.length-1])&&(e=arguments[arguments.length-1],1===arguments.length&&(t=null));var n=this.encode(t),r=this.decode.bind(this);return new s(this._requestManager,n,c.eth(),r,e)},u.prototype.attachToContract=function(t){var e=this.execute.bind(this);t.allEvents=e},e.exports=u},{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":43}],24:[function(t,e,n){var r=t("./jsonrpc"),o=t("./errors"),i=function(t){this.requestManager=t._requestManager,this.requests=[]};i.prototype.add=function(t){this.requests.push(t)},i.prototype.execute=function(){var t=this.requests;this.requestManager.sendBatch(t,function(e,n){n=n||[],t.map(function(t,e){return n[e]||{}}).forEach(function(e,n){if(t[n].callback){if(!r.isValidResponse(e))return t[n].callback(o.InvalidResponse(e));t[n].callback(null,t[n].format?t[n].format(e.result):e.result)}})})},e.exports=i},{"./errors":26,"./jsonrpc":35}],25:[function(t,e,n){var r=t("../utils/utils"),o=t("../solidity/coder"),i=t("./event"),a=t("./function"),s=t("./allevents"),c=function(t,e){return t.filter(function(t){return"constructor"===t.type&&t.inputs.length===e.length}).map(function(t){return t.inputs.map(function(t){return t.type})}).map(function(t){return o.encodeParams(t,e)})[0]||""},u=function(t){t.abi.filter(function(t){return"function"===t.type}).map(function(e){return new a(t._eth,e,t.address)}).forEach(function(e){e.attachToContract(t)})},f=function(t){var e=t.abi.filter(function(t){return"event"===t.type}),n=new s(t._eth._requestManager,e,t.address);n.attachToContract(t),e.map(function(e){return new i(t._eth._requestManager,e,t.address)}).forEach(function(e){e.attachToContract(t)})},l=function(t,e){var n=0,r=!1,o=t._eth.filter("latest",function(i){if(!i&&!r)if(n++,n>50){if(o.stopWatching(function(){}),r=!0,!e)throw new Error("Contract transaction couldn't be found after 50 blocks");e(new Error("Contract transaction couldn't be found after 50 blocks"))}else t._eth.getTransactionReceipt(t.transactionHash,function(n,i){i&&!r&&t._eth.getCode(i.contractAddress,function(n,a){if(!r&&a)if(o.stopWatching(function(){}),r=!0,a.length>3)t.address=i.contractAddress,u(t),f(t),e&&e(null,t);else{if(!e)throw new Error("The contract code couldn't be stored, please check your gas amount.");e(new Error("The contract code couldn't be stored, please check your gas amount."))}})})})},p=function(t,e){this.eth=t,this.abi=e,this.new=function(){var t,n=new h(this.eth,this.abi),o={},i=Array.prototype.slice.call(arguments);r.isFunction(i[i.length-1])&&(t=i.pop());var a=i[i.length-1];if(r.isObject(a)&&!r.isArray(a)&&(o=i.pop()),o.value>0){var s=e.filter(function(t){return"constructor"===t.type&&t.inputs.length===i.length})[0]||{};if(!s.payable)throw new Error("Cannot send value to non-payable constructor")}var u=c(this.abi,i);if(o.data+=u,t)this.eth.sendTransaction(o,function(e,r){e?t(e):(n.transactionHash=r,t(null,n),l(n,t))});else{var f=this.eth.sendTransaction(o);n.transactionHash=f,l(n)}return n},this.new.getData=this.getData.bind(this)};p.prototype.at=function(t,e){var n=new h(this.eth,this.abi,t);return u(n),f(n),e&&e(null,n),n},p.prototype.getData=function(){var t={},e=Array.prototype.slice.call(arguments),n=e[e.length-1];r.isObject(n)&&!r.isArray(n)&&(t=e.pop());var o=c(this.abi,e);return t.data+=o,t.data};var h=function(t,e,n){this._eth=t,this.transactionHash=null,this.address=n,this.abi=e};e.exports=p},{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(t,e,n){e.exports={InvalidNumberOfParams:function(){return new Error("Invalid number of input parameters")},InvalidConnection:function(t){return new Error("CONNECTION ERROR: Couldn't connect to node "+t+".")},InvalidProvider:function(){return new Error("Provider not set or invalid")},InvalidResponse:function(t){var e=t&&t.error&&t.error.message?t.error.message:"Invalid JSON RPC response: "+JSON.stringify(t);return new Error(e)},ConnectionTimeout:function(t){return new Error("CONNECTION TIMEOUT: timeout of "+t+" ms achived")}}},{}],27:[function(t,e,n){var r=t("../utils/utils"),o=t("../solidity/coder"),i=t("./formatters"),a=t("../utils/sha3"),s=t("./filter"),c=t("./methods/watches"),u=function(t,e,n){this._requestManager=t,this._params=e.inputs,this._name=r.transformToFullName(e),this._address=n,this._anonymous=e.anonymous};u.prototype.types=function(t){return this._params.filter(function(e){return e.indexed===t}).map(function(t){return t.type})},u.prototype.displayName=function(){return r.extractDisplayName(this._name)},u.prototype.typeName=function(){return r.extractTypeName(this._name)},u.prototype.signature=function(){return a(this._name)},u.prototype.encode=function(t,e){t=t||{},e=e||{};var n={};["fromBlock","toBlock"].filter(function(t){return void 0!==e[t]}).forEach(function(t){n[t]=i.inputBlockNumberFormatter(e[t])}),n.topics=[],n.address=this._address,this._anonymous||n.topics.push("0x"+this.signature());var a=this._params.filter(function(t){return t.indexed===!0}).map(function(e){var n=t[e.name];return void 0===n||null===n?null:r.isArray(n)?n.map(function(t){return"0x"+o.encodeParam(e.type,t)}):"0x"+o.encodeParam(e.type,n)});return n.topics=n.topics.concat(a),n},u.prototype.decode=function(t){t.data=t.data||"",t.topics=t.topics||[];var e=this._anonymous?t.topics:t.topics.slice(1),n=e.map(function(t){return t.slice(2)}).join(""),r=o.decodeParams(this.types(!0),n),a=t.data.slice(2),s=o.decodeParams(this.types(!1),a),c=i.outputLogFormatter(t);return c.event=this.displayName(),c.address=t.address,c.args=this._params.reduce(function(t,e){return t[e.name]=e.indexed?r.shift():s.shift(),t},{}),delete c.data,delete c.topics,c},u.prototype.execute=function(t,e,n){r.isFunction(arguments[arguments.length-1])&&(n=arguments[arguments.length-1],2===arguments.length&&(e=null),1===arguments.length&&(e=null,t={}));var o=this.encode(t,e),i=this.decode.bind(this);return new s(this._requestManager,o,c.eth(),i,n)},u.prototype.attachToContract=function(t){var e=this.execute.bind(this),n=this.displayName();t[n]||(t[n]=e),t[n][this.typeName()]=this.execute.bind(this,t)},e.exports=u},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":43}],28:[function(t,e,n){var r=t("./formatters"),o=t("./../utils/utils"),i=t("./method"),a=t("./property"),s=function(t){var e=function(e){var n;e.property?(t[e.property]||(t[e.property]={}),n=t[e.property]):n=t,e.methods&&e.methods.forEach(function(e){e.attachToObject(n),e.setRequestManager(t._requestManager)}),e.properties&&e.properties.forEach(function(e){e.attachToObject(n),e.setRequestManager(t._requestManager)})};return e.formatters=r,e.utils=o,e.Method=i,e.Property=a,e};e.exports=s},{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":45}],29:[function(t,e,n){var r=t("./formatters"),o=t("../utils/utils"),i=function(t){return null===t||"undefined"==typeof t?null:(t=String(t),0===t.indexOf("0x")?t:o.fromUtf8(t))},a=function(t){return o.isString(t)?t:(t=t||{},t.topics=t.topics||[],t.topics=t.topics.map(function(t){return o.isArray(t)?t.map(i):i(t)}),{topics:t.topics,from:t.from,to:t.to,address:t.address,fromBlock:r.inputBlockNumberFormatter(t.fromBlock),toBlock:r.inputBlockNumberFormatter(t.toBlock)})},s=function(t,e){o.isString(t.options)||t.get(function(t,n){t&&e(t),o.isArray(n)&&n.forEach(function(t){e(null,t)})})},c=function(t){var e=function(e,n){return e?t.callbacks.forEach(function(t){t(e)}):void(o.isArray(n)&&n.forEach(function(e){e=t.formatter?t.formatter(e):e,t.callbacks.forEach(function(t){t(null,e)})}))};t.requestManager.startPolling({method:t.implementation.poll.call,params:[t.filterId]},t.filterId,e,t.stopWatching.bind(t))},u=function(t,e,n,r,o,i){var u=this,f={};return n.forEach(function(e){e.setRequestManager(t),e.attachToObject(f)}),this.requestManager=t,this.options=a(e),this.implementation=f,this.filterId=null,this.callbacks=[],this.getLogsCallbacks=[],this.pollFilters=[],this.formatter=r,this.implementation.newFilter(this.options,function(t,e){ +if(t)u.callbacks.forEach(function(e){e(t)}),i(t);else if(u.filterId=e,u.getLogsCallbacks.forEach(function(t){u.get(t)}),u.getLogsCallbacks=[],u.callbacks.forEach(function(t){s(u,t)}),u.callbacks.length>0&&c(u),"function"==typeof o)return u.watch(o)}),this};u.prototype.watch=function(t){return this.callbacks.push(t),this.filterId&&(s(this,t),c(this)),this},u.prototype.stopWatching=function(t){return this.requestManager.stopPolling(this.filterId),this.callbacks=[],t?void this.implementation.uninstallFilter(this.filterId,t):this.implementation.uninstallFilter(this.filterId)},u.prototype.get=function(t){var e=this;if(!o.isFunction(t)){if(null===this.filterId)throw new Error("Filter ID Error: filter().get() can't be chained synchronous, please provide a callback for the get() method.");var n=this.implementation.getLogs(this.filterId);return n.map(function(t){return e.formatter?e.formatter(t):t})}return null===this.filterId?this.getLogsCallbacks.push(t):this.implementation.getLogs(this.filterId,function(n,r){n?t(n):t(null,r.map(function(t){return e.formatter?e.formatter(t):t}))}),this},e.exports=u},{"../utils/utils":20,"./formatters":30}],30:[function(t,e,n){var r=t("../utils/utils"),o=t("../utils/config"),i=t("./iban"),a=function(t){return r.toBigNumber(t)},s=function(t){return"latest"===t||"pending"===t||"earliest"===t},c=function(t){return void 0===t?o.defaultBlock:u(t)},u=function(t){if(void 0!==t)return s(t)?t:r.toHex(t)},f=function(t){return t.from=t.from||o.defaultAccount,t.from&&(t.from=v(t.from)),t.to&&(t.to=v(t.to)),["gasPrice","gas","value","nonce"].filter(function(e){return void 0!==t[e]}).forEach(function(e){t[e]=r.fromDecimal(t[e])}),t},l=function(t){return t.from=t.from||o.defaultAccount,t.from=v(t.from),t.to&&(t.to=v(t.to)),["gasPrice","gas","value","nonce"].filter(function(e){return void 0!==t[e]}).forEach(function(e){t[e]=r.fromDecimal(t[e])}),t},p=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),t.nonce=r.toDecimal(t.nonce),t.gas=r.toDecimal(t.gas),t.gasPrice=r.toBigNumber(t.gasPrice),t.value=r.toBigNumber(t.value),t},h=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),t.cumulativeGasUsed=r.toDecimal(t.cumulativeGasUsed),t.gasUsed=r.toDecimal(t.gasUsed),r.isArray(t.logs)&&(t.logs=t.logs.map(function(t){return m(t)})),t},d=function(t){return t.gasLimit=r.toDecimal(t.gasLimit),t.gasUsed=r.toDecimal(t.gasUsed),t.size=r.toDecimal(t.size),t.timestamp=r.toDecimal(t.timestamp),null!==t.number&&(t.number=r.toDecimal(t.number)),t.difficulty=r.toBigNumber(t.difficulty),t.totalDifficulty=r.toBigNumber(t.totalDifficulty),r.isArray(t.transactions)&&t.transactions.forEach(function(t){if(!r.isString(t))return p(t)}),t},m=function(t){return null!==t.blockNumber&&(t.blockNumber=r.toDecimal(t.blockNumber)),null!==t.transactionIndex&&(t.transactionIndex=r.toDecimal(t.transactionIndex)),null!==t.logIndex&&(t.logIndex=r.toDecimal(t.logIndex)),t},y=function(t){return t.ttl=r.fromDecimal(t.ttl),t.workToProve=r.fromDecimal(t.workToProve),t.priority=r.fromDecimal(t.priority),r.isArray(t.topics)||(t.topics=t.topics?[t.topics]:[]),t.topics=t.topics.map(function(t){return 0===t.indexOf("0x")?t:r.fromUtf8(t)}),t},g=function(t){return t.expiry=r.toDecimal(t.expiry),t.sent=r.toDecimal(t.sent),t.ttl=r.toDecimal(t.ttl),t.workProved=r.toDecimal(t.workProved),t.topics||(t.topics=[]),t.topics=t.topics.map(function(t){return r.toAscii(t)}),t},v=function(t){var e=new i(t);if(e.isValid()&&e.isDirect())return"0x"+e.address();if(r.isStrictAddress(t))return t;if(r.isAddress(t))return"0x"+t;throw new Error("invalid address")},b=function(t){return t.startingBlock=r.toDecimal(t.startingBlock),t.currentBlock=r.toDecimal(t.currentBlock),t.highestBlock=r.toDecimal(t.highestBlock),t.knownStates&&(t.knownStates=r.toDecimal(t.knownStates),t.pulledStates=r.toDecimal(t.pulledStates)),t};e.exports={inputDefaultBlockNumberFormatter:c,inputBlockNumberFormatter:u,inputCallFormatter:f,inputTransactionFormatter:l,inputAddressFormatter:v,inputPostFormatter:y,outputBigNumberFormatter:a,outputTransactionFormatter:p,outputTransactionReceiptFormatter:h,outputBlockFormatter:d,outputLogFormatter:m,outputPostFormatter:g,outputSyncingFormatter:b}},{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(t,e,n){var r=t("../solidity/coder"),o=t("../utils/utils"),i=t("./formatters"),a=t("../utils/sha3"),s=function(t,e,n){this._eth=t,this._inputTypes=e.inputs.map(function(t){return t.type}),this._outputTypes=e.outputs.map(function(t){return t.type}),this._constant=e.constant,this._payable=e.payable,this._name=o.transformToFullName(e),this._address=n};s.prototype.extractCallback=function(t){if(o.isFunction(t[t.length-1]))return t.pop()},s.prototype.extractDefaultBlock=function(t){if(t.length>this._inputTypes.length&&!o.isObject(t[t.length-1]))return i.inputDefaultBlockNumberFormatter(t.pop())},s.prototype.toPayload=function(t){var e={};return t.length>this._inputTypes.length&&o.isObject(t[t.length-1])&&(e=t[t.length-1]),e.to=this._address,e.data="0x"+this.signature()+r.encodeParams(this._inputTypes,t),e},s.prototype.signature=function(){return a(this._name).slice(0,8)},s.prototype.unpackOutput=function(t){if(t){t=t.length>=2?t.slice(2):t;var e=r.decodeParams(this._outputTypes,t);return 1===e.length?e[0]:e}},s.prototype.call=function(){var t=Array.prototype.slice.call(arguments).filter(function(t){return void 0!==t}),e=this.extractCallback(t),n=this.extractDefaultBlock(t),r=this.toPayload(t);if(!e){var o=this._eth.call(r,n);return this.unpackOutput(o)}var i=this;this._eth.call(r,n,function(t,n){if(t)return e(t,null);var r=null;try{r=i.unpackOutput(n)}catch(e){t=e}e(t,r)})},s.prototype.sendTransaction=function(){var t=Array.prototype.slice.call(arguments).filter(function(t){return void 0!==t}),e=this.extractCallback(t),n=this.toPayload(t);if(n.value>0&&!this._payable)throw new Error("Cannot send value to non-payable function");return e?void this._eth.sendTransaction(n,e):this._eth.sendTransaction(n)},s.prototype.estimateGas=function(){var t=Array.prototype.slice.call(arguments),e=this.extractCallback(t),n=this.toPayload(t);return e?void this._eth.estimateGas(n,e):this._eth.estimateGas(n)},s.prototype.getData=function(){var t=Array.prototype.slice.call(arguments),e=this.toPayload(t);return e.data},s.prototype.displayName=function(){return o.extractDisplayName(this._name)},s.prototype.typeName=function(){return o.extractTypeName(this._name)},s.prototype.request=function(){var t=Array.prototype.slice.call(arguments),e=this.extractCallback(t),n=this.toPayload(t),r=this.unpackOutput.bind(this);return{method:this._constant?"eth_call":"eth_sendTransaction",callback:e,params:[n],format:r}},s.prototype.execute=function(){var t=!this._constant;return t?this.sendTransaction.apply(this,Array.prototype.slice.call(arguments)):this.call.apply(this,Array.prototype.slice.call(arguments))},s.prototype.attachToContract=function(t){var e=this.execute.bind(this);e.request=this.request.bind(this),e.call=this.call.bind(this),e.sendTransaction=this.sendTransaction.bind(this),e.estimateGas=this.estimateGas.bind(this),e.getData=this.getData.bind(this);var n=this.displayName();t[n]||(t[n]=e),t[n][this.typeName()]=e},e.exports=s},{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./formatters":30}],32:[function(t,e,n){var r=t("./errors");"undefined"!=typeof window&&window.XMLHttpRequest?XMLHttpRequest=window.XMLHttpRequest:XMLHttpRequest=t("xmlhttprequest").XMLHttpRequest;var o=t("xhr2"),i=function(t,e){this.host=t||"http://localhost:8545",this.timeout=e||0};i.prototype.prepareRequest=function(t){var e;return t?(e=new o,e.timeout=this.timeout):e=new XMLHttpRequest,e.open("POST",this.host,t),e.setRequestHeader("Content-Type","application/json"),e},i.prototype.send=function(t){var e=this.prepareRequest(!1);try{e.send(JSON.stringify(t))}catch(t){throw r.InvalidConnection(this.host)}var n=e.responseText;try{n=JSON.parse(n)}catch(t){throw r.InvalidResponse(e.responseText)}return n},i.prototype.sendAsync=function(t,e){var n=this.prepareRequest(!0);n.onreadystatechange=function(){if(4===n.readyState&&1!==n.timeout){var t=n.responseText,o=null;try{t=JSON.parse(t)}catch(t){o=r.InvalidResponse(n.responseText)}e(o,t)}},n.ontimeout=function(){e(r.ConnectionTimeout(this.timeout))};try{n.send(JSON.stringify(t))}catch(t){e(r.InvalidConnection(this.host))}},i.prototype.isConnected=function(){try{return this.send({id:9999999999,jsonrpc:"2.0",method:"net_listening",params:[]}),!0}catch(t){return!1}},e.exports=i},{"./errors":26,xhr2:86,xmlhttprequest:17}],33:[function(t,e,n){var r=t("bignumber.js"),o=function(t,e){for(var n=t;n.length<2*e;)n="0"+n;return n},i=function(t){var e="A".charCodeAt(0),n="Z".charCodeAt(0);return t=t.toUpperCase(),t=t.substr(4)+t.substr(0,4),t.split("").map(function(t){var r=t.charCodeAt(0);return r>=e&&r<=n?r-e+10:t}).join("")},a=function(t){for(var e,n=t;n.length>2;)e=n.slice(0,9),n=parseInt(e,10)%97+n.slice(e.length);return parseInt(n,10)%97},s=function(t){this._iban=t};s.fromAddress=function(t){var e=new r(t,16),n=e.toString(36),i=o(n,15);return s.fromBban(i.toUpperCase())},s.fromBban=function(t){var e="XE",n=a(i(e+"00"+t)),r=("0"+(98-n)).slice(-2);return new s(e+r+t)},s.createIndirect=function(t){return s.fromBban("ETH"+t.institution+t.identifier)},s.isValid=function(t){var e=new s(t);return e.isValid()},s.prototype.isValid=function(){return/^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban)&&1===a(i(this._iban))},s.prototype.isDirect=function(){return 34===this._iban.length||35===this._iban.length},s.prototype.isIndirect=function(){return 20===this._iban.length},s.prototype.checksum=function(){return this._iban.substr(2,2)},s.prototype.institution=function(){return this.isIndirect()?this._iban.substr(7,4):""},s.prototype.client=function(){return this.isIndirect()?this._iban.substr(11):""},s.prototype.address=function(){if(this.isDirect()){var t=this._iban.substr(4),e=new r(t,36);return o(e.toString(16),20)}return""},s.prototype.toString=function(){return this._iban},e.exports=s},{"bignumber.js":"bignumber.js"}],34:[function(t,e,n){"use strict";var r=t("../utils/utils"),o=t("./errors"),i=function(t,e){var n=this;this.responseCallbacks={},this.path=t,this.connection=e.connect({path:this.path}),this.connection.on("error",function(t){console.error("IPC Connection Error",t),n._timeout()}),this.connection.on("end",function(){n._timeout()}),this.connection.on("data",function(t){n._parseResponse(t.toString()).forEach(function(t){var e=null;r.isArray(t)?t.forEach(function(t){n.responseCallbacks[t.id]&&(e=t.id)}):e=t.id,n.responseCallbacks[e]&&(n.responseCallbacks[e](null,t),delete n.responseCallbacks[e])})})};i.prototype._parseResponse=function(t){var e=this,n=[],r=t.replace(/\}[\n\r]?\{/g,"}|--|{").replace(/\}\][\n\r]?\[\{/g,"}]|--|[{").replace(/\}[\n\r]?\[\{/g,"}|--|[{").replace(/\}\][\n\r]?\{/g,"}]|--|{").split("|--|");return r.forEach(function(t){e.lastChunk&&(t=e.lastChunk+t);var r=null;try{r=JSON.parse(t)}catch(n){return e.lastChunk=t,clearTimeout(e.lastChunkTimeout),void(e.lastChunkTimeout=setTimeout(function(){throw e._timeout(),o.InvalidResponse(t)},15e3))}clearTimeout(e.lastChunkTimeout),e.lastChunk=null,r&&n.push(r)}),n},i.prototype._addResponseCallback=function(t,e){var n=t.id||t[0].id,r=t.method||t[0].method;this.responseCallbacks[n]=e,this.responseCallbacks[n].method=r},i.prototype._timeout=function(){for(var t in this.responseCallbacks)this.responseCallbacks.hasOwnProperty(t)&&(this.responseCallbacks[t](o.InvalidConnection("on IPC")),delete this.responseCallbacks[t])},i.prototype.isConnected=function(){var t=this;return t.connection.writable||t.connection.connect({path:t.path}),!!this.connection.writable},i.prototype.send=function(t){if(this.connection.writeSync){var e;this.connection.writable||this.connection.connect({path:this.path});var n=this.connection.writeSync(JSON.stringify(t));try{e=JSON.parse(n)}catch(t){throw o.InvalidResponse(n)}return e}throw new Error('You tried to send "'+t.method+'" synchronously. Synchronous requests are not supported by the IPC provider.')},i.prototype.sendAsync=function(t,e){this.connection.writable||this.connection.connect({path:this.path}),this.connection.write(JSON.stringify(t)),this._addResponseCallback(t,e)},e.exports=i},{"../utils/utils":20,"./errors":26}],35:[function(t,e,n){var r={messageId:0};r.toPayload=function(t,e){return t||console.error("jsonrpc method should be specified!"),r.messageId++,{jsonrpc:"2.0",id:r.messageId,method:t,params:e||[]}},r.isValidResponse=function(t){function e(t){return!!t&&!t.error&&"2.0"===t.jsonrpc&&"number"==typeof t.id&&void 0!==t.result}return Array.isArray(t)?t.every(e):e(t)},r.toBatchPayload=function(t){return t.map(function(t){return r.toPayload(t.method,t.params)})},e.exports=r},{}],36:[function(t,e,n){var r=t("../utils/utils"),o=t("./errors"),i=function(t){this.name=t.name,this.call=t.call,this.params=t.params||0,this.inputFormatter=t.inputFormatter,this.outputFormatter=t.outputFormatter,this.requestManager=null};i.prototype.setRequestManager=function(t){this.requestManager=t},i.prototype.getCall=function(t){return r.isFunction(this.call)?this.call(t):this.call},i.prototype.extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},i.prototype.validateArgs=function(t){if(t.length!==this.params)throw o.InvalidNumberOfParams()},i.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter.map(function(e,n){return e?e(t[n]):t[n]}):t},i.prototype.formatOutput=function(t){return this.outputFormatter&&t?this.outputFormatter(t):t},i.prototype.toPayload=function(t){var e=this.getCall(t),n=this.extractCallback(t),r=this.formatInput(t);return this.validateArgs(r),{method:e,params:r,callback:n}},i.prototype.attachToObject=function(t){var e=this.buildCall();e.call=this.call;var n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},t[n[0]][n[1]]=e):t[n[0]]=e},i.prototype.buildCall=function(){var t=this,e=function(){var e=t.toPayload(Array.prototype.slice.call(arguments));return e.callback?t.requestManager.sendAsync(e,function(n,r){e.callback(n,t.formatOutput(r))}):t.formatOutput(t.requestManager.send(e))};return e.request=this.request.bind(this),e},i.prototype.request=function(){var t=this.toPayload(Array.prototype.slice.call(arguments));return t.format=this.formatOutput.bind(this),t},e.exports=i},{"../utils/utils":20,"./errors":26}],37:[function(t,e,n){var r=t("../method"),o=function(t){this._requestManager=t._requestManager;var e=this;i().forEach(function(n){n.attachToObject(e),n.setRequestManager(t._requestManager)})},i=function(){var t=new r({name:"putString",call:"db_putString",params:3}),e=new r({name:"getString",call:"db_getString",params:2}),n=new r({name:"putHex",call:"db_putHex",params:3}),o=new r({name:"getHex",call:"db_getHex",params:2});return[t,e,n,o]};e.exports=o},{"../method":36}],38:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;w().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),x().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),this.iban=d,this.sendIBANTransaction=m.bind(null,this)}var o=t("../formatters"),i=t("../../utils/utils"),a=t("../method"),s=t("../property"),c=t("../../utils/config"),u=t("../contract"),f=t("./watches"),l=t("../filter"),p=t("../syncing"),h=t("../namereg"),d=t("../iban"),m=t("../transfer"),y=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},g=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},v=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},b=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},_=function(t){return i.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"};Object.defineProperty(r.prototype,"defaultBlock",{get:function(){return c.defaultBlock},set:function(t){return c.defaultBlock=t,t}}),Object.defineProperty(r.prototype,"defaultAccount",{get:function(){return c.defaultAccount},set:function(t){return c.defaultAccount=t,t}});var w=function(){var t=new a({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter],outputFormatter:o.outputBigNumberFormatter}),e=new a({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[null,i.toHex,o.inputDefaultBlockNumberFormatter]}),n=new a({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.inputAddressFormatter,o.inputDefaultBlockNumberFormatter]}),r=new a({name:"getBlock",call:y,params:2,inputFormatter:[o.inputBlockNumberFormatter,function(t){return!!t}],outputFormatter:o.outputBlockFormatter}),s=new a({name:"getUncle",call:v,params:2,inputFormatter:[o.inputBlockNumberFormatter,i.toHex],outputFormatter:o.outputBlockFormatter}),c=new a({name:"getCompilers",call:"eth_getCompilers",params:0}),u=new a({name:"getBlockTransactionCount",call:b,params:1,inputFormatter:[o.inputBlockNumberFormatter],outputFormatter:i.toDecimal}),f=new a({name:"getBlockUncleCount",call:_,params:1,inputFormatter:[o.inputBlockNumberFormatter],outputFormatter:i.toDecimal}),l=new a({name:"getTransaction",call:"eth_getTransactionByHash",params:1,outputFormatter:o.outputTransactionFormatter}),p=new a({name:"getTransactionFromBlock",call:g,params:2,inputFormatter:[o.inputBlockNumberFormatter,i.toHex],outputFormatter:o.outputTransactionFormatter}),h=new a({name:"getTransactionReceipt",call:"eth_getTransactionReceipt",params:1,outputFormatter:o.outputTransactionReceiptFormatter}),d=new a({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[null,o.inputDefaultBlockNumberFormatter],outputFormatter:i.toDecimal}),m=new a({name:"sendRawTransaction",call:"eth_sendRawTransaction",params:1,inputFormatter:[null]}),w=new a({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[o.inputTransactionFormatter]}),x=new a({name:"sign",call:"eth_sign",params:2,inputFormatter:[o.inputAddressFormatter,null]}),k=new a({name:"call",call:"eth_call",params:2,inputFormatter:[o.inputCallFormatter,o.inputDefaultBlockNumberFormatter]}),B=new a({name:"estimateGas",call:"eth_estimateGas",params:1,inputFormatter:[o.inputCallFormatter],outputFormatter:i.toDecimal}),S=new a({name:"compile.solidity",call:"eth_compileSolidity",params:1}),C=new a({name:"compile.lll",call:"eth_compileLLL",params:1}),A=new a({name:"compile.serpent",call:"eth_compileSerpent",params:1}),F=new a({name:"submitWork",call:"eth_submitWork",params:3}),I=new a({name:"getWork",call:"eth_getWork",params:0});return[t,e,n,r,s,c,u,f,l,p,h,d,k,B,m,w,x,S,C,A,F,I]},x=function(){return[new s({name:"coinbase",getter:"eth_coinbase"}),new s({name:"mining",getter:"eth_mining"}),new s({name:"hashrate",getter:"eth_hashrate",outputFormatter:i.toDecimal}),new s({name:"syncing",getter:"eth_syncing",outputFormatter:o.outputSyncingFormatter}),new s({name:"gasPrice",getter:"eth_gasPrice",outputFormatter:o.outputBigNumberFormatter}),new s({name:"accounts",getter:"eth_accounts"}),new s({name:"blockNumber",getter:"eth_blockNumber",outputFormatter:i.toDecimal}),new s({name:"protocolVersion",getter:"eth_protocolVersion"})]};r.prototype.contract=function(t){var e=new u(this,t);return e},r.prototype.filter=function(t,e){return new l(this._requestManager,t,f.eth(),o.outputLogFormatter,e)},r.prototype.namereg=function(){return this.contract(h.global.abi).at(h.global.address)},r.prototype.icapNamereg=function(){return this.contract(h.icap.abi).at(h.icap.address)},r.prototype.isSyncing=function(t){return new p(this._requestManager,t)},e.exports=r},{"../../utils/config":18,"../../utils/utils":20,"../contract":25,"../filter":29,"../formatters":30,"../iban":33,"../method":36,"../namereg":44,"../property":45,"../syncing":48,"../transfer":49,"./watches":43}],39:[function(t,e,n){var r=t("../../utils/utils"),o=t("../property"),i=function(t){this._requestManager=t._requestManager;var e=this;a().forEach(function(n){n.attachToObject(e),n.setRequestManager(t._requestManager)})},a=function(){return[new o({name:"listening",getter:"net_listening"}),new o({name:"peerCount",getter:"net_peerCount",outputFormatter:r.toDecimal})]};e.exports=i},{"../../utils/utils":20,"../property":45}],40:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),c().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})}var o=t("../method"),i=t("../property"),a=t("../formatters"),s=function(){var t=new o({name:"newAccount",call:"personal_newAccount",params:1,inputFormatter:[null]}),e=new o({name:"unlockAccount",call:"personal_unlockAccount",params:3,inputFormatter:[a.inputAddressFormatter,null,null]}),n=new o({name:"sendTransaction",call:"personal_sendTransaction",params:2,inputFormatter:[a.inputTransactionFormatter,null]}),r=new o({name:"lockAccount",call:"personal_lockAccount",params:1,inputFormatter:[a.inputAddressFormatter]});return[t,e,n,r]},c=function(){return[new i({name:"listAccounts",getter:"personal_listAccounts"})]};e.exports=r},{"../formatters":30,"../method":36,"../property":45}],41:[function(t,e,n){var r=t("../method"),o=t("../formatters"),i=t("../filter"),a=t("./watches"),s=function(t){this._requestManager=t._requestManager;var e=this;c().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})};s.prototype.filter=function(t,e){return new i(this._requestManager,t,a.shh(),o.outputPostFormatter,e)};var c=function(){var t=new r({name:"post",call:"shh_post",params:1,inputFormatter:[o.inputPostFormatter]}),e=new r({name:"newIdentity",call:"shh_newIdentity",params:0}),n=new r({name:"hasIdentity",call:"shh_hasIdentity",params:1}),i=new r({name:"newGroup",call:"shh_newGroup",params:0}),a=new r({name:"addToGroup",call:"shh_addToGroup",params:0});return[t,e,n,i,a]};e.exports=s},{"../filter":29,"../formatters":30,"../method":36,"./watches":43}],42:[function(t,e,n){"use strict";function r(t){this._requestManager=t._requestManager;var e=this;a().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)}),s().forEach(function(t){t.attachToObject(e),t.setRequestManager(e._requestManager)})}var o=t("../method"),i=t("../property"),a=function(){var t=new o({name:"blockNetworkRead",call:"bzz_blockNetworkRead",params:1,inputFormatter:[null]}),e=new o({name:"syncEnabled",call:"bzz_syncEnabled",params:1,inputFormatter:[null]}),n=new o({name:"swapEnabled",call:"bzz_swapEnabled",params:1,inputFormatter:[null]}),r=new o({name:"download",call:"bzz_download",params:2,inputFormatter:[null,null]}),i=new o({name:"upload",call:"bzz_upload",params:2,inputFormatter:[null,null]}),a=new o({name:"retrieve",call:"bzz_retrieve",params:1,inputFormatter:[null]}),s=new o({name:"store",call:"bzz_store",params:2,inputFormatter:[null,null]}),c=new o({name:"get",call:"bzz_get",params:1,inputFormatter:[null]}),u=new o({name:"put",call:"bzz_put",params:2,inputFormatter:[null,null]}),f=new o({name:"modify",call:"bzz_modify",params:4,inputFormatter:[null,null,null,null]});return[t,e,n,r,i,a,s,c,u,f]},s=function(){return[new i({name:"hive",getter:"bzz_hive"}),new i({name:"info",getter:"bzz_info"})]};e.exports=r},{"../method":36,"../property":45}],43:[function(t,e,n){var r=t("../method"),o=function(){var t=function(t){var e=t[0];switch(e){case"latest":return t.shift(),this.params=0,"eth_newBlockFilter";case"pending":return t.shift(),this.params=0,"eth_newPendingTransactionFilter";default:return"eth_newFilter"}},e=new r({name:"newFilter",call:t,params:1}),n=new r({name:"uninstallFilter",call:"eth_uninstallFilter",params:1}),o=new r({name:"getLogs",call:"eth_getFilterLogs",params:1}),i=new r({name:"poll",call:"eth_getFilterChanges",params:1});return[e,n,o,i]},i=function(){var t=new r({name:"newFilter",call:"shh_newFilter",params:1}),e=new r({name:"uninstallFilter",call:"shh_uninstallFilter",params:1}),n=new r({name:"getLogs",call:"shh_getMessages",params:1}),o=new r({name:"poll",call:"shh_getFilterChanges",params:1});return[t,e,n,o]};e.exports={eth:o,shh:i}},{"../method":36}],44:[function(t,e,n){var r=t("../contracts/GlobalRegistrar.json"),o=t("../contracts/ICAPRegistrar.json"),i="0xc6d9d2cd449a754c494264e1809c50e34d64562b",a="0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00";e.exports={global:{abi:r,address:i},icap:{abi:o,address:a}}},{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],45:[function(t,e,n){var r=t("../utils/utils"),o=function(t){this.name=t.name,this.getter=t.getter,this.setter=t.setter,this.outputFormatter=t.outputFormatter,this.inputFormatter=t.inputFormatter,this.requestManager=null};o.prototype.setRequestManager=function(t){this.requestManager=t},o.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter(t):t},o.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t&&void 0!==t?this.outputFormatter(t):t},o.prototype.extractCallback=function(t){if(r.isFunction(t[t.length-1]))return t.pop()},o.prototype.attachToObject=function(t){var e={get:this.buildGet(),enumerable:!0},n=this.name.split("."),r=n[0];n.length>1&&(t[n[0]]=t[n[0]]||{},t=t[n[0]],r=n[1]),Object.defineProperty(t,r,e),t[i(r)]=this.buildAsyncGet()};var i=function(t){return"get"+t.charAt(0).toUpperCase()+t.slice(1)};o.prototype.buildGet=function(){var t=this;return function(){return t.formatOutput(t.requestManager.send({method:t.getter}))}},o.prototype.buildAsyncGet=function(){var t=this,e=function(e){t.requestManager.sendAsync({method:t.getter},function(n,r){e(n,t.formatOutput(r))})};return e.request=this.request.bind(this),e},o.prototype.request=function(){var t={method:this.getter,params:[],callback:this.extractCallback(Array.prototype.slice.call(arguments))};return t.format=this.formatOutput.bind(this),t},e.exports=o},{"../utils/utils":20}],46:[function(t,e,n){var r=t("./jsonrpc"),o=t("../utils/utils"),i=t("../utils/config"),a=t("./errors"),s=function(t){this.provider=t,this.polls={},this.timeout=null};s.prototype.send=function(t){if(!this.provider)return console.error(a.InvalidProvider()),null;var e=r.toPayload(t.method,t.params),n=this.provider.send(e);if(!r.isValidResponse(n))throw a.InvalidResponse(n);return n.result},s.prototype.sendAsync=function(t,e){if(!this.provider)return e(a.InvalidProvider());var n=r.toPayload(t.method,t.params);this.provider.sendAsync(n,function(t,n){return t?e(t):r.isValidResponse(n)?void e(null,n.result):e(a.InvalidResponse(n))})},s.prototype.sendBatch=function(t,e){if(!this.provider)return e(a.InvalidProvider());var n=r.toBatchPayload(t);this.provider.sendAsync(n,function(t,n){return t?e(t):o.isArray(n)?void e(t,n):e(a.InvalidResponse(n))})},s.prototype.setProvider=function(t){this.provider=t},s.prototype.startPolling=function(t,e,n,r){this.polls[e]={data:t,id:e,callback:n,uninstall:r},this.timeout||this.poll()},s.prototype.stopPolling=function(t){delete this.polls[t],0===Object.keys(this.polls).length&&this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},s.prototype.reset=function(t){for(var e in this.polls)t&&e.indexOf("syncPoll_")!==-1||(this.polls[e].uninstall(),delete this.polls[e]);0===Object.keys(this.polls).length&&this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},s.prototype.poll=function(){if(this.timeout=setTimeout(this.poll.bind(this),i.ETH_POLLING_TIMEOUT),0!==Object.keys(this.polls).length){if(!this.provider)return void console.error(a.InvalidProvider());var t=[],e=[];for(var n in this.polls)t.push(this.polls[n].data),e.push(n);if(0!==t.length){var s=r.toBatchPayload(t),c={};s.forEach(function(t,n){c[t.id]=e[n]});var u=this;this.provider.sendAsync(s,function(t,e){if(!t){if(!o.isArray(e))throw a.InvalidResponse(e);e.map(function(t){var e=c[t.id];return!!u.polls[e]&&(t.callback=u.polls[e].callback,t)}).filter(function(t){return!!t}).filter(function(t){var e=r.isValidResponse(t);return e||t.callback(a.InvalidResponse(t)),e}).forEach(function(t){t.callback(null,t.result)})}})}}},e.exports=s},{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],47:[function(t,e,n){var r=function(){this.defaultBlock="latest",this.defaultAccount=void 0};e.exports=r},{}],48:[function(t,e,n){var r=t("./formatters"),o=t("../utils/utils"),i=1,a=function(t){var e=function(e,n){return e?t.callbacks.forEach(function(t){t(e)}):(o.isObject(n)&&n.startingBlock&&(n=r.outputSyncingFormatter(n)),void t.callbacks.forEach(function(e){t.lastSyncState!==n&&(!t.lastSyncState&&o.isObject(n)&&e(null,!0),setTimeout(function(){e(null,n)},0),t.lastSyncState=n)}))};t.requestManager.startPolling({method:"eth_syncing",params:[]},t.pollId,e,t.stopWatching.bind(t))},s=function(t,e){return this.requestManager=t,this.pollId="syncPoll_"+i++,this.callbacks=[],this.addCallback(e),this.lastSyncState=!1,a(this),this};s.prototype.addCallback=function(t){return t&&this.callbacks.push(t),this},s.prototype.stopWatching=function(){this.requestManager.stopPolling(this.pollId),this.callbacks=[]},e.exports=s},{"../utils/utils":20,"./formatters":30}],49:[function(t,e,n){var r=t("./iban"),o=t("../contracts/SmartExchange.json"),i=function(t,e,n,o,i){var c=new r(n);if(!c.isValid())throw new Error("invalid iban address");if(c.isDirect())return a(t,e,c.address(),o,i);if(!i){var u=t.icapNamereg().addr(c.institution());return s(t,e,u,o,c.client())}t.icapNamereg().addr(c.institution(),function(n,r){return s(t,e,r,o,c.client(),i)})},a=function(t,e,n,r,o){return t.sendTransaction({address:n,from:e,value:r},o)},s=function(t,e,n,r,i,a){var s=o;return t.contract(s).at(n).deposit(i,{from:e,value:r},a)};e.exports=i},{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(t,e,n){},{}],51:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.BlockCipher,o=e.algo,i=[],a=[],s=[],c=[],u=[],f=[],l=[],p=[],h=[],d=[];!function(){for(var t=[],e=0;e<256;e++)e<128?t[e]=e<<1:t[e]=e<<1^283;for(var n=0,r=0,e=0;e<256;e++){var o=r^r<<1^r<<2^r<<3^r<<4;o=o>>>8^255&o^99,i[n]=o,a[o]=n;var m=t[n],y=t[m],g=t[y],v=257*t[o]^16843008*o;s[n]=v<<24|v>>>8,c[n]=v<<16|v>>>16,u[n]=v<<8|v>>>24,f[n]=v;var v=16843009*g^65537*y^257*m^16843008*n;l[o]=v<<24|v>>>8,p[o]=v<<16|v>>>16,h[o]=v<<8|v>>>24,d[o]=v,n?(n=m^t[t[t[g^m]]],r^=t[t[r]]):n=r=1}}();var m=[0,1,2,4,8,16,32,64,128,27,54],y=o.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,n=t.sigBytes/4,r=this._nRounds=n+6,o=4*(r+1),a=this._keySchedule=[],s=0;s6&&s%n==4&&(c=i[c>>>24]<<24|i[c>>>16&255]<<16|i[c>>>8&255]<<8|i[255&c]):(c=c<<8|c>>>24,c=i[c>>>24]<<24|i[c>>>16&255]<<16|i[c>>>8&255]<<8|i[255&c],c^=m[s/n|0]<<24),a[s]=a[s-n]^c}for(var u=this._invKeySchedule=[],f=0;f>>24]]^p[i[c>>>16&255]]^h[i[c>>>8&255]]^d[i[255&c]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,c,u,f,i)},decryptBlock:function(t,e){var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n,this._doCryptBlock(t,e,this._invKeySchedule,l,p,h,d,a);var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n},_doCryptBlock:function(t,e,n,r,o,i,a,s){for(var c=this._nRounds,u=t[e]^n[0],f=t[e+1]^n[1],l=t[e+2]^n[2],p=t[e+3]^n[3],h=4,d=1;d>>24]^o[f>>>16&255]^i[l>>>8&255]^a[255&p]^n[h++],y=r[f>>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&u]^n[h++],g=r[l>>>24]^o[p>>>16&255]^i[u>>>8&255]^a[255&f]^n[h++],v=r[p>>>24]^o[u>>>16&255]^i[f>>>8&255]^a[255&l]^n[h++];u=m,f=y,l=g,p=v}var m=(s[u>>>24]<<24|s[f>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[h++],y=(s[f>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&u])^n[h++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[u>>>8&255]<<8|s[255&f])^n[h++],v=(s[p>>>24]<<24|s[u>>>16&255]<<16|s[f>>>8&255]<<8|s[255&l])^n[h++];t[e]=m,t[e+1]=y,t[e+2]=g,t[e+3]=v},keySize:8});e.AES=r._createHelper(y)}(),t.AES})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){t.lib.Cipher||function(e){var n=t,r=n.lib,o=r.Base,i=r.WordArray,a=r.BufferedBlockAlgorithm,s=n.enc,c=(s.Utf8,s.Base64),u=n.algo,f=u.EvpKDF,l=r.Cipher=a.extend({cfg:o.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,n){this.cfg=this.cfg.extend(n),this._xformMode=t,this._key=e,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){t&&this._append(t);var e=this._doFinalize();return e},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?k:_}return function(e){return{encrypt:function(n,r,o){return t(r).encrypt(e,n,r,o)},decrypt:function(n,r,o){return t(r).decrypt(e,n,r,o)}}}}()}),p=(r.StreamCipher=l.extend({_doFinalize:function(){var t=this._process(!0);return t},blockSize:1}),n.mode={}),h=r.BlockCipherMode=o.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=p.CBC=function(){function t(t,n,r){var o=this._iv;if(o){var i=o;this._iv=e}else var i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},g=(r.BlockCipher=l.extend({cfg:l.cfg.extend({mode:d,padding:y}),reset:function(){l.reset.call(this);var t=this.cfg,e=t.iv,n=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=n.createEncryptor;else{var r=n.createDecryptor;this._minBufferSize=1}this._mode=r.call(n,this,e&&e.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{var e=this._process(!0);t.unpad(e)}return e},blockSize:4}),r.CipherParams=o.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),v=n.format={},b=v.OpenSSL={stringify:function(t){var e=t.ciphertext,n=t.salt;if(n)var r=i.create([1398893684,1701076831]).concat(n).concat(e);else var r=e;return r.toString(c)},parse:function(t){var e=c.parse(t),n=e.words;if(1398893684==n[0]&&1701076831==n[1]){var r=i.create(n.slice(2,4));n.splice(0,4),e.sigBytes-=16}return g.create({ciphertext:e,salt:r})}},_=r.SerializableCipher=o.extend({cfg:o.extend({format:b}),encrypt:function(t,e,n,r){r=this.cfg.extend(r);var o=t.createEncryptor(n,r),i=o.finalize(e),a=o.cfg;return g.create({ciphertext:i,key:n,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:r.format})},decrypt:function(t,e,n,r){r=this.cfg.extend(r),e=this._parse(e,r.format);var o=t.createDecryptor(n,r).finalize(e.ciphertext);return o},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),w=n.kdf={},x=w.OpenSSL={execute:function(t,e,n,r){r||(r=i.random(8));var o=f.create({keySize:e+n}).compute(t,r),a=i.create(o.words.slice(e),4*n);return o.sigBytes=4*e,g.create({key:o,iv:a,salt:r})}},k=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:x}),encrypt:function(t,e,n,r){r=this.cfg.extend(r);var o=r.kdf.execute(n,t.keySize,t.ivSize);r.iv=o.iv;var i=_.encrypt.call(this,t,e,o.key,r);return i.mixIn(o),i},decrypt:function(t,e,n,r){r=this.cfg.extend(r),e=this._parse(e,r.format);var o=r.kdf.execute(n,t.keySize,t.ivSize,e.salt);r.iv=o.iv;var i=_.decrypt.call(this,t,e,o.key,r);return i}})}()})},{"./core":53}],53:[function(t,e,n){!function(t,r){"object"==typeof n?e.exports=n=r():"function"==typeof define&&define.amd?define([],r):t.CryptoJS=r()}(this,function(){var t=t||function(t,e){var n=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),r={},o=r.lib={},i=o.Base=function(){return{extend:function(t){var e=n(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=o.WordArray=i.extend({init:function(t,n){t=this.words=t||[],n!=e?this.sigBytes=n:this.sigBytes=4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i>>2]>>>24-i%4*8&255;e[r+i>>>2]|=a<<24-(r+i)%4*8}else for(var i=0;i>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n,r=[],o=function(e){var e=e,n=987654321,r=4294967295;return function(){n=36969*(65535&n)+(n>>16)&r,e=18e3*(65535&e)+(e>>16)&r;var o=(n<<16)+e&r;return o/=4294967296,o+=.5,o*(t.random()>.5?1:-1)}},i=0;i>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(n,e/2)}},u=s.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(n,e)}},f=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},l=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=4*i,c=o/s;c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0);var u=c*i,f=t.min(4*u,o);if(u){for(var l=0;l>>6-a%4*2;r[i>>>2]|=(s|c)<<24-i%4*8,i++}return o.create(r,i)}var n=t,r=n.lib,o=r.WordArray,i=n.enc;i.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var o=[],i=0;i>>2]>>>24-i%4*8&255,s=e[i+1>>>2]>>>24-(i+1)%4*8&255,c=e[i+2>>>2]>>>24-(i+2)%4*8&255,u=a<<16|s<<8|c,f=0;f<4&&i+.75*f>>6*(3-f)&63));var l=r.charAt(64);if(l)for(;o.length%4;)o.push(l);return o.join("")},parse:function(t){var n=t.length,r=this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var i=0;i>>8&16711935}var n=t,r=n.lib,o=r.WordArray,i=n.enc;i.Utf16=i.Utf16BE={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o>>2]>>>16-o%4*8&65535;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r>>1]|=t.charCodeAt(r)<<16-r%2*16;return o.create(n,2*e)}};i.Utf16LE={stringify:function(t){for(var n=t.words,r=t.sigBytes,o=[],i=0;i>>2]>>>16-i%4*8&65535);o.push(String.fromCharCode(a))}return o.join("")},parse:function(t){for(var n=t.length,r=[],i=0;i>>1]|=e(t.charCodeAt(i)<<16-i%2*16);return o.create(r,2*n)}}}(),t.enc.Utf16})},{"./core":53}],56:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./sha1"),t("./hmac")):"function"==typeof define&&define.amd?define(["./core","./sha1","./hmac"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.Base,o=n.WordArray,i=e.algo,a=i.MD5,s=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:a,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var n=this.cfg,r=n.hasher.create(),i=o.create(),a=i.words,s=n.keySize,c=n.iterations;a.lengthr&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),a=this._iKey=e.clone(),s=o.words,c=a.words,u=0;u>>2]|=t[r]<<24-r%4*8;o.call(this,n,e)}else o.apply(this,arguments)};i.prototype=r}}(),t.lib.WordArray})},{"./core":53}],61:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(e){function n(t,e,n,r,o,i,a){var s=t+(e&n|~e&r)+o+a;return(s<>>32-i)+e}function r(t,e,n,r,o,i,a){var s=t+(e&r|n&~r)+o+a;return(s<>>32-i)+e}function o(t,e,n,r,o,i,a){var s=t+(e^n^r)+o+a;return(s<>>32-i)+e}function i(t,e,n,r,o,i,a){var s=t+(n^(e|~r))+o+a;return(s<>>32-i)+e}var a=t,s=a.lib,c=s.WordArray,u=s.Hasher,f=a.algo,l=[];!function(){for(var t=0;t<64;t++)l[t]=4294967296*e.abs(e.sin(t+1))|0}();var p=f.MD5=u.extend({_doReset:function(){this._hash=new c.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var a=0;a<16;a++){var s=e+a,c=t[s];t[s]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}var u=this._hash.words,f=t[e+0],p=t[e+1],h=t[e+2],d=t[e+3],m=t[e+4],y=t[e+5],g=t[e+6],v=t[e+7],b=t[e+8],_=t[e+9],w=t[e+10],x=t[e+11],k=t[e+12],B=t[e+13],S=t[e+14],C=t[e+15],A=u[0],F=u[1],I=u[2],O=u[3];A=n(A,F,I,O,f,7,l[0]),O=n(O,A,F,I,p,12,l[1]),I=n(I,O,A,F,h,17,l[2]),F=n(F,I,O,A,d,22,l[3]),A=n(A,F,I,O,m,7,l[4]),O=n(O,A,F,I,y,12,l[5]),I=n(I,O,A,F,g,17,l[6]),F=n(F,I,O,A,v,22,l[7]),A=n(A,F,I,O,b,7,l[8]),O=n(O,A,F,I,_,12,l[9]),I=n(I,O,A,F,w,17,l[10]),F=n(F,I,O,A,x,22,l[11]),A=n(A,F,I,O,k,7,l[12]),O=n(O,A,F,I,B,12,l[13]),I=n(I,O,A,F,S,17,l[14]),F=n(F,I,O,A,C,22,l[15]),A=r(A,F,I,O,p,5,l[16]),O=r(O,A,F,I,g,9,l[17]),I=r(I,O,A,F,x,14,l[18]),F=r(F,I,O,A,f,20,l[19]),A=r(A,F,I,O,y,5,l[20]),O=r(O,A,F,I,w,9,l[21]),I=r(I,O,A,F,C,14,l[22]),F=r(F,I,O,A,m,20,l[23]),A=r(A,F,I,O,_,5,l[24]),O=r(O,A,F,I,S,9,l[25]),I=r(I,O,A,F,d,14,l[26]),F=r(F,I,O,A,b,20,l[27]),A=r(A,F,I,O,B,5,l[28]),O=r(O,A,F,I,h,9,l[29]),I=r(I,O,A,F,v,14,l[30]),F=r(F,I,O,A,k,20,l[31]),A=o(A,F,I,O,y,4,l[32]),O=o(O,A,F,I,b,11,l[33]),I=o(I,O,A,F,x,16,l[34]),F=o(F,I,O,A,S,23,l[35]),A=o(A,F,I,O,p,4,l[36]),O=o(O,A,F,I,m,11,l[37]),I=o(I,O,A,F,v,16,l[38]),F=o(F,I,O,A,w,23,l[39]),A=o(A,F,I,O,B,4,l[40]),O=o(O,A,F,I,f,11,l[41]),I=o(I,O,A,F,d,16,l[42]),F=o(F,I,O,A,g,23,l[43]),A=o(A,F,I,O,_,4,l[44]),O=o(O,A,F,I,k,11,l[45]),I=o(I,O,A,F,C,16,l[46]),F=o(F,I,O,A,h,23,l[47]),A=i(A,F,I,O,f,6,l[48]),O=i(O,A,F,I,v,10,l[49]),I=i(I,O,A,F,S,15,l[50]),F=i(F,I,O,A,y,21,l[51]),A=i(A,F,I,O,k,6,l[52]),O=i(O,A,F,I,d,10,l[53]),I=i(I,O,A,F,w,15,l[54]),F=i(F,I,O,A,p,21,l[55]),A=i(A,F,I,O,b,6,l[56]),O=i(O,A,F,I,C,10,l[57]),I=i(I,O,A,F,g,15,l[58]),F=i(F,I,O,A,B,21,l[59]),A=i(A,F,I,O,m,6,l[60]),O=i(O,A,F,I,x,10,l[61]),I=i(I,O,A,F,h,15,l[62]),F=i(F,I,O,A,_,21,l[63]),u[0]=u[0]+A|0,u[1]=u[1]+F|0,u[2]=u[2]+I|0,u[3]=u[3]+O|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296),a=r;n[(o+64>>>9<<4)+15]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[(o+64>>>9<<4)+14]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(n.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var f=c[u];c[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return s},clone:function(){var t=u.clone.call(this);return t._hash=this._hash.clone(),t}});a.MD5=u._createHelper(p),a.HmacMD5=u._createHmacHelper(p)}(Math),t.MD5})},{"./core":53}],62:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.mode.CFB=function(){function e(t,e,n,r){var o=this._iv;if(o){var i=o.slice(0);this._iv=void 0}else var i=this._prevBlock;r.encryptBlock(i,0);for(var a=0;a>24&255)){var e=t>>16&255,n=t>>8&255,r=255&t;255===e?(e=0,255===n?(n=0,255===r?r=0:++r):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=r}else t+=1<<24;return t}function n(t){return 0===(t[0]=e(t[0]))&&(t[1]=e(t[1])),t}var r=t.lib.BlockCipherMode.extend(),o=r.Encryptor=r.extend({processBlock:function(t,e){var r=this._cipher,o=r.blockSize,i=this._iv,a=this._counter;i&&(a=this._counter=i.slice(0),this._iv=void 0),n(a);var s=a.slice(0);r.encryptBlock(s,0);for(var c=0;c>>2]|=o<<24-i%4*8,t.sigBytes+=o},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923})},{"./cipher-core":52,"./core":53}],68:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.pad.Iso10126={pad:function(e,n){var r=4*n,o=r-e.sigBytes%r;e.concat(t.lib.WordArray.random(o-1)).concat(t.lib.WordArray.create([o<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126})},{"./cipher-core":52,"./core":53}],69:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.pad.Iso97971={pad:function(e,n){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,n)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971})},{"./cipher-core":52,"./core":53}],70:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding})},{"./cipher-core":52,"./core":53}],71:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return t.pad.ZeroPadding={pad:function(t,e){var n=4*e;t.clamp(),t.sigBytes+=n-(t.sigBytes%n||n)},unpad:function(t){for(var e=t.words,n=t.sigBytes-1;!(e[n>>>2]>>>24-n%4*8&255);)n--;t.sigBytes=n+1}},t.pad.ZeroPadding})},{"./cipher-core":52,"./core":53}],72:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./sha1"),t("./hmac")):"function"==typeof define&&define.amd?define(["./core","./sha1","./hmac"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.Base,o=n.WordArray,i=e.algo,a=i.SHA1,s=i.HMAC,c=i.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:a,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var n=this.cfg,r=s.create(n.hasher,t),i=o.create(),a=o.create([1]),c=i.words,u=a.words,f=n.keySize,l=n.iterations;c.length>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(var n=0;n<8;n++){var r=t[n]+e[n],o=65535&r,i=r>>>16,a=((o*o>>>17)+o*i>>>15)+i*i,u=((4294901760&r)*r|0)+((65535&r)*r|0);c[n]=a^u}t[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,t[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,t[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,t[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,t[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,t[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,t[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,t[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}var n=t,r=n.lib,o=r.StreamCipher,i=n.algo,a=[],s=[],c=[],u=i.RabbitLegacy=o.extend({_doReset:function(){var t=this._key.words,n=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],o=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)e.call(this);for(var i=0;i<8;i++)o[i]^=r[i+4&7];if(n){var a=n.words,s=a[0],c=a[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),l=u>>>16|4294901760&f,p=f<<16|65535&u;o[0]^=u,o[1]^=l,o[2]^=f,o[3]^=p,o[4]^=u,o[5]^=l,o[6]^=f,o[7]^=p;for(var i=0;i<4;i++)e.call(this)}},_doProcessBlock:function(t,n){var r=this._X;e.call(this),a[0]=r[0]^r[5]>>>16^r[3]<<16,a[1]=r[2]^r[7]>>>16^r[5]<<16,a[2]=r[4]^r[1]>>>16^r[7]<<16,a[3]=r[6]^r[3]>>>16^r[1]<<16;for(var o=0;o<4;o++)a[o]=16711935&(a[o]<<8|a[o]>>>24)|4278255360&(a[o]<<24|a[o]>>>8),t[n+o]^=a[o]},blockSize:4,ivSize:2});n.RabbitLegacy=o._createHelper(u)}(),t.RabbitLegacy})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return function(){function e(){for(var t=this._X,e=this._C,n=0;n<8;n++)s[n]=e[n];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(var n=0;n<8;n++){var r=t[n]+e[n],o=65535&r,i=r>>>16,a=((o*o>>>17)+o*i>>>15)+i*i,u=((4294901760&r)*r|0)+((65535&r)*r|0);c[n]=a^u}t[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,t[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,t[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,t[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,t[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,t[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,t[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,t[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}var n=t,r=n.lib,o=r.StreamCipher,i=n.algo,a=[],s=[],c=[],u=i.Rabbit=o.extend({_doReset:function(){for(var t=this._key.words,n=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var o=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var r=0;r<4;r++)e.call(this);for(var r=0;r<8;r++)i[r]^=o[r+4&7];if(n){var a=n.words,s=a[0],c=a[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),l=u>>>16|4294901760&f,p=f<<16|65535&u;i[0]^=u,i[1]^=l,i[2]^=f,i[3]^=p,i[4]^=u,i[5]^=l,i[6]^=f,i[7]^=p;for(var r=0;r<4;r++)e.call(this)}},_doProcessBlock:function(t,n){var r=this._X;e.call(this),a[0]=r[0]^r[5]>>>16^r[3]<<16,a[1]=r[2]^r[7]>>>16^r[5]<<16,a[2]=r[4]^r[1]>>>16^r[7]<<16,a[3]=r[6]^r[3]>>>16^r[1]<<16;for(var o=0;o<4;o++)a[o]=16711935&(a[o]<<8|a[o]>>>24)|4278255360&(a[o]<<24|a[o]>>>8),t[n+o]^=a[o]},blockSize:4,ivSize:2});n.Rabbit=o._createHelper(u)}(),t.Rabbit})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return function(){function e(){for(var t=this._S,e=this._i,n=this._j,r=0,o=0;o<4;o++){e=(e+1)%256,n=(n+t[e])%256;var i=t[e];t[e]=t[n],t[n]=i,r|=t[(t[e]+t[n])%256]<<24-8*o}return this._i=e,this._j=n,r}var n=t,r=n.lib,o=r.StreamCipher,i=n.algo,a=i.RC4=o.extend({_doReset:function(){for(var t=this._key,e=t.words,n=t.sigBytes,r=this._S=[],o=0;o<256;o++)r[o]=o;for(var o=0,i=0;o<256;o++){var a=o%n,s=e[a>>>2]>>>24-a%4*8&255;i=(i+r[o]+s)%256;var c=r[o];r[o]=r[i],r[i]=c}this._i=this._j=0},_doProcessBlock:function(t,n){t[n]^=e.call(this)},keySize:8,ivSize:0});n.RC4=o._createHelper(a);var s=i.RC4Drop=a.extend({cfg:a.cfg.extend({drop:192}),_doReset:function(){a._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)e.call(this)}});n.RC4Drop=o._createHelper(s)}(),t.RC4})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(e){function n(t,e,n){return t^e^n}function r(t,e,n){return t&e|~t&n}function o(t,e,n){return(t|~e)^n}function i(t,e,n){return t&n|e&~n}function a(t,e,n){return t^(e|~n)}function s(t,e){return t<>>32-e}var c=t,u=c.lib,f=u.WordArray,l=u.Hasher,p=c.algo,h=f.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),d=f.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),m=f.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),y=f.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),g=f.create([0,1518500249,1859775393,2400959708,2840853838]),v=f.create([1352829926,1548603684,1836072691,2053994217,0]),b=p.RIPEMD160=l.extend({ +_doReset:function(){this._hash=f.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var c=0;c<16;c++){var u=e+c,f=t[u];t[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}var l,p,b,_,w,x,k,B,S,C,A=this._hash.words,F=g.words,I=v.words,O=h.words,N=d.words,T=m.words,D=y.words;x=l=A[0],k=p=A[1],B=b=A[2],S=_=A[3],C=w=A[4];for(var E,c=0;c<80;c+=1)E=l+t[e+O[c]]|0,E+=c<16?n(p,b,_)+F[0]:c<32?r(p,b,_)+F[1]:c<48?o(p,b,_)+F[2]:c<64?i(p,b,_)+F[3]:a(p,b,_)+F[4],E=0|E,E=s(E,T[c]),E=E+w|0,l=w,w=_,_=s(b,10),b=p,p=E,E=x+t[e+N[c]]|0,E+=c<16?a(k,B,S)+I[0]:c<32?i(k,B,S)+I[1]:c<48?o(k,B,S)+I[2]:c<64?r(k,B,S)+I[3]:n(k,B,S)+I[4],E=0|E,E=s(E,D[c]),E=E+C|0,x=C,C=S,S=s(B,10),B=k,k=E;E=A[1]+b+S|0,A[1]=A[2]+_+C|0,A[2]=A[3]+w+x|0,A[3]=A[4]+l+k|0,A[4]=A[0]+p+B|0,A[0]=E},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;e[r>>>5]|=128<<24-r%32,e[(r+64>>>9<<4)+14]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(e.length+1),this._process();for(var o=this._hash,i=o.words,a=0;a<5;a++){var s=i[a];i[a]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return o},clone:function(){var t=l.clone.call(this);return t._hash=this._hash.clone(),t}});c.RIPEMD160=l._createHelper(b),c.HmacRIPEMD160=l._createHmacHelper(b)}(Math),t.RIPEMD160})},{"./core":53}],77:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.WordArray,o=n.Hasher,i=e.algo,a=[],s=i.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],c=n[4],u=0;u<80;u++){if(u<16)a[u]=0|t[e+u];else{var f=a[u-3]^a[u-8]^a[u-14]^a[u-16];a[u]=f<<1|f>>>31}var l=(r<<5|r>>>27)+c+a[u];l+=u<20?(o&i|~o&s)+1518500249:u<40?(o^i^s)+1859775393:u<60?(o&i|o&s|i&s)-1894007588:(o^i^s)-899497514,c=s,s=i,i=o<<30|o>>>2,o=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+c|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[(r+64>>>9<<4)+14]=Math.floor(n/4294967296),e[(r+64>>>9<<4)+15]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA1=o._createHelper(s),e.HmacSHA1=o._createHmacHelper(s)}(),t.SHA1})},{"./core":53}],78:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./sha256")):"function"==typeof define&&define.amd?define(["./core","./sha256"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,r=n.WordArray,o=e.algo,i=o.SHA256,a=o.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});e.SHA224=i._createHelper(a),e.HmacSHA224=i._createHmacHelper(a)}(),t.SHA224})},{"./core":53,"./sha256":79}],79:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,o=r.WordArray,i=r.Hasher,a=n.algo,s=[],c=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)t(r)&&(o<8&&(s[o]=n(e.pow(r,.5))),c[o]=n(e.pow(r,1/3)),o++),r++}();var u=[],f=a.SHA256=i.extend({_doReset:function(){this._hash=new o.init(s.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],a=n[3],s=n[4],f=n[5],l=n[6],p=n[7],h=0;h<64;h++){if(h<16)u[h]=0|t[e+h];else{var d=u[h-15],m=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=u[h-2],g=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[h]=m+u[h-7]+g+u[h-16]}var v=s&f^~s&l,b=r&o^r&i^o&i,_=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),w=(s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25),x=p+w+v+c[h]+u[h],k=_+b;p=l,l=f,f=s,s=a+x|0,a=i,i=o,o=r,r=x+k|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+a|0,n[4]=n[4]+s|0,n[5]=n[5]+f|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[(o+64>>>9<<4)+14]=e.floor(r/4294967296),n[(o+64>>>9<<4)+15]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});n.SHA256=i._createHelper(f),n.HmacSHA256=i._createHmacHelper(f)}(Math),t.SHA256})},{"./core":53}],80:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],o):o(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,o=r.WordArray,i=r.Hasher,a=n.x64,s=a.Word,c=n.algo,u=[],f=[],l=[];!function(){for(var t=1,e=0,n=0;n<24;n++){u[t+5*e]=(n+1)*(n+2)/2%64;var r=e%5,o=(2*t+3*e)%5;t=r,e=o}for(var t=0;t<5;t++)for(var e=0;e<5;e++)f[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,a=0;a<24;a++){for(var c=0,p=0,h=0;h<7;h++){if(1&i){var d=(1<>>24)|4278255360&(i<<24|i>>>8),a=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8);var s=n[o];s.high^=a,s.low^=i}for(var c=0;c<24;c++){for(var h=0;h<5;h++){for(var d=0,m=0,y=0;y<5;y++){var s=n[h+5*y];d^=s.high,m^=s.low}var g=p[h];g.high=d,g.low=m}for(var h=0;h<5;h++)for(var v=p[(h+4)%5],b=p[(h+1)%5],_=b.high,w=b.low,d=v.high^(_<<1|w>>>31),m=v.low^(w<<1|_>>>31),y=0;y<5;y++){var s=n[h+5*y];s.high^=d,s.low^=m}for(var x=1;x<25;x++){var s=n[x],k=s.high,B=s.low,S=u[x];if(S<32)var d=k<>>32-S,m=B<>>32-S;else var d=B<>>64-S,m=k<>>64-S;var C=p[f[x]];C.high=d,C.low=m}var A=p[0],F=n[0];A.high=F.high,A.low=F.low;for(var h=0;h<5;h++)for(var y=0;y<5;y++){var x=h+5*y,s=n[x],I=p[x],O=p[(h+1)%5+5*y],N=p[(h+2)%5+5*y];s.high=I.high^~O.high&N.high,s.low=I.low^~O.low&N.low}var s=n[0],T=l[c];s.high^=T.high,s.low^=T.low}},_doFinalize:function(){var t=this._data,n=t.words,r=(8*this._nDataBytes,8*t.sigBytes),i=32*this.blockSize;n[r>>>5]|=1<<24-r%32,n[(e.ceil((r+1)/i)*i>>>5)-1]|=128,t.sigBytes=4*n.length,this._process();for(var a=this._state,s=this.cfg.outputLength/8,c=s/8,u=[],f=0;f>>24)|4278255360&(p<<24|p>>>8),h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),u.push(h),u.push(p)}return new o.init(u,s)},clone:function(){for(var t=i.clone.call(this),e=t._state=this._state.slice(0),n=0;n<25;n++)e[n]=e[n].clone();return t}});n.SHA3=i._createHelper(h),n.HmacSHA3=i._createHmacHelper(h)}(Math),t.SHA3})},{"./core":53,"./x64-core":84}],81:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./x64-core"),t("./sha512")):"function"==typeof define&&define.amd?define(["./core","./x64-core","./sha512"],o):o(r.CryptoJS)}(this,function(t){return function(){var e=t,n=e.x64,r=n.Word,o=n.WordArray,i=e.algo,a=i.SHA512,s=i.SHA384=a.extend({_doReset:function(){this._hash=new o.init([new r.init(3418070365,3238371032),new r.init(1654270250,914150663),new r.init(2438529370,812702999),new r.init(355462360,4144912697),new r.init(1731405415,4290775857),new r.init(2394180231,1750603025),new r.init(3675008525,1694076839),new r.init(1203062813,3204075428)])},_doFinalize:function(){var t=a._doFinalize.call(this);return t.sigBytes-=16,t}});e.SHA384=a._createHelper(s),e.HmacSHA384=a._createHmacHelper(s)}(),t.SHA384})},{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],o):o(r.CryptoJS)}(this,function(t){return function(){function e(){return a.create.apply(a,arguments)}var n=t,r=n.lib,o=r.Hasher,i=n.x64,a=i.Word,s=i.WordArray,c=n.algo,u=[e(1116352408,3609767458),e(1899447441,602891725),e(3049323471,3964484399),e(3921009573,2173295548),e(961987163,4081628472),e(1508970993,3053834265),e(2453635748,2937671579),e(2870763221,3664609560),e(3624381080,2734883394),e(310598401,1164996542),e(607225278,1323610764),e(1426881987,3590304994),e(1925078388,4068182383),e(2162078206,991336113),e(2614888103,633803317),e(3248222580,3479774868),e(3835390401,2666613458),e(4022224774,944711139),e(264347078,2341262773),e(604807628,2007800933),e(770255983,1495990901),e(1249150122,1856431235),e(1555081692,3175218132),e(1996064986,2198950837),e(2554220882,3999719339),e(2821834349,766784016),e(2952996808,2566594879),e(3210313671,3203337956),e(3336571891,1034457026),e(3584528711,2466948901),e(113926993,3758326383),e(338241895,168717936),e(666307205,1188179964),e(773529912,1546045734),e(1294757372,1522805485),e(1396182291,2643833823),e(1695183700,2343527390),e(1986661051,1014477480),e(2177026350,1206759142),e(2456956037,344077627),e(2730485921,1290863460),e(2820302411,3158454273),e(3259730800,3505952657),e(3345764771,106217008),e(3516065817,3606008344),e(3600352804,1432725776),e(4094571909,1467031594),e(275423344,851169720),e(430227734,3100823752),e(506948616,1363258195),e(659060556,3750685593),e(883997877,3785050280),e(958139571,3318307427),e(1322822218,3812723403),e(1537002063,2003034995),e(1747873779,3602036899),e(1955562222,1575990012),e(2024104815,1125592928),e(2227730452,2716904306),e(2361852424,442776044),e(2428436474,593698344),e(2756734187,3733110249),e(3204031479,2999351573),e(3329325298,3815920427),e(3391569614,3928383900),e(3515267271,566280711),e(3940187606,3454069534),e(4118630271,4000239992),e(116418474,1914138554),e(174292421,2731055270),e(289380356,3203993006),e(460393269,320620315),e(685471733,587496836),e(852142971,1086792851),e(1017036298,365543100),e(1126000580,2618297676),e(1288033470,3409855158),e(1501505948,4234509866),e(1607167915,987167468),e(1816402316,1246189591)],f=[];!function(){for(var t=0;t<80;t++)f[t]=e()}();var l=c.SHA512=o.extend({_doReset:function(){this._hash=new s.init([new a.init(1779033703,4089235720),new a.init(3144134277,2227873595),new a.init(1013904242,4271175723),new a.init(2773480762,1595750129),new a.init(1359893119,2917565137),new a.init(2600822924,725511199),new a.init(528734635,4215389547),new a.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],a=n[3],s=n[4],c=n[5],l=n[6],p=n[7],h=r.high,d=r.low,m=o.high,y=o.low,g=i.high,v=i.low,b=a.high,_=a.low,w=s.high,x=s.low,k=c.high,B=c.low,S=l.high,C=l.low,A=p.high,F=p.low,I=h,O=d,N=m,T=y,D=g,E=v,P=b,R=_,M=w,H=x,j=k,q=B,z=S,L=C,U=A,W=F,J=0;J<80;J++){var G=f[J];if(J<16)var X=G.high=0|t[e+2*J],$=G.low=0|t[e+2*J+1];else{var V=f[J-15],K=V.high,Z=V.low,Y=(K>>>1|Z<<31)^(K>>>8|Z<<24)^K>>>7,Q=(Z>>>1|K<<31)^(Z>>>8|K<<24)^(Z>>>7|K<<25),tt=f[J-2],et=tt.high,nt=tt.low,rt=(et>>>19|nt<<13)^(et<<3|nt>>>29)^et>>>6,ot=(nt>>>19|et<<13)^(nt<<3|et>>>29)^(nt>>>6|et<<26),it=f[J-7],at=it.high,st=it.low,ct=f[J-16],ut=ct.high,ft=ct.low,$=Q+st,X=Y+at+($>>>0>>0?1:0),$=$+ot,X=X+rt+($>>>0>>0?1:0),$=$+ft,X=X+ut+($>>>0>>0?1:0);G.high=X,G.low=$}var lt=M&j^~M&z,pt=H&q^~H&L,ht=I&N^I&D^N&D,dt=O&T^O&E^T&E,mt=(I>>>28|O<<4)^(I<<30|O>>>2)^(I<<25|O>>>7),yt=(O>>>28|I<<4)^(O<<30|I>>>2)^(O<<25|I>>>7),gt=(M>>>14|H<<18)^(M>>>18|H<<14)^(M<<23|H>>>9),vt=(H>>>14|M<<18)^(H>>>18|M<<14)^(H<<23|M>>>9),bt=u[J],_t=bt.high,wt=bt.low,xt=W+vt,kt=U+gt+(xt>>>0>>0?1:0),xt=xt+pt,kt=kt+lt+(xt>>>0>>0?1:0),xt=xt+wt,kt=kt+_t+(xt>>>0>>0?1:0),xt=xt+$,kt=kt+X+(xt>>>0<$>>>0?1:0),Bt=yt+dt,St=mt+ht+(Bt>>>0>>0?1:0);U=z,W=L,z=j,L=q,j=M,q=H,H=R+xt|0,M=P+kt+(H>>>0>>0?1:0)|0,P=D,R=E,D=N,E=T,N=I,T=O,O=xt+Bt|0,I=kt+St+(O>>>0>>0?1:0)|0}d=r.low=d+O,r.high=h+I+(d>>>0>>0?1:0),y=o.low=y+T,o.high=m+N+(y>>>0>>0?1:0),v=i.low=v+E,i.high=g+D+(v>>>0>>0?1:0),_=a.low=_+R,a.high=b+P+(_>>>0>>0?1:0),x=s.low=x+H,s.high=w+M+(x>>>0>>0?1:0),B=c.low=B+q,c.high=k+j+(B>>>0>>0?1:0),C=l.low=C+L,l.high=S+z+(C>>>0>>0?1:0),F=p.low=F+W,p.high=A+U+(F>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;e[r>>>5]|=128<<24-r%32,e[(r+128>>>10<<5)+30]=Math.floor(n/4294967296),e[(r+128>>>10<<5)+31]=n,t.sigBytes=4*e.length,this._process();var o=this._hash.toX32();return o},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});n.SHA512=o._createHelper(l),n.HmacSHA512=o._createHmacHelper(l)}(),t.SHA512})},{"./core":53,"./x64-core":84}],83:[function(t,e,n){!function(r,o,i){"object"==typeof n?e.exports=n=o(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],o):o(r.CryptoJS)}(this,function(t){return function(){function e(t,e){var n=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=n,this._lBlock^=n<>>t^this._lBlock)&e;this._lBlock^=n,this._rBlock^=n<>>5]>>>31-o%32&1}for(var i=this._subKeys=[],a=0;a<16;a++){for(var s=i[a]=[],l=f[a],r=0;r<24;r++)s[r/6|0]|=n[(u[r]-1+l)%28]<<31-r%6,s[4+(r/6|0)]|=n[28+(u[r+24]-1+l)%28]<<31-r%6;s[0]=s[0]<<1|s[0]>>>31;for(var r=1;r<7;r++)s[r]=s[r]>>>4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}for(var p=this._invSubKeys=[],r=0;r<16;r++)p[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,r,o){this._lBlock=t[r],this._rBlock=t[r+1],e.call(this,4,252645135),e.call(this,16,65535),n.call(this,2,858993459),n.call(this,8,16711935),e.call(this,1,1431655765);for(var i=0;i<16;i++){for(var a=o[i],s=this._lBlock,c=this._rBlock,u=0,f=0;f<8;f++)u|=l[f][((c^a[f])&p[f])>>>0];this._lBlock=c,this._rBlock=s^u}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,e.call(this,1,1431655765),n.call(this,8,16711935),n.call(this,2,858993459),e.call(this,16,65535),e.call(this,4,252645135),t[r]=this._lBlock,t[r+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=a._createHelper(h);var d=s.TripleDES=a.extend({_doReset:function(){var t=this._key,e=t.words;this._des1=h.createEncryptor(i.create(e.slice(0,2))),this._des2=h.createEncryptor(i.create(e.slice(2,4))),this._des3=h.createEncryptor(i.create(e.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2});r.TripleDES=a._createHelper(d)}(),t.TripleDES})},{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(t,e,n){!function(r,o){"object"==typeof n?e.exports=n=o(t("./core")):"function"==typeof define&&define.amd?define(["./core"],o):o(r.CryptoJS)}(this,function(t){return function(e){var n=t,r=n.lib,o=r.Base,i=r.WordArray,a=n.x64={};a.Word=o.extend({init:function(t,e){this.high=t,this.low=e}}),a.WordArray=o.extend({init:function(t,n){t=this.words=t||[],n!=e?this.sigBytes=n:this.sigBytes=8*t.length},toX32:function(){for(var t=this.words,e=t.length,n=[],r=0;r=55296&&e<=56319&&o65535&&(e-=65536,o+=v(e>>>10&1023|55296),e=56320|1023&e),o+=v(e);return o}function i(t){if(t>=55296&&t<=57343)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value")}function a(t,e){return v(t>>e&63|128)}function s(t){if(0==(4294967168&t))return v(t);var e="";return 0==(4294965248&t)?e=v(t>>6&31|192):0==(4294901760&t)?(i(t),e=v(t>>12&15|224),e+=a(t,6)):0==(4292870144&t)&&(e=v(t>>18&7|240),e+=a(t,12),e+=a(t,6)),e+=v(63&t|128)}function c(t){for(var e,n=r(t),o=n.length,i=-1,a="";++i=y)throw Error("Invalid byte index");var t=255&m[g];if(g++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function f(){var t,e,n,r,o;if(g>y)throw Error("Invalid byte index");if(g==y)return!1;if(t=255&m[g],g++,0==(128&t))return t;if(192==(224&t)){if(e=u(),o=(31&t)<<6|e,o>=128)return o;throw Error("Invalid continuation byte")}if(224==(240&t)){if(e=u(),n=u(),o=(15&t)<<12|e<<6|n,o>=2048)return i(o),o;throw Error("Invalid continuation byte")}if(240==(248&t)&&(e=u(),n=u(),r=u(),o=(7&t)<<18|e<<12|n<<6|r,o>=65536&&o<=1114111))return o;throw Error("Invalid UTF-8 detected")}function l(t){m=r(t),y=m.length,g=0;for(var e,n=[];(e=f())!==!1;)n.push(e);return o(n)}var p="object"==typeof n&&n,h="object"==typeof e&&e&&e.exports==p&&e,d="object"==typeof global&&global;d.global!==d&&d.window!==d||(t=d);var m,y,g,v=String.fromCharCode,b={version:"2.1.2",encode:c,decode:l};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return b});else if(p&&!p.nodeType)if(h)h.exports=b;else{var _={},w=_.hasOwnProperty;for(var x in b)w.call(b,x)&&(p[x]=b[x])}else t.utf8=b}(this)},{}],86:[function(t,e,n){e.exports=XMLHttpRequest},{}],"bignumber.js":[function(t,e,n){!function(n){"use strict";function r(t){function e(t,r){var o,i,a,s,c,u,f=this;if(!(f instanceof e))return W&&T(26,"constructor call without new",t),new e(t,r);if(null!=r&&J(r,2,64,P,"base")){if(r=0|r,u=t+"",10==r)return f=new e(t instanceof e?t:u),D(f,H+f.e+1,j);if((s="number"==typeof t)&&0*t!=0||!new RegExp("^-?"+(o="["+x.slice(0,r)+"]+")+"(?:\\."+o+")?$",r<37?"i":"").test(u))return m(f,u,s,r);s?(f.s=1/t<0?(u=u.slice(1),-1):1,W&&u.replace(/^0\.0*|\./,"").length>15&&T(P,w,t),s=!1):f.s=45===u.charCodeAt(0)?(u=u.slice(1),-1):1,u=n(u,10,r,f.s)}else{if(t instanceof e)return f.s=t.s,f.e=t.e,f.c=(t=t.c)?t.slice():t,void(P=0);if((s="number"==typeof t)&&0*t==0){if(f.s=1/t<0?(t=-t,-1):1,t===~~t){for(i=0,a=t;a>=10;a/=10,i++);return f.e=i,f.c=[t],void(P=0)}u=t+""}else{if(!y.test(u=t+""))return m(f,u,s);f.s=45===u.charCodeAt(0)?(u=u.slice(1),-1):1}}for((i=u.indexOf("."))>-1&&(u=u.replace(".","")),(a=u.search(/e/i))>0?(i<0&&(i=a),i+=+u.slice(a+1),u=u.substring(0,a)):i<0&&(i=u.length),a=0;48===u.charCodeAt(a);a++);for(c=u.length;48===u.charCodeAt(--c););if(u=u.slice(a,c+1))if(c=u.length,s&&W&&c>15&&T(P,w,f.s*t),i=i-a-1,i>U)f.c=f.e=null;else if(i=0&&(c=$,$=0,t=t.replace(".",""),d=new e(r),p=d.pow(t.length-m),$=c,d.c=u(l(i(p.c),p.e),10,n),d.e=d.c.length),h=u(t,r,n),s=c=h.length;0==h[--c];h.pop());if(!h[0])return"0";if(m<0?--s:(p.c=h,p.e=s,p.s=o,p=E(p,d,y,g,n),h=p.c,f=p.r,s=p.e),a=s+y+1,m=h[a],c=n/2,f=f||a<0||null!=h[a+1],f=g<4?(null!=m||f)&&(0==g||g==(p.s<0?3:2)):m>c||m==c&&(4==g||f||6==g&&1&h[a-1]||g==(p.s<0?8:7)),a<1||!h[0])t=f?l("1",-y):"0";else{if(h.length=a,f)for(--n;++h[--a]>n;)h[a]=0,a||(++s,h.unshift(1));for(c=h.length;!h[--c];);for(m=0,t="";m<=c;t+=x.charAt(h[m++]));t=l(t,s)}return t}function h(t,n,r,o){var a,s,c,u,p;if(r=null!=r&&J(r,0,8,o,_)?0|r:j,!t.c)return t.toString();if(a=t.c[0],c=t.e,null==n)p=i(t.c),p=19==o||24==o&&c<=q?f(p,c):l(p,c);else if(t=D(new e(t),n,r),s=t.e,p=i(t.c),u=p.length,19==o||24==o&&(n<=s||s<=q)){for(;uu){if(--n>0)for(p+=".";n--;p+="0");}else if(n+=s-u,n>0)for(s+1==u&&(p+=".");n--;p+="0");return t.s<0&&a?"-"+p:p}function I(t,n){var r,o,i=0;for(c(t[0])&&(t=t[0]),r=new e(t[0]);++in||t!=p(t))&&T(r,(o||"decimal places")+(tn?" out of range":" not an integer"),t),!0}function N(t,e,n){for(var r=1,o=e.length;!e[--o];e.pop());for(o=e[0];o>=10;o/=10,r++);return(n=r+n*B-1)>U?t.c=t.e=null:n=10;s/=10,o++);if(i=e-o,i<0)i+=B,a=e,c=l[u=0],f=c/p[o-a-1]%10|0;else if(u=g((i+1)/B),u>=l.length){if(!r)break t;for(;l.length<=u;l.push(0));c=f=0,o=1,i%=B,a=i-B+1}else{for(c=s=l[u],o=1;s>=10;s/=10,o++);i%=B,a=i-B+o,f=a<0?0:c/p[o-a-1]%10|0}if(r=r||e<0||null!=l[u+1]||(a<0?c:c%p[o-a-1]),r=n<4?(f||r)&&(0==n||n==(t.s<0?3:2)):f>5||5==f&&(4==n||r||6==n&&(i>0?a>0?c/p[o-a]:0:l[u-1])%10&1||n==(t.s<0?8:7)),e<1||!l[0])return l.length=0,r?(e-=t.e+1,l[0]=p[e%B],t.e=-e||0):l[0]=t.e=0,t;if(0==i?(l.length=u,s=1,u--):(l.length=u+1,s=p[B-i],l[u]=a>0?v(c/p[o-a]%p[a])*s:0),r)for(;;){if(0==u){for(i=1,a=l[0];a>=10;a/=10,i++);for(a=l[0]+=s,s=1;a>=10;a/=10,s++);i!=s&&(t.e++,l[0]==k&&(l[0]=1));break}if(l[u]+=s,l[u]!=k)break;l[u--]=0,s=1}for(i=l.length;0===l[--i];l.pop());}t.e>U?t.c=t.e=null:t.en)return null!=(t=o[n++])};return a(e="DECIMAL_PLACES")&&J(t,0,F,2,e)&&(H=0|t),r[e]=H,a(e="ROUNDING_MODE")&&J(t,0,8,2,e)&&(j=0|t),r[e]=j,a(e="EXPONENTIAL_AT")&&(c(t)?J(t[0],-F,0,2,e)&&J(t[1],0,F,2,e)&&(q=0|t[0],z=0|t[1]):J(t,-F,F,2,e)&&(q=-(z=0|(t<0?-t:t)))),r[e]=[q,z],a(e="RANGE")&&(c(t)?J(t[0],-F,-1,2,e)&&J(t[1],1,F,2,e)&&(L=0|t[0],U=0|t[1]):J(t,-F,F,2,e)&&(0|t?L=-(U=0|(t<0?-t:t)):W&&T(2,e+" cannot be zero",t))),r[e]=[L,U],a(e="ERRORS")&&(t===!!t||1===t||0===t?(P=0,J=(W=!!t)?O:s):W&&T(2,e+b,t)),r[e]=W,a(e="CRYPTO")&&(t===!!t||1===t||0===t?(G=!(!t||!d||"object"!=typeof d),t&&!G&&W&&T(2,"crypto unavailable",d)):W&&T(2,e+b,t)),r[e]=G,a(e="MODULO_MODE")&&J(t,0,9,2,e)&&(X=0|t),r[e]=X,a(e="POW_PRECISION")&&J(t,0,F,2,e)&&($=0|t),r[e]=$,a(e="FORMAT")&&("object"==typeof t?V=t:W&&T(2,e+" not an object",t)),r[e]=V,r},e.max=function(){return I(arguments,R.lt)},e.min=function(){return I(arguments,R.gt)},e.random=function(){var t=9007199254740992,n=Math.random()*t&2097151?function(){return v(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,o,i,a,s,c=0,u=[],f=new e(M);if(t=null!=t&&J(t,0,F,14)?0|t:H,a=g(t/B),G)if(d&&d.getRandomValues){for(r=d.getRandomValues(new Uint32Array(a*=2));c>>11),s>=9e15?(o=d.getRandomValues(new Uint32Array(2)),r[c]=o[0], +r[c+1]=o[1]):(u.push(s%1e14),c+=2);c=a/2}else if(d&&d.randomBytes){for(r=d.randomBytes(a*=7);c=9e15?d.randomBytes(7).copy(r,c):(u.push(s%1e14),c+=7);c=a/7}else W&&T(14,"crypto unavailable",d);if(!c)for(;c=10;s/=10,c++);cr?1:-1;else for(o=i=0;oe[o]?1:-1;break}return i}function r(t,e,n,r){for(var o=0;n--;)t[n]-=o,o=t[n]1;t.shift());}return function(i,a,s,c,u){var f,l,p,h,d,m,y,g,b,_,w,x,S,C,A,F,I,O=i.s==a.s?1:-1,N=i.c,T=a.c;if(!(N&&N[0]&&T&&T[0]))return new e(i.s&&a.s&&(N?!T||N[0]!=T[0]:T)?N&&0==N[0]||!T?0*O:O/0:NaN);for(g=new e(O),b=g.c=[],l=i.e-a.e,O=s+l+1,u||(u=k,l=o(i.e/B)-o(a.e/B),O=O/B|0),p=0;T[p]==(N[p]||0);p++);if(T[p]>(N[p]||0)&&l--,O<0)b.push(1),h=!0;else{for(C=N.length,F=T.length,p=0,O+=2,d=v(u/(T[0]+1)),d>1&&(T=t(T,d,u),N=t(N,d,u),F=T.length,C=N.length),S=F,_=N.slice(0,F),w=_.length;w=u/2&&A++;do{if(d=0,f=n(T,_,F,w),f<0){if(x=_[0],F!=w&&(x=x*u+(_[1]||0)),d=v(x/A),d>1)for(d>=u&&(d=u-1),m=t(T,d,u),y=m.length,w=_.length;1==n(m,_,y,w);)d--,r(m,F=10;O/=10,p++);D(g,s+(g.e=p+l*B-1)+1,c,h)}else g.e=l,g.r=+h;return g}}(),m=function(){var t=/^(-?)0([xbo])/i,n=/^([^.]+)\.$/,r=/^\.([^.]+)$/,o=/^-?(Infinity|NaN)$/,i=/^\s*\+|^\s+|\s+$/g;return function(a,s,c,u){var f,l=c?s:s.replace(i,"");if(o.test(l))a.s=isNaN(l)?null:l<0?-1:1;else{if(!c&&(l=l.replace(t,function(t,e,n){return f="x"==(n=n.toLowerCase())?16:"b"==n?2:8,u&&u!=f?t:e}),u&&(f=u,l=l.replace(n,"$1").replace(r,"0.$1")),s!=l))return new e(l,f);W&&T(P,"not a"+(u?" base "+u:"")+" number",s),a.s=null}a.c=a.e=null,P=0}}(),R.absoluteValue=R.abs=function(){var t=new e(this);return t.s<0&&(t.s=1),t},R.ceil=function(){return D(new e(this),this.e+1,2)},R.comparedTo=R.cmp=function(t,n){return P=1,a(this,new e(t,n))},R.decimalPlaces=R.dp=function(){var t,e,n=this.c;if(!n)return null;if(t=((e=n.length-1)-o(this.e/B))*B,e=n[e])for(;e%10==0;e/=10,t--);return t<0&&(t=0),t},R.dividedBy=R.div=function(t,n){return P=3,E(this,new e(t,n),H,j)},R.dividedToIntegerBy=R.divToInt=function(t,n){return P=4,E(this,new e(t,n),0,1)},R.equals=R.eq=function(t,n){return P=5,0===a(this,new e(t,n))},R.floor=function(){return D(new e(this),this.e+1,3)},R.greaterThan=R.gt=function(t,n){return P=6,a(this,new e(t,n))>0},R.greaterThanOrEqualTo=R.gte=function(t,n){return P=7,1===(n=a(this,new e(t,n)))||0===n},R.isFinite=function(){return!!this.c},R.isInteger=R.isInt=function(){return!!this.c&&o(this.e/B)>this.c.length-2},R.isNaN=function(){return!this.s},R.isNegative=R.isNeg=function(){return this.s<0},R.isZero=function(){return!!this.c&&0==this.c[0]},R.lessThan=R.lt=function(t,n){return P=8,a(this,new e(t,n))<0},R.lessThanOrEqualTo=R.lte=function(t,n){return P=9,(n=a(this,new e(t,n)))===-1||0===n},R.minus=R.sub=function(t,n){var r,i,a,s,c=this,u=c.s;if(P=10,t=new e(t,n),n=t.s,!u||!n)return new e(NaN);if(u!=n)return t.s=-n,c.plus(t);var f=c.e/B,l=t.e/B,p=c.c,h=t.c;if(!f||!l){if(!p||!h)return p?(t.s=-n,t):new e(h?c:NaN);if(!p[0]||!h[0])return h[0]?(t.s=-n,t):new e(p[0]?c:3==j?-0:0)}if(f=o(f),l=o(l),p=p.slice(),u=f-l){for((s=u<0)?(u=-u,a=p):(l=f,a=h),a.reverse(),n=u;n--;a.push(0));a.reverse()}else for(i=(s=(u=p.length)<(n=h.length))?u:n,u=n=0;n0)for(;n--;p[r++]=0);for(n=k-1;i>u;){if(p[--i]0?(c=s,r=f):(a=-a,r=u),r.reverse();a--;r.push(0));r.reverse()}for(a=u.length,n=f.length,a-n<0&&(r=f,f=u,u=r,n=a),a=0;n;)a=(u[--n]=u[n]+f[n]+a)/k|0,u[n]%=k;return a&&(u.unshift(a),++c),N(t,u,c)},R.precision=R.sd=function(t){var e,n,r=this,o=r.c;if(null!=t&&t!==!!t&&1!==t&&0!==t&&(W&&T(13,"argument"+b,t),t!=!!t&&(t=null)),!o)return null;if(n=o.length-1,e=n*B+1,n=o[n]){for(;n%10==0;n/=10,e--);for(n=o[0];n>=10;n/=10,e++);}return t&&r.e+1>e&&(e=r.e+1),e},R.round=function(t,n){var r=new e(this);return(null==t||J(t,0,F,15))&&D(r,~~t+this.e+1,null!=n&&J(n,0,8,15,_)?0|n:j),r},R.shift=function(t){var n=this;return J(t,-S,S,16,"argument")?n.times("1e"+p(t)):new e(n.c&&n.c[0]&&(t<-S||t>S)?n.s*(t<0?0:1/0):n)},R.squareRoot=R.sqrt=function(){var t,n,r,a,s,c=this,u=c.c,f=c.s,l=c.e,p=H+4,h=new e("0.5");if(1!==f||!u||!u[0])return new e(!f||f<0&&(!u||u[0])?NaN:u?c:1/0);if(f=Math.sqrt(+c),0==f||f==1/0?(n=i(u),(n.length+l)%2==0&&(n+="0"),f=Math.sqrt(n),l=o((l+1)/2)-(l<0||l%2),f==1/0?n="1e"+l:(n=f.toExponential(),n=n.slice(0,n.indexOf("e")+1)+l),r=new e(n)):r=new e(f+""),r.c[0])for(l=r.e,f=l+p,f<3&&(f=0);;)if(s=r,r=h.times(s.plus(E(c,s,p,1))),i(s.c).slice(0,f)===(n=i(r.c)).slice(0,f)){if(r.e=0;){for(r=0,d=w[a]%v,m=w[a]/v|0,c=f,s=a+c;s>a;)l=_[--c]%v,p=_[c]/v|0,u=m*l+p*d,l=d*l+u%v*v+y[s]+r,r=(l/g|0)+(u/v|0)+m*p,y[s--]=l%g;y[s]=r}return r?++i:y.shift(),N(t,y,i)},R.toDigits=function(t,n){var r=new e(this);return t=null!=t&&J(t,1,F,18,"precision")?0|t:null,n=null!=n&&J(n,0,8,18,_)?0|n:j,t?D(r,t,n):r},R.toExponential=function(t,e){return h(this,null!=t&&J(t,0,F,19)?~~t+1:null,e,19)},R.toFixed=function(t,e){return h(this,null!=t&&J(t,0,F,20)?~~t+this.e+1:null,e,20)},R.toFormat=function(t,e){var n=h(this,null!=t&&J(t,0,F,21)?~~t+this.e+1:null,e,21);if(this.c){var r,o=n.split("."),i=+V.groupSize,a=+V.secondaryGroupSize,s=V.groupSeparator,c=o[0],u=o[1],f=this.s<0,l=f?c.slice(1):c,p=l.length;if(a&&(r=i,i=a,a=r,p-=r),i>0&&p>0){for(r=p%i||i,c=l.substr(0,r);r0&&(c+=s+l.slice(r)),f&&(c="-"+c)}n=u?c+V.decimalSeparator+((a=+V.fractionGroupSize)?u.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+V.fractionGroupSeparator):u):c}return n},R.toFraction=function(t){var n,r,o,a,s,c,u,f,l,p=W,h=this,d=h.c,m=new e(M),y=r=new e(M),g=u=new e(M);if(null!=t&&(W=!1,c=new e(t),W=p,(p=c.isInt())&&!c.lt(M)||(W&&T(22,"max denominator "+(p?"out of range":"not an integer"),t),t=!p&&c.c&&D(c,c.e+1,1).gte(M)?c:null)),!d)return h.toString();for(l=i(d),a=m.e=l.length-h.e-1,m.c[0]=C[(s=a%B)<0?B+s:s],t=!t||c.cmp(m)>0?a>0?m:y:c,s=U,U=1/0,c=new e(l),u.c[0]=0;f=E(c,m,0,1),o=r.plus(f.times(g)),1!=o.cmp(t);)r=g,g=o,y=u.plus(f.times(o=y)),u=o,m=c.minus(f.times(o=m)),c=o;return o=E(t.minus(r),g,0,1),u=u.plus(o.times(y)),r=r.plus(o.times(g)),u.s=y.s=h.s,a*=2,n=E(y,g,a,j).minus(h).abs().cmp(E(u,r,a,j).minus(h).abs())<1?[y.toString(),g.toString()]:[u.toString(),r.toString()],U=s,n},R.toNumber=function(){var t=this;return+t||(t.s?0*t.s:NaN)},R.toPower=R.pow=function(t){var n,r,o=v(t<0?-t:+t),i=this;if(!J(t,-S,S,23,"exponent")&&(!isFinite(t)||o>S&&(t/=0)||parseFloat(t)!=t&&!(t=NaN)))return new e(Math.pow(+i,t));for(n=$?g($/B+2):0,r=new e(M);;){if(o%2){if(r=r.times(i),!r.c)break;n&&r.c.length>n&&(r.c.length=n)}if(o=v(o/2),!o)break;i=i.times(i),n&&i.c&&i.c.length>n&&(i.c.length=n)}return t<0&&(r=M.div(r)),n?D(r,$,j):r},R.toPrecision=function(t,e){return h(this,null!=t&&J(t,1,F,24,"precision")?0|t:null,e,24)},R.toString=function(t){var e,r=this,o=r.s,a=r.e;return null===a?o?(e="Infinity",o<0&&(e="-"+e)):e="NaN":(e=i(r.c),e=null!=t&&J(t,2,64,25,"base")?n(l(e,a),0|t,10,o):a<=q||a>=z?f(e,a):l(e,a),o<0&&r.c[0]&&(e="-"+e)),e},R.truncated=R.trunc=function(){return D(new e(this),this.e+1,1)},R.valueOf=R.toJSON=function(){return this.toString()},null!=t&&e.config(t),e}function o(t){var e=0|t;return t>0||t===e?e:e-1}function i(t){for(var e,n,r=1,o=t.length,i=t[0]+"";ru^n?1:-1;for(s=(c=o.length)<(u=i.length)?c:u,a=0;ai[a]^n?1:-1;return c==u?0:c>u^n?1:-1}function s(t,e,n){return(t=p(t))>=e&&t<=n}function c(t){return"[object Array]"==Object.prototype.toString.call(t)}function u(t,e,n){for(var r,o,i=[0],a=0,s=t.length;an-1&&(null==i[r+1]&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function f(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function l(t,e){var n,r;if(e<0){for(r="0.";++e;r+="0");t=r+t}else if(n=t.length,++e>n){for(r="0",e-=n;--e;r+="0");t+=r}else e>>>>>> develop diff --git a/docs/web3-eth-contract.rst b/docs/web3-eth-contract.rst index e88b9c6..788c55f 100644 --- a/docs/web3-eth-contract.rst +++ b/docs/web3-eth-contract.rst @@ -254,6 +254,7 @@ Example .on('receipt', function(receipt){ // same as when the promise gets resolved, see below }) + .on('confirmation', function(confirmationNumber, receipt){ ... }) .then(function(receipt){ console.log(myContract.options.address) // gives the new contract address }); @@ -351,7 +352,7 @@ Example ... }); - // or sending a transaction to a method + // or sending and using the events myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'}) .on('transactionHash', function(hash){ @@ -360,6 +361,7 @@ Example .on('receipt', function(receipt){ ... }) + .on('confirmation', function(confirmationNumber, receipt){ ... }) .on('error', console.error); @@ -435,7 +437,7 @@ Parameters * ``String`` - **from**: The address the transaction should be send from. * ``String`` - **gasPrice** (optional): The gas price in wei to use for this transaction. * ``Number`` - **gas** (optional): The maximum gas provided for this transaction (gas limit). -2. ``Function`` - **callback** (optional): This callback will be fired first with the "transactionHash" and later for the "receipt" as second argument, or with an error object as the first argument. +2. ``Function`` - **callback** (optional): This callback will be fired first with the "transactionHash", or with an error object as the first argument. ------- Returns @@ -444,7 +446,8 @@ Returns ``PromiEvent``: A promise combined event emitter. Will be resolved when the transaction *receipt* is available. Additionally the following events are available: - ``"transactionHash"`` returns ``String``: is fired right after the transaction is send and a transaction hash is available. -- ``"receipt"`` returns ``String``: is fired when the transaction receipt with the contract address is available. +- ``"receipt"`` returns ``Object``: is fired when the transaction receipt is available. +- ``"confirmation"`` returns ``Number``, ``Object``: is fired for every confirmation up to the 12th confirmation. Receives the confirmation number as the first and the receipt as the second argument. - ``"error"`` returns ``Error``: is fired if an error occurs during deployment. @@ -474,6 +477,7 @@ Example .on('receipt', function(receipt){ ... }) + .on('confirmation', function(confirmationNumber, receipt){ ... }) .on('error', console.error); diff --git a/gulpfile.js b/gulpfile.js index d1b087b..10863c3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,7 +2,7 @@ 'use strict'; -var version = require('./lib/version.json'); +var version = require('./lerna.json'); var path = require('path'); var del = require('del'); diff --git a/index.js b/index.js deleted file mode 100644 index badd4d5..0000000 --- a/index.js +++ /dev/null @@ -1,8 +0,0 @@ -var Web3 = require('./lib/web3'); - -// dont override global variable -if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') { - window.Web3 = Web3; -} - -module.exports = Web3; diff --git a/lerna.json b/lerna.json new file mode 100644 index 0000000..d94faad --- /dev/null +++ b/lerna.json @@ -0,0 +1,7 @@ +{ + "version": "1.0.0", + "lerna": "2.0.0-beta.32", + "packages": [ + "packages/*" + ] +} diff --git a/lib/contracts/GlobalRegistrar.json b/lib/contracts/GlobalRegistrar.json deleted file mode 100644 index 928e05f..0000000 --- a/lib/contracts/GlobalRegistrar.json +++ /dev/null @@ -1,254 +0,0 @@ -[ - { - "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": "", - "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" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "_name", - "type": "bytes32" - }, - { - "indexed": false, - "name": "_winner", - "type": "address" - } - ], - "name": "AuctionEnded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "_name", - "type": "bytes32" - }, - { - "indexed": false, - "name": "_bidder", - "type": "address" - }, - { - "indexed": false, - "name": "_value", - "type": "uint256" - } - ], - "name": "NewBid", - "type": "event" - }, - { - "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" - } -] diff --git a/lib/contracts/ICAPRegistrar.json b/lib/contracts/ICAPRegistrar.json deleted file mode 100644 index 429845d..0000000 --- a/lib/contracts/ICAPRegistrar.json +++ /dev/null @@ -1,108 +0,0 @@ -[ - { - "constant": true, - "inputs": [ - { - "name": "_name", - "type": "bytes32" - } - ], - "name": "owner", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_name", - "type": "bytes32" - }, - { - "name": "_refund", - "type": "address" - } - ], - "name": "disown", - "outputs": [], - "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": false, - "inputs": [ - { - "name": "_name", - "type": "bytes32" - }, - { - "name": "_newOwner", - "type": "address" - } - ], - "name": "transfer", - "outputs": [], - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_name", - "type": "bytes32" - }, - { - "name": "_a", - "type": "address" - } - ], - "name": "setAddr", - "outputs": [], - "type": "function" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "name", - "type": "bytes32" - } - ], - "name": "Changed", - "type": "event" - } -] diff --git a/lib/contracts/SmartExchange.json b/lib/contracts/SmartExchange.json deleted file mode 100644 index 2415573..0000000 --- a/lib/contracts/SmartExchange.json +++ /dev/null @@ -1,147 +0,0 @@ -[ - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "bytes32" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [], - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "bytes32" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "indirectId", - "type": "bytes32" - }, - { - "name": "value", - "type": "uint256" - } - ], - "name": "icapTransfer", - "outputs": [], - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "to", - "type": "bytes32" - } - ], - "name": "deposit", - "outputs": [], - "payable": true, - "type": "function" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "AnonymousDeposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "bytes32" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "bytes32" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "bytes32" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "indirectId", - "type": "bytes32" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "IcapTransfer", - "type": "event" - } -] diff --git a/lib/utils/browser-bn.js b/lib/utils/browser-bn.js deleted file mode 100644 index 30aabb2..0000000 --- a/lib/utils/browser-bn.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = BigNumber; // jshint ignore:line - diff --git a/lib/utils/config.js b/lib/utils/config.js deleted file mode 100644 index 5c16262..0000000 --- a/lib/utils/config.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - This file is part of web3.js. - - web3.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. - - web3.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 web3.js. If not, see . -*/ -/** @file config.js - * @authors: - * Marek Kotewicz - * @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/2, - defaultBlock: 'latest', - defaultAccount: undefined -}; - diff --git a/lib/version.json b/lib/version.json deleted file mode 100644 index b8bfb0c..0000000 --- a/lib/version.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} diff --git a/lib/web3.js b/lib/web3.js deleted file mode 100644 index 625e383..0000000 --- a/lib/web3.js +++ /dev/null @@ -1,153 +0,0 @@ -/* - This file is part of web3.js. - - web3.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. - - web3.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 web3.js. If not, see . -*/ -/** - * @file web3.js - * @authors: - * Jeffrey Wilcke - * Marek Kotewicz - * Marian Oancea - * Fabian Vogelsteller - * Gav Wood - * @date 2016 - */ - -var RequestManager = require('./web3/requestmanager'); -var Iban = require('./web3/iban'); -var Eth = require('./web3/methods/eth'); -var DB = require('./web3/methods/db'); -var Shh = require('./web3/methods/shh'); -var Net = require('./web3/methods/net'); -var Personal = require('./web3/methods/personal'); -var Swarm = require('./web3/methods/swarm'); -var Settings = require('./web3/settings'); -var version = require('./version.json'); -var utils = require('./utils/utils'); -var sha3 = require('./utils/sha3'); -var extend = require('./web3/extend'); -var Batch = require('./web3/batch'); -var Property = require('./web3/property'); -var HttpProvider = require('./web3/providers/httpprovider'); -var IpcProvider = require('./web3/providers/ipcprovider'); -var WebsocketProvider = require('./web3/providers/websocketprovider'); -var BigNumber = require('bignumber.js'); - - - -function Web3 (provider) { - this._requestManager = new RequestManager(provider); - this.currentProvider = provider; - this.eth = new Eth(this); - this.db = new DB(this); - this.shh = new Shh(this); - this.net = new Net(this); - this.personal = new Personal(this); - this.bzz = new Swarm(this); - this.settings = new Settings(); - this.version = { - api: version.version - }; - this.providers = { - HttpProvider: HttpProvider, - IpcProvider: IpcProvider, - WebsocketProvider: WebsocketProvider - }; - this._extend = extend(this); - this._extend({ - properties: properties() - }); -} - -// expose providers on the class -Web3.providers = { - HttpProvider: HttpProvider, - IpcProvider: IpcProvider, - WebsocketProvider: WebsocketProvider -}; - -Web3.prototype.setProvider = function (provider) { - this._requestManager.setProvider(provider); - this.currentProvider = provider; -}; - -Web3.prototype.reset = function (keepIsSyncing) { - this._requestManager.reset(keepIsSyncing); - this.settings = new Settings(); -}; - -Web3.prototype.BigNumber = BigNumber; -Web3.prototype.toHex = utils.toHex; -Web3.prototype.toAscii = utils.toAscii; -Web3.prototype.toUtf8 = utils.toUtf8; -Web3.prototype.fromAscii = utils.fromAscii; -Web3.prototype.fromUtf8 = utils.fromUtf8; -Web3.prototype.toDecimal = utils.toDecimal; -Web3.prototype.fromDecimal = utils.fromDecimal; -Web3.prototype.toBigNumber = utils.toBigNumber; -Web3.prototype.toWei = utils.toWei; -Web3.prototype.fromWei = utils.fromWei; -Web3.prototype.isAddress = utils.isAddress; -Web3.prototype.isChecksumAddress = utils.isChecksumAddress; -Web3.prototype.toChecksumAddress = utils.toChecksumAddress; -Web3.prototype.isIBAN = utils.isIBAN; - - -Web3.prototype.sha3 = function(string, options) { - return '0x' + sha3(string, options); -}; - -/** - * Transforms direct icap to address - */ -Web3.prototype.fromICAP = function (icap) { - var iban = new Iban(icap); - return iban.address(); -}; - -var properties = function () { - return [ - new Property({ - name: 'version.node', - 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 - }) - ]; -}; - -Web3.prototype.isConnected = function(){ - return (this.currentProvider && this.currentProvider.isConnected()); -}; - -Web3.prototype.createBatch = function () { - return new Batch(this); -}; - -module.exports = Web3; - diff --git a/lib/web3/events.js b/lib/web3/events.js deleted file mode 100644 index 6ca9bff..0000000 --- a/lib/web3/events.js +++ /dev/null @@ -1,315 +0,0 @@ -/* - This file is part of web3.js. - - web3.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. - - web3.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 web3.js. If not, see . -*/ -/** - * @file event.js - * @author Marek Kotewicz - * @author Fabian Vogelsteller - * @date 2016 - */ - -var utils = require('../utils/utils'); -var coder = require('../solidity/coder'); -var formatters = require('./formatters'); -var sha3 = require('../utils/sha3'); -var Subscription = require('./subscription'); - -/** - * This prototype should be used to create event filters - */ -var ContractEvent = function (requestManager, json, address, allEvents) { - this._requestManager = requestManager; - this._address = address; - this._json = json; - this._name = json.inputs ? utils.transformToFullName(json) : null; - this._params = json.inputs; - this._anonymous = json.anonymous; - this._allEvents = !!allEvents; -}; - -/** - * Should be used to get filtered param types - * - * @method types - * @param {Bool} decide if returned typed should be indexed - * @param {Object} params the parameters of the event - * @return {Array} array of types - */ -ContractEvent.prototype.types = function (indexed, params) { - return params.filter(function (i) { - return i.indexed === indexed; - }).map(function (i) { - return i.type; - }); -}; - -/** - * Should be used to get event display name - * - * @method displayName - * @param {String} name (optional) the events name - * @return {String} event display name - */ -ContractEvent.prototype.displayName = function (name) { - return utils.extractDisplayName(name || this._name); -}; - -/** - * Should be used to get event type name - * - * @method typeName - * @return {String} event type name - */ -ContractEvent.prototype.typeName = function () { - return utils.extractTypeName(this._name); -}; - -/** - * Should be used to get event signature - * - * @method signature - * @return {String} event signature - */ -ContractEvent.prototype.signature = function () { - return sha3(this._name); -}; - -/** - * Should be used to encode indexed params and options to one final object - * - * @method encode - * @param {Object} options - * @return {Object} everything combined together and encoded - */ -ContractEvent.prototype.encode = function (options) { - options = options || {}; - var indexed = options.filter || {}, - result = {}; - - - ['fromBlock', 'toBlock'].filter(function (f) { - return options[f] !== undefined; - }).forEach(function (f) { - result[f] = formatters.inputBlockNumberFormatter(options[f]); - }); - - result.topics = []; - - // single events - if(!this._allEvents) { - - if (!this._anonymous) { - 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); - } - - result.address = this._address; - - 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 - */ -ContractEvent.prototype.decode = function (data) { - var name = null, - params = null, - anonymous = null; - data.data = data.data || ''; - data.topics = data.topics || []; - - // all events - if(this._allEvents) { - - var eventTopic = data.topics[0].slice(2); - var match = this._json.filter(function (j) { - return eventTopic === sha3(utils.transformToFullName(j)); - })[0]; - - if (!match) { // cannot find matching event? - console.warn('Can\'t find event for log'); - return data; - } - - name = utils.transformToFullName(match); - params = match.inputs; - anonymous = match.anonymous; - - // single event - } else { - name = this._name; - params = this._params; - anonymous = this._anonymous; - } - - var argTopics = 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, params), indexedData); - - var notIndexedData = data.data.slice(2); - var notIndexedParams = coder.decodeParams(this.types(false, params), notIndexedData); - - var result = formatters.outputLogFormatter(data); - result.event = this.displayName(name); - result.address = data.address; - - result.returnValues = params.reduce(function (acc, current) { - acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift(); - return acc; - }, {}); - - delete result.data; - delete result.topics; - - return result; -}; - -/** - * Get the arguments of the function call - * - * @method getArgs - * @param {Object} options - * @param {Function} callback - * @return {Object} filter object - */ -ContractEvent.prototype.getArgs = function (options, callback) { - if (utils.isFunction(arguments[arguments.length - 1])) { - callback = arguments[arguments.length - 1]; - - if(arguments.length === 1) { - options = null; - } - } - - return { - options: this.encode(options), - formatter: this.decode.bind(this), - callback: callback - }; -}; - -/** - * Should be used to create new filter object from event - * - * @method execute - * @param {Object} options - * @param {Function} callback - * @return {Object} filter object - */ -ContractEvent.prototype.execute = function () { - - var args = this.getArgs.apply(this, arguments); - var subscription = new Subscription({ - subscription: { - params: 1, - inputFormatter: [formatters.inputLogFormatter], - outputFormatter: args.formatter - }, - subscribeMethod: 'eth_subscribe', - unsubscribeMethod: 'eth_unsubscribe', - requestManager: this._requestManager - }); - - return subscription.subscribe.apply(subscription, ['logs', args.options, args.callback]); -}; - -// TODO: put indexed args into the options object - -/** - * Get past logs for this event - * - * @method getPastEvents - * @param {Object} options - * @param {Function} callback - * @param {Contract} - */ -ContractEvent.prototype.getPastEvents = function(){ - - var args = this.getArgs.apply(this, arguments); - - // TODO remove send sync and return promise - - if (utils.isFunction(args.callback)) { - return this._requestManager.send({ - method: 'eth_getLogs', - params: [args.options] - }, function(error, logs){ - if(!error) { - args.callback(null, logs.map(args.formatter)); - } else { - args.callback(error); - } - }); - } - - return this._requestManager.sendSync({ - method: 'eth_getLogs', - params: [args.options] - }).map(args.formatter); -}; - -/** - * Should be used to attach event to contract object - * - * @method attachToContract - * @param {Contract} - */ -ContractEvent.prototype.attachToContract = function (contract) { - var execute = this.execute.bind(this); - - // attach past logs - execute.getPastEvents = this.getPastEvents.bind(this); - - // all events - if(this._allEvents) { - contract.allEvents = execute; - - // single event - } else { - - var displayName = this.displayName(); - if (!contract[displayName]) { - contract[displayName] = execute; - } - contract[displayName][this.typeName()] = this.execute.bind(this, contract); - } - -}; - -module.exports = ContractEvent; - diff --git a/lib/web3/extend.js b/lib/web3/extend.js deleted file mode 100644 index 55ad7dc..0000000 --- a/lib/web3/extend.js +++ /dev/null @@ -1,48 +0,0 @@ -var formatters = require('./formatters'); -var utils = require('./../utils/utils'); -var Method = require('./method'); -var Property = require('./property'); - -// TODO: refactor, so the input params are not altered. -// it's necessary to make same 'extension' work with multiple providers -var extend = function (web3) { - /* jshint maxcomplexity:5 */ - var ex = function (extension) { - - var extendedObject; - if (extension.property) { - if (!web3[extension.property]) { - web3[extension.property] = {}; - } - extendedObject = web3[extension.property]; - } else { - extendedObject = web3; - } - - if (extension.methods) { - extension.methods.forEach(function (method) { - method.attachToObject(extendedObject); - method.setRequestManager(web3._requestManager); - }); - } - - if (extension.properties) { - extension.properties.forEach(function (property) { - property.attachToObject(extendedObject); - property.setRequestManager(web3._requestManager); - }); - } - }; - - ex.formatters = formatters; - ex.utils = utils; - ex.Method = Method; - ex.Property = Property; - - return ex; -}; - - - -module.exports = extend; - diff --git a/lib/web3/filter.js b/lib/web3/filter.js deleted file mode 100644 index 0eb41be..0000000 --- a/lib/web3/filter.js +++ /dev/null @@ -1,235 +0,0 @@ -/* - This file is part of web3.js. - - web3.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. - - web3.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 web3.js. If not, see . -*/ -/** @file filter.js - * @authors: - * Jeffrey Wilcke - * Marek Kotewicz - * Marian Oancea - * Fabian Vogelsteller - * Gav Wood - * @date 2014 - */ - -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.fromUtf8(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); - }); - - return { - topics: options.topics, - from: options.from, - to: options.to, - address: options.address, - fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock), - toBlock: formatters.inputBlockNumberFormatter(options.toBlock) - }; -}; - -/** -Adds the callback and sets up the methods, to iterate over the results. - -@method getLogsAtStart -@param {Object} self -@param {funciton} -*/ -var getLogsAtStart = function(self, callback){ - // call getFilterLogs for the first watch callback start - if (!utils.isString(self.options)) { - self.get(function (err, messages) { - // don't send all the responses to all the watches again... just to self one - if (err) { - callback(err); - } - - if(utils.isArray(messages)) { - messages.forEach(function (message) { - callback(null, message); - }); - } - }); - } -}; - -/** -Adds the callback and sets up the methods, to iterate over the results. - -@method pollFilter -@param {Object} self -*/ -var pollFilter = function(self) { - - var onMessage = function (error, messages) { - if (error) { - return self.callbacks.forEach(function (callback) { - callback(error); - }); - } - - if(utils.isArray(messages)) { - messages.forEach(function (message) { - message = self.formatter ? self.formatter(message) : message; - self.callbacks.forEach(function (callback) { - callback(null, message); - }); - }); - } - }; - - self.requestManager.startPolling({ - method: self.implementation.poll.call, - params: [self.filterId], - }, self.filterId, onMessage, self.stopWatching.bind(self)); - -}; - -var Filter = function (requestManager, options, methods, formatter, callback, filterCreationErrorCallback) { - var self = this; - var implementation = {}; - methods.forEach(function (method) { - method.setRequestManager(requestManager); - method.attachToObject(implementation); - }); - this.requestManager = requestManager; - this.options = getOptions(options); - this.implementation = implementation; - this.filterId = null; - this.callbacks = []; - this.getLogsCallbacks = []; - this.pollFilters = []; - this.formatter = formatter; - this.implementation.newFilter(this.options, function(error, id){ - if(error) { - self.callbacks.forEach(function(cb){ - cb(error); - }); - filterCreationErrorCallback(error); - } else { - self.filterId = id; - - // check if there are get pending callbacks as a consequence - // of calling get() with filterId unassigned. - self.getLogsCallbacks.forEach(function (cb){ - self.get(cb); - }); - self.getLogsCallbacks = []; - - // get filter logs for the already existing watch calls - self.callbacks.forEach(function(cb){ - getLogsAtStart(self, cb); - }); - if(self.callbacks.length > 0) - pollFilter(self); - - // start to watch immediately - if(typeof callback === 'function') { - return self.watch(callback); - } - } - }); - - return this; -}; - -Filter.prototype.watch = function (callback) { - this.callbacks.push(callback); - - if(this.filterId) { - getLogsAtStart(this, callback); - pollFilter(this); - } - - return this; -}; - -Filter.prototype.stopWatching = function (callback) { - this.requestManager.stopPolling(this.filterId); - this.callbacks = []; - // remove filter async - if (callback) { - this.implementation.uninstallFilter(this.filterId, callback); - } else { - return this.implementation.uninstallFilter(this.filterId); - } -}; - -Filter.prototype.get = function (callback) { - var self = this; - if (utils.isFunction(callback)) { - if (this.filterId === null) { - // If filterId is not set yet, call it back - // when newFilter() assigns it. - this.getLogsCallbacks.push(callback); - } else { - 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 { - if (this.filterId === null) { - throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.'); - } - var logs = this.implementation.getLogs(this.filterId); - return logs.map(function (log) { - return self.formatter ? self.formatter(log) : log; - }); - } - - return this; -}; - -module.exports = Filter; - diff --git a/lib/web3/method.js b/lib/web3/method.js deleted file mode 100644 index 09f1de8..0000000 --- a/lib/web3/method.js +++ /dev/null @@ -1,199 +0,0 @@ -/* - This file is part of web3.js. - - web3.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. - - web3.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 web3.js. If not, see . -*/ -/** - * @file method.js - * @author Marek Kotewicz - * @date 2015 - */ - -var utils = require('../utils/utils'); -var errors = require('./errors'); -var Promise = require("bluebird"); -// var eventifiedPromise = require('./eventifiedPromise.js'); - -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; - // this.parent = parent; - this.requestManager = null; -}; - -Method.prototype.setRequestManager = function (rm) { - this.requestManager = rm; -}; - -/** - * 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) { - var _this = this; - - if(utils.isArray(result)) { - return result.map(function(res){ - return _this.outputFormatter && res ? _this.outputFormatter(res) : res; - }); - } else { - return this.outputFormatter && result ? this.outputFormatter(result) : result; - } -}; - -/** - * 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 - }; -}; - -Method.prototype.attachToObject = function (obj) { - var func = this.buildCall(); - func.call = this.call; // TODO!!! 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; - } -}; - -Method.prototype.buildCall = function() { - var method = this; - var send = function () { - var resolve, reject, - promise = new Promise(function() { - resolve = arguments[0]; - reject = arguments[1]; - }),//eventifiedPromise(), - payload = method.toPayload(Array.prototype.slice.call(arguments)); - - - method.requestManager.send(payload, function (err, result) { - result = method.formatOutput(result); - - // TODO? if afterProcess is available - // if(method.afterProcessor) - // method.afterProcessor(defer, err, result); - - // TODO send transaction uses PromiEvent - - if(!err) { - if(payload.callback) { - payload.callback(null, result); - } - // defer.promise.emit('data', result); - resolve(result); - //defer.promise.removeAllListeners(); - } else { - return utils._fireError(err, null, reject, payload.callback); - } - }); - - return promise; - }; - send.request = this.request.bind(this); - return send; -}; - -/** - * 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; -}; - -module.exports = Method; - diff --git a/lib/web3/methods/db.js b/lib/web3/methods/db.js deleted file mode 100644 index 4b63960..0000000 --- a/lib/web3/methods/db.js +++ /dev/null @@ -1,66 +0,0 @@ -/* - This file is part of web3.js. - - web3.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. - - web3.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 web3.js. If not, see . -*/ -/** @file db.js - * @authors: - * Marek Kotewicz - * @date 2015 - */ - -var Method = require('../method'); - -var DB = function (web3) { - this._requestManager = web3._requestManager; - - var self = this; - - methods().forEach(function(method) { - method.attachToObject(self); - method.setRequestManager(web3._requestManager); - }); -}; - -var methods = function () { - 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 - }); - - return [ - putString, getString, putHex, getHex - ]; -}; - -module.exports = DB; diff --git a/lib/web3/methods/net.js b/lib/web3/methods/net.js deleted file mode 100644 index 0fdb852..0000000 --- a/lib/web3/methods/net.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - This file is part of web3.js. - - web3.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. - - web3.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 web3.js. If not, see . -*/ -/** @file eth.js - * @authors: - * Marek Kotewicz - * @date 2015 - */ - -var utils = require('../../utils/utils'); -var Property = require('../property'); - -var Net = function (web3) { - this._requestManager = web3._requestManager; - - var self = this; - - properties().forEach(function(p) { - p.attachToObject(self); - p.setRequestManager(web3._requestManager); - }); -}; - -/// @returns an array of objects describing web3.eth api properties -var properties = function () { - return [ - new Property({ - name: 'listening', - getter: 'net_listening' - }), - new Property({ - name: 'peerCount', - getter: 'net_peerCount', - outputFormatter: utils.toDecimal - }) - ]; -}; - -module.exports = Net; diff --git a/lib/web3/property.js b/lib/web3/property.js deleted file mode 100644 index f7ddb20..0000000 --- a/lib/web3/property.js +++ /dev/null @@ -1,144 +0,0 @@ -/* - This file is part of web3.js. - - web3.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. - - web3.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 web3.js. If not, see . -*/ -/** - * @file property.js - * @author Fabian Vogelsteller - * @author Marek Kotewicz - * @date 2015 - */ - -var utils = require('../utils/utils'); - -var Property = function (options) { - this.name = options.name; - this.getter = options.getter; - this.setter = options.setter; - this.outputFormatter = options.outputFormatter; - this.inputFormatter = options.inputFormatter; - this.requestManager = null; -}; - -Property.prototype.setRequestManager = function (rm) { - this.requestManager = rm; -}; - -/** - * 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 && result !== undefined ? this.outputFormatter(result) : result; -}; - -/** - * Should be used to extract callback from array of arguments. Modifies input param - * - * @method extractCallback - * @param {Array} arguments - * @return {Function|Null} callback, if exists - */ -Property.prototype.extractCallback = function (args) { - if (utils.isFunction(args[args.length - 1])) { - return args.pop(); // modify the args array! - } -}; - - -/** - * Should attach function to method - * - * @method attachToObject - * @param {Object} - * @param {Function} - */ -Property.prototype.attachToObject = function (obj) { - var proto = { - get: this.buildGet(), - enumerable: true - }; - - 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); - obj[asyncGetterName(name)] = this.buildAsyncGet(); -}; - -var asyncGetterName = function (name) { - return 'get' + name.charAt(0).toUpperCase() + name.slice(1); -}; - -Property.prototype.buildGet = function () { - var property = this; - return function get() { - return property.formatOutput(property.requestManager.sendSync({ - method: property.getter - })); - }; -}; - -Property.prototype.buildAsyncGet = function () { - var property = this; - var get = function (callback) { - property.requestManager.send({ - method: property.getter - }, function (err, result) { - callback(err, property.formatOutput(result)); - }); - }; - get.request = this.request.bind(this); - return get; -}; - -/** - * Should be called to create pure JSONRPC request which can be used in batch request - * - * @method request - * @param {...} params - * @return {Object} jsonrpc request - */ -Property.prototype.request = function () { - var payload = { - method: this.getter, - params: [], - callback: this.extractCallback(Array.prototype.slice.call(arguments)) - }; - payload.format = this.formatOutput.bind(this); - return payload; -}; - -module.exports = Property; - diff --git a/lib/web3/settings.js b/lib/web3/settings.js deleted file mode 100644 index 4999235..0000000 --- a/lib/web3/settings.js +++ /dev/null @@ -1,9 +0,0 @@ - - -var Settings = function () { - this.defaultBlock = 'latest'; - this.defaultAccount = undefined; -}; - -module.exports = Settings; - diff --git a/lib/web3/transfer.js b/lib/web3/transfer.js deleted file mode 100644 index 6a0d081..0000000 --- a/lib/web3/transfer.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - This file is part of web3.js. - - web3.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. - - web3.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 web3.js. If not, see . -*/ -/** - * @file transfer.js - * @author Marek Kotewicz - * @date 2015 - */ - -var Iban = require('./iban'); -var exchangeAbi = require('../contracts/SmartExchange.json'); - -/** - * Should be used to make Iban transfer - * - * @method transfer - * @param {String} from - * @param {String} to iban - * @param {Value} value to be tranfered - * @param {Function} callback, callback - */ -var transfer = function (eth, from, to, value, callback) { - var iban = new Iban(to); - if (!iban.isValid()) { - throw new Error('invalid iban address'); - } - - if (iban.isDirect()) { - return transferToAddress(eth, from, iban.address(), value, callback); - } - - if (!callback) { - var address = eth.icapNamereg().addr(iban.institution()); - return deposit(eth, from, address, value, iban.client()); - } - - eth.icapNamereg().addr(iban.institution(), function (err, address) { - return deposit(eth, from, address, value, iban.client(), callback); - }); - -}; - -/** - * Should be used to transfer funds to certain address - * - * @method transferToAddress - * @param {String} from - * @param {String} to - * @param {Value} value to be tranfered - * @param {Function} callback, callback - */ -var transferToAddress = function (eth, from, to, value, callback) { - return eth.sendTransaction({ - address: to, - from: from, - value: value - }, callback); -}; - -/** - * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!) - * - * @method deposit - * @param {String} from - * @param {String} to - * @param {Value} value to be transfered - * @param {String} client unique identifier - * @param {Function} callback, callback - */ -var deposit = function (eth, from, to, value, client, callback) { - var abi = exchangeAbi; - return eth.contract(abi).at(to).deposit(client, { - from: from, - value: value - }, callback); -}; - -module.exports = transfer; - diff --git a/package.json b/package.json index 8c783f3..7a6653d 100644 --- a/package.json +++ b/package.json @@ -1,93 +1,87 @@ { - "name": "web3", - "namespace": "ethereum", - "version": "1.0.0", - "description": "Ethereum JavaScript API, middleware to talk to a ethereum node over RPC", - "license": "LGPL-3.0", - "main": "./index.js", - "directories": { - "lib": "./lib" - }, - "browser": { - "xmlhttprequest": "./lib/utils/browser-xhr.js" - }, - "dependencies": { - "bignumber.js": "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2", - "bluebird": "^3.3.1", - "crypto-js": "^3.1.4", - "eventemitter3": "^1.1.1", - "global": "^4.3.1", - "lodash": "^4.17.4", - "utf8": "^2.1.1", - "websocket": "^1.0.23", - "xhr2": "*", - "xmlhttprequest": "*" - }, - "devDependencies": { - "bower": ">=1.4.1", - "browserify": ">=10.0", - "chai": "^3.0.0", - "coveralls": "^2.11.2", - "del": ">=2.0.2", - "exorcist": "^0.4.0", - "gulp": ">=3.9.0", - "gulp-jshint": ">=1.5.0", - "gulp-rename": ">=1.2.0", - "gulp-replace": "^0.5.3", - "gulp-streamify": "0.0.5", - "gulp-uglify": ">=1.2.0", - "istanbul": "^0.4.4", - "jshint": ">=2.5.0", - "mocha": ">=2.3.3", - "sandboxed-module": "^2.0.2", - "vinyl-source-stream": "^1.1.0" - }, - "scripts": { - "build": "gulp", - "watch": "gulp watch", - "lint": "jshint *.js lib", - "test": "mocha; jshint *.js lib", - "test-coveralls": "istanbul cover _mocha -- -R spec && cat coverage/lcov.info | coveralls --verbose" - }, - "repository": { - "type": "git", - "url": "https://github.com/ethereum/web3.js.git" - }, - "homepage": "https://github.com/ethereum/web3.js", - "bugs": { - "url": "https://github.com/ethereum/web3.js/issues" - }, - "keywords": [ - "ethereum", - "javascript", - "API" - ], - "author": "ethdev.com", - "authors": [ - { - "name": "Fabian Vogelsteller", - "email": "fabian@ethereum.org", - "homepage": "http://frozeman.de" + "name": "web3", + "namespace": "ethereum", + "version": "1.0.0", + "description": "Ethereum JavaScript API, middleware to talk to a ethereum node over RPC", + "license": "LGPL-3.0", + "main": "./src/index.js", + "directories": { + "src": "./src", + "doc": "./doc" }, - { - "name": "Marek Kotewicz", - "email": "marek@ethcore.io", - "url": "https://github.com/debris" + "dependencies": { + }, - { - "name": "Marian Oancea", - "email": "marian@ethereum.org", - "url": "https://github.com/cubedro" + "devDependencies": { + "bower": ">=1.4.1", + "browserify": ">=10.0", + "chai": "^3.0.0", + "coveralls": "^2.11.2", + "del": ">=2.0.2", + "exorcist": "^0.4.0", + "gulp": ">=3.9.0", + "gulp-jshint": ">=1.5.0", + "gulp-rename": ">=1.2.0", + "gulp-replace": "^0.5.3", + "gulp-streamify": "0.0.5", + "gulp-uglify": ">=1.2.0", + "istanbul": "^0.4.4", + "jshint": ">=2.5.0", + "mocha": ">=2.3.3", + "sandboxed-module": "^2.0.2", + "vinyl-source-stream": "^1.1.0", + "lerna": "2.0.0-beta.32", + "crypto-js": "^3.1.4", + "underscore": "^1.8.3", + "bignumber.js": "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2" }, - { - "name": "Gav Wood", - "email": "g@ethcore.io", - "homepage": "http://gavwood.com" + "scripts": { + "postinstall": "lerna bootstrap", + "build": "gulp", + "watch": "gulp watch", + "lint": "jshint *.js packages", + "test": "mocha; jshint *.js packages", + "test-coveralls": "istanbul cover _mocha -- -R spec && cat coverage/lcov.info | coveralls --verbose" }, - { - "name": "Jeffery Wilcke", - "email": "jeffrey.wilcke@ethereum.org", - "url": "https://github.com/obscuren" - } - ] + "repository": { + "type": "git", + "url": "https://github.com/ethereum/web3.js.git" + }, + "homepage": "https://github.com/ethereum/web3.js", + "bugs": { + "url ": "https://github.com/ethereum/web3.js/issues" + }, + "keywords": [ + "Ethereum", + "JavaScript", + "API" + ], + "author": "ethereum.org", + "authors": [ + { + "name": "Fabian Vogelsteller", + "email": "fabian@ethereum.org", + "homepage": "http://frozeman.de" + }, + { + "name": "Marek Kotewicz", + "email": "marek@ethcore.io", + "url": "https://github.com/debris" + }, + { + "name": "Marian Oancea", + "email": "marian@ethereum.org", + "url": "https://github.com/cubedro" + }, + { + "name": "Gav Wood", + "email": "g@ethcore.io", + "homepage": "http://gavwood.com" + }, + { + "name": "Jeffery Wilcke", + "email": "jeffrey.wilcke@ethereum.org", + "url": "https://github.com/obscuren" + } + ] } diff --git a/packages/web3-bzz/package.json b/packages/web3-bzz/package.json new file mode 100644 index 0000000..3aa6036 --- /dev/null +++ b/packages/web3-bzz/package.json @@ -0,0 +1,12 @@ +{ + "name": "web3-bzz", + "version": "1.0.0", + "description": "Web3 module to interact with the Swarm network.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-bzz", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-core": "^1.0.0", + "web3-core-method": "^1.0.0" + } +} diff --git a/lib/web3/methods/swarm.js b/packages/web3-bzz/src/index.js similarity index 75% rename from lib/web3/methods/swarm.js rename to packages/web3-bzz/src/index.js index 31eaaaa..f2ab644 100644 --- a/lib/web3/methods/swarm.js +++ b/packages/web3-bzz/src/index.js @@ -15,34 +15,34 @@ along with web3.js. If not, see . */ /** - * @file bzz.js - * @author Alex Beregszaszi - * @date 2016 - * - * Reference: https://github.com/ethereum/go-ethereum/blob/swarm/internal/web3ext/web3ext.go#L33 + * @file index.js + * @author Fabian Vogelsteller + * @date 2017 */ "use strict"; -var Method = require('../method'); -var Property = require('../property'); +var core = require('web3-core'); +var Method = require('web3-core-method'); -function Swarm(web3) { - this._requestManager = web3._requestManager; - var self = this; +function Swarm() { + var _this = this; + + // sets _requestmanager + core.packageInit(this, arguments); + methods().forEach(function(method) { - method.attachToObject(self); - method.setRequestManager(self._requestManager); - }); - - properties().forEach(function(p) { - p.attachToObject(self); - p.setRequestManager(self._requestManager); + method.attachToObject(_this); + method.setRequestManager(_this._requestManager); }); } +core.addProviders(Swarm); + + + var methods = function () { var blockNetworkRead = new Method({ name: 'blockNetworkRead', @@ -114,6 +114,20 @@ var methods = function () { inputFormatter: [null, null, null, null] }); + var getHive = new Method({ + name: 'getHive', + call: 'bzz_hive', + params: 0, + inputFormatter: [] + }); + + var getInfo = new Method({ + name: 'getInfo', + call: 'bzz_info', + params: 0, + inputFormatter: [] + }); + return [ blockNetworkRead, syncEnabled, @@ -124,22 +138,12 @@ var methods = function () { store, get, put, - modify - ]; -}; - -var properties = function () { - return [ - new Property({ - name: 'hive', - getter: 'bzz_hive' - }), - new Property({ - name: 'info', - getter: 'bzz_info' - }) + modify, + getHive, + getInfo ]; }; module.exports = Swarm; + diff --git a/packages/web3-core-helpers/package.json b/packages/web3-core-helpers/package.json new file mode 100644 index 0000000..387f2fe --- /dev/null +++ b/packages/web3-core-helpers/package.json @@ -0,0 +1,12 @@ +{ + "name": "web3-core-helpers", + "version": "1.0.0", + "description": "Web3 core tools helper for sub packages. This is an internal package.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-core-helpers", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-utils": "^1.0.0", + "web3-core-iban": "^1.0.0" + } +} diff --git a/packages/web3-core-helpers/src/config.js b/packages/web3-core-helpers/src/config.js new file mode 100644 index 0000000..dd1e8ae --- /dev/null +++ b/packages/web3-core-helpers/src/config.js @@ -0,0 +1,64 @@ +/* + This file is part of web3.js. + + web3.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. + + web3.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 web3.js. If not, see . + */ +/** + * @file index.js + * @author Marek Kotewicz + * @date 2015 + */ + +// 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/2, + defaultBlock: 'latest', + defaultAccount: null +}; + diff --git a/lib/web3/errors.js b/packages/web3-core-helpers/src/errors.js similarity index 82% rename from lib/web3/errors.js rename to packages/web3-core-helpers/src/errors.js index 72a63a5..95c8a06 100644 --- a/lib/web3/errors.js +++ b/packages/web3-core-helpers/src/errors.js @@ -14,15 +14,16 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -/** +/** * @file errors.js - * @author Marek Kotewicz - * @date 2015 + * @author Fabian Vogelsteller + * @author Marek Kotewicz + * @date 2017 */ module.exports = { - InvalidNumberOfParams: function () { - return new Error('Invalid number of input parameters'); + InvalidNumberOfParams: function (got, expected, method) { + return new Error('Invalid number of parameters for "'+ method +'". Got '+ got +' expected '+ expected +'!'); }, InvalidConnection: function (host){ return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.'); diff --git a/lib/web3/formatters.js b/packages/web3-core-helpers/src/formatters.js similarity index 78% rename from lib/web3/formatters.js rename to packages/web3-core-helpers/src/formatters.js index 27e58c2..d5f4e27 100644 --- a/lib/web3/formatters.js +++ b/packages/web3-core-helpers/src/formatters.js @@ -16,15 +16,15 @@ */ /** * @file formatters.js - * @author Marek Kotewicz - * @author Fabian Vogelsteller - * @date 2015 + * @author Fabian Vogelsteller + * @author Marek Kotewicz + * @date 2017 */ -var utils = require('../utils/utils'); -var config = require('../utils/config'); -var Iban = require('./iban'); -var sha3 = require('../utils/sha3'); +var utils = require('web3-utils'); +var Iban = require('web3-core-iban'); + +var config = require('./config'); /** * Should the format output to a big number @@ -34,7 +34,7 @@ var sha3 = require('../utils/sha3'); * @returns {BigNumber} object */ var outputBigNumberFormatter = function (number) { - return utils.toBigNumber(number); + return utils.toBigNumber(number).toFixed(); }; var isPredefinedBlockNumber = function (blockNumber) { @@ -42,7 +42,7 @@ var isPredefinedBlockNumber = function (blockNumber) { }; var inputDefaultBlockNumberFormatter = function (blockNumber) { - if (!blockNumber) { + if (blockNumber === undefined || blockNumber === null) { return config.defaultBlock; } return inputBlockNumberFormatter(blockNumber); @@ -66,10 +66,10 @@ var inputBlockNumberFormatter = function (blockNumber) { */ var inputCallFormatter = function (options){ - options.from = options.from || config.defaultAccount; + var from = options.from || config.defaultAccount; - if (options.from) { - options.from = inputAddressFormatter(options.from); + if (from) { + options.from = inputAddressFormatter(from); } if (options.to) { // it might be contract creation @@ -128,8 +128,16 @@ var outputTransactionFormatter = function (tx){ 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); + tx.gasPrice = outputBigNumberFormatter(tx.gasPrice); + tx.value = outputBigNumberFormatter(tx.value); + + if(tx.to) { + tx.to = utils.toChecksumAddress(tx.to); + } + if(tx.from) { + tx.from = utils.toChecksumAddress(tx.from); + } + return tx; }; @@ -149,9 +157,11 @@ var outputTransactionReceiptFormatter = function (receipt){ receipt.gasUsed = utils.toDecimal(receipt.gasUsed); if(utils.isArray(receipt.logs)) { - receipt.logs = receipt.logs.map(function(log){ - return outputLogFormatter(log); - }); + receipt.logs = receipt.logs.map(outputLogFormatter); + } + + if(receipt.contractAddress) { + receipt.contractAddress = utils.toChecksumAddress(receipt.contractAddress); } return receipt; @@ -171,11 +181,11 @@ var outputBlockFormatter = function(block) { block.gasUsed = utils.toDecimal(block.gasUsed); block.size = utils.toDecimal(block.size); block.timestamp = utils.toDecimal(block.timestamp); - if(block.number !== null) + if (block.number !== null) block.number = utils.toDecimal(block.number); - block.difficulty = utils.toBigNumber(block.difficulty); - block.totalDifficulty = utils.toBigNumber(block.totalDifficulty); + block.difficulty = outputBigNumberFormatter(block.difficulty); + block.totalDifficulty = outputBigNumberFormatter(block.totalDifficulty); if (utils.isArray(block.transactions)) { block.transactions.forEach(function(item){ @@ -184,6 +194,9 @@ var outputBlockFormatter = function(block) { }); } + if (block.miner) + block.miner = utils.toChecksumAddress(block.miner); + return block; }; @@ -216,11 +229,8 @@ var inputLogFormatter = function(options) { toTopic = null; - if(options.address && !utils.isAddress(options.address)) - throw new Error('The given address is not valid!'); - - // if(options.address) - // options.address = options.address.toLowerCase(); + if(options.address) + options.address = inputAddressFormatter(options.address); return options; }; @@ -235,15 +245,25 @@ var inputLogFormatter = function(options) { var outputLogFormatter = function(log) { // generate a custom log id - log.id = 'log_'+ sha3(log.blockHash.replace('0x','') + log.transactionHash.replace('0x','') + log.logIndex.replace('0x','')).substr(0,8); + if(typeof log.blockHash === 'string' && + typeof log.transactionHash === 'string' && + typeof log.logIndex === 'string') { + var shaId = utils.sha3(log.blockHash.replace('0x','') + log.transactionHash.replace('0x','') + log.logIndex.replace('0x','')); + log.id = 'log_'+ shaId.replace('0x','').substr(0,8); + } else { + log.id = null; + } - if(log.blockNumber !== null) + if (log.blockNumber !== null) log.blockNumber = utils.toDecimal(log.blockNumber); - if(log.transactionIndex !== null) + if (log.transactionIndex !== null) log.transactionIndex = utils.toDecimal(log.transactionIndex); - if(log.logIndex !== null) + if (log.logIndex !== null) log.logIndex = utils.toDecimal(log.logIndex); + if (log.address) + log.address = utils.toChecksumAddress(log.address); + return log; }; @@ -257,9 +277,13 @@ var outputLogFormatter = function(log) { 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); + + if (post.ttl) + post.ttl = utils.fromDecimal(post.ttl); + if (post.workToProve) + post.workToProve = utils.fromDecimal(post.workToProve); + if (post.priority) + post.priority = utils.fromDecimal(post.priority); // fallback if (!utils.isArray(post.topics)) { @@ -300,7 +324,7 @@ var outputPostFormatter = function(post){ post.topics = []; } post.topics = post.topics.map(function(topic){ - return utils.toAscii(topic); + return utils.toUtf8(topic); }); return post; @@ -309,13 +333,11 @@ var outputPostFormatter = function(post){ var inputAddressFormatter = function (address) { var iban = new Iban(address); if (iban.isValid() && iban.isDirect()) { - return '0x' + iban.address(); - } else if (utils.isStrictAddress(address)) { - return address; + return iban.address().toLowerCase(); } else if (utils.isAddress(address)) { - return '0x' + address; + return '0x' + address.toLowerCase().replace('0x',''); } - throw new Error('invalid address'); + throw new Error('Provided address "'+ address +'" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can\'t be converted.'); }; diff --git a/lib/web3/namereg.js b/packages/web3-core-helpers/src/index.js similarity index 57% rename from lib/web3/namereg.js rename to packages/web3-core-helpers/src/index.js index d06ecbe..a26a0e0 100644 --- a/lib/web3/namereg.js +++ b/packages/web3-core-helpers/src/index.js @@ -14,26 +14,21 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -/** - * @file namereg.js - * @author Marek Kotewicz - * @date 2015 +/** + * @file index.js + * @author Fabian Vogelsteller + * @date 2017 */ -var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json'); -var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json'); +"use strict"; -var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b'; -var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00'; +var errors = require('./errors'); +var formatters = require('./formatters'); +var config = require('./config'); module.exports = { - global: { - abi: globalRegistrarAbi, - address: globalNameregAddress - }, - icap: { - abi: icapRegistrarAbi, - address: icapNameregAddress - } + errors: errors, + formatters: formatters, + config: config }; diff --git a/packages/web3-core-iban/package.json b/packages/web3-core-iban/package.json new file mode 100644 index 0000000..f4cc547 --- /dev/null +++ b/packages/web3-core-iban/package.json @@ -0,0 +1,12 @@ +{ + "name": "web3-core-iban", + "version": "1.0.0", + "description": "This package converts Ethereum addresses to IBAN adresses a vice versa.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-core-iban", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-utils": "^1.0.0", + "bignumber.js": "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2" + } +} diff --git a/lib/web3/iban.js b/packages/web3-core-iban/src/index.js similarity index 92% rename from lib/web3/iban.js rename to packages/web3-core-iban/src/index.js index bd22ed2..f5200ca 100644 --- a/lib/web3/iban.js +++ b/packages/web3-core-iban/src/index.js @@ -14,14 +14,20 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -/** +/** * @file iban.js - * @author Marek Kotewicz + * + * Details: https://github.com/ethereum/wiki/wiki/ICAP:-Inter-exchange-Client-Address-Protocol + * + * @author Marek Kotewicz * @date 2015 */ +var utils = require('web3-utils'); + var BigNumber = require('bignumber.js'); + var padLeft = function (string, bytes) { var result = string; while (result.length < bytes * 2) { @@ -92,6 +98,10 @@ var Iban = function (iban) { * @return {Iban} the IBAN object */ Iban.fromAddress = function (address) { + if(!utils.isAddress(address)){ + throw new Error('Provided address is not a valid address: '+ address); + } + var asBn = new BigNumber(address, 16); var base36 = asBn.toString(36); var padded = padLeft(base36, 15); @@ -128,7 +138,7 @@ Iban.createIndirect = function (options) { }; /** - * Thos method should be used to check if given string is valid iban object + * This method should be used to check if given string is valid iban object * * @method isValid * @param {String} iban string @@ -213,8 +223,8 @@ Iban.prototype.address = function () { if (this.isDirect()) { var base36 = this._iban.substr(4); var asBn = new BigNumber(base36, 36); - return padLeft(asBn.toString(16), 20); - } + return utils.toChecksumAddress(padLeft(asBn.toString(16), 20)); + } return ''; }; @@ -224,4 +234,3 @@ Iban.prototype.toString = function () { }; module.exports = Iban; - diff --git a/packages/web3-core-method/package.json b/packages/web3-core-method/package.json new file mode 100644 index 0000000..91e1a1c --- /dev/null +++ b/packages/web3-core-method/package.json @@ -0,0 +1,14 @@ +{ + "name": "web3-core-method", + "version": "1.0.0", + "description": "Creates the methods on the web3 modules. This is an internal package.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-core-method", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-core-helpers": "^1.0.0", + "web3-utils": "^1.0.0", + "web3-core-promiEvent": "^1.0.0", + "underscore": "^1.8.3" + } +} diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js new file mode 100644 index 0000000..b982e65 --- /dev/null +++ b/packages/web3-core-method/src/index.js @@ -0,0 +1,351 @@ +/* + This file is part of web3.js. + + web3.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. + + web3.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 web3.js. If not, see . +*/ +/** + * @file index.js + * @author Marek Kotewicz + * @author Fabian Vogelsteller + * @date 2017 + */ + +var _ = require('underscore'); +var errors = require('web3-core-helpers').errors; +var utils = require('web3-utils'); +var promiEvent = require('web3-core-promiEvent'); + +var TIMEOUTBLOCK = 50; +var CONFIRMATIONBLOCKS = 12; + +var Method = function (options) { + + if(!options.call || !options.name) { + throw new Error('When creating a method you need to provide at least the "name" and "call" property.'); + } + + this.name = options.name; + this.call = options.call; + this.params = options.params || 0; + this.inputFormatter = options.inputFormatter; + this.outputFormatter = options.outputFormatter; + this.requestManager = null; +}; + +Method.prototype.setRequestManager = function (rm, eth) { + this.requestManager = rm; + + if (eth) { + this.eth = eth; + } +}; + +/** + * 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(args.length, this.params, this.name); + } +}; + +/** + * 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) { + var _this = this; + + if(utils.isArray(result)) { + return result.map(function(res){ + return _this.outputFormatter && res ? _this.outputFormatter(res) : res; + }); + } else { + return this.outputFormatter && result ? this.outputFormatter(result) : result; + } +}; + +/** + * 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 + }; +}; + +Method.prototype.attachToObject = function (obj) { + var func = this.buildCall(); + func.call = this.call; // TODO!!! 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; + } +}; + +Method.prototype._confirmTransaction = function (defer, result, payload) { + var method = this, + promiseResolved = false, + canUnsubscribe = true, + timeoutCount = 0, + confirmationCount = 0, + isContractDeployment = _.isObject(payload.params[0]) && + payload.params[0].data && + payload.params[0].from && + !payload.params[0].to, + receiptError = new Error('Failed to check for transaction receipt.'); + + + // fire "receipt" and confirmation events and resolve after + method.eth.subscribe('newBlockHeaders', function (err, block, sub) { + if(!err) { + + method.eth.getTransactionReceipt(result) + // catch error from requesting receipt + .catch(function () { + sub.unsubscribe(); + promiseResolved = true; + utils._fireError(receiptError, defer.eventEmitter, defer.reject); + }) + // if CONFIRMATION listener exists check for confirmations + .then(function(receipt) { + + if (!receipt) { + throw new Error('Receipt is null'); + } + + if (defer.eventEmitter.listeners('confirmation').length > 0) { + + defer.eventEmitter.emit('confirmation', confirmationCount, receipt); + + canUnsubscribe = false; + confirmationCount++; + + if (confirmationCount === CONFIRMATIONBLOCKS + 1) { // add 1 so we account for conf 0 + sub.unsubscribe(); + defer.eventEmitter.removeAllListeners(); + } + } + + return receipt; + }) + // CHECK for CONTRACT DEPLOYMENT + .then(function(receipt) { + + if (isContractDeployment && !promiseResolved) { + + if (!receipt.contractAddress) { + promiseResolved = true; + utils._fireError(new Error('The transaction receipt didn\'t contain a contract address.'), defer.eventEmitter, defer.reject); + return; + } + + method.eth.getCode(receipt.contractAddress, function (e, code) { + + if (!code) { + return; + } + + + if (code.length > 2) { + defer.eventEmitter.emit('receipt', receipt); + defer.resolve(receipt); + + } else { + utils._fireError(new Error('The contract code couldn\'t be stored, please check your gas limit.'), defer.eventEmitter, defer.reject); + } + + if (canUnsubscribe) { + sub.unsubscribe(); + defer.eventEmitter.removeAllListeners(); + } + promiseResolved = true; + }); + } + + return receipt; + }) + // CHECK for normal tx check for receipt only + .then(function(receipt) { + + if (!isContractDeployment && !promiseResolved) { + + if(!receipt.outOfGas) { + defer.eventEmitter.emit('receipt', receipt); + defer.resolve(receipt); + + } else { + utils._fireError(new Error('Transaction ran out of gas.'), defer.eventEmitter, defer.reject); + } + + if (canUnsubscribe) { + sub.unsubscribe(); + defer.eventEmitter.removeAllListeners(); + } + promiseResolved = true; + } + + }) + // time out the transaction if not mined after 50 blocks + .catch(function () { + if (timeoutCount >= TIMEOUTBLOCK) { + sub.unsubscribe(); + promiseResolved = true; + utils._fireError(new Error('Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined!'), defer.eventEmitter, defer.reject); + } + + timeoutCount++; + }); + + + } else { + sub.unsubscribe(); + promiseResolved = true; + utils._fireError(receiptError, defer.eventEmitter, defer.reject); + } + }); +}; + +Method.prototype.buildCall = function() { + var method = this, + isSendTx = (method.call === 'eth_sendTransaction' || method.call === 'eth_sendRawTransaction'); + + + + // actual send function + var send = function () { + var defer = promiEvent(!isSendTx), + payload = method.toPayload(Array.prototype.slice.call(arguments)); + + + method.requestManager.send(payload, function (err, result) { + result = method.formatOutput(result); + + + if (!err) { + if (payload.callback) { + payload.callback(null, result); + } + } else { + if(err.error) { + err = err.error; + } + + utils._fireError(err, defer.eventEmitter, defer.reject, payload.callback); + return; + } + + // return PROMISE + if (!isSendTx) { + + if (!err) { + defer.resolve(result); + + } + + // return PROMIEVENT + } else if (method.eth) { + + defer.eventEmitter.emit('transactionHash', result); + + + method._confirmTransaction(defer, result, payload); + + + } + + }); + + return defer.eventEmitter; + }; + + send.request = this.request.bind(this); + return send; +}; + +/** + * Should be called to create the pure JSONRPC request which can be used in a batch request + * + * @method request + * @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; +}; + +module.exports = Method; diff --git a/packages/web3-core-promiEvent/package.json b/packages/web3-core-promiEvent/package.json new file mode 100644 index 0000000..2244268 --- /dev/null +++ b/packages/web3-core-promiEvent/package.json @@ -0,0 +1,12 @@ +{ + "name": "web3-core-promiEvent", + "version": "1.0.0", + "description": "This package extends eventEmitters with promises to allow chaining as well as multiple final states of a function.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-core-promiEvent", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "bluebird": "^3.3.1", + "eventemitter3": "^1.1.1" + } +} diff --git a/lib/web3/eventifiedPromise.js b/packages/web3-core-promiEvent/src/index.js similarity index 67% rename from lib/web3/eventifiedPromise.js rename to packages/web3-core-promiEvent/src/index.js index 7efb05e..f8234f7 100644 --- a/lib/web3/eventifiedPromise.js +++ b/packages/web3-core-promiEvent/src/index.js @@ -15,8 +15,8 @@ along with web3.js. If not, see . */ /** - * @file eventifiedPromise.js - * @author Fabian Vogelsteller + * @file index.js + * @author Fabian Vogelsteller * @date 2016 */ @@ -28,9 +28,9 @@ var Promise = require("bluebird"); * * @method eventifiedPromise */ -var eventifiedPromise = function(justPromise) { +var promiEvent = function(justPromise) { var resolve, reject, - promise = new Promise(function() { + eventEmitter = new Promise(function() { resolve = arguments[0]; reject = arguments[1]; }); @@ -39,7 +39,7 @@ var eventifiedPromise = function(justPromise) { return { resolve: resolve, reject: reject, - promise: promise + eventEmitter: eventEmitter }; } @@ -47,20 +47,20 @@ var eventifiedPromise = function(justPromise) { var emitter = new EventEmitter(); // add eventEmitter to the promise - promise.emit = emitter.emit; - promise.on = emitter.on; - promise.once = emitter.once; - promise.off = emitter.off; - promise.listeners = emitter.listeners; - promise.addListener = emitter.addListener; - promise.removeListener = emitter.removeListener; - promise.removeAllListeners = emitter.removeAllListeners; + eventEmitter.emit = emitter.emit; + eventEmitter.on = emitter.on; + eventEmitter.once = emitter.once; + eventEmitter.off = emitter.off; + eventEmitter.listeners = emitter.listeners; + eventEmitter.addListener = emitter.addListener; + eventEmitter.removeListener = emitter.removeListener; + eventEmitter.removeAllListeners = emitter.removeAllListeners; return { resolve: resolve, reject: reject, - promise: promise + eventEmitter: eventEmitter }; }; -module.exports = eventifiedPromise; +module.exports = promiEvent; diff --git a/packages/web3-core-requestManager/package.json b/packages/web3-core-requestManager/package.json new file mode 100644 index 0000000..7c9ab95 --- /dev/null +++ b/packages/web3-core-requestManager/package.json @@ -0,0 +1,17 @@ +{ + "name": "web3-requestManager", + "version": "1.0.0", + "description": "Web3 module to handle requests to external providers. Contains also the providers.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-requestManager", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-core-helpers": "^1.0.0", + "underscore": "^1.8.3", + "xmlhttprequest": "*", + "xhr2": "*" + }, + "browser": { + "xmlhttprequest": "./src/browser-xhr.js" + } +} diff --git a/lib/web3/batch.js b/packages/web3-core-requestManager/src/batch.js similarity index 96% rename from lib/web3/batch.js rename to packages/web3-core-requestManager/src/batch.js index 0c9dc98..dd8b61c 100644 --- a/lib/web3/batch.js +++ b/packages/web3-core-requestManager/src/batch.js @@ -14,14 +14,14 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -/** +/** * @file batch.js * @author Marek Kotewicz * @date 2015 */ var Jsonrpc = require('./jsonrpc'); -var errors = require('./errors'); +var errors = require('web3-core-helpers').errors; var Batch = function (web3) { this.requestManager = web3._requestManager; @@ -59,7 +59,7 @@ Batch.prototype.execute = function () { requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result)); } }); - }); + }); }; module.exports = Batch; diff --git a/lib/utils/browser-xhr.js b/packages/web3-core-requestManager/src/browser-xhr.js similarity index 100% rename from lib/utils/browser-xhr.js rename to packages/web3-core-requestManager/src/browser-xhr.js diff --git a/lib/web3/requestmanager.js b/packages/web3-core-requestManager/src/index.js similarity index 88% rename from lib/web3/requestmanager.js rename to packages/web3-core-requestManager/src/index.js index 87ad4fe..6c5a45f 100644 --- a/lib/web3/requestmanager.js +++ b/packages/web3-core-requestManager/src/index.js @@ -15,18 +15,28 @@ along with web3.js. If not, see . */ /** - * @file requestmanager.js - * @author Jeffrey Wilcke - * @author Marek Kotewicz - * @author Marian Oancea - * @author Fabian Vogelsteller - * @author Gav Wood - * @date 2014 + * @file index.js + * @author Fabian Vogelsteller + * @date 2017 */ +"use strict"; + + +var _ = require('underscore'); var Jsonrpc = require('./jsonrpc'); -var utils = require('../utils/utils'); -var errors = require('./errors'); +var errors = require('web3-core-helpers').errors; +var BatchManager = require('./batch'); + +var HttpProvider = require('./providers/httpprovider'); +var IpcProvider = require('./providers/ipcprovider'); +var WebsocketProvider = require('./providers/websocketprovider'); + +var providers = { + HttpProvider: HttpProvider, + IpcProvider: IpcProvider, + WebsocketProvider: WebsocketProvider +}; /** * It's responsible for passing messages to providers @@ -37,8 +47,13 @@ var errors = require('./errors'); var RequestManager = function (provider) { this.setProvider(provider); this.subscriptions = {}; + + this.providers = providers; }; +// expose providers +RequestManager.providers = providers; + /** * Should be used to synchronously send request * @@ -110,7 +125,7 @@ RequestManager.prototype.sendBatch = function (data, callback) { return callback(err); } - if (!utils.isArray(results)) { + if (!_.isArray(results)) { return callback(errors.InvalidResponse(results)); } @@ -216,4 +231,8 @@ RequestManager.prototype.reset = function (keepIsSyncing) { this.provider.reset(); }; -module.exports = RequestManager; +module.exports = { + Manager: RequestManager, + BatchManager: BatchManager +}; + diff --git a/lib/web3/jsonrpc.js b/packages/web3-core-requestManager/src/jsonrpc.js similarity index 94% rename from lib/web3/jsonrpc.js rename to packages/web3-core-requestManager/src/jsonrpc.js index 34d0c20..5d44a19 100644 --- a/lib/web3/jsonrpc.js +++ b/packages/web3-core-requestManager/src/jsonrpc.js @@ -36,8 +36,9 @@ var Jsonrpc = { * @returns {Object} valid jsonrpc payload object */ Jsonrpc.toPayload = function (method, params) { - if (!method) - console.error('jsonrpc method should be specified!'); + if (!method) { + throw new Error('JSONRPC method should be specified for params: "'+ JSON.stringify(params) +'"!'); + } // advance message ID Jsonrpc.messageId++; diff --git a/lib/web3/providers/httpprovider.js b/packages/web3-core-requestManager/src/providers/httpprovider.js similarity index 98% rename from lib/web3/providers/httpprovider.js rename to packages/web3-core-requestManager/src/providers/httpprovider.js index 5c5ae91..6778864 100644 --- a/lib/web3/providers/httpprovider.js +++ b/packages/web3-core-requestManager/src/providers/httpprovider.js @@ -23,7 +23,8 @@ */ -var errors = require('../errors'); +var errors = require('web3-core-helpers').errors; + // workaround to use httpprovider in different envs diff --git a/lib/web3/providers/ipcprovider.js b/packages/web3-core-requestManager/src/providers/ipcprovider.js similarity index 97% rename from lib/web3/providers/ipcprovider.js rename to packages/web3-core-requestManager/src/providers/ipcprovider.js index 565a3fe..d21ae63 100644 --- a/lib/web3/providers/ipcprovider.js +++ b/packages/web3-core-requestManager/src/providers/ipcprovider.js @@ -22,8 +22,8 @@ "use strict"; -var utils = require('../../utils/utils'); -var errors = require('../errors'); +var _ = require('underscore'); +var errors = require('web3-core-helpers').errors; var IpcProvider = function (path, net) { @@ -46,7 +46,7 @@ var IpcProvider = function (path, net) { var id = null; // get the id which matches the returned id - if(utils.isArray(result)) { + if(_.isArray(result)) { result.forEach(function(load){ if(_this.responseCallbacks[load.id]) id = load.id; @@ -58,7 +58,7 @@ var IpcProvider = function (path, net) { // notification if(!id && result.method === 'eth_subscription') { _this.notificationCallbacks.forEach(function(callback){ - if(utils.isFunction(callback)) + if(_.isFunction(callback)) callback(null, result); }); @@ -91,7 +91,7 @@ IpcProvider.prototype.addDefaultEvents = function(){ // inform notifications _this.notificationCallbacks.forEach(function (callback) { - if (utils.isFunction(callback)) + if (_.isFunction(callback)) callback(new Error('IPC socket connection closed')); }); }); diff --git a/lib/web3/providers/websocketprovider.js b/packages/web3-core-requestManager/src/providers/websocketprovider.js similarity index 97% rename from lib/web3/providers/websocketprovider.js rename to packages/web3-core-requestManager/src/providers/websocketprovider.js index 4c8c542..e665fe5 100644 --- a/lib/web3/providers/websocketprovider.js +++ b/packages/web3-core-requestManager/src/providers/websocketprovider.js @@ -22,8 +22,8 @@ "use strict"; -var utils = require('../../utils/utils'); -var errors = require('../errors'); +var _ = require('underscore'); +var errors = require('web3-core-helpers').errors; // var W3CWebSocket = require('websocket').w3cwebsocket; // Default connection ws://localhost:8546 @@ -49,7 +49,7 @@ var WebsocketProvider = function (path) { var id = null; // get the id which matches the returned id - if(utils.isArray(result)) { + if(_.isArray(result)) { result.forEach(function(load){ if(_this.responseCallbacks[load.id]) id = load.id; @@ -61,7 +61,7 @@ var WebsocketProvider = function (path) { // notification if(!id && result.method === 'eth_subscription') { _this.notificationCallbacks.forEach(function(callback){ - if(utils.isFunction(callback)) + if(_.isFunction(callback)) callback(null, result); }); @@ -96,7 +96,7 @@ WebsocketProvider.prototype.addDefaultEvents = function(){ // cancel subscriptions noteCb.forEach(function (callback) { - if (utils.isFunction(callback)) + if (_.isFunction(callback)) callback(e); }); }; diff --git a/packages/web3-core-subscriptions/package.json b/packages/web3-core-subscriptions/package.json new file mode 100644 index 0000000..43e04e8 --- /dev/null +++ b/packages/web3-core-subscriptions/package.json @@ -0,0 +1,13 @@ +{ + "name": "web3-core-subscriptions", + "version": "1.0.0", + "description": "Manages web3 subscriptions. This is an internal package.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-core-subscriptions", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-core-helpers": "^1.0.0", + "underscore": "^1.8.3", + "eventemitter3": "^1.1.1" + } +} diff --git a/lib/web3/subscriptions.js b/packages/web3-core-subscriptions/src/index.js similarity index 84% rename from lib/web3/subscriptions.js rename to packages/web3-core-subscriptions/src/index.js index 4c31d3d..f737e14 100644 --- a/lib/web3/subscriptions.js +++ b/packages/web3-core-subscriptions/src/index.js @@ -14,11 +14,10 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -/** @file subscriptions.js - * - * @authors: - * Fabian Vogelsteller - * @date 2016 +/** + * @file index.js + * @author Fabian Vogelsteller + * @date 2017 */ var Subscription = require('./subscription.js'); @@ -55,6 +54,10 @@ Subscriptions.prototype.buildCall = function() { var _this = this; return function(){ + if(!_this.subscriptions[arguments[0]]) { + console.warn('Subscription "'+ JSON.stringify(arguments[0]) +'" doesn\'t exist. Subscribing anyway.'); + } + var subscription = new Subscription({ subscription: _this.subscriptions[arguments[0]], subscribeMethod: _this.subscribe, @@ -66,4 +69,8 @@ Subscriptions.prototype.buildCall = function() { }; }; -module.exports = Subscriptions; + +module.exports = { + subscriptions: Subscriptions, + subscription: Subscription +}; diff --git a/lib/web3/subscription.js b/packages/web3-core-subscriptions/src/subscription.js similarity index 90% rename from lib/web3/subscription.js rename to packages/web3-core-subscriptions/src/subscription.js index 2c91793..657a40e 100644 --- a/lib/web3/subscription.js +++ b/packages/web3-core-subscriptions/src/subscription.js @@ -14,15 +14,14 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -/** @file subscription.js - * - * @authors: - * Fabian Vogelsteller - * @date 2016 +/** + * @file subscription.js + * @author Fabian Vogelsteller + * @date 2017 */ -var utils = require('../utils/utils'); -var errors = require('./errors'); +var _ = require('underscore'); +var errors = require('web3-core-helpers').errors; var EventEmitter = require('eventemitter3'); @@ -64,7 +63,7 @@ var Subscription = function (options) { */ Subscription.prototype._extractCallback = function (args) { - if (utils.isFunction(args[args.length - 1])) { + if (_.isFunction(args[args.length - 1])) { return args.pop(); // modify the args array! } }; @@ -87,7 +86,7 @@ Subscription.prototype._validateArgs = function (args) { subscription.params = 0; if (args.length !== subscription.params + 1) { - throw errors.InvalidNumberOfParams(); + throw errors.InvalidNumberOfParams(args.length, subscription.params + 1, args[0]); } }; @@ -102,7 +101,16 @@ Subscription.prototype._validateArgs = function (args) { Subscription.prototype._formatInput = function (args) { var subscription = this.options.subscription; - if (!subscription || !subscription.inputFormatter) { + if (!subscription) { + return args; + } + + // replace subscription with given name + if (subscription.subscriptionName) { + args[0] = subscription.subscriptionName; + } + + if (!subscription.inputFormatter) { return args; } @@ -180,7 +188,7 @@ Subscription.prototype.subscribe = function() { this.options.params = payload.params[1]; // get past logs, if fromBlock is available - if(payload.params[0] === 'logs' && utils.isObject(payload.params[1]) && payload.params[1].hasOwnProperty('fromBlock') && isFinite(payload.params[1].fromBlock)) { + if(payload.params[0] === 'logs' && _.isObject(payload.params[1]) && payload.params[1].hasOwnProperty('fromBlock') && isFinite(payload.params[1].fromBlock)) { // send the subscription request this.options.requestManager.send({ method: 'eth_getLogs', @@ -213,12 +221,13 @@ Subscription.prototype.subscribe = function() { _this.options.requestManager.addSubscription(_this.id, payload.params[0] ,'eth', function(err, result) { // TODO remove once its fixed in geth - if(utils.isArray(result)) + if(_.isArray(result)) result = result[0]; var output = _this._formatOutput(result); if (!err) { + // TODO remove eventEmitter?? if(output.removed) _this.emit('changed', output); else diff --git a/packages/web3-core/package.json b/packages/web3-core/package.json new file mode 100644 index 0000000..890b037 --- /dev/null +++ b/packages/web3-core/package.json @@ -0,0 +1,14 @@ +{ + "name": "web3-core", + "version": "1.0.0", + "description": "Web3 core tools for sub packages. This is an internal package.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-core", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-core-helpers": "^1.0.0", + "web3-core-method": "^1.0.0", + "web3-utils": "^1.0.0", + "web3-requestManager": "^1.0.0" + } +} diff --git a/packages/web3-core/src/extend.js b/packages/web3-core/src/extend.js new file mode 100644 index 0000000..dbc06c8 --- /dev/null +++ b/packages/web3-core/src/extend.js @@ -0,0 +1,65 @@ +/* + This file is part of web3.js. + + web3.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. + + web3.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 web3.js. If not, see . + */ +/** + * @file extend.js + * @author Fabian Vogelsteller + * @date 2017 + */ + +var formatters = require('web3-core-helpers').formatters; +var Method = require('web3-core-method'); +var utils = require('web3-utils'); + + +var extend = function (pckg) { + /* jshint maxcomplexity:5 */ + var ex = function (extension) { + + var extendedObject; + if (extension.property) { + if (!pckg[extension.property]) { + pckg[extension.property] = {}; + } + extendedObject = pckg[extension.property]; + } else { + extendedObject = pckg; + } + + if (extension.methods) { + extension.methods.forEach(function (method) { + if(!(method instanceof Method)) { + method = new Method(method); + } + + method.attachToObject(extendedObject); + method.setRequestManager(pckg._requestManager); + }); + } + + }; + + ex.formatters = formatters; + ex.utils = utils; + ex.Method = Method; + + return ex; +}; + + + +module.exports = extend; + diff --git a/packages/web3-core/src/index.js b/packages/web3-core/src/index.js new file mode 100644 index 0000000..07bb659 --- /dev/null +++ b/packages/web3-core/src/index.js @@ -0,0 +1,89 @@ +/* + This file is part of web3.js. + + web3.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. + + web3.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 web3.js. If not, see . +*/ +/** + * @file index.js + * @author Fabian Vogelsteller + * @date 2017 + */ + + +var requestManager = require('web3-requestManager'); +var extend = require('./extend.js'); + +module.exports = { + packageInit: function (pkg, args) { + args = Array.prototype.slice.call(args); + + if (!pkg) { + throw new Error('You need to instantiate using the "new" keyword.'); + } + + // if (!args[0]) { + // throw new Error('You must pass in a provider as argument!'); + // } + + // make write only property of pkg.provider + Object.defineProperty(pkg, 'currentProvider', { + get: function () { + return pkg._provider; + }, + set: function () { + return pkg._provider; + }, + enumerable: true + }); + + // inherit from web3 umbrella package + if (args[0] && args[0]._requestManager) { + pkg._requestManager = args[0]._requestManager; + pkg._provider = args[0].provider; + + // set requestmanager on package + } else { + pkg._requestManager = new requestManager.Manager(args[0]); + pkg._provider = args[0]; + } + + // add providers + pkg.providers = requestManager.Manager.providers; + + // add set Provider function + pkg.setProvider = function (provider) { + pkg._requestManager.setProvider(provider); + pkg._provider = provider; + return true; + }; + + // add reset function + pkg.reset = function (keepIsSyncing) { + pkg._requestManager.reset(keepIsSyncing); + return true; + }; + + // attach batch request creation + pkg.createBatchRequest = function () { + return new requestManager.BatchManager(pkg); + }; + + // attach extend function + pkg.extend = extend(pkg); + }, + addProviders: function (pkg) { + pkg.providers = requestManager.Manager.providers; + } +}; + diff --git a/packages/web3-eth/package.json b/packages/web3-eth/package.json new file mode 100644 index 0000000..e00d7b7 --- /dev/null +++ b/packages/web3-eth/package.json @@ -0,0 +1,20 @@ +{ + "name": "web3-eth", + "version": "1.0.0", + "description": "Web3 module to interact with the Ethereum blockchain and smart contracts.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-eth", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-core": "^1.0.0", + "web3-core-helpers": "^1.0.0", + "web3-core-iban": "^1.0.0", + "web3-core-subscriptions": "^1.0.0", + "web3-core-method": "^1.0.0", + "web3-utils": "^1.0.0", + "underscore": "^1.8.3", + "web3-core-promiEvent": "^1.0.0", + + "bignumber.js": "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2" + } +} diff --git a/lib/web3/contract.js b/packages/web3-eth/src/contract.js similarity index 76% rename from lib/web3/contract.js rename to packages/web3-eth/src/contract.js index fdc25a2..e5bea65 100644 --- a/lib/web3/contract.js +++ b/packages/web3-eth/src/contract.js @@ -20,14 +20,15 @@ * @date 2016 */ -var _ = require('lodash'); -var utils = require('../utils/utils'); -var eventifiedPromise = require('./eventifiedPromise.js'); -var Method = require('./method.js'); -var coder = require('../solidity/coder'); -var formatters = require('./formatters'); -var sha3 = require('../utils/sha3'); -var Subscription = require('./subscription.js'); +var _ = require('underscore'); +var Method = require('web3-core-method'); +var utils = require('web3-utils'); +var Subscription = require('web3-core-subscriptions').subscription; +var formatters = require('web3-core-helpers').formatters; +var promiEvent = require('web3-core-promiEvent'); + + +var coder = require('./solidity/coder'); /** @@ -67,10 +68,9 @@ var Contract = function(jsonInterface, address, options) { // set address Object.defineProperty(this.options, 'address', { set: function(value){ - if(utils.isAddress(value)) - this._address = value.toLowerCase(); - else if(value) - throw new Error('The provided contract address is not a valid address.'); + if(value) { + this._address = formatters.inputAddressFormatter(value); + } }, get: function(){ return this._address; @@ -95,7 +95,7 @@ var Contract = function(jsonInterface, address, options) { // function if (method.type === 'function') { - method.signature = '0x'+ sha3(utils.transformToFullName(method)).slice(0, 8); + method.signature = utils.sha3(utils.transformToFullName(method)).slice(0, 10); func = _this._createTxObject.bind({ method: method, parent: _this @@ -112,14 +112,10 @@ var Contract = function(jsonInterface, address, options) { // add method by name _this.methods[funcName] = func; - // also add to the main contract object - // if(!_this[method.name] || _this[method.name].name === 'bound _createTxObject') - // _this[method.name] = _this.methods[method.name]; - // _this[method.signature] = _this.methods[method.signature]; // event } else if (method.type === 'event') { - method.signature = '0x'+ sha3(utils.transformToFullName(method)); + method.signature = utils.sha3(utils.transformToFullName(method)); var event = _this._on.bind(_this, method.signature); // add method only if not already exists @@ -161,7 +157,7 @@ var Contract = function(jsonInterface, address, options) { }; -Contract.prototype._web3 = {}; // web3 is attached here in eth.js +Contract.prototype._eth = {}; // eth is attached here in web3-eth/src/index.js /** @@ -333,8 +329,6 @@ Contract.prototype._decodeEventABI = function (data) { result.event = event.name; - //delete result.data; - //delete result.topics; return result; }; @@ -354,7 +348,7 @@ Contract.prototype._encodeMethodABI = function _encodeMethodABI() { var signature = false, paramsABI = this._parent.options.jsonInterface.filter(function (json) { return ((methodSignature === 'constructor' && json.type === methodSignature) || - ((json.signature === methodSignature || json.signature === '0x'+ methodSignature.replace('0x','') || json.name === methodSignature) && json.type === 'function')); + ((json.signature === methodSignature || json.signature === methodSignature.replace('0x','') || json.name === methodSignature) && json.type === 'function')); }).map(function (json) { if(json.inputs.length !== args.length) { throw new Error('The number of arguments is not matching the methods required number. You need to pass '+ json.inputs.length +' arguments.'); @@ -436,10 +430,9 @@ Contract.prototype.deploy = function(options, callback){ // return error, if no "data" is specified if(!options.data) { - return utils._fireError(new Error('No "data" specified in neither the given options, nor the default options.'), defer.promise, defer.reject, callback); + return utils._fireError(new Error('No "data" specified in neither the given options, nor the default options.'), null, null, callback); } - // return defer.promise; var constructor = _.find(this.options.jsonInterface, function (method) { return (method.type === 'constructor'); }) || {}; @@ -550,7 +543,7 @@ Contract.prototype._on = function(){ }, subscribeMethod: 'eth_subscribe', unsubscribeMethod: 'eth_unsubscribe', - requestManager: this._web3._requestManager + requestManager: this._eth._requestManager }); subscription.subscribe('logs', subOptions.params, subOptions.callback || function () {}); @@ -576,7 +569,7 @@ Contract.prototype.getPastEvents = function(){ inputFormatter: [formatters.inputLogFormatter], outputFormatter: this._decodeEventABI.bind(subOptions.event) }); - getPastLogs.setRequestManager(this._web3._requestManager); + getPastLogs.setRequestManager(this._eth._requestManager); var call = getPastLogs.buildCall(); getPastLogs = null; @@ -617,112 +610,6 @@ Contract.prototype._createTxObject = function _createTxObject(){ }; - -/** - * The callback called when executing a method - * - * @method _methodReturnCallback - * @param {Object} err - * @param {Mixed} returnValue - */ -Contract.prototype._methodReturnCallback = function methodReturnCallback(defer, callback, type, err, returnValue) { - var _this = this, - error = new Error('Failed to check for transaction receipt.'), - callbackFired = false; - - if(type === 'call') { - returnValue = _this._parent._decodeMethodReturn(_this._method.outputs, returnValue); - } - - - if (err) { - return utils._fireError(err, defer.promise, defer.reject, callback); - } else { - - // send immediate returnValue (see end of the function for resolve event of call and estimateGas) - if(callback) { - callback(null, returnValue); - } - - // check for receipt on send - if(type === 'send') { - - defer.promise.emit('transactionHash', returnValue); - - // fire "receipt" event and resolve after - _this._parent._web3.eth.subscribe('newBlocks', {}, function (err, block, sub) { - if(!err) { - - _this._parent._web3.eth.getTransactionReceipt(returnValue, function (err, receipt) { - if(!err) { - if(!callbackFired && receipt) { - - // CHECK for contract deployment - if(_this._deployData) { - - if(!receipt.contractAddress) { - callbackFired = true; - return utils._fireError(new Error('The transaction receipt didn\'t contain a contract address.'), defer.promise, defer.reject); - } - - _this._parent._web3.eth.getCode(receipt.contractAddress, function(e, code){ - - if(!code) - return; - - sub.unsubscribe(); - callbackFired = true; - - if(code.length > 2) { - defer.promise.emit('receipt', receipt); - defer.resolve(receipt); - defer.promise.removeAllListeners(); - } else { - return utils._fireError(new Error('The contract code couldn\'t be stored, please check your gas limit.'), defer.promise, defer.reject); - } - }); - - - - // CHECK for normal tx check for receipt only - } else { - sub.unsubscribe(); - callbackFired = true; - - if(!receipt.outOfGas) { - defer.promise.emit('receipt', receipt); - defer.resolve(receipt); - defer.promise.removeAllListeners(); - - } else { - return utils._fireError(new Error('Transaction ran out of gas.'), defer.promise, defer.reject); - } - } - - } - } else { - sub.unsubscribe(); - callbackFired = true; - return utils._fireError(error, defer.promise, defer.reject); - } - }); - - - } else { - sub.unsubscribe(); - callbackFired = true; - return utils._fireError(error, defer.promise, defer.reject); - } - }); - - } else { - - // remove all listeners on the end, as no event will ever fire again - defer.resolve(returnValue); - } - } -}; - /** * Generates the options for the execute call * @@ -745,7 +632,7 @@ Contract.prototype._processExecuteArguments = function _processExecuteArguments( // get the options processedArgs.options = (utils.isObject(args[args.length - 1])) ? args.pop() : {}; - // get the generateRequest argument + // get the generateRequest argument for batch requests processedArgs.generateRequest = (args[args.length - 1] === true)? args.pop() : false; processedArgs.options = this._parent._fillWithDefaultOptions(processedArgs.options); @@ -760,7 +647,7 @@ Contract.prototype._processExecuteArguments = function _processExecuteArguments( // return error, if no "data" is specified if(!processedArgs.options.data) - return utils._fireError(new Error('Couldn\'t find a matching contract method, or the number of parameters is wrong.'), defer.promise, defer.reject, processedArgs.callback); + return utils._fireError(new Error('Couldn\'t find a matching contract method, or the number of parameters is wrong.'), defer.eventEmitter, defer.reject, processedArgs.callback); return processedArgs; }; @@ -773,11 +660,12 @@ Contract.prototype._processExecuteArguments = function _processExecuteArguments( * @param {Boolean} makeRequest if true, it simply returns the request parameters, rather than executing it */ Contract.prototype._executeMethod = function _executeMethod(){ - var args = this._parent._processExecuteArguments.call(this, Array.prototype.slice.call(arguments), defer), - defer = eventifiedPromise((args.type !== 'send')); + var _this = this, + args = this._parent._processExecuteArguments.call(this, Array.prototype.slice.call(arguments), defer), + defer = promiEvent((args.type !== 'send')); - // simple return request + // simple return request for batch requests if(args.generateRequest) { var payload = { @@ -796,40 +684,52 @@ Contract.prototype._executeMethod = function _executeMethod(){ } else { - var methodReturnCallback = this._parent._methodReturnCallback.bind(this, defer, args.callback, args.type); - switch (args.type) { case 'estimate': - this._parent._web3.eth.estimateGas(args.options, methodReturnCallback); + return this._parent._eth.estimateGas(args.options, args.callback); - break; case 'call': // TODO check errors: missing "from" should give error on deploy and send, call ? - this._parent._web3.eth.call(args.options, args.defaultBlock, methodReturnCallback); + this._parent._eth.call(args.options, args.defaultBlock, function (err, result) { + + // decode result + if(result) { + result = _this._parent._decodeMethodReturn(_this._method.outputs, result); + } + + // throw error + if(err) { + return utils._fireError(err, null, defer.reject, args.callback); + } + + if(_.isFunction(args.callback)) { + args.callback(null, result); + } + defer.resolve(result); + }); + + return defer.eventEmitter; - break; case 'send': // return error, if no "from" is specified if(!utils.isAddress(args.options.from)) { - return utils._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'), defer.promise, defer.reject, args.callback); + return utils._fireError(new Error('No "from" address specified in neither the given options, nor the default options.'), defer.eventEmitter, defer.reject, args.callback); } if (_.isBoolean(this._method.payable) && !this._method.payable && args.options.value && args.options.value > 0) { - return utils._fireError(new Error('Can not send value to non-payable contract method or constructor'), defer.promise, defer.reject, args.callback); + return utils._fireError(new Error('Can not send value to non-payable contract method or constructor'), defer.eventEmitter, defer.reject, args.callback); } - this._parent._web3.eth.sendTransaction(args.options, methodReturnCallback); + return this._parent._eth.sendTransaction(args.options, args.callback); - break; } } - return defer.promise; }; module.exports = Contract; diff --git a/lib/web3/methods/eth.js b/packages/web3-eth/src/index.js similarity index 64% rename from lib/web3/methods/eth.js rename to packages/web3-eth/src/index.js index 60ec6c4..7c9f6a8 100644 --- a/lib/web3/methods/eth.js +++ b/packages/web3-eth/src/index.js @@ -15,98 +15,162 @@ along with web3.js. If not, see . */ /** - * @file eth.js - * @author Marek Kotewicz - * @author Fabian Vogelsteller - * @date 2015 + * @file index.js + * @author Fabian Vogelsteller + * @date 2017 */ "use strict"; -var formatters = require('../formatters'); -var utils = require('../../utils/utils'); -var c = require('../../utils/config'); -var Method = require('../method'); -var Property = require('../property'); -var Subscriptions = require('../subscriptions'); -var Contract = require('../contract'); -var namereg = require('../namereg'); -var Iban = require('../iban'); -var transfer = require('../transfer'); +var _ = require('underscore'); +var core = require('web3-core'); +var helpers = require('web3-core-helpers'); +var Subscriptions = require('web3-core-subscriptions').subscriptions; +var utils = require('web3-utils'); +var Method = require('web3-core-method'); +var Contract = require('./contract'); +var Iban = require('web3-core-iban'); + +var formatters = helpers.formatters; + var blockCall = function (args) { - return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber"; + return (_.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'; + return (_.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'; + return (_.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'; + return (_.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'; + return (_.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber'; }; -function Eth(web3) { - this._requestManager = web3._requestManager; - var self = this; +function Eth() { + var _this = this; + + // sets _requestmanager + core.packageInit(this, arguments); + methods().forEach(function(method) { - method.attachToObject(self); - method.setRequestManager(self._requestManager); + method.attachToObject(_this); + method.setRequestManager(_this._requestManager, _this); // second param means is Eth (necessary for promiEvent) }); - properties().forEach(function(p) { - p.attachToObject(self); - p.setRequestManager(self._requestManager); - }); // add contract this.contract = Contract; - this.contract.prototype._web3 = web3; + this.contract.prototype._eth = this; - this.iban = Iban; - this.sendIBANTransaction = transfer.bind(null, this); + // add IBAN + this.iban = { + _Iban: Iban, + toAddress: function (ib) { + ib = new Iban(ib); - this.namereg = function () { - return this.contract(namereg.global.abi).at(namereg.global.address); + if(!ib.isDirect()) { + throw new Error('IBAN is indirect and can\'t be converted'); + } + + return ib.address(); + }, + toIBAN: function (address) { + return Iban.fromAddress(address).toString(); + } }; - this.icapNamereg = function () { - return this.contract(namereg.icap.abi).at(namereg.icap.address); - }; } +core.addProviders(Eth); + Object.defineProperty(Eth.prototype, 'defaultBlock', { get: function () { - return c.defaultBlock; + return helpers.config.defaultBlock; }, set: function (val) { - c.defaultBlock = val; + helpers.config.defaultBlock = val; return val; - } + }, + enumerable: true }); Object.defineProperty(Eth.prototype, 'defaultAccount', { get: function () { - return c.defaultAccount; + return helpers.config.defaultAccount; }, set: function (val) { - c.defaultAccount = val; + helpers.config.defaultAccount = val; return val; - } + }, + enumerable: true }); var methods = function () { + + var getVersion = new Method({ + name: 'getProtocolVersion', + call: 'eth_protocolVersion', + params: 0 + }); + + var getCoinbase = new Method({ + name: 'getCoinbase', + call: 'eth_coinbase', + params: 0 + }); + + var getMining = new Method({ + name: 'isMining', + call: 'eth_mining', + params: 0 + }); + + var getHashrate = new Method({ + name: 'getHashrate', + call: 'eth_hashrate', + params: 0, + outputFormatter: utils.toDecimal + }); + + var getSyncing = new Method({ + name: 'getSyncing', + call: 'eth_syncing', + params: 0, + outputFormatter: formatters.outputSyncingFormatter + }); + + var getGasPrice = new Method({ + name: 'getGasPrice', + call: 'eth_gasPrice', + params: 0, + outputFormatter: formatters.outputBigNumberFormatter + }); + + var getAccounts = new Method({ + name: 'getAccounts', + call: 'eth_accounts', + params: 0, + outputFormatter: utils.toChecksumAddress + }); + + var getBlockNumber = new Method({ + name: 'getBlockNumber', + call: 'eth_blockNumber', + params: 0, + outputFormatter: utils.toDecimal + }); + var getBalance = new Method({ name: 'getBalance', call: 'eth_getBalance', @@ -119,7 +183,7 @@ var methods = function () { name: 'getStorageAt', call: 'eth_getStorageAt', params: 3, - inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter] + inputFormatter: [formatters.inputAddressFormatter, utils.toHex, formatters.inputDefaultBlockNumberFormatter] }); var getCode = new Method({ @@ -166,6 +230,7 @@ var methods = function () { name: 'getTransaction', call: 'eth_getTransactionByHash', params: 1, + inputFormatter: [formatters.inputAddressFormatter], outputFormatter: formatters.outputTransactionFormatter }); @@ -181,6 +246,7 @@ var methods = function () { name: 'getTransactionReceipt', call: 'eth_getTransactionReceipt', params: 1, + inputFormatter: [null], outputFormatter: formatters.outputTransactionReceiptFormatter }); @@ -192,8 +258,8 @@ var methods = function () { outputFormatter: utils.toDecimal }); - var sendRawTransaction = new Method({ - name: 'sendRawTransaction', + var sendSignedTransaction = new Method({ + name: 'sendSignedTransaction', call: 'eth_sendRawTransaction', params: 1, inputFormatter: [null] @@ -279,8 +345,10 @@ var methods = function () { subscribe: 'eth_subscribe', unsubscribe: 'eth_unsubscribe', subscriptions: { - 'newBlocks': { - params: 1, + 'newBlockHeaders': { + // TODO change name on RPC side? + subscriptionName: 'newHeads', // replace subscription with this name + params: 0, outputFormatter: formatters.outputBlockFormatter }, 'pendingTransactions': { @@ -301,6 +369,14 @@ var methods = function () { return [ + getVersion, + getCoinbase, + getMining, + getHashrate, + getSyncing, + getGasPrice, + getAccounts, + getBlockNumber, getBalance, getStorageAt, getCode, @@ -315,7 +391,7 @@ var methods = function () { getTransactionCount, call, estimateGas, - sendRawTransaction, + sendSignedTransaction, sendTransaction, sign, compileSolidity, @@ -323,50 +399,8 @@ var methods = function () { compileSerpent, submitWork, getWork, - subscribe, - getPastLogs - ]; -}; - - -var properties = function () { - return [ - 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: 'syncing', - getter: 'eth_syncing', - outputFormatter: formatters.outputSyncingFormatter - }), - 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 - }), - new Property({ - name: 'protocolVersion', - getter: 'eth_protocolVersion' - }) + getPastLogs, + subscribe ]; }; diff --git a/lib/solidity/address.js b/packages/web3-eth/src/solidity/address.js similarity index 100% rename from lib/solidity/address.js rename to packages/web3-eth/src/solidity/address.js diff --git a/lib/solidity/bool.js b/packages/web3-eth/src/solidity/bool.js similarity index 100% rename from lib/solidity/bool.js rename to packages/web3-eth/src/solidity/bool.js diff --git a/lib/solidity/bytes.js b/packages/web3-eth/src/solidity/bytes.js similarity index 100% rename from lib/solidity/bytes.js rename to packages/web3-eth/src/solidity/bytes.js diff --git a/lib/solidity/coder.js b/packages/web3-eth/src/solidity/coder.js similarity index 100% rename from lib/solidity/coder.js rename to packages/web3-eth/src/solidity/coder.js diff --git a/lib/solidity/dynamicbytes.js b/packages/web3-eth/src/solidity/dynamicbytes.js similarity index 100% rename from lib/solidity/dynamicbytes.js rename to packages/web3-eth/src/solidity/dynamicbytes.js diff --git a/lib/solidity/formatters.js b/packages/web3-eth/src/solidity/formatters.js similarity index 94% rename from lib/solidity/formatters.js rename to packages/web3-eth/src/solidity/formatters.js index 19fae1b..7db6bb8 100644 --- a/lib/solidity/formatters.js +++ b/packages/web3-eth/src/solidity/formatters.js @@ -21,8 +21,8 @@ */ var BigNumber = require('bignumber.js'); -var utils = require('../utils/utils'); -var c = require('../utils/config'); +var utils = require('web3-utils'); +var c = require('web3-core-helpers').config; var SolidityParam = require('./param'); @@ -133,9 +133,9 @@ var formatOutputInt = function (param) { // 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).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1).toFixed(); } - return new BigNumber(value, 16); + return new BigNumber(value, 16).toFixed(); }; /** @@ -143,11 +143,11 @@ var formatOutputInt = function (param) { * * @method formatOutputUInt * @param {SolidityParam} - * @returns {BigNumeber} right-aligned output bytes formatted to uint + * @returns {BigNumber} right-aligned output bytes formatted to uint */ var formatOutputUInt = function (param) { var value = param.staticPart() || "0"; - return new BigNumber(value, 16); + return new BigNumber(value, 16).toFixed(); }; /** @@ -158,7 +158,7 @@ var formatOutputUInt = function (param) { * @returns {BigNumber} input bytes formatted to real */ var formatOutputReal = function (param) { - return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128)); + return new BigNumber(formatOutputInt(param)).dividedBy(new BigNumber(2).pow(128)).toFixed(); }; /** @@ -169,7 +169,7 @@ var formatOutputReal = function (param) { * @returns {BigNumber} input bytes formatted to ureal */ var formatOutputUReal = function (param) { - return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128)); + return new BigNumber(formatOutputUInt(param)).dividedBy(new BigNumber(2).pow(128)).toFixed(); }; /** diff --git a/lib/solidity/int.js b/packages/web3-eth/src/solidity/int.js similarity index 100% rename from lib/solidity/int.js rename to packages/web3-eth/src/solidity/int.js diff --git a/lib/solidity/param.js b/packages/web3-eth/src/solidity/param.js similarity index 96% rename from lib/solidity/param.js rename to packages/web3-eth/src/solidity/param.js index e06b592..807f267 100644 --- a/lib/solidity/param.js +++ b/packages/web3-eth/src/solidity/param.js @@ -14,13 +14,13 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -/** +/** * @file param.js * @author Marek Kotewicz * @date 2015 */ -var utils = require('../utils/utils'); +var utils = require('web3-utils'); /** * SolidityParam object prototype. @@ -33,7 +33,7 @@ var SolidityParam = function (value, offset) { /** * This method should be used to get length of params's dynamic part - * + * * @method dynamicPartLength * @returns {Number} length of dynamic part (in bytes) */ @@ -61,7 +61,7 @@ SolidityParam.prototype.withOffset = function (offset) { * @param {SolidityParam} result of combination */ SolidityParam.prototype.combine = function (param) { - return new SolidityParam(this.value + param.value); + return new SolidityParam(this.value + param.value); }; /** @@ -93,8 +93,8 @@ SolidityParam.prototype.offsetAsBytes = function () { */ SolidityParam.prototype.staticPart = function () { if (!this.isDynamic()) { - return this.value; - } + return this.value; + } return this.offsetAsBytes(); }; @@ -126,7 +126,7 @@ SolidityParam.prototype.encode = function () { * @returns {String} */ SolidityParam.encodeList = function (params) { - + // updating offsets var totalOffset = params.length * 32; var offsetParams = params.map(function (param) { diff --git a/lib/solidity/real.js b/packages/web3-eth/src/solidity/real.js similarity index 100% rename from lib/solidity/real.js rename to packages/web3-eth/src/solidity/real.js diff --git a/lib/solidity/string.js b/packages/web3-eth/src/solidity/string.js similarity index 100% rename from lib/solidity/string.js rename to packages/web3-eth/src/solidity/string.js diff --git a/lib/solidity/type.js b/packages/web3-eth/src/solidity/type.js similarity index 100% rename from lib/solidity/type.js rename to packages/web3-eth/src/solidity/type.js diff --git a/lib/solidity/uint.js b/packages/web3-eth/src/solidity/uint.js similarity index 100% rename from lib/solidity/uint.js rename to packages/web3-eth/src/solidity/uint.js diff --git a/lib/solidity/ureal.js b/packages/web3-eth/src/solidity/ureal.js similarity index 100% rename from lib/solidity/ureal.js rename to packages/web3-eth/src/solidity/ureal.js diff --git a/packages/web3-net/package.json b/packages/web3-net/package.json new file mode 100644 index 0000000..b70e39b --- /dev/null +++ b/packages/web3-net/package.json @@ -0,0 +1,13 @@ +{ + "name": "web3-net", + "version": "1.0.0", + "description": "Web3 module to interact with the Ethereum nodes networking properties.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-net", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-core": "^1.0.0", + "web3-core-method": "^1.0.0", + "web3-utils": "^1.0.0" + } +} diff --git a/packages/web3-net/src/index.js b/packages/web3-net/src/index.js new file mode 100644 index 0000000..332a0b7 --- /dev/null +++ b/packages/web3-net/src/index.js @@ -0,0 +1,72 @@ +/* + This file is part of web3.js. + + web3.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. + + web3.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 web3.js. If not, see . +*/ +/** + * @file index.js + * @author Fabian Vogelsteller + * @date 2017 + */ + +"use strict"; + +var core = require('web3-core'); +var Method = require('web3-core-method'); +var utils = require('web3-utils'); + + +var Net = function () { + var _this = this; + + // sets _requestmanager + core.packageInit(this, arguments); + + + methods().forEach(function(method) { + method.attachToObject(_this); + method.setRequestManager(_this._requestManager); + }); + +}; + +core.addProviders(Net); + + +var methods = function () { + + var getListening = new Method({ + name: 'isListening', + call: 'net_listening', + params: 0 + }); + + var getPeerCount = new Method({ + name: 'getPeerCount', + call: 'net_peerCount', + params: 0, + outputFormatter: utils.toDecimal + }); + + + return [ + getListening, + getPeerCount + ]; +}; + + +module.exports = Net; + + diff --git a/packages/web3-personal/package.json b/packages/web3-personal/package.json new file mode 100644 index 0000000..0be3343 --- /dev/null +++ b/packages/web3-personal/package.json @@ -0,0 +1,14 @@ +{ + "name": "web3-personal", + "version": "1.0.0", + "description": "Web3 module to interact with the Ethereum blockchain accounts stored in the node.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-personal", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-core": "^1.0.0", + "web3-core-helpers": "^1.0.0", + "web3-core-method": "^1.0.0", + "web3-utils": "^1.0.0" + } +} diff --git a/lib/web3/methods/personal.js b/packages/web3-personal/src/index.js similarity index 68% rename from lib/web3/methods/personal.js rename to packages/web3-personal/src/index.js index 0756a0f..fad6458 100644 --- a/lib/web3/methods/personal.js +++ b/packages/web3-personal/src/index.js @@ -15,40 +15,51 @@ along with web3.js. If not, see . */ /** - * @file eth.js - * @author Marek Kotewicz - * @author Fabian Vogelsteller - * @date 2015 + * @file index.js + * @author Fabian Vogelsteller + * @date 2017 */ "use strict"; -var Method = require('../method'); -var Property = require('../property'); -var formatters = require('../formatters'); +var core = require('web3-core'); +var Method = require('web3-core-method'); +var utils = require('web3-utils'); -function Personal(web3) { - this._requestManager = web3._requestManager; +var formatters = require('web3-core-helpers').formatters; + + +function Personal() { + var _this = this; + + // sets _requestmanager + core.packageInit(this, arguments); - var self = this; methods().forEach(function(method) { - method.attachToObject(self); - method.setRequestManager(self._requestManager); - }); - - properties().forEach(function(p) { - p.attachToObject(self); - p.setRequestManager(self._requestManager); + method.attachToObject(_this); + method.setRequestManager(_this._requestManager); }); } +core.addProviders(Personal); + + var methods = function () { + + var getAccounts = new Method({ + name: 'getAccounts', + call: 'personal_listAccounts', + params: 0, + outputFormatter: utils.toChecksumAddress + }); + var newAccount = new Method({ name: 'newAccount', call: 'personal_newAccount', params: 1, - inputFormatter: [null] + inputFormatter: [null], + outputFormatter: utils.toChecksumAddress }); var unlockAccount = new Method({ @@ -72,7 +83,9 @@ var methods = function () { inputFormatter: [formatters.inputAddressFormatter] }); + return [ + getAccounts, newAccount, unlockAccount, sendTransaction, @@ -80,14 +93,7 @@ var methods = function () { ]; }; -var properties = function () { - return [ - new Property({ - name: 'listAccounts', - getter: 'personal_listAccounts' - }) - ]; -}; - module.exports = Personal; + + diff --git a/packages/web3-shh/package.json b/packages/web3-shh/package.json new file mode 100644 index 0000000..b82265b --- /dev/null +++ b/packages/web3-shh/package.json @@ -0,0 +1,14 @@ +{ + "name": "web3-shh", + "version": "1.0.0", + "description": "Web3 module to interact with the Whisper messaging protocol.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-shh", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "web3-core": "^1.0.0", + "web3-core-helpers": "^1.0.0", + "web3-core-method": "^1.0.0", + "web3-core-subscriptions": "^1.0.0" + } +} diff --git a/lib/web3/methods/shh.js b/packages/web3-shh/src/index.js similarity index 72% rename from lib/web3/methods/shh.js rename to packages/web3-shh/src/index.js index 3bec083..e73f663 100644 --- a/lib/web3/methods/shh.js +++ b/packages/web3-shh/src/index.js @@ -14,34 +14,42 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -/** @file shh.js - * @authors: - * Marek Kotewicz - * @date 2015 +/** + * @file index.js + * @author Fabian Vogelsteller + * @date 2017 */ -var Method = require('../method'); -var formatters = require('../formatters'); -var Subscriptions = require('../subscriptions'); +"use strict"; + +var core = require('web3-core'); +var Subscriptions = require('web3-core-subscriptions').subscriptions; +var Method = require('web3-core-method'); + +var formatters = require('web3-core-helpers').formatters; -var Shh = function (web3) { - this._requestManager = web3._requestManager; +var Shh = function () { + var _this = this; - var self = this; + // sets _requestmanager + core.packageInit(this, arguments); - methods().forEach(function(method) { - method.attachToObject(self); - method.setRequestManager(self._requestManager); + + methods().forEach(function(method) { + method.attachToObject(_this); + method.setRequestManager(_this._requestManager); }); }; +core.addProviders(Shh); -var methods = function () { + +var methods = function () { var post = new Method({ - name: 'post', - call: 'shh_post', + name: 'post', + call: 'shh_post', params: 1, inputFormatter: [formatters.inputPostFormatter] }); @@ -74,7 +82,7 @@ var methods = function () { name: 'getPastMessages', call: 'shh_getMessages', params: 1, - inputFormatter: [formatters.inputLogFormatter], + inputFormatter: [formatters.inputPostFormatter], outputFormatter: formatters.outputPostFormatter }); @@ -86,7 +94,7 @@ var methods = function () { subscriptions: { 'messages': { params: 1, - inputFormatter: [formatters.inputLogFormatter], + inputFormatter: [formatters.inputPostFormatter], outputFormatter: formatters.outputPostFormatter } } @@ -105,3 +113,4 @@ var methods = function () { module.exports = Shh; + diff --git a/packages/web3-utils/package.json b/packages/web3-utils/package.json new file mode 100644 index 0000000..04c4cf6 --- /dev/null +++ b/packages/web3-utils/package.json @@ -0,0 +1,14 @@ +{ + "name": "web3-utils", + "version": "1.0.0", + "description": "Collection of utility functions used in web3.js.", + "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-utils", + "license": "LGPL-3.0", + "main": "src/index.js", + "dependencies": { + "utf8": "^2.1.1", + "crypto-js": "^3.1.4", + + "bignumber.js": "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2" + } +} diff --git a/lib/utils/utils.js b/packages/web3-utils/src/index.js similarity index 88% rename from lib/utils/utils.js rename to packages/web3-utils/src/index.js index ac2ea3a..d868fca 100644 --- a/lib/utils/utils.js +++ b/packages/web3-utils/src/index.js @@ -1,43 +1,33 @@ /* - This file is part of web3.js. + This file is part of web3.js. - web3.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. + web3.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. - web3.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. + web3.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 web3.js. If not, see . -*/ + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . + */ /** * @file utils.js - * @author Marek Kotewicz - * @date 2015 - */ - -/** - * Utils - * - * @module utils - */ - -/** - * Utility functions - * - * @class [utils] utils - * @constructor + * @author Marek Kotewicz + * @author Fabian Vogelsteller + * @date 2017 */ var BigNumber = require('bignumber.js'); -var sha3 = require('./sha3.js'); var utf8 = require('utf8'); +// var iban = require('web3-core-iban'); +var sha3 = require('./sha3.js'); + var unitMap = { 'noether': '0', 'wei': '1', @@ -79,18 +69,25 @@ var unitMap = { * @return {Object} the emitter */ var _fireError = function (error, emitter, reject, callback) { - setTimeout(function(){ - if(isFunction(callback)) { - callback(error); + if(isFunction(callback)) { + callback(error); + } + if(isFunction(reject)) { + // suppress uncatched error if an error listener is present + if(emitter && + isFunction(emitter.listeners) && + emitter.listeners('error').length && + isFunction(emitter.suppressUnhandledRejections)) { + emitter.suppressUnhandledRejections(); } - if(isFunction(reject)) { - reject(error); - } - if(emitter && isFunction(emitter.emit)) { - emitter.emit('error', error); - emitter.removeAllListeners(); - } - }, 0); + reject(error); + } + + if(emitter && isFunction(emitter.emit)) { + emitter.emit('error', error); + emitter.removeAllListeners(); + } + return emitter; }; @@ -338,7 +335,7 @@ var getValueOfUnit = function (unit) { * @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)); @@ -366,7 +363,7 @@ var fromWei = function(number, unit) { * @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)); @@ -379,7 +376,7 @@ var toWei = function(number, unit) { * @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; @@ -408,16 +405,6 @@ var toTwosComplement = function (number) { 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}$/i.test(address); -}; /** * Checks if the given string is an address @@ -425,12 +412,12 @@ var isStrictAddress = function (address) { * @method isAddress * @param {String} address the given HEX adress * @return {Boolean} -*/ + */ var isAddress = function (address) { - if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) { + if (!/^(0x|0X)?[0-9a-f]{40}$/i.test(address)) { // check if it has the basic requirements of an address return false; - } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) { + } else if (/^(0x|0X)?[0-9a-f]{40}$/.test(address) || /^(0x|0X)?[0-9A-F]{40}$/.test(address)) { // If it's all small caps or all all caps, return true return true; } else { @@ -447,11 +434,11 @@ var isAddress = function (address) { * @method isChecksumAddress * @param {String} address the given HEX adress * @return {Boolean} -*/ + */ var isChecksumAddress = function (address) { // Check each case address = address.replace('0x',''); - var addressHash = sha3(address.toLowerCase()); + var addressHash = sha3(address.toLowerCase()).replace('0x',''); for (var i = 0; i < 40; i++ ) { // the nth letter should be uppercase if the nth digit of casemap is 1 @@ -470,18 +457,18 @@ var isChecksumAddress = function (address) { * @method toChecksumAddress * @param {String} address the given HEX adress * @return {String} -*/ + */ var toChecksumAddress = function (address) { if (typeof address === 'undefined') return ''; address = address.toLowerCase().replace('0x',''); - var addressHash = sha3(address); + var addressHash = sha3(address).replace('0x',''); var checksumAddress = '0x'; for (var i = 0; i < address.length; i++ ) { // If ith character is 9 to f then make it uppercase if (parseInt(addressHash[i], 16) > 7) { - checksumAddress += address[i].toUpperCase(); + checksumAddress += address[i].toUpperCase(); } else { checksumAddress += address[i]; } @@ -497,8 +484,8 @@ var toChecksumAddress = function (address) { * @return {String} formatted address */ var toAddress = function (address) { - if (isStrictAddress(address)) { - return address; + if (isAddress(address)) { + return '0x'+ address.toLowerCase().replace('0x',''); } if (/^[0-9a-f]{40}$/.test(address)) { @@ -611,7 +598,6 @@ module.exports = { toTwosComplement: toTwosComplement, toAddress: toAddress, isBigNumber: isBigNumber, - isStrictAddress: isStrictAddress, isAddress: isAddress, isChecksumAddress: isChecksumAddress, toChecksumAddress: toChecksumAddress, @@ -620,5 +606,8 @@ module.exports = { isObject: isObject, isBoolean: isBoolean, isArray: isArray, - isJson: isJson + isJson: isJson, + sha3: sha3, + // iban: iban }; + diff --git a/lib/utils/sha3.js b/packages/web3-utils/src/sha3.js similarity index 93% rename from lib/utils/sha3.js rename to packages/web3-utils/src/sha3.js index a7ce60a..d9ee385 100644 --- a/lib/utils/sha3.js +++ b/packages/web3-utils/src/sha3.js @@ -14,9 +14,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -/** +/** * @file sha3.js - * @author Marek Kotewicz + * @author Marek Kotewicz * @date 2015 */ @@ -31,7 +31,7 @@ module.exports = function (value, options) { value = CryptoJS.enc.Hex.parse(value); } - return sha3(value, { + return '0x'+ sha3(value, { outputLength: 256 }).toString(); }; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..6466bd8 --- /dev/null +++ b/src/index.js @@ -0,0 +1,60 @@ +/* + This file is part of web3.js. + + web3.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. + + web3.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 web3.js. If not, see . +*/ +/** + * @file index.js + * @authors: + * Fabian Vogelsteller + * Gav Wood + * Jeffrey Wilcke + * Marek Kotewicz + * Marian Oancea + * @date 2017 + */ + + +var core = require('../packages/web3-core'); + +var Eth = require('../packages/web3-eth'); +var Net = require('../packages/web3-net'); +var Shh = require('../packages/web3-shh'); +var Personal = require('../packages/web3-personal'); + +var utils = require('../packages/web3-utils'); + + + + +var Web3 = function () { + + // sets _requestmanager etc + core.packageInit(this, arguments); + + + this.net = new Net(this); + this.eth = new Eth(this); + this.personal = new Personal(this); // move to -> web3.eth.accounts + this.shh = new Shh(this); + + this.utils = utils; +}; + +core.addProviders(Web3); + + + +module.exports = Web3; + diff --git a/test/async.js b/test/async.js index f550a3d..b29a573 100644 --- a/test/async.js +++ b/test/async.js @@ -1,21 +1,22 @@ var chai = require('chai'); var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); +var Web3 = require('../src/index'); var FakeHttpProvider = require('./helpers/FakeHttpProvider'); +var web3 = new Web3(); + // use sendTransaction as dummy -var method = 'sendTransaction'; +var method = 'call'; var tests = [{ input: { 'from': 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', 'to': 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS' }, - formattedInput: { + formattedInput: [{ 'from': '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', 'to': '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8' - }, + }, 'latest'], result: '0xb', formattedResult: '0xb', call: 'eth_'+ method @@ -23,8 +24,8 @@ var tests = [{ describe('async', function () { tests.forEach(function (test, index) { - it('test: ' + index, function (done) { - + it('test callback: ' + index, function (done) { + // given var provider = new FakeHttpProvider(); web3.setProvider(provider); @@ -32,23 +33,47 @@ describe('async', function () { provider.injectValidation(function (payload) { assert.equal(payload.jsonrpc, '2.0'); assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, [test.formattedInput]); + assert.deepEqual(payload.params, test.formattedInput); }); - // when + // when web3.eth[method](test.input, function(error, result){ // then assert.isNull(error); assert.strictEqual(test.formattedResult, result); - + done(); }); - + }); - it('error test: ' + index, function (done) { - + it('test promise: ' + index, function (done) { + + // given + var provider = new FakeHttpProvider(); + web3.setProvider(provider); + provider.injectResult(test.result); + provider.injectValidation(function (payload) { + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, test.call); + assert.deepEqual(payload.params, test.formattedInput); + }); + + // when + web3.eth[method](test.input) + .then(function(result){ + + // then + assert.strictEqual(test.formattedResult, result); + + done(); + }); + + }); + + it('error test callback: ' + index, function (done) { + // given var provider = new FakeHttpProvider(); web3.setProvider(provider); @@ -59,10 +84,10 @@ describe('async', function () { provider.injectValidation(function (payload) { assert.equal(payload.jsonrpc, '2.0'); assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, [test.formattedInput]); + assert.deepEqual(payload.params, test.formattedInput); }); - // when + // when web3.eth[method](test.input, function(error, result){ // then @@ -70,8 +95,37 @@ describe('async', function () { assert.strictEqual(test.formattedResult, error.message); done(); + }).catch(function () { + }); - + + }); + + it('error test promise: ' + index, function (done) { + + // given + var provider = new FakeHttpProvider(); + web3.setProvider(provider); + provider.injectError({ + message: test.result, + code: -32603 + }); + provider.injectValidation(function (payload) { + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, test.call); + assert.deepEqual(payload.params, test.formattedInput); + }); + + // when + web3.eth[method](test.input) + .catch(function(error){ + + // then + assert.strictEqual(test.formattedResult, error.message); + + done(); + }); + }); }); }); diff --git a/test/batch.js b/test/batch.js index b3e1a7d..e200917 100644 --- a/test/batch.js +++ b/test/batch.js @@ -1,31 +1,32 @@ var chai = require('chai'); var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); +var Web3 = require('../src/index'); var FakeHttpProvider = require('./helpers/FakeHttpProvider'); -var bn = require('bignumber.js'); + + describe('lib/web3/batch', function () { describe('execute', function () { it('should execute batch request', function (done) { var provider = new FakeHttpProvider(); - web3.setProvider(provider); - web3.reset(); + var web3 = new Web3(provider); var result = '0x126'; + var resultVal = '294'; var result2 = '0x127'; + var result2Val = '295'; provider.injectBatchResults([result, result2]); var counter = 0; var callback = function (err, r) { counter++; - assert.deepEqual(new bn(result), r); + assert.deepEqual(r, resultVal); }; var callback2 = function (err, r) { assert.equal(counter, 1); - assert.deepEqual(new bn(result2), r); + assert.deepEqual(r, result2Val); done(); }; @@ -39,7 +40,7 @@ describe('lib/web3/batch', function () { assert.deepEqual(second.params, ['0x0000000000000000000000000000000000000005', 'latest']); }); - var batch = web3.createBatch(); + var batch = web3.createBatchRequest(); batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback)); batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000005', 'latest', callback2)); batch.execute(); @@ -48,8 +49,7 @@ describe('lib/web3/batch', function () { it('should execute batch request for async properties', function (done) { var provider = new FakeHttpProvider(); - web3.setProvider(provider); - web3.reset(); + var web3 = new Web3(provider); var result = []; var result2 = '0xb'; @@ -77,7 +77,7 @@ describe('lib/web3/batch', function () { assert.deepEqual(second.params, []); }); - var batch = web3.createBatch(); + var batch = web3.createBatchRequest(); batch.add(web3.eth.getAccounts.request(callback)); batch.add(web3.net.getPeerCount.request(callback2)); batch.execute(); @@ -86,8 +86,7 @@ describe('lib/web3/batch', function () { it('should execute batch request with contract', function (done) { var provider = new FakeHttpProvider(); - web3.setProvider(provider); - web3.reset(); + var web3 = new Web3(provider); var abi = [{ "name": "balance", @@ -106,23 +105,25 @@ describe('lib/web3/batch', function () { var address = '0x1000000000000000000000000000000000000001'; var result = '0x126'; + var resultVal = '294'; var result2 = '0x0000000000000000000000000000000000000000000000000000000000000123'; + var result2Val = '291'; var counter = 0; var callback = function (err, r) { counter++; - assert.deepEqual(new bn(result), r); + assert.deepEqual(r, resultVal); }; var callback2 = function (err, r) { assert.equal(counter, 1); - assert.deepEqual(new bn(result2), r); + assert.deepEqual(r, result2Val); }; var callback3 = function (err, r) { counter++; assert.equal(counter, 2); - assert.deepEqual(new bn(result2), r); + assert.deepEqual(r, result2Val); done(); }; @@ -168,7 +169,7 @@ describe('lib/web3/batch', function () { }); - var batch = web3.createBatch(); + var batch = web3.createBatchRequest(); batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000022', 'latest', callback)); batch.add(new web3.eth.contract(abi, address).methods.balance(address).call.request(callback2)); batch.add(new web3.eth.contract(abi, address).methods.balance(address).call.request({from: '0x1000000000000000000000000000000000000002'}, callback2)); @@ -181,8 +182,7 @@ describe('lib/web3/batch', function () { it('should execute batch requests and receive errors', function (done) { var provider = new FakeHttpProvider(); - web3.setProvider(provider); - web3.reset(); + var web3 = new Web3(provider); var abi = [{ "name": "balance", @@ -231,7 +231,7 @@ describe('lib/web3/batch', function () { '0xa']); }); - var batch = web3.createBatch(); + var batch = web3.createBatchRequest(); batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback)); batch.add(new web3.eth.contract(abi, address).methods.balance(address).call.request({from: '0x0000000000000000000000000000000000000000'},10, callback2)); provider.injectBatchResults([result, result2], true); // injects error diff --git a/test/coder.decodeParam.js b/test/coder.decodeParam.js_ similarity index 100% rename from test/coder.decodeParam.js rename to test/coder.decodeParam.js_ diff --git a/test/coder.encodeParam.js b/test/coder.encodeParam.js_ similarity index 100% rename from test/coder.encodeParam.js rename to test/coder.encodeParam.js_ diff --git a/test/contract.js b/test/contract.js index cfbdbff..a9188b5 100644 --- a/test/contract.js +++ b/test/contract.js @@ -1,11 +1,8 @@ var chai = require('chai'); var assert = chai.assert; -var Web3 = require('../index'); +var Eth = require('../packages/web3-eth'); +var sha3 = require('../packages/web3-utils').sha3; var FakeHttpProvider = require('./helpers/FakeHttpProvider'); -var eventifiedPromise = require('../lib/web3/eventifiedPromise.js'); -var utils = require('../lib/utils/utils'); -var BigNumber = require('bignumber.js'); -var sha3 = require('../lib/utils/sha3'); var abi = [{ @@ -91,9 +88,9 @@ describe('contract', function () { describe('internal method', function () { it('_encodeEventABI should return the encoded event object without topics', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var result = contract._encodeEventABI({ signature: '0x1234', @@ -120,9 +117,9 @@ describe('contract', function () { }); it('_encodeEventABI should return the encoded event object with topics', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var result = contract._encodeEventABI({ signature: '0x1234', @@ -150,9 +147,9 @@ describe('contract', function () { }); it('_encodeEventABI should return the encoded event object with topics and multiple choices', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var result = contract._encodeEventABI({ signature: '0x1234', @@ -182,13 +179,13 @@ describe('contract', function () { }); it('_decodeEventABI should return the decoded event object with topics', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'Changed(address,uint256,uint256,uint256)'; - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var result = contract._decodeEventABI.call({ - signature: '0x'+ sha3(signature), + signature: sha3(signature), "name":"Changed", "type":"event", "inputs": [ @@ -200,7 +197,7 @@ describe('contract', function () { }, { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -226,10 +223,10 @@ describe('contract', function () { }); it('_decodeMethodReturn should return the decoded values', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'Changed(address,uint256,uint256,uint256)'; - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var result = contract._decodeMethodReturn([{ "name": "myAddress", @@ -245,72 +242,15 @@ describe('contract', function () { done(); }); - it('_methodReturnCallback should subscribe and check for receipts and code if a contract was deployed', function (done) { - var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); - - provider.injectValidation(function (payload) { - assert.equal(payload.method, 'eth_subscribe'); - assert.deepEqual(payload.params, ['newBlocks', {}]); - }); - provider.injectResult('0x1234567'); - - // fake newBlock - provider.injectNotification({ - method: 'eth_subscription', - params: { - subscription: '0x1234567', - result: { - blockNumber: '0x10' - } - } - }); - - provider.injectValidation(function (payload) { - assert.equal(payload.method, 'eth_getTransactionReceipt'); - assert.deepEqual(payload.params, ['0x1234000000000000000000000000000000000000000000000000000000056789']); - }); - provider.injectResult({ - contractAddress: address, - cumulativeGasUsed: '0xa', - transactionIndex: '0x3', - blockNumber: '0xa' - }); - provider.injectValidation(function (payload) { - assert.equal(payload.method, 'eth_getCode'); - assert.deepEqual(payload.params, [address, 'latest']); - }); - provider.injectResult('0x321'); - - - var contract = new web3.eth.contract(abi, address); - var defer = eventifiedPromise(); - - defer.promise.then(function (result) { - - assert.equal(result.contractAddress, address); - assert.equal(result.blockNumber, 10); - assert.equal(result.transactionIndex, 3); - assert.equal(result.cumulativeGasUsed, 10); - - done(); - }); - - contract._methodReturnCallback.call({ - _parent: contract, - _deployData: '0x12345' - }, defer, null, 'send', null, '0x1234000000000000000000000000000000000000000000000000000000056789') - - }); it('_executeMethod should sendTransaction and check for receipts', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); - var signature = sha3('mySend(address,uint256)').slice(0, 8); + var eth = new Eth(provider); + var signature = sha3('mySend(address,uint256)').slice(0, 10); provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_sendTransaction'); assert.deepEqual(payload.params, [{ - data: "0x"+ signature +"0000000000000000000000001234567890123456789012345678901234567891000000000000000000000000000000000000000000000000000000000000000a", + data: signature +"0000000000000000000000001234567890123456789012345678901234567891000000000000000000000000000000000000000000000000000000000000000a", from: address2, to: address }]); @@ -319,7 +259,7 @@ describe('contract', function () { provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_subscribe'); - assert.deepEqual(payload.params, ['newBlocks', {}]); + assert.deepEqual(payload.params, ['newHeads']); }); provider.injectResult('0x1234567'); @@ -351,7 +291,7 @@ describe('contract', function () { provider.injectResult('0x321'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var txObject = {}; txObject._method = { @@ -389,13 +329,13 @@ describe('contract', function () { }); it('_executeMethod should call and return values', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); - var signature = sha3('balance(address)').slice(0, 8); + var eth = new Eth(provider); + var signature = sha3('balance(address)').slice(0, 10); provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: "0x"+ signature +"0000000000000000000000001234567890123456789012345678901234567891", + data: signature +"0000000000000000000000001234567890123456789012345678901234567891", from: address2, to: address }, 'latest']); @@ -403,7 +343,7 @@ describe('contract', function () { provider.injectResult('0x000000000000000000000000000000000000000000000000000000000000000a'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var txObject = {}; txObject._method = { @@ -425,10 +365,10 @@ describe('contract', function () { txObject.arguments = [address]; var deploy = contract._executeMethod.call(txObject, 'call', {from: address2}, function (err, result) { - assert.deepEqual(result, new BigNumber(0xa)); + assert.equal(result, '10'); }) .then(function(result){ - assert.deepEqual(result, new BigNumber(0xa)); + assert.equal(result, '10'); done(); }); @@ -438,14 +378,14 @@ describe('contract', function () { describe('event', function () { it('should create event subscription', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'Changed(address,uint256,uint256,uint256)'; provider.injectValidation(function (payload) { assert.equal(payload.jsonrpc, '2.0'); assert.equal(payload.method, 'eth_subscribe'); assert.deepEqual(payload.params[1], { topics: [ - '0x' + sha3(signature), + sha3(signature), ('0x000000000000000000000000' + address.replace('0x', '')), null ], @@ -467,7 +407,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), ('0x000000000000000000000000' + address.replace('0x', '')), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -481,7 +421,7 @@ describe('contract', function () { } }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var event = contract.events.Changed({filter: {from: address}}, function (err, result, sub) { assert.equal(result.returnValues.from, address); @@ -496,7 +436,7 @@ describe('contract', function () { it('should create event from the events object and use the fromBlock option', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'Changed(address,uint256,uint256,uint256)'; provider.injectValidation(function (payload) { @@ -506,7 +446,7 @@ describe('contract', function () { provider.injectResult([{ address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000002' ], @@ -520,7 +460,7 @@ describe('contract', function () { { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000003' ], @@ -537,7 +477,7 @@ describe('contract', function () { assert.equal(payload.method, 'eth_subscribe'); assert.deepEqual(payload.params[1], { topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), null ], @@ -560,7 +500,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -574,7 +514,7 @@ describe('contract', function () { } }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var count = 0; var event = contract.events.Changed({fromBlock: 0,filter: {from: address}}) .on('data', function (result) { @@ -609,7 +549,7 @@ describe('contract', function () { it('should create event from the events object using a signature and callback', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'Changed(address,uint256,uint256,uint256)'; provider.injectValidation(function (payload) { @@ -617,7 +557,7 @@ describe('contract', function () { assert.equal(payload.method, 'eth_subscribe'); assert.deepEqual(payload.params[1], { topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), null ], @@ -640,7 +580,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -654,7 +594,7 @@ describe('contract', function () { } }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var event = contract.events['0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651']({filter: {from: address}}, function (err, result) { assert.equal(result.returnValues.from, address); assert.equal(result.returnValues.amount, 1); @@ -667,7 +607,7 @@ describe('contract', function () { it('should create event from the events object using event name and parameters', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'Changed(address,uint256,uint256,uint256)'; provider.injectValidation(function (payload) { @@ -675,7 +615,7 @@ describe('contract', function () { assert.equal(payload.method, 'eth_subscribe'); assert.deepEqual(payload.params[1], { topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), null ], @@ -698,7 +638,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -712,7 +652,7 @@ describe('contract', function () { } }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var event = contract.events[signature]({filter: {from: address}}, function (err, result) { assert.equal(result.returnValues.from, address); assert.equal(result.returnValues.amount, 1); @@ -725,7 +665,7 @@ describe('contract', function () { it('should create event using the once function and unsubscribe after one log received', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'Changed(address,uint256,uint256,uint256)'; provider.injectValidation(function (payload) { @@ -733,7 +673,7 @@ describe('contract', function () { assert.equal(payload.method, 'eth_subscribe'); assert.deepEqual(payload.params[1], { topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), null ], @@ -755,7 +695,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -776,7 +716,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -791,7 +731,7 @@ describe('contract', function () { }); var count = 1; - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var event = contract.once('Changed', {filter: {from: address}}, function (err, result) { assert.equal(result.returnValues.from, address); assert.equal(result.returnValues.amount, 1); @@ -808,7 +748,7 @@ describe('contract', function () { it('should create event using the once function and unsubscribe after one log received using the event emitter', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'Changed(address,uint256,uint256,uint256)'; provider.injectValidation(function (payload) { @@ -816,7 +756,7 @@ describe('contract', function () { assert.equal(payload.method, 'eth_subscribe'); assert.deepEqual(payload.params[1], { topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), null ], @@ -838,7 +778,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -859,7 +799,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -874,7 +814,7 @@ describe('contract', function () { }); var count = 1; - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var event = contract.once('Changed', {filter: {from: address}}) .on('data', function (result) { assert.equal(result.returnValues.from, address); @@ -895,7 +835,7 @@ describe('contract', function () { it('should create all event filter and receive two logs', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'Changed(address,uint256,uint256,uint256)'; provider.injectValidation(function (payload) { @@ -916,7 +856,7 @@ describe('contract', function () { provider.injectResult(true); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); var count = 0; var event = contract.events.allEvents(function (err, result) { @@ -946,7 +886,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3('Changed(address,uint256,uint256,uint256)'), + sha3('Changed(address,uint256,uint256,uint256)'), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000001' ], @@ -968,7 +908,7 @@ describe('contract', function () { result: { address: address, topics: [ - '0x' + sha3('Unchanged(uint256,address,uint256)'), + sha3('Unchanged(uint256,address,uint256)'), '0x0000000000000000000000000000000000000000000000000000000000000002', '0x000000000000000000000000'+ address.replace('0x','') ], @@ -985,15 +925,15 @@ describe('contract', function () { describe('with methods', function () { it('should change the address', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + '0000000000000000000000001234567890123456789012345678901234567891', + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891', to: address, from: address2 }, 'latest']); @@ -1007,7 +947,7 @@ describe('contract', function () { provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + '0000000000000000000000001234567890123456789012345678901234567891', + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891', to: address2, from: address }, 'latest']); @@ -1018,9 +958,9 @@ describe('contract', function () { it('should reset functions when resetting json interface', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); - var contract = new web3.eth.contract(abi); + var contract = new eth.contract(abi); assert.isFunction(contract.methods.mySend); assert.isFunction(contract.events.Changed); @@ -1055,22 +995,22 @@ describe('contract', function () { it('should encode a function call', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; - var contract = new web3.eth.contract(abi); + var contract = new eth.contract(abi); var result = contract.methods.balance(address).encodeABI(); - assert.equal(result, '0x' + sha3(signature).slice(0, 8) + '0000000000000000000000001234567890123456789012345678901234567891'); + assert.equal(result, sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891'); }); it('should encode a constructor call with pre set data', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; - var contract = new web3.eth.contract(abi, {data: '0x1234'}); + var contract = new eth.contract(abi, {data: '0x1234'}); var result = contract.deploy({ arguments: [address, 10] @@ -1081,10 +1021,10 @@ describe('contract', function () { it('should encode a constructor call with passed data', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; - var contract = new web3.eth.contract(abi); + var contract = new eth.contract(abi); var result = contract.deploy({ arguments: [address, 10], @@ -1097,19 +1037,19 @@ describe('contract', function () { it('should estimate a function', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_estimateGas'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + '0000000000000000000000001234567890123456789012345678901234567891', + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891', to: address }]); }); provider.injectResult('0x0000000000000000000000000000000000000000000000000000000000000032'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.balance(address).estimateGas(function (err, res) { assert.deepEqual(res, 50); @@ -1119,7 +1059,7 @@ describe('contract', function () { it('should estimate the constructor', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; provider.injectValidation(function (payload) { @@ -1130,7 +1070,7 @@ describe('contract', function () { }); provider.injectResult('0x000000000000000000000000000000000000000000000000000000000000000a'); - var contract = new web3.eth.contract(abi, address, {data: '0x1234'}); + var contract = new eth.contract(abi, address, {data: '0x1234'}); contract.deploy({ arguments: [address, 50] @@ -1142,58 +1082,58 @@ describe('contract', function () { it('should call constant function', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + '0000000000000000000000001234567890123456789012345678901234567891', + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891', to: address }, 'latest']); }); provider.injectResult('0x0000000000000000000000000000000000000000000000000000000000000032'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.balance(address).call(function (err, res) { - assert.deepEqual(new BigNumber(0x32), res); + assert.deepEqual(res, '50'); done(); }); }); it('should call constant function with default block', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + '0000000000000000000000001234567890123456789012345678901234567891', + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891', to: address }, '0xb']); }); provider.injectResult('0x0000000000000000000000000000000000000000000000000000000000000032'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.balance(address).call(11) .then(function (r) { - assert.deepEqual(new BigNumber(0x32), r); + assert.deepEqual(r, '50'); done(); }); }); it('should sendTransaction to contract function', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'mySend(address,uint256)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_sendTransaction'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891' + '0000000000000000000000000000000000000000000000000000000000000011' , from: address, @@ -1201,16 +1141,16 @@ describe('contract', function () { }]); }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.mySend(address, 17).send({from: address}); }); it('should throw error when trying to send ether to a non payable contract function', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); try{ contract.methods.myDisallowedSend(address, 17).send({from: address, value: 123}) @@ -1228,13 +1168,13 @@ describe('contract', function () { it('should not throw error when trying to not send ether to a non payable contract function', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'myDisallowedSend(address,uint256)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_sendTransaction'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891' + '0000000000000000000000000000000000000000000000000000000000000011' , from: address, @@ -1244,7 +1184,7 @@ describe('contract', function () { done(); }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); try{ contract.methods.myDisallowedSend(address, 17).send({from: address}) @@ -1263,8 +1203,8 @@ describe('contract', function () { it('should sendTransaction to contract function using the function namen incl. parameters', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); - var signature = '0x'+ sha3('mySend(address,uint256)').slice(0, 8); + var eth = new Eth(provider); + var signature = sha3('mySend(address,uint256)').slice(0, 10); provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_sendTransaction'); @@ -1277,15 +1217,15 @@ describe('contract', function () { }]); }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods['mySend(address,uint256)'](address, 17).send({from: address}); }); it('should sendTransaction to contract function using the signature', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); - var signature = '0x'+ sha3('mySend(address,uint256)').slice(0, 8); + var eth = new Eth(provider); + var signature = sha3('mySend(address,uint256)').slice(0, 10); provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_sendTransaction'); @@ -1298,14 +1238,14 @@ describe('contract', function () { }]); }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods[signature](address, 17).send({from: address}); }); it('should make a call with optional params', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; var count = 0; @@ -1316,7 +1256,7 @@ describe('contract', function () { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + '0000000000000000000000001234567890123456789012345678901234567891', + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891', to: address, from: address, gas: '0xc350' @@ -1325,24 +1265,24 @@ describe('contract', function () { provider.injectResult('0x0000000000000000000000000000000000000000000000000000000000000032'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.balance(address).call({from: address, gas: 50000}) .then(function (r) { - assert.deepEqual(new BigNumber(0x32), r); + assert.deepEqual(r, '50'); done(); }); }); it('should explicitly make a call with optional params', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + '0000000000000000000000001234567890123456789012345678901234567891', + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891', to: address, from: address, gas: '0xc350' @@ -1350,11 +1290,11 @@ describe('contract', function () { }); provider.injectResult('0x0000000000000000000000000000000000000000000000000000000000000032'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.balance(address).call({from: address, gas: 50000}) .then(function (r) { - assert.deepEqual(new BigNumber(0x32), r); + assert.deepEqual(r, '50'); done(); }); @@ -1362,13 +1302,13 @@ describe('contract', function () { it('should explicitly make a call with optional params and defaultBlock', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'balance(address)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + '0000000000000000000000001234567890123456789012345678901234567891', + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891', to: address, from: address, gas: '0xc350' @@ -1376,11 +1316,11 @@ describe('contract', function () { }); provider.injectResult('0x0000000000000000000000000000000000000000000000000000000000000032'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.balance(address).call({from: address, gas: 50000}, 11) .then(function (r) { - assert.deepEqual(new BigNumber(0x32), r); + assert.deepEqual(r, '50'); done(); }); @@ -1388,13 +1328,13 @@ describe('contract', function () { it('should sendTransaction with optional params', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'mySend(address,uint256)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_sendTransaction'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891' + '0000000000000000000000000000000000000000000000000000000000000011' , to: address, @@ -1405,20 +1345,20 @@ describe('contract', function () { }]); }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.mySend(address, 17).send({from: address, gas: 50000, gasPrice: 3000, value: 10000}); }); it('should explicitly sendTransaction with optional params', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'mySend(address,uint256)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_sendTransaction'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891' + '0000000000000000000000000000000000000000000000000000000000000011' , to: address, @@ -1429,21 +1369,21 @@ describe('contract', function () { }]); }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.mySend(address, 17).send({from: address, gas: 50000, gasPrice: 3000, value: 10000}); }); it('should explicitly call sendTransaction with optional params and call callback without error', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'mySend(address,uint256)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_sendTransaction'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891' + '0000000000000000000000000000000000000000000000000000000000000011' , to: address, @@ -1454,7 +1394,7 @@ describe('contract', function () { }]); }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.mySend(address, 17).send({from: address, gas: 50000, gasPrice: 3000, value: 10000}, function (err) { assert.equal(err, null); @@ -1464,13 +1404,13 @@ describe('contract', function () { it('should explicitly estimateGas with optional params', function () { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'mySend(address,uint256)'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_estimateGas'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + + data: sha3(signature).slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567891' + '0000000000000000000000000000000000000000000000000000000000000011' , to: address, @@ -1481,14 +1421,14 @@ describe('contract', function () { }]); }); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.mySend(address, 17).estimateGas({from: address, gas: 50000, gasPrice: 3000, value: 10000}); }); it('getPastEvents should get past events and format them correctly', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'testArr(int[])'; provider.injectValidation(function (payload) { @@ -1504,12 +1444,12 @@ describe('contract', function () { }); var topic1 = [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x000000000000000000000000000000000000000000000000000000000000000a' ]; var topic2 = [ - '0x' + sha3(signature), + sha3(signature), '0x000000000000000000000000'+ address.replace('0x',''), '0x0000000000000000000000000000000000000000000000000000000000000003' ]; @@ -1535,7 +1475,7 @@ describe('contract', function () { '0000000000000000000000000000000000000000000000000000000000000005' }]); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.getPastEvents('Changed', {filter: {from: address2}}) .then(function (result) { @@ -1553,9 +1493,9 @@ describe('contract', function () { '0000000000000000000000000000000000000000000000000000000000000009', returnValues: { from: address, - amount: new BigNumber(0xa), - t1: new BigNumber(0x2), - t2: new BigNumber(0x9), + amount: '10', + t1: '2', + t2: '9' } }, { @@ -1572,26 +1512,26 @@ describe('contract', function () { '0000000000000000000000000000000000000000000000000000000000000005', returnValues: { from: address, - amount: new BigNumber(0x3), - t1: new BigNumber(0x4), - t2: new BigNumber(0x5), + amount: '3', + t1: '4', + t2: '5' } }]); done(); - }); + }).catch(done); }); it('should call testArr method and properly parse result', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'testArr(int[])'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + + data: sha3(signature).slice(0, 10) + '0000000000000000000000000000000000000000000000000000000000000020' + '0000000000000000000000000000000000000000000000000000000000000001' + '0000000000000000000000000000000000000000000000000000000000000003', @@ -1603,10 +1543,10 @@ describe('contract', function () { provider.injectResult('0x0000000000000000000000000000000000000000000000000000000000000005'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.testArr([3]).call() .then(function (result) { - assert.deepEqual(new BigNumber(5), result); + assert.deepEqual(result, '5'); done(); }); @@ -1614,13 +1554,13 @@ describe('contract', function () { it('should call testArr method, properly parse result and return the result in a callback', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); var signature = 'testArr(int[])'; provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_call'); assert.deepEqual(payload.params, [{ - data: '0x' + sha3(signature).slice(0, 8) + + data: sha3(signature).slice(0, 10) + '0000000000000000000000000000000000000000000000000000000000000020' + '0000000000000000000000000000000000000000000000000000000000000001' + '0000000000000000000000000000000000000000000000000000000000000003', @@ -1631,10 +1571,10 @@ describe('contract', function () { }); provider.injectResult('0x0000000000000000000000000000000000000000000000000000000000000005'); - var contract = new web3.eth.contract(abi, address); + var contract = new eth.contract(abi, address); contract.methods.testArr([3]).call(function (err, result) { - assert.deepEqual(new BigNumber(5), result); + assert.deepEqual(result, '5'); done(); }); @@ -1643,9 +1583,9 @@ describe('contract', function () { describe('with data', function () { it('should deploy a contract and use callback', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); - provider.injectValidation(function () {}); + provider.injectResult('0x1234567'); provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_sendTransaction'); @@ -1657,7 +1597,7 @@ describe('contract', function () { }]); }); - var contract = new web3.eth.contract(abi); + var contract = new eth.contract(abi); contract.deploy({ data: '0x1234567', @@ -1666,15 +1606,16 @@ describe('contract', function () { from: address, gas: 50000, gasPrice: 3000 - }, function (err) { + }, function (err, result) { assert.equal(err, null); + assert.equal(result, '0x1234567'); done(); }); }); it('should deploy a contract and use all promise steps', function (done) { var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); + var eth = new Eth(provider); provider.injectValidation(function (payload) { @@ -1691,7 +1632,7 @@ describe('contract', function () { provider.injectValidation(function (payload) { assert.equal(payload.method, 'eth_subscribe'); - assert.deepEqual(payload.params, ['newBlocks', {}]); + assert.deepEqual(payload.params, ['newHeads']); }); provider.injectResult('0x1234567'); @@ -1720,7 +1661,7 @@ describe('contract', function () { provider.injectResult('0x321'); - var contract = new web3.eth.contract(abi); + var contract = new eth.contract(abi); contract.deploy({ data: '0x1234567', diff --git a/test/errors.js b/test/errors.js index 3ed3c85..b983c65 100644 --- a/test/errors.js +++ b/test/errors.js @@ -1,13 +1,14 @@ var chai = require('chai'); var assert = chai.assert; -var errors = require('../lib/web3/errors'); + +var errors = require('../packages/web3-core-helpers/src/errors.js'); describe('lib/web3/method', function () { describe('getCall', function () { for(var key in errors) { it('should return and error', function () { - + assert.instanceOf(errors[key](), Error); }); } diff --git a/test/event.decode.js b/test/event.decode.js index 63c2097..8b6d520 100644 --- a/test/event.decode.js +++ b/test/event.decode.js @@ -1,16 +1,16 @@ var chai = require('chai'); var assert = chai.assert; -var BigNumber = require('bignumber.js'); -var SolidityEvent = require('../lib/web3/events'); -var Web3 = require('../index'); +var Eth = require('../packages/web3-eth/'); var name = 'event1'; -var address = '0x1234567890123456789012345678901234567890'; +var address = '0xffddb67890123456789012345678901234567890'; +var resultAddress = '0xffdDb67890123456789012345678901234567890'; var tests = [{ abi: { name: name, + type: 'event', inputs: [] }, data: { @@ -27,9 +27,12 @@ var tests = [{ logIndex: 1, transactionIndex: 16, transactionHash: '0x1234567890', - address: address, + address: resultAddress, blockHash: '0x1234567890', - blockNumber: 1 + blockNumber: 1, + id: "log_c71f2e84", + data: '', + topics: [] } }, { abi: { @@ -52,14 +55,17 @@ var tests = [{ expected: { event: name, returnValues: { - a: new BigNumber(1) + a: '1' }, logIndex: 1, transactionIndex: 16, transactionHash: '0x1234567890', - address: address, + address: resultAddress, blockHash: '0x1234567890', - blockNumber: 1 + blockNumber: 1, + topics: [], + data: "0x0000000000000000000000000000000000000000000000000000000000000001", + id: "log_c71f2e84" } }, { abi: { @@ -89,11 +95,11 @@ var tests = [{ address: address, blockHash: '0x1234567890', blockNumber: '0x1', - data: '0x' + - '0000000000000000000000000000000000000000000000000000000000000001' + + data: '0x' + + '0000000000000000000000000000000000000000000000000000000000000001' + '0000000000000000000000000000000000000000000000000000000000000004', topics: [ - address, + address, '0x000000000000000000000000000000000000000000000000000000000000000a', '0x0000000000000000000000000000000000000000000000000000000000000010' ] @@ -101,17 +107,26 @@ var tests = [{ expected: { event: name, returnValues: { - a: new BigNumber(1), - b: new BigNumber(10), - c: new BigNumber(4), - d: new BigNumber(16) + a: '1', + b: '10', + c: '4', + d: '16' }, logIndex: 1, transactionIndex: 16, transactionHash: '0x1234567890', - address: address, + address: resultAddress, blockHash: '0x1234567890', - blockNumber: 1 + blockNumber: 1, + id: "log_c71f2e84", + data: '0x' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000004', + topics: [ + address, + '0x000000000000000000000000000000000000000000000000000000000000000a', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] } }, { abi: { @@ -139,11 +154,11 @@ var tests = [{ logIndex: '0x1', transactionIndex: '0x10', transactionHash: '0x1234567890', - address: address, + address: resultAddress, blockHash: '0x1234567890', blockNumber: '0x1', - data: '0x' + - '0000000000000000000000000000000000000000000000000000000000000001' + + data: '0x' + + '0000000000000000000000000000000000000000000000000000000000000001' + '0000000000000000000000000000000000000000000000000000000000000004', topics: [ '0x000000000000000000000000000000000000000000000000000000000000000a', @@ -153,17 +168,25 @@ var tests = [{ expected: { event: name, returnValues: { - a: new BigNumber(1), - b: new BigNumber(10), - c: new BigNumber(4), - d: new BigNumber(16) + a: '1', + b: '10', + c: '4', + d: '16' }, logIndex: 1, transactionIndex: 16, transactionHash: '0x1234567890', - address: address, + address: resultAddress, blockHash: '0x1234567890', - blockNumber: 1 + blockNumber: 1, + id: "log_c71f2e84", + data: '0x' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000004', + topics: [ + '0x000000000000000000000000000000000000000000000000000000000000000a', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] } }]; @@ -171,10 +194,10 @@ describe('lib/web3/event', function () { describe('decode', function () { tests.forEach(function (test, index) { it('test no: ' + index, function () { - var web3 = new Web3(); - var event = new SolidityEvent(web3, test.abi, address); + var eth = new Eth(); + var contract = new eth.contract([test.abi], address); - var result = event.decode(test.data); + var result = contract._decodeEventABI.call(test.abi, test.data); assert.deepEqual(result, test.expected); }); }); diff --git a/test/event.encode.js b/test/event.encode.js index 9775315..49dd1db 100644 --- a/test/event.encode.js +++ b/test/event.encode.js @@ -1,7 +1,6 @@ var chai = require('chai'); var assert = chai.assert; -var SolidityEvent = require('../lib/web3/events'); -var Web3 = require('../index'); +var Eth = require('../packages/web3-eth'); var address = '0x1234567890123456789012345678901234567890'; @@ -10,7 +9,8 @@ var signature = '0xffff'; var tests = [{ abi: { name: 'event1', - inputs: [] + inputs: [], + signature: signature }, options: {}, expected: { @@ -26,7 +26,8 @@ var tests = [{ type: 'int', name: 'a', indexed: true - }] + }], + signature: signature }, options: { filter: { @@ -59,7 +60,8 @@ var tests = [{ type: 'int', name: 'd', indexed: true - }] + }], + signature: signature }, options: { filter: { @@ -86,7 +88,8 @@ var tests = [{ type: 'int', name: 'b', indexed: true - }] + }], + signature: signature }, options: { filter: { @@ -109,7 +112,8 @@ var tests = [{ type: 'int', name: 'a', indexed: true - }] + }], + signature: signature }, options: { filter: { @@ -130,7 +134,8 @@ var tests = [{ type: 'int', name: 'a', indexed: true - }] + }], + signature: signature }, options: { filter: { @@ -156,7 +161,8 @@ var tests = [{ type: 'int', name: 'a', indexed: true - }] + }], + signature: signature }, options: { filter: { @@ -182,7 +188,8 @@ var tests = [{ name: 'a', indexed: true }], - anonymous: true + anonymous: true, + signature: signature }, options: { filter: { @@ -207,7 +214,8 @@ var tests = [{ name: 'b', indexed: true }], - anonymous: true + anonymous: true, + signature: signature }, options: { filter: { @@ -227,13 +235,11 @@ describe('lib/web3/event', function () { describe('encode', function () { tests.forEach(function (test, index) { it('test no: ' + index, function () { - var web3 = new Web3(); - var event = new SolidityEvent(web3, test.abi, address); - event.signature = function () { // inject signature - return signature.slice(2); - }; + var eth = new Eth(); + var contract = new eth.contract([test.abi], address); - var result = event.encode(test.options); + + var result = contract._encodeEventABI(test.abi, test.options); assert.deepEqual(result, test.expected); }); }); diff --git a/test/formatters.inputAddressFormatter.js b/test/formatters.inputAddressFormatter.js index 42cfc3f..d18e1c9 100644 --- a/test/formatters.inputAddressFormatter.js +++ b/test/formatters.inputAddressFormatter.js @@ -1,13 +1,13 @@ var chai = require('chai'); var assert = chai.assert; -var formatters = require('../lib/web3/formatters.js'); -var BigNumber = require('bignumber.js'); +var formatters = require('../packages/web3-core-helpers/src/formatters.js'); var tests = [ - { input: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', result: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8' }, + { input: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', result: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8' }, { input: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', result: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8'}, { input: '00c5496aee77c1ba1f0854206a26dda82a81d6d8', result: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8'}, - { input: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', result: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae' } + { input: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', result: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae' }, + { input: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', result: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae' } ]; var errorTests = [ @@ -15,11 +15,12 @@ var errorTests = [ '0x0c5496aee77c1ba1f0854206a26dda82a81d6d8', '00c5496aee77c1ba1f0854206a26dda82a81d6d', 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZE', - '0x' + '0x', + '0x11f4d0a3c12e86B4b5F39b213f7E19D048276DAe' ] describe('formatters', function () { - describe('inputAddressFormatter', function () { + describe('inputAddressFormatter correct addresses', function () { tests.forEach(function(test){ it('should return the correct value', function () { assert.deepEqual(formatters.inputAddressFormatter(test.input), test.result); @@ -30,12 +31,12 @@ describe('formatters', function () { describe('formatters', function () { - describe('inputAddressFormatter', function () { + describe('inputAddressFormatter wrong addresses', function () { errorTests.forEach(function(test){ it('should throw an exception', function () { assert.throws(function () { formatters.inputAddressFormatter(test); - }); + }, null, null, 'Should throw:'+ test); }); }); }); diff --git a/test/formatters.inputDefaultBlockFormatter.js b/test/formatters.inputDefaultBlockFormatter.js index 8ae5ea2..afc0eb3 100644 --- a/test/formatters.inputDefaultBlockFormatter.js +++ b/test/formatters.inputDefaultBlockFormatter.js @@ -1,6 +1,6 @@ var chai = require('chai'); var assert = chai.assert; -var formatters = require('../lib/web3/formatters'); +var formatters = require('../packages/web3-core-helpers/src/formatters.js'); var tests = [ { value: 'latest', expected: 'latest' }, diff --git a/test/formatters.inputPostFormatter.js b/test/formatters.inputPostFormatter.js index f583b4b..5497eb4 100644 --- a/test/formatters.inputPostFormatter.js +++ b/test/formatters.inputPostFormatter.js @@ -1,6 +1,6 @@ var chai = require('chai'); var assert = chai.assert; -var formatters = require('../lib/web3/formatters.js'); +var formatters = require('../packages/web3-core-helpers/src/formatters.js'); describe('formatters', function () { describe('inputPostFormatter', function () { @@ -13,7 +13,8 @@ describe('formatters', function () { payload: '0x7b2274657374223a2274657374227d',//{test: 'test'}, ttl: 200, priority: 1000, - topics: ['hello','mytopics'] + topics: ['hello','mytopics'], + "workToProve": 1 }), { from: '0x00000', to: '0x00000', @@ -21,7 +22,7 @@ describe('formatters', function () { ttl: '0xc8', priority: '0x3e8', topics: ['0x68656c6c6f','0x6d79746f70696373'], - workToProve: '0x0' + workToProve: '0x1' }); }); diff --git a/test/formatters.inputTransactionFormatter.js b/test/formatters.inputTransactionFormatter.js index 5f81ee9..f5d6a29 100644 --- a/test/formatters.inputTransactionFormatter.js +++ b/test/formatters.inputTransactionFormatter.js @@ -1,23 +1,22 @@ var chai = require('chai'); var assert = chai.assert; -var formatters = require('../lib/web3/formatters.js'); -var BigNumber = require('bignumber.js'); +var formatters = require('../packages/web3-core-helpers/src/formatters.js'); var tests = [{ input: { data: '0x34234bf23bf4234', - value: new BigNumber(100), - from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', - to: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', + value: '100', + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // checksum address + to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', nonce: 1000, gas: 1000, - gasPrice: new BigNumber(1000) + gasPrice: '1000' }, result: { data: '0x34234bf23bf4234', value: '0x64', - from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', - to: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', nonce: '0x3e8', gas: '0x3e8', gasPrice: '0x3e8' @@ -25,24 +24,24 @@ var tests = [{ },{ input: { data: '0x34234bf23bf4234', - value: new BigNumber(100), + value: '100', from: '00c5496aee77c1ba1f0854206a26dda82a81d6d8', - to: '00c5496aee77c1ba1f0854206a26dda82a81d6d8', + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe' // checksum address }, result: { data: '0x34234bf23bf4234', value: '0x64', from: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', - to: '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', + to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae' } },{ input: { data: '0x34234bf23bf4234', - value: new BigNumber(100), + value: '100', from: '00c5496aee77c1ba1f0854206a26dda82a81d6d8', to: '00c5496aee77c1ba1f0854206a26dda82a81d6d8', gas: '1000', - gasPrice: new BigNumber(1000) + gasPrice: '1000' }, result: { data: '0x34234bf23bf4234', @@ -55,11 +54,11 @@ var tests = [{ }, { input: { data: '0x34234bf23bf4234', - value: new BigNumber(100), + value: '100', from: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', to: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', gas: '1000', - gasPrice: new BigNumber(1000) + gasPrice: '1000' }, result: { data: '0x34234bf23bf4234', @@ -72,10 +71,10 @@ var tests = [{ }, { input: { data: '0x34234bf23bf4234', - value: new BigNumber(100), + value: '100', from: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', gas: '1000', - gasPrice: new BigNumber(1000) + gasPrice: '1000' }, result: { data: '0x34234bf23bf4234', diff --git a/test/formatters.outputBlockFormatter.js b/test/formatters.outputBlockFormatter.js index a94c87b..d6bf275 100644 --- a/test/formatters.outputBlockFormatter.js +++ b/test/formatters.outputBlockFormatter.js @@ -1,12 +1,12 @@ var chai = require('chai'); -var assert = chai.assert; -var formatters = require('../lib/web3/formatters.js'); -var BigNumber = require('bignumber.js'); +var assert = chai.assert; +var formatters = require('../packages/web3-core-helpers/src/formatters.js'); + describe('formatters', function () { describe('outputBlockFormatter', function () { it('should return the correct value', function () { - + assert.deepEqual(formatters.outputBlockFormatter({ hash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', parentHash: '0x83ffb245cfced97ccc5c75253d6960376d6c6dea93647397a543a72fdaea5265', @@ -26,12 +26,12 @@ describe('formatters', function () { }), { hash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', parentHash: '0x83ffb245cfced97ccc5c75253d6960376d6c6dea93647397a543a72fdaea5265', - miner: '0xdcc6960376d6c6dea93647383ffb245cfced97cf', + miner: '0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf', stateRoot: '0x54dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583', sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', bloom: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - difficulty: new BigNumber(1000), - totalDifficulty: new BigNumber(1000), + difficulty: '1000', + totalDifficulty: '1000', number: 1000, gasLimit: 1000, gasUsed: 1000, @@ -42,7 +42,7 @@ describe('formatters', function () { }); }); it('should return the correct value, when null values are present', function () { - + assert.deepEqual(formatters.outputBlockFormatter({ hash: null, parentHash: '0x83ffb245cfced97ccc5c75253d6960376d6c6dea93647397a543a72fdaea5265', @@ -66,8 +66,8 @@ describe('formatters', function () { stateRoot: '0x54dda68af07643f68739a6e9612ad157a26ae7e2ce81f77842bb5835fbcde583', sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', bloom: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', - difficulty: new BigNumber(1000), - totalDifficulty: new BigNumber(1000), + difficulty: '1000', + totalDifficulty: '1000', number: null, gasLimit: 1000, gasUsed: 1000, diff --git a/test/formatters.outputLogFormatter.js b/test/formatters.outputLogFormatter.js index 432bfb0..da69200 100644 --- a/test/formatters.outputLogFormatter.js +++ b/test/formatters.outputLogFormatter.js @@ -1,10 +1,10 @@ var assert = require('assert'); -var formatters = require('../lib/web3/formatters.js'); +var formatters = require('../packages/web3-core-helpers/src/formatters.js'); describe('formatters', function () { describe('outputLogFormatter', function () { it('should return the correct value', function () { - + assert.deepEqual(formatters.outputLogFormatter({ transactionIndex: '0x3e8', logIndex: '0x3e8', @@ -12,7 +12,8 @@ describe('formatters', function () { transactionHash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', blockHash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', data: '0x7b2274657374223a2274657374227', - topics: ['0x68656c6c6f','0x6d79746f70696373'] + address: "0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae", // lowercase address + topics: ['0x68656c6c6f','0x6d79746f70696373'] }), { transactionIndex: 1000, logIndex: 1000, @@ -20,11 +21,13 @@ describe('formatters', function () { transactionHash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', blockHash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', data: '0x7b2274657374223a2274657374227', - topics: ['0x68656c6c6f','0x6d79746f70696373'] + topics: ['0x68656c6c6f','0x6d79746f70696373'], + address: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", // checksum address + id: "log_2b801386" }); }); it('should return the correct value, when null values are present', function () { - + assert.deepEqual(formatters.outputLogFormatter({ transactionIndex: null, logIndex: null, @@ -32,13 +35,14 @@ describe('formatters', function () { transactionHash: null, blockHash: null, data: '0x7b2274657374223a2274657374227', - topics: ['0x68656c6c6f','0x6d79746f70696373'] + topics: ['0x68656c6c6f','0x6d79746f70696373'] }), { transactionIndex: null, logIndex: null, blockNumber: null, transactionHash: null, blockHash: null, + id: null, data: '0x7b2274657374223a2274657374227', topics: ['0x68656c6c6f','0x6d79746f70696373'] }); diff --git a/test/formatters.outputPostFormatter.js b/test/formatters.outputPostFormatter.js index 60eb53a..6db807e 100644 --- a/test/formatters.outputPostFormatter.js +++ b/test/formatters.outputPostFormatter.js @@ -1,5 +1,5 @@ var assert = require('assert'); -var formatters = require('../lib/web3/formatters.js'); +var formatters = require('../packages/web3-core-helpers/src/formatters.js'); describe('formatters', function () { describe('outputPostFormatter', function () { diff --git a/test/formatters.outputTransactionFormatter.js b/test/formatters.outputTransactionFormatter.js index db48316..38dede4 100644 --- a/test/formatters.outputTransactionFormatter.js +++ b/test/formatters.outputTransactionFormatter.js @@ -1,15 +1,14 @@ var assert = require('assert'); -var formatters = require('../lib/web3/formatters.js'); -var BigNumber = require('bignumber.js'); +var formatters = require('../packages/web3-core-helpers/src/formatters.js'); describe('formatters', function () { describe('outputTransactionFormatter', function () { it('should return the correct value', function () { - + assert.deepEqual(formatters.outputTransactionFormatter({ input: '0x3454645634534', - from: '0x00000', - to: '0x00000', + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', value: '0x3e8', gas: '0x3e8', gasPrice: '0x3e8', @@ -19,11 +18,11 @@ describe('formatters', function () { blockHash: '0xc9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9' }), { input: '0x3454645634534', - from: '0x00000', - to: '0x00000', - value: new BigNumber(1000), + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + value: '1000', gas: 1000, - gasPrice: new BigNumber(1000), + gasPrice: '1000', nonce: 11, blockNumber: 1000, blockHash: '0xc9b9cdc2092a9d6589d96662b1fd6949611163fb3910cf8a173cd060f17702f9', @@ -32,10 +31,10 @@ describe('formatters', function () { }); it('should return the correct value, when null values are present', function () { - + assert.deepEqual(formatters.outputTransactionFormatter({ input: '0x3454645634534', - from: '0x00000', + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', to: null, value: '0x3e8', gas: '0x3e8', @@ -46,11 +45,11 @@ describe('formatters', function () { blockHash: null }), { input: '0x3454645634534', - from: '0x00000', + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', to: null, - value: new BigNumber(1000), + value: 1000, gas: 1000, - gasPrice: new BigNumber(1000), + gasPrice: '1000', nonce: 11, blockNumber: null, blockHash: null, diff --git a/test/helpers/FakeHttpProvider.js b/test/helpers/FakeHttpProvider.js index 90a0dcd..5ba6a24 100644 --- a/test/helpers/FakeHttpProvider.js +++ b/test/helpers/FakeHttpProvider.js @@ -1,6 +1,6 @@ var chai = require('chai'); var assert = require('assert'); -var utils = require('../../lib/utils/utils'); +var _ = require('lodash'); @@ -33,7 +33,7 @@ var FakeHttpProvider = function () { }; FakeHttpProvider.prototype.sendSync = function (payload) { - assert.equal(utils.isArray(payload) || utils.isObject(payload), true); + assert.equal(_.isArray(payload) || _.isObject(payload), true); var error = this.getResponseOrError('error', payload); if (error) { @@ -59,8 +59,8 @@ FakeHttpProvider.prototype.send = function (payload, callback) { // else // this.countId++; - assert.equal(utils.isArray(payload) || utils.isObject(payload), true); - assert.equal(utils.isFunction(callback), true); + assert.equal(_.isArray(payload) || _.isObject(payload), true); + assert.equal(_.isFunction(callback), true); var validation = this.validation.shift(); @@ -69,7 +69,7 @@ FakeHttpProvider.prototype.send = function (payload, callback) { validation(JSON.parse(JSON.stringify(payload)), callback); } - var response = _this.getResponseOrError('response', payload); + var response = this.getResponseOrError('response', payload); var error = this.getResponseOrError('error', payload); setTimeout(function(){ @@ -87,13 +87,15 @@ FakeHttpProvider.prototype.getResponseOrError = function (type, payload) { var _this = this; var response; - if(type === 'error') + if(type === 'error') { response = this.error.shift(); - else + } else { response = this.response.shift() || this.getResponseStub(); + } + if(response) { - if(utils.isArray(response)) { + if(_.isArray(response)) { response = response.map(function(resp, index) { resp.id = payload[index] ? payload[index].id : _this.countId++; return resp; @@ -119,12 +121,7 @@ FakeHttpProvider.prototype.injectNotification = function (notification) { // this.response = response; // }; -FakeHttpProvider.prototype.injectResult = function (result) { - var response = this.getResponseStub(); - response.result = result; - this.response.push(response); -}; FakeHttpProvider.prototype.injectBatchResults = function (results, error) { var _this = this; @@ -140,11 +137,18 @@ FakeHttpProvider.prototype.injectBatchResults = function (results, error) { })); }; -FakeHttpProvider.prototype.injectError = function (error) { - var error = this.getErrorStub(); - error.error = error; // message, code +FakeHttpProvider.prototype.injectResult = function (result) { + var response = this.getResponseStub(); + response.result = result; - this.error.push(error); + this.response.push(response); +}; + +FakeHttpProvider.prototype.injectError = function (error) { + var errorStub = this.getErrorStub(); + errorStub.error = error; // message, code + + this.error.push(errorStub); }; FakeHttpProvider.prototype.injectValidation = function (callback) { diff --git a/test/helpers/test.method.js b/test/helpers/test.method.js index d95f277..f295d1f 100644 --- a/test/helpers/test.method.js +++ b/test/helpers/test.method.js @@ -1,9 +1,11 @@ var chai = require('chai'); var assert = chai.assert; -var Web3 = require('../../index'); - var FakeHttpProvider = require('./FakeHttpProvider'); -var clone = function (object) { return JSON.parse(JSON.stringify(object)); }; +var Web3 = require('../../src/index'); + +var clone = function (object) { return object ? JSON.parse(JSON.stringify(object)) : []; }; + +// TODO add tests for send transaction promiEvents var runTests = function (obj, method, tests) { @@ -12,60 +14,92 @@ var runTests = function (obj, method, tests) { describe(testName, function () { describe(method, function () { tests.forEach(function (test, index) { - it('sync test: ' + index, function () { - + it('promise test: ' + index, function (done) { + // given var provider = new FakeHttpProvider(); var web3 = new Web3(provider); - provider.injectResult(test.result); + provider.injectResult(clone(test.result)); provider.injectValidation(function (payload) { assert.equal(payload.jsonrpc, '2.0'); assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, test.formattedArgs); + assert.deepEqual(payload.params, test.formattedArgs || []); }); - var args = clone(test.args) - - // when - if (obj) { - var result = web3[obj][method].apply(web3[obj], args); - } else { - var result = web3[method].apply(web3, args); + // if notification its sendTransaction, which needs two more results, subscription and receipt + if(test.notification) { + provider.injectResult(clone(test.result)); + provider.injectResult(clone(test.result)); + // fake newBlock + provider.injectNotification(test.notification); } - // when - //var result = (obj) - //? web3[obj][method].apply(null, test.args.slice(0)) - //: web3[method].apply(null, test.args.slice(0)); - - // then - assert.deepEqual(test.formattedResult, result); + + var args = clone(test.args); + + if(test.error) { + if (obj) { + assert.throws(web3[obj][method].bind(web3[obj], args)); + } else { + assert.throws(web3[method].bind(web3, args)); + } + + done(); + + } else { + + if (obj) { + var result = web3[obj][method].apply(web3[obj], args); + } else { + var result = web3[method].apply(web3, args); + } + //var result = (obj) + //? web3[obj][method].apply(null, test.args.slice(0)) + //: web3[method].apply(null, test.args.slice(0)); + + result.then(function(result){ + assert.deepEqual(result, test.formattedResult); + done(); + }); + } + }); - - it('async test: ' + index, function (done) { - + + it('callback test: ' + index, function (done) { + // given var provider = new FakeHttpProvider(); var web3 = new Web3(provider); - provider.injectResult(test.result); + provider.injectResult(clone(test.result)); provider.injectValidation(function (payload) { assert.equal(payload.jsonrpc, '2.0'); assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, test.formattedArgs); + assert.deepEqual(payload.params, test.formattedArgs || []); }); var args = clone(test.args); - - // add callback - args.push(function (err, result) { - assert.deepEqual(test.formattedResult, result); - done(); - }); - // when - if (obj) { - web3[obj][method].apply(web3[obj], args); + if(test.error) { + if (obj) { + assert.throws(web3[obj][method].bind(web3[obj], args)); + } else { + assert.throws(web3[method].bind(web3, args)); + } + + done(); + } else { - web3[method].apply(web3, args); + // add callback + args.push(function (err, result) { + assert.deepEqual(result, test.formattedResult); + done(); + }); + + // when + if (obj) { + web3[obj][method].apply(web3[obj], args); + } else { + web3[method].apply(web3, args); + } } }); }); diff --git a/test/helpers/test.subscription.js b/test/helpers/test.subscription.js new file mode 100644 index 0000000..64585ea --- /dev/null +++ b/test/helpers/test.subscription.js @@ -0,0 +1,72 @@ +var chai = require('chai'); +var assert = chai.assert; +var FakeHttpProvider = require('./FakeHttpProvider'); +var Web3 = require('../../src/index'); +var web3 = Web3(); + + +var runTests = function (protocol, tests) { + + describe('web3.shh.subscribe', function () { + tests.forEach(function (test, index) { + it('should create a subscription for "'+ test.args[0] +'"', function (done) { + + // given + var sub; + var provider = new FakeHttpProvider(); + var web3 = new Web3(provider); + + provider.injectResult(test.firstResult); + provider.injectResult(test.secondResult); + var step = 0; + provider.injectValidation(function (payload) { + if (step === 0) { + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, protocol + '_subscribe'); + assert.deepEqual(payload.params, test.firstPayload.params); + + step++; + } else if (step === 1) { + + assert.equal(payload.method, protocol + '_unsubscribe'); + } + + }); + + // add callback + test.args.push(function(err, result) { + if (test.err) { + // todo + } else if(test.subscriptionResults) { + var subRes = test.subscriptionResults.shift(); + + assert.deepEqual(result, subRes); + } + + if(!test.subscriptionResults || !test.subscriptionResults.length) { + sub.unsubscribe(); + done(); + } + + }); + + // when + sub = web3[test.protocol].subscribe.apply(web3[test.protocol], test.args); + + // fire subscriptions + test.subscriptions.forEach(function (subscription) { + provider.injectNotification({ + method: protocol + '_subscription', + params: subscription + }); + }); + + }); + }); + }); +}; + +module.exports = { + runTests: runTests +} + diff --git a/test/httpprovider.js b/test/httpprovider.js index 70f65a9..4ebf36a 100644 --- a/test/httpprovider.js +++ b/test/httpprovider.js @@ -3,7 +3,7 @@ var assert = chai.assert; var SandboxedModule = require('sandboxed-module'); SandboxedModule.registerBuiltInSourceTransformer('istanbul'); -var HttpProvider = SandboxedModule.require('../lib/web3/providers/httpprovider', { +var HttpProvider = SandboxedModule.require('../packages/web3-core-requestmanager/src/providers/httpprovider', { requires: { 'xhr2': require('./helpers/FakeXHR2'), 'xmlhttprequest': require('./helpers/FakeXMLHttpRequest') diff --git a/test/iban.createIndirect.js b/test/iban.createIndirect.js index cce4a08..6544be9 100644 --- a/test/iban.createIndirect.js +++ b/test/iban.createIndirect.js @@ -1,5 +1,6 @@ var chai = require('chai'); -var Iban = require('../lib/web3/iban.js'); +var Iban = require('../packages/web3-core-iban'); + var assert = chai.assert; var tests = [ @@ -15,7 +16,7 @@ describe('lib/web3/iban', function () { identifier: test.identifier }), new Iban(test.expected)); }); - }); + }); }); }); diff --git a/test/iban.fromAddress.js b/test/iban.fromAddress.js index c1cea67..308940a 100644 --- a/test/iban.fromAddress.js +++ b/test/iban.fromAddress.js @@ -1,5 +1,6 @@ var chai = require('chai'); -var Iban = require('../lib/web3/iban.js'); +var Iban = require('../packages/web3-core-iban'); + var assert = chai.assert; var tests = [ @@ -16,7 +17,7 @@ describe('lib/web3/iban', function () { it('shoud create indirect iban: ' + test.expected, function () { assert.deepEqual(Iban.fromAddress(test.address), new Iban(test.expected)); }); - }); + }); }); }); diff --git a/test/iban.isValid.js b/test/iban.isValid.js index 31ea0d6..e1a42f4 100644 --- a/test/iban.isValid.js +++ b/test/iban.isValid.js @@ -1,5 +1,6 @@ var chai = require('chai'); -var Iban = require('../lib/web3/iban.js'); +var Iban = require('../packages/web3-core-iban'); + var assert = chai.assert; var tests = [ @@ -29,7 +30,7 @@ describe('lib/web3/iban', function () { it('shoud test if value ' + test.obj + ' is iban: ' + test.is, function () { assert.equal(Iban.isValid(test.obj), test.is); }); - }); + }); }); }); diff --git a/test/iban.toAddress.js b/test/iban.toAddress.js index 09a166a..9323151 100644 --- a/test/iban.toAddress.js +++ b/test/iban.toAddress.js @@ -1,9 +1,10 @@ var chai = require('chai'); -var Iban = require('../lib/web3/iban.js'); +var Iban = require('../packages/web3-core-iban'); + var assert = chai.assert; var tests = [ - { direct: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', address: '00c5496aee77c1ba1f0854206a26dda82a81d6d8'} + { direct: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', address: '0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8'} ]; describe('lib/web3/iban', function () { @@ -13,7 +14,7 @@ describe('lib/web3/iban', function () { var iban = new Iban(test.direct); assert.deepEqual(iban.address(), test.address); }); - }); + }); }); }); diff --git a/test/ipcprovider.js b/test/ipcprovider.js index 70f7d24..53c5221 100644 --- a/test/ipcprovider.js +++ b/test/ipcprovider.js @@ -1,11 +1,12 @@ var chai = require('chai'); var assert = chai.assert; var SandboxedModule = require('sandboxed-module'); + var FakeIpcRequest = require('./helpers/FakeIpcRequest') var net = new FakeIpcRequest(); SandboxedModule.registerBuiltInSourceTransformer('istanbul'); -var IpcProvider = SandboxedModule.require('../lib/web3/providers/ipcprovider', { +var IpcProvider = SandboxedModule.require('../packages/web3-core-requestmanager/src/providers/ipcprovider', { requires: { 'bignumber.js': require('bignumber.js'), }, diff --git a/test/jsonrpc.id.js b/test/jsonrpc.id.js index bdd093e..1bcce99 100644 --- a/test/jsonrpc.id.js +++ b/test/jsonrpc.id.js @@ -1,11 +1,11 @@ var chai = require('chai'); var assert = chai.assert; -var Jsonrpc = require('../lib/web3/jsonrpc'); +var Jsonrpc = require('../packages/web3-core-requestManager/src/jsonrpc'); describe('lib/web3/jsonrpc', function () { describe('id', function () { it('should increment the id', function () { - + // given var method = 'm'; @@ -14,7 +14,7 @@ describe('lib/web3/jsonrpc', function () { var p2 = Jsonrpc.toPayload(method); // then - assert.equal(p2.id, p1.id + 1); + assert.equal(p2.id, p1.id + 1); }); }); }); diff --git a/test/jsonrpc.isValidResponse.js b/test/jsonrpc.isValidResponse.js index e5ab2a6..a0834ff 100644 --- a/test/jsonrpc.isValidResponse.js +++ b/test/jsonrpc.isValidResponse.js @@ -1,11 +1,11 @@ var assert = require('assert'); -var Jsonrpc = require('../lib/web3/jsonrpc'); +var Jsonrpc = require('../packages/web3-core-requestManager/src/jsonrpc'); describe('jsonrpc', function () { describe('isValidResponse', function () { it('should validate basic jsonrpc response', function () { - - // given + + // given var response = { jsonrpc: '2.0', id: 1, @@ -20,8 +20,8 @@ describe('jsonrpc', function () { }); it('should validate basic undefined response', function () { - - // given + + // given var response = undefined; // when @@ -30,10 +30,10 @@ describe('jsonrpc', function () { // then assert.equal(valid, false); }); - + it('should validate jsonrpc response without jsonrpc field', function () { - - // given + + // given var response = { id: 1, result: [] @@ -45,10 +45,10 @@ describe('jsonrpc', function () { // then assert.equal(valid, false); }); - + it('should validate jsonrpc response with wrong jsonrpc version', function () { - - // given + + // given var response = { jsonrpc: '1.0', id: 1, @@ -61,10 +61,10 @@ describe('jsonrpc', function () { // then assert.equal(valid, false); }); - + it('should validate jsonrpc response without id number', function () { - - // given + + // given var response = { jsonrpc: '2.0', result: [] @@ -78,8 +78,8 @@ describe('jsonrpc', function () { }); it('should validate jsonrpc response with wrong id field', function () { - - // given + + // given var response = { jsonrpc: '2.0', id: 'x', @@ -94,8 +94,8 @@ describe('jsonrpc', function () { }); it('should validate jsonrpc response without result field', function () { - - // given + + // given var response = { jsonrpc: '2.0', id: 1 @@ -109,12 +109,12 @@ describe('jsonrpc', function () { }); it('should validate jsonrpc response with result field === false', function () { - - // given + + // given var response = { jsonrpc: '2.0', id: 1, - result: false + result: false }; // when @@ -125,12 +125,12 @@ describe('jsonrpc', function () { }); it('should validate jsonrpc response with result field === 0', function () { - - // given + + // given var response = { jsonrpc: '2.0', id: 1, - result: 0 + result: 0 }; // when diff --git a/test/jsonrpc.toBatchPayload.js b/test/jsonrpc.toBatchPayload.js index d82e159..e1254e7 100644 --- a/test/jsonrpc.toBatchPayload.js +++ b/test/jsonrpc.toBatchPayload.js @@ -1,11 +1,11 @@ var assert = require('assert'); -var Jsonrpc = require('../lib/web3/jsonrpc'); +var Jsonrpc = require('../packages/web3-core-requestManager/src/jsonrpc'); describe('jsonrpc', function () { describe('toBatchPayload', function () { it('should create basic batch payload', function () { - - // given + + // given var messages = [{ method: 'helloworld' }, { @@ -30,10 +30,10 @@ describe('jsonrpc', function () { assert.equal(typeof payload[1].id, 'number'); assert.equal(payload[0].id + 1, payload[1].id); }); - + it('should create batch payload for empty input array', function () { - - // given + + // given var messages = []; // when diff --git a/test/jsonrpc.toPayload.js b/test/jsonrpc.toPayload.js index c480576..792ea80 100644 --- a/test/jsonrpc.toPayload.js +++ b/test/jsonrpc.toPayload.js @@ -1,12 +1,12 @@ var chai = require('chai'); -var assert = chai.assert; -var Jsonrpc = require('../lib/web3/jsonrpc'); +var assert = chai.assert; +var Jsonrpc = require('../packages/web3-core-requestManager/src/jsonrpc'); describe('jsonrpc', function () { describe('toPayload', function () { it('should create basic payload', function () { - - // given + + // given var method = 'helloworld'; // when @@ -19,10 +19,10 @@ describe('jsonrpc', function () { assert.equal(payload.params.length, 0); assert.equal(typeof payload.id, 'number'); }); - + it('should create payload with params', function () { - - // given + + // given var method = 'helloworld1'; var params = [123, 'test']; diff --git a/test/method.buildCall.js b/test/method.buildCall.js new file mode 100644 index 0000000..e5f2712 --- /dev/null +++ b/test/method.buildCall.js @@ -0,0 +1,676 @@ +var chai = require('chai'); +var assert = chai.assert; +var formatters = require('../packages/web3-core-helpers/src/formatters.js'); +var FakeHttpProvider = require('./helpers/FakeHttpProvider'); +var Eth = require('../packages/web3-eth'); +var Method = require('../packages/web3-core-method'); + +var address = '0x1234567890123456789012345678901234567891'; + + +describe('lib/web3/method', function () { + describe('buildCall', function () { + it('should return a promise and resolve it', function (done) { + var provider = new FakeHttpProvider(); + var eth = new Eth(provider); + var method = new Method({ + name: 'call', + call: 'eth_call', + params: 2, + inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter] + }); + method.setRequestManager(eth._requestManager); + + // generate send function + var send = method.buildCall(); + + // add results + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_call'); + assert.deepEqual(payload.params, [{ + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + data: '0xa123456' + },"latest"]); + }); + provider.injectResult('0x1234567453543456321456321'); // tx hash + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }).then(function (result) { + + assert.deepEqual(result, '0x1234567453543456321456321'); + + done(); + }); + + }); + it('should return a promise and fail it', function (done) { + var provider = new FakeHttpProvider(); + var eth = new Eth(provider); + var method = new Method({ + name: 'call', + call: 'eth_call', + params: 2, + inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter] + }); + method.setRequestManager(eth._requestManager); + + // generate send function + var send = method.buildCall(); + + // add results + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_call'); + assert.deepEqual(payload.params, [{ + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + data: '0xa123456' + },"latest"]); + }); + provider.injectError({ + message: 'Wrong!', + code: 1234 + }); + + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }) + .catch(function (error) { + assert.deepEqual(error, { + message: 'Wrong!', + code: 1234 + }); + + done(); + }); + + }); + + var succeedOnReceipt = function () { + var provider = new FakeHttpProvider(); + var eth = new Eth(provider); + var method = new Method({ + name: 'sendTransaction', + call: 'eth_sendTransaction', + params: 1, + inputFormatter: [formatters.inputTransactionFormatter] + }); + method.setRequestManager(eth._requestManager, eth); + + // generate send function + var send = method.buildCall(); + + // add results + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_sendTransaction'); + assert.deepEqual(payload.params, [{ + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + value: '0xa' + }]); + }); + provider.injectResult('0x1234567453543456321456321'); // tx hash + + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_subscribe'); + assert.deepEqual(payload.params, ['newHeads']); + }); + provider.injectResult('0x1234567'); // subscription id + + // fake newBlock + provider.injectNotification({ + method: 'eth_subscription', + params: { + subscription: '0x1234567', + result: { + blockNumber: '0x10' + } + } + }); + + // receipt + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_getTransactionReceipt'); + assert.deepEqual(payload.params, ['0x1234567453543456321456321']); + }); + provider.injectResult({ + contractAddress: address, + cumulativeGasUsed: '0xa', + transactionIndex: '0x3', + blockNumber: '0xa' + }); + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_unsubscribe'); + assert.deepEqual(payload.params, ['0x1234567']); + }); + provider.injectResult(true); // unsubscribe result + + return send; + }; + + it('should use promise "then" when subscribing and checking for receipt if "sendTransaction"', function (done) { + + var send = succeedOnReceipt(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + value: '0xa' + }).then(function (result) { + + + assert.deepEqual(result, { + contractAddress: address, + cumulativeGasUsed: 10, + transactionIndex: 3, + blockNumber: 10, + gasUsed: 0 + }); + + done(); + }); + + }); + it('should use on("receipt", ...) when subscribing and checking for receipt if "sendTransaction"', function (done) { + + var send = succeedOnReceipt(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + value: '0xa' + }).on('receipt', function (result) { + + + assert.deepEqual(result, { + contractAddress: address, + cumulativeGasUsed: 10, + transactionIndex: 3, + blockNumber: 10, + gasUsed: 0 + }); + + done(); + }); + + }); + + + var succeedwhenDeploying = function () { + var provider = new FakeHttpProvider(); + var eth = new Eth(provider); + var method = new Method({ + name: 'sendTransaction', + call: 'eth_sendTransaction', + params: 1, + inputFormatter: [formatters.inputTransactionFormatter] + }); + method.setRequestManager(eth._requestManager, eth); + + // generate send function + var send = method.buildCall(); + + // add results + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_sendTransaction'); + assert.deepEqual(payload.params, [{ + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + data: '0xa123456' + }]); + }); + provider.injectResult('0x1234567453543456321456321'); // tx hash + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_subscribe'); + assert.deepEqual(payload.params, ['newHeads']); + }); + provider.injectResult('0x1234567'); // subscription id + + // fake newBlock + provider.injectNotification({ + method: 'eth_subscription', + params: { + subscription: '0x1234567', + result: { + blockNumber: '0x10' + } + } + }); + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_getTransactionReceipt'); + assert.deepEqual(payload.params, ['0x1234567453543456321456321']); + }); + // receipt + provider.injectResult({ + contractAddress: address, + cumulativeGasUsed: '0xa', + transactionIndex: '0x3', + blockNumber: '0xa' + }); + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_getCode'); + assert.deepEqual(payload.params, [address, 'latest']); + }); + // code result + provider.injectResult('0x321'); + + return send; + }; + + it('should use promise "then" when subscribing and checking for receipt and code if "sendTransaction" deploying contract', function (done) { + + var send = succeedwhenDeploying(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }).then(function (result) { + + assert.deepEqual(result, { + contractAddress: address, + cumulativeGasUsed: 10, + transactionIndex: 3, + blockNumber: 10, + gasUsed: 0 + }); + + done(); + }); + + }); + + it('should use on("receipt", ...) when subscribing and checking for receipt and code if "sendTransaction" deploying contract', function (done) { + + var send = succeedwhenDeploying(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }).on('receipt', function (result) { + + assert.deepEqual(result, { + contractAddress: address, + cumulativeGasUsed: 10, + transactionIndex: 3, + blockNumber: 10, + gasUsed: 0 + }); + + done(); + }); + + }); + + var failOnCodeEmpty = function () { + var provider = new FakeHttpProvider(); + var eth = new Eth(provider); + var method = new Method({ + name: 'sendTransaction', + call: 'eth_sendTransaction', + params: 1, + inputFormatter: [formatters.inputTransactionFormatter] + }); + method.setRequestManager(eth._requestManager, eth); + + // generate send function + var send = method.buildCall(); + + // add results + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_sendTransaction'); + assert.deepEqual(payload.params, [{ + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + data: '0xa123456' + }]); + }); + provider.injectResult('0x1234567453543456321456321'); // tx hash + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_subscribe'); + assert.deepEqual(payload.params, ['newHeads']); + }); + provider.injectResult('0x1234567'); // subscription id + + // fake newBlock + provider.injectNotification({ + method: 'eth_subscription', + params: { + subscription: '0x1234567', + result: { + blockNumber: '0x10' + } + } + }); + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_getTransactionReceipt'); + assert.deepEqual(payload.params, ['0x1234567453543456321456321']); + }); + // receipt + provider.injectResult({ + contractAddress: address, + cumulativeGasUsed: '0xa', + transactionIndex: '0x3', + blockNumber: '0xa' + }); + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_getCode'); + assert.deepEqual(payload.params, [address, 'latest']); + }); + // code result + provider.injectResult('0x'); + + return send; + }; + + it('should fail on promise when subscribing and check for receipt and code if "sendTransaction" and deploying contract: error if code is empty', function (done) { + + var send = failOnCodeEmpty(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }).catch(function (error) { + assert.instanceOf(error, Error); + done(); + }); + + }); + + it('should fail with on("error", ...) when subscribing and check for receipt and code if "sendTransaction" and deploying contract: error if code is empty', function (done) { + + var send = failOnCodeEmpty(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }).on('error', function (error) { + assert.instanceOf(error, Error); + done(); + }); + + }); + + var failOnMissingAddress = function () { + var provider = new FakeHttpProvider(); + var eth = new Eth(provider); + var method = new Method({ + name: 'sendTransaction', + call: 'eth_sendTransaction', + params: 1, + inputFormatter: [formatters.inputTransactionFormatter] + }); + method.setRequestManager(eth._requestManager, eth); + + // generate send function + var send = method.buildCall(); + + // add results + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_sendTransaction'); + assert.deepEqual(payload.params, [{ + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + data: '0xa123456' + }]); + }); + provider.injectResult('0x1234567453543456321456321'); // tx hash + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_subscribe'); + assert.deepEqual(payload.params, ['newHeads']); + }); + provider.injectResult('0x1234567'); // subscription id + + // fake newBlock + provider.injectNotification({ + method: 'eth_subscription', + params: { + subscription: '0x1234567', + result: { + blockNumber: '0x10' + } + } + }); + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_getTransactionReceipt'); + assert.deepEqual(payload.params, ['0x1234567453543456321456321']); + }); + // receipt + provider.injectResult({ + contractAddress: null, + cumulativeGasUsed: '0xa', + transactionIndex: '0x3', + blockNumber: '0xa' + }); + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_unsubscribe'); + assert.deepEqual(payload.params, ['0x1234567']); + }); + // code result + provider.injectResult(true); + + return send; + }; + + it('should fail on promise when subscribing and check for receipt and code if "sendTransaction" and deploying contract: error if receipt has no contract address', function (done) { + var send = failOnMissingAddress(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }).catch(function (error) { + assert.instanceOf(error, Error); + done(); + }); + + }); + it('should fail with on("error", ...) when subscribing and check for receipt and code if "sendTransaction" and deploying contract: error if receipt has no contract address', function (done) { + var send = failOnMissingAddress(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }).on('error', function (error) { + assert.instanceOf(error, Error); + }).catch(function (error) { + // also run catch! + assert.instanceOf(error, Error); + done(); + }); + + }); + + var failOnTimeout = function () { + var provider = new FakeHttpProvider(); + var eth = new Eth(provider); + var method = new Method({ + name: 'sendTransaction', + call: 'eth_sendTransaction', + params: 1, + inputFormatter: [formatters.inputTransactionFormatter] + }); + method.setRequestManager(eth._requestManager, eth); + + // generate send function + var send = method.buildCall(); + + // add results + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_sendTransaction'); + assert.deepEqual(payload.params, [{ + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + data: '0xa123456' + }]); + }); + provider.injectResult('0x1234567453543456321456321'); // tx hash + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_subscribe'); + assert.deepEqual(payload.params, ['newHeads']); + }); + provider.injectResult('0x1234567'); // subscription id + + // fire 50 fake newBlocks + for (i = 0; i < 51; i++) { + setTimeout(function () { + provider.injectNotification({ + method: 'eth_subscription', + params: { + subscription: '0x1234567', + result: { + blockNumber: '0x10' + } + } + }); + },i); + + // receipt + provider.injectResult(null); + } + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_getTransactionReceipt'); + assert.deepEqual(payload.params, ['0x1234567453543456321456321']); + }); + + return send; + + }; + + it('should fail with promise when subscribing and check for receipt and code if "sendTransaction" and deploying contract: if not receipt after 50 blocks', function (done) { + var send = failOnTimeout(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }).catch(function (error) { + assert.instanceOf(error, Error); + done(); + }); + }); + it('should fail with on("error", ...) when subscribing and check for receipt and code if "sendTransaction" and deploying contract: if not receipt after 50 blocks', function (done) { + var send = failOnTimeout(); + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + data: '0xa123456' + }).on('error', function (error) { + assert.instanceOf(error, Error); + done(); + }); + + }); + + it('should give confirmation receipts with on("confirmation", ...) when subscribing "sendTransaction"', function (done) { + var provider = new FakeHttpProvider(); + var eth = new Eth(provider); + var method = new Method({ + name: 'sendTransaction', + call: 'eth_sendTransaction', + params: 1, + inputFormatter: [formatters.inputTransactionFormatter] + }); + method.setRequestManager(eth._requestManager, eth); + + // generate send function + var send = method.buildCall(); + + // add results + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_sendTransaction'); + assert.deepEqual(payload.params, [{ + from: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + to: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae' + }]); + }); + provider.injectResult('0x1234567453543456321456321'); // tx hash + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_subscribe'); + assert.deepEqual(payload.params, ['newHeads']); + }); + provider.injectResult('0x1234567'); // subscription id + + // fire 50 fake newBlocks + for (i = 0; i < 30; i++) { + + setTimeout(function () { + provider.injectNotification({ + method: 'eth_subscription', + params: { + subscription: '0x1234567', + result: { + blockNumber: '0x10' + } + } + }); + }, i); + + // receipt + provider.injectResult({ + contractAddress: null, + cumulativeGasUsed: '0xa', + transactionIndex: '0x3', + blockNumber: '0xa' + }); + } + + provider.injectValidation(function (payload) { + assert.equal(payload.method, 'eth_getTransactionReceipt'); + assert.deepEqual(payload.params, ['0x1234567453543456321456321']); + }); + + + var countConf = 0; + + send({ + from: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe' + }) + .on('transactionHash', function(result){ + assert.deepEqual(result, '0x1234567453543456321456321'); + }) + .on('receipt', function(result){ + + assert.deepEqual(result, { + contractAddress: null, + cumulativeGasUsed: 10, + transactionIndex: 3, + blockNumber: 10, + gasUsed: 0 + }); + + }) + .on('confirmation', function (conf, receipt) { + + assert.deepEqual(receipt, { + contractAddress: null, + cumulativeGasUsed: 10, + transactionIndex: 3, + blockNumber: 10, + gasUsed: 0 + }); + + assert.deepEqual(conf, countConf); + + countConf++; + + if(conf === 12) { + done(); + } + }); + + }); + }); +}); + diff --git a/test/method.extractCallback.js b/test/method.extractCallback.js index 34e480c..e95759c 100644 --- a/test/method.extractCallback.js +++ b/test/method.extractCallback.js @@ -1,13 +1,13 @@ var chai = require('chai'); var assert = chai.assert; -var Method = require('../lib/web3/method'); +var Method = require('../packages/web3-core-method'); describe('lib/web3/method', function () { describe('extractCallback', function () { it('should extract callback', function () { - + // given - var method = new Method({}); + var method = new Method({name: 'something', call: 'eth_something'}); var callback = function () { }; var args = [1, callback] @@ -18,11 +18,11 @@ describe('lib/web3/method', function () { assert.equal(args.length, 1); assert.equal(callback, result); }); - + it('should extract callback created using newFunction', function () { - + // given - var method = new Method({}); + var method = new Method({name: 'something', call: 'eth_something'}); var callback = new Function (); var args = [1, callback] @@ -35,9 +35,9 @@ describe('lib/web3/method', function () { }); it('should not extract the callback', function () { - + // given - var method = new Method({}); + var method = new Method({name: 'something', call: 'eth_something'}); var args = [1, 2] // when diff --git a/test/method.formatInput.js b/test/method.formatInput.js index c778f10..2f11623 100644 --- a/test/method.formatInput.js +++ b/test/method.formatInput.js @@ -1,17 +1,18 @@ var chai = require('chai'); var assert = chai.assert; -var Method = require('../lib/web3/method'); +var Method = require('../packages/web3-core-method'); describe('lib/web3/method', function () { describe('formatInput', function () { it('should format plain input', function () { - + // given var star = function (arg) { return arg + '*'; }; - + var method = new Method({ + name: 'something', call: 'eth_something', inputFormatter: [star, star, star] }); var args = ['1','2','3']; @@ -27,12 +28,12 @@ describe('lib/web3/method', function () { it('should do nothing if there is no formatter', function () { // given - var method = new Method({}); + var method = new Method({name: 'something', call: 'eth_something'}); var args = [1,2,3]; // when var result = method.formatInput(args); - + // then assert.deepEqual(result, args); }); diff --git a/test/method.formatOutput.js b/test/method.formatOutput.js index acfead0..ca55c13 100644 --- a/test/method.formatOutput.js +++ b/test/method.formatOutput.js @@ -1,17 +1,18 @@ var chai = require('chai'); var assert = chai.assert; -var Method = require('../lib/web3/method'); +var Method = require('../packages/web3-core-method'); describe('lib/web3/method', function () { describe('formatOutput', function () { it('should format plain output', function () { - + // given var formatter = function (arg) { return arg + '*'; }; - + var method = new Method({ + name: 'something', call: 'eth_something', outputFormatter: formatter }); var args = '1'; @@ -24,14 +25,36 @@ describe('lib/web3/method', function () { assert.deepEqual(result, expectedArgs); }); - it('should format output arrays with the same formatter', function () { - + it('should format plain output if array', function () { + // given var formatter = function (arg) { return arg + '*'; }; - + var method = new Method({ + name: 'something', call: 'eth_something', + outputFormatter: formatter + }); + var args = '1'; + var expectedArgs = ['1*', '1*']; + + // when + var result = method.formatOutput([args, args]); + + // then + assert.deepEqual(result, expectedArgs); + }); + + it('should format output arrays with the same formatter', function () { + + // given + var formatter = function (arg) { + return arg + '*'; + }; + + var method = new Method({ + name: 'something', call: 'eth_something', outputFormatter: formatter }); var args = ['1','2','3']; @@ -43,16 +66,16 @@ describe('lib/web3/method', function () { // then assert.deepEqual(result, expectedArgs); }); - + it('should do nothing if there is no formatter', function () { // given - var method = new Method({}); + var method = new Method({name: 'something', call: 'eth_something'}); var args = [1,2,3]; // when var result = method.formatOutput(args); - + // then assert.deepEqual(result, args); }); diff --git a/test/method.getCall.js b/test/method.getCall.js index 398de32..41413bb 100644 --- a/test/method.getCall.js +++ b/test/method.getCall.js @@ -1,14 +1,15 @@ var chai = require('chai'); var assert = chai.assert; -var Method = require('../lib/web3/method'); +var Method = require('../packages/web3-core-method'); describe('lib/web3/method', function () { describe('getCall', function () { it('should return call name', function () { - + // given var call = 'hello_call_world'; var method = new Method({ + name: 'something', call: call }); @@ -20,16 +21,17 @@ describe('lib/web3/method', function () { }); it('should return call based on args', function () { - + // given var call = function (args) { return args ? args.length.toString() : '0'; }; - + var method = new Method({ + name: 'something', call: call }); - + // when var r0 = method.getCall(); var r1 = method.getCall([1]); @@ -39,7 +41,7 @@ describe('lib/web3/method', function () { assert.equal(r0, '0'); assert.equal(r1, '1'); assert.equal(r2, '2'); - + }); }); }); diff --git a/test/method.validateArgs.js b/test/method.validateArgs.js index cd4882c..6947ff4 100644 --- a/test/method.validateArgs.js +++ b/test/method.validateArgs.js @@ -1,14 +1,15 @@ var chai = require('chai'); var assert = chai.assert; -var Method = require('../lib/web3/method'); -var errors = require('../lib/web3/errors'); +var Method = require('../packages/web3-core-method'); +var errors = require('../packages/web3-core-helpers/src/errors'); describe('lib/web3/method', function () { describe('validateArgs', function () { it('should pass', function () { - + // given var method = new Method({ + name: 'something', call: 'eth_something', params: 1 }); @@ -25,9 +26,11 @@ describe('lib/web3/method', function () { }); it('should return call based on args', function () { - + // given var method = new Method({ + name: 'something', + call: 'eth_something', params: 2 }); @@ -37,10 +40,10 @@ describe('lib/web3/method', function () { // when var test = function () { method.validateArgs(args); }; var test2 = function () { method.validateArgs(args2); }; - + // then - assert.throws(test, errors.InvalidNumberOfParams().message); - assert.throws(test2, errors.InvalidNumberOfParams().message); + assert.throws(test, errors.InvalidNumberOfParams(1, 2, 'something').message); + assert.throws(test2, errors.InvalidNumberOfParams(3, 2, 'something').message); }); }); }); diff --git a/test/mocha.opts b/test/mocha.opts index 5ada47b..ff593c4 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1 +1 @@ ---reporter spec +--reporter dot diff --git a/test/polling.js b/test/polling.js deleted file mode 100644 index c383853..0000000 --- a/test/polling.js +++ /dev/null @@ -1,125 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); -var utils = require('../lib/utils/utils'); - -var tests = [{ - protocol: 'eth', - args: ['latest'], - firstResult: 1, - firstPayload: { - method: "eth_newBlockFilter", - params: [] - }, - secondResult: ['0x1234'], - secondPayload: { - method: "eth_getFilterChanges" - } -}, -{ - protocol: 'eth', - args: ['pending'], - firstResult: 1, - firstPayload: { - method: "eth_newPendingTransactionFilter", - params: [] - }, - secondResult: ['0x1234'], - secondPayload: { - method: "eth_getFilterChanges" - } -}]; - -var testPolling = function (tests) { - - describe('web3.eth.filter.polling', function () { - tests.forEach(function (test, index) { - it('should create && successfully poll filter', function (done) { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - web3.reset(); - provider.injectResult(test.firstResult); - var step = 0; - provider.injectValidation(function (payload) { - if (step === 0) { - step = 1; - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.firstPayload.method); - assert.deepEqual(payload.params, test.firstPayload.params); - } else if (step === 1 && utils.isArray(payload)) { - step++; - var r = payload.filter(function (p) { - return p.jsonrpc === '2.0' && p.method === test.secondPayload.method && p.params[0] === test.firstResult; - }); - assert.equal(r.length > 0, true); - } - - }); - - // when - var filter = web3[test.protocol].filter.apply(web3[test.protocol], test.args); - provider.injectBatchResults([test.secondResult]); - filter.watch(function (err, result) { - if (test.err) { - // todo - } else { - assert.equal(result, test.secondResult[0]); - } - filter.stopWatching(function (err) { - assert.isNotOk(err); - done(); - }); - - }); - }); - it('should create && successfully poll filter when passed as callback', function (done) { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - web3.reset(); - provider.injectResult(test.firstResult); - var step = 0; - provider.injectValidation(function (payload) { - if (step === 0) { - step = 1; - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.firstPayload.method); - assert.deepEqual(payload.params, test.firstPayload.params); - } else if (step === 1 && utils.isArray(payload)) { - step++; - var r = payload.filter(function (p) { - return p.jsonrpc === '2.0' && p.method === test.secondPayload.method && p.params[0] === test.firstResult; - }); - assert.equal(r.length > 0, true); - } - - }); - - // add callback - test.args.push(function (err, result) { - if (test.err) { - // todo - } else { - assert.equal(result, test.secondResult[0]); - } - filter.stopWatching(function (err) { - assert.isNotOk(err); - done(); - }); - - }); - - // when - var filter = web3[test.protocol].filter.apply(web3[test.protocol], test.args); - provider.injectBatchResults([test.secondResult]); - }); - }); - }); -}; - -testPolling(tests); diff --git a/test/requestmanager.js b/test/requestmanager.js index 0aa924a..10767ae 100644 --- a/test/requestmanager.js +++ b/test/requestmanager.js @@ -1,7 +1,7 @@ var chai = require('chai'); var assert = chai.assert; -var RequestManager = require('../lib/web3/requestmanager'); var FakeHttpProvider = require('./helpers/FakeHttpProvider'); +var requestManager = require('../packages/web3-core-requestManager'); // TODO: handling errors! // TODO: validation of params! @@ -10,7 +10,7 @@ describe('lib/web3/requestmanager', function () { describe('send', function () { it('should return expected result synchronously', function () { var provider = new FakeHttpProvider(); - var manager = new RequestManager(provider); + var manager = new requestManager.Manager(provider); var expected = 'hello_world'; provider.injectResult(expected); @@ -24,7 +24,7 @@ describe('lib/web3/requestmanager', function () { it('should return expected result asynchronously', function (done) { var provider = new FakeHttpProvider(); - var manager = new RequestManager(provider); + var manager = new requestManager.Manager(provider); var expected = 'hello_world'; provider.injectResult(expected); diff --git a/test/sha3.js b/test/sha3.js deleted file mode 100644 index 444b70d..0000000 --- a/test/sha3.js +++ /dev/null @@ -1,19 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var sha3 = require('../lib/utils/sha3'); -var web3 = require('../index'); - -describe('lib/utils/sha3', function () { - var test = function (v, e, o) { - it('should encode ' + v + ' to ' + e, function () { - assert.equal(sha3(v, o), e); - }); - }; - - test('test123', 'f81b517a242b218999ec8eec0ea6e2ddbef2a367a14e93f4a32a39e260f686ad'); - test('test(int)', 'f4d03772bec1e62fbe8c5691e1a9101e520e8f8b5ca612123694632bf3cb51b1'); - test('0x80', '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', { encoding: 'hex' }); - test('0x80', '6b03a5eef7706e3fb52a61c19ab1122fad7237726601ac665bd4def888f0e4a0'); - test('0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1', '82ff40c0a986c6a5cfad4ddf4c3aa6996f1a7837f9c398e17e5de5cbd5a12b28', { encoding: 'hex' }); -}); - diff --git a/test/soldity.formatters.formatInputInt.js b/test/soldity.formatters.formatInputInt.js index b7fabc7..aecab30 100644 --- a/test/soldity.formatters.formatInputInt.js +++ b/test/soldity.formatters.formatInputInt.js @@ -1,7 +1,7 @@ var chai = require('chai'); var assert = chai.assert; -var formatters = require('../lib/solidity/formatters.js'); -var SolidityParam = require('../lib/solidity/param'); +var formatters = require('../packages/web3-eth/src/solidity/formatters.js'); +var SolidityParam = require('../packages/web3-eth/src/solidity/param'); var tests = [ { input: 1, result: new SolidityParam('0000000000000000000000000000000000000000000000000000000000000001') }, diff --git a/test/utils.extractDisplayName.js b/test/utils.extractDisplayName.js index d3faef8..dc25e60 100644 --- a/test/utils.extractDisplayName.js +++ b/test/utils.extractDisplayName.js @@ -1,12 +1,12 @@ var assert = require('assert'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); describe('lib/utils/utils', function () { describe('extractDisplayName', function () { it('should extract display name from method with no params', function () { - + // given - var test = 'helloworld()'; + var test = 'helloworld()'; // when var displayName = utils.extractDisplayName(test); @@ -14,11 +14,11 @@ describe('lib/utils/utils', function () { // then assert.equal(displayName, 'helloworld'); }); - + it('should extract display name from method with one param' , function () { - + // given - var test = 'helloworld1(int)'; + var test = 'helloworld1(int)'; // when var displayName = utils.extractDisplayName(test); @@ -26,11 +26,11 @@ describe('lib/utils/utils', function () { // then assert.equal(displayName, 'helloworld1'); }); - + it('should extract display name from method with two params' , function () { - + // given - var test = 'helloworld2(int,string)'; + var test = 'helloworld2(int,string)'; // when var displayName = utils.extractDisplayName(test); diff --git a/test/utils.extractTypeName.js b/test/utils.extractTypeName.js index 4109978..fe44f00 100644 --- a/test/utils.extractTypeName.js +++ b/test/utils.extractTypeName.js @@ -1,22 +1,22 @@ var assert = require('assert'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); describe('lib/utils/utils', function () { describe('extractTypeName', function () { it('should extract type name from method with no params', function () { - + // given var test = 'helloworld()'; // when - var typeName = utils.extractTypeName(test); + var typeName = utils.extractTypeName(test); // then assert.equal(typeName, ''); }); it('should extract type name from method with one param', function () { - + // given var test = 'helloworld1(int)'; @@ -26,9 +26,9 @@ describe('lib/utils/utils', function () { // then assert.equal(typeName, 'int'); }); - + it('should extract type name from method with two params', function () { - + // given var test = 'helloworld2(int,string)'; @@ -38,9 +38,9 @@ describe('lib/utils/utils', function () { // then assert.equal(typeName, 'int,string'); }); - + it('should extract type name from method with spaces between params', function () { - + // given var test = 'helloworld3(int, string)'; diff --git a/test/utils.fromAscii.js b/test/utils.fromAscii.js index 9960a62..7b62527 100644 --- a/test/utils.fromAscii.js +++ b/test/utils.fromAscii.js @@ -1,6 +1,6 @@ var chai = require('chai'); -var BigNumber = require('bignumber.js'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ diff --git a/test/utils.fromDecimal.js b/test/utils.fromDecimal.js index c0e5ed6..63d1e13 100644 --- a/test/utils.fromDecimal.js +++ b/test/utils.fromDecimal.js @@ -1,5 +1,6 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ diff --git a/test/utils.fromUtf8.js b/test/utils.fromUtf8.js index f21a3b8..504352b 100644 --- a/test/utils.fromUtf8.js +++ b/test/utils.fromUtf8.js @@ -1,6 +1,6 @@ var chai = require('chai'); -var BigNumber = require('bignumber.js'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ diff --git a/test/utils.fromWei.js b/test/utils.fromWei.js index e8691eb..a2b7acb 100644 --- a/test/utils.fromWei.js +++ b/test/utils.fromWei.js @@ -1,10 +1,10 @@ var assert = require('assert'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); describe('lib/utils/utils', function () { describe('fromWei', function () { it('should return the correct value', function () { - + assert.equal(utils.fromWei(1000000000000000000, 'wei'), '1000000000000000000'); assert.equal(utils.fromWei(1000000000000000000, 'kwei'), '1000000000000000'); assert.equal(utils.fromWei(1000000000000000000, 'mwei'), '1000000000000'); diff --git a/test/utils.isAddress.js b/test/utils.isAddress.js index a0658e3..d981f1c 100644 --- a/test/utils.isAddress.js +++ b/test/utils.isAddress.js @@ -1,5 +1,6 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ @@ -17,7 +18,7 @@ describe('lib/utils/utils', function () { it('shoud test if value ' + test.value + ' is address: ' + test.is, function () { assert.equal(utils.isAddress(test.value), test.is); }); - }); + }); }); }); diff --git a/test/utils.isBigNumber.js b/test/utils.isBigNumber.js index d78739b..82038b8 100644 --- a/test/utils.isBigNumber.js +++ b/test/utils.isBigNumber.js @@ -1,6 +1,8 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var BigNumber = require('bignumber.js'); + var assert = chai.assert; var tests = [ @@ -21,6 +23,6 @@ describe('lib/utils/utils', function () { it('shoud test if value ' + test.func + ' is BigNumber: ' + test.is, function () { assert.equal(utils.isBigNumber(test.value), test.is); }); - }); + }); }); }); diff --git a/test/utils.isChecksumAddress.js b/test/utils.isChecksumAddress.js index d4c603c..2745e18 100644 --- a/test/utils.isChecksumAddress.js +++ b/test/utils.isChecksumAddress.js @@ -1,5 +1,6 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ @@ -21,7 +22,7 @@ describe('lib/utils/utils', function () { it('shoud test if address ' + test.value + ' passes checksum: ' + test.is, function () { assert.equal(utils.isChecksumAddress(test.value), test.is); }); - }); + }); }); }); diff --git a/test/utils.isFunction.js b/test/utils.isFunction.js index 05882b2..e1e9e1f 100644 --- a/test/utils.isFunction.js +++ b/test/utils.isFunction.js @@ -1,5 +1,6 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ @@ -15,7 +16,7 @@ describe('lib/utils/utils', function () { it('shoud test if value ' + test.func + ' is function: ' + test.is, function () { assert.equal(utils.isFunction(test.func), test.is); }); - }); + }); }); }); diff --git a/test/utils.isJson.js b/test/utils.isJson.js index 73d86d8..97de983 100644 --- a/test/utils.isJson.js +++ b/test/utils.isJson.js @@ -1,5 +1,6 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ @@ -20,7 +21,7 @@ describe('lib/utils/utils', function () { it('shoud test if value ' + test.obj + ' is json: ' + test.is, function () { assert.equal(utils.isJson(test.obj), test.is); }); - }); + }); }); }); diff --git a/test/utils.isStrictAddress.js b/test/utils.isStrictAddress.js deleted file mode 100644 index e23e3de..0000000 --- a/test/utils.isStrictAddress.js +++ /dev/null @@ -1,23 +0,0 @@ -var chai = require('chai'); -var utils = require('../lib/utils/utils.js'); -var assert = chai.assert; - -var tests = [ - { value: function () {}, is: false}, - { value: new Function(), is: false}, - { value: 'function', is: false}, - { value: {}, is: false}, - { value: '0xc6d9d2cd449a754c494264e1809c50e34d64562b', is: true }, - { value: 'c6d9d2cd449a754c494264e1809c50e34d64562b', is: false } -]; - -describe('lib/utils/utils', function () { - describe('isStrictAddress', function () { - tests.forEach(function (test) { - it('shoud test if value ' + test.value + ' is address: ' + test.is, function () { - assert.equal(utils.isStrictAddress(test.value), test.is); - }); - }); - }); -}); - diff --git a/test/utils.isString.js b/test/utils.isString.js index 73b95d2..6e8e90d 100644 --- a/test/utils.isString.js +++ b/test/utils.isString.js @@ -1,5 +1,6 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ @@ -16,7 +17,7 @@ describe('lib/utils/utils', function () { it('shoud test if value ' + test.func + ' is string: ' + test.is, function () { assert.equal(utils.isString(test.value), test.is); }); - }); + }); }); }); diff --git a/test/utils.toAscii.js b/test/utils.toAscii.js index c8990e3..fa0734f 100644 --- a/test/utils.toAscii.js +++ b/test/utils.toAscii.js @@ -1,6 +1,6 @@ var chai = require('chai'); -var BigNumber = require('bignumber.js'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ diff --git a/test/utils.toBigNumber.js b/test/utils.toBigNumber.js index efe3fa7..796a177 100644 --- a/test/utils.toBigNumber.js +++ b/test/utils.toBigNumber.js @@ -1,6 +1,8 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var BigNumber = require('bignumber.js'); + var assert = chai.assert; var tests = [ @@ -38,7 +40,7 @@ describe('lib/utils/utils', function () { describe('toBigNumber', function () { tests.forEach(function (test) { it('should turn ' + test.value + ' to ' + test.expected, function () { - assert.equal(utils.toBigNumber(test.value).toString(10), test.expected); + assert.equal(utils.toBigNumber(test.value).toFixed(), test.expected); }); }); }); diff --git a/test/utils.toDecimal.js b/test/utils.toDecimal.js index 74352f3..53d65d3 100644 --- a/test/utils.toDecimal.js +++ b/test/utils.toDecimal.js @@ -1,10 +1,10 @@ var assert = require('assert'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); describe('lib/utils/utils', function () { describe('toDecimal', function () { it('should return the correct value', function () { - + assert.equal(utils.toDecimal("0x3e8"), '1000'); // allow compatiblity assert.equal(utils.toDecimal(100000), '100000'); diff --git a/test/utils.toHex.js b/test/utils.toHex.js index 0448330..0589fca 100644 --- a/test/utils.toHex.js +++ b/test/utils.toHex.js @@ -1,6 +1,8 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils'); +var utils = require('../packages/web3-utils'); + var BigNumber = require('bignumber.js'); + var assert = chai.assert; var tests = [ diff --git a/test/utils.toUtf8.js b/test/utils.toUtf8.js index 1a7b212..ab17eb9 100644 --- a/test/utils.toUtf8.js +++ b/test/utils.toUtf8.js @@ -1,6 +1,6 @@ var chai = require('chai'); -var BigNumber = require('bignumber.js'); -var utils = require('../lib/utils/utils.js'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; var tests = [ diff --git a/test/utils.toWei.js b/test/utils.toWei.js index 74eda52..b63e5d7 100644 --- a/test/utils.toWei.js +++ b/test/utils.toWei.js @@ -1,11 +1,12 @@ var chai = require('chai'); -var utils = require('../lib/utils/utils'); +var utils = require('../packages/web3-utils'); + var assert = chai.assert; describe('lib/utils/utils', function () { describe('toWei', function () { it('should return the correct value', function () { - + assert.equal(utils.toWei(1, 'wei'), '1'); assert.equal(utils.toWei(1, 'kwei'), '1000'); assert.equal(utils.toWei(1, 'Kwei'), '1000'); diff --git a/test/web3.db.getHex.js b/test/web3.db.getHex.js deleted file mode 100644 index 7e17d0c..0000000 --- a/test/web3.db.getHex.js +++ /dev/null @@ -1,14 +0,0 @@ -var testMethod = require('./helpers/test.method.js'); - -var method = 'getHex'; - -var tests = [{ - args: ['myDB', 'myKey'], - formattedArgs: ['myDB', 'myKey'], - result: '0xf', - formattedResult: '0xf', - call: 'db_'+ method -}]; - -testMethod.runTests('db', method, tests); - diff --git a/test/web3.db.getString.js b/test/web3.db.getString.js deleted file mode 100644 index 0a8a82e..0000000 --- a/test/web3.db.getString.js +++ /dev/null @@ -1,15 +0,0 @@ -var chai = require('chai'); -var testMethod = require('./helpers/test.method.js'); - -var method = 'getString'; - -var tests = [{ - args: ['myDB', 'myKey'], - formattedArgs: ['myDB', 'myKey'], - result: 'myValue', - formattedResult: 'myValue', - call: 'db_'+ method -}]; - -testMethod.runTests('db', method, tests); - diff --git a/test/web3.db.methods.js b/test/web3.db.methods.js deleted file mode 100644 index 535d03c..0000000 --- a/test/web3.db.methods.js +++ /dev/null @@ -1,15 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index.js'); -var web3 = new Web3(); -var u = require('./helpers/test.utils.js'); - -describe('web3.db', function() { - describe('methods', function() { - u.methodExists(web3.db, 'putHex'); - u.methodExists(web3.db, 'getHex'); - u.methodExists(web3.db, 'putString'); - u.methodExists(web3.db, 'getString'); - }); -}); - diff --git a/test/web3.db.putHex.js b/test/web3.db.putHex.js deleted file mode 100644 index 306abae..0000000 --- a/test/web3.db.putHex.js +++ /dev/null @@ -1,16 +0,0 @@ -var chai = require('chai'); -var web3 = require('../index'); -var testMethod = require('./helpers/test.method.js'); - -var method = 'putHex'; - -var tests = [{ - args: ['myDB', 'myKey', '0xb'], - formattedArgs: ['myDB', 'myKey', '0xb'], - result: true, - formattedResult: true, - call: 'db_'+ method -}]; - -testMethod.runTests('db', method, tests); - diff --git a/test/web3.db.putString.js b/test/web3.db.putString.js deleted file mode 100644 index ddd3287..0000000 --- a/test/web3.db.putString.js +++ /dev/null @@ -1,16 +0,0 @@ -var chai = require('chai'); -var web3 = require('../index'); -var testMethod = require('./helpers/test.method.js'); - -var method = 'putString'; - -var tests = [{ - args: ['myDB', 'myKey', 'myValue'], - formattedArgs: ['myDB', 'myKey', 'myValue'], - result: true, - formattedResult: true, - call: 'db_'+ method -}]; - -testMethod.runTests('db', method, tests); - diff --git a/test/web3.eth.accounts.js b/test/web3.eth.accounts.js deleted file mode 100644 index 2a590e2..0000000 --- a/test/web3.eth.accounts.js +++ /dev/null @@ -1,39 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'accounts'; - -var tests = [{ - result: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], - formattedResult: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], - call: 'eth_'+ method -}]; - -describe('web3.eth', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - var result = web3.eth[method]; - - // then - assert.deepEqual(test.formattedResult, result); - }); - }); - }); -}); - diff --git a/test/web3.eth.blockNumber.js b/test/web3.eth.blockNumber.js deleted file mode 100644 index ec10e7e..0000000 --- a/test/web3.eth.blockNumber.js +++ /dev/null @@ -1,59 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'blockNumber'; - -var tests = [{ - result: '0xb', - formattedResult: 11, - call: 'eth_'+ method -}]; - -describe('web3.eth', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - var result = web3.eth[method]; - - // then - assert.strictEqual(test.formattedResult, result); - }); - - it('async get property test: ' + index, function (done) { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - web3.eth.getBlockNumber(function (err, result) { - assert.strictEqual(test.formattedResult, result); - done(); - }); - - }); - }); - }); -}); - diff --git a/test/web3.eth.coinbase.js b/test/web3.eth.coinbase.js deleted file mode 100644 index 8086e58..0000000 --- a/test/web3.eth.coinbase.js +++ /dev/null @@ -1,39 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'coinbase'; - -var tests = [{ - result: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - formattedResult: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - call: 'eth_'+ method -}]; - -describe('web3.eth', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - var result = web3.eth[method]; - - // then - assert.deepEqual(test.formattedResult, result); - }); - }); - }); -}); - diff --git a/test/web3.eth.contract.js b/test/web3.eth.contract.js deleted file mode 100644 index c4aeb2b..0000000 --- a/test/web3.eth.contract.js +++ /dev/null @@ -1,250 +0,0 @@ -var assert = require('assert'); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); -var Web3 = require('../index'); - - -describe('web3.eth.contract', function() { - it('should create simple contract with one method from abi with explicit type name', function () { - - // given - var description = [{ - "name": "test(uint256)", - "type": "function", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ] - }]; - var address = '0x1234567890123456789012345678901234567892'; - - // when - var web3 = new Web3(); - var myCon = web3.eth.contract(description).at(address); - - // then - assert.equal('function', typeof myCon.test); - assert.equal('function', typeof myCon.test['uint256']); - }); - - it('should create simple contract with one method from abi with implicit type name', function () { - - // given - var description = [{ - "name": "test", - "type": "function", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ] - }]; - var address = '0x1234567890123456789012345678901234567892'; - - // when - var web3 = new Web3(); - var myCon = web3.eth.contract(description).at(address); - - // then - assert.equal('function', typeof myCon.test); - assert.equal('function', typeof myCon.test['uint256']); - }); - - it('should create contract with multiple methods', function () { - - // given - var description = [{ - "name": "test", - "type": "function", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ], - }, { - "name": "test2", - "type": "function", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ] - }]; - var address = '0x1234567890123456789012345678901234567892'; - - // when - var web3 = new Web3(); - var myCon = web3.eth.contract(description).at(address); - - // then - assert.equal('function', typeof myCon.test); - assert.equal('function', typeof myCon.test['uint256']); - assert.equal('function', typeof myCon.test2); - assert.equal('function', typeof myCon.test2['uint256']); - }); - - it('should create contract with overloaded methods', function () { - - // given - var description = [{ - "name": "test", - "type": "function", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ], - }, { - "name": "test", - "type": "function", - "inputs": [{ - "name": "a", - "type": "string" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ] - }]; - var address = '0x1234567890123456789012345678901234567892'; - - // when - var web3 = new Web3(); - var myCon = web3.eth.contract(description).at(address); - - // then - assert.equal('function', typeof myCon.test); - assert.equal('function', typeof myCon.test['uint256']); - assert.equal('function', typeof myCon.test['string']); - }); - - it('should create contract with no methods', function () { - - // given - var description = [{ - "name": "test(uint256)", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ] - }]; - var address = '0x1234567890123456789012345678901234567892'; - - // when - var web3 = new Web3(); - var myCon = web3.eth.contract(description).at(address); - - // then - assert.equal('undefined', typeof myCon.test); - - }); - - it('should create contract with one event', function () { - - // given - var description = [{ - "name": "test", - "type": "event", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ] - }]; - var address = '0x1234567890123456789012345678901234567892'; - - // when - var web3 = new Web3(); - var myCon = web3.eth.contract(description).at(address); - - // then - assert.equal('function', typeof myCon.test); - assert.equal('function', typeof myCon.test['uint256']); - - }); - - it('should create contract with nondefault constructor', function (done) { - var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); - var address = '0x1234567890123456789012345678901234567894'; - var code = '0x31241231231123123123123121cf121212i123123123123123512312412512111111'; - var description = [{ - "name": "test", - "type": "constructor", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ] - }]; - - var steps = 1; - - provider.injectResult(address); - provider.injectValidation(function (payload) { - if (steps === 1) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, 'eth_sendTransaction'); - assert.equal(payload.params[0].data, code + '0000000000000000000000000000000000000000000000000000000000000002'); - steps++; - - } else if (steps === 2) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, 'eth_newBlockFilter'); - steps++; - } - }); - - web3.eth.contract(description).new(2, {from: address, data: code}, function(e, myCon){ - done(); - web3.stopWatching(); - }); - }); -}); - diff --git a/test/web3.eth.defaultBlock.js b/test/web3.eth.defaultBlock.js index de34b47..bf96395 100644 --- a/test/web3.eth.defaultBlock.js +++ b/test/web3.eth.defaultBlock.js @@ -1,12 +1,13 @@ var chai = require('chai'); var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); +var Eth = require('../packages/web3-eth'); + +var eth = new Eth(); describe('web3.eth', function () { describe('defaultBlock', function () { it('should check if defaultBlock is set to proper value', function () { - assert.equal(web3.eth.defaultBlock, 'latest'); + assert.equal(eth.defaultBlock, 'latest'); }); }); }); diff --git a/test/web3.eth.estimateGas.js b/test/web3.eth.estimateGas.js index efa6bf3..808f682 100644 --- a/test/web3.eth.estimateGas.js +++ b/test/web3.eth.estimateGas.js @@ -1,4 +1,3 @@ -var web3 = require('../index'); var testMethod = require('./helpers/test.method.js'); var method = 'estimateGas'; diff --git a/test/web3.eth.gasPrice.js b/test/web3.eth.gasPrice.js index 6caf766..f58a3db 100644 --- a/test/web3.eth.gasPrice.js +++ b/test/web3.eth.gasPrice.js @@ -1,40 +1,14 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var BigNumber = require('bignumber.js'); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); +var testMethod = require('./helpers/test.method.js'); -var method = 'gasPrice'; +var method = 'getGasPrice'; +var methodCall = 'eth_gasPrice'; var tests = [{ result: '0x15f90', - formattedResult: new BigNumber(90000), - call: 'eth_'+ method + formattedResult: '90000', + call: methodCall }]; -describe('web3.eth', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - // when - var result = web3.eth[method]; - - // then - assert.deepEqual(test.formattedResult, result); - }); - }); - }); -}); +testMethod.runTests('eth', method, tests); diff --git a/test/web3.eth.getAccounts.js b/test/web3.eth.getAccounts.js new file mode 100644 index 0000000..2b8e16e --- /dev/null +++ b/test/web3.eth.getAccounts.js @@ -0,0 +1,19 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'getAccounts'; +var call = 'eth_accounts'; + +var tests = [{ + result: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae'], + formattedResult: ['0x47D33b27Bb249a2DBab4C0612BF9CaF4C1950855', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'], + call: call +}, +{ + result: ['0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'], + formattedResult: ['0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'], + call: call +}]; + + +testMethod.runTests('eth', method, tests); + diff --git a/test/web3.eth.getBalance.js b/test/web3.eth.getBalance.js index 7fb582a..e7599c4 100644 --- a/test/web3.eth.getBalance.js +++ b/test/web3.eth.getBalance.js @@ -1,7 +1,7 @@ -var BigNumber = require('bignumber.js'); -var Web3 = require('../index'); -var web3 = new Web3(); var testMethod = require('./helpers/test.method.js'); +var Eth = require('../packages/web3-eth'); + +var eth = new Eth(); var method = 'getBalance'; @@ -9,61 +9,74 @@ var tests = [{ args: ['0x000000000000000000000000000000000000012d', 2], formattedArgs: ['0x000000000000000000000000000000000000012d', '0x2'], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method },{ args: ['0x000000000000000000000000000000000000012d', '0x1'], formattedArgs: ['0x000000000000000000000000000000000000012d', '0x1'], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method }, { args: ['0x000000000000000000000000000000000000012d', 0x1], formattedArgs: ['0x000000000000000000000000000000000000012d', '0x1'], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method }, { args: ['0x000000000000000000000000000000000000012d'], - formattedArgs: ['0x000000000000000000000000000000000000012d', web3.eth.defaultBlock], + formattedArgs: ['0x000000000000000000000000000000000000012d', eth.defaultBlock], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method }, { + args: ['0XDBDBDB2CBD23B783741E8D7FCF51E459B497E4A6', 0x1], + formattedArgs: ['0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', '0x1'], + result: '0x31981', + formattedResult: '203137', + call: 'eth_'+ method +}, { + args: ['0xdbdbdB2cBD23b783741e8d7fcF51e459b497e4a6', 0x1], // checksum address + formattedArgs: ['0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', '0x1'], + result: '0x31981', + formattedResult: '203137', + call: 'eth_'+ method +}, + { args: ['0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', 0x1], formattedArgs: ['0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', '0x1'], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method }, { args: ['dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', 0x1], formattedArgs: ['0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', '0x1'], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method }, { args: ['0x000000000000000000000000000000000000012d', 0x1], formattedArgs: ['0x000000000000000000000000000000000000012d', '0x1'], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method }, { args: ['0x000000000000000000000000000000000000012d'], formattedArgs: ['0x000000000000000000000000000000000000012d', 'latest'], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method }, { args: ['000000000000000000000000000000000000012d'], formattedArgs: ['0x000000000000000000000000000000000000012d', 'latest'], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method }, { - args: ['XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS'], + args: ['XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS'], // iban address formattedArgs: ['0x00c5496aee77c1ba1f0854206a26dda82a81d6d8', 'latest'], result: '0x31981', - formattedResult: new BigNumber('0x31981', 16), + formattedResult: '203137', call: 'eth_'+ method }]; diff --git a/test/web3.eth.getBlock.js b/test/web3.eth.getBlock.js index 2061209..971a4e8 100644 --- a/test/web3.eth.getBlock.js +++ b/test/web3.eth.getBlock.js @@ -1,6 +1,3 @@ -var Web3 = require('../index'); -var web3 = new Web3(); -var BigNumber = require('bignumber.js'); var testMethod = require('./helpers/test.method.js'); var method = 'getBlock'; @@ -34,9 +31,9 @@ var formattedBlockResult = { "logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff", - "miner": "0x4e65fda2159562a496f9f3522f89122a3088497a", - "difficulty": new BigNumber(163591), - "totalDifficulty": new BigNumber(163591), + "miner": "0x4E65FDa2159562a496F9f3522f89122A3088497a", + "difficulty": '163591', + "totalDifficulty": '163591', "size": 163591, "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": 653145, @@ -87,9 +84,9 @@ var formattedBlockResultWithTx = { "logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff", - "miner": "0x4e65fda2159562a496f9f3522f89122a3088497a", - "difficulty": new BigNumber(163591), - "totalDifficulty": new BigNumber(163591), + "miner": "0x4E65FDa2159562a496F9f3522f89122A3088497a", + "difficulty": '163591', + "totalDifficulty": '163591', "size": 163591, "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": 653145, @@ -102,11 +99,11 @@ var formattedBlockResultWithTx = { "blockHash": "0x6fd9e2a26ab", "blockNumber": 5599, "transactionIndex": 1, - "from":"0x407d73d8a49eeb85d32cf465507dd71d507100c1", - "to":"0x85h43d8a49eeb85d32cf465507dd71d507100c1", - "value": new BigNumber(520464), + "from":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", + "to":"0x85h43d8a49EEB85D32CF465507dD71D507100C1", + "value": '520464', "gas": 520464, - "gasPrice": new BigNumber(10000000000000), + "gasPrice": '10000000000000', "input":"0x603880600c6000396000f30060", }], "uncles": ["0x460cfb8472af2c5fd05b5a2", "0xd5460cfb8472af2c5fd05b5a2"] diff --git a/test/web3.eth.getBlockNumber.js b/test/web3.eth.getBlockNumber.js new file mode 100644 index 0000000..d5357dd --- /dev/null +++ b/test/web3.eth.getBlockNumber.js @@ -0,0 +1,12 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'getBlockNumber'; + +var tests = [{ + result: '0xb', + formattedResult: 11, + call: 'eth_blockNumber' +}]; + + +testMethod.runTests('eth', method, tests); diff --git a/test/web3.eth.getBlockTransactionCount.js b/test/web3.eth.getBlockTransactionCount.js index 009b25e..83460dc 100644 --- a/test/web3.eth.getBlockTransactionCount.js +++ b/test/web3.eth.getBlockTransactionCount.js @@ -1,11 +1,15 @@ -var chai = require('chai'); -var web3 = require('../index'); var testMethod = require('./helpers/test.method.js'); var method = 'getBlockTransactionCount'; var tests = [{ + args: ['0x4e65fda2159562a496f9f3522f8922f89122a3088497a122a3088497a'], + formattedArgs: ['0x4e65fda2159562a496f9f3522f8922f89122a3088497a122a3088497a'], + result: '0xb', + formattedResult: 11, + call: 'eth_getBlockTransactionCountByHash' +},{ args: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], formattedArgs: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], result: '0xb', diff --git a/test/web3.eth.getBlockUncleCount.js b/test/web3.eth.getBlockUncleCount.js index f8193b7..9561cc5 100644 --- a/test/web3.eth.getBlockUncleCount.js +++ b/test/web3.eth.getBlockUncleCount.js @@ -1,8 +1,6 @@ -var chai = require('chai'); -var web3 = require('../index'); -var method = 'getBlockUncleCount'; var testMethod = require('./helpers/test.method.js'); +var method = 'getBlockUncleCount'; var tests = [{ args: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], diff --git a/test/web3.eth.getCode.js b/test/web3.eth.getCode.js index 9a76f5a..548ecc0 100644 --- a/test/web3.eth.getCode.js +++ b/test/web3.eth.getCode.js @@ -1,14 +1,20 @@ -var chai = require('chai'); -var Web3 = require('../index'); -var web3 = new Web3(); var testMethod = require('./helpers/test.method.js'); +var Eth = require('../packages/web3-eth'); + +var eth = new Eth(); var method = 'getCode'; var tests = [{ + args: ['0x4E65FDa2159562a496F9f3522f89122A3088497a'], // checksum address + formattedArgs: ['0x4e65fda2159562a496f9f3522f89122a3088497a', eth.defaultBlock], + result: '0x47d33b27bb249a2dbab4c0612bf9caf4747d33b27bb249a2dbab4c0612bf9cafd33b27bb249a2dbab4c0612bf9caf4c1950855', + formattedResult: '0x47d33b27bb249a2dbab4c0612bf9caf4747d33b27bb249a2dbab4c0612bf9cafd33b27bb249a2dbab4c0612bf9caf4c1950855', + call: 'eth_'+ method +},{ args: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], - formattedArgs: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', web3.eth.defaultBlock], + formattedArgs: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', eth.defaultBlock], result: '0x47d33b27bb249a2dbab4c0612bf9caf4747d33b27bb249a2dbab4c0612bf9cafd33b27bb249a2dbab4c0612bf9caf4c1950855', formattedResult: '0x47d33b27bb249a2dbab4c0612bf9caf4747d33b27bb249a2dbab4c0612bf9cafd33b27bb249a2dbab4c0612bf9caf4c1950855', call: 'eth_'+ method diff --git a/test/web3.eth.getCoinbase.js b/test/web3.eth.getCoinbase.js new file mode 100644 index 0000000..122e288 --- /dev/null +++ b/test/web3.eth.getCoinbase.js @@ -0,0 +1,13 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'getCoinbase'; + + +var tests = [{ + result: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + formattedResult: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + call: 'eth_coinbase' +}]; + + +testMethod.runTests('eth', method, tests); diff --git a/test/web3.eth.getCompilers.js b/test/web3.eth.getCompilers.js index ab426b2..6e9c081 100644 --- a/test/web3.eth.getCompilers.js +++ b/test/web3.eth.getCompilers.js @@ -1,5 +1,3 @@ -var chai = require('chai'); -var web3 = require('../index'); var testMethod = require('./helpers/test.method.js'); var method = 'getCompilers'; diff --git a/test/web3.eth.getHashRate.js b/test/web3.eth.getHashRate.js new file mode 100644 index 0000000..12f7fa9 --- /dev/null +++ b/test/web3.eth.getHashRate.js @@ -0,0 +1,14 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'getHashrate'; + + +var tests = [{ + result: '0x788a8', + formattedResult: 493736, + call: 'eth_hashrate' +}]; + + +testMethod.runTests('eth', method, tests); + diff --git a/test/web3.eth.getStorageAt.js b/test/web3.eth.getStorageAt.js index 08a46e0..690e384 100644 --- a/test/web3.eth.getStorageAt.js +++ b/test/web3.eth.getStorageAt.js @@ -1,20 +1,20 @@ -var chai = require('chai'); -var Web3 = require('../index'); -var web3 = new Web3(); var testMethod = require('./helpers/test.method.js'); +var Eth = require('../packages/web3-eth'); + +var eth = new Eth(); var method = 'getStorageAt'; var tests = [{ - args: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', 2], - formattedArgs: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', '0x2', web3.eth.defaultBlock], + args: ['0x4E65FDa2159562a496F9f3522f89122A3088497a', 2], // checksum address + formattedArgs: ['0x4e65fda2159562a496f9f3522f89122a3088497a', '0x2', eth.defaultBlock], result: '0x47d33b2', formattedResult: '0x47d33b2', call: 'eth_'+ method },{ - args: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', 2, 0], - formattedArgs: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', '0x2', '0x0'], + args: ['0x4E65FDa2159562a496F9f3522f89122A3088497a', 2, 0], + formattedArgs: ['0x4e65fda2159562a496f9f3522f89122a3088497a', '0x2', '0x0'], result: '0x47d33b27bb249a2dbab4c0612bf9caf4747d33b27bb249a2dbab4c0612bf9cafd33b27bb249a2dbab4c0612bf9caf4c1950855', formattedResult: '0x47d33b27bb249a2dbab4c0612bf9caf4747d33b27bb249a2dbab4c0612bf9cafd33b27bb249a2dbab4c0612bf9caf4c1950855', call: 'eth_'+ method diff --git a/test/web3.eth.getTransaction.js b/test/web3.eth.getTransaction.js index 897bb13..8ccdc26 100644 --- a/test/web3.eth.getTransaction.js +++ b/test/web3.eth.getTransaction.js @@ -1,6 +1,3 @@ -var chai = require('chai'); -var web3 = require('../index'); -var BigNumber = require('bignumber.js'); var testMethod = require('./helpers/test.method.js'); var method = 'getTransaction'; @@ -24,17 +21,17 @@ var formattedTxResult = { "blockHash": "0x6fd9e2a26ab", "blockNumber": 5599, "transactionIndex": 1, - "from":"0x407d73d8a49eeb85d32cf465507dd71d507100c1", - "to":"0x85h43d8a49eeb85d32cf465507dd71d507100c1", - "value": new BigNumber(520464), + "from":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", // checksum address + "to":"0x85h43d8a49EEB85D32CF465507dD71D507100C1", // checksum address + "value": '520464', "gas": 520464, - "gasPrice": new BigNumber(10000000000000), + "gasPrice": '10000000000000', "input":"0x603880600c6000396000f30060" }; var tests = [{ - args: ['0x2dbab4c0612bf9caf4c195085547dc0612bf9caf4c1950855'], - formattedArgs: ['0x2dbab4c0612bf9caf4c195085547dc0612bf9caf4c1950855'], + args: ['0x407D73d8a49eeb85D32Cf465507dd71d507100c1'], // checksum address + formattedArgs: ['0x407d73d8a49eeb85d32cf465507dd71d507100c1'], result: txResult, formattedResult: formattedTxResult, call: 'eth_'+ method + 'ByHash' diff --git a/test/web3.eth.getTransactionFromBlock.js b/test/web3.eth.getTransactionFromBlock.js index 9f59a60..8cc762a 100644 --- a/test/web3.eth.getTransactionFromBlock.js +++ b/test/web3.eth.getTransactionFromBlock.js @@ -1,6 +1,3 @@ -var chai = require('chai'); -var web3 = require('../index'); -var BigNumber = require('bignumber.js'); var testMethod = require('./helpers/test.method.js'); var method = 'getTransactionFromBlock'; @@ -26,11 +23,11 @@ var formattedTxResult = { "blockHash": "0x6fd9e2a26ab", "blockNumber": 5599, "transactionIndex": 1, - "from":"0x407d73d8a49eeb85d32cf465507dd71d507100c1", - "to":"0x85h43d8a49eeb85d32cf465507dd71d507100c1", - "value": new BigNumber(520464), + "from":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", // checksum address + "to":"0x85h43d8a49EEB85D32CF465507dD71D507100C1", // checksum address + "value": '520464', "gas": 520464, - "gasPrice": new BigNumber(10000000000000), + "gasPrice": '10000000000000', "input":"0x603880600c6000396000f30060" }; diff --git a/test/web3.eth.getTransactionReceipt.js b/test/web3.eth.getTransactionReceipt.js index f4398d9..aa5515b 100644 --- a/test/web3.eth.getTransactionReceipt.js +++ b/test/web3.eth.getTransactionReceipt.js @@ -1,6 +1,3 @@ -var chai = require('chai'); -var web3 = require('../index'); -var BigNumber = require('bignumber.js'); var testMethod = require('./helpers/test.method.js'); var method = 'getTransactionReceipt'; @@ -20,15 +17,15 @@ var txResult = { transactionHash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', blockHash: '0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265', data: '0x7b2274657374223a2274657374227', - topics: ['0x68656c6c6f','0x6d79746f70696373'] + topics: ['0x68656c6c6f','0x6d79746f70696373'] },{ transactionIndex: null, logIndex: null, blockNumber: null, transactionHash: null, blockHash: null, - data: '0x7b2274657374223a2274657374227', - topics: ['0x68656c6c6f','0x6d79746f70696373'] + data: '0x7cc274657374223a2274657374227', + topics: ['0x68656c6c6f'] }] }; var formattedTxResult = { @@ -36,10 +33,11 @@ var formattedTxResult = { "blockNumber": 5599, "transactionHash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "transactionIndex": 1, - "contractAddress":"0x407d73d8a49eeb85d32cf465507dd71d507100c1", + "contractAddress":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", // checksum address "cumulativeGasUsed": 520464, "gasUsed": 520464, "logs": [{ + id: "log_2b801386", transactionIndex: 1000, logIndex: 1000, blockNumber: 1000, @@ -48,23 +46,25 @@ var formattedTxResult = { data: '0x7b2274657374223a2274657374227', topics: ['0x68656c6c6f','0x6d79746f70696373'] },{ + id: null, transactionIndex: null, logIndex: null, blockNumber: null, transactionHash: null, blockHash: null, - data: '0x7b2274657374223a2274657374227', - topics: ['0x68656c6c6f','0x6d79746f70696373'] + data: '0x7cc274657374223a2274657374227', + topics: ['0x68656c6c6f'] }] }; var tests = [{ - args: ['0x2dbab4c0612bf9caf4c195085547dc0612bf9caf4c1950855'], - formattedArgs: ['0x2dbab4c0612bf9caf4c195085547dc0612bf9caf4c1950855'], + args: ['0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'], + formattedArgs: ['0xd6960376d6c6dea93647383ffb245cfced97ccc5c7525397a543a72fdaea5265'], result: txResult, formattedResult: formattedTxResult, call: 'eth_'+ method }]; + testMethod.runTests('eth', method, tests); diff --git a/test/web3.eth.getUncle.js b/test/web3.eth.getUncle.js index 83bbae9..ae39028 100644 --- a/test/web3.eth.getUncle.js +++ b/test/web3.eth.getUncle.js @@ -1,7 +1,3 @@ -var chai = require('chai'); -var Web3 = require('../index'); -var web3 = new Web3(); -var BigNumber = require('bignumber.js'); var testMethod = require('./helpers/test.method.js'); var method = 'getUncle'; @@ -35,9 +31,9 @@ var formattedBlockResult = { "logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff", - "miner": "0x4e65fda2159562a496f9f3522f89122a3088497a", - "difficulty": new BigNumber(163591), - "totalDifficulty": new BigNumber(163591), + "miner": "0x4E65FDa2159562a496F9f3522f89122A3088497a", // checksum address + "difficulty": '163591', + "totalDifficulty": '163591', "size": 163591, "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": 653145, @@ -88,9 +84,9 @@ var formattedBlockResultWithTx = { "logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff", - "miner": "0x4e65fda2159562a496f9f3522f89122a3088497a", - "difficulty": new BigNumber(163591), - "totalDifficulty": new BigNumber(163591), + "miner": "0x4E65FDa2159562a496F9f3522f89122A3088497a", // checksum address + "difficulty": '163591', + "totalDifficulty": '163591', "size": 163591, "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": 653145, @@ -103,11 +99,11 @@ var formattedBlockResultWithTx = { "blockHash": "0x6fd9e2a26ab", "blockNumber": 5599, "transactionIndex": 1, - "from":"0x407d73d8a49eeb85d32cf465507dd71d507100c1", - "to":"0x85h43d8a49eeb85d32cf465507dd71d507100c1", - "value": new BigNumber(520464), + "from":"0x407D73d8a49eeb85D32Cf465507dd71d507100c1", // checksum address + "to":"0x85h43d8a49EEB85D32CF465507dD71D507100C1", // checksum address + "value": '520464', "gas": 520464, - "gasPrice": new BigNumber(10000000000000), + "gasPrice": '10000000000000', "input":"0x603880600c6000396000f30060", }], "uncles": ["0x460cfb8472af2c5fd05b5a2", "0xd5460cfb8472af2c5fd05b5a2"] diff --git a/test/web3.eth.getWork.js b/test/web3.eth.getWork.js index 181c189..1fb8259 100644 --- a/test/web3.eth.getWork.js +++ b/test/web3.eth.getWork.js @@ -1,5 +1,3 @@ -var chai = require('chai'); -var web3 = require('../index'); var testMethod = require('./helpers/test.method.js'); var method = 'getWork'; diff --git a/test/web3.eth.hashRate.js b/test/web3.eth.hashRate.js deleted file mode 100644 index e657eec..0000000 --- a/test/web3.eth.hashRate.js +++ /dev/null @@ -1,43 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'hashrate'; - -var tests = [{ - result: '0x788a8', - formattedResult: 493736, - call: 'eth_'+ method -}]; - -describe('web3.eth', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - var result = web3.eth[method]; - - // then - assert.strictEqual(test.formattedResult, result); - - // clear the validation - provider.injectValidation(function () {}); - web3.reset(); - }); - }); - }); -}); - diff --git a/test/web3.eth.iban.js b/test/web3.eth.iban.js new file mode 100644 index 0000000..90353e6 --- /dev/null +++ b/test/web3.eth.iban.js @@ -0,0 +1,46 @@ +var chai = require('chai'); +var assert = chai.assert; +var Eth = require('../packages/web3-eth'); +var eth = new Eth(); + +var tests = [ + { + direct: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', + address: '0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8' // checksum address + }, + { + direct: 'XE1222Q908LN1QBBU6XUQSO1OHWJIOS46OO', + address: '0x11c5496AEE77c1bA1f0854206a26dDa82A81D6D8' + }, + { + direct: 'XE75JRZCTTLBSYEQBGAS7GID8DKR7QY0QA3', + address: '0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B' // checksum address + }, + { + error: true, + direct: 'XE81ETHXREGGAVOFYORK', + address: '0xHELLO' // checksum address + } +]; + +describe('eth', function () { + describe('iban', function () { + tests.forEach(function (test) { + it('toAddress() should transform iban to address: ' + test.address, function () { + if(test.error) { + assert.throws(eth.iban.toAddress.bind(eth, test.direct)); + } else { + assert.deepEqual(eth.iban.toAddress(test.direct), test.address); + } + }); + it('toIBAN() should transform address to iban: ' + test.address, function () { + if(test.error) { + assert.throws(eth.iban.toIBAN.bind(eth, test.address)); + } else { + assert.deepEqual(eth.iban.toIBAN(test.address), test.direct); + } + }); + }); + }); +}); + diff --git a/test/web3.eth.isMining.js b/test/web3.eth.isMining.js new file mode 100644 index 0000000..0486767 --- /dev/null +++ b/test/web3.eth.isMining.js @@ -0,0 +1,13 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'isMining'; +var call = 'eth_mining'; + +var tests = [{ + result: true, + formattedResult: true, + call: call +}]; + + +testMethod.runTests('eth', method, tests); diff --git a/test/web3.eth.isSyncing.js b/test/web3.eth.isSyncing.js deleted file mode 100644 index 3a42719..0000000 --- a/test/web3.eth.isSyncing.js +++ /dev/null @@ -1,77 +0,0 @@ -var chai = require('chai'); -var Web3 = require('../index'); -var assert = chai.assert; -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'isSyncing'; - -var tests = [{ - args: [], - formattedArgs: [], - result: [{ - startingBlock: '0xb', - currentBlock: '0xb', - highestBlock: '0xb' - }], - formattedResult: { - startingBlock: 11, - currentBlock: 11, - highestBlock: 11 - }, - call: 'eth_syncing' -}, { - args: [], - formattedArgs: [], - result: [{ - startingBlock: '0xb', - currentBlock: '0xb', - highestBlock: '0xb', - knownStates: '0xb', - pulledStates: '0xb' - }], - formattedResult: { - startingBlock: 11, - currentBlock: 11, - highestBlock: 11, - knownStates: 11, - pulledStates: 11 - }, - call: 'eth_syncing' -}]; - -describe('eth', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function (done) { - // given - var provider = new FakeHttpProvider(); - var web3 = new Web3(provider); - provider.injectBatchResults(test.result); - provider.injectValidation(function(payload) { - assert.equal(payload[0].jsonrpc, '2.0', 'failed'); - assert.equal(payload[0].method, test.call); - assert.deepEqual(payload[0].params, test.formattedArgs); - }); - - var count = 1; - - // TODO results seem to be overwritten - - - // call - var syncing = web3.eth[method](function(e, res){ - if(count === 1) { - assert.isTrue(res); - count++; - } else { - assert.deepEqual(res, test.formattedResult); - syncing.stopWatching(); - done(); - } - }); - - }); - }); - }); -}); - diff --git a/test/web3.eth.methods.js b/test/web3.eth.methods.js deleted file mode 100644 index 3104ecd..0000000 --- a/test/web3.eth.methods.js +++ /dev/null @@ -1,36 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index.js'); -var web3 = new Web3(); -var u = require('./helpers/test.utils.js'); - -describe('web3.eth', function() { - describe('methods', function() { - u.methodExists(web3.eth, 'getBalance'); - u.methodExists(web3.eth, 'getStorageAt'); - u.methodExists(web3.eth, 'getTransactionCount'); - u.methodExists(web3.eth, 'getCode'); - u.methodExists(web3.eth, 'sendTransaction'); - u.methodExists(web3.eth, 'call'); - u.methodExists(web3.eth, 'getBlock'); - u.methodExists(web3.eth, 'getTransaction'); - u.methodExists(web3.eth, 'getUncle'); - u.methodExists(web3.eth, 'getCompilers'); - u.methodExists(web3.eth.compile, 'lll'); - u.methodExists(web3.eth.compile, 'solidity'); - u.methodExists(web3.eth.compile, 'serpent'); - u.methodExists(web3.eth, 'getBlockTransactionCount'); - u.methodExists(web3.eth, 'getBlockUncleCount'); - u.methodExists(web3.eth, 'subscribe'); - u.methodExists(web3.eth, 'contract'); - - u.propertyExists(web3.eth, 'coinbase'); - u.propertyExists(web3.eth, 'mining'); - u.propertyExists(web3.eth, 'gasPrice'); - u.propertyExists(web3.eth, 'accounts'); - u.propertyExists(web3.eth, 'defaultBlock'); - u.propertyExists(web3.eth, 'blockNumber'); - u.propertyExists(web3.eth, 'protocolVersion'); - }); -}); - diff --git a/test/web3.eth.mining.js b/test/web3.eth.mining.js deleted file mode 100644 index 9be4390..0000000 --- a/test/web3.eth.mining.js +++ /dev/null @@ -1,39 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'mining'; - -var tests = [{ - result: true, - formattedResult: true, - call: 'eth_'+ method -}]; - -describe('web3.eth', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - var result = web3.eth[method]; - - // then - assert.deepEqual(test.formattedResult, result); - }); - }); - }); -}); - diff --git a/test/web3.eth.protocolVersion.js b/test/web3.eth.protocolVersion.js index bdb91fc..0aca61b 100644 --- a/test/web3.eth.protocolVersion.js +++ b/test/web3.eth.protocolVersion.js @@ -1,37 +1,13 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); +var testMethod = require('./helpers/test.method.js'); -var method = 'protocolVersion'; +var method = 'getProtocolVersion'; +var call = 'eth_protocolVersion'; var tests = [{ - result: ['1234'], - call: 'eth_'+ method + result: '12345', + formattedResult: '12345', + call: call }]; -describe('eth.protocolVersion', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - var result = web3.eth[method]; - - // then - assert.deepEqual(test.result, result); - }); - }); - }); -}); +testMethod.runTests('eth', method, tests); diff --git a/test/web3.eth.sendIBANTransaction.js b/test/web3.eth.sendIBANTransaction.js deleted file mode 100644 index 6fdcfb6..0000000 --- a/test/web3.eth.sendIBANTransaction.js +++ /dev/null @@ -1,49 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider2 = require('./helpers/FakeHttpProvider2'); - -describe('web3.eth.sendIBANTransaction', function () { - it('should send transaction', function () { - - var iban = 'XE81ETHXREGGAVOFYORK'; - var address = '0x1234567890123456789012345678901234500000'; - var exAddress = '0x1234567890123456789012345678901234567890' - - var provider = new FakeHttpProvider2(); - web3.setProvider(provider); - web3.reset(); - - provider.injectResultList([{ - result: exAddress - }, { - result: '' - }]); - - var step = 0; - provider.injectValidation(function (payload) { - if (step === 0) { - step++; - assert.equal(payload.method, 'eth_call'); - assert.deepEqual(payload.params, [{ - data: "0x3b3b57de5852454700000000000000000000000000000000000000000000000000000000", - to: web3.eth.icapNamereg().address - }, "latest"]); - - return; - } - assert.equal(payload.method, 'eth_sendTransaction'); - assert.deepEqual(payload.params, [{ - data: '0xb214faa54741564f46594f524b0000000000000000000000000000000000000000000000', - from: address, - to: exAddress, - value: payload.params[0].value // don't check this - }]); - }); - - web3.eth.sendIBANTransaction(address, iban, 10000); - - }); -}); - diff --git a/test/web3.eth.sendTransaction.js b/test/web3.eth.sendTransaction.js new file mode 100644 index 0000000..37207cd --- /dev/null +++ b/test/web3.eth.sendTransaction.js @@ -0,0 +1,88 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'sendTransaction'; + + +var tests = [{ + args: [{ + from: '0xdbdbdB2cBD23b783741e8d7fcF51e459b497e4a6', // checksum address + to: '0xdbdbdB2cBD23b783741e8d7fcF51e459b497e4a6', // checksum address + value: '1234567654321' + }], + formattedArgs: [{ + from: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + to: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + value: "0x11f71f76bb1" + }], + result: ['0x1234567'], + formattedResult: ['0x1234567'], + notification: { + method: 'eth_subscription', + params: { + subscription: '0x1234567', + result: { + blockNumber: '0x10' + } + } + }, + call: 'eth_'+ method +},{ + args: [{ + from: '0XDBDBDB2CBD23B783741E8D7FCF51E459B497E4A6', + to: '0XDBDBDB2CBD23B783741E8D7FCF51E459B497E4A6', + value: '1234567654321', + data: '0x213453ffffff' + }], + formattedArgs: [{ + from: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + to: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + value: "0x11f71f76bb1", + data: '0x213453ffffff' + }], + result: ['0x12345678976543213456786543212345675432'], + formattedResult: ['0x12345678976543213456786543212345675432'], + notification: { + method: 'eth_subscription', + params: { + subscription: '0x12345678976543213456786543212345675432', + result: { + blockNumber: '0x10' + } + } + }, + call: 'eth_'+ method +},{ + args: [{ + from: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', // iban address + to: '0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', + value: '1234567654321' + }], + formattedArgs: [{ + from: "0x00c5496aee77c1ba1f0854206a26dda82a81d6d8", + to: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + value: "0x11f71f76bb1" + }], + result: ['0x12345678976543213456786543212345675432'], + formattedResult: ['0x12345678976543213456786543212345675432'], + notification: { + method: 'eth_subscription', + params: { + subscription: '0x12345678976543213456786543212345675432', + result: { + blockNumber: '0x10' + } + } + }, + call: 'eth_'+ method +},{ + error: true, // only for testing + args: [{ + from: 'XE81ETHXREGGAVOFYORK', // iban address + to: '0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', + value: '1234567654321' + }], + call: 'eth_'+ method +}]; + +testMethod.runTests('eth', method, tests); + diff --git a/test/web3.eth.submitWork.js b/test/web3.eth.submitWork.js index 3751c80..352fa10 100644 --- a/test/web3.eth.submitWork.js +++ b/test/web3.eth.submitWork.js @@ -1,5 +1,3 @@ -var chai = require('chai'); -var web3 = require('../index'); var testMethod = require('./helpers/test.method.js'); var method = 'submitWork'; diff --git a/test/web3.eth.subscribe.js b/test/web3.eth.subscribe.js index 517db0a..e98f636 100644 --- a/test/web3.eth.subscribe.js +++ b/test/web3.eth.subscribe.js @@ -1,36 +1,60 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); -var utils = require('../lib/utils/utils'); +var testSubscription = require('./helpers/test.subscription.js'); + // NEW HEADS var tests = [{ protocol: 'eth', - args: ['newBlocks', {}], + args: ['newBlockHeaders'], firstResult: '0x1234', firstPayload: { method: "eth_subscribe", - params: ['newBlocks',{}] + params: ['newHeads'] }, secondResult: true, secondPayload: { method: "eth_unsubscribe" }, - subscription: { + subscriptions: [{ subscription: '0x1234', result: { - address: '0x123456789012345678901234567890123456789', - topics: [ - '0x4545454500000000000000001234567890123456789012345678901234567891', - '0x0000000000000000000000000000000000000000000000000000000000000001' - ], - number: 2, - data: '0x0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000008' + difficulty: "0x15d9223a23aa", + totalDifficulty: "0x15d9223a23aa", + extraData: "0xd983010305844765746887676f312e342e328777696e646f7773", + gasLimit: "0x47e7c4", + gasUsed: "0x38658", + hash: "0x950427f707bf395fda0092d4f5dcbcf32d632106fb08e397124d0726082693e6", + logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + miner: "0xf8b483dba2c3b7176a3da549ad41a48bb3121069", + nonce: "0x084149998194cc5f", + number: "0x1348c9", + parentHash: "0x7736fab79e05dc611604d22470dadad26f56fe494421b5b333de816ce1f25701", + receiptRoot: "0x2fab35823ad00c7bb388595cb46652fe7886e00660a01e867824d3dceb1c8d36", + sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + stateRoot: "0xb3346685172db67de536d8765c43c31009d0eb3bd9c501c9be3229203f15f378", + timestamp: "0x56ffeff8", + transactionsRoot: "0x0167ffa60e3ebc0b080cdb95f7c0087dd6c0e61413140e39d94d3468d7c9689f" } - } + }], + subscriptionResults: [{ + difficulty: "24022326322090", + totalDifficulty: "24022326322090", + extraData: "0xd983010305844765746887676f312e342e328777696e646f7773", + gasLimit: 4712388, + gasUsed: 231000, + hash: "0x950427f707bf395fda0092d4f5dcbcf32d632106fb08e397124d0726082693e6", + logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + miner: "0xf8b483DbA2c3B7176a3Da549ad41A48BB3121069", // checksum address + nonce: "0x084149998194cc5f", + number: 1263817, + parentHash: "0x7736fab79e05dc611604d22470dadad26f56fe494421b5b333de816ce1f25701", + receiptRoot: "0x2fab35823ad00c7bb388595cb46652fe7886e00660a01e867824d3dceb1c8d36", + sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + stateRoot: "0xb3346685172db67de536d8765c43c31009d0eb3bd9c501c9be3229203f15f378", + timestamp: 1459613688, + transactionsRoot: "0x0167ffa60e3ebc0b080cdb95f7c0087dd6c0e61413140e39d94d3468d7c9689f", + size: 0 + }] }, + // LOGS { protocol: 'eth', args: ['logs',{}], @@ -43,96 +67,167 @@ var tests = [{ secondPayload: { method: "eth_unsubscribe" }, - subscription: { + subscriptions: [{ subscription: '0x4444', result: { - address: '0x123456789012345678901234567890123456789', + logIndex: '0x23', + transactionHash: '0x2345fdfdf', + blockHash: '0x43534ffddd', + transactionIndex: '0x1', + blockNumber: '0x3222', + address: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', topics: [ '0x0000000000000000000000000000000000000000000000000000000005656565' ], - number: 2, data: '0x0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000008' + '0000000000000000000000000000000000000000000000000000000000000008' } - } + }], + subscriptionResults: [{ + id: "log_d43624aa", + blockHash: "0x43534ffddd", + blockNumber: 12834, + logIndex: 35, + transactionHash: '0x2345fdfdf', + transactionIndex: 1, + address: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // checksum address + topics: [ + '0x0000000000000000000000000000000000000000000000000000000005656565' + ], + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000008' + }] }, { protocol: 'eth', - args: ['logs',{address: '0x1234567890123456789012345678901234567859', topics: ['0x23']}], + args: ['logs',{address: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', topics: ['0x23']}], // checksum address firstResult: '0x555', firstPayload: { method: "eth_subscribe", - params: ['logs',{address: '0x1234567890123456789012345678901234567859', topics: ['0x23']}] + params: ['logs',{address: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', topics: ['0x23']}] }, secondResult: true, secondPayload: { method: "eth_unsubscribe" }, - subscription: { + subscriptions: [{ subscription: '0x555', result: { - address: '0x1234567890123456789012345678901234567859', + logIndex: '0x23', + transactionHash: '0x2345fdfdf', + blockHash: '0x43534ffddd', + transactionIndex: '0x1', + blockNumber: '0x3222', + address: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', topics: [ '0x0000000000000000000000000000000000000000000000000000000005656565' ], - number: 2, data: '0x0000000000000000000000000000000000000000000000000000000000000001' + - '0000000000000000000000000000000000000000000000000000000000000008' + '0000000000000000000000000000000000000000000000000000000000000008' } - } + }], + subscriptionResults: [{ + id: "log_d43624aa", + blockHash: "0x43534ffddd", + blockNumber: 12834, + logIndex: 35, + transactionHash: '0x2345fdfdf', + transactionIndex: 1, + address: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // checksum address + topics: [ + '0x0000000000000000000000000000000000000000000000000000000005656565' + ], + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000008' + }] +}, +{ + protocol: 'eth', + args: ['logs',{address: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', topics: ['0x23']}], + firstResult: '0x5556666', + firstPayload: { + method: "eth_subscribe", + params: ['logs',{address: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', topics: ['0x23']}] + }, + secondResult: true, + secondPayload: { + method: "eth_unsubscribe" + }, + subscriptions: [{ + subscription: '0x5556666', + result: { + logIndex: '0x23', + transactionHash: '0x2345fdfdf', + blockHash: '0x43534ffddd', + transactionIndex: '0x1', + blockNumber: '0x3222', + address: '0x11f4d0a3c12e86b4b5f39b213f7e19d048276dae', + topics: [ + '0x0000000000000000000000000000000000000000000000000000000005656565' + ], + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000008' + } + }], + subscriptionResults: [{ + id: "log_d43624aa", + blockHash: "0x43534ffddd", + blockNumber: 12834, + logIndex: 35, + transactionHash: '0x2345fdfdf', + transactionIndex: 1, + address: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', // checksum address + topics: [ + '0x0000000000000000000000000000000000000000000000000000000005656565' + ], + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000008' + }] +}, + // SYNCING +{ + protocol: 'eth', + args: ['syncing'], + firstResult: '0x666666', + firstPayload: { + method: "eth_subscribe", + params: ['syncing'] + }, + secondResult: true, + secondPayload: { + method: "eth_unsubscribe" + }, + subscriptions: [{ + subscription: '0x666666', + result: true + },{ + subscription: '0x666666', + result: { + startingBlock: '0xbff23', + currentBlock: '0xbff11', + highestBlock: '0xadf23', + knownStates: '0xaaa23', + pulledStates: '0x23' + } + }, + { + subscription: '0x666666', + result: false + } + ], + subscriptionResults: [ + true, + { + startingBlock: 786211, + currentBlock: 786193, + highestBlock: 712483, + knownStates: 698915, + pulledStates: 35 + }, + false + ] }]; -var testPolling = function (tests) { - - describe('web3.eth.subscribe', function () { - tests.forEach(function (test, index) { - it('should create a subscription', function (done) { - // given - var sub; - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - web3.reset(); - provider.injectResult(test.firstResult); - var step = 0; - provider.injectValidation(function (payload) { - if (step === 0) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, 'eth_subscribe'); - assert.deepEqual(payload.params, test.firstPayload.params); +testSubscription.runTests('eth', tests); - - step++; - } else if (step === 1) { - provider.injectResult(test.secondResult); - assert.equal(payload.method, 'eth_unsubscribe'); - } - - }); - - // add callback - test.args.push(function(err, result) { - if (test.err) { - // todo - } else { - assert.deepEqual(result, test.subscription.result); - } - sub.unsubscribe(); - done(); - - }); - - // when - var sub = web3[test.protocol].subscribe.apply(web3[test.protocol], test.args); - - provider.injectNotification({ - method: 'eth_subscription', - params: test.subscription - }); - - }); - }); - }); -}; - -testPolling(tests); diff --git a/test/web3.eth_methods.js b/test/web3.eth_methods.js new file mode 100644 index 0000000..8ab55f4 --- /dev/null +++ b/test/web3.eth_methods.js @@ -0,0 +1,44 @@ +var chai = require('chai'); +var assert = chai.assert; +var u = require('./helpers/test.utils.js'); + +var Eth = require('../packages/web3-eth'); +var eth = new Eth(); + +describe('eth', function() { + describe('methods', function() { + u.methodExists(eth, 'getBalance'); + u.methodExists(eth, 'getStorageAt'); + u.methodExists(eth, 'getTransactionCount'); + u.methodExists(eth, 'getCode'); + u.methodExists(eth, 'sendTransaction'); + u.methodExists(eth, 'call'); + u.methodExists(eth, 'getBlock'); + u.methodExists(eth, 'getTransaction'); + u.methodExists(eth, 'getUncle'); + u.methodExists(eth, 'getCompilers'); + u.methodExists(eth.compile, 'lll'); + u.methodExists(eth.compile, 'solidity'); + u.methodExists(eth.compile, 'serpent'); + u.methodExists(eth, 'getBlockTransactionCount'); + u.methodExists(eth, 'getBlockUncleCount'); + u.methodExists(eth, 'subscribe'); + u.methodExists(eth, 'contract'); + + + u.methodExists(eth, 'isMining'); + u.methodExists(eth, 'getCoinbase'); + u.methodExists(eth, 'getGasPrice'); + u.methodExists(eth, 'getAccounts'); + u.methodExists(eth, 'getBlockNumber'); + u.methodExists(eth, 'getProtocolVersion'); + + u.methodExists(eth, 'setProvider'); + + u.propertyExists(eth, 'iban'); + u.propertyExists(eth, 'providers'); + u.propertyExists(eth, 'defaultBlock'); + u.propertyExists(eth, 'defaultAccount'); + }); +}); + diff --git a/test/web3.extend.js b/test/web3.extend.js index 7b1c244..de275a4 100644 --- a/test/web3.extend.js +++ b/test/web3.extend.js @@ -1,75 +1,90 @@ var chai = require('chai'); var assert = chai.assert; var FakeHttpProvider = require('./helpers/FakeHttpProvider'); -var Web3 = require('../lib/web3'); +var Web3 = require('../src/index'); var web3 = new Web3(); var tests = [{ - properties: [new web3._extend.Property({ - name: 'gasPrice', - getter: 'eth_gasPrice', - outputFormatter: web3._extend.formatters.outputBigNumberFormatter - })] -},{ - methods: [new web3._extend.Method({ + methods: [{ + name: 'getGasPrice', + call: 'eth_gasPrice', + outputFormatter: web3.extend.formatters.outputBigNumberFormatter + },{ name: 'getBalance', call: 'eth_getBalance', params: 2, - inputFormatter: [web3._extend.utils.toAddress, web3._extend.formatters.inputDefaultBlockNumberFormatter], - outputFormatter: web3._extend.formatters.outputBigNumberFormatter - })] + inputFormatter: [web3.extend.utils.toAddress, web3.extend.formatters.inputDefaultBlockNumberFormatter], + outputFormatter: web3.extend.formatters.outputBigNumberFormatter + }] },{ property: 'admin', - properties: [new web3._extend.Property({ - name: 'gasPrice', - getter: 'eth_gasPrice', - outputFormatter: web3._extend.formatters.outputBigNumberFormatter - })], - methods: [new web3._extend.Method({ + methods: [{ + name: 'getGasPrice', + call: 'eth_gasPrice', + outputFormatter: web3.extend.formatters.outputBigNumberFormatter + },{ name: 'getBalance', call: 'eth_getBalance', params: 2, - inputFormatter: [web3._extend.utils.toAddress, web3._extend.formatters.inputDefaultBlockNumberFormatter], - outputFormatter: web3._extend.formatters.outputBigNumberFormatter - })] + inputFormatter: [web3.extend.utils.toAddress, web3.extend.formatters.inputDefaultBlockNumberFormatter], + outputFormatter: web3.extend.formatters.outputBigNumberFormatter + }] +},{ + error: true, + methods: [{ + name: 'getGasPrice', + outputFormatter: web3.extend.formatters.outputBigNumberFormatter + }] +},{ + error: true, + methods: [{ + call: 'eth_gasPrice', + outputFormatter: web3.extend.formatters.outputBigNumberFormatter + }] }]; describe('web3', function () { - describe('_extend', function () { + describe('extend', function () { tests.forEach(function (test, index) { - it('test no: ' + index, function () { - web3._extend(test); + it('test no: ' + index, function (done) { + var count = 1; + var provider = new FakeHttpProvider(); + web3.setProvider(provider); - if(test.properties) - test.properties.forEach(function(property){ + if(test.error) { + assert.throws(web3.extend.bind(web3,test)); - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(''); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, property.getter); - }); + return done(); - if(test.property) { - assert.isObject(web3[test.property][property.name]); - assert.isFunction(web3[test.property]['get'+ property.name.charAt(0).toUpperCase() + property.name.slice(1)]); - } else { - assert.isObject(web3[property.name]); - assert.isFunction(web3['get'+ property.name.charAt(0).toUpperCase() + property.name.slice(1)]); - } - }); + } else { + web3.extend(test); + } if(test.methods) test.methods.forEach(function(property){ - if(test.property) - assert.isFunction(web3[test.property][property.name]); - else - assert.isFunction(web3[property.name]); - }); + + provider.injectResult('0x1234'); + provider.injectValidation(function (payload) { + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, property.call); + + if(test.methods.length === count) + done(); + else + count++; + }); + + if(test.property) { + assert.isFunction(web3[test.property][property.name]); + web3[test.property][property.name](); + } else { + assert.isFunction(web3[property.name]); + web3[property.name](); + } + }); }); }); }); diff --git a/test/web3.fromICAP.js b/test/web3.fromICAP.js deleted file mode 100644 index e815849..0000000 --- a/test/web3.fromICAP.js +++ /dev/null @@ -1,19 +0,0 @@ -var chai = require('chai'); -var Web3 = require('../index'); -var web3 = new Web3(); -var assert = chai.assert; - -var tests = [ - { direct: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', address: '00c5496aee77c1ba1f0854206a26dda82a81d6d8'} -]; - -describe('web3', function () { - describe('fromICAP', function () { - tests.forEach(function (test) { - it('shoud transform iban to address: ' + test.address, function () { - assert.deepEqual(web3.fromICAP(test.direct), test.address); - }); - }); - }); -}); - diff --git a/test/web3.methods.js b/test/web3.methods.js deleted file mode 100644 index d47e8c9..0000000 --- a/test/web3.methods.js +++ /dev/null @@ -1,25 +0,0 @@ -var Web3 = require('../index.js'); -var web3 = new Web3(); -var u = require('./helpers/test.utils.js'); - -describe('web3', function() { - describe('methods', function () { - u.methodExists(web3, 'sha3'); - u.methodExists(web3, 'toAscii'); - u.methodExists(web3, 'fromAscii'); - u.methodExists(web3, 'toDecimal'); - u.methodExists(web3, 'fromDecimal'); - u.methodExists(web3, 'fromWei'); - u.methodExists(web3, 'toWei'); - u.methodExists(web3, 'toBigNumber'); - u.methodExists(web3, 'isAddress'); - u.methodExists(web3, 'setProvider'); - u.methodExists(web3, 'reset'); - - u.propertyExists(web3, 'providers'); - u.propertyExists(web3, 'eth'); - u.propertyExists(web3, 'db'); - u.propertyExists(web3, 'shh'); - }); -}); - diff --git a/test/web3.net.getPeerCount.js b/test/web3.net.getPeerCount.js new file mode 100644 index 0000000..b69329d --- /dev/null +++ b/test/web3.net.getPeerCount.js @@ -0,0 +1,12 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'getPeerCount'; + + +var tests = [{ + result: '0xf', + formattedResult: 15, + call: 'net_peerCount' +}]; + +testMethod.runTests('net', method, tests); diff --git a/test/web3.net.isListening.js b/test/web3.net.isListening.js new file mode 100644 index 0000000..a350412 --- /dev/null +++ b/test/web3.net.isListening.js @@ -0,0 +1,12 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'isListening'; + + +var tests = [{ + result: true, + formattedResult: true, + call: 'net_listening' +}]; + +testMethod.runTests('net', method, tests); diff --git a/test/web3.net.listening.js b/test/web3.net.listening.js deleted file mode 100644 index 3d2fed0..0000000 --- a/test/web3.net.listening.js +++ /dev/null @@ -1,39 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'listening'; - -var tests = [{ - result: true, - formattedResult: true, - call: 'net_'+ method -}]; - -describe('web3.net', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - var result = web3.net[method]; - - // then - assert.deepEqual(test.formattedResult, result); - }); - }); - }); -}); - diff --git a/test/web3.net.methods.js b/test/web3.net.methods.js deleted file mode 100644 index 917ac6f..0000000 --- a/test/web3.net.methods.js +++ /dev/null @@ -1,12 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index.js'); -var web3 = new Web3(); -var u = require('./helpers/test.utils.js'); - -describe('web3.net', function() { - describe('methods', function() { - u.propertyExists(web3.net, 'listening'); - u.propertyExists(web3.net, 'peerCount'); - }); -}); diff --git a/test/web3.net.peerCount.js b/test/web3.net.peerCount.js deleted file mode 100644 index efaea96..0000000 --- a/test/web3.net.peerCount.js +++ /dev/null @@ -1,39 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'peerCount'; - -var tests = [{ - result: '0xf', - formattedResult: 15, - call: 'net_'+ method -}]; - -describe('web3.net', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - var result = web3.net[method]; - - // then - assert.deepEqual(test.formattedResult, result); - }); - }); - }); -}); - diff --git a/test/web3.net_methods.js b/test/web3.net_methods.js new file mode 100644 index 0000000..7713efa --- /dev/null +++ b/test/web3.net_methods.js @@ -0,0 +1,12 @@ +var chai = require('chai'); +var assert = chai.assert; +var u = require('./helpers/test.utils.js'); +var Net = require('../packages/web3-net'); +var net = new Net(); + +describe('web3.net', function() { + describe('methods', function() { + u.methodExists(net, 'isListening'); + u.methodExists(net, 'getPeerCount'); + }); +}); diff --git a/test/web3.personal.getAccounts.js b/test/web3.personal.getAccounts.js new file mode 100644 index 0000000..e187fb6 --- /dev/null +++ b/test/web3.personal.getAccounts.js @@ -0,0 +1,12 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'getAccounts'; + + +var tests = [{ + result: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], + formattedResult: ['0x47D33b27Bb249a2DBab4C0612BF9CaF4C1950855'], // checksum address + call: 'personal_listAccounts' +}]; + +testMethod.runTests('personal', method, tests); diff --git a/test/web3.personal.listAccounts.js b/test/web3.personal.listAccounts.js deleted file mode 100644 index 02c085d..0000000 --- a/test/web3.personal.listAccounts.js +++ /dev/null @@ -1,38 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var web3 = new Web3(); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'listAccounts'; - -var tests = [{ - result: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], - formattedResult: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], - call: 'personal_'+ method -}]; - -describe('web3.personal', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, []); - }); - - // when - var result = web3.personal[method]; - - // then - assert.deepEqual(test.formattedResult, result); - }); - }); - }); -}); diff --git a/test/web3.personal.lockAccount.js b/test/web3.personal.lockAccount.js new file mode 100644 index 0000000..942ad95 --- /dev/null +++ b/test/web3.personal.lockAccount.js @@ -0,0 +1,20 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'lockAccount'; + + +var tests = [{ + args: ['0x47D33b27Bb249a2DBab4C0612BF9CaF4C1950855'], // checksum address + formattedArgs: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], + result: true, + formattedResult: true, + call: 'personal_'+ method +},{ + args: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], + formattedArgs: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], + result: true, + formattedResult: true, + call: 'personal_'+ method +}]; + +testMethod.runTests('personal', method, tests); diff --git a/test/web3.personal.methods.js b/test/web3.personal.methods.js deleted file mode 100644 index 22acdb6..0000000 --- a/test/web3.personal.methods.js +++ /dev/null @@ -1,13 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index.js'); -var web3 = new Web3(); -var u = require('./helpers/test.utils.js'); - -describe('web3.net', function() { - describe('methods', function() { - u.propertyExists(web3.personal, 'listAccounts'); - u.methodExists(web3.personal, 'newAccount'); - u.methodExists(web3.personal, 'unlockAccount'); - }); -}); diff --git a/test/web3.personal.newAccount.js b/test/web3.personal.newAccount.js index 4e7fdac..cd9bf21 100644 --- a/test/web3.personal.newAccount.js +++ b/test/web3.personal.newAccount.js @@ -1,15 +1,15 @@ -var chai = require('chai'); -var web3 = require('../index'); var testMethod = require('./helpers/test.method.js'); var method = 'newAccount'; + var tests = [{ args: ['P@ssw0rd!'], formattedArgs: ['P@ssw0rd!'], result: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], - formattedResult: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'], - call: 'personal_'+ method + formattedResult: ['0x47D33b27Bb249a2DBab4C0612BF9CaF4C1950855'], // checksum address + call: 'personal_newAccount' }]; testMethod.runTests('personal', method, tests); + diff --git a/test/web3.personal.sendTransaction.js b/test/web3.personal.sendTransaction.js new file mode 100644 index 0000000..45b00eb --- /dev/null +++ b/test/web3.personal.sendTransaction.js @@ -0,0 +1,61 @@ +var testMethod = require('./helpers/test.method.js'); + +var method = 'sendTransaction'; + + +var tests = [{ + args: [{ + from: '0xdbdbdB2cBD23b783741e8d7fcF51e459b497e4a6', // checksum address + to: '0xdbdbdB2cBD23b783741e8d7fcF51e459b497e4a6', // checksum address + value: '1234567654321' + }, 'SomePass@Word!'], + formattedArgs: [{ + from: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + to: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + value: "0x11f71f76bb1" + }, 'SomePass@Word!'], + result: ['0x12345678976543213456786543212345675432'], + formattedResult: ['0x12345678976543213456786543212345675432'], + call: 'personal_'+ method +},{ + args: [{ + from: '0XDBDBDB2CBD23B783741E8D7FCF51E459B497E4A6', + to: '0XDBDBDB2CBD23B783741E8D7FCF51E459B497E4A6', + value: '1234567654321', + data: '0x213453ffffff' + }, 'SomePass@Word!'], + formattedArgs: [{ + from: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + to: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + value: "0x11f71f76bb1", + data: '0x213453ffffff' + }, 'SomePass@Word!'], + result: ['0x12345678976543213456786543212345675432'], + formattedResult: ['0x12345678976543213456786543212345675432'], + call: 'personal_'+ method +},{ + args: [{ + from: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', // iban address + to: '0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', + value: '1234567654321' + }, 'SomePass@Word!'], + formattedArgs: [{ + from: "0x00c5496aee77c1ba1f0854206a26dda82a81d6d8", + to: "0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + value: "0x11f71f76bb1" + }, 'SomePass@Word!'], + result: ['0x12345678976543213456786543212345675432'], + formattedResult: ['0x12345678976543213456786543212345675432'], + call: 'personal_'+ method +},{ + error: true, // only for testing + args: [{ + from: 'XE81ETHXREGGAVOFYORK', // iban address + to: '0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6', + value: '1234567654321' + }, 'SomePass@Word!'], + call: 'personal_'+ method +}]; + +testMethod.runTests('personal', method, tests); + diff --git a/test/web3.personal.unlockAccount.js b/test/web3.personal.unlockAccount.js index 25af902..26d53e0 100644 --- a/test/web3.personal.unlockAccount.js +++ b/test/web3.personal.unlockAccount.js @@ -1,11 +1,10 @@ -var chai = require('chai'); -var web3 = require('../index'); var testMethod = require('./helpers/test.method.js'); var method = 'unlockAccount'; + var tests = [{ - args: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', 'P@ssw0rd!'], + args: ['0x47D33b27Bb249a2DBab4C0612BF9CaF4C1950855', 'P@ssw0rd!'], // checksum address formattedArgs: ['0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', 'P@ssw0rd!', null], result: true, formattedResult: true, diff --git a/test/web3.personal_methods.js b/test/web3.personal_methods.js new file mode 100644 index 0000000..adf2573 --- /dev/null +++ b/test/web3.personal_methods.js @@ -0,0 +1,15 @@ +var chai = require('chai'); +var assert = chai.assert; +var u = require('./helpers/test.utils.js'); +var Personal = require('../packages/web3-personal'); +var personal = new Personal(); + +describe('web3.net', function() { + describe('methods', function() { + u.methodExists(personal, 'getAccounts'); + u.methodExists(personal, 'newAccount'); + u.methodExists(personal, 'unlockAccount'); + u.methodExists(personal, 'lockAccount'); + u.methodExists(personal, 'sendTransaction'); + }); +}); diff --git a/test/web3.sha3.js b/test/web3.sha3.js deleted file mode 100644 index f9fc6e7..0000000 --- a/test/web3.sha3.js +++ /dev/null @@ -1,20 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index'); -var sha3 = require('../lib/utils/sha3'); -var web3 = new Web3(); - -var method = 'sha3'; - -describe('web3.sha3', function () { - it('should return sha3 with hex prefix', function() { - test1 = web3.sha3('test123'); - test2 = web3.sha3('test(int)'); - test3 = web3.sha3('0x80', {encoding: 'hex'}); - test4 = web3.sha3('0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1', {encoding: 'hex'}); - assert.deepEqual(test1, '0x' + sha3('test123')); - assert.deepEqual(test2, '0x' + sha3('test(int)')); - assert.deepEqual(test3, '0x' + sha3('0x80', {encoding: 'hex'})); - assert.deepEqual(test4, '0x' + sha3('0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1', {encoding: 'hex'})); - }); -}); diff --git a/test/web3.shh.hasIdentity.js b/test/web3.shh.hasIdentity.js index 569247a..9882768 100644 --- a/test/web3.shh.hasIdentity.js +++ b/test/web3.shh.hasIdentity.js @@ -1,5 +1,3 @@ -var chai = require('chai'); -var web3 = require('../index'); var testMethod = require('./helpers/test.method.js'); var method = 'hasIdentity'; diff --git a/test/web3.shh.methods.js b/test/web3.shh.methods.js deleted file mode 100644 index 33f1f74..0000000 --- a/test/web3.shh.methods.js +++ /dev/null @@ -1,17 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var Web3 = require('../index.js'); -var web3 = new Web3(); -var u = require('./helpers/test.utils.js'); - -describe('web3.shh', function() { - describe('methods', function() { - u.methodExists(web3.shh, 'post'); - u.methodExists(web3.shh, 'newIdentity'); - u.methodExists(web3.shh, 'hasIdentity'); - u.methodExists(web3.shh, 'newGroup'); - u.methodExists(web3.shh, 'addToGroup'); - u.methodExists(web3.shh, 'subscribe'); - }); -}); - diff --git a/test/web3.shh.post.js b/test/web3.shh.post.js index dd2a666..918253d 100644 --- a/test/web3.shh.post.js +++ b/test/web3.shh.post.js @@ -1,7 +1,5 @@ -var chai = require('chai'); -var Web3 = require('../index'); -var web3 = new Web3(); var testMethod = require('./helpers/test.method.js'); +var utils = require('../packages/web3-utils'); var method = 'post'; @@ -9,17 +7,16 @@ var tests = [{ args: [{ from: '0x123123123', topics: ['hello_world'], - payload: web3.toHex('12345'), + payload: utils.toHex('12345'), ttl: 100, workToProve: 101 }], formattedArgs: [{ from: '0x123123123', - topics: [web3.fromAscii('hello_world')], - payload: web3.toHex('12345'), - ttl: web3.toHex('100'), - workToProve: web3.toHex('101'), - priority: '0x0' + topics: [utils.fromUtf8('hello_world')], + payload: utils.toHex('12345'), + ttl: utils.toHex('100'), + workToProve: utils.toHex('101') }], result: true, formattedResult: true, @@ -30,16 +27,14 @@ var tests = [{ topics: ['hello_world'], payload: '0x12345', ttl: 0x100, - workToProve: 0x101, - priority: 0x15 + workToProve: 0x101 }], formattedArgs: [{ from: '0x21312', - topics: [web3.fromAscii('hello_world')], + topics: [utils.fromUtf8('hello_world')], payload: '0x12345', ttl: '0x100', - workToProve: '0x101', - priority: '0x15' + workToProve: '0x101' }], result: true, formattedResult: true, diff --git a/test/web3.shh.subscribe.js b/test/web3.shh.subscribe.js index 2d6f716..668549b 100644 --- a/test/web3.shh.subscribe.js +++ b/test/web3.shh.subscribe.js @@ -1,92 +1,43 @@ -var chai = require('chai'); -var Web3 = require('../index'); -var web3 = new Web3(); -var assert = chai.assert; -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); +var testSubscription = require('./helpers/test.subscription.js'); -var method = 'subscribe'; +// TODO discuss the whisper in and outputs with vlad! +// NEW HEADS var tests = [{ - args: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['0x324f5435', '0x564b4566f3453'] + protocol: 'shh', + args: ['messages',{topics: ['Hello','World!']}], + firstResult: '0x1234', + firstPayload: { + method: "shh_subscribe", + params: ['messages',{topics: ['0x48656c6c6f','0x576f726c6421']}], + }, + secondResult: true, + secondPayload: { + method: "shh_unsubscribe" + }, + subscriptions: [{ + subscription: '0x1234', + result: { + expiry: '0x38658', + sent: "0x56ffeff8", + ttl: '0x38658', + workProved: '0x38658', + payload: '0x23452', + topics: ['0x48656c6c6f','0x576f726c6421'] + } }], - formattedArgs: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['0x324f5435', '0x564b4566f3453'] - }], - result: '0xf', - formattedResult: '0xf', - call: 'shh_subscribe' -}, -{ - args: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['0x324f5435', ['0x564b4566f3453', '0x345345343453']] - }], - formattedArgs: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['0x324f5435', ['0x564b4566f3453', '0x345345343453']] - }], - result: '0xf', - formattedResult: '0xf', - call: 'shh_subscribe' -}, -{ - args: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['0x324f5435', null, ['0x564b4566f3453', '0x345345343453']] - }], - formattedArgs: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['0x324f5435', null, ['0x564b4566f3453', '0x345345343453']] - }], - result: '0xf', - formattedResult: '0xf', - call: 'shh_subscribe' -}, -{ - args: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['myString', 11, '23', null] - }], - formattedArgs: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['0x6d79537472696e67', '0x3131', '0x3233', null] - }], - result: '0xf', - formattedResult: '0xf', - call: 'shh_subscribe' + subscriptionResults: [{ + expiry: 231000, + sent: 1459613688, + ttl: 231000, + workProved: 231000, + payload: '0x23452', + topics: ['Hello','World!'] + }] }]; -describe('shh', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - web3.reset(); - provider.injectResult(test.result); - var step = 0; - provider.injectValidation(function (payload) { - if(step) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, test.formattedArgs); +testSubscription.runTests('shh', tests); - step++; - } - }); - test.args.push(function(err, res){}); - // call - web3.shh[method].apply(web3.shh, test.args); - - }); - }); - }); -}); diff --git a/test/web3.shh_methods.js b/test/web3.shh_methods.js new file mode 100644 index 0000000..507cd4d --- /dev/null +++ b/test/web3.shh_methods.js @@ -0,0 +1,15 @@ +var u = require('./helpers/test.utils.js'); +var Shh = require('../packages/web3-shh'); +var shh = new Shh(); + +describe('shh', function() { + describe('methods', function() { + u.methodExists(shh, 'post'); + u.methodExists(shh, 'newIdentity'); + u.methodExists(shh, 'hasIdentity'); + u.methodExists(shh, 'newGroup'); + u.methodExists(shh, 'addToGroup'); + u.methodExists(shh, 'subscribe'); + }); +}); + diff --git a/test/web3.utils.sha3.js b/test/web3.utils.sha3.js new file mode 100644 index 0000000..21df435 --- /dev/null +++ b/test/web3.utils.sha3.js @@ -0,0 +1,52 @@ +var chai = require('chai'); +var assert = chai.assert; +var sha3 = require('../packages/web3-utils').sha3; +var CryptoJS = require('crypto-js'); +var cjsSha3 = require('crypto-js/sha3'); + +var method = 'sha3'; + +describe('web3.sha3', function () { + it('should return sha3 with hex prefix', function() { + test1 = sha3('test123'); + test2 = sha3('test(int)'); + assert.deepEqual(test1, '0x' + cjsSha3('test123', { + outputLength: 256 + }).toString()); + assert.deepEqual(test2, '0x' + cjsSha3('test(int)', { + outputLength: 256 + }).toString()); + }); + it('should return sha3 with hex prefix when hex input', function() { + var sha3Hex = function(value){ + if (value.length > 2 && value.substr(0, 2) === '0x') { + value = value.substr(2); + } + value = CryptoJS.enc.Hex.parse(value); + + return cjsSha3(value, { + outputLength: 256 + }).toString(); + }; + + test3 = sha3('0x80', {encoding: 'hex'}); + test4 = sha3('0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1', {encoding: 'hex'}); + assert.deepEqual(test3, '0x' + sha3Hex('0x80')); + assert.deepEqual(test4, '0x' + sha3Hex('0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1')); + }); + it('should return sha3 with hex prefix when hex input', function() { + + var test = function (v, e, o) { + it('should encode ' + v + ' to ' + e, function () { + assert.equal(sha3(v, o), e); + }); + }; + + test('test123', '0xf81b517a242b218999ec8eec0ea6e2ddbef2a367a14e93f4a32a39e260f686ad'); + test('test(int)', '0xf4d03772bec1e62fbe8c5691e1a9101e520e8f8b5ca612123694632bf3cb51b1'); + test('0x80', '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', { encoding: 'hex' }); + test('0x80', '0x6b03a5eef7706e3fb52a61c19ab1122fad7237726601ac665bd4def888f0e4a0'); + test('0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1', '0x82ff40c0a986c6a5cfad4ddf4c3aa6996f1a7837f9c398e17e5de5cbd5a12b28', { encoding: 'hex' }); + + }); +}); diff --git a/test/web3.utils_methods.js b/test/web3.utils_methods.js new file mode 100644 index 0000000..e0d92e1 --- /dev/null +++ b/test/web3.utils_methods.js @@ -0,0 +1,17 @@ +var u = require('./helpers/test.utils.js'); +var utils = require('../packages/web3-utils'); + +describe('utils', function() { + describe('methods', function () { + u.methodExists(utils, 'sha3'); + u.methodExists(utils, 'toAscii'); + u.methodExists(utils, 'fromAscii'); + u.methodExists(utils, 'toDecimal'); + u.methodExists(utils, 'fromDecimal'); + u.methodExists(utils, 'fromWei'); + u.methodExists(utils, 'toWei'); + u.methodExists(utils, 'toBigNumber'); + u.methodExists(utils, 'isAddress'); + }); +}); + diff --git a/test/web3_methods.js b/test/web3_methods.js new file mode 100644 index 0000000..34cd6c5 --- /dev/null +++ b/test/web3_methods.js @@ -0,0 +1,20 @@ +var u = require('./helpers/test.utils.js'); +var Web3 = require('../src/index.js'); +var web3 = new Web3(); + +describe('web3', function() { + describe('methods', function () { + u.methodExists(web3, 'setProvider'); + + u.propertyExists(web3, 'providers'); + // u.propertyExists(web3, 'currentProvider'); + + u.propertyExists(web3, 'eth'); + u.propertyExists(web3, 'net'); + u.propertyExists(web3, 'shh'); + u.propertyExists(web3, 'personal'); + + u.propertyExists(web3, 'utils'); + }); +}); +