aboutsummaryrefslogtreecommitdiffstats
path: root/jsre
diff options
context:
space:
mode:
Diffstat (limited to 'jsre')
-rw-r--r--jsre/ethereum_js.go2
-rw-r--r--jsre/jsre.go12
2 files changed, 12 insertions, 2 deletions
diff --git a/jsre/ethereum_js.go b/jsre/ethereum_js.go
index 8b2f6e9dd..fb0170288 100644
--- a/jsre/ethereum_js.go
+++ b/jsre/ethereum_js.go
@@ -1,3 +1,3 @@
package jsre
-const Ethereum_JS = `require=function t(e,n,r){function o(i,u){if(!n[i]){if(!e[i]){var s="function"==typeof require&&require;if(!u&&s)return s(i,!0);if(a)return a(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[i]={exports:{}};e[i][0].call(l.exports,function(t){var n=e[i][1][t];return o(n?n:t)},l,l.exports,t,e,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(t,e){var n=t("../utils/utils"),r=t("../utils/config"),o=t("./types"),a=t("./formatters"),i=function(t){throw new Error("parser does not support type: "+t)},u=function(t){return"[]"===t.slice(-2)},s=function(t,e){return u(t)||"string"===t?a.formatInputInt(e.length):""},c=o.inputTypes(),l=function(t,e){var n="",r="",o="";return t.forEach(function(t,r){n+=s(t.type,e[r])}),t.forEach(function(n,a){for(var s=!1,l=0;l<c.length&&!s;l++)s=c[l].type(t[a].type,e[a]);s||i(t[a].type);var f=c[l-1].format;u(t[a].type)?o+=e[a].reduce(function(t,e){return t+f(e)},""):"string"===t[a].type?o+=f(e[a]):r+=f(e[a])}),n+=r+o},f=function(t){return u(t)||"string"===t?2*r.ETH_PADDING:0},p=o.outputTypes(),m=function(t,e){e=e.slice(2);var n=[],s=2*r.ETH_PADDING,c=t.reduce(function(t,e){return t+f(e.type)},0),l=e.slice(0,c);return e=e.slice(c),t.forEach(function(r,c){for(var f=!1,m=0;m<p.length&&!f;m++)f=p[m].type(t[c].type);f||i(t[c].type);var d=p[m-1].format;if(u(t[c].type)){var h=a.formatOutputUInt(l.slice(0,s));l=l.slice(s);for(var g=[],y=0;h>y;y++)g.push(d(e.slice(0,s))),e=e.slice(s);n.push(g)}else o.prefixedType("string")(t[c].type)?(l=l.slice(s),n.push(d(e.slice(0,s))),e=e.slice(s)):(n.push(d(e.slice(0,s))),e=e.slice(s))}),n},d=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),o=n.extractTypeName(t.name),a=function(){var e=Array.prototype.slice.call(arguments);return l(t.inputs,e)};void 0===e[r]&&(e[r]=a),e[r][o]=a}),e},h=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),o=n.extractTypeName(t.name),a=function(e){return m(t.outputs,e)};void 0===e[r]&&(e[r]=a),e[r][o]=a}),e};e.exports={inputParser:d,outputParser:h,formatInput:l,formatOutput:m}},{"../utils/config":4,"../utils/utils":5,"./formatters":2,"./types":3}],2:[function(t,e){var n=t("../utils/utils"),r=t("../utils/config"),o=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},a=function(t){var e=2*r.ETH_PADDING;return BigNumber.config(r.ETH_BIGNUMBER_ROUNDING_MODE),o(n.toTwosComplement(t).round().toString(16),e)},i=function(t){return n.fromAscii(t,r.ETH_PADDING).substr(2)},u=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},s=function(t){return a(new BigNumber(t).times(new BigNumber(2).pow(128)))},c=function(t){return"1"===new BigNumber(t.substr(0,1),16).toString(2).substr(0,1)},l=function(t){return t=t||"0",c(t)?new BigNumber(t,16).minus(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new BigNumber(t,16)},f=function(t){return t=t||"0",new BigNumber(t,16)},p=function(t){return l(t).dividedBy(new BigNumber(2).pow(128))},m=function(t){return f(t).dividedBy(new BigNumber(2).pow(128))},d=function(t){return"0x"+t},h=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},g=function(t){return n.toAscii(t)},y=function(t){return"0x"+t.slice(t.length-40,t.length)};e.exports={formatInputInt:a,formatInputString:i,formatInputBool:u,formatInputReal:s,formatOutputInt:l,formatOutputUInt:f,formatOutputReal:p,formatOutputUReal:m,formatOutputHash:d,formatOutputBool:h,formatOutputString:g,formatOutputAddress:y}},{"../utils/config":4,"../utils/utils":5}],3:[function(t,e){var n=t("./formatters"),r=function(t){return function(e){return 0===e.indexOf(t)}},o=function(t){return function(e){return t===e}},a=function(){return[{type:r("uint"),format:n.formatInputInt},{type:r("int"),format:n.formatInputInt},{type:r("hash"),format:n.formatInputInt},{type:r("string"),format:n.formatInputString},{type:r("real"),format:n.formatInputReal},{type:r("ureal"),format:n.formatInputReal},{type:o("address"),format:n.formatInputInt},{type:o("bool"),format:n.formatInputBool}]},i=function(){return[{type:r("uint"),format:n.formatOutputUInt},{type:r("int"),format:n.formatOutputInt},{type:r("hash"),format:n.formatOutputHash},{type:r("string"),format:n.formatOutputString},{type:r("real"),format:n.formatOutputReal},{type:r("ureal"),format:n.formatOutputUReal},{type:o("address"),format:n.formatOutputAddress},{type:o("bool"),format:n.formatOutputBool}]};e.exports={prefixedType:r,namedType:o,inputTypes:a,outputTypes:i}},{"./formatters":2}],4:[function(t,e){var n=["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:n,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:BigNumber.ROUND_DOWN},ETH_POLLING_TIMEOUT:1e3,ETH_DEFAULTBLOCK:"latest"}},{}],5:[function(t,e){var n={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"},r=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},o=function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);r>n;n+=2){var o=parseInt(t.substr(n,2),16);if(0===o)break;e+=String.fromCharCode(o)}return e},a=function(t){for(var e="",n=0;n<t.length;n++){var r=t.charCodeAt(n).toString(16);e+=r.length<2?"0"+r:r}return e},i=function(t,e){e=void 0===e?0:e;for(var n=a(t);n.length<2*e;)n+="00";return"0x"+n},u=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},s=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)).replace(" ",""):""},c=function(t){return t.filter(function(t){return"function"===t.type})},l=function(t){return t.filter(function(t){return"event"===t.type})},f=function(t){return y(t).toNumber()},p=function(t){var e=y(t),n=e.toString(16);return e.lessThan(0)?"-0x"+n.substr(1):"0x"+n},m=function(t){if(B(t))return t;if(w(t))return p(t);if(T(t))return i(JSON.stringify(t));if(_(t)){if(0===t.indexOf("-0x"))return p(t);if(!isFinite(t))return i(t)}return p(t)},d=function(t){t=t?t.toLowerCase():"ether";var e=n[t];if(void 0===e)throw new Error("This unit doesn't exists, please use the one of the following units"+JSON.stringify(n,null,2));return new BigNumber(e,10)},h=function(t,e){var n=y(t).dividedBy(d(e));return w(t)?n:n.toString(10)},g=function(t,e){var n=y(t).times(d(e));return w(t)?n:n.toString(10)},y=function(t){return t=t||0,w(t)?t:!_(t)||0!==t.indexOf("0x")&&0!==t.indexOf("-0x")?new BigNumber(t.toString(10),10):new BigNumber(t.replace("0x",""),16)},b=function(t){var e=y(t);return e.lessThan(0)?new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(e).plus(1):e},v=function(t){return _(t)?0===t.indexOf("0x")&&42===t.length||-1===t.indexOf("0x")&&40===t.length:!1},w=function(t){return t instanceof BigNumber||t&&t.constructor&&"BigNumber"===t.constructor.name},_=function(t){return"string"==typeof t||t&&t.constructor&&"String"===t.constructor.name},x=function(t){return"function"==typeof t},T=function(t){return"object"==typeof t},B=function(t){return"boolean"==typeof t},F=function(t){return t instanceof Array};e.exports={findIndex:r,toHex:m,toDecimal:f,fromDecimal:p,toAscii:o,fromAscii:i,extractDisplayName:u,extractTypeName:s,filterFunctions:c,filterEvents:l,toWei:g,fromWei:h,toBigNumber:y,toTwosComplement:b,isBigNumber:w,isAddress:v,isFunction:x,isString:_,isObject:T,isBoolean:B,isArray:F}},{}],6:[function(t,e){var n=t("./web3/net"),r=t("./web3/eth"),o=t("./web3/db"),a=t("./web3/shh"),i=t("./web3/watches"),u=t("./web3/filter"),s=t("./utils/utils"),c=t("./solidity/formatters"),l=t("./web3/requestmanager"),f=t("./utils/config"),p=function(){return[{name:"sha3",call:"web3_sha3"}]},m=function(t,e){e.forEach(function(e){var n=e.name.split("."),r=function(){var t=null,n=Array.prototype.slice.call(arguments),r="function"==typeof e.call?e.call(n):e.call;return"function"==typeof n[n.length-1]&&(t=n[n.length-1],Array.prototype.pop.call(n)),e.addDefaultblock&&(n.length!==e.addDefaultblock?Array.prototype.push.call(n,isFinite(f.ETH_DEFAULTBLOCK)?s.fromDecimal(f.ETH_DEFAULTBLOCK):f.ETH_DEFAULTBLOCK):n[n.length-1]=isFinite(n[n.length-1])?s.fromDecimal(n[n.length-1]):n[n.length-1]),e.newMethod&&console.warn("This method is deprecated please use web3."+e.newMethod+"() instead."),v.manager.send({method:r,params:n,outputFormatter:e.outputFormatter,inputFormatter:e.inputFormatter,addDefaultblock:e.addDefaultblock},t)};n.length>1?(t[n[0]]||(t[n[0]]={}),t[n[0]][n[1]]=r):t[n[0]]=r})},d=function(t,e){e.forEach(function(e){var n={};n.get=function(){return e.newProperty&&console.warn("This property is deprecated please use web3."+e.newProperty+" instead."),v.manager.send({method:e.getter,outputFormatter:e.outputFormatter})},e.setter&&(n.set=function(t){return e.newProperty&&console.warn("This property is deprecated please use web3."+e.newProperty+" instead."),v.manager.send({method:e.setter,params:[t],inputFormatter:e.inputFormatter})}),n.enumerable=!e.newProperty,Object.defineProperty(t,e.name,n)})},h=function(t,e,n,r){v.manager.startPolling({method:t,params:[e]},e,n,r)},g=function(t){v.manager.stopPolling(t)},y={startPolling:h.bind(null,"eth_getFilterChanges"),stopPolling:g},b={startPolling:h.bind(null,"shh_getFilterChanges"),stopPolling:g},v={manager:l(),providers:{},setProvider:function(t){v.manager.setProvider(t)},reset:function(){v.manager.reset()},toHex:s.toHex,toAscii:s.toAscii,fromAscii:s.fromAscii,toDecimal:s.toDecimal,fromDecimal:s.fromDecimal,toBigNumber:s.toBigNumber,toWei:s.toWei,fromWei:s.fromWei,isAddress:s.isAddress,net:{},eth:{contractFromAbi:function(t){return console.warn("Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead."),function(e){e=e||"0xc6d9d2cd449a754c494264e1809c50e34d64562b";var n=v.eth.contract(e,t);return n.address=e,n}},filter:function(t,e,n){return t._isEvent?t(e,n):u(t,y,c.outputLogFormatter)},watch:function(t,e,n){return console.warn("eth.watch() is deprecated please use eth.filter() instead."),this.filter(t,e,n)}},db:{},shh:{filter:function(t){return u(t,b,c.outputPostFormatter)},watch:function(t){return console.warn("shh.watch() is deprecated please use shh.filter() instead."),this.filter(t)}}};Object.defineProperty(v.eth,"defaultBlock",{get:function(){return f.ETH_DEFAULTBLOCK},set:function(t){return f.ETH_DEFAULTBLOCK=t,f.ETH_DEFAULTBLOCK}}),m(v,p()),m(v.net,n.methods),d(v.net,n.properties),m(v.eth,r.methods),d(v.eth,r.properties),m(v.db,o.methods()),m(v.shh,a.methods()),m(y,i.eth()),m(b,i.shh()),e.exports=v},{"./solidity/formatters":2,"./utils/config":4,"./utils/utils":5,"./web3/db":8,"./web3/eth":9,"./web3/filter":11,"./web3/net":15,"./web3/requestmanager":17,"./web3/shh":18,"./web3/watches":20}],7:[function(t,e){function n(t,e){t.forEach(function(t){if(-1===t.name.indexOf("(")){var e=t.name,n=t.inputs.map(function(t){return t.type}).join();t.name=e+"("+n+")"}});var n={};return c(n),l(n,t,e),f(n,t,e),p(n,t,e),n}var r=t("../web3"),o=t("../solidity/abi"),a=t("../utils/utils"),i=t("./event"),u=t("./signature"),s=function(t){r._currentContractAbi=t.abi,r._currentContractAddress=t.address,r._currentContractMethodName=t.method,r._currentContractMethodParams=t.params},c=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},t.transact=function(e){return console.warn("myContract.transact() is deprecated please use myContract.sendTransaction() instead."),t.sendTransaction(e)},t._options={},["gas","gasPrice","value","from"].forEach(function(e){t[e]=function(n){return t._options[e]=n,t}})},l=function(t,e,n){var i=o.inputParser(e),c=o.outputParser(e);a.filterFunctions(e).forEach(function(o){var l=a.extractDisplayName(o.name),f=a.extractTypeName(o.name),p=function(){var a=Array.prototype.slice.call(arguments),p=u.functionSignatureFromAscii(o.name),m=i[l][f].apply(null,a),d=t._options||{};d.to=n,d.data=p+m;var h=t._isTransaction===!0||t._isTransaction!==!1&&!o.constant,g=d.collapse!==!1;if(t._options={},t._isTransaction=null,h)return s({abi:e,address:n,method:o.name,params:a}),void r.eth.sendTransaction(d);var y=r.eth.call(d),b=c[l][f](y);return g&&(1===b.length?b=b[0]:0===b.length&&(b=null)),b};void 0===t[l]&&(t[l]=p),t[l][f]=p})},f=function(t,e,n){t.address=n,t._onWatchEventResult=function(t){var n=event.getMatchingEvent(a.filterEvents(e)),r=i.outputParser(n);return r(t)},Object.defineProperty(t,"topics",{get:function(){return a.filterEvents(e).map(function(t){return u.eventSignatureFromAscii(t.name)})}})},p=function(t,e,n){a.filterEvents(e).forEach(function(e){var o=function(){var t=Array.prototype.slice.call(arguments),o=u.eventSignatureFromAscii(e.name),a=i.inputParser(n,o,e),s=a.apply(null,t),c=function(t){var n=i.outputParser(e);return n(t)};return r.eth.filter(s,void 0,void 0,c)};o._isEvent=!0;var s=a.extractDisplayName(e.name),c=a.extractTypeName(e.name);void 0===t[s]&&(t[s]=o),t[s][c]=o})},m=function(t){return t instanceof Array&&1===arguments.length?n.bind(null,t):(console.warn("Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead."),new n(arguments[1],arguments[0]))};e.exports=m},{"../solidity/abi":1,"../utils/utils":5,"../web3":6,"./event":10,"./signature":19}],8:[function(t,e){var n=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]};e.exports={methods:n}},{}],9:[function(t,e){var n=t("./formatters"),r=t("../utils/utils"),o=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},a=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},i=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},u=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},s=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},c=[{name:"getBalance",call:"eth_getBalance",addDefaultblock:2,outputFormatter:n.convertToBigNumber},{name:"getStorage",call:"eth_getStorage",addDefaultblock:2},{name:"getStorageAt",call:"eth_getStorageAt",addDefaultblock:3,inputFormatter:r.toHex},{name:"getData",call:"eth_getData",addDefaultblock:2},{name:"getBlock",call:o,outputFormatter:n.outputBlockFormatter,inputFormatter:[r.toHex,function(t){return t?!0:!1}]},{name:"getUncle",call:i,outputFormatter:n.outputBlockFormatter,inputFormatter:[r.toHex,r.toHex,function(t){return t?!0:!1}]},{name:"getCompilers",call:"eth_getCompilers"},{name:"getBlockTransactionCount",call:u,outputFormatter:r.toDecimal,inputFormatter:r.toHex},{name:"getBlockUncleCount",call:s,outputFormatter:r.toDecimal,inputFormatter:r.toHex},{name:"getTransaction",call:"eth_getTransactionByHash",outputFormatter:n.outputTransactionFormatter},{name:"getTransactionFromBlock",call:a,outputFormatter:n.outputTransactionFormatter,inputFormatter:r.toHex},{name:"getTransactionCount",call:"eth_getTransactionCount",addDefaultblock:2,outputFormatter:r.toDecimal},{name:"sendTransaction",call:"eth_sendTransaction",inputFormatter:n.inputTransactionFormatter},{name:"call",call:"eth_call",addDefaultblock:2,inputFormatter:n.inputCallFormatter},{name:"compile.solidity",call:"eth_compileSolidity",inputFormatter:r.toHex},{name:"compile.lll",call:"eth_compileLLL",inputFormatter:r.toHex},{name:"compile.serpent",call:"eth_compileSerpent",inputFormatter:r.toHex},{name:"flush",call:"eth_flush"},{name:"balanceAt",call:"eth_balanceAt",newMethod:"eth.getBalance"},{name:"stateAt",call:"eth_stateAt",newMethod:"eth.getStorageAt"},{name:"storageAt",call:"eth_storageAt",newMethod:"eth.getStorage"},{name:"countAt",call:"eth_countAt",newMethod:"eth.getTransactionCount"},{name:"codeAt",call:"eth_codeAt",newMethod:"eth.getData"},{name:"transact",call:"eth_transact",newMethod:"eth.sendTransaction"},{name:"block",call:o,newMethod:"eth.getBlock"},{name:"transaction",call:a,newMethod:"eth.getTransaction"},{name:"uncle",call:i,newMethod:"eth.getUncle"},{name:"compilers",call:"eth_compilers",newMethod:"eth.getCompilers"},{name:"solidity",call:"eth_solidity",newMethod:"eth.compile.solidity"},{name:"lll",call:"eth_lll",newMethod:"eth.compile.lll"},{name:"serpent",call:"eth_serpent",newMethod:"eth.compile.serpent"},{name:"transactionCount",call:u,newMethod:"eth.getBlockTransactionCount"},{name:"uncleCount",call:s,newMethod:"eth.getBlockUncleCount"},{name:"logs",call:"eth_logs"}],l=[{name:"coinbase",getter:"eth_coinbase"},{name:"mining",getter:"eth_mining"},{name:"gasPrice",getter:"eth_gasPrice",outputFormatter:n.convertToBigNumber},{name:"accounts",getter:"eth_accounts"},{name:"blockNumber",getter:"eth_blockNumber",outputFormatter:r.toDecimal},{name:"listening",getter:"net_listening",setter:"eth_setListening",newProperty:"net.listening"},{name:"peerCount",getter:"net_peerCount",newProperty:"net.peerCount"},{name:"number",getter:"eth_number",newProperty:"eth.blockNumber"}];e.exports={methods:c,properties:l}},{"../utils/utils":5,"./formatters":12}],10:[function(t,e){var n=t("../solidity/abi"),r=t("../utils/utils"),o=t("./signature"),a=function(t,e){return t.filter(function(t){return t.indexed===e})},i=function(t,e){var n=r.findIndex(t,function(t){return t.name===e});return-1===n?void console.error("indexed param with name "+e+" not found"):t[n]},u=function(t,e){return Object.keys(e).map(function(r){var o=[i(a(t.inputs,!0),r)],u=e[r];return u instanceof Array?u.map(function(t){return n.formatInput(o,[t])}):n.formatInput(o,[u])})},s=function(t,e,n){return function(r,o){var a=o||{};return a.address=t,a.topics=[],a.topics.push(e),r&&(a.topics=a.topics.concat(u(n,r))),a}},c=function(t,e,n){var r=e.slice(),o=n.slice();return t.reduce(function(t,e){var n;return n=e.indexed?r.splice(0,1)[0]:o.splice(0,1)[0],t[e.name]=n,t},{})},l=function(t){return function(e){var o={event:r.extractDisplayName(t.name),number:e.number,hash:e.hash,args:{}};if(e.topics=e.topic,!e.topics)return o;var i=a(t.inputs,!0),u="0x"+e.topics.slice(1,e.topics.length).map(function(t){return t.slice(2)}).join(""),s=n.formatOutput(i,u),l=a(t.inputs,!1),f=n.formatOutput(l,e.data);return o.args=c(t.inputs,s,f),o}},f=function(t,e){for(var n=0;n<t.length;n++){var r=o.eventSignatureFromAscii(t[n].name);if(r===e.topics[0])return t[n]}return void 0};e.exports={inputParser:s,outputParser:l,getMatchingEvent:f}},{"../solidity/abi":1,"../utils/utils":5,"./signature":19}],11:[function(t,e){var n=t("../utils/utils"),r=function(t){return!!t&&"function"==typeof t.newFilter&&"function"==typeof t.getLogs&&"function"==typeof t.uninstallFilter&&"function"==typeof t.startPolling&&"function"==typeof t.stopPolling},o=function(t){return"string"==typeof t?t:(t=t||{},t.topic&&(console.warn('"topic" is deprecated, is "topics" instead'),t.topics=t.topic),t.earliest&&(console.warn('"earliest" is deprecated, is "fromBlock" instead'),t.fromBlock=t.earliest),t.latest&&(console.warn('"latest" is deprecated, is "toBlock" instead'),t.toBlock=t.latest),t.skip&&(console.warn('"skip" is deprecated, is "offset" instead'),t.offset=t.skip),t.max&&(console.warn('"max" is deprecated, is "limit" instead'),t.limit=t.max),t.topics instanceof Array&&(t.topics=t.topics.map(function(t){return n.toHex(t)})),{fromBlock:n.toHex(t.fromBlock),toBlock:n.toHex(t.toBlock),limit:n.toHex(t.limit),offset:n.toHex(t.offset),to:t.to,address:t.address,topics:t.topics})},a=function(t,e,a){if(!r(e))return void console.error("filter implemenation is invalid");t=o(t);var i=[],u=e.newFilter(t),s=function(t){t.forEach(function(t){t=a?a(t):t,i.forEach(function(e){e(t)})})};e.startPolling(u,s,e.uninstallFilter);var c=function(t){i.push(t)},l=function(){e.stopPolling(u),e.uninstallFilter(u),i=[]},f=function(){var t=e.getLogs(u);return n.isArray(t)?t.map(function(t){return a?a(t):t}):t};return{watch:c,stopWatching:l,get:f,changed:function(){return console.warn("watch().changed() is deprecated please use filter().watch() instead."),c.apply(this,arguments)},arrived:function(){return console.warn("watch().arrived() is deprecated please use filter().watch() instead."),c.apply(this,arguments)},happened:function(){return console.warn("watch().happened() is deprecated please use filter().watch() instead."),c.apply(this,arguments)},uninstall:function(){return console.warn("watch().uninstall() is deprecated please use filter().stopWatching() instead."),l.apply(this,arguments)},messages:function(){return console.warn("watch().messages() is deprecated please use filter().get() instead."),f.apply(this,arguments)},logs:function(){return console.warn("watch().logs() is deprecated please use filter().get() instead."),f.apply(this,arguments)}}};e.exports=a},{"../utils/utils":5}],12:[function(t,e){var n=t("../utils/utils"),r=function(t){return n.toBigNumber(t)},o=function(t){return t.code&&(t.data=t.code,delete t.code),["gasPrice","gas","value"].forEach(function(e){t[e]=n.fromDecimal(t[e])}),t},a=function(t){return t.gas=n.toDecimal(t.gas),t.gasPrice=n.toBigNumber(t.gasPrice),t.value=n.toBigNumber(t.value),t},i=function(t){return t.code&&(t.data=t.code,delete t.code),t},u=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.minGasPrice=n.toBigNumber(t.minGasPrice),t.difficulty=n.toBigNumber(t.difficulty),t.totalDifficulty=n.toBigNumber(t.totalDifficulty),t.transactions instanceof Array&&t.transactions.forEach(function(t){return n.isString(t)?void 0:a(t)}),t},s=function(t){return t.blockNumber=n.toDecimal(t.blockNumber),t.transactionIndex=n.toDecimal(t.transactionIndex),t.logIndex=n.toDecimal(t.logIndex),t},c=function(t){return t.payload=n.toHex(t.payload),t.ttl=n.fromDecimal(t.ttl),t.priority=n.fromDecimal(t.priority),t.topics instanceof Array||(t.topics=[t.topics]),t.topics=t.topics.map(function(t){return n.fromAscii(t)}),t},l=function(t){if(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),0===t.payload.indexOf("{")||0===t.payload.indexOf("["))try{t.payload=JSON.parse(t.payload)}catch(e){}return t.topics=t.topics.map(function(t){return n.toAscii(t)}),t};e.exports={convertToBigNumber:r,inputTransactionFormatter:o,outputTransactionFormatter:a,inputCallFormatter:i,outputBlockFormatter:u,outputLogFormatter:s,inputPostFormatter:c,outputPostFormatter:l}},{"../utils/utils":5}],13:[function(t,e){var n=function(t){this.name="HTTP",this.handlers=[],this.host=t||"http://localhost:8080"};n.prototype.send=function(t,e){var n=new XMLHttpRequest;if(n.open("POST",this.host,!1),"function"!=typeof e){if(n.open("POST",this.host,!1),n.send(JSON.stringify(t)),200!==n.status)return;return JSON.parse(n.responseText)}n.onreadystatechange=function(){if(4===n.readyState){var t="";try{t=JSON.parse(n.responseText)}catch(r){t=r}e(t,n.status)}},n.open("POST",this.host,!0),n.send(JSON.stringify(t))},e.exports=n},{}],14:[function(t,e){var n=1,r=function(t,e){return t||console.error("jsonrpc method should be specified!"),{jsonrpc:"2.0",method:t,params:e||[],id:n++}},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)})};e.exports={toPayload:r,isValidResponse:o,toBatchPayload:a}},{}],15:[function(t,e){var n=t("../utils/utils"),r=[],o=[{name:"listening",getter:"net_listening"},{name:"peerCount",getter:"net_peerCount",outputFormatter:n.toDecimal}];e.exports={methods:r,properties:o}},{"../utils/utils":5}],16:[function(t,e){var n=function(){};n.prototype.send=function(t){var e=navigator.qt.callMethod(JSON.stringify(t));return JSON.parse(e)},e.exports=n},{}],17:[function(t,e){var n=t("./jsonrpc"),r=t("../utils/config"),o=function(){var t,e=[],o=null,a=function(e,r){"function"==typeof e.inputFormatter?e.params=Array.prototype.map.call(e.params,function(t,n){return!e.addDefaultblock||n+1<e.addDefaultblock?e.inputFormatter(t):t}):e.inputFormatter instanceof Array&&(e.params=Array.prototype.map.call(e.inputFormatter,function(t,n){return!e.addDefaultblock||n+1<e.addDefaultblock?t(e.params[n]):e.params[n]}));var o=n.toPayload(e.method,e.params);if(!t)return console.error("provider is not set"),null;if("function"!=typeof r||"HTTP"!==t.name){var a=t.send(o);return n.isValidResponse(a)?"function"==typeof e.outputFormatter?e.outputFormatter(a.result):a.result:(console.log(a),"object"==typeof a&&a.error&&a.error.message&&console.error(a.error.message),null)}t.send(o,function(t,o){return n.isValidResponse(t)?void r(null,"function"==typeof e.outputFormatter?e.outputFormatter(t.result):t.result):("object"==typeof t&&t.error&&t.error.message?(console.error(t.error.message),r(t.error)):r(new Error({status:o,error:t,message:"Bad Request"})),null)})},i=function(e){t=e},u=function(t,n,r,o){e.push({data:t,id:n,callback:r,uninstall:o})},s=function(t){for(var n=e.length;n--;){var r=e[n];r.id===t&&e.splice(n,1)}},c=function(){e.forEach(function(t){t.uninstall(t.id)}),e=[],o&&(clearTimeout(o),o=null),l()},l=function(){e.forEach(function(t){a(t.data,function(e,n){n instanceof Array&&0!==n.length&&t.callback(n)})}),o=setTimeout(l,r.ETH_POLLING_TIMEOUT)};return l(),{send:a,setProvider:i,startPolling:u,stopPolling:s,reset:c}};e.exports=o},{"../utils/config":4,"./jsonrpc":14}],18:[function(t,e){var n=t("./formatters"),r=function(){return[{name:"post",call:"shh_post",inputFormatter:n.inputPostFormatter},{name:"newIdentity",call:"shh_newIdentity"},{name:"hasIdentity",call:"shh_hasIdentity"},{name:"newGroup",call:"shh_newGroup"},{name:"addToGroup",call:"shh_addToGroup"},{name:"haveIdentity",call:"shh_haveIdentity",newMethod:"shh.hasIdentity"}]};e.exports={methods:r}},{"./formatters":12}],19:[function(t,e){var n=t("../web3"),r=t("../utils/config"),o=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*r.ETH_SIGNATURE_LENGTH)},a=function(t){return n.sha3(n.fromAscii(t))};e.exports={functionSignatureFromAscii:o,eventSignatureFromAscii:a}},{"../utils/config":4,"../web3":6}],20:[function(t,e){var n=function(){var t=function(t){return"string"==typeof t[0]?"eth_newBlockFilter":"eth_newFilter"};return[{name:"newFilter",call:t},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getLogs",call:"eth_getFilterLogs"}]},r=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getLogs",call:"shh_getMessages"}]};e.exports={eth:n,shh:r}},{}],web3:[function(t,e){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"),e.exports=n},{"./lib/solidity/abi":1,"./lib/web3":6,"./lib/web3/contract":7,"./lib/web3/httpprovider":13,"./lib/web3/qtsync":16}]},{},["web3"]);`
+const Ethereum_JS = `require=function t(e,n,r){function o(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(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=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return o(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(t,e){var n=t("../utils/utils"),r=t("../utils/config"),o=t("./types"),i=t("./formatters"),a=function(t){throw new Error("parser does not support type: "+t)},s=function(t){return"[]"===t.slice(-2)},u=function(t,e){return s(t)||"bytes"===t?i.formatInputInt(e.length):""},c=o.inputTypes(),l=function(t,e){var n="",r="",o="";return t.forEach(function(t,r){n+=u(t.type,e[r])}),t.forEach(function(n,i){for(var u=!1,l=0;l<c.length&&!u;l++)u=c[l].type(t[i].type,e[i]);u||a(t[i].type);var f=c[l-1].format;s(t[i].type)?o+=e[i].reduce(function(t,e){return t+f(e)},""):"bytes"===t[i].type?o+=f(e[i]):r+=f(e[i])}),n+=r+o},f=function(t){return s(t)||"bytes"===t?2*r.ETH_PADDING:0},p=o.outputTypes(),m=function(t,e){e=e.slice(2);var n=[],u=2*r.ETH_PADDING,c=t.reduce(function(t,e){return t+f(e.type)},0),l=e.slice(0,c);return e=e.slice(c),t.forEach(function(r,c){for(var f=!1,m=0;m<p.length&&!f;m++)f=p[m].type(t[c].type);f||a(t[c].type);var d=p[m-1].format;if(s(t[c].type)){var h=i.formatOutputUInt(l.slice(0,u));l=l.slice(u);for(var g=[],y=0;h>y;y++)g.push(d(e.slice(0,u))),e=e.slice(u);n.push(g)}else o.prefixedType("bytes")(t[c].type)?(l=l.slice(u),n.push(d(e.slice(0,u))),e=e.slice(u)):(n.push(d(e.slice(0,u))),e=e.slice(u))}),n},d=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 l(t.inputs,e)};void 0===e[r]&&(e[r]=i),e[r][o]=i}),e},h=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),o=n.extractTypeName(t.name),i=function(e){return m(t.outputs,e)};void 0===e[r]&&(e[r]=i),e[r][o]=i}),e};e.exports={inputParser:d,outputParser:h,formatInput:l,formatOutput:m}},{"../utils/config":5,"../utils/utils":6,"./formatters":2,"./types":3}],2:[function(t,e){var n=t("bignumber.js"),r=t("../utils/utils"),o=t("../utils/config"),i=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},a=function(t){var e=2*o.ETH_PADDING;return n.config(o.ETH_BIGNUMBER_ROUNDING_MODE),i(r.toTwosComplement(t).round().toString(16),e)},s=function(t){return r.fromAscii(t,o.ETH_PADDING).substr(2)},u=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},c=function(t){return a(new n(t).times(new n(2).pow(128)))},l=function(t){return"1"===new n(t.substr(0,1),16).toString(2).substr(0,1)},f=function(t){return t=t||"0",l(t)?new n(t,16).minus(new n("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new n(t,16)},p=function(t){return t=t||"0",new n(t,16)},m=function(t){return f(t).dividedBy(new n(2).pow(128))},d=function(t){return p(t).dividedBy(new n(2).pow(128))},h=function(t){return"0x"+t},g=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},y=function(t){return r.toAscii(t)},v=function(t){return"0x"+t.slice(t.length-40,t.length)};e.exports={formatInputInt:a,formatInputString:s,formatInputBool:u,formatInputReal:c,formatOutputInt:f,formatOutputUInt:p,formatOutputReal:m,formatOutputUReal:d,formatOutputHash:h,formatOutputBool:g,formatOutputString:y,formatOutputAddress:v}},{"../utils/config":5,"../utils/utils":6,"bignumber.js":"bignumber.js"}],3:[function(t,e){var n=t("./formatters"),r=function(t){return function(e){return 0===e.indexOf(t)}},o=function(t){return function(e){return t===e}},i=function(){return[{type:r("uint"),format:n.formatInputInt},{type:r("int"),format:n.formatInputInt},{type:r("bytes"),format:n.formatInputString},{type:r("real"),format:n.formatInputReal},{type:r("ureal"),format:n.formatInputReal},{type:o("address"),format:n.formatInputInt},{type:o("bool"),format:n.formatInputBool}]},a=function(){return[{type:r("uint"),format:n.formatOutputUInt},{type:r("int"),format:n.formatOutputInt},{type:r("bytes"),format:n.formatOutputString},{type:r("real"),format:n.formatOutputReal},{type:r("ureal"),format:n.formatOutputUReal},{type:o("address"),format:n.formatOutputAddress},{type:o("bool"),format:n.formatOutputBool}]};e.exports={prefixedType:r,namedType:o,inputTypes:i,outputTypes:a}},{"./formatters":2}],4:[function(t,e,n){"use strict";n.XMLHttpRequest="undefined"==typeof XMLHttpRequest?{}:XMLHttpRequest},{}],5:[function(t,e){var n=t("bignumber.js"),r=["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:r,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:n.ROUND_DOWN},ETH_POLLING_TIMEOUT:1e3,ETH_DEFAULTBLOCK:"latest"}},{"bignumber.js":"bignumber.js"}],6:[function(t,e){var n=t("bignumber.js"),r={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"},o=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},i=function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);r>n;n+=2){var o=parseInt(t.substr(n,2),16);if(0===o)break;e+=String.fromCharCode(o)}return e},a=function(t){for(var e="",n=0;n<t.length;n++){var r=t.charCodeAt(n).toString(16);e+=r.length<2?"0"+r:r}return e},s=function(t,e){e=void 0===e?0:e;for(var n=a(t);n.length<2*e;)n+="00";return"0x"+n},u=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},c=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)).replace(" ",""):""},l=function(t){return t.filter(function(t){return"function"===t.type})},f=function(t){return t.filter(function(t){return"event"===t.type})},p=function(t){return v(t).toNumber()},m=function(t){var e=v(t),n=e.toString(16);return e.lessThan(0)?"-0x"+n.substr(1):"0x"+n},d=function(t){if(O(t))return m(+t);if(x(t))return m(t);if(T(t))return s(JSON.stringify(t));if(F(t)){if(0===t.indexOf("-0x"))return m(t);if(!isFinite(t))return s(t)}return m(t)},h=function(t){t=t?t.toLowerCase():"ether";var e=r[t];if(void 0===e)throw new Error("This unit doesn't exists, please use the one of the following units"+JSON.stringify(r,null,2));return new n(e,10)},g=function(t,e){var n=v(t).dividedBy(h(e));return x(t)?n:n.toString(10)},y=function(t,e){var n=v(t).times(h(e));return x(t)?n:n.toString(10)},v=function(t){return t=t||0,x(t)?t:!F(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=v(t);return e.lessThan(0)?new n("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(e).plus(1):e},w=function(t){return F(t)?0===t.indexOf("0x")&&42===t.length||-1===t.indexOf("0x")&&40===t.length:!1},x=function(t){return t instanceof n||t&&t.constructor&&"BigNumber"===t.constructor.name},F=function(t){return"string"==typeof t||t&&t.constructor&&"String"===t.constructor.name},_=function(t){return"function"==typeof t},T=function(t){return"object"==typeof t},O=function(t){return"boolean"==typeof t},N=function(t){return t instanceof Array},B=function(t){try{JSON.parse(t)}catch(e){return!1}return!0};e.exports={findIndex:o,toHex:d,toDecimal:p,fromDecimal:m,toAscii:i,fromAscii:s,extractDisplayName:u,extractTypeName:c,filterFunctions:l,filterEvents:f,toWei:y,fromWei:g,toBigNumber:v,toTwosComplement:b,isBigNumber:x,isAddress:w,isFunction:_,isString:F,isObject:T,isBoolean:O,isArray:N,isJson:B}},{"bignumber.js":"bignumber.js"}],7:[function(t,e){e.exports={version:"0.1.3"}},{}],8:[function(t,e){var n=t("./version.json"),r=t("./web3/net"),o=t("./web3/eth"),i=t("./web3/db"),a=t("./web3/shh"),s=t("./web3/watches"),u=t("./web3/filter"),c=t("./utils/utils"),l=t("./web3/formatters"),f=t("./web3/requestmanager"),p=t("./utils/config"),m=t("./web3/method"),d=t("./web3/property"),h=function(){var t=new m({name:"sha3",call:"web3_sha3",params:1,inputFormatter:[c.toHex]});return[t]},g=[new d({name:"version.client",getter:"web3_clientVersion"}),new d({name:"version.network",getter:"net_version"})],y=function(t,e){e.forEach(function(e){var n=function(){var t=Array.prototype.slice.call(arguments),n=e.getCall(t),r=e.extractCallback(t),o=e.formatInput(t);e.validateArgs(o);var i={method:n,params:o};return r&&_.manager.sendAsync?_.manager.sendAsync(i,function(t,n){r(null,e.formatOutput(n))}):e.formatOutput(_.manager.send(i))};e.attachToObject(t,n)})},v=function(t,e){e.forEach(function(e){var n={};n.get=function(){return e.formatOutput(_.manager.send({method:e.getter}))},e.setter&&(n.set=function(t){return _.manager.send({method:e.setter,params:[e.formatInput(t)]})}),e.attachToObject(t,n)})},b=function(t,e,n,r){_.manager.startPolling({method:t,params:[e]},e,n,r)},w=function(t){_.manager.stopPolling(t)},x={startPolling:b.bind(null,"eth_getFilterChanges"),stopPolling:w},F={startPolling:b.bind(null,"shh_getFilterChanges"),stopPolling:w},_={version:{api:n.version},manager:new f,providers:{},setProvider:function(t){_.manager.setProvider(t)},reset:function(){_.manager.reset()},toHex:c.toHex,toAscii:c.toAscii,fromAscii:c.fromAscii,toDecimal:c.toDecimal,fromDecimal:c.fromDecimal,toBigNumber:c.toBigNumber,toWei:c.toWei,fromWei:c.fromWei,isAddress:c.isAddress,net:{},eth:{contractFromAbi:function(t){return console.warn("Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead."),function(e){e=e||"0xc6d9d2cd449a754c494264e1809c50e34d64562b";var n=_.eth.contract(e,t);return n.address=e,n}},filter:function(t,e,n){return t._isEvent?t(e,n):u(t,x,l.outputLogFormatter)},watch:function(t,e,n){return console.warn("eth.watch() is deprecated please use eth.filter() instead."),this.filter(t,e,n)}},db:{},shh:{filter:function(t){return u(t,F,l.outputPostFormatter)},watch:function(t){return console.warn("shh.watch() is deprecated please use shh.filter() instead."),this.filter(t)}}};Object.defineProperty(_.eth,"defaultBlock",{get:function(){return p.ETH_DEFAULTBLOCK},set:function(t){return p.ETH_DEFAULTBLOCK=t,p.ETH_DEFAULTBLOCK}}),y(_,h()),v(_,g),y(_.net,r.methods),v(_.net,r.properties),y(_.eth,o.methods),v(_.eth,o.properties),y(_.db,i.methods),y(_.shh,a.methods),y(x,s.eth()),y(F,s.shh()),e.exports=_},{"./utils/config":5,"./utils/utils":6,"./version.json":7,"./web3/db":10,"./web3/eth":12,"./web3/filter":14,"./web3/formatters":15,"./web3/method":18,"./web3/net":19,"./web3/property":20,"./web3/requestmanager":22,"./web3/shh":23,"./web3/watches":25}],9:[function(t,e){function n(t,e){t.forEach(function(t){if(-1===t.name.indexOf("(")){var e=t.name,n=t.inputs.map(function(t){return t.type}).join();t.name=e+"("+n+")"}});var n={};return c(n),l(n,t,e),f(n,t,e),p(n,t,e),n}var r=t("../web3"),o=t("../solidity/abi"),i=t("../utils/utils"),a=t("./event"),s=t("./signature"),u=function(t){r._currentContractAbi=t.abi,r._currentContractAddress=t.address,r._currentContractMethodName=t.method,r._currentContractMethodParams=t.params},c=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},t.transact=function(e){return console.warn("myContract.transact() is deprecated please use myContract.sendTransaction() instead."),t.sendTransaction(e)},t._options={},["gas","gasPrice","value","from"].forEach(function(e){t[e]=function(n){return t._options[e]=n,t}})},l=function(t,e,n){var a=o.inputParser(e),c=o.outputParser(e);i.filterFunctions(e).forEach(function(o){var l=i.extractDisplayName(o.name),f=i.extractTypeName(o.name),p=function(){var i=Array.prototype.slice.call(arguments),p=s.functionSignatureFromAscii(o.name),m=a[l][f].apply(null,i),d=t._options||{};d.to=n,d.data=p+m;var h=t._isTransaction===!0||t._isTransaction!==!1&&!o.constant,g=d.collapse!==!1;if(t._options={},t._isTransaction=null,h)return u({abi:e,address:n,method:o.name,params:i}),void r.eth.sendTransaction(d);var y=r.eth.call(d),v=c[l][f](y);return g&&(1===v.length?v=v[0]:0===v.length&&(v=null)),v};void 0===t[l]&&(t[l]=p),t[l][f]=p})},f=function(t,e,n){t.address=n,t._onWatchEventResult=function(t){var n=event.getMatchingEvent(i.filterEvents(e)),r=a.outputParser(n);return r(t)},Object.defineProperty(t,"topics",{get:function(){return i.filterEvents(e).map(function(t){return s.eventSignatureFromAscii(t.name)})}})},p=function(t,e,n){i.filterEvents(e).forEach(function(e){var o=function(){var t=Array.prototype.slice.call(arguments),o=s.eventSignatureFromAscii(e.name),i=a.inputParser(n,o,e),u=i.apply(null,t),c=function(t){var n=a.outputParser(e);return n(t)};return r.eth.filter(u,void 0,void 0,c)};o._isEvent=!0;var u=i.extractDisplayName(e.name),c=i.extractTypeName(e.name);void 0===t[u]&&(t[u]=o),t[u][c]=o})},m=function(t){return t instanceof Array&&1===arguments.length?n.bind(null,t):(console.warn("Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead."),new n(arguments[1],arguments[0]))};e.exports=m},{"../solidity/abi":1,"../utils/utils":6,"../web3":8,"./event":13,"./signature":24}],10:[function(t,e){var n=t("./method"),r=new n({name:"putString",call:"db_putString",params:3}),o=new n({name:"putHex",call:"db_putHex",params:3}),i=new n({name:"getString",call:"db_getString",params:2}),a=new n({name:"getHex",call:"db_getHex",params:2}),s=[r,o,i,a];e.exports={methods:s}},{"./method":18}],11:[function(t,e){var n=t("../utils/utils");e.exports={InvalidNumberOfParams:new Error("Invalid number of input parameters"),InvalidProvider:new Error("Providor not set or invalid"),InvalidResponse:function(t){var e="Invalid JSON RPC response";return n.isObject(t)&&t.error&&t.error.message&&(e=t.error.message),new Error(e)}}},{"../utils/utils":6}],12:[function(t,e){"use strict";var n=t("./formatters"),r=t("../utils/utils"),o=t("./method"),i=t("./property"),a=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},s=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},u=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},c=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},l=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},f=new o({name:"getBalance",call:"eth_getBalance",params:2,inputFormatter:[r.toHex,n.inputDefaultBlockNumberFormatter],outputFormatter:n.outputBigNumberFormatter}),p=new o({name:"getStorageAt",call:"eth_getStorageAt",params:3,inputFormatter:[null,r.toHex,n.inputDefaultBlockNumberFormatter]}),m=new o({name:"getCode",call:"eth_getCode",params:2,inputFormatter:[null,n.inputDefaultBlockNumberFormatter]}),d=new o({name:"getBlock",call:a,params:2,inputFormatter:[r.toHex,function(t){return!!t}],outputFormatter:n.outputBlockFormatter}),h=new o({name:"getUncle",call:u,params:3,inputFormatter:[r.toHex,r.toHex,function(t){return!!t}],outputFormatter:n.outputBlockFormatter}),g=new o({name:"getCompilers",call:"eth_getCompilers",params:0}),y=new o({name:"getBlockTransactionCount",call:c,params:1,inputFormatter:[r.toHex],outputFormatter:r.toDecimal}),v=new o({name:"getBlockUncleCount",call:l,params:1,inputFormatter:[r.toHex],outputFormatter:r.toDecimal}),b=new o({name:"getTransaction",call:"eth_getTransactionByHash",params:1,outputFormatter:n.outputTransactionFormatter}),w=new o({name:"getTransactionFromBlock",call:s,params:2,inputFormatter:[r.toHex,r.toHex],outputFormatter:n.outputTransactionFormatter}),x=new o({name:"getTransactionCount",call:"eth_getTransactionCount",params:2,inputFormatter:[null,n.inputDefaultBlockNumberFormatter],outputFormatter:r.toDecimal}),F=new o({name:"sendTransaction",call:"eth_sendTransaction",params:1,inputFormatter:[n.inputTransactionFormatter]}),_=new o({name:"call",call:"eth_call",params:2,inputFormatter:[n.inputCallFormatter,n.inputDefaultBlockNumberFormatter]}),T=new o({name:"compile.solidity",call:"eth_compileSolidity",params:1}),O=new o({name:"compile.lll",call:"eth_compileLLL",params:1}),N=new o({name:"compile.serpent",call:"eth_compileSerpent",params:1}),B=new o({name:"flush",call:"eth_flush",params:0}),I=[f,p,m,d,h,g,y,v,b,w,x,_,F,T,O,N,B],P=[new i({name:"coinbase",getter:"eth_coinbase"}),new i({name:"mining",getter:"eth_mining"}),new i({name:"gasPrice",getter:"eth_gasPrice",outputFormatter:n.inputNumberFormatter}),new i({name:"accounts",getter:"eth_accounts"}),new i({name:"blockNumber",getter:"eth_blockNumber",outputFormatter:r.toDecimal})];e.exports={methods:I,properties:P}},{"../utils/utils":6,"./formatters":15,"./method":18,"./property":20}],13:[function(t,e){var n=t("../solidity/abi"),r=t("../utils/utils"),o=t("./signature"),i=function(t,e){return t.filter(function(t){return t.indexed===e})},a=function(t,e){var n=r.findIndex(t,function(t){return t.name===e});return-1===n?void console.error("indexed param with name "+e+" not found"):t[n]},s=function(t,e){return Object.keys(e).map(function(r){var o=[a(i(t.inputs,!0),r)],s=e[r];return s instanceof Array?s.map(function(t){return n.formatInput(o,[t])}):n.formatInput(o,[s])})},u=function(t,e,n){return function(r,o){var i=o||{};return i.address=t,i.topics=[],i.topics.push(e),r&&(i.topics=i.topics.concat(s(n,r))),i}},c=function(t,e,n){var r=e.slice(),o=n.slice();return t.reduce(function(t,e){var n;return n=e.indexed?r.splice(0,1)[0]:o.splice(0,1)[0],t[e.name]=n,t},{})},l=function(t){return function(e){var o={event:r.extractDisplayName(t.name),number:e.number,hash:e.hash,args:{}};if(e.topics=e.topic,!e.topics)return o;var a=i(t.inputs,!0),s="0x"+e.topics.slice(1,e.topics.length).map(function(t){return t.slice(2)}).join(""),u=n.formatOutput(a,s),l=i(t.inputs,!1),f=n.formatOutput(l,e.data);return o.args=c(t.inputs,u,f),o}},f=function(t,e){for(var n=0;n<t.length;n++){var r=o.eventSignatureFromAscii(t[n].name);if(r===e.topics[0])return t[n]}return void 0};e.exports={inputParser:u,outputParser:l,getMatchingEvent:f}},{"../solidity/abi":1,"../utils/utils":6,"./signature":24}],14:[function(t,e){var n=t("../utils/utils"),r=function(t){return!!t&&"function"==typeof t.newFilter&&"function"==typeof t.getLogs&&"function"==typeof t.uninstallFilter&&"function"==typeof t.startPolling&&"function"==typeof t.stopPolling},o=function(t){if("string"==typeof t)return t;t=t||{},t.topic&&(console.warn('"topic" is deprecated, is "topics" instead'),t.topics=t.topic),t.earliest&&(console.warn('"earliest" is deprecated, is "fromBlock" instead'),t.fromBlock=t.earliest),t.latest&&(console.warn('"latest" is deprecated, is "toBlock" instead'),t.toBlock=t.latest),t.skip&&(console.warn('"skip" is deprecated, is "offset" instead'),t.offset=t.skip),t.max&&(console.warn('"max" is deprecated, is "limit" instead'),t.limit=t.max),t.topics instanceof Array&&(t.topics=t.topics.map(function(t){return n.toHex(t)}));var e={};return t.topics&&(e.topics=t.topics),t.to&&(e.to=t.to),t.address&&(e.address=t.address),"undefined"!=typeof t.fromBlock&&(e.fromBlock=n.toHex(t.fromBlock)),"undefined"!=typeof t.toBlock&&(e.toBlock=n.toHex(t.toBlock)),e},i=function(t,e,i){if(!r(e))return void console.error("filter implemenation is invalid");t=o(t);var a=[],s=e.newFilter(t),u=function(t){t.forEach(function(t){t=i?i(t):t,a.forEach(function(e){e(t)})})},c=function(t){e.startPolling(s,u,e.uninstallFilter),a.push(t)},l=function(){e.stopPolling(s),a=[]},f=function(){e.stopPolling(s),e.uninstallFilter(s),a=[]},p=function(){var t=e.getLogs(s);return n.isArray(t)?t.map(function(t){return i?i(t):t}):t};return{watch:c,stopWatching:l,get:p,uninstall:f,changed:function(){return console.warn("watch().changed() is deprecated please use filter().watch() instead."),c.apply(this,arguments)},arrived:function(){return console.warn("watch().arrived() is deprecated please use filter().watch() instead."),c.apply(this,arguments)},happened:function(){return console.warn("watch().happened() is deprecated please use filter().watch() instead."),c.apply(this,arguments)},messages:function(){return console.warn("watch().messages() is deprecated please use filter().get() instead."),p.apply(this,arguments)},logs:function(){return console.warn("watch().logs() is deprecated please use filter().get() instead."),p.apply(this,arguments)}}};e.exports=i},{"../utils/utils":6}],15:[function(t,e){var n=t("../utils/utils"),r=t("../utils/config"),o=function(t){return n.toBigNumber(t)},i=function(t){return void 0===t?r.ETH_DEFAULTBLOCK:n.toHex(t)},a=function(t){return t.code&&(t.data=t.code,delete t.code),["gasPrice","gas","value"].forEach(function(e){t[e]=n.fromDecimal(t[e])}),t},s=function(t){return t.blockNumber=n.toDecimal(t.blockNumber),t.transactionIndex=n.toDecimal(t.transactionIndex),t.gas=n.toDecimal(t.gas),t.gasPrice=n.toBigNumber(t.gasPrice),t.value=n.toBigNumber(t.value),t},u=function(t){return t.code&&(t.data=t.code,delete t.code),t},c=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.minGasPrice=n.toBigNumber(t.minGasPrice),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:s(t)}),t},l=function(t){return t.blockNumber=n.toDecimal(t.blockNumber),t.transactionIndex=n.toDecimal(t.transactionIndex),t.logIndex=n.toDecimal(t.logIndex),t},f=function(t){return t.payload=n.toHex(t.payload),t.ttl=n.fromDecimal(t.ttl),t.priority=n.fromDecimal(t.priority),n.isArray(t.topics)||(t.topics=[t.topics]),t.topics=t.topics.map(function(t){return n.fromAscii(t)}),t},p=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.map(function(t){return n.toAscii(t)}),t};e.exports={inputDefaultBlockNumberFormatter:i,inputTransactionFormatter:a,inputCallFormatter:u,inputPostFormatter:f,outputBigNumberFormatter:o,outputTransactionFormatter:s,outputBlockFormatter:c,outputLogFormatter:l,outputPostFormatter:p}},{"../utils/config":5,"../utils/utils":6}],16:[function(t,e){"use strict";var n=t("xmlhttprequest").XMLHttpRequest,r=function(t){this.host=t||"http://localhost:8080"};r.prototype.send=function(t){var e=new n;return e.open("POST",this.host,!1),e.send(JSON.stringify(t)),JSON.parse(e.responseText)},r.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),r.send(JSON.stringify(t))},e.exports=r},{xmlhttprequest:4}],17:[function(t,e){var n=function(){this.messageId=1};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},{}],18:[function(t,e){var n=t("../utils/utils"),r=t("./errors"),o=function(t){this.name=t.name,this.call=t.call,this.params=t.params||0,this.inputFormatter=t.inputFormatter,this.outputFormatter=t.outputFormatter};o.prototype.getCall=function(t){return n.isFunction(this.call)?this.call(t):this.call},o.prototype.extractCallback=function(t){return n.isFunction(t[t.length-1])?t.pop():null},o.prototype.validateArgs=function(t){if(t.length!==this.params)throw r.InvalidNumberOfParams},o.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter.map(function(e,n){return e?e(t[n]):t[n]}):t},o.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t?this.outputFormatter(t):t},o.prototype.attachToObject=function(t,e){var n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},t[n[0]][n[1]]=e):t[n[0]]=e},e.exports=o},{"../utils/utils":6,"./errors":11}],19:[function(t,e){var n=t("../utils/utils"),r=t("./property"),o=[],i=[new r({name:"listening",getter:"net_listening"}),new r({name:"peerCount",getter:"net_peerCount",outputFormatter:n.toDecimal})];e.exports={methods:o,properties:i}},{"../utils/utils":6,"./property":20}],20:[function(t,e){var n=(t("../utils/utils"),t("./errors"),function(t){this.name=t.name,this.getter=t.getter,this.setter=t.setter,this.outputFormatter=t.outputFormatter,this.inputFormatter=t.inputFormatter});n.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter(t):t},n.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t?this.outputFormatter(t):t},n.prototype.attachToObject=function(t,e){var n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},Object.defineProperty(t[n[0]],n[1],e)):Object.defineProperty(t,n[0],e)},e.exports=n},{"../utils/utils":6,"./errors":11}],21:[function(t,e){var n=function(){};n.prototype.send=function(t){var e=navigator.qt.callMethod(JSON.stringify(t));return JSON.parse(e)},e.exports=n},{}],22:[function(t,e){var n=t("./jsonrpc"),r=t("../utils/utils"),o=t("../utils/config"),i=t("./errors"),a=function(t){this.jsonrpc=new n,this.provider=t,this.polls=[],this.timeout=null,this.poll()};a.prototype.send=function(t){if(!this.provider)return console.error(i.InvalidProvider),null;var e=this.jsonrpc.toPayload(t.method,t.params),n=this.provider.send(e);if(!this.jsonrpc.isValidResponse(n))throw i.InvalidResponse(n);return n.result},a.prototype.sendAsync=function(t,e){if(!this.provider)return e(i.InvalidProvider);var n=this.jsonrpc.toPayload(t.method,t.params),r=this;this.provider.sendAsync(n,function(t,n){return t?e(t):r.jsonrpc.isValidResponse(n)?void e(null,n.result):e(i.InvalidResponse(n))})},a.prototype.setProvider=function(t){this.provider=t},a.prototype.startPolling=function(t,e,n,r){this.polls.push({data:t,id:e,callback:n,uninstall:r})},a.prototype.stopPolling=function(t){for(var e=this.polls.length;e--;){var n=this.polls[e];n.id===t&&this.polls.splice(e,1)}},a.prototype.reset=function(){this.polls.forEach(function(t){t.uninstall(t.id)}),this.polls=[],this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.poll()},a.prototype.poll=function(){if(this.timeout=setTimeout(this.poll.bind(this),o.ETH_POLLING_TIMEOUT),this.polls.length){if(!this.provider)return void console.error(i.InvalidProvider);var t=this.jsonrpc.toBatchPayload(this.polls.map(function(t){return t.data})),e=this;this.provider.sendAsync(t,function(t,n){if(!t){if(!r.isArray(n))throw i.InvalidResponse(n);n.map(function(t,n){return t.callback=e.polls[n].callback,t}).filter(function(t){var n=e.jsonrpc.isValidResponse(t);return n||t.callback(i.InvalidResponse(t)),n}).filter(function(t){return r.isArray(t.result)&&t.result.length>0}).forEach(function(t){t.callback(null,t)})}})}},e.exports=a},{"../utils/config":5,"../utils/utils":6,"./errors":11,"./jsonrpc":17}],23:[function(t,e){var n=t("./method"),r=t("./formatters"),o=new n({name:"post",call:"shh_post",params:1,inputFormatter:r.inputPostFormatter}),i=new n({name:"newIdentity",call:"shh_newIdentity",params:0}),a=new n({name:"hasIdentity",call:"shh_hasIdentity",params:1}),s=new n({name:"newGroup",call:"shh_newGroup",params:0}),u=new n({name:"addToGroup",call:"shh_addToGroup",params:0}),c=[o,i,a,s,u];e.exports={methods:c}},{"./formatters":15,"./method":18}],24:[function(t,e){var n=t("../web3"),r=t("../utils/config"),o=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*r.ETH_SIGNATURE_LENGTH)},i=function(t){return n.sha3(n.fromAscii(t))};e.exports={functionSignatureFromAscii:o,eventSignatureFromAscii:i}},{"../utils/config":5,"../web3":8}],25:[function(t,e){var n=t("./method"),r=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});return[e,r,o]},o=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});return[t,e,r]};e.exports={eth:r,shh:o}},{"./method":18}],26:[function(){},{}],"bignumber.js":[function(t,e){"use strict";e.exports=BigNumber},{}],"ethereum.js":[function(t,e){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"),e.exports=n},{"./lib/solidity/abi":1,"./lib/web3":8,"./lib/web3/contract":9,"./lib/web3/httpprovider":16,"./lib/web3/qtsync":21}]},{},["ethereum.js"]);`
diff --git a/jsre/jsre.go b/jsre/jsre.go
index a01fb56d8..a49422a12 100644
--- a/jsre/jsre.go
+++ b/jsre/jsre.go
@@ -2,9 +2,10 @@ package jsre
import (
"fmt"
- "github.com/robertkrimen/otto"
"io/ioutil"
+ "github.com/robertkrimen/otto"
+
"github.com/ethereum/go-ethereum/common"
)
@@ -113,3 +114,12 @@ func (self *JSRE) Eval(code string) (s string, err error) {
}
return fmt.Sprintf("%v", val), nil
}
+
+func (self *JSRE) Compile(fn string, src interface{}) error {
+ script, err := self.vm.Compile(fn, src)
+ if err != nil {
+ return err
+ }
+ self.vm.Run(script)
+ return nil
+}