You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
17 KiB
1 lines
17 KiB
require=function t(n,e,r){function o(i,u){if(!e[i]){if(!n[i]){var f="function"==typeof require&&require;if(!u&&f)return f(i,!0);if(a)return a(i,!0);var s=new Error("Cannot find module '"+i+"'");throw s.code="MODULE_NOT_FOUND",s}var c=e[i]={exports:{}};n[i][0].call(c.exports,function(t){var e=n[i][1][t];return o(e?e:t)},c,c.exports,t,n,e,r)}return e[i].exports}for(var a="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(t,n){var e=t("./utils"),r=t("./types"),o=t("./const"),a=t("./formatters"),i=function(t){console.error("parser does not support type: "+t)},u=function(t){return"[]"===t.slice(-2)},f=function(t,n){return u(t)||"string"===t?a.formatInputInt(n.length):""},s=r.inputTypes(),c=function(t,n){var e="",r="",o="";return t.forEach(function(t,r){e+=f(t.type,n[r])}),t.forEach(function(e,a){for(var f=!1,c=0;c<s.length&&!f;c++)f=s[c].type(t[a].type,n[a]);f||i(t[a].type);var l=s[c-1].format;u(t[a].type)?o+=n[a].reduce(function(t,n){return t+l(n)},""):"string"===t[a].type?o+=l(n[a]):r+=l(n[a])}),e+=r+o},l=function(t){return u(t)||"string"===t?2*o.ETH_PADDING:0},p=r.outputTypes(),m=function(t,n){n=n.slice(2);var e=[],f=2*o.ETH_PADDING,s=t.reduce(function(t,n){return t+l(n.type)},0),c=n.slice(0,s);return n=n.slice(s),t.forEach(function(o,s){for(var l=!1,m=0;m<p.length&&!l;m++)l=p[m].type(t[s].type);l||i(t[s].type);var h=p[m-1].format;if(u(t[s].type)){var d=a.formatOutputUInt(c.slice(0,f));c=c.slice(f);for(var g=[],v=0;d>v;v++)g.push(h(n.slice(0,f))),n=n.slice(f);e.push(g)}else r.prefixedType("string")(t[s].type)?(c=c.slice(f),e.push(h(n.slice(0,f))),n=n.slice(f)):(e.push(h(n.slice(0,f))),n=n.slice(f))}),e},h=function(t){var n={};return t.forEach(function(t){var r=e.extractDisplayName(t.name),o=e.extractTypeName(t.name),a=function(){var n=Array.prototype.slice.call(arguments);return c(t.inputs,n)};void 0===n[r]&&(n[r]=a),n[r][o]=a}),n},d=function(t){var n={};return t.forEach(function(t){var r=e.extractDisplayName(t.name),o=e.extractTypeName(t.name),a=function(n){return m(t.outputs,n)};void 0===n[r]&&(n[r]=a),n[r][o]=a}),n};n.exports={inputParser:h,outputParser:d,formatInput:c,formatOutput:m}},{"./const":2,"./formatters":8,"./types":15,"./utils":16}],2:[function(t,n){var e=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];n.exports={ETH_PADDING:32,ETH_SIGNATURE_LENGTH:4,ETH_UNITS:e,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:BigNumber.ROUND_DOWN},ETH_POLLING_TIMEOUT:1e3}},{}],3:[function(t,n){var e=t("./web3"),r=t("./abi"),o=t("./utils"),a=t("./event"),i=t("./signature"),u=function(t){e._currentContractAbi=t.abi,e._currentContractAddress=t.address,e._currentContractMethodName=t.method,e._currentContractMethodParams=t.params},f=function(t){t.call=function(n){return t._isTransact=!1,t._options=n,t},t.transact=function(n){return t._isTransact=!0,t._options=n,t},t._options={},["gas","gasPrice","value","from"].forEach(function(n){t[n]=function(e){return t._options[n]=e,t}})},s=function(t,n,a){var f=r.inputParser(n),s=r.outputParser(n);o.filterFunctions(n).forEach(function(r){var c=o.extractDisplayName(r.name),l=o.extractTypeName(r.name),p=function(){var o=Array.prototype.slice.call(arguments),p=i.functionSignatureFromAscii(r.name),m=f[c][l].apply(null,o),h=t._options||{};h.to=a,h.data=p+m;var d=t._isTransact===!0||t._isTransact!==!1&&!r.constant,g=h.collapse!==!1;if(t._options={},t._isTransact=null,d)return u({abi:n,address:a,method:r.name,params:o}),void e.eth.transact(h);var v=e.eth.call(h),y=s[c][l](v);return g&&(1===y.length?y=y[0]:0===y.length&&(y=null)),y};void 0===t[c]&&(t[c]=p),t[c][l]=p})},c=function(t,n,e){t.address=e,t._onWatchEventResult=function(t){var e=event.getMatchingEvent(o.filterEvents(n)),r=a.outputParser(e);return r(t)},Object.defineProperty(t,"topic",{get:function(){return o.filterEvents(n).map(function(t){return i.eventSignatureFromAscii(t.name)})}})},l=function(t,n,r){o.filterEvents(n).forEach(function(n){var u=function(){var t=Array.prototype.slice.call(arguments),o=i.eventSignatureFromAscii(n.name),u=a.inputParser(r,o,n),f=u.apply(null,t),s=function(t){var e=a.outputParser(n);return e(t)};return e.eth.watch(f,void 0,void 0,s)};u._isEvent=!0;var f=o.extractDisplayName(n.name),s=o.extractTypeName(n.name);void 0===t[f]&&(t[f]=u),t[f][s]=u})},p=function(t,n){n.forEach(function(t){if(-1===t.name.indexOf("(")){var n=t.name,e=t.inputs.map(function(t){return t.type}).join();t.name=n+"("+e+")"}});var e={};return f(e),s(e,n,t),c(e,n,t),l(e,n,t),e};n.exports=p},{"./abi":1,"./event":6,"./signature":14,"./utils":16,"./web3":18}],4:[function(t,n){var e=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]};n.exports={methods:e}},{}],5:[function(t,n){var e=function(){var t=function(t){return"string"==typeof t[0]?"eth_blockByHash":"eth_blockByNumber"},n=function(t){return"string"==typeof t[0]?"eth_transactionByHash":"eth_transactionByNumber"},e=function(t){return"string"==typeof t[0]?"eth_uncleByHash":"eth_uncleByNumber"},r=function(t){return"string"==typeof t[0]?"eth_transactionCountByHash":"eth_transactionCountByNumber"},o=function(t){return"string"==typeof t[0]?"eth_uncleCountByHash":"eth_uncleCountByNumber"};return[{name:"balanceAt",call:"eth_balanceAt"},{name:"stateAt",call:"eth_stateAt"},{name:"storageAt",call:"eth_storageAt"},{name:"countAt",call:"eth_countAt"},{name:"codeAt",call:"eth_codeAt"},{name:"transact",call:"eth_transact"},{name:"call",call:"eth_call"},{name:"block",call:t},{name:"transaction",call:n},{name:"uncle",call:e},{name:"compilers",call:"eth_compilers"},{name:"flush",call:"eth_flush"},{name:"lll",call:"eth_lll"},{name:"solidity",call:"eth_solidity"},{name:"serpent",call:"eth_serpent"},{name:"logs",call:"eth_logs"},{name:"transactionCount",call:r},{name:"uncleCount",call:o}]},r=function(){return[{name:"coinbase",getter:"eth_coinbase",setter:"eth_setCoinbase"},{name:"listening",getter:"eth_listening",setter:"eth_setListening"},{name:"mining",getter:"eth_mining",setter:"eth_setMining"},{name:"gasPrice",getter:"eth_gasPrice"},{name:"accounts",getter:"eth_accounts"},{name:"peerCount",getter:"eth_peerCount"},{name:"defaultBlock",getter:"eth_defaultBlock",setter:"eth_setDefaultBlock"},{name:"number",getter:"eth_number"}]};n.exports={methods:e,properties:r}},{}],6:[function(t,n){var e=t("./abi"),r=t("./utils"),o=t("./signature"),a=function(t,n){return t.filter(function(t){return t.indexed===n})},i=function(t,n){var e=r.findIndex(t,function(t){return t.name===n});return-1===e?void console.error("indexed param with name "+n+" not found"):t[e]},u=function(t,n){return Object.keys(n).map(function(r){var o=[i(a(t.inputs,!0),r)],u=n[r];return u instanceof Array?u.map(function(t){return e.formatInput(o,[t])}):e.formatInput(o,[u])})},f=function(t,n,e){return function(r,o){var a=o||{};return a.address=t,a.topic=[],a.topic.push(n),r&&(a.topic=a.topic.concat(u(e,r))),a}},s=function(t,n,e){var r=n.slice(),o=e.slice();return t.reduce(function(t,n){var e;return e=n.indexed?r.splice(0,1)[0]:o.splice(0,1)[0],t[n.name]=e,t},{})},c=function(t){return function(n){var o={event:r.extractDisplayName(t.name),number:n.number,hash:n.hash,args:{}};if(n.topics=n.topic,!n.topic)return o;var i=a(t.inputs,!0),u="0x"+n.topic.slice(1,n.topic.length).map(function(t){return t.slice(2)}).join(""),f=e.formatOutput(i,u),c=a(t.inputs,!1),l=e.formatOutput(c,n.data);return o.args=s(t.inputs,f,l),o}},l=function(t,n){for(var e=0;e<t.length;e++){var r=o.eventSignatureFromAscii(t[e].name);if(r===n.topic[0])return t[e]}return void 0};n.exports={inputParser:f,outputParser:c,getMatchingEvent:l}},{"./abi":1,"./signature":14,"./utils":16}],7:[function(t,n){var e=function(t){return!!t&&"function"==typeof t.newFilter&&"function"==typeof t.getMessages&&"function"==typeof t.uninstallFilter&&"function"==typeof t.startPolling&&"function"==typeof t.stopPolling},r=function(t){return"string"==typeof t?t:(t=t||{},t.topics&&console.warn('"topics" is deprecated, is "topic" instead'),{to:t.to,topic:t.topic,earliest:t.earliest,latest:t.latest,max:t.max,skip:t.skip,address:t.address})},o=function(t,n,o){if(!e(n))return void console.error("filter implemenation is invalid");t=r(t);var a=[],i=n.newFilter(t),u=function(t){t.forEach(function(t){t=o?o(t):t,a.forEach(function(n){n(t)})})};n.startPolling(i,u,n.uninstallFilter);var f=function(t){a.push(t)},s=function(){return n.getMessages(i)},c=function(){n.stopPolling(i),n.uninstallFilter(i),a=[]};return{changed:f,arrived:f,happened:f,messages:s,logs:s,uninstall:c}};n.exports=o},{}],8:[function(t,n){var e=t("./utils"),r=t("./const"),o=function(t,n,e){return new Array(n-t.length+1).join(e?e:"0")+t},a=function(t){var n=2*r.ETH_PADDING;return t instanceof BigNumber||"number"==typeof t?("number"==typeof t&&(t=new BigNumber(t)),BigNumber.config(r.ETH_BIGNUMBER_ROUNDING_MODE),t=t.round(),t.lessThan(0)&&(t=new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(t).plus(1)),t=t.toString(16)):t=0===t.indexOf("0x")?t.substr(2):"string"==typeof t?a(new BigNumber(t)):(+t).toString(16),o(t,n)},i=function(t){return e.fromAscii(t,r.ETH_PADDING).substr(2)},u=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},f=function(t){return a(new BigNumber(t).times(new BigNumber(2).pow(128)))},s=function(t){return"1"===new BigNumber(t.substr(0,1),16).toString(2).substr(0,1)},c=function(t){return t=t||"0",s(t)?new BigNumber(t,16).minus(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new BigNumber(t,16)},l=function(t){return t=t||"0",new BigNumber(t,16)},p=function(t){return c(t).dividedBy(new BigNumber(2).pow(128))},m=function(t){return l(t).dividedBy(new BigNumber(2).pow(128))},h=function(t){return"0x"+t},d=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},g=function(t){return e.toAscii(t)},v=function(t){return"0x"+t.slice(t.length-40,t.length)};n.exports={formatInputInt:a,formatInputString:i,formatInputBool:u,formatInputReal:f,formatOutputInt:c,formatOutputUInt:l,formatOutputReal:p,formatOutputUReal:m,formatOutputHash:h,formatOutputBool:d,formatOutputString:g,formatOutputAddress:v}},{"./const":2,"./utils":16}],9:[function(t,n){var e=function(t){this.handlers=[],this.host=t||"http://127.0.0.1:8080"};e.prototype.send=function(t){var n=new XMLHttpRequest;n.open("POST",this.host,!1),n.send(JSON.stringify(t));var e=n.responseText;return 200===n.status?JSON.parse(e):void 0},n.exports=e},{}],10:[function(t,n){var e=1,r=function(t,n){return t||console.error("jsonrpc method should be specified!"),{jsonrpc:"2.0",method:t,params:n||[],id:e++}},o=function(t){return!!t&&!t.error&&"2.0"===t.jsonrpc&&"number"==typeof t.id&&void 0!==t.result},a=function(t){return t.map(function(t){return r(t.method,t.params)})};n.exports={toPayload:r,isValidResponse:o,toBatchPayload:a}},{}],11:[function(t,n){var e=function(){};e.prototype.send=function(t){var n=navigator.qt.callMethod(JSON.stringify(t));return JSON.parse(n)},n.exports=e},{}],12:[function(t,n){var e=t("./jsonrpc"),r=t("./const"),o=function(){var t,n=[],o=null,a=function(n){var r=e.toPayload(n.method,n.params);if(!t)return console.error("provider is not set"),null;var o=t.send(r);return e.isValidResponse(o)?o.result:(console.log(o),null)},i=function(n){t=n},u=function(t,e,r,o){n.push({data:t,id:e,callback:r,uninstall:o})},f=function(t){for(var e=n.length;e--;){var r=n[e];r.id===t&&n.splice(e,1)}},s=function(){n.forEach(function(t){t.uninstall(t.id)}),n=[],o&&(clearTimeout(o),o=null),c()},c=function(){n.forEach(function(t){var n=a(t.data);n instanceof Array&&0!==n.length&&t.callback(n)}),o=setTimeout(c,r.ETH_POLLING_TIMEOUT)};return c(),{send:a,setProvider:i,startPolling:u,stopPolling:f,reset:s}};n.exports=o},{"./const":2,"./jsonrpc":10}],13:[function(t,n){var e=function(){return[{name:"post",call:"shh_post"},{name:"newIdentity",call:"shh_newIdentity"},{name:"haveIdentity",call:"shh_haveIdentity"},{name:"newGroup",call:"shh_newGroup"},{name:"addToGroup",call:"shh_addToGroup"}]};n.exports={methods:e}},{}],14:[function(t,n){var e=t("./web3"),r=t("./const"),o=function(t){return e.sha3(e.fromAscii(t)).slice(0,2+2*r.ETH_SIGNATURE_LENGTH)},a=function(t){return e.sha3(e.fromAscii(t))};n.exports={functionSignatureFromAscii:o,eventSignatureFromAscii:a}},{"./const":2,"./web3":18}],15:[function(t,n){var e=t("./formatters"),r=function(t){return function(n){return 0===n.indexOf(t)}},o=function(t){return function(n){return t===n}},a=function(){return[{type:r("uint"),format:e.formatInputInt},{type:r("int"),format:e.formatInputInt},{type:r("hash"),format:e.formatInputInt},{type:r("string"),format:e.formatInputString},{type:r("real"),format:e.formatInputReal},{type:r("ureal"),format:e.formatInputReal},{type:o("address"),format:e.formatInputInt},{type:o("bool"),format:e.formatInputBool}]},i=function(){return[{type:r("uint"),format:e.formatOutputUInt},{type:r("int"),format:e.formatOutputInt},{type:r("hash"),format:e.formatOutputHash},{type:r("string"),format:e.formatOutputString},{type:r("real"),format:e.formatOutputReal},{type:r("ureal"),format:e.formatOutputUReal},{type:o("address"),format:e.formatOutputAddress},{type:o("bool"),format:e.formatOutputBool}]};n.exports={prefixedType:r,namedType:o,inputTypes:a,outputTypes:i}},{"./formatters":8}],16:[function(t,n){var e=t("./const"),r=function(t,n){for(var e=!1,r=0;r<t.length&&!e;r++)e=n(t[r]);return e?r-1:-1},o=function(t){var n="",e=0,r=t.length;for("0x"===t.substring(0,2)&&(e=2);r>e;e+=2){var o=parseInt(t.substr(e,2),16);if(0===o)break;n+=String.fromCharCode(o)}return n},a=function(t){for(var n="",e=0;e<t.length;e++){var r=t.charCodeAt(e).toString(16);n+=r.length<2?"0"+r:r}return n},i=function(t,n){n=void 0===n?0:n;for(var e=a(t);e.length<2*n;)e+="00";return"0x"+e},u=function(t){var n=t.indexOf("(");return-1!==n?t.substr(0,n):t},f=function(t){var n=t.indexOf("(");return-1!==n?t.substr(n+1,t.length-1-(n+1)).replace(" ",""):""},s=function(t){return t.filter(function(t){return"function"===t.type})},c=function(t){return t.filter(function(t){return"event"===t.type})},l=function(t){for(var n="string"==typeof t?0===t.indexOf("0x")?parseInt(t.substr(2),16):parseInt(t):t,r=0,o=e.ETH_UNITS;n>3e3&&r<o.length-1;)n/=1e3,r++;for(var a=n.toString().length<n.toFixed(2).length?n.toString():n.toFixed(2),i=function(t,n,e){return n+","+e};;){var u=a;if(a=a.replace(/(\d)(\d\d\d[\.\,])/,i),u===a)break}return a+" "+o[r]};n.exports={findIndex:r,toAscii:o,fromAscii:i,extractDisplayName:u,extractTypeName:f,filterFunctions:s,filterEvents:c,toEth:l}},{"./const":2}],17:[function(t,n){var e=function(){var t=function(t){return"string"==typeof t[0]?"eth_newFilterString":"eth_newFilter"};return[{name:"newFilter",call:t},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getMessages",call:"eth_filterLogs"}]},r=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessages",call:"shh_getMessages"}]};n.exports={eth:e,shh:r}},{}],18:[function(t,n){var e=t("./eth"),r=t("./db"),o=t("./shh"),a=t("./watches"),i=t("./filter"),u=t("./utils"),f=t("./requestmanager"),s=function(){return[{name:"sha3",call:"web3_sha3"}]},c=function(t,n){n.forEach(function(n){t[n.name]=function(){var t=Array.prototype.slice.call(arguments),e="function"==typeof n.call?n.call(t):n.call;return g.manager.send({method:e,params:t})}})},l=function(t,n){n.forEach(function(n){var e={};e.get=function(){return g.manager.send({method:n.getter})},n.setter&&(e.set=function(t){return g.manager.send({method:n.setter,params:[t]})}),Object.defineProperty(t,n.name,e)})},p=function(t,n,e,r){g.manager.startPolling({method:t,params:[n]},n,e,r)},m=function(t){g.manager.stopPolling(t)},h={startPolling:p.bind(null,"eth_changed"),stopPolling:m},d={startPolling:p.bind(null,"shh_changed"),stopPolling:m},g={manager:f(),providers:{},toAscii:u.toAscii,fromAscii:u.fromAscii,toDecimal:function(t){return t=t.length>2?t.substring(2):"0",new BigNumber(t,16).toString(10)},fromDecimal:function(t){return"0x"+new BigNumber(t).toString(16)},toEth:u.toEth,eth:{contractFromAbi:function(t){return function(n){n=n||"0xc6d9d2cd449a754c494264e1809c50e34d64562b";var e=g.eth.contract(n,t);return e.address=n,e}},watch:function(t,n,e,r){return t._isEvent?t(n,e):i(t,h,r)}},db:{},shh:{watch:function(t){return i(t,d)}},setProvider:function(t){g.manager.setProvider(t)},reset:function(){g.manager.reset()}};c(g,s()),c(g.eth,e.methods()),l(g.eth,e.properties()),c(g.db,r.methods()),c(g.shh,o.methods()),c(h,a.eth()),c(d,a.shh()),n.exports=g},{"./db":4,"./eth":5,"./filter":7,"./requestmanager":12,"./shh":13,"./utils":16,"./watches":17}],web3:[function(t,n){var e=t("./lib/web3");e.providers.HttpSyncProvider=t("./lib/httpsync"),e.providers.QtSyncProvider=t("./lib/qtsync"),e.eth.contract=t("./lib/contract"),e.abi=t("./lib/abi"),n.exports=e},{"./lib/abi":1,"./lib/contract":3,"./lib/httpsync":9,"./lib/qtsync":11,"./lib/web3":18}]},{},["web3"]);
|