plugeth/dist/ethereum.min.js

1 line
14 KiB
JavaScript
Raw Normal View History

2015-01-31 13:05:48 +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"),r=(t("./utils"),t("./types")),i=t("./const"),o=t("./formatters"),a=function(t){return t.filter(function(t){return"function"===t.type})},u=function(t){return t.filter(function(t){return"event"===t.type})},f=function(t){return"[]"===t.slice(-2)},s=function(t,e){return f(t)||"string"===t?o.formatInputInt(e.length):""},c=r.inputTypes(),l=function(t,e){{var n="";2*i.ETH_PADDING}return t.inputs.forEach(function(t,r){n+=s(t.type,e[r])}),t.inputs.forEach(function(r,i){for(var o=!1,a=0;a<c.length&&!o;a++)o=c[a].type(t.inputs[i].type,e[i]);o||console.error("input parser does not support type: "+t.inputs[i].type);var u=c[a-1].format,s="";s=f(t.inputs[i].type)?e[i].reduce(function(t,e){return t+u(e)},""):u(e[i]),n+=s}),n},p=function(t){return f(t)||"string"===t?2*i.ETH_PADDING:0},h=r.outputTypes(),m=function(t,e){e=e.slice(2);var n=[],a=2*i.ETH_PADDING,u=t.outputs.reduce(function(t,e){return t+p(e.type)},0),s=e.slice(0,u);return e=e.slice(u),t.outputs.forEach(function(i,u){for(var c=!1,l=0;l<h.length&&!c;l++)c=h[l].type(t.outputs[u].type);c||console.error("output parser does not support type: "+t.outputs[u].type);var p=h[l-1].format;if(f(t.outputs[u].type)){var m=o.formatOutputUInt(s.slice(0,a));s=s.slice(a);for(var d=[],g=0;m>g;g++)d.push(p(e.slice(0,a))),e=e.slice(a);n.push(d)}else r.prefixedType("string")(t.outputs[u].type)?(s=s.slice(a),n.push(p(e.slice(0,a))),e=e.slice(a)):(n.push(p(e.slice(0,a))),e=e.slice(a))}),n},d=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},g=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)):""},v=function(t){var e={};return t.forEach(function(t){var n=d(t.name),r=g(t.name),i=function(){var e=Array.prototype.slice.call(arguments);return l(t,e)};void 0===e[n]&&(e[n]=i),e[n][r]=i}),e},y=function(t){var e={};return t.forEach(function(t){var n=d(t.name),r=g(t.name),i=function(e){return m(t,e)};void 0===e[n]&&(e[n]=i),e[n][r]=i}),e},b=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*i.ETH_METHOD_SIGNATURE_LENGTH)};e.exports={inputParser:v,outputParser:y,methodSignature:b,methodDisplayName:d,methodTypeName:g,filterFunctions:a,filterEvents:u}},{"./const":2,"./formatters":6,"./types":10,"./utils":11,"./web3":12}],2:[function(t,e){e.exports={ETH_PADDING:32,ETH_METHOD_SIGNATURE_LENGTH:4,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:BigNumber.ROUND_DOWN}}},{}],3:[function(t,e){var n=t("./web3"),r=t("./abi"),i=t("./event"),o=function(t){t.call=function(e){return t._isTransact=!1,t._options=e,t},t.transact=function(e){return t._isTransact=!0,t._options=e,t},t._options={},["gas","gasPrice","value","from"].forEach(function(e){t[e]=function(n){return t._options[e]=n,t}})},a=function(t,e,i){var o=r.inputParser(e),a=r.outputParser(e);r.filterFunctions(e).forEach(function(u){var f=r.methodDisplayName(u.name),s=r.methodTypeName(u.name),c=function(){var c=Array.prototype.slice.call(arguments),l=r.methodSignature(u.name),p=o[f][s].apply(null,c),h=t._options||{};h.to=i,h.data=l+p;var m=t._isTransact===!0||t._isTransact!==!1&&!u.constant,d=h.collapse!==!1;if(t._options={},t._isTransact=null,m)return n._currentContractAbi=e,n._currentContractAddress=i,n._currentContractMethodName=u.name,n._currentContractMethodParams=c,void n.eth.transact(h);var g=n.eth.call(h),v=a[f][s](g);return d&&(1===v.length?v=v[0]:0===v.length&&(v=null)),v};void 0===t[f]&&(t[f]=c),t[f][s]=c})},u=function(t,e,n){t.address=n,Object.defineProperty(t,"topic",{get:function(){return r.filterEvents(e).map(function(t){return r.methodSignature(t.name)})}})},f=function(t,e,o){r.filterEvents(e).forEach(function(e){var a=function(){var t=Array.protot