constants separated to const.js file

This commit is contained in:
Marek Kotewicz
2015-01-31 14:05:48 +01:00
parent 4bdf52fc1e
commit a8a2e3231c
6 changed files with 104 additions and 58 deletions

View File

@@ -25,10 +25,7 @@ if (process.env.NODE_ENV !== 'build') {
}
var utils = require('./utils');
BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_DOWN });
var ETH_PADDING = 32;
var c = require('./const');
/// @param string string to be padded
/// @param number of characters that result string should have
@@ -43,10 +40,11 @@ var padLeft = function (string, chars, sign) {
/// If the value is floating point, round it down
/// @returns right-aligned byte representation of int
var formatInputInt = function (value) {
var padding = ETH_PADDING * 2;
var padding = c.ETH_PADDING * 2;
if (value instanceof BigNumber || typeof value === 'number') {
if (typeof value === 'number')
value = new BigNumber(value);
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
value = value.round();
if (value.lessThan(0))
@@ -65,7 +63,7 @@ var formatInputInt = function (value) {
/// Formats input value to byte representation of string
/// @returns left-algined byte representation of string
var formatInputString = function (value) {
return utils.fromAscii(value, ETH_PADDING).substr(2);
return utils.fromAscii(value, c.ETH_PADDING).substr(2);
};
/// Formats input value to byte representation of bool