plugeth/dist/ethereum.min.js

1 line
13 KiB
JavaScript
Raw Normal View History

2015-01-31 00:30:19 +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=4,o=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},a=function(t,e){return o(t,function(t){return t.name===e})},u=function(t,e){var n=a(t,e);return-1===n?void console.error("method "+e+" not found in the abi"):t[n]},f=function(t){return t.filter(function(t){return"function"===t.type})},s=function(t){return t.filter(function(t){return"event"===t.type})},c=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},l=function(t){return function(e){return 0===e.indexOf(t)}},p=function(t){return function(e){return t===e}},h=function(t){return"[]"===t.slice(-2)},d=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?d(new BigNumber(t)):(+t).toString(16),c(t,e)},m=function(t){return n.fromAscii(t,r).substr(2)},g=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},v=function(t){return d(new BigNumber(t).times(new BigNumber(2).pow(128)))},b=function(t,e){return h(t)||"string"===t?d(e.length):""},y=function(){return[{type:l("uint"),format:d},{type:l("int"),format:d},{type:l("hash"),format:d},{type:l("string"),format:m},{type:l("real"),format:v},{type:l("ureal"),format:v},{type:p("address"),format:d},{type:p("bool"),format:g}]},_=y(),w=function(t,e,n){var r="",i=u(t,e);return i.inputs.forEach(function(t,e){r+=b(t.type,n[e])}),i.inputs.forEach(function(t,e){for(var o=!1,a=0;a<_.length&&!o;a++)o=_[a].type(i.inputs[e].type,n[e]);o||console.error("input parser does not support type: "+i.inputs[e].type);var u=_[a-1].format,f="";f=h(i.inputs[e].type)?n[e].reduce(function(t,e){return t+u(e)},""):u(n[e]),r+=f}),r},N=function(t){return"1"===new BigNumber(t.substr(0,1),16).toString(2).substr(0,1)},x=function(t){return t=t||"0",N(t)?new BigNumber(t,16).minus(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new BigNumber(t,16)},B=function(t){return t=t||"0",new BigNumber(t,16)},S=function(t){return x(t).dividedBy(new BigNumber(2).pow(128))},A=function(t){return B(t).dividedBy(new BigNumber(2).pow(128))},E=function(t){return"0x"+t},O=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},P=function(t){return n.toAscii(t)},k=function(t){return"0x"+t.slice(t.length-40,t.length)},F=function(t){return h(t)||"string"===t?2*r:0},T=function(){return[{type:l("uint"),format:B},{type:l("int"),format:x},{type:l("hash"),format:E},{type:l("string"),format:P},{type:l("real"),format:S},{type:l("ureal"),format:A},{type:p("address"),format:k},{type:p("bool"),format:O}]},M=T(),D=function(t,e,n){n=n.slice(2);var i=[],o=u(t,e),a=2*r,f=o.outputs.reduce(function(t,e){return t+F(e.type)},0),s=n.slice(0,f);return n=n.slice(f),o.outputs.forEach(function(t,e){for(var r=!1,u=0;u<M.length&&!r;u++)r=M[u].type(o.outputs[e].type);r||console.error("output parser does not support type: "+o.outputs[e].type);var f=M[u-1].format;if(h(o.outputs[e].type)){var c=B(s.slice(0,a));s=s.slice(a);for(var p=[],d=0;c>d;d++)p.push(f(n.slice(0,a))),n=n.slice(a);i.push(p)}else l("string")(o.outputs[e].type)?(s=s.slice(a),i.push(f(n.slice(0,a))),n=n.slice(a)):(i.push(f(n.slice(0,a))),n=n.slice(a))}),i},C=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},q=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-