plugeth/dist/ethereum.min.js

1 line
14 KiB
JavaScript
Raw Normal View History

require=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[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:{}};t[a][0].call(l.exports,function(e){var n=t[a][1][e];return o(n?n:e)},l,l.exports,e,t,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(e,t){var n=function(e){return parseInt(e,16).toString()},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){return new Array(t-e.length+1).join("0")+e},a=function(){var e=function(e){return function(t,n){var r=e;if(0!==t.indexOf(r))return!1;var o=32;return"string"===e?web3.fromAscii(n,o).substr(2):(n="number"==typeof n?n.toString(16):"string"==typeof n?web3.toHex(n):0===n.indexOf("0x")?n.substr(2):(+n).toString(16),i(n,2*o))}},t=function(e,t){return function(n,r){if(n!==e)return!1;var o=32;return i(t?t(r):r,2*o)}},n=function(e){return e?"0x1":"0x0"};return[e("uint"),e("int"),e("hash"),e("string"),e("real"),e("ureal"),t("address"),t("bool",n)]},s=a(),u=function(e,t,n){var r="",i=o(e,t);if(-1!==i){for(var a=e[i],u=0;u<a.inputs.length;u++){for(var c=!1,l=0;l<s.length&&!c;l++)c=s[l](a.inputs[u].type,n[u]);c||console.error("unsupported json type: "+a.inputs[u].type),r+=c}return r}},c=function(){var e=function(e){return function(t){var n=e;if(0!==t.indexOf(n))return-1;var r=32;return 2*r}},t=function(e){return function(t){var n=32;return e===t?2*n:-1}},r=function(e){return e.length<=8?+parseInt(e,16):n(e)},o=function(e){return"0x"+e},i=function(e){return"1"===e?!0:!1},a=function(e){return web3.toAscii(e)};return[{padding:e("uint"),format:r},{padding:e("int"),format:r},{padding:e("hash"),format:o},{padding:e("string"),format:a},{padding:e("real"),format:r},{padding:e("ureal"),format:r},{padding:t("address")},{padding:t("bool"),format:i}]},l=c(),h=function(e,t,n){var r=o(e,t);if(-1!==r){n=n.slice(2);for(var i=[],a=e[r],s=0;s<a.outputs.length;s++){for(var u=-1,c=0;c<l.length&&-1===u;c++)u=l[c].padding(a.outputs[s].type);if(-1!==u){var h=n.slice(0,u),f=l[c-1].format;i.push(f?f(h):"0x"+h),n=n.slice(u)}}return i}},f=function(e){var t={};return e.forEach(function(n){t[n.name]=function(){var t=Array.prototype.slice.call(arguments);return u(e,n.name,t)}}),t},p=function(e){var t={};return e.forEach(function(n){t[n.name]=function(t){return h(e,n.name,t)}}),t},d=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:f,outputParser:p,methodSignature:d}},{}],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),a={};return t.forEach(function(s){a[s.name]=function(){var a=Array.prototype.slice.call(arguments),u=o[s.name].apply(null,a),c=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)+u,web3.eth.call(o).