diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-31 21:05:48 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-31 21:05:48 +0800 |
commit | a8a2e3231c2ced50989dc5d23659f7482a667f69 (patch) | |
tree | 8529faaa567708c9e4955f613317911e6e8aad0f /lib/abi.js | |
parent | 4bdf52fc1e5030d53a8b7337051e12ebd0509009 (diff) | |
download | dexon-a8a2e3231c2ced50989dc5d23659f7482a667f69.tar dexon-a8a2e3231c2ced50989dc5d23659f7482a667f69.tar.gz dexon-a8a2e3231c2ced50989dc5d23659f7482a667f69.tar.bz2 dexon-a8a2e3231c2ced50989dc5d23659f7482a667f69.tar.lz dexon-a8a2e3231c2ced50989dc5d23659f7482a667f69.tar.xz dexon-a8a2e3231c2ced50989dc5d23659f7482a667f69.tar.zst dexon-a8a2e3231c2ced50989dc5d23659f7482a667f69.zip |
constants separated to const.js file
Diffstat (limited to 'lib/abi.js')
-rw-r--r-- | lib/abi.js | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/lib/abi.js b/lib/abi.js index 1fd3a58fc..01d2debb7 100644 --- a/lib/abi.js +++ b/lib/abi.js @@ -21,22 +21,12 @@ * @date 2014 */ -if (process.env.NODE_ENV !== 'build') { - var BigNumber = require('bignumber.js'); // jshint ignore:line -} - var web3 = require('./web3'); var utils = require('./utils'); var types = require('./types'); +var c = require('./const'); var f = require('./formatters'); -BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_DOWN }); - -var ETH_PADDING = 32; - -/// method signature length in bytes -var ETH_METHOD_SIGNATURE_LENGTH = 4; - /// Filters all function from input abi /// @returns abi array with filtered objects of type 'function' var filterFunctions = function (json) { @@ -74,7 +64,7 @@ var inputTypes = types.inputTypes(); /// @returns bytes representation of input params var toAbiInput = function (method, params) { var bytes = ""; - var padding = ETH_PADDING * 2; + var padding = c.ETH_PADDING * 2; /// first we iterate in search for dynamic method.inputs.forEach(function (input, index) { @@ -107,7 +97,7 @@ var toAbiInput = function (method, params) { var dynamicBytesLength = function (type) { if (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length. - return ETH_PADDING * 2; + return c.ETH_PADDING * 2; return 0; }; @@ -121,7 +111,7 @@ var fromAbiOutput = function (method, output) { output = output.slice(2); var result = []; - var padding = ETH_PADDING * 2; + var padding = c.ETH_PADDING * 2; var dynamicPartLength = method.outputs.reduce(function (acc, curr) { return acc + dynamicBytesLength(curr.type); @@ -227,7 +217,7 @@ var outputParser = function (json) { /// @param method name for which we want to get method signature /// @returns (promise) contract method signature for method with given name var methodSignature = function (name) { - return web3.sha3(web3.fromAscii(name)).slice(0, 2 + ETH_METHOD_SIGNATURE_LENGTH * 2); + return web3.sha3(web3.fromAscii(name)).slice(0, 2 + c.ETH_METHOD_SIGNATURE_LENGTH * 2); }; module.exports = { |