bsc/dist/ethereum.min.js

1 line
15 KiB
JavaScript
Raw Normal View History

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