Skip to content

Commit

Permalink
Use ripple-lib-value package and update ripple-lib-transactionparser …
Browse files Browse the repository at this point in the history
…dependency
  • Loading branch information
Chris Clark committed Sep 24, 2015
1 parent 135da61 commit c79b12b
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 246 deletions.
14 changes: 6 additions & 8 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -28,7 +28,8 @@
"lru-cache": "~2.5.0",
"ripple-address-codec": "^1.6.0",
"ripple-keypairs": "^0.9.0",
"ripple-lib-transactionparser": "^0.5.0",
"ripple-lib-transactionparser": "^0.5.1",
"ripple-lib-value": "0.1.0",
"sjcl-codec": "0.1.0",
"ws": "~0.7.1"
},
Expand Down
1 change: 1 addition & 0 deletions src/api/common/schemas/order-change.json
Expand Up @@ -9,6 +9,7 @@
},
"quantity": {"$ref": "balance"},
"totalPrice": {"$ref": "balance"},
"makerExchangeRate": {"$ref": "value"},
"sequence": {"$ref": "sequence"},
"status": {"enum": ["created", "open", "closed", "canceled"]}
},
Expand Down
13 changes: 7 additions & 6 deletions src/core/amount.js
Expand Up @@ -8,15 +8,15 @@ const extend = require('extend');
const utils = require('./utils');
const UInt160 = require('./uint160').UInt160;
const Currency = require('./currency').Currency;
const Value = require('./value').Value;
const IOUValue = require('./iouvalue').IOUValue;
const XRPValue = require('./xrpvalue').XRPValue;
const {XRPValue, IOUValue} = require('ripple-lib-value');

type Value = XRPValue | IOUValue;

function Amount(value = new XRPValue(NaN)) {
// Json format:
// integer : XRP
// { 'value' : ..., 'currency' : ..., 'issuer' : ...}
assert(value instanceof Value);
assert(value instanceof XRPValue || value instanceof IOUValue);

this._value = value;
this._is_native = true; // Default to XRP. Only valid if value is not NaN.
Expand Down Expand Up @@ -625,7 +625,8 @@ function(quality, counterCurrency, counterIssuer, opts) {
}
if (this._is_native) {
this._set_value(
new XRPValue(nativeAdjusted.round(6, Value.getBNRoundDown()).toString()));
new XRPValue(nativeAdjusted.round(6, XRPValue.getBNRoundDown())
.toString()));
} else {
this._set_value(nativeAdjusted);
}
Expand Down Expand Up @@ -723,7 +724,7 @@ Amount.prototype.parse_native = function(j) {
// Requires _currency to be set!
Amount.prototype.parse_value = function(j) {
this._is_native = false;
const newValue = new IOUValue(j, Value.getBNRoundDown());
const newValue = new IOUValue(j, IOUValue.getBNRoundDown());
this._set_value(newValue);
return this;
};
Expand Down
1 change: 0 additions & 1 deletion src/core/index.js
Expand Up @@ -20,7 +20,6 @@ exports.TransactionQueue = require('./transactionqueue').TransactionQueue;
exports.convertBase = require('./baseconverter');

exports._test = {
IOUValue: require('./iouvalue').IOUValue,
Log: require('./log'),
PathFind: require('./pathfind').PathFind,
TransactionManager: require('./transactionmanager').TransactionManager,
Expand Down
56 changes: 0 additions & 56 deletions src/core/iouvalue.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/core/orderbook.js
Expand Up @@ -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('ripple-lib-value');

function _sortOffers(a, b) {
const aQuality = OrderBookUtils.getOfferQuality(a, this._currencyGets);
Expand Down
2 changes: 1 addition & 1 deletion src/core/orderbookutils.js
Expand Up @@ -7,7 +7,7 @@ const Types = require('./serializedtypes');
const Amount = require('./amount').Amount;
const Currency = require('./currency').Currency;
const UInt160 = require('./uint160').UInt160;
const IOUValue = require('./iouvalue').IOUValue;
const {IOUValue} = require('ripple-lib-value');
const OrderBookUtils = {};

function assertValidNumber(number, message) {
Expand Down
109 changes: 0 additions & 109 deletions src/core/value.js

This file was deleted.

59 changes: 0 additions & 59 deletions src/core/xrpvalue.js

This file was deleted.

Expand Up @@ -31,6 +31,7 @@
"currency": "XRP",
"value": "0"
},
"makerExchangeRate": "1185000",
"sequence": 465,
"status": "canceled"
}
Expand All @@ -39,4 +40,4 @@
"ledgerVersion": 14661789,
"indexInLedger": 4
}
}
}
1 change: 1 addition & 0 deletions test/fixtures/api/responses/get-transaction-order.json
Expand Up @@ -40,6 +40,7 @@
"currency": "XRP",
"value": "0.0002"
},
"makerExchangeRate": "1185000",
"sequence": 465,
"status": "created"
}
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/api/responses/get-transaction-payment.json
Expand Up @@ -75,6 +75,7 @@
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"value": "-0.001002"
},
"makerExchangeRate": "1099",
"sequence": 58,
"status": "open"
}
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/api/responses/get-transactions.json
Expand Up @@ -81,6 +81,7 @@
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"value": "-0.001002"
},
"makerExchangeRate": "1099",
"sequence": 58,
"status": "open"
}
Expand Down Expand Up @@ -172,6 +173,7 @@
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"value": "-0.001002"
},
"makerExchangeRate": "1099",
"sequence": 58,
"status": "open"
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/orderbook.js
Expand Up @@ -7,7 +7,7 @@ const addresses = require('./addresses');
const Meta = require('ripple-lib').Meta;
const SerializedObject = require('ripple-lib').SerializedObject;
const Types = require('ripple-lib').types;
const IOUValue = require('ripple-lib')._test.IOUValue;
const IOUValue = require('ripple-lib-value').IOUValue;

module.exports.FIAT_BALANCE = '10';
module.exports.NATIVE_BALANCE = '55';
Expand Down
2 changes: 1 addition & 1 deletion test/orderbook-autobridge-test.js
Expand Up @@ -8,7 +8,7 @@ const Remote = require('ripple-lib').Remote;
const Currency = require('ripple-lib').Currency;
const addresses = require('./fixtures/addresses');
const fixtures = require('./fixtures/orderbook');
const IOUValue = require('ripple-lib')._test.IOUValue;
const IOUValue = require('ripple-lib-value').IOUValue;

describe('OrderBook Autobridging', function() {
this.timeout(0);
Expand Down

0 comments on commit c79b12b

Please sign in to comment.