plugeth/dist/ethereum.min.js

1 line
12 KiB
JavaScript
Raw Normal View History

2015-01-21 19:30:32 +00:00
require=function t(e,n,r){function i(a,u){if(!n[a]){if(!e[a]){var f="function"==typeof require&&require;if(!u&&f)return f(a,!0);if(o)return o(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e){var n=t("./web3");BigNumber.config({ROUNDING_MODE:BigNumber.ROUND_DOWN});var r=32,i=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,e){return i(t,function(t){return t.name===e})},a=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},u=function(t){return function(e){return 0===e.indexOf(t)}},f=function(t){return function(e){return t===e}},s=function(t){return"[]"===t.slice(-2)},c=function(t){var e=2*r;return t instanceof BigNumber||"number"==typeof t?("number"==typeof t&&(t=new BigNumber(t)),t=t.round(),t.lessThan(0)&&(t=new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(t).plus(1)),t=t.toString(16)):t=0===t.indexOf("0x")?t.substr(2):"string"==typeof t?c(new BigNumber(t)):(+t).toString(16),a(t,e)},l=function(t){return n.fromAscii(t,r).substr(2)},h=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},p=function(t){return c(new BigNumber(t).times(new BigNumber(2).pow(128)))},d=function(t,e){return s(t)||u("string")(t)?c(e.length):""},g=function(){return[{type:u("uint"),format:c},{type:u("int"),format:c},{type:u("hash"),format:c},{type:u("string"),format:l},{type:u("real"),format:p},{type:u("ureal"),format:p},{type:f("address"),format:c},{type:f("bool"),format:h}]},m=g(),v=function(t,e,n){var r="",i=o(t,e);if(-1!==i){var a=t[i];return a.inputs.forEach(function(t,e){r+=d(t.type,n[e])}),a.inputs.forEach(function(t,e){for(var i=!1,o=0;o<m.length&&!i;o++)i=m[o].type(a.inputs[e].type,n[e]);i||console.error("input parser does not support type: "+a.inputs[e].type);var u=m[o-1].format,f="";f=s(a.inputs[e].type)?n[e].reduce(function(t,e){return t+u(e)},""):u(n[e]),r+=f}),r}},b=function(t){return"1"===new BigNumber(t.substr(0,1),16).toString(2).substr(0,1)},y=function(t){return b(t)?new BigNumber(t,16).minus(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new BigNumber(t,16)},_=function(t){return new BigNumber(t,16)},w=function(t){return y(t).dividedBy(new BigNumber(2).pow(128))},N=function(t){return _(t).dividedBy(new BigNumber(2).pow(128))},x=function(t){return"0x"+t},B=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},S=function(t){return n.toAscii(t)},A=function(t){return"0x"+t.slice(t.length-40,t.length)},O=function(t){return s(t)||u("string")(t)?2*r:0},P=function(){return[{type:u("uint"),format:_},{type:u("int"),format:y},{type:u("hash"),format:x},{type:u("string"),format:S},{type:u("real"),format:w},{type:u("ureal"),format:N},{type:f("address"),format:A},{type:f("bool"),format:B}]},k=P(),E=function(t,e,n){var i=o(t,e);if(-1!==i){n=n.slice(2);var a=[],f=t[i],c=2*r,l=f.outputs.reduce(function(t,e){return t+O(e.type)},0),h=n.slice(0,l);return n=n.slice(l),f.outputs.forEach(function(t,e){for(var r=!1,i=0;i<k.length&&!r;i++)r=k[i].type(f.outputs[e].type);r||console.error("output parser does not support type: "+f.outputs[e].type);var o=k[i-1].format;if(s(f.outputs[e].type)){var l=_(h.slice(0,c));h=h.slice(c);for(var p=[],d=0;l>d;d++)p.push(o(n.slice(0,c))),n=n.slice(c);a.push(p)}else u("string")(f.outputs[e].type)?(h=h.slice(c),a.push(o(n.slice(0,c))),n=n.slice(c)):(a.push(o(n.slice(0,c))),n=n.slice(c))}),a}},F=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},D=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)):""},I=function(t){var e={};return t.forEach(function(n){var r=F(n.name),i=D(n.name),o=function(){var e=Array.prototype.slice.call(arguments);return v(t,n.name,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e},M=fu