plugeth/dist/ethereum.min.js

1 line
14 KiB
JavaScript
Raw Normal View History

2015-01-31 12:54:39 +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("./formatters");BigNumber.config({ROUNDING_MODE:BigNumber.ROUND_DOWN});var o=32,a=4,u=function(t){return t.filter(function(t){return"function"===t.type})},f=function(t){return t.filter(function(t){return"event"===t.type})},s=function(t){return"[]"===t.slice(-2)},c=function(t,e){return s(t)||"string"===t?i.formatInputInt(e.length):""},l=r.inputTypes(),p=function(t,e){var n="";return t.inputs.forEach(function(t,r){n+=c(t.type,e[r])}),t.inputs.forEach(function(r,i){for(var o=!1,a=0;a<l.length&&!o;a++)o=l[a].type(t.inputs[i].type,e[i]);o||console.error("input parser does not support type: "+t.inputs[i].type);var u=l[a-1].format,f="";f=s(t.inputs[i].type)?e[i].reduce(function(t,e){return t+u(e)},""):u(e[i]),n+=f}),n},h=function(t){return s(t)||"string"===t?2*o:0},m=r.outputTypes(),d=function(t,e){e=e.slice(2);var n=[],a=2*o,u=t.outputs.reduce(function(t,e){return t+h(e.type)},0),f=e.slice(0,u);return e=e.slice(u),t.outputs.forEach(function(o,u){for(var c=!1,l=0;l<m.length&&!c;l++)c=m[l].type(t.outputs[u].type);c||console.error("output parser does not support type: "+t.outputs[u].type);var p=m[l-1].format;if(s(t.outputs[u].type)){var h=i.formatOutputUInt(f.slice(0,a));f=f.slice(a);for(var d=[],g=0;h>g;g++)d.push(p(e.slice(0,a))),e=e.slice(a);n.push(d)}else r.prefixedType("string")(t.outputs[u].type)?(f=f.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},g=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},v=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)):""},y=function(t){var e={};return t.forEach(function(t){var n=g(t.name),r=v(t.name),i=function(){var e=Array.prototype.slice.call(arguments);return p(t,e)};void 0===e[n]&&(e[n]=i),e[n][r]=i}),e},b=function(t){var e={};return t.forEach(function(t){var n=g(t.name),r=v(t.name),i=function(e){return d(t,e)};void 0===e[n]&&(e[n]=i),e[n][r]=i}),e},_=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*a)};e.exports={inputParser:y,outputParser:b,methodSignature:_,methodDisplayName:g,methodTypeName:v,filterFunctions:u,filterEvents:f}},{"./formatters":5,"./types":9,"./utils":10,"./web3":11}],2:[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.prototype.slice.call(arguments),a=r.methodSignature(e.name),u=i(o,a,e),f=u.apply(null,t);return n.eth.watch(f)};a._isEvent=!0,a.address=o,Object.defineProperty(a,"topic",{get:func