plugeth/dist/ethereum.min.js

1 line
12 KiB
JavaScript
Raw Normal View History

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