plugeth/dist/ethereum.min.js

1 line
12 KiB
JavaScript
Raw Normal View History

2014-11-14 12:11:47 +00:00
require=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};e[s][0].call(l.exports,function(t){var n=e[s][1][t];return o(n?n:t)},l,l.exports,t,e,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(t,e){var n=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},r=function(t,e){return n(t,function(t){return t.name===e})},o=function(t,e){return new Array(2*e-t.toString().length+1).join("0")+t},i=function(){var t=function(t){return function(e,n){var r,i=t;return 0!==e.indexOf(i)?!1:(r=parseInt(e.slice(i.length))/8,o(n,r))}},e=function(t,e,n){return function(r,i){return r!==t?!1:o(n?i:n(i),e)}},n=function(t){return t?"1":"0"};return[t("uint"),t("int"),e("address",20),e("bool",1,n)]},s=i(),a=function(t,e,n){var o,i,a,u,c,l="",h=r(t,e);if(-1!==h){for(l=l+h+"x0",o=t[h],i=0;i<o.inputs.length;i++){for(a=!1,u=0;u<s.length&&!a;u++)c=parseInt(n[i]).toString(16),a=s[u](o.inputs[i].type,c);a||console.error("unsupported json type: "+o.inputs[i].type),l+=a}return l}},u=function(){var t=function(t){return function(e){var n,r=t;return 0!==e.indexOf(r)?-1:(n=parseInt(e.slice(r.length))/8,2*n)}},e=function(t,e){return function(n){return t===n?2*e:-1}},n=function(t){return parseInt(t,16)},r=function(t){return"1"===t?!0:!1};return[{padding:t("uint"),format:n},{padding:t("int"),format:n},{padding:e("address",20)},{padding:e("bool",1),format:r}]},c=u(),l=function(t,e,n){var o,i,s,a,u,l,h,p=r(t,e);if(-1!==p){for(n=n.slice(2),o=[],i=t[p],s=0;s<i.outputs.length;s++){for(a=-1,u=0;u<c.length&&-1===a;u++)a=c[u].padding(i.outputs[s].type);-1!==a&&(l=n.slice(0,a),h=c[u-1].format,o.push(h?h(l):l),n=n.slice(a))}return o}},h=function(t){var e={};return t.forEach(function(n){e[n.name]=function(){var e=Array.prototype.slice.call(arguments);return a(t,n.name,e)}}),e},p=function(t){var e={};return t.forEach(function(n){e[n.name]=function(e){return l(t,n.name,e)}}),e};e.exports={inputParser:h,outputParser:p}},{}],2:[function(t,e){var n=function(t){var e,n,r,o;if(!web3.haveProvider()){if(this.sendQueue=[],this.onmessageQueue=[],navigator.qt)return void(this.provider=new web3.providers.QtProvider);t=t||{},e={httprpc:t.httprpc||"http://localhost:8080",websockets:t.websockets||"ws://localhost:40404/eth"},n=this,r=function(t){o.close(),t?n.provider=new web3.providers.WebSocketProvider(e.websockets):(n.provider=new web3.providers.HttpRpcProvider(e.httprpc),n.poll=n.provider.poll.bind(n.provider)),n.sendQueue.forEach(function(t){n.provider(t)}),n.onmessageQueue.forEach(function(t){n.provider.onmessage=t})},o=new WebSocket(e.websockets),o.onopen=function(){r(!0)},o.onerror=function(){r(!1)}}};n.prototype.send=function(t){return this.provider?void this.provider.send(t):void this.sendQueue.push(t)},Object.defineProperty(n.prototype,"onmessage",{set:function(t){return this.provider?void(this.provider.onmessage=t):void this.onmessageQueue.push(t)}}),e.exports=n},{}],3:[function(t,e){function n(t){return{jsonrpc:"2.0",method:t.call,params:t.args,id:t._id}}function r(t){var e=JSON.parse(t);return{_id:e.id,data:e.result,error:e.error}}var o=function(t){this.handlers=[],this.host=t};o.prototype.sendRequest=function(t,e){var r=n(t),o=new XMLHttpRequest;o.open("POST",this.host,!0),o.send(JSON.stringify(r)),o.onreadystatechange=function(){4===o.readyState&&e&&e(o)}},o.prototype.send=function(t){var e=this;this.sendRequest(t,function(t){e.handlers.forEach(function(n){n.call(e,r(t.responseText))})})},o.prototype.poll=function(t,e){var n=this;this.sendRequest(t,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:t.call,_id:e,data:o.result})})})},Object.defineProperty(o.prototype,"onmessage",{set:function(t){this.handlers.push(t)}}),e.exports=o},{}],4:[function(t,e){function n(t){return t instanc