Rename IOUValue.js and XRPValue.js to lowercase and other fixes

This commit is contained in:
Madeline Shortt
2015-07-08 10:23:13 -07:00
parent 6bffe06c3b
commit 2ac4549712
5 changed files with 14 additions and 10 deletions

View File

@@ -10,8 +10,8 @@ const UInt160 = require('./uint160').UInt160;
const Seed = require('./seed').Seed;
const Currency = require('./currency').Currency;
const Value = require('./value').Value;
const IOUValue = require('./IOUValue').IOUValue;
const XRPValue = require('./XRPValue').XRPValue;
const IOUValue = require('./iouvalue').IOUValue;
const XRPValue = require('./xrpvalue').XRPValue;
function Amount(value = new XRPValue(NaN)) {
// Json format:
@@ -607,7 +607,7 @@ function(quality, counterCurrency, counterIssuer, opts) {
}
if (this._is_native) {
this._set_value(
new XRPValue(nativeAdjusted.round(6, Value.getBNRoundDown())));
new XRPValue(nativeAdjusted.round(6, Value.getBNRoundDown()).toString()));
} else {
this._set_value(nativeAdjusted);
}

View File

@@ -3,12 +3,13 @@
'use strict';
const Value = require('./value').Value;
const XRPValue = require('./XRPValue').XRPValue;
const XRPValue = require('./xrpvalue').XRPValue;
const GlobalBigNumber = require('bignumber.js');
const BigNumber = GlobalBigNumber.another({
ROUNDING_MODE: GlobalBigNumber.ROUND_HALF_UP,
DECIMAL_PLACES: 40
});
const rippleUnits = new BigNumber(1e6);
class IOUValue extends Value {
@@ -22,7 +23,7 @@ class IOUValue extends Value {
if (multiplicand instanceof XRPValue) {
return super.multiply(
new IOUValue(
multiplicand._value.times(multiplicand.rippleUnits)));
multiplicand._value.times(rippleUnits)));
}
return super.multiply(multiplicand);
}
@@ -30,7 +31,7 @@ class IOUValue extends Value {
divide(divisor: Value) {
if (divisor instanceof XRPValue) {
return super.divide(
new IOUValue(divisor._value.times(divisor.rippleUnits)));
new IOUValue(divisor._value.times(rippleUnits)));
}
return super.divide(divisor);
}

View File

@@ -22,7 +22,7 @@ const Currency = require('./currency').Currency;
const AutobridgeCalculator = require('./autobridgecalculator');
const OrderBookUtils = require('./orderbookutils');
const log = require('./log').internal.sub('orderbook');
const IOUValue = require('./IOUValue').IOUValue;
const IOUValue = require('./iouvalue').IOUValue;
function assertValidNumber(number, message) {
assert(!_.isNull(number) && !isNaN(number), message);

View File

@@ -6,6 +6,9 @@ function getMantissa16FromString(decimalString) {
let mantissa = decimalString.replace(/\./, '') // remove decimal point
.replace(/e.*/, '') // remove scientific notation
.replace(/^0*/, ''); // remove leading zeroes
if (mantissa.length > 16) {
return mantissa.substring(0, 16);
}
while (mantissa.length < 16) {
mantissa += '0'; // add trailing zeroes until length is 16
}

View File

@@ -9,12 +9,12 @@ const BigNumber = GlobalBigNumber.another({
});
const Value = require('./value').Value;
const rippleUnits = new BigNumber(1e6);
class XRPValue extends Value {
constructor(value: string | BigNumber) {
super(value);
this.rippleUnits = new BigNumber(1e6);
if (this._value.dp() > 6) {
throw new Error(
'Value has more than 6 digits of precision past the decimal point, '
@@ -26,7 +26,7 @@ class XRPValue extends Value {
multiply(multiplicand: Value) {
if (multiplicand instanceof XRPValue) {
return super.multiply(
new XRPValue(multiplicand._value.times(multiplicand.rippleUnits)));
new XRPValue(multiplicand._value.times(rippleUnits)));
}
return super.multiply(multiplicand);
}
@@ -34,7 +34,7 @@ class XRPValue extends Value {
divide(divisor: Value) {
if (divisor instanceof XRPValue) {
return super.divide(
new XRPValue(divisor._value.times(divisor.rippleUnits)));
new XRPValue(divisor._value.times(rippleUnits)));
}
return super.divide(divisor);
}