plugeth/dist/ethereum.min.js

1 line
10 KiB
JavaScript
Raw Normal View History

2014-11-12 17:59:29 +00:00
require=function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return o(n?n:e)},l,l.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t){var n=function(e,t){for(var n=!1,r=0;r<e.length&&!n;r++)n=t(e[r]);return n?r-1:-1},r=function(e,t){return new Array(t-e.toString.length+1).join("0")+e},o=function(){var e=function(e){return function(t,n){var o,i=e;return 0!==t.indexOf(i)?!1:(o=parseInt(t.slice(i.length))/8,r(n,o))}},t=function(e,t){return function(n,o){return n!==e?!1:r(o,t)}};return[e("uint"),e("int"),t("address",20),t("bool",1)]},i=o(),s=function(e,t,r){var o,s,a,c,u="",l=n(e,function(e){return e.name===t});if(-1!==l){for(u=u+l+"x",o=e[l],s=0;s<o.inputs.length;s++){for(a=!1,c=0;c<i.length&&!a;c++)a=i[c](o.inputs[s].type,r[s]);a||console.error("unsupported json type: "+o.inputs[s].type),u+=a}return u}};t.exports={toBytes:s}},{}],2:[function(e,t){var n=function(e){var t,n,r,o;if(!web3.haveProvider()){if(this.sendQueue=[],this.onmessageQueue=[],navigator.qt)return void(this.provider=new web3.providers.QtProvider);e=e||{},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){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},{}],4:[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 g.trigger(e._event,e._id,e.data);if(e._id){var t=g._callbacks[e._id];t&&(t.call(this,e.error,e.data),delete g._callbacks[e._id])}}var o,i,s,a,c=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:"countAt",call:"eth_countAt"},{name:"codeAt",call:"eth_codeAt"},{name: