Official Go implementation of the Ethereum protocol
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.
 
 
 
 
 
 
go-ethereum/dist/ethereum.min.js

1 lines
14 KiB

require=function e(t,n,r){function o(f,s){if(!n[f]){if(!t[f]){var a="function"==typeof require&&require;if(!s&&a)return a(f,!0);if(i)return i(f,!0);var u=new Error("Cannot find module '"+f+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[f]={exports:{}};t[f][0].call(c.exports,function(e){var n=t[f][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[f].exports}for(var i="function"==typeof require&&require,f=0;f<r.length;f++)o(r[f]);return o}({1:[function(e,t){var n=e("bignumber.js"),r=function(e,t){for(var n=!1,r=0;r<e.length&&!n;r++)n=t(e[r]);return n?r-1:-1},o=function(e,t){return r(e,function(e){return e.name===t})},i=function(e,t,n){return new Array(t-e.length+1).join(n?n:"0")+e},f=function(e){return function(t){return 0===t.indexOf(e)}},s=function(e){return function(t){return e===t}},a=function(){var e=function(e){var t=64;return e=e instanceof n?e.lessThan(0)?new n("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(e).plus(1).toString(16):e.toString(16):"number"==typeof e?0>e?new n("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(e).plus(1).toString(16):new n(e).toString(16):0===e.indexOf("0x")?e.substr(2):"string"==typeof e?new n(e).toString(16):(+e).toString(16),i(e,t)},t=function(e){return web3.fromAscii(e,32).substr(2)},r=function(e){return"000000000000000000000000000000000000000000000000000000000000000"+(e?"1":"0")};return[{type:f("uint"),format:e},{type:f("int"),format:e},{type:f("hash"),format:e},{type:f("string"),format:t},{type:f("real"),format:e},{type:f("ureal"),format:e},{type:s("address"),format:e},{type:s("bool"),format:r}]},u=a(),c=function(e,t,n){var r="",i=o(e,t);if(-1!==i){for(var f=e[i],s=0;s<f.inputs.length;s++){for(var a=!1,c=0;c<u.length&&!a;c++)a=u[c].type(f.inputs[s].type,n[s]);a||console.error("input parser does not support type: "+f.inputs[s].type);var l=u[c-1].format;r+=l?l(n[s]):n[s]}return r}},l=function(){var e=function(e){return"f"===e.substr(0,1).toLowerCase()?new n(e,16).minus(new n("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new n(e,16)},t=function(e){return new n(e,16)},r=function(e){return"0x"+e},o=function(e){return"0000000000000000000000000000000000000000000000000000000000000001"===e?!0:!1},i=function(e){return web3.toAscii(e)},a=function(e){return"0x"+e.slice(e.length-40,e.length)};return[{type:f("uint"),format:t},{type:f("int"),format:e},{type:f("hash"),format:r},{type:f("string"),format:i},{type:f("real"),format:e},{type:f("ureal"),format:e},{type:s("address"),format:a},{type:s("bool"),format:o}]},h=l(),p=function(e,t,n){var r=o(e,t);if(-1!==r){n=n.slice(2);for(var i=[],f=e[r],s=64,a=0;a<f.outputs.length;a++){for(var u=!1,c=0;c<h.length&&!u;c++)u=h[c].type(f.outputs[a].type);if(u){var l=n.slice(0,s),p=h[c-1].format;i.push(p?p(l):"0x"+l),n=n.slice(s)}else console.error("output parser does not support type: "+f.outputs[a].type)}return i}},d=function(e){var t={};return e.forEach(function(n){t[n.name]=function(){var t=Array.prototype.slice.call(arguments);return c(e,n.name,t)}}),t},v=function(e){var t={};return e.forEach(function(n){t[n.name]=function(t){return p(e,n.name,t)}}),t},g=function(e,t){var n=e[o(e,t)],r=t+"(",i=n.inputs.map(function(e){return e.type});return r+=i.join(","),r+=")",web3.sha3(web3.fromAscii(r))};t.exports={inputParser:d,outputParser:v,methodSignature:g}},{"bignumber.js":void 0}],2:[function(e,t){var n=function(e){if(!web3.haveProvider()){if(this.sendQueue=[],this.onmessageQueue=[],navigator.qt)return void(this.provider=new web3.providers.QtProvider);e=e||{};var t={httprpc:e.httprpc||"http://localhost:8080",websockets:e.websockets||"ws://localhost:40404/eth"},n=this,r=function(e){o.close(),e?n.provider=new web3.providers.WebSocketProvider(t.websockets):(n.provider=new web3.providers.HttpRpcProvider(t.httprpc),n.poll=n.provider.poll.bind(n.provider)),n.sendQueue.forEach(function(e){n.provider(e)}),n.onmessageQueue.forEach(function(e){n.provider.onmessage=e})},o=new WebSocket(t.websockets);o.onopen=function(){r(!0)},o.onerror=function(){r(!1)}}};n.prototype.send=function(e){return this.provider?void this.provider.send(e):void this.sendQueue.push(e)},Object.defineProperty(n.prototype,"onmessage",{set:function(e){return this.provider?void(this.provider.onmessage=e):void this.onmessageQueue.push(e)}}),t.exports=n},{}],3:[function(e,t){var n=e("./abi"),r=4,o=function(e,t){var o=n.inputParser(t),i=n.outputParser(t),f={};return t.forEach(function(s){f[s.name]=function(){var f=Array.prototype.slice.call(arguments),a=o[s.name].apply(null,f),u=function(e){return i[s.name](e)};return{call:function(o){return o=o||{},o.to=e,n.methodSignature(t,s.name).then(function(e){return o.data=e.slice(0,2+2*r)+a,web3.eth.call(o).then(u)})},transact:function(o){return o=o||{},o.to=e,n.methodSignature(t,s.name).then(function(e){return o.data=e.slice(0,2+2*r)+a,web3.eth.transact(o).then(u)})}}}}),f};t.exports=o},{"./abi":1}],4:[function(e,t){var n=function(e,t){this.impl=t,this.callbacks=[];var n=this;this.promise=t.newFilter(e),this.promise.then(function(e){n.id=e,web3.on(t.changed,e,n.trigger.bind(n)),web3.provider.startPolling({call:t.changed,args:[e]},e)})};n.prototype.arrived=function(e){this.changed(e)},n.prototype.changed=function(e){var t=this;this.promise.then(function(){t.callbacks.push(e)})},n.prototype.trigger=function(e){for(var t=0;t<this.callbacks.length;t++)this.callbacks[t].call(this,e)},n.prototype.uninstall=function(){var e=this;this.promise.then(function(t){e.impl.uninstallFilter(t),web3.provider.stopPolling(t),web3.off(impl.changed,t)})},n.prototype.messages=function(){var e=this;return this.promise.then(function(t){return e.impl.getMessages(t)})},n.prototype.logs=function(){return this.messages()},t.exports=n},{}],5:[function(e,t){function n(e){return{jsonrpc:"2.0",method:e.call,params:e.args,id:e._id}}function r(e){var t=JSON.parse(e);return{_id:t.id,data:t.result,error:t.error}}var o=function(e){this.handlers=[],this.host=e};o.prototype.sendRequest=function(e,t){var r=n(e),o=new XMLHttpRequest;o.open("POST",this.host,!0),o.send(JSON.stringify(r)),o.onreadystatechange=function(){4===o.readyState&&t&&t(o)}},o.prototype.send=function(e){var t=this;this.sendRequest(e,function(e){t.handlers.forEach(function(n){n.call(t,r(e.responseText))})})},o.prototype.poll=function(e,t){var n=this;this.sendRequest(e,function(r){var o=JSON.parse(r.responseText);!o.error&&(o.result instanceof Array?0!==o.result.length:o.result)&&n.handlers.forEach(function(r){r.call(n,{_event:e.call,_id:t,data:o.result})})})},Object.defineProperty(o.prototype,"onmessage",{set:function(e){this.handlers.push(e)}}),t.exports=o},{}],6:[function(e,t){var n=function(){this.queued=[],this.polls=[],this.ready=!1,this.provider=void 0,this.id=1;var e=this,t=function(){e.provider&&e.provider.poll&&e.polls.forEach(function(t){t.data._id=e.id,e.id++,e.provider.poll(t.data,t.id)}),setTimeout(t,12e3)};t()};n.prototype.send=function(e,t){e._id=this.id,t&&(web3._callbacks[e._id]=t),e.args=e.args||[],this.id++,void 0!==this.provider?this.provider.send(e):(console.warn("provider is not set"),this.queued.push(e))},n.prototype.set=function(e){void 0!==this.provider&&void 0!==this.provider.unload&&this.provider.unload(),this.provider=e,this.ready=!0},n.prototype.sendQueued=function(){for(var e=0;this.queued.length;e++)this.send(this.queued[e])},n.prototype.installed=function(){return void 0!==this.provider},n.prototype.startPolling=function(e,t){this.provider&&this.provider.poll&&this.polls.push({data:e,id:t})},n.prototype.stopPolling=function(e){for(var t=this.polls.length;t--;){var n=this.polls[t];n.id===e&&this.polls.splice(t,1)}},t.exports=n},{}],7:[function(e,t){var n=function(){this.handlers=[];var e=this;navigator.qt.onmessage=function(t){e.handlers.forEach(function(n){n.call(e,JSON.parse(t.data))})}};n.prototype.send=function(e){navigator.qt.postMessage(JSON.stringify(e))},Object.defineProperty(n.prototype,"onmessage",{set:function(e){this.handlers.push(e)}}),t.exports=n},{}],8:[function(e,t){function n(e){return e instanceof Promise?Promise.resolve(e):e instanceof Array?new Promise(function(t){var r=e.map(function(e){return n(e)});return Promise.all(r).then(function(n){for(var r=0;r<e.length;r++)e[r]=n[r];t(e)})}):e instanceof Object?new Promise(function(t){var r=Object.keys(e),o=r.map(function(t){return n(e[t])});return Promise.all(o).then(function(n){for(var o=0;o<r.length;o++)e[r[o]]=n[o];t(e)})}):Promise.resolve(e)}function r(e){if(void 0!==e._event)return void m.trigger(e._event,e._id,e.data);if(e._id){var t=m._callbacks[e._id];t&&(t.call(this,e.error,e.data),delete m._callbacks[e._id])}}var o=e("./filter"),i=e("./providermanager"),f=function(){return[{name:"sha3",call:"web3_sha3"}]},s=function(){var e=function(e){return"string"==typeof e[0]?"eth_blockByHash":"eth_blockByNumber"},t=function(e){return"string"==typeof e[0]?"eth_transactionByHash":"eth_transactionByNumber"},n=function(e){return"string"==typeof e[0]?"eth_uncleByHash":"eth_uncleByNumber"},r=[{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:e},{name:"transaction",call:t},{name:"uncle",call:n},{name:"compilers",call:"eth_compilers"},{name:"lll",call:"eth_lll"},{name:"solidity",call:"eth_solidity"},{name:"serpent",call:"eth_serpent"},{name:"logs",call:"eth_logs"}];return r},a=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:"account",getter:"eth_account"},{name:"accounts",getter:"eth_accounts"},{name:"peerCount",getter:"eth_peerCount"},{name:"defaultBlock",getter:"eth_defaultBlock",setter:"eth_setDefaultBlock"},{name:"number",getter:"eth_number"}]},u=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},c=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"}]},l=function(){var e=function(e){return"string"==typeof e[0]?"eth_newFilterString":"eth_newFilter"};return[{name:"newFilter",call:e},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getMessages",call:"eth_filterLogs"}]},h=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessage",call:"shh_getMessages"}]},p=function(e,t){t.forEach(function(t){e[t.name]=function(){return n(Array.prototype.slice.call(arguments)).then(function(e){var n="function"==typeof t.call?t.call(e):t.call;return{call:n,args:e}}).then(function(e){return new Promise(function(t,n){m.provider.send(e,function(e,r){return e?void n(e):void t(r)})})}).catch(function(e){console.error(e)})}})},d=function(e,t){t.forEach(function(t){var r={};r.get=function(){return new Promise(function(e,n){m.provider.send({call:t.getter},function(t,r){return t?void n(t):void e(r)})})},t.setter&&(r.set=function(e){return n([e]).then(function(e){return new Promise(function(n){m.provider.send({call:t.setter,args:e},function(e,t){return e?void reject(e):void n(t)})})}).catch(function(e){console.error(e)})}),Object.defineProperty(e,t.name,r)})},v=function(e){return parseInt(e,16).toString()},g=function(e){return parseInt(e).toString(16)},m={_callbacks:{},_events:{},providers:{},toHex:function(e){for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n).toString(16);t+=r.length<2?"0"+r:r}return t},toAscii:function(e){var t="",n=0,r=e.length;for("0x"===e.substring(0,2)&&(n=2);r>n;n+=2){var o=parseInt(e.substr(n,2),16);if(0===o)break;t+=String.fromCharCode(o)}return t},fromAscii:function(e,t){t=void 0===t?0:t;for(var n=this.toHex(e);n.length<2*t;)n+="00";return"0x"+n},toDecimal:function(e){return v(e.substring(2))},fromDecimal:function(e){return"0x"+g(e)},toEth:function(e){for(var t="string"==typeof e?0===e.indexOf("0x")?parseInt(e.substr(2),16):parseInt(e):e,n=0,r=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];t>3e3&&n<r.length-1;)t/=1e3,n++;for(var o=t.toString().length<t.toFixed(2).length?t.toString():t.toFixed(2),i=function(e,t,n){return t+","+n};;){var f=o;if(o=o.replace(/(\d)(\d\d\d[\.\,])/,i),f===o)break}return o+" "+r[n]},eth:{watch:function(e){return new o(e,y)}},db:{},shh:{watch:function(e){return new o(e,b)}},on:function(e,t,n){return void 0===m._events[e]&&(m._events[e]={}),m._events[e][t]=n,this},off:function(e,t){return void 0!==m._events[e]&&delete m._events[e][t],this},trigger:function(e,t,n){var r=m._events[e];if(r&&r[t]){var o=r[t];o(n)}},haveProvider:function(){return!!m.provider.provider}};p(m,f()),p(m.eth,s()),d(m.eth,a()),p(m.db,u()),p(m.shh,c());var y={changed:"eth_changed"};p(y,l());var b={changed:"shh_changed"};p(b,h()),m.provider=new i,m.setProvider=function(e){e.onmessage=r,m.provider.set(e),m.provider.sendQueued()},"undefined"!=typeof t&&(t.exports=m)},{"./filter":4,"./providermanager":6}],9:[function(e,t){var n=function(e){this.handlers=[],this.queued=[],this.ready=!1,this.ws=new WebSocket(e);var t=this;this.ws.onmessage=function(e){for(var n=0;n<t.handlers.length;n++)t.handlers[n].call(t,JSON.parse(e.data),e)},this.ws.onopen=function(){t.ready=!0;for(var e=0;e<t.queued.length;e++)t.send(t.queued[e])}};n.prototype.send=function(e){if(this.ready){var t=JSON.stringify(e);this.ws.send(t)}else this.queued.push(e)},n.prototype.onMessage=function(e){this.handlers.push(e)},n.prototype.unload=function(){this.ws.close()},Object.defineProperty(n.prototype,"onmessage",{set:function(e){this.onMessage(e)}}),"undefined"!=typeof t&&(t.exports=n)},{}],web3:[function(e,t){var n=e("./lib/web3");n.providers.WebSocketProvider=e("./lib/websocket"),n.providers.HttpRpcProvider=e("./lib/httprpc"),n.providers.QtProvider=e("./lib/qt"),n.providers.AutoProvider=e("./lib/autoprovider"),n.eth.contract=e("./lib/contract"),t.exports=n},{"./lib/autoprovider":2,"./lib/contract":3,"./lib/httprpc":5,"./lib/qt":7,"./lib/web3":8,"./lib/websocket":9}]},{},["web3"]);