mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-24 12:08:22 +00:00
1 line
31 KiB
JavaScript
1 line
31 KiB
JavaScript
require=function t(e,r,n){function o(a,u){if(!r[a]){if(!e[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[a]={exports:{}};e[a][0].call(l.exports,function(t){var r=e[a][1][t];return o(r?r:t)},l,l.exports,t,e,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(t,e,r){var n=t("../utils/utils"),o=t("./coder"),i=t("./utils"),a=function(t,e){var r=t.map(function(t){return t.type});return o.encodeParams(r,e)},u=function(t,e){var r=t.map(function(t){return t.type});return o.decodeParams(r,e)},s=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),o=n.extractTypeName(t.name),i=function(){var e=Array.prototype.slice.call(arguments);return a(t.inputs,e)};void 0===e[r]&&(e[r]=i),e[r][o]=i}),e},c=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),o=n.extractTypeName(t.name),i=function(e){return u(t.outputs,e)};void 0===e[r]&&(e[r]=i),e[r][o]=i}),e},l=function(t,e){var r=i.getConstructor(t,e.length);return r?a(r.inputs,e):(e.length>0&&console.warn("didn't found matching constructor, using default one"),"")};e.exports={inputParser:s,outputParser:c,formatInput:a,formatOutput:u,formatConstructorParams:l}},{"../utils/utils":8,"./coder":2,"./utils":5}],2:[function(t,e,r){var n=t("bignumber.js"),o=t("../utils/utils"),i=t("./formatters"),a=t("./param"),u=function(t){return"[]"===t.slice(-2)},s=function(t){this._name=t.name,this._match=t.match,this._mode=t.mode,this._inputFormatter=t.inputFormatter,this._outputFormatter=t.outputFormatter};s.prototype.isType=function(t){return"strict"===this._match?this._name===t||0===t.indexOf(this._name)&&"[]"===t.slice(this._name.length):"prefix"===this._match?0===t.indexOf(this._name):void 0},s.prototype.formatInput=function(t,e){if(o.isArray(t)&&e){var r=this;return t.map(function(t){return r._inputFormatter(t)}).reduce(function(t,e){return t.appendArrayElement(e),t},new a("",i.formatInputInt(t.length).value))}return this._inputFormatter(t)},s.prototype.formatOutput=function(t,e){if(e){for(var r=[],o=new n(t.prefix,16),i=0;64*o>i;i+=64)r.push(this._outputFormatter(new a(t.suffix.slice(i,i+64))));return r}return this._outputFormatter(t)},s.prototype.isVariadicType=function(t){return u(t)||"bytes"===this._mode},s.prototype.shiftParam=function(t,e){if("bytes"===this._mode)return e.shiftBytes();if(u(t)){var r=new n(e.prefix.slice(0,64),16);return e.shiftArray(r)}return e.shiftValue()};var c=function(t){this._types=t};c.prototype._requireType=function(t){var e=this._types.filter(function(e){return e.isType(t)})[0];if(!e)throw Error("invalid solidity type!: "+t);return e},c.prototype._bytesToParam=function(t,e){var r=this,n=t.reduce(function(t,e){return r._requireType(e).isVariadicType(e)?t+1:t},0),o=t.length-n,i=e.slice(0,64*n);e=e.slice(64*n);var u=e.slice(0,64*o),s=e.slice(64*o);return new a(u,i,s)},c.prototype._formatInput=function(t,e){return this._requireType(t).formatInput(e,u(t))},c.prototype.encodeParam=function(t,e){return this._formatInput(t,e).encode()},c.prototype.encodeParams=function(t,e){var r=this;return t.map(function(t,n){return r._formatInput(t,e[n])}).reduce(function(t,e){return t.append(e),t},new a).encode()},c.prototype._formatOutput=function(t,e){return this._requireType(t).formatOutput(e,u(t))},c.prototype.decodeParam=function(t,e){return this._formatOutput(t,this._bytesToParam([t],e))},c.prototype.decodeParams=function(t,e){var r=this,n=this._bytesToParam(t,e);return t.map(function(t){var e=r._requireType(t),o=e.shiftParam(t,n);return e.formatOutput(o,u(t))})};var l=new c([new s({name:"address",match:"strict",mode:"value",inputFormatter:i.formatInputInt,outputFormatter:i.formatOutputAddress}),new s({name:"bool",match:"strict",mode:"value",inputFormatter:i.formatInputBool,outputFormatter:i.formatOutputBool}),new s({name:"int",match:"prefix",mode:"value",inputFormatter:i.formatInputInt,outputFormatter:i.formatOutputInt}),new s({name:"uint",match:"prefix",mode:"value",inputFormatter:i.formatInputInt,outputFormatter:i.formatOutputUInt}),new s({name:"bytes",match:"prefix",mode:"bytes",inputFormatter:i.formatInputString,outputFormatter:i.formatOutputString}),new s({name:"real",match:"prefix",mode:"value",inputFormatter:i.formatInputReal,outputFormatter:i.formatOutputReal}),new s({name:"ureal",match:"prefix",mode:"value",inputFormatter:i.formatInputReal,outputFormatter:i.formatOutputUReal})]);e.exports=l},{"../utils/utils":8,"./formatters":3,"./param":4,"bignumber.js":"bignumber.js"}],3:[function(t,e,r){var n=t("bignumber.js"),o=t("../utils/utils"),i=t("../utils/config"),a=t("./param"),u=function(t){var e=2*i.ETH_PADDING;n.config(i.ETH_BIGNUMBER_ROUNDING_MODE);var r=o.padLeft(o.toTwosComplement(t).round().toString(16),e);return new a(r)},s=function(t){var e=o.fromAscii(t,i.ETH_PADDING).substr(2);return new a("",u(t.length).value,e)},c=function(t){var e="000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0");return new a(e)},l=function(t){return u(new n(t).times(new n(2).pow(128)))},f=function(t){return"1"===new n(t.substr(0,1),16).toString(2).substr(0,1)},p=function(t){var e=t.value||"0";return f(e)?new n(e,16).minus(new n("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new n(e,16)},m=function(t){var e=t.value||"0";return new n(e,16)},h=function(t){return p(t).dividedBy(new n(2).pow(128))},d=function(t){return m(t).dividedBy(new n(2).pow(128))},g=function(t){return"0x"+t.value},v=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t.value?!0:!1},y=function(t){return o.toAscii(t.suffix)},b=function(t){var e=t.value;return"0x"+e.slice(e.length-40,e.length)};e.exports={formatInputInt:u,formatInputString:s,formatInputBool:c,formatInputReal:l,formatOutputInt:p,formatOutputUInt:m,formatOutputReal:h,formatOutputUReal:d,formatOutputHash:g,formatOutputBool:v,formatOutputString:y,formatOutputAddress:b}},{"../utils/config":7,"../utils/utils":8,"./param":4,"bignumber.js":"bignumber.js"}],4:[function(t,e,r){var n=function(t,e,r){this.prefix=e||"",this.value=t||"",this.suffix=r||""};n.prototype.append=function(t){this.prefix+=t.prefix,this.value+=t.value,this.suffix+=t.suffix},n.prototype.appendArrayElement=function(t){this.suffix+=t.value,this.prefix+=t.prefix},n.prototype.encode=function(){return this.prefix+this.value+this.suffix},n.prototype.shiftValue=function(){var t=this.value.slice(0,64);return this.value=this.value.slice(64),new n(t)},n.prototype.shiftBytes=function(){return this.shiftArray(1)},n.prototype.shiftArray=function(t){var e=this.prefix.slice(0,64);this.prefix=this.value.slice(64);var r=this.suffix.slice(0,64*t);return this.suffix=this.suffix.slice(64*t),new n("",e,r)},n.prototype.empty=function(){return!this.value.length&&!this.prefix.length&&!this.suffix.length},e.exports=n},{}],5:[function(t,e,r){var n=function(t,e){return t.filter(function(t){return"constructor"===t.type&&t.inputs.length===e})[0]},o=function(t){return t.filter(function(t){return"function"===t.type})},i=function(t){return t.filter(function(t){return"event"===t.type})};e.exports={getConstructor:n,filterFunctions:o,filterEvents:i}},{}],6:[function(t,e,r){"use strict";r.XMLHttpRequest="undefined"==typeof XMLHttpRequest?{}:XMLHttpRequest},{}],7:[function(t,e,r){var n=t("bignumber.js"),o=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];e.exports={ETH_PADDING:32,ETH_SIGNATURE_LENGTH:4,ETH_UNITS:o,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:n.ROUND_DOWN},ETH_POLLING_TIMEOUT:1e3,defaultBlock:"latest",defaultAccount:void 0}},{"bignumber.js":"bignumber.js"}],8:[function(t,e,r){var n=t("bignumber.js"),o={wei:"1",kwei:"1000",ada:"1000",mwei:"1000000",babbage:"1000000",gwei:"1000000000",shannon:"1000000000",szabo:"1000000000000",finney:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",einstein:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"},i=function(t,e,r){return new Array(e-t.length+1).join(r?r:"0")+t},a=function(t,e){for(var r=!1,n=0;n<t.length&&!r;n++)r=e(t[n]);return r?n-1:-1},u=function(t){var e="",r=0,n=t.length;for("0x"===t.substring(0,2)&&(r=2);n>r;r+=2){var o=parseInt(t.substr(r,2),16);if(0===o)break;e+=String.fromCharCode(o)}return e},s=function(t){for(var e="",r=0;r<t.length;r++){var n=t.charCodeAt(r).toString(16);e+=n.length<2?"0"+n:n}return e},c=function(t,e){e=void 0===e?0:e;for(var r=s(t);r.length<2*e;)r+="00";return"0x"+r},l=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},f=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)).replace(" ",""):""},p=function(t){return y(t).toNumber()},m=function(t){var e=y(t),r=e.toString(16);return e.lessThan(0)?"-0x"+r.substr(1):"0x"+r},h=function(t){if(null===t||"undefined"==typeof t)return t;if(T(t))return m(+t);if(F(t))return m(t);if(O(t))return c(JSON.stringify(t));if(I(t)){if(0===t.indexOf("-0x"))return m(t);if(!isFinite(t))return c(t)}return m(t)},d=function(t){t=t?t.toLowerCase():"ether";var e=o[t];if(void 0===e)throw new Error("This unit doesn't exists, please use the one of the following units"+JSON.stringify(o,null,2));return new n(e,10)},g=function(t,e){var r=y(t).dividedBy(d(e));return F(t)?r:r.toString(10)},v=function(t,e){var r=y(t).times(d(e));return F(t)?r:r.toString(10)},y=function(t){return t=t||0,F(t)?t:!I(t)||0!==t.indexOf("0x")&&0!==t.indexOf("-0x")?new n(t.toString(10),10):new n(t.replace("0x",""),16)},b=function(t){var e=y(t);return e.lessThan(0)?new n("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(e).plus(1):e},w=function(t){return/^0x[0-9a-f]{40}$/.test(t)},x=function(t){return/^(0x)?[0-9a-f]{40}$/.test(t)},_=function(t){return w(t)?t:/^[0-9a-f]{40}$/.test(t)?"0x"+t:"0x"+i(h(t).substr(2),40)},F=function(t){return t instanceof n||t&&t.constructor&&"BigNumber"===t.constructor.name},I=function(t){return"string"==typeof t||t&&t.constructor&&"String"===t.constructor.name},N=function(t){return"function"==typeof t},O=function(t){return"object"==typeof t},T=function(t){return"boolean"==typeof t},B=function(t){return t instanceof Array},A=function(t){try{return!!JSON.parse(t)}catch(e){return!1}};e.exports={padLeft:i,findIndex:a,toHex:h,toDecimal:p,fromDecimal:m,toAscii:u,fromAscii:c,extractDisplayName:l,extractTypeName:f,toWei:v,fromWei:g,toBigNumber:y,toTwosComplement:b,toAddress:_,isBigNumber:F,isStrictAddress:w,isAddress:x,isFunction:N,isString:I,isObject:O,isBoolean:T,isArray:B,isJson:A}},{"bignumber.js":"bignumber.js"}],9:[function(t,e,r){e.exports={version:"0.2.8"}},{}],10:[function(t,e,r){var n=t("./version.json"),o=t("./web3/net"),i=t("./web3/eth"),a=t("./web3/db"),u=t("./web3/shh"),s=t("./web3/watches"),c=t("./web3/filter"),l=t("./utils/utils"),f=t("./web3/formatters"),p=t("./web3/requestmanager"),m=t("./utils/config"),h=t("./web3/method"),d=t("./web3/property"),g=[new h({name:"sha3",call:"web3_sha3",params:1})],v=[new d({name:"version.client",getter:"web3_clientVersion"}),new d({name:"version.network",getter:"net_version",inputFormatter:l.toDecimal}),new d({name:"version.ethereum",getter:"eth_protocolVersion",inputFormatter:l.toDecimal}),new d({name:"version.whisper",getter:"shh_version",inputFormatter:l.toDecimal})],y=function(t,e){e.forEach(function(e){e.attachToObject(t)})},b=function(t,e){e.forEach(function(e){e.attachToObject(t)})},w={};w.providers={},w.version={},w.version.api=n.version,w.eth={},w.eth.filter=function(t,e,r,n){return t._isEvent?t(e,r):new c(t,s.eth(),n||f.outputLogFormatter)},w.shh={},w.shh.filter=function(t){return new c(t,s.shh(),f.outputPostFormatter)},w.net={},w.db={},w.setProvider=function(t){p.getInstance().setProvider(t)},w.reset=function(){p.getInstance().reset(),m.defaultBlock="latest",m.defaultAccount=void 0},w.toHex=l.toHex,w.toAscii=l.toAscii,w.fromAscii=l.fromAscii,w.toDecimal=l.toDecimal,w.fromDecimal=l.fromDecimal,w.toBigNumber=l.toBigNumber,w.toWei=l.toWei,w.fromWei=l.fromWei,w.isAddress=l.isAddress,Object.defineProperty(w.eth,"defaultBlock",{get:function(){return m.defaultBlock},set:function(t){return m.defaultBlock=t,t}}),Object.defineProperty(w.eth,"defaultAccount",{get:function(){return m.defaultAccount},set:function(t){return m.defaultAccount=t,t}}),y(w,g),b(w,v),y(w.net,o.methods),b(w.net,o.properties),y(w.eth,i.methods),b(w.eth,i.properties),y(w.db,a.methods),y(w.shh,u.methods),e.exports=w},{"./utils/config":7,"./utils/utils":8,"./version.json":9,"./web3/db":12,"./web3/eth":14,"./web3/filter":16,"./web3/formatters":17,"./web3/method":20,"./web3/net":21,"./web3/property":22,"./web3/requestmanager":24,"./web3/shh":25,"./web3/watches":27}],11:[function(t,e,r){function n(t,e){t.forEach(function(t){if(-1===t.name.indexOf("(")){var e=t.name,r=t.inputs.map(function(t){return t.type}).join();t.name=e+"("+r+")"}});var r="";if(a.isAddress(e))r=e;else{e=e||{};var n=Array.prototype.slice.call(arguments,2),u=i.formatConstructorParams(t,n);e.data+=u,r=o.eth.sendTransaction(e)}var s={};return l(s),f(s,t,r),p(s,t,r),m(s,t,r),s}var o=t("../web3"),i=t("../solidity/abi"),a=t("../utils/utils"),u=t("../solidity/utils"),s=t("./event"),c=t("./signature"),l=function(t){t.call=function(e){return t._isTransaction=!1,t._options=e,t},t.sendTransaction=function(e){return t._isTransaction=!0,t._options=e,t}},f=function(t,e,r){var n=i.inputParser(e),s=i.outputParser(e);u.filterFunctions(e).forEach(function(e){var i=a.extractDisplayName(e.name),u=a.extractTypeName(e.name),l=function(){var a=Array.prototype.slice.call(arguments),l=c.functionSignatureFromAscii(e.name),f=n[i][u].apply(null,a),p=t._options||{};p.to=r,p.data=l+f;var m=t._isTransaction===!0||t._isTransaction!==!1&&!e.constant;if(t._options={},t._isTransaction=null,m)return void o.eth.sendTransaction(p);var h=o.eth.call(p),d=s[i][u](h);return 1===d.length?d[0]:d};void 0===t[i]&&(t[i]=l),t[i][u]=l})},p=function(t,e,r){t.address=r,t._onWatchEventResult=function(t){var r=event.getMatchingEvent(u.filterEvents(e)),n=s.outputParser(r);return n(t)},Object.defineProperty(t,"topics",{get:function(){return u.filterEvents(e).map(function(t){return c.eventSignatureFromAscii(t.name)})}})},m=function(t,e,r){u.filterEvents(e).forEach(function(e){var n=function(){var t=Array.prototype.slice.call(arguments),n=c.eventSignatureFromAscii(e.name),i=s.inputParser(r,n,e),a=i.apply(null,t),u=function(t){var r=s.outputParser(e);return r(t)};return o.eth.filter(a,void 0,void 0,u)};n._isEvent=!0;var i=a.extractDisplayName(e.name),u=a.extractTypeName(e.name);void 0===t[i]&&(t[i]=n),t[i][u]=n})},h=function(t){return n.bind(null,t)};e.exports=h},{"../solidity/abi":1,"../solidity/utils":5,"../utils/utils":8,"../web3":10,"./event":15,"./signature":26}],12:[function(t,e,r){var n=t("./method"),o=new n({name:"putString",call:"db_putString",params:3}),i=new n({name:"getString",call:"db_getString",params:2}),a=new n({name:"putHex",call:"db_putHex",params:3}),u=new n({name:"getHex",call:"db_getHex",params:2}),s=[o,i,a,u];e.exports={methods:s}},{"./method":20}],13:[function(t,e,r){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+", is it running?")},InvalidProvider:function(){return new Error("Providor not set or invalid")},InvalidResponse:function(t){var e=t&&t.error&&t.error.message?t.error.message:"Invalid JSON RPC response";return new Error(e)}}},{}],14:[function(t,e,r){"use strict";var n=t("./formatters"),o=t("../utils/utils"),i=t("./method"),a=t("./property"),u=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},s=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},c=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},l=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},f=function(t){return o.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},p=new i({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[o.toAddress,n.inputDefaultBlockNumberFormatter],outputFormatter:n.outputBigNumberFormatter}),m=new i({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[null,o.toHex,n.inputDefaultBlockNumberFormatter]}),h=new i({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[o.toAddress,n.inputDefaultBlockNumberFormatter]}),d=new i({name:"getBlock",call:u,params:2,inputFormatter:[o.toHex,function(t){return!!t}],outputFormatter:n.outputBlockFormatter}),g=new i({name:"getUncle",call:c,params:2,inputFormatter:[o.toHex,o.toHex],outputFormatter:n.outputBlockFormatter}),v=new i({name:"getCompilers",call:"eth_getCompilers",params:0}),y=new i({name:"getBlockTransactionCount",call:l,params:1,inputFormatter:[n.inputBlockNumberFormatter],outputFormatter:o.toDecimal}),b=new i({name:"getBlockUncleCount",call:f,params:1,inputFormatter:[n.inputBlockNumberFormatter],outputFormatter:o.toDecimal}),w=new i({name:"getTransaction",call:"eth_getTransactionByHash",params:1,outputFormatter:n.outputTransactionFormatter}),x=new i({name:"getTransactionFromBlock",call:s,params:2,inputFormatter:[o.toHex,o.toHex],outputFormatter:n.outputTransactionFormatter}),_=new i({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[null,n.inputDefaultBlockNumberFormatter],outputFormatter:o.toDecimal}),F=new i({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[n.inputTransactionFormatter]}),I=new i({name:"call",call:"eth_call",params:2,inputFormatter:[n.inputTransactionFormatter,n.inputDefaultBlockNumberFormatter]}),N=new i({name:"compile.solidity",call:"eth_compileSolidity",params:1}),O=new i({name:"compile.lll",call:"eth_compileLLL",params:1}),T=new i({name:"compile.serpent",call:"eth_compileSerpent",params:1}),B=[p,m,h,d,g,v,y,b,w,x,_,I,F,N,O,T],A=[new a({name:"coinbase",getter:"eth_coinbase"}),new a({name:"mining",getter:"eth_mining"}),new a({name:"gasPrice",getter:"eth_gasPrice",outputFormatter:n.outputBigNumberFormatter}),new a({name:"accounts",getter:"eth_accounts"}),new a({name:"blockNumber",getter:"eth_blockNumber",outputFormatter:o.toDecimal})];e.exports={methods:B,properties:A}},{"../utils/utils":8,"./formatters":17,"./method":20,"./property":22}],15:[function(t,e,r){var n=t("../solidity/abi"),o=t("../utils/utils"),i=t("./signature"),a=function(t,e){return t.filter(function(t){return t.indexed===e})},u=function(t,e){var r=o.findIndex(t,function(t){return t.name===e});return-1===r?void console.error("indexed param with name "+e+" not found"):t[r]},s=function(t,e){return Object.keys(e).map(function(r){var o=[u(a(t.inputs,!0),r)],i=e[r];return i instanceof Array?i.map(function(t){return n.formatInput(o,[t])}):"0x"+n.formatInput(o,[i])})},c=function(t,e,r){return function(n,o){var i=o||{};return i.address=t,i.topics=[],i.topics.push(e),n&&(i.topics=i.topics.concat(s(r,n))),i}},l=function(t,e,r){var n=e.slice(),o=r.slice();return t.reduce(function(t,e){var r;return r=e.indexed?n.splice(0,1)[0]:o.splice(0,1)[0],t[e.name]=r,t},{})},f=function(t){return function(e){var r={event:o.extractDisplayName(t.name),number:e.number,hash:e.hash,args:{}};if(!e.topics)return r;e.data=e.data||"";var i=a(t.inputs,!0),u=e.topics.slice(1).map(function(t){return t.slice(2)}).join(""),s=n.formatOutput(i,u),c=a(t.inputs,!1),f=n.formatOutput(c,e.data.slice(2));return r.args=l(t.inputs,s,f),r}},p=function(t,e){for(var r=0;r<t.length;r++){var n=i.eventSignatureFromAscii(t[r].name);if(n===e.topics[0])return t[r]}return void 0};e.exports={inputParser:c,outputParser:f,getMatchingEvent:p}},{"../solidity/abi":1,"../utils/utils":8,"./signature":26}],16:[function(t,e,r){var n=t("./requestmanager"),o=t("./formatters"),i=t("../utils/utils"),a=function(t){return i.isString(t)?t:(t=t||{},t.topics=t.topics||[],t.topics=t.topics.map(function(t){return i.isArray(t)?t.map(i.toHex):i.toHex(t)}),{topics:t.topics,to:t.to,address:t.address,fromBlock:o.inputBlockNumberFormatter(t.fromBlock),toBlock:o.inputBlockNumberFormatter(t.toBlock)})},u=function(t,e,r){var n={};e.forEach(function(t){t.attachToObject(n)}),this.options=a(t),this.implementation=n,this.callbacks=[],this.formatter=r,this.filterId=this.implementation.newFilter(this.options)};u.prototype.watch=function(t){this.callbacks.push(t);var e=this,r=function(t,r){return t?e.callbacks.forEach(function(e){e(t)}):void r.forEach(function(t){t=e.formatter?e.formatter(t):t,e.callbacks.forEach(function(e){e(null,t)})})};i.isString(this.options)||this.get(function(e,r){e&&t(e),r.forEach(function(e){t(null,e)})}),n.getInstance().startPolling({method:this.implementation.poll.call,params:[this.filterId]},this.filterId,r,this.stopWatching.bind(this))},u.prototype.stopWatching=function(){n.getInstance().stopPolling(this.filterId),this.implementation.uninstallFilter(this.filterId),this.callbacks=[]},u.prototype.get=function(t){var e=this;if(!i.isFunction(t)){var r=this.implementation.getLogs(this.filterId);return r.map(function(t){return e.formatter?e.formatter(t):t})}this.implementation.getLogs(this.filterId,function(r,n){r?t(r):t(null,n.map(function(t){return e.formatter?e.formatter(t):t}))})},e.exports=u},{"../utils/utils":8,"./formatters":17,"./requestmanager":24}],17:[function(t,e,r){var n=t("../utils/utils"),o=t("../utils/config"),i=function(t){return n.toBigNumber(t)},a=function(t){return"latest"===t||"pending"===t||"earliest"===t},u=function(t){return void 0===t?o.defaultBlock:s(t)},s=function(t){return void 0===t?void 0:a(t)?t:n.toHex(t)},c=function(t){return t.from=t.from||o.defaultAccount,t.code&&(t.data=t.code,delete t.code),["gasPrice","gas","value"].filter(function(e){return void 0!==t[e]}).forEach(function(e){t[e]=n.fromDecimal(t[e])}),t},l=function(t){return t.blockNumber=n.toDecimal(t.blockNumber),t.transactionIndex=n.toDecimal(t.transactionIndex),t.nonce=n.toDecimal(t.nonce),t.gas=n.toDecimal(t.gas),t.gasPrice=n.toBigNumber(t.gasPrice),t.value=n.toBigNumber(t.value),t},f=function(t){return t.gasLimit=n.toDecimal(t.gasLimit),t.gasUsed=n.toDecimal(t.gasUsed),t.size=n.toDecimal(t.size),t.timestamp=n.toDecimal(t.timestamp),t.number=n.toDecimal(t.number),t.difficulty=n.toBigNumber(t.difficulty),t.totalDifficulty=n.toBigNumber(t.totalDifficulty),n.isArray(t.transactions)&&t.transactions.forEach(function(t){return n.isString(t)?void 0:l(t)}),t},p=function(t){return null===t?null:(t.blockNumber=n.toDecimal(t.blockNumber),t.transactionIndex=n.toDecimal(t.transactionIndex),t.logIndex=n.toDecimal(t.logIndex),t)},m=function(t){return t.payload=n.toHex(t.payload),t.ttl=n.fromDecimal(t.ttl),t.workToProve=n.fromDecimal(t.workToProve),t.priority=n.fromDecimal(t.priority),n.isArray(t.topics)||(t.topics=t.topics?[t.topics]:[]),t.topics=t.topics.map(function(t){return n.fromAscii(t)}),t},h=function(t){return t.expiry=n.toDecimal(t.expiry),t.sent=n.toDecimal(t.sent),t.ttl=n.toDecimal(t.ttl),t.workProved=n.toDecimal(t.workProved),t.payloadRaw=t.payload,t.payload=n.toAscii(t.payload),n.isJson(t.payload)&&(t.payload=JSON.parse(t.payload)),t.topics||(t.topics=[]),t.topics=t.topics.map(function(t){return n.toAscii(t)}),t};e.exports={inputDefaultBlockNumberFormatter:u,inputBlockNumberFormatter:s,inputTransactionFormatter:c,inputPostFormatter:m,outputBigNumberFormatter:i,outputTransactionFormatter:l,outputBlockFormatter:f,outputLogFormatter:p,outputPostFormatter:h}},{"../utils/config":7,"../utils/utils":8}],18:[function(t,e,r){"use strict";var n=t("xmlhttprequest").XMLHttpRequest,o=t("./errors"),i=function(t){this.host=t||"http://localhost:8545"};i.prototype.send=function(t){var e=new n;e.open("POST",this.host,!1);try{e.send(JSON.stringify(t))}catch(r){throw o.InvalidConnection(this.host)}return JSON.parse(e.responseText)},i.prototype.sendAsync=function(t,e){var r=new n;r.onreadystatechange=function(){4===r.readyState&&e(null,JSON.parse(r.responseText))},r.open("POST",this.host,!0);try{r.send(JSON.stringify(t))}catch(i){e(o.InvalidConnection(this.host))}},e.exports=i},{"./errors":13,xmlhttprequest:6}],19:[function(t,e,r){var n=function(){return arguments.callee._singletonInstance?arguments.callee._singletonInstance:(arguments.callee._singletonInstance=this,void(this.messageId=1))};n.getInstance=function(){var t=new n;return t},n.prototype.toPayload=function(t,e){return t||console.error("jsonrpc method should be specified!"),{jsonrpc:"2.0",method:t,params:e||[],id:this.messageId++}},n.prototype.isValidResponse=function(t){return!!t&&!t.error&&"2.0"===t.jsonrpc&&"number"==typeof t.id&&void 0!==t.result},n.prototype.toBatchPayload=function(t){var e=this;return t.map(function(t){return e.toPayload(t.method,t.params)})},e.exports=n},{}],20:[function(t,e,r){var n=t("./requestmanager"),o=t("../utils/utils"),i=t("./errors"),a=function(t){this.name=t.name,this.call=t.call,this.params=t.params||0,this.inputFormatter=t.inputFormatter,this.outputFormatter=t.outputFormatter};a.prototype.getCall=function(t){return o.isFunction(this.call)?this.call(t):this.call},a.prototype.extractCallback=function(t){return o.isFunction(t[t.length-1])?t.pop():null},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,r){return e?e(t[r]):t[r]}):t},a.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t?this.outputFormatter(t):t},a.prototype.attachToObject=function(t){var e=this.send.bind(this);e.call=this.call;var r=this.name.split(".");r.length>1?(t[r[0]]=t[r[0]]||{},t[r[0]][r[1]]=e):t[r[0]]=e},a.prototype.toPayload=function(t){var e=this.getCall(t),r=this.extractCallback(t),n=this.formatInput(t);return this.validateArgs(n),{method:e,params:n,callback:r}},a.prototype.send=function(){var t=this.toPayload(Array.prototype.slice.call(arguments));if(t.callback){var e=this;return n.getInstance().sendAsync(t,function(r,n){t.callback(null,e.formatOutput(n))})}return this.formatOutput(n.getInstance().send(t))},e.exports=a},{"../utils/utils":8,"./errors":13,"./requestmanager":24}],21:[function(t,e,r){var n=t("../utils/utils"),o=t("./property"),i=[],a=[new o({name:"listening",getter:"net_listening"}),new o({name:"peerCount",getter:"net_peerCount",outputFormatter:n.toDecimal})];e.exports={methods:i,properties:a}},{"../utils/utils":8,"./property":22}],22:[function(t,e,r){var n=t("./requestmanager"),o=function(t){this.name=t.name,this.getter=t.getter,this.setter=t.setter,this.outputFormatter=t.outputFormatter,this.inputFormatter=t.inputFormatter};o.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter(t):t},o.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t?this.outputFormatter(t):t},o.prototype.attachToObject=function(t){var e={get:this.get.bind(this),set:this.set.bind(this)},r=this.name.split(".");r.length>1?(t[r[0]]=t[r[0]]||{},Object.defineProperty(t[r[0]],r[1],e)):Object.defineProperty(t,r[0],e)},o.prototype.get=function(){return this.formatOutput(n.getInstance().send({method:this.getter}))},o.prototype.set=function(t){return n.getInstance().send({method:this.setter,params:[this.formatInput(t)]})},e.exports=o},{"./requestmanager":24}],23:[function(t,e,r){var n=function(){};n.prototype.send=function(t){var e=navigator.qt.callMethod(JSON.stringify(t));return JSON.parse(e)},e.exports=n},{}],24:[function(t,e,r){var n=t("./jsonrpc"),o=t("../utils/utils"),i=t("../utils/config"),a=t("./errors"),u=function(t){return arguments.callee._singletonInstance?arguments.callee._singletonInstance:(arguments.callee._singletonInstance=this,this.provider=t,this.polls=[],this.timeout=null,void this.poll())};u.getInstance=function(){var t=new u;return t},u.prototype.send=function(t){if(!this.provider)return console.error(a.InvalidProvider()),null;var e=n.getInstance().toPayload(t.method,t.params),r=this.provider.send(e);if(!n.getInstance().isValidResponse(r))throw a.InvalidResponse(r);return r.result},u.prototype.sendAsync=function(t,e){if(!this.provider)return e(a.InvalidProvider());var r=n.getInstance().toPayload(t.method,t.params);this.provider.sendAsync(r,function(t,r){return t?e(t):n.getInstance().isValidResponse(r)?void e(null,r.result):e(a.InvalidResponse(r))})},u.prototype.setProvider=function(t){this.provider=t},u.prototype.startPolling=function(t,e,r,n){this.polls.push({data:t,id:e,callback:r,uninstall:n})},u.prototype.stopPolling=function(t){for(var e=this.polls.length;e--;){var r=this.polls[e];r.id===t&&this.polls.splice(e,1)}},u.prototype.reset=function(){this.polls.forEach(function(t){t.uninstall(t.id)}),this.polls=[],this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.poll()},u.prototype.poll=function(){if(this.timeout=setTimeout(this.poll.bind(this),i.ETH_POLLING_TIMEOUT),this.polls.length){if(!this.provider)return void console.error(a.InvalidProvider());var t=n.getInstance().toBatchPayload(this.polls.map(function(t){return t.data})),e=this;this.provider.sendAsync(t,function(t,r){if(!t){if(!o.isArray(r))throw a.InvalidResponse(r);r.map(function(t,r){return t.callback=e.polls[r].callback,t}).filter(function(t){var e=n.getInstance().isValidResponse(t);return e||t.callback(a.InvalidResponse(t)),e}).filter(function(t){return o.isArray(t.result)&&t.result.length>0}).forEach(function(t){t.callback(null,t.result)})}})}},e.exports=u},{"../utils/config":7,"../utils/utils":8,"./errors":13,"./jsonrpc":19}],25:[function(t,e,r){var n=t("./method"),o=t("./formatters"),i=new n({name:"post",call:"shh_post",params:1,inputFormatter:[o.inputPostFormatter]}),a=new n({name:"newIdentity",call:"shh_newIdentity",params:0}),u=new n({name:"hasIdentity",call:"shh_hasIdentity",params:1}),s=new n({name:"newGroup",call:"shh_newGroup",params:0}),c=new n({name:"addToGroup",call:"shh_addToGroup",params:0}),l=[i,a,u,s,c];e.exports={methods:l}},{"./formatters":17,"./method":20}],26:[function(t,e,r){var n=t("../web3"),o=t("../utils/config"),i=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*o.ETH_SIGNATURE_LENGTH)},a=function(t){return n.sha3(n.fromAscii(t))};e.exports={functionSignatureFromAscii:i,eventSignatureFromAscii:a}},{"../utils/config":7,"../web3":10}],27:[function(t,e,r){var n=t("./method"),o=function(){var t=function(t){return"string"==typeof t[0]?"eth_newBlockFilter":"eth_newFilter"},e=new n({name:"newFilter",call:t,params:1}),r=new n({name:"uninstallFilter",call:"eth_uninstallFilter",params:1}),o=new n({name:"getLogs",call:"eth_getFilterLogs",params:1}),i=new n({name:"poll",call:"eth_getFilterChanges",params:1});return[e,r,o,i]},i=function(){var t=new n({name:"newFilter",call:"shh_newFilter",params:1}),e=new n({name:"uninstallFilter",call:"shh_uninstallFilter",params:1}),r=new n({name:"getLogs",call:"shh_getMessages",params:1}),o=new n({name:"poll",call:"shh_getFilterChanges",params:1});return[t,e,r,o]};e.exports={eth:o,shh:i}},{"./method":20}],28:[function(t,e,r){},{}],"bignumber.js":[function(t,e,r){"use strict";e.exports=BigNumber},{}],web3:[function(t,e,r){var n=t("./lib/web3");n.providers.HttpProvider=t("./lib/web3/httpprovider"),n.providers.QtSyncProvider=t("./lib/web3/qtsync"),n.eth.contract=t("./lib/web3/contract"),n.abi=t("./lib/solidity/abi"),"undefined"!=typeof window&&"undefined"==typeof window.web3&&(window.web3=n),e.exports=n},{"./lib/solidity/abi":1,"./lib/web3":10,"./lib/web3/contract":11,"./lib/web3/httpprovider":18,"./lib/web3/qtsync":23}]},{},["web3"]); |