mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-05 05:15:48 +00:00
Compare commits
35 Commits
0.10.0-rc2
...
0.10.1-rc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f212e4dd1 | ||
|
|
c263654c88 | ||
|
|
874e3f24a6 | ||
|
|
b14343f3cf | ||
|
|
732b50dea7 | ||
|
|
be3bbe9b61 | ||
|
|
51211bbba0 | ||
|
|
5d1ff1c912 | ||
|
|
ea1be4fc50 | ||
|
|
7cc05f0d92 | ||
|
|
54606f3c21 | ||
|
|
a5d1705930 | ||
|
|
bfc0fb6c88 | ||
|
|
d1d4452217 | ||
|
|
2166a434a3 | ||
|
|
1053fa18e1 | ||
|
|
fa147d467e | ||
|
|
3f61598d6c | ||
|
|
9bf3724ce6 | ||
|
|
c2f27a4deb | ||
|
|
b6b99dde02 | ||
|
|
1fd0f4a8fe | ||
|
|
67d39737a4 | ||
|
|
aef4fe29a3 | ||
|
|
34c0677c45 | ||
|
|
3cb4a64b47 | ||
|
|
0db0375a5e | ||
|
|
47e6bdc644 | ||
|
|
66c2e27711 | ||
|
|
72387873b4 | ||
|
|
59017bc0bd | ||
|
|
2dde114d3d | ||
|
|
9e89904f03 | ||
|
|
56d0aca254 | ||
|
|
239710cebf |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,6 +25,7 @@ Release/*.*
|
||||
|
||||
# Ignore locally installed node_modules
|
||||
node_modules
|
||||
!test/node_modules
|
||||
|
||||
# Ignore tmp directory.
|
||||
tmp
|
||||
|
||||
38
Gulpfile.js
38
Gulpfile.js
@@ -151,26 +151,30 @@ gulp.task('bower', ['bower-build', 'bower-build-min', 'bower-build-debug', 'bowe
|
||||
|
||||
gulp.task('lint', function() {
|
||||
gulp.src('src/js/ripple/*.js')
|
||||
.pipe(jshint())
|
||||
.pipe(jshint('./jshintrc'))
|
||||
.pipe(map(function(file, callback) {
|
||||
if (!file.jshint.success) {
|
||||
console.log('\nIn', file.path);
|
||||
|
||||
file.jshint.results.forEach(function(err) {
|
||||
if (err && err.error) {
|
||||
var col1 = err.error.line + ':' + err.error.character;
|
||||
var col2 = '[' + err.error.reason + ']';
|
||||
var col3 = '(' + err.error.code + ')';
|
||||
|
||||
while (col1.length < 8) {
|
||||
col1 += ' ';
|
||||
}
|
||||
|
||||
console.log(' ' + [ col1, col2, col3 ].join(' '));
|
||||
}
|
||||
});
|
||||
if (file.jshint.success) {
|
||||
return callback(null, file);
|
||||
}
|
||||
|
||||
console.log('\n>' + file.path.substring(file.base.length) + '\n');
|
||||
|
||||
file.jshint.results.forEach(function(err) {
|
||||
if (err && err.error) {
|
||||
var col1 = err.error.line + ':' + err.error.character;
|
||||
var col2 = err.error.reason;
|
||||
var col3 = '(' + err.error.code + ')';
|
||||
|
||||
while (col1.length < 8) {
|
||||
col1 = ' ' + col1;
|
||||
}
|
||||
|
||||
col1 += ' |';
|
||||
|
||||
console.log([ col1, col2, col3 ].join(' '));
|
||||
}
|
||||
});
|
||||
|
||||
callback(null, file);
|
||||
}));
|
||||
});
|
||||
|
||||
15
HISTORY.md
15
HISTORY.md
@@ -1,3 +1,14 @@
|
||||
##0.10.1
|
||||
|
||||
+ [Track the funded status of an order based on cumulative account orders](https://github.com/ripple/ripple-lib/commit/67d39737a4d5e0fcd9d9b47b9083ee00e5a9e652) and [67d3973](https://github.com/ripple/ripple-lib/commit/b6b99dde022e1e14c4797e454b1d7fca50e49482)
|
||||
|
||||
+ [Add support for `ledger` option in requestBookOffers](https://github.com/ripple/ripple-lib/commit/34c0677c453c409ef0a5b351959abdc176d3bacb)
|
||||
|
||||
+ [Add support for `limit` option in requestBookOffers](https://github.com/ripple/ripple-lib/commit/d1d4452217c878d0b377d24830b4cd8b3162f6e0)
|
||||
|
||||
+ [Fix metadata account check](https://github.com/ripple/ripple-lib/commit/3f61598d6c87e3cc877af60e2d515f9eff73dfe1)
|
||||
|
||||
|
||||
##0.10.0
|
||||
|
||||
+ [Transaction changes](https://github.com/ripple/ripple-lib/pull/221)
|
||||
@@ -21,7 +32,9 @@ are locally determined to have expired: `tejMaxLedger`.
|
||||
+ [Update jscl library](https://github.com/ripple/ripple-lib/commit/3204998fcb6f31d6c90532a737a4adb8a1e420f6)
|
||||
- Improved entropy by taking advantage of platform crypto
|
||||
- Use jscl's k256 curve instead of altering the c256 curve with k256 configuration
|
||||
- **deprecated:** the c256 curve is linked to the k256 curve to provide backwards compatibility, this link will be removed in the future
|
||||
- **deprecated:** the c256 curve is linked to the k256 curve to provide backwards compatibility, this link will be removed in the future
|
||||
|
||||
+ [Fix empty queue check on reconnect](https://github.com/ripple/ripple-lib/commit/3c21994adcf72d1fbd87d453ceb917f9ad6df4ec)
|
||||
|
||||
##0.9.4
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ A JavaScript API for interacting with Ripple in Node.js and the browser
|
||||
###Features
|
||||
|
||||
+ Connect to a rippled server in JavaScript (Node.js or browser)
|
||||
+ Issue [rippled API](https://ripple.com/wiki/JSON_Messages) requests
|
||||
+ Issue [rippled API](https://ripple.com/build/rippled-apis/) requests
|
||||
+ Listen to events on the Ripple network (transaction, ledger, etc.)
|
||||
+ Sign and submit transactions to the Ripple network
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ This file provides step-by-step walkthroughs for some of the most common usages
|
||||
]
|
||||
}
|
||||
|
||||
var remote = new Remote({options});
|
||||
var remote = new Remote(options);
|
||||
|
||||
remote.connect(function(err, res) {
|
||||
/* remote connected, use some remote functions here */
|
||||
|
||||
22
jshintrc
Normal file
22
jshintrc
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"browser": true,
|
||||
"jquery": true,
|
||||
"node": true,
|
||||
"camelcase": false,
|
||||
"eqeqeq": true,
|
||||
"eqnull": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"quotmark": "single",
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"curly": true,
|
||||
"freeze": true,
|
||||
"nonbsp": true,
|
||||
"boss": true,
|
||||
"laxbreak": true,
|
||||
"maxparams": 4,
|
||||
"maxdepth": 3,
|
||||
"esnext": true,
|
||||
"-W004": true
|
||||
}
|
||||
33
npm-shrinkwrap.json
generated
33
npm-shrinkwrap.json
generated
@@ -1,18 +1,21 @@
|
||||
{
|
||||
"name": "ripple-lib",
|
||||
"version": "0.10.0-rc2",
|
||||
"version": "0.10.1-rc1",
|
||||
"dependencies": {
|
||||
"async": {
|
||||
"version": "0.8.0",
|
||||
"from": "async@>=0.8.0 <0.9.0"
|
||||
"from": "async@>=0.8.0 <0.9.0",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-0.8.0.tgz"
|
||||
},
|
||||
"extend": {
|
||||
"version": "1.2.1",
|
||||
"from": "extend@>=1.2.1 <1.3.0"
|
||||
"from": "extend@>=1.2.1 <1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz"
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "2.5.0",
|
||||
"from": "lru-cache@>=2.5.0 <2.6.0"
|
||||
"from": "lru-cache@>=2.5.0 <2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz"
|
||||
},
|
||||
"ripple-wallet-generator": {
|
||||
"version": "1.0.1",
|
||||
@@ -22,6 +25,7 @@
|
||||
"superagent": {
|
||||
"version": "0.18.2",
|
||||
"from": "superagent@>=0.18.0 <0.19.0",
|
||||
"resolved": "https://registry.npmjs.org/superagent/-/superagent-0.18.2.tgz",
|
||||
"dependencies": {
|
||||
"qs": {
|
||||
"version": "0.6.6",
|
||||
@@ -56,6 +60,7 @@
|
||||
"debug": {
|
||||
"version": "1.0.4",
|
||||
"from": "debug@>=1.0.1 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-1.0.4.tgz",
|
||||
"dependencies": {
|
||||
"ms": {
|
||||
"version": "0.6.2",
|
||||
@@ -75,8 +80,9 @@
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-0.1.3.tgz",
|
||||
"dependencies": {
|
||||
"combined-stream": {
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.7",
|
||||
"from": "combined-stream@>=0.0.4 <0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz",
|
||||
"dependencies": {
|
||||
"delayed-stream": {
|
||||
"version": "0.0.5",
|
||||
@@ -87,17 +93,20 @@
|
||||
},
|
||||
"async": {
|
||||
"version": "0.9.0",
|
||||
"from": "async@>=0.9.0 <0.10.0"
|
||||
"from": "async@>=0.9.0 <0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-0.9.0.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "1.0.27-1",
|
||||
"from": "readable-stream@1.0.27-1",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.27-1.tgz",
|
||||
"dependencies": {
|
||||
"core-util-is": {
|
||||
"version": "1.0.1",
|
||||
"from": "core-util-is@>=1.0.0 <1.1.0"
|
||||
"from": "core-util-is@>=1.0.0 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz"
|
||||
},
|
||||
"isarray": {
|
||||
"version": "0.0.1",
|
||||
@@ -106,11 +115,13 @@
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "0.10.31",
|
||||
"from": "string_decoder@>=0.10.0 <0.11.0"
|
||||
"from": "string_decoder@>=0.10.0 <0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz"
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.1",
|
||||
"from": "inherits@>=2.0.1 <2.1.0"
|
||||
"from": "inherits@>=2.0.1 <2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,10 +130,12 @@
|
||||
"ws": {
|
||||
"version": "0.4.32",
|
||||
"from": "ws@>=0.4.31 <0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-0.4.32.tgz",
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.1.0",
|
||||
"from": "commander@>=2.1.0 <2.2.0"
|
||||
"from": "commander@>=2.1.0 <2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.1.0.tgz"
|
||||
},
|
||||
"nan": {
|
||||
"version": "1.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ripple-lib",
|
||||
"version": "0.10.0-rc2",
|
||||
"version": "0.10.1-rc1",
|
||||
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
|
||||
"files": [
|
||||
"src/js/*",
|
||||
|
||||
@@ -5,6 +5,7 @@ exports.Account = require('./account').Account;
|
||||
exports.Transaction = require('./transaction').Transaction;
|
||||
exports.Currency = require('./currency').Currency;
|
||||
exports.Base = require('./base').Base;
|
||||
exports.UInt128 = require('./uint128').UInt128;
|
||||
exports.UInt160 = require('./uint160').UInt160;
|
||||
exports.UInt256 = require('./uint256').UInt256;
|
||||
exports.Seed = require('./seed').Seed;
|
||||
@@ -19,6 +20,10 @@ exports.binformat = require('./binformat');
|
||||
exports.utils = require('./utils');
|
||||
exports.Server = require('./server').Server;
|
||||
exports.Wallet = require('./wallet');
|
||||
exports.Ledger = require('./ledger').Ledger;
|
||||
exports.TransactionQueue = require('./transactionqueue').TransactionQueue;
|
||||
exports.VaultClient = require('./vaultclient').VaultClient;
|
||||
exports.Blob = require('./blob').Blob;
|
||||
|
||||
// Important: We do not guarantee any specific version of SJCL or for any
|
||||
// specific features to be included. The version and configuration may change at
|
||||
@@ -28,6 +33,8 @@ exports.Wallet = require('./wallet');
|
||||
// the official client, it makes sense to expose the SJCL instance so we don't
|
||||
// have to include it twice.
|
||||
exports.sjcl = require('./utils').sjcl;
|
||||
exports.jsbn = require('./utils').jsbn;
|
||||
exports.types = require('./serializedtypes');
|
||||
|
||||
exports.config = require('./config');
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var extend = require('extend');
|
||||
var utils = require('./utils');
|
||||
var utils = require('./utils');
|
||||
var UInt160 = require('./uint160').UInt160;
|
||||
var Amount = require('./amount').Amount;
|
||||
|
||||
@@ -26,28 +26,37 @@ function Meta(data) {
|
||||
data.AffectedNodes.forEach(this.addNode, this);
|
||||
};
|
||||
|
||||
Meta.nodeTypes = [
|
||||
Meta.NODE_TYPES = [
|
||||
'CreatedNode',
|
||||
'ModifiedNode',
|
||||
'DeletedNode'
|
||||
];
|
||||
|
||||
Meta.amountFieldsAffectingIssuer = [
|
||||
Meta.AMOUNT_FIELDS_AFFECTING_ISSUER = [
|
||||
'LowLimit',
|
||||
'HighLimit',
|
||||
'TakerPays',
|
||||
'TakerGets'
|
||||
];
|
||||
|
||||
Meta.ACCOUNT_FIELDS = [
|
||||
'Account',
|
||||
'Owner',
|
||||
'Destination',
|
||||
'Issuer',
|
||||
'Target'
|
||||
];
|
||||
|
||||
/**
|
||||
* @param {Object} node
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Meta.prototype.getNodeType = function(node) {
|
||||
var result = null;
|
||||
|
||||
for (var i=0; i<Meta.nodeTypes.length; i++) {
|
||||
var type = Meta.nodeTypes[i];
|
||||
for (var i=0; i<Meta.NODE_TYPES.length; i++) {
|
||||
var type = Meta.NODE_TYPES[i];
|
||||
if (node.hasOwnProperty(type)) {
|
||||
result = type;
|
||||
break;
|
||||
@@ -57,6 +66,15 @@ Meta.prototype.getNodeType = function(node) {
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {String} field
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Meta.prototype.isAccountField = function(field) {
|
||||
return Meta.ACCOUNT_FIELDS.indexOf(field) !== -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add node to metadata
|
||||
*
|
||||
@@ -72,7 +90,6 @@ Meta.prototype.addNode = function(node) {
|
||||
|
||||
if ((result.nodeType = this.getNodeType(node))) {
|
||||
node = node[result.nodeType];
|
||||
|
||||
result.diffType = result.nodeType;
|
||||
result.entryType = node.LedgerEntryType;
|
||||
result.ledgerIndex = node.LedgerIndex;
|
||||
@@ -114,56 +131,6 @@ Meta.prototype.getNodes = function(options) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Execute a function on each affected node.
|
||||
*
|
||||
* The callback is passed two parameters. The first is a node object which looks
|
||||
* like this:
|
||||
*
|
||||
* {
|
||||
* // Type of diff, e.g. CreatedNode, ModifiedNode
|
||||
* nodeType: 'CreatedNode'
|
||||
*
|
||||
* // Type of node affected, e.g. RippleState, AccountRoot
|
||||
* entryType: 'RippleState',
|
||||
*
|
||||
* // Index of the ledger this change occurred in
|
||||
* ledgerIndex: '01AB01AB...',
|
||||
*
|
||||
* // Contains all fields with later versions taking precedence
|
||||
* //
|
||||
* // This is a shorthand for doing things like checking which account
|
||||
* // this affected without having to check the nodeType.
|
||||
* fields: {...},
|
||||
*
|
||||
* // Old fields (before the change)
|
||||
* fieldsPrev: {...},
|
||||
*
|
||||
* // New fields (that have been added)
|
||||
* fieldsNew: {...},
|
||||
*
|
||||
* // Changed fields
|
||||
* fieldsFinal: {...}
|
||||
* }
|
||||
*
|
||||
* The second parameter to the callback is the index of the node in the metadata
|
||||
* (first entry is index 0).
|
||||
*/
|
||||
|
||||
[
|
||||
'forEach',
|
||||
'map',
|
||||
'filter',
|
||||
'every',
|
||||
'some',
|
||||
'reduce'
|
||||
].forEach(function(fn) {
|
||||
Meta.prototype[fn] = function() {
|
||||
return Array.prototype[fn].apply(this.nodes, arguments);
|
||||
};
|
||||
});
|
||||
|
||||
Meta.prototype.each = Meta.prototype.forEach;
|
||||
|
||||
Meta.prototype.getAffectedAccounts = function(from) {
|
||||
if (this._affectedAccounts) {
|
||||
@@ -176,12 +143,16 @@ Meta.prototype.getAffectedAccounts = function(from) {
|
||||
// TransactionMetaSet::getAffectedAccounts
|
||||
for (var i=0; i<this.nodes.length; i++) {
|
||||
var node = this.nodes[i];
|
||||
var fields = (node.nodeType === 'CreatedNode') ? node.fieldsNew : node.fieldsFinal;
|
||||
var fields = (node.nodeType === 'CreatedNode')
|
||||
? node.fieldsNew
|
||||
: node.fieldsFinal;
|
||||
|
||||
for (var fieldName in fields) {
|
||||
var field = fields[fieldName];
|
||||
if (typeof field === 'string' && UInt160.is_valid(field)) {
|
||||
|
||||
if (this.isAccountField(fieldName) && UInt160.is_valid(field)) {
|
||||
accounts.push(field);
|
||||
} else if (~Meta.amountFieldsAffectingIssuer.indexOf(fieldName)) {
|
||||
} else if (~Meta.AMOUNT_FIELDS_AFFECTING_ISSUER.indexOf(fieldName)) {
|
||||
var amount = Amount.from_json(field);
|
||||
var issuer = amount.issuer();
|
||||
if (issuer.is_valid() && !issuer.is_zero()) {
|
||||
|
||||
@@ -43,8 +43,9 @@ function OrderBook(remote, getsC, getsI, paysC, paysI, key) {
|
||||
this._shouldSubscribe = true;
|
||||
this._listeners = 0;
|
||||
this._offers = [ ];
|
||||
this._ownerFunds = { };
|
||||
this._offerCounts = { };
|
||||
this._ownerFunds = { };
|
||||
this._ownerOffers = { };
|
||||
|
||||
// We consider ourselves synchronized if we have a current
|
||||
// copy of the offers, we are online and subscribed to updates.
|
||||
@@ -180,6 +181,7 @@ OrderBook.prototype.unsubscribe = function() {
|
||||
|
||||
OrderBook.prototype.resetCache = function() {
|
||||
this._ownerFunds = { };
|
||||
this._ownerOffers = { };
|
||||
this._offerCounts = { };
|
||||
this._synchronized = false;
|
||||
};
|
||||
@@ -232,6 +234,8 @@ OrderBook.prototype.removeCachedFunds = function(account) {
|
||||
|
||||
/**
|
||||
* Get offer count for offer owner
|
||||
*
|
||||
* @param {String} account address
|
||||
*/
|
||||
|
||||
OrderBook.prototype.getOfferCount = function(account) {
|
||||
@@ -241,6 +245,8 @@ OrderBook.prototype.getOfferCount = function(account) {
|
||||
|
||||
/**
|
||||
* Increment offer count for offer owner
|
||||
*
|
||||
* @param {String} account address
|
||||
*/
|
||||
|
||||
OrderBook.prototype.incrementOfferCount = function(account) {
|
||||
@@ -252,6 +258,8 @@ OrderBook.prototype.incrementOfferCount = function(account) {
|
||||
|
||||
/**
|
||||
* Decrement offer count for offer owner
|
||||
*
|
||||
* @param {String} account address
|
||||
*/
|
||||
|
||||
OrderBook.prototype.decrementOfferCount = function(account) {
|
||||
@@ -261,6 +269,58 @@ OrderBook.prototype.decrementOfferCount = function(account) {
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add offer amount to sum amount being offered by an account
|
||||
*
|
||||
* @param {String} account address
|
||||
* @param {Object|String} offer amount
|
||||
* @return sum
|
||||
*/
|
||||
|
||||
OrderBook.prototype.addOwnerOffer = function(account, amount) {
|
||||
assert(UInt160.is_valid(account), 'Account is invalid');
|
||||
var previousAmount = this.getOwnerOfferSum(account);
|
||||
var newAmount = previousAmount.add(Amount.from_json(amount));
|
||||
this._ownerOffers[account] = newAmount;
|
||||
return newAmount;
|
||||
};
|
||||
|
||||
/**
|
||||
* Subtract offer amount from sum amount being offered by an account
|
||||
*
|
||||
* @param {String} account address
|
||||
* @param {Object|String} offer amount
|
||||
* @return sum
|
||||
*/
|
||||
|
||||
OrderBook.prototype.subtractOwnerOffer = function(account, amount) {
|
||||
assert(UInt160.is_valid(account), 'Account is invalid');
|
||||
var previousAmount = this.getOwnerOfferSum(account);
|
||||
var newAmount = previousAmount.subtract(Amount.from_json(amount));
|
||||
this._ownerOffers[account] = newAmount;
|
||||
return newAmount;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get sum amount for offers by an account
|
||||
*
|
||||
* @param {String} account address
|
||||
* @return sum
|
||||
*/
|
||||
|
||||
OrderBook.prototype.getOwnerOfferSum = function(account) {
|
||||
assert(UInt160.is_valid(account), 'Account is invalid');
|
||||
var amount = this._ownerOffers[account];
|
||||
if (!amount) {
|
||||
if (this._currencyGets.is_native()) {
|
||||
amount = Amount.from_json('0');
|
||||
} else {
|
||||
amount = Amount.from_json('0' + OrderBook.IOU_SUFFIX);
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute funded amount for a balance/transferRate
|
||||
*
|
||||
@@ -358,11 +418,20 @@ OrderBook.prototype.setFundedAmount = function(offer, fundedAmount) {
|
||||
return offer;
|
||||
}
|
||||
|
||||
// Sum of offer amounts by an account
|
||||
var offerSum = this.getOwnerOfferSum(offer.Account);
|
||||
|
||||
if (offerSum.is_zero()) {
|
||||
// If there are no cached offer amounts for the account, default to
|
||||
// TakerGets of this offer
|
||||
offerSum = Amount.from_json(offer.TakerGets);
|
||||
}
|
||||
|
||||
offer.is_fully_funded = Amount.from_json(
|
||||
this._currencyGets.is_native()
|
||||
? fundedAmount
|
||||
: fundedAmount + OrderBook.IOU_SUFFIX
|
||||
).compareTo(Amount.from_json(offer.TakerGets)) >= 0;
|
||||
).compareTo(offerSum) >= 0;
|
||||
|
||||
if (offer.is_fully_funded) {
|
||||
offer.taker_gets_funded = Amount.from_json(offer.TakerGets).to_text();
|
||||
@@ -376,12 +445,8 @@ OrderBook.prototype.setFundedAmount = function(offer, fundedAmount) {
|
||||
? offer.TakerPays.value
|
||||
: offer.TakerPays;
|
||||
|
||||
var takerGetsValue = (typeof offer.TakerGets === 'object')
|
||||
? offer.TakerGets.value
|
||||
: offer.TakerGets;
|
||||
|
||||
var takerPays = Amount.from_json(takerPaysValue + OrderBook.IOU_SUFFIX);
|
||||
var takerGets = Amount.from_json(takerGetsValue + OrderBook.IOU_SUFFIX);
|
||||
var takerGets = Amount.from_json(offerSum);
|
||||
var fundedPays = Amount.from_json(fundedAmount + OrderBook.IOU_SUFFIX);
|
||||
var rate = takerPays.divide(takerGets);
|
||||
|
||||
@@ -662,9 +727,16 @@ OrderBook.offerRewrite = function(offer) {
|
||||
OrderBook.prototype.setOffers = function(offers) {
|
||||
assert(Array.isArray(offers));
|
||||
|
||||
var l = offers.length;
|
||||
var newOffers = [ ];
|
||||
|
||||
for (var i=0, l=offers.length; i<l; i++) {
|
||||
for (var i=0; i<l; i++) {
|
||||
var offer = offers[i];
|
||||
// Add offer amount to sum for account
|
||||
this.addOwnerOffer(offer.Account, offer.TakerGets);
|
||||
}
|
||||
|
||||
for (var i=0; i<l; i++) {
|
||||
var offer = OrderBook.offerRewrite(offers[i]);
|
||||
var fundedAmount;
|
||||
|
||||
@@ -675,8 +747,8 @@ OrderBook.prototype.setOffers = function(offers) {
|
||||
this.addCachedFunds(offer.Account, fundedAmount);
|
||||
}
|
||||
|
||||
this.setFundedAmount(offer, fundedAmount);
|
||||
this.incrementOfferCount(offer.Account);
|
||||
this.setFundedAmount(offer, fundedAmount);
|
||||
|
||||
newOffers.push(offer);
|
||||
}
|
||||
@@ -888,6 +960,9 @@ OrderBook.prototype.insertOffer = function(node, fundedAmount) {
|
||||
log.info('inserting offer', this._key, node.fields);
|
||||
}
|
||||
|
||||
// Add offer amount to sum for account
|
||||
this.addOwnerOffer(node.fields.Account, node.fields.TakerGets);
|
||||
|
||||
var nodeFields = OrderBook.offerRewrite(node.fields);
|
||||
nodeFields.LedgerEntryType = node.entryType;
|
||||
nodeFields.index = node.ledgerIndex;
|
||||
@@ -904,7 +979,7 @@ OrderBook.prototype.insertOffer = function(node, fundedAmount) {
|
||||
// XXX Should use Amount#from_quality
|
||||
var price = Amount.from_json(
|
||||
nodeFields.TakerPays
|
||||
).ratio_human(node.fields.TakerGets, DATE_REF);
|
||||
).ratio_human(nodeFields.TakerGets, DATE_REF);
|
||||
|
||||
for (var i=0, l=this._offers.length; i<l; i++) {
|
||||
var offer = this._offers[i];
|
||||
@@ -944,14 +1019,21 @@ OrderBook.prototype.modifyOffer = function(node, isDeletedNode) {
|
||||
var offer = this._offers[i];
|
||||
if (offer.index === node.ledgerIndex) {
|
||||
if (isDeletedNode) {
|
||||
// Multiple offers same account?
|
||||
// Remove offer amount from sum for account
|
||||
this.subtractOwnerOffer(offer.Account, offer.TakerGets);
|
||||
this._offers.splice(i, 1);
|
||||
this.emit('offer_removed', offer);
|
||||
} else {
|
||||
// TODO: This assumes no fields are deleted, which is
|
||||
// probably a safe assumption, but should be checked.
|
||||
var previousOffer = extend({}, offer);
|
||||
var previousOffer = extend({ }, offer);
|
||||
extend(offer, node.fieldsFinal);
|
||||
|
||||
// Remove offer amount from sum for account
|
||||
this.subtractOwnerOffer(offer.Account, previousOffer.TakerGets);
|
||||
// Add offer amount from sum for account
|
||||
this.addOwnerOffer(offer.Account, offer.TakerGets);
|
||||
|
||||
this.emit('offer_changed', previousOffer, offer);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -17,6 +17,7 @@ var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
var assert = require('assert');
|
||||
var LRU = require('lru-cache');
|
||||
var async = require('async');
|
||||
var Server = require('./server').Server;
|
||||
var Request = require('./request').Request;
|
||||
var Server = require('./server').Server;
|
||||
@@ -1258,7 +1259,7 @@ Remote.accountRequest = function(type, options, callback) {
|
||||
request.message.peer = UInt160.json_rewrite(peer);
|
||||
}
|
||||
|
||||
if (!isNaN(Number(limit))) {
|
||||
if (!isNaN(limit)) {
|
||||
limit = Number(limit);
|
||||
|
||||
// max for 32-bit unsigned int is 4294967295
|
||||
@@ -1424,10 +1425,19 @@ Remote.prototype.requestAccountTx = function(options, callback) {
|
||||
}, options);
|
||||
|
||||
request.once('success', function(res) {
|
||||
if (options.parseBinary) {
|
||||
res.transactions = res.transactions.map(Remote.parseBinaryTransaction);
|
||||
if (!options.parseBinary) {
|
||||
request.emit('transactions', res);
|
||||
return;
|
||||
}
|
||||
request.emit('transactions', res);
|
||||
|
||||
async.mapSeries(res.transactions, function(transaction, next) {
|
||||
async.setImmediate(function() {
|
||||
next(null, Remote.parseBinaryTransaction(transaction));
|
||||
});
|
||||
}, function(err, transactions) {
|
||||
res.transactions = transactions;
|
||||
request.emit('transactions', res);
|
||||
});
|
||||
});
|
||||
|
||||
request.callback(callback, 'transactions');
|
||||
@@ -1476,14 +1486,19 @@ Remote.prototype.requestTxHistory = function(start, callback) {
|
||||
/**
|
||||
* Request book_offers
|
||||
*
|
||||
* @param {Object} gets
|
||||
* @param {Object} pays
|
||||
* @param {String} taker
|
||||
* @param [Function] calback
|
||||
* @param {Object} options
|
||||
* @param {Object} options.gets - taker_gets with issuer and currency
|
||||
* @param {Object} options.pays - taker_pays with issuer and currency
|
||||
* @param {String} [options.taker]
|
||||
* @param {String} [options.ledger]
|
||||
* @param {String|Number} [options.limit]
|
||||
* @param [Function] callback
|
||||
* @return {Request}
|
||||
*/
|
||||
|
||||
Remote.prototype.requestBookOffers = function(gets, pays, taker, callback) {
|
||||
var ledger;
|
||||
var limit;
|
||||
var lastArg = arguments[arguments.length - 1];
|
||||
|
||||
if (gets.hasOwnProperty('gets') || gets.hasOwnProperty('taker_gets')) {
|
||||
@@ -1495,6 +1510,8 @@ Remote.prototype.requestBookOffers = function(gets, pays, taker, callback) {
|
||||
taker = options.taker;
|
||||
pays = options.pays || options.taker_pays;
|
||||
gets = options.gets || options.taker_gets;
|
||||
ledger = options.ledger;
|
||||
limit = options.limit;
|
||||
}
|
||||
|
||||
if (typeof lastArg === 'function') {
|
||||
@@ -1520,9 +1537,26 @@ Remote.prototype.requestBookOffers = function(gets, pays, taker, callback) {
|
||||
}
|
||||
|
||||
request.message.taker = taker ? taker : UInt160.ACCOUNT_ONE;
|
||||
request.ledgerSelect(ledger);
|
||||
|
||||
if (!isNaN(limit)) {
|
||||
limit = Number(limit);
|
||||
|
||||
// max for 32-bit unsigned int is 4294967295
|
||||
// we'll clamp to 1e9
|
||||
if (limit > 1e9) {
|
||||
limit = 1e9;
|
||||
}
|
||||
// min for 32-bit unsigned int is 0
|
||||
// we'll clamp to 0
|
||||
if (limit < 0) {
|
||||
limit = 0;
|
||||
}
|
||||
|
||||
request.message.limit = limit;
|
||||
}
|
||||
|
||||
request.callback(callback);
|
||||
|
||||
return request;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ var SerializedObject = require('./serializedobject').SerializedObject;
|
||||
var RippleError = require('./rippleerror').RippleError;
|
||||
var hashprefixes = require('./hashprefixes');
|
||||
var config = require('./config');
|
||||
var log = require('./log').internal.sub('transaction');
|
||||
|
||||
/**
|
||||
* @constructor Transaction
|
||||
@@ -131,6 +132,7 @@ Transaction.set_clear_flags = {
|
||||
asfRequireAuth: 2,
|
||||
asfDisallowXRP: 3,
|
||||
asfDisableMaster: 4,
|
||||
asfAccountTxnID: 5,
|
||||
asfNoFreeze: 6,
|
||||
asfGlobalFreeze: 7
|
||||
}
|
||||
@@ -858,6 +860,15 @@ Transaction.prototype.addMemo = function(memoType, memoFormat, memoData) {
|
||||
return this;
|
||||
};
|
||||
|
||||
Transaction.prototype.setAccountTxnID =
|
||||
Transaction.prototype.accountTxnID = function(id) {
|
||||
if (typeof id === 'string') {
|
||||
this.tx_json.AccountTxnID = id;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct an 'AccountSet' transaction
|
||||
*
|
||||
|
||||
@@ -13,7 +13,6 @@ var BigInteger = utils.jsbn.BigInteger;
|
||||
var UInt = function() {
|
||||
// Internal form: NaN or BigInteger
|
||||
this._value = NaN;
|
||||
|
||||
this._update();
|
||||
};
|
||||
|
||||
@@ -96,6 +95,10 @@ UInt.prototype.clone = function() {
|
||||
UInt.prototype.copyTo = function(d) {
|
||||
d._value = this._value;
|
||||
|
||||
if (this._version_byte !== void(0)) {
|
||||
d._version_byte = this._version_byte;
|
||||
}
|
||||
|
||||
if (typeof d._update === 'function') {
|
||||
d._update();
|
||||
}
|
||||
@@ -104,7 +107,9 @@ UInt.prototype.copyTo = function(d) {
|
||||
};
|
||||
|
||||
UInt.prototype.equals = function(d) {
|
||||
return this._value instanceof BigInteger && d._value instanceof BigInteger && this._value.equals(d._value);
|
||||
return this._value instanceof BigInteger
|
||||
&& d._value instanceof BigInteger
|
||||
&& this._value.equals(d._value);
|
||||
};
|
||||
|
||||
UInt.prototype.is_valid = function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var Account = require('../src/js/ripple/account').Account;
|
||||
var Account = require('ripple-lib').Account;
|
||||
|
||||
describe('Account', function(){
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var BigInteger = require('../src/js/jsbn/jsbn').BigInteger;
|
||||
var Amount = utils.load_module('amount').Amount;
|
||||
var UInt160 = utils.load_module('uint160').UInt160;
|
||||
var config = utils.get_config();
|
||||
var assert = require('assert');
|
||||
var BigInteger = require('ripple-lib').jsbn.BigInteger;
|
||||
var Amount = require('ripple-lib').Amount;
|
||||
var UInt160 = require('ripple-lib').UInt160;
|
||||
var load_config = require('ripple-lib').config.load;
|
||||
var config = require('./config-example');
|
||||
|
||||
load_config(config);
|
||||
|
||||
|
||||
describe('Amount', function() {
|
||||
describe('Negatives', function() {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var Seed = utils.load_module('seed').Seed;
|
||||
var config = require('./testutils').get_config();
|
||||
var Seed = require('ripple-lib').Seed;
|
||||
|
||||
describe('Base58', function() {
|
||||
describe('Seed', function() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var currency = utils.load_module('currency').Currency;
|
||||
var timeUtil = utils.load_module('utils').time;
|
||||
var currency = require('ripple-lib').Currency;
|
||||
var timeUtil = require('ripple-lib').utils.time;
|
||||
|
||||
describe('Currency', function() {
|
||||
describe('json_rewrite', function() {
|
||||
|
||||
303
test/fixtures/metadata-with-hex-accounts.json
vendored
Normal file
303
test/fixtures/metadata-with-hex-accounts.json
vendored
Normal file
@@ -0,0 +1,303 @@
|
||||
{
|
||||
"AffectedNodes": [
|
||||
{
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rNGySgyyEdRJ6MKmzsZwyhhVeFKdENRGQ6",
|
||||
"BookDirectory": "DFA3B6DDAB58C7E8E5D944E736DA4B7046C30E4F460FD9DE4D08594FC79E1600",
|
||||
"BookNode": "0000000000000000",
|
||||
"Flags": 131072,
|
||||
"OwnerNode": "0000000000000031",
|
||||
"PreviousTxnID": "83CA9AB231B0B4DA8ACF6305A6D7B00AB83404A1FDB8F8BCF7108EB87E0A8196",
|
||||
"PreviousTxnLgrSeq": 10555009,
|
||||
"Sequence": 12370,
|
||||
"TakerGets": "44978350398",
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rQ3qJZwtzi4Zo3nWbmX9gwCke6S8jmHRCn",
|
||||
"value": "1056.990784602728"
|
||||
}
|
||||
},
|
||||
"LedgerEntryType": "Offer",
|
||||
"LedgerIndex": "0496450E3F46368FB011B8B524605A906C0854441D30420457A81EA89BE649BE"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Balance": {
|
||||
"currency": "USD",
|
||||
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
|
||||
"value": "0"
|
||||
},
|
||||
"Flags": 1114112,
|
||||
"HighLimit": {
|
||||
"currency": "USD",
|
||||
"issuer": "rabVnHuo1eq747GbnLDAJfE9GpsGwcL9Hy",
|
||||
"value": "0"
|
||||
},
|
||||
"HighNode": "0000000000000000",
|
||||
"LowLimit": {
|
||||
"currency": "USD",
|
||||
"issuer": "rGa3Tb6vaMVU5RQMjxk4nsMGSArbu8epGG",
|
||||
"value": "5"
|
||||
},
|
||||
"LowNode": "0000000000000000"
|
||||
},
|
||||
"LedgerEntryType": "RippleState",
|
||||
"LedgerIndex": "2DECFAC23B77D5AEA6116C15F5C6D4669EBAEE9E7EE050A40FE2B1E47B6A9419",
|
||||
"PreviousFields": {
|
||||
"Balance": {
|
||||
"currency": "USD",
|
||||
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
|
||||
"value": "3"
|
||||
}
|
||||
},
|
||||
"PreviousTxnID": "6F35AD78AA196389D15F4BAF054122070506633C1506EF16A48877E2593CCE2D",
|
||||
"PreviousTxnLgrSeq": 10555014
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Balance": {
|
||||
"currency": "USD",
|
||||
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
|
||||
"value": "1228.52678703286"
|
||||
},
|
||||
"Flags": 1114112,
|
||||
"HighLimit": {
|
||||
"currency": "USD",
|
||||
"issuer": "rabVnHuo1eq747GbnLDAJfE9GpsGwcL9Hy",
|
||||
"value": "0"
|
||||
},
|
||||
"HighNode": "0000000000000076",
|
||||
"LowLimit": {
|
||||
"currency": "USD",
|
||||
"issuer": "rPofp4ruTavGuFnb9AYN2vRPBFxHB7RRsH",
|
||||
"value": "50000"
|
||||
},
|
||||
"LowNode": "0000000000000000"
|
||||
},
|
||||
"LedgerEntryType": "RippleState",
|
||||
"LedgerIndex": "4AB2FFDEE65E025AAB54305A161C80D32082574BB0502311F29227089C696388",
|
||||
"PreviousFields": {
|
||||
"Balance": {
|
||||
"currency": "USD",
|
||||
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
|
||||
"value": "1225.52678703286"
|
||||
}
|
||||
},
|
||||
"PreviousTxnID": "65C5A92212AA82A89C3824F6F071FE49C95C45DE9113EB51763A217DBACB5B4C",
|
||||
"PreviousTxnLgrSeq": 10554856
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Flags": 0,
|
||||
"Owner": "rP5VvumKn5qqn4RYTMGipmPE9965ARVQNT",
|
||||
"RootIndex": "65E53030C59CD541BB6A8B631F13FA9BBF6F6E28B63D41AA363F23313B34B094"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "65E53030C59CD541BB6A8B631F13FA9BBF6F6E28B63D41AA363F23313B34B094"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rNGySgyyEdRJ6MKmzsZwyhhVeFKdENRGQ6",
|
||||
"Balance": "335297994919",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 12,
|
||||
"Sequence": 12379
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "6ACA1AAB7CD8877EA63E0C282A37FC212AD24640743F019AC2DD8674E003B741",
|
||||
"PreviousFields": {
|
||||
"OwnerCount": 13
|
||||
},
|
||||
"PreviousTxnID": "83CA9AB231B0B4DA8ACF6305A6D7B00AB83404A1FDB8F8BCF7108EB87E0A8196",
|
||||
"PreviousTxnLgrSeq": 10555009
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Balance": {
|
||||
"currency": "USD",
|
||||
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
|
||||
"value": "-15.68270575272517"
|
||||
},
|
||||
"Flags": 131072,
|
||||
"HighLimit": {
|
||||
"currency": "USD",
|
||||
"issuer": "rGa3Tb6vaMVU5RQMjxk4nsMGSArbu8epGG",
|
||||
"value": "5000"
|
||||
},
|
||||
"HighNode": "0000000000000000",
|
||||
"LowLimit": {
|
||||
"currency": "USD",
|
||||
"issuer": "rQ3qJZwtzi4Zo3nWbmX9gwCke6S8jmHRCn",
|
||||
"value": "0"
|
||||
},
|
||||
"LowNode": "000000000000004A"
|
||||
},
|
||||
"LedgerEntryType": "RippleState",
|
||||
"LedgerIndex": "826CF5BFD28F3934B518D0BDF3231259CBD3FD0946E3C3CA0C97D2C75D2D1A09",
|
||||
"PreviousFields": {
|
||||
"Balance": {
|
||||
"currency": "USD",
|
||||
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
|
||||
"value": "-12.68270575272517"
|
||||
}
|
||||
},
|
||||
"PreviousTxnID": "6F35AD78AA196389D15F4BAF054122070506633C1506EF16A48877E2593CCE2D",
|
||||
"PreviousTxnLgrSeq": 10555014
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Flags": 0,
|
||||
"IndexPrevious": "000000000000002C",
|
||||
"Owner": "rNGySgyyEdRJ6MKmzsZwyhhVeFKdENRGQ6",
|
||||
"RootIndex": "A93C6B313E260AC7C7734DF44F4461075E2C937C936C2B81DA2C9F69D4A0B0F2"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "8D8FB3359BBA810ED5C5894088F2415E322811181ADCC5BB087E829207DFBBEB"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rP5VvumKn5qqn4RYTMGipmPE9965ARVQNT",
|
||||
"Balance": "25116082528",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 5,
|
||||
"Sequence": 2197
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "8F55B7E947241AD38FD6D47374BF8E7CA7DF177C8B79712B4CAC5E91FD5023FF",
|
||||
"PreviousFields": {
|
||||
"OwnerCount": 6
|
||||
},
|
||||
"PreviousTxnID": "0327747C391C678CA2AC46F422E1E8D307A41E9C0ED5DB2677B51CEBE41BD243",
|
||||
"PreviousTxnLgrSeq": 10554892
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rauAjp7gUp8xqHnPFDSo72Nc6aMx2k9yDk",
|
||||
"Balance": "233929959",
|
||||
"Flags": 0,
|
||||
"OwnerCount": 14,
|
||||
"Sequence": 31927
|
||||
},
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"LedgerIndex": "A27BB98F7C9D32F404B364622645F80480F87C8A91BB13CA9F6E569144C2A5A8",
|
||||
"PreviousFields": {
|
||||
"Balance": "233941959",
|
||||
"Sequence": 31926
|
||||
},
|
||||
"PreviousTxnID": "65C5A92212AA82A89C3824F6F071FE49C95C45DE9113EB51763A217DBACB5B4C",
|
||||
"PreviousTxnLgrSeq": 10554856
|
||||
}
|
||||
},
|
||||
{
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"ExchangeRate": "4D08594FC79E1600",
|
||||
"Flags": 0,
|
||||
"RootIndex": "DFA3B6DDAB58C7E8E5D944E736DA4B7046C30E4F460FD9DE4D08594FC79E1600",
|
||||
"TakerGetsCurrency": "0000000000000000000000000000000000000000",
|
||||
"TakerGetsIssuer": "0000000000000000000000000000000000000000",
|
||||
"TakerPaysCurrency": "0000000000000000000000005553440000000000",
|
||||
"TakerPaysIssuer": "0520B3C85F482532A9578DBB3950B85CA03594D1"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "DFA3B6DDAB58C7E8E5D944E736DA4B7046C30E4F460FD9DE4D08594FC79E1600"
|
||||
}
|
||||
},
|
||||
{
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"ExchangeRate": "4D08594FE7353EDE",
|
||||
"Flags": 0,
|
||||
"RootIndex": "DFA3B6DDAB58C7E8E5D944E736DA4B7046C30E4F460FD9DE4D08594FE7353EDE",
|
||||
"TakerGetsCurrency": "0000000000000000000000000000000000000000",
|
||||
"TakerGetsIssuer": "0000000000000000000000000000000000000000",
|
||||
"TakerPaysCurrency": "0000000000000000000000005553440000000000",
|
||||
"TakerPaysIssuer": "0520B3C85F482532A9578DBB3950B85CA03594D1"
|
||||
},
|
||||
"LedgerEntryType": "DirectoryNode",
|
||||
"LedgerIndex": "DFA3B6DDAB58C7E8E5D944E736DA4B7046C30E4F460FD9DE4D08594FE7353EDE"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ModifiedNode": {
|
||||
"FinalFields": {
|
||||
"Balance": {
|
||||
"currency": "USD",
|
||||
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
|
||||
"value": "-2818.268620725051"
|
||||
},
|
||||
"Flags": 2228224,
|
||||
"HighLimit": {
|
||||
"currency": "USD",
|
||||
"issuer": "rauAjp7gUp8xqHnPFDSo72Nc6aMx2k9yDk",
|
||||
"value": "50000"
|
||||
},
|
||||
"HighNode": "0000000000000000",
|
||||
"LowLimit": {
|
||||
"currency": "USD",
|
||||
"issuer": "rQ3qJZwtzi4Zo3nWbmX9gwCke6S8jmHRCn",
|
||||
"value": "0"
|
||||
},
|
||||
"LowNode": "00000000000001B0"
|
||||
},
|
||||
"LedgerEntryType": "RippleState",
|
||||
"LedgerIndex": "FAD28E839AF29C6CCB8DA6DC71510A5BF8A9C34062C128071C7D22E2469B8288",
|
||||
"PreviousFields": {
|
||||
"Balance": {
|
||||
"currency": "USD",
|
||||
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
|
||||
"value": "-2821.274620725051"
|
||||
}
|
||||
},
|
||||
"PreviousTxnID": "65C5A92212AA82A89C3824F6F071FE49C95C45DE9113EB51763A217DBACB5B4C",
|
||||
"PreviousTxnLgrSeq": 10554856
|
||||
}
|
||||
},
|
||||
{
|
||||
"DeletedNode": {
|
||||
"FinalFields": {
|
||||
"Account": "rP5VvumKn5qqn4RYTMGipmPE9965ARVQNT",
|
||||
"BookDirectory": "DFA3B6DDAB58C7E8E5D944E736DA4B7046C30E4F460FD9DE4D08594FE7353EDE",
|
||||
"BookNode": "0000000000000000",
|
||||
"Flags": 0,
|
||||
"OwnerNode": "0000000000000000",
|
||||
"PreviousTxnID": "0327747C391C678CA2AC46F422E1E8D307A41E9C0ED5DB2677B51CEBE41BD243",
|
||||
"PreviousTxnLgrSeq": 10554892,
|
||||
"Sequence": 2196,
|
||||
"TakerGets": "4255320000",
|
||||
"TakerPays": {
|
||||
"currency": "USD",
|
||||
"issuer": "rQ3qJZwtzi4Zo3nWbmX9gwCke6S8jmHRCn",
|
||||
"value": "100"
|
||||
}
|
||||
},
|
||||
"LedgerEntryType": "Offer",
|
||||
"LedgerIndex": "FB2E442ED1A5BCA1E237BA133807AE17AED1A7E4B9F404906308ADB01A57609D"
|
||||
}
|
||||
}
|
||||
],
|
||||
"DeliveredAmount": {
|
||||
"currency": "USD",
|
||||
"issuer": "rabVnHuo1eq747GbnLDAJfE9GpsGwcL9Hy",
|
||||
"value": "3"
|
||||
},
|
||||
"TransactionIndex": 5,
|
||||
"TransactionResult": "tesSUCCESS"
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var Seed = utils.load_module('seed').Seed;
|
||||
var config = require('./testutils').get_config();
|
||||
var Seed = require('ripple-lib').Seed;
|
||||
|
||||
describe('KeyPair', function() {
|
||||
it('can generate an address', function () {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
|
||||
var utils = require('./testutils');
|
||||
var Ledger = utils.load_module('ledger').Ledger;
|
||||
var config = require('./testutils').get_config();
|
||||
var Ledger = require('ripple-lib').Ledger;
|
||||
|
||||
/**
|
||||
* @param ledger_index {Number}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
var assert = require('assert');
|
||||
var sjcl = require('../build/sjcl');
|
||||
var Message = require('../src/js/ripple/message').Message;
|
||||
var Seed = require('../src/js/ripple/seed').Seed;
|
||||
var Remote = require('../src/js/ripple/remote').Remote;
|
||||
var sjcl = require('ripple-lib').sjcl;
|
||||
var Message = require('ripple-lib').Message;
|
||||
var Seed = require('ripple-lib').Seed;
|
||||
var Remote = require('ripple-lib').Remote;
|
||||
|
||||
describe('Message', function(){
|
||||
|
||||
|
||||
1
test/node_modules/ripple-lib
generated
vendored
Symbolic link
1
test/node_modules/ripple-lib
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../src/js/ripple/
|
||||
@@ -1,9 +1,8 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var Remote = utils.load_module('remote').Remote;
|
||||
var Currency = utils.load_module('currency').Currency;
|
||||
var Amount = utils.load_module('amount').Amount;
|
||||
var Meta = utils.load_module('meta').Meta;
|
||||
var Remote = require('ripple-lib').Remote;
|
||||
var Currency = require('ripple-lib').Currency;
|
||||
var Amount = require('ripple-lib').Amount;
|
||||
var Meta = require('ripple-lib').Meta;
|
||||
|
||||
describe('OrderBook', function() {
|
||||
it('toJSON', function() {
|
||||
@@ -338,6 +337,7 @@ describe('OrderBook', function() {
|
||||
});
|
||||
|
||||
var offer = {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: {
|
||||
value: '100',
|
||||
currency: 'BTC',
|
||||
@@ -349,6 +349,7 @@ describe('OrderBook', function() {
|
||||
book.setFundedAmount(offer, '100.1234');
|
||||
|
||||
var expected = {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: offer.TakerGets,
|
||||
TakerPays: offer.TakerPays,
|
||||
is_fully_funded: true,
|
||||
@@ -368,6 +369,7 @@ describe('OrderBook', function() {
|
||||
});
|
||||
|
||||
var offer = {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: {
|
||||
value: '100',
|
||||
currency: 'BTC',
|
||||
@@ -379,6 +381,7 @@ describe('OrderBook', function() {
|
||||
book.setFundedAmount(offer, '99');
|
||||
|
||||
var expected = {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: offer.TakerGets,
|
||||
TakerPays: offer.TakerPays,
|
||||
is_fully_funded: false,
|
||||
@@ -398,6 +401,7 @@ describe('OrderBook', function() {
|
||||
});
|
||||
|
||||
var offer = {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: '100',
|
||||
TakerPays: {
|
||||
value: '123.456',
|
||||
@@ -409,6 +413,7 @@ describe('OrderBook', function() {
|
||||
book.setFundedAmount(offer, '100.1');
|
||||
|
||||
var expected = {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: offer.TakerGets,
|
||||
TakerPays: offer.TakerPays,
|
||||
is_fully_funded: true,
|
||||
@@ -428,6 +433,7 @@ describe('OrderBook', function() {
|
||||
});
|
||||
|
||||
var offer = {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: '100',
|
||||
TakerPays: {
|
||||
value: '123.456',
|
||||
@@ -439,6 +445,7 @@ describe('OrderBook', function() {
|
||||
book.setFundedAmount(offer, '99');
|
||||
|
||||
var expected = {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: offer.TakerGets,
|
||||
TakerPays: offer.TakerPays,
|
||||
is_fully_funded: false,
|
||||
@@ -458,6 +465,7 @@ describe('OrderBook', function() {
|
||||
});
|
||||
|
||||
var offer = {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: {
|
||||
value: '100',
|
||||
currency: 'BTC',
|
||||
@@ -469,6 +477,7 @@ describe('OrderBook', function() {
|
||||
book.setFundedAmount(offer, '0');
|
||||
|
||||
assert.deepEqual(offer, {
|
||||
Account: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
||||
TakerGets: offer.TakerGets,
|
||||
TakerPays: offer.TakerPays,
|
||||
is_fully_funded: false,
|
||||
@@ -1451,6 +1460,56 @@ describe('OrderBook', function() {
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
owner_funds: '0.950363009783092',
|
||||
quality: '498.6116758238228'
|
||||
},
|
||||
{
|
||||
Account: 'rwBG69mujDoD5yQfL3Sf7Yuh7rUNYdxe9Y',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131072,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
PreviousTxnID: 'C8296B9CCA6DC594C7CD271C5D8FD11FEE380021A07768B25935642CDB37048A',
|
||||
PreviousTxnLgrSeq: 8342469,
|
||||
Sequence: 29356,
|
||||
TakerGets: {
|
||||
currency: 'BTC',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '0.5'
|
||||
},
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
owner_funds: '0.950363009783092',
|
||||
quality: '498.6116758238228'
|
||||
},
|
||||
{
|
||||
Account: 'rwBG69mujDoD5yQfL3Sf7Yuh7rUNYdxe9Y',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131078,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
PreviousTxnID: 'C8296B9CCA6DC594C7CD271C5D8FD11FEE380021A07768B25935642CDB37048A',
|
||||
PreviousTxnLgrSeq: 8342469,
|
||||
Sequence: 29354,
|
||||
TakerGets: {
|
||||
currency: 'BTC',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '0.5'
|
||||
},
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
owner_funds: '0.950363009783092',
|
||||
quality: '498.6116758238228'
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -1534,10 +1593,258 @@ describe('OrderBook', function() {
|
||||
is_fully_funded: true,
|
||||
taker_gets_funded: '0.2',
|
||||
taker_pays_funded: '99.72233516476456'
|
||||
}
|
||||
},
|
||||
{ Account: 'rwBG69mujDoD5yQfL3Sf7Yuh7rUNYdxe9Y',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131072,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
Sequence: 29356,
|
||||
TakerGets: { currency: 'BTC',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '0.5'
|
||||
},
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
owner_funds: '0.950363009783092',
|
||||
is_fully_funded: false,
|
||||
taker_gets_funded: '0.9484660776278363',
|
||||
taker_pays_funded: '94.58325208561269' },
|
||||
{ Account: 'rwBG69mujDoD5yQfL3Sf7Yuh7rUNYdxe9Y',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131078,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
Sequence: 29354,
|
||||
TakerGets: {
|
||||
currency: 'BTC',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '0.5'
|
||||
},
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
owner_funds: '0.950363009783092',
|
||||
is_fully_funded: false,
|
||||
taker_gets_funded: '0.9484660776278363',
|
||||
taker_pays_funded: '94.58325208561269'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
book.on('model', function(model) {
|
||||
assert.deepEqual(model, expected);
|
||||
assert.strictEqual(book._synchronized, true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Request offers -- native currency', function(done) {
|
||||
var remote = new Remote();
|
||||
|
||||
var offers = {
|
||||
offers: [
|
||||
{
|
||||
Account: 'rGCHV41NxoK7wHQJhmao2RqjWZvBrTUhW1',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711A3A4254F5000',
|
||||
BookNode: '0000000000000000',
|
||||
Flags: 131072,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000000',
|
||||
Sequence: 195,
|
||||
TakerGets: '1000',
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '56.06639660617357'
|
||||
},
|
||||
index: 'B6BC3B0F87976370EE11F5575593FE63AA5DC1D602830DC96F04B2D597F044BF',
|
||||
owner_funds: '600'
|
||||
},
|
||||
{
|
||||
Account: 'raudnGKfTK23YKfnS7ixejHrqGERTYNFXk',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131072,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
Sequence: 29354,
|
||||
TakerGets: '2000',
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
owner_funds: '4000',
|
||||
},
|
||||
{
|
||||
Account: 'rwBG69mujDoD5yQfL3Sf7Yuh7rUNYdxe9Y',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131072,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
Sequence: 29356,
|
||||
TakerGets: '2000',
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
owner_funds: '3900',
|
||||
},
|
||||
{
|
||||
Account: 'rwBG69mujDoD5yQfL3Sf7Yuh7rUNYdxe9Y',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131078,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
PreviousTxnID: 'C8296B9CCA6DC594C7CD271C5D8FD11FEE380021A07768B25935642CDB37048A',
|
||||
PreviousTxnLgrSeq: 8342469,
|
||||
Sequence: 29354,
|
||||
TakerGets: '2000',
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
quality: '498.6116758238228'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var expected = [
|
||||
{
|
||||
Account: 'rGCHV41NxoK7wHQJhmao2RqjWZvBrTUhW1',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711A3A4254F5000',
|
||||
BookNode: '0000000000000000',
|
||||
Flags: 131072,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000000',
|
||||
Sequence: 195,
|
||||
TakerGets: '1000',
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '56.06639660617357'
|
||||
},
|
||||
index: 'B6BC3B0F87976370EE11F5575593FE63AA5DC1D602830DC96F04B2D597F044BF',
|
||||
owner_funds: '600',
|
||||
is_fully_funded: false,
|
||||
taker_gets_funded: '600',
|
||||
taker_pays_funded: '33.63983796370414'
|
||||
},
|
||||
{
|
||||
Account: 'raudnGKfTK23YKfnS7ixejHrqGERTYNFXk',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131072,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
Sequence: 29354,
|
||||
TakerGets: '2000',
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
owner_funds: '4000',
|
||||
is_fully_funded: true,
|
||||
taker_gets_funded: '2000',
|
||||
taker_pays_funded: '99.72233516476456'
|
||||
},
|
||||
{
|
||||
Account: 'rwBG69mujDoD5yQfL3Sf7Yuh7rUNYdxe9Y',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131072,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
Sequence: 29356,
|
||||
TakerGets: '2000',
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
owner_funds: '3900',
|
||||
is_fully_funded: false,
|
||||
taker_gets_funded: '3900',
|
||||
taker_pays_funded: '97.22927678564545'
|
||||
},
|
||||
{
|
||||
Account: 'rwBG69mujDoD5yQfL3Sf7Yuh7rUNYdxe9Y',
|
||||
BookDirectory: '6EAB7C172DEFA430DBFAD120FDC373B5F5AF8B191649EC985711B6D8C62EF414',
|
||||
BookNode: '0000000000000000',
|
||||
Expiration: 461498565,
|
||||
Flags: 131078,
|
||||
LedgerEntryType: 'Offer',
|
||||
OwnerNode: '0000000000000144',
|
||||
Sequence: 29354,
|
||||
TakerGets: '2000',
|
||||
TakerPays: {
|
||||
currency: 'USD',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
value: '99.72233516476456'
|
||||
},
|
||||
index: 'A437D85DF80D250F79308F2B613CF5391C7CF8EE9099BC4E553942651CD9FA86',
|
||||
is_fully_funded: false,
|
||||
taker_gets_funded: '3900',
|
||||
taker_pays_funded: '97.22927678564545'
|
||||
}
|
||||
]
|
||||
|
||||
remote.request = function(request) {
|
||||
switch (request.message.command) {
|
||||
case 'book_offers':
|
||||
assert.deepEqual(request.message, {
|
||||
command: 'book_offers',
|
||||
id: void(0),
|
||||
taker_gets: {
|
||||
currency: '0000000000000000000000000000000000000000',
|
||||
},
|
||||
taker_pays: {
|
||||
currency: '0000000000000000000000005553440000000000',
|
||||
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
},
|
||||
taker: 'rrrrrrrrrrrrrrrrrrrrBZbvji'
|
||||
});
|
||||
|
||||
setImmediate(function() {
|
||||
request.emit('success', offers);
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
var book = remote.createOrderBook({
|
||||
currency_gets: 'XRP',
|
||||
currency_pays: 'USD',
|
||||
issuer_pays: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
});
|
||||
|
||||
book.on('model', function(model) {
|
||||
assert.deepEqual(model, expected);
|
||||
assert.strictEqual(book._synchronized, true);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
|
||||
var Remote = utils.load_module('remote').Remote;
|
||||
var Server = utils.load_module('server').Server;
|
||||
var Request = utils.load_module('request').Request;
|
||||
var Remote = require('ripple-lib').Remote;
|
||||
var Server = require('ripple-lib').Server;
|
||||
var Request = require('ripple-lib').Request;
|
||||
var UInt160 = require('ripple-lib').UInt160;
|
||||
var Currency = require('ripple-lib').Currency;
|
||||
|
||||
var options, remote, callback, database, tx;
|
||||
|
||||
@@ -335,7 +335,7 @@ describe('Remote', function () {
|
||||
});
|
||||
|
||||
it('requestAccountLines, account and callback', function() {
|
||||
var callback = function() {};
|
||||
function callback() {}
|
||||
var remote = new Remote({
|
||||
servers: [ { host: 's-west.ripple.com', port: 443, secure: true } ]
|
||||
});
|
||||
@@ -354,7 +354,7 @@ describe('Remote', function () {
|
||||
});
|
||||
|
||||
it('requestAccountLines, ledger, peer', function() {
|
||||
var callback = function() {};
|
||||
function callback() {}
|
||||
var remote = new Remote({
|
||||
servers: [ { host: 's-west.ripple.com', port: 443, secure: true } ]
|
||||
});
|
||||
@@ -379,7 +379,7 @@ describe('Remote', function () {
|
||||
});
|
||||
|
||||
it('requestAccountLines, ledger, peer, limit and marker', function() {
|
||||
var callback = function() {};
|
||||
function callback() {}
|
||||
var remote = new Remote({
|
||||
servers: [ { host: 's-west.ripple.com', port: 443, secure: true } ]
|
||||
});
|
||||
@@ -408,7 +408,7 @@ describe('Remote', function () {
|
||||
});
|
||||
|
||||
it('requestAccountOffers, ledger, peer, limit and marker', function() {
|
||||
var callback = function() {};
|
||||
function callback() {}
|
||||
var remote = new Remote({
|
||||
servers: [ { host: 's-west.ripple.com', port: 443, secure: true } ]
|
||||
});
|
||||
@@ -436,6 +436,81 @@ describe('Remote', function () {
|
||||
assert(request.requested);
|
||||
});
|
||||
|
||||
it('requestBookOffers, ledger', function() {
|
||||
function callback() {}
|
||||
var remote = new Remote({
|
||||
servers: [ { host: 's-west.ripple.com', port: 443, secure: true } ]
|
||||
});
|
||||
var request = remote.requestBookOffers(
|
||||
{
|
||||
gets: {
|
||||
currency: 'USD',
|
||||
issuer: ADDRESS
|
||||
},
|
||||
pays: {
|
||||
currency: 'XRP'
|
||||
},
|
||||
ledger: LEDGER_HASH
|
||||
},
|
||||
callback
|
||||
);
|
||||
|
||||
assert.deepEqual(request.message, {
|
||||
command: 'book_offers',
|
||||
id: undefined,
|
||||
taker_gets: {
|
||||
currency: Currency.from_human('USD').to_hex(),
|
||||
issuer: ADDRESS
|
||||
},
|
||||
taker_pays: {
|
||||
currency: '0000000000000000000000000000000000000000'
|
||||
},
|
||||
taker: UInt160.ACCOUNT_ONE,
|
||||
ledger_hash: LEDGER_HASH
|
||||
});
|
||||
|
||||
assert(request.requested);
|
||||
});
|
||||
|
||||
it('requestBookOffers, ledger and limit', function() {
|
||||
function callback() {}
|
||||
|
||||
var remote = new Remote({
|
||||
servers: [ { host: 's-west.ripple.com', port: 443, secure: true } ]
|
||||
});
|
||||
var request = remote.requestBookOffers(
|
||||
{
|
||||
gets: {
|
||||
currency: 'USD',
|
||||
issuer: ADDRESS
|
||||
},
|
||||
pays: {
|
||||
currency: 'XRP'
|
||||
},
|
||||
ledger: LEDGER_HASH,
|
||||
limit: 10
|
||||
},
|
||||
callback
|
||||
);
|
||||
|
||||
assert.deepEqual(request.message, {
|
||||
command: 'book_offers',
|
||||
id: undefined,
|
||||
taker_gets: {
|
||||
currency: Currency.from_human('USD').to_hex(),
|
||||
issuer: ADDRESS
|
||||
},
|
||||
taker_pays: {
|
||||
currency: Currency.from_human('XRP').to_hex()
|
||||
},
|
||||
taker: UInt160.ACCOUNT_ONE,
|
||||
ledger_hash: LEDGER_HASH,
|
||||
limit: 10
|
||||
});
|
||||
|
||||
assert(request.requested);
|
||||
});
|
||||
|
||||
it('create remote and get pending transactions', function() {
|
||||
before(function() {
|
||||
tx = [{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var Request = utils.load_module('request').Request;
|
||||
var Remote = utils.load_module('remote').Remote;
|
||||
var Server = utils.load_module('server').Server;
|
||||
var Currency = utils.load_module('currency').Currency;
|
||||
var Request = require('ripple-lib').Request;
|
||||
var Remote = require('ripple-lib').Remote;
|
||||
var Server = require('ripple-lib').Server;
|
||||
var Currency = require('ripple-lib').Currency;
|
||||
|
||||
function makeServer(url) {
|
||||
var server = new Server(new process.EventEmitter(), url);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var Seed = utils.load_module('seed').Seed;
|
||||
var config = require('./testutils').get_config();
|
||||
var Seed = require('ripple-lib').Seed;
|
||||
|
||||
describe('Seed', function() {
|
||||
it('can generate many addresses', function () {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
var utils = require('./testutils');
|
||||
var assert = require('assert');
|
||||
var SerializedObject = utils.load_module('serializedobject').SerializedObject;
|
||||
var sjcl = require('./../src/js/ripple/utils').sjcl;
|
||||
var SerializedObject = require('ripple-lib').SerializedObject;
|
||||
var sjcl = require('ripple-lib').sjcl;
|
||||
|
||||
// Shortcuts
|
||||
var hex = sjcl.codec.hex;
|
||||
@@ -325,4 +324,4 @@ describe('Serialized object', function() {
|
||||
|
||||
});
|
||||
|
||||
// vim:sw=2:sts=2:ts=8:et
|
||||
// vim:sw=2:sts=2:ts=8:et
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
var utils = require('./testutils');
|
||||
var assert = require('assert');
|
||||
var SerializedObject = utils.load_module('serializedobject').SerializedObject;
|
||||
var types = utils.load_module('serializedtypes');
|
||||
var amountConstants = require('../src/js/ripple/amount').consts;
|
||||
var BigInteger = require('../src/js/jsbn/jsbn').BigInteger;
|
||||
|
||||
var config = require('./testutils').get_config();
|
||||
var SerializedObject = require('ripple-lib').SerializedObject;
|
||||
var types = require('ripple-lib').types;
|
||||
var Amount = require('ripple-lib').Amount;
|
||||
var BigInteger = require('ripple-lib').jsbn.BigInteger;
|
||||
|
||||
describe('Serialized types', function() {
|
||||
describe('Int8', function() {
|
||||
@@ -553,7 +550,7 @@ describe('Serialized types', function() {
|
||||
});
|
||||
it('Serialize max_value/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', function () {
|
||||
var so = new SerializedObject();
|
||||
types.Amount.serialize(so, amountConstants.max_value+'/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
|
||||
types.Amount.serialize(so, Amount.max_value+'/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
|
||||
assert.strictEqual(so.to_hex(), 'EC6386F26FC0FFFF0000000000000000000000005553440000000000B5F762798A53D543A014CAF8B297CFF8F2F937E8');
|
||||
});
|
||||
it('Parse 1 XRP', function () {
|
||||
@@ -590,7 +587,7 @@ describe('Serialized types', function() {
|
||||
});
|
||||
it('Parse max_value/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', function () {
|
||||
var so = new SerializedObject('EC6386F26FC0FFFF0000000000000000000000005553440000000000B5F762798A53D543A014CAF8B297CFF8F2F937E8');
|
||||
assert.strictEqual(types.Amount.parse(so).to_text_full(), amountConstants.max_value+'/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
|
||||
assert.strictEqual(types.Amount.parse(so).to_text_full(), Amount.max_value+'/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
var assert = require('assert');
|
||||
var ws = require('ws');
|
||||
var utils = require('./testutils');
|
||||
var Remote = utils.load_module('remote').Remote;
|
||||
var Server = utils.load_module('server').Server;
|
||||
var Request = utils.load_module('request').Request;
|
||||
var Transaction = utils.load_module('transaction').Transaction;
|
||||
var Remote = require('ripple-lib').Remote;
|
||||
var Server = require('ripple-lib').Server;
|
||||
var Request = require('ripple-lib').Request;
|
||||
var Transaction = require('ripple-lib').Transaction;
|
||||
|
||||
describe('Server', function() {
|
||||
it('Server constructor - invalid options', function() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var Seed = utils.load_module('seed').Seed;
|
||||
var Seed = require('ripple-lib').Seed;
|
||||
|
||||
function _isNaN(n) {
|
||||
return typeof n === 'number' && isNaN(n);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var sjcl = require('../build/sjcl');
|
||||
var Seed = require('../src/js/ripple/seed').Seed;
|
||||
var sjcl = require('ripple-lib').sjcl;
|
||||
var Seed = require('ripple-lib').Seed;
|
||||
|
||||
describe('SJCL ECDSA Canonicalization', function() {
|
||||
describe('canonicalizeSignature', function() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var sjcl = require('../build/sjcl');
|
||||
var sjcl = require('ripple-lib').sjcl;
|
||||
|
||||
describe('ECDSA signing with recoverable public key', function(){
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var sjcl = require('../build/sjcl');
|
||||
var sjcl = require('ripple-lib').sjcl;
|
||||
|
||||
describe('SJCL Extramath', function() {
|
||||
describe('setBitM', function() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var sjcl = require('../build/sjcl');
|
||||
var sjcl = require('ripple-lib').sjcl;
|
||||
|
||||
describe('SJCL Jacobi', function() {
|
||||
it('(15/13) = -1', function () {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var sjcl = require('../build/sjcl');
|
||||
var sjcl = require('ripple-lib').sjcl;
|
||||
|
||||
function testExp(vec) {
|
||||
var actual = new sjcl.bn(vec.g).powermodMontgomery(new sjcl.bn(vec.e),
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
var ripple = require('../src/js/ripple');
|
||||
|
||||
exports.get_config = get_config;
|
||||
|
||||
function get_config() {
|
||||
var config = { };
|
||||
try {
|
||||
config = require('./config');
|
||||
} catch(exception) {
|
||||
config = require('./config-example');
|
||||
}
|
||||
return load_config(config);
|
||||
};
|
||||
|
||||
exports.load_config = load_config;
|
||||
|
||||
function load_config(config) {
|
||||
return load_module('config').load(config);
|
||||
};
|
||||
|
||||
exports.load_module = load_module;
|
||||
|
||||
function load_module(name) {
|
||||
if (process.env.RIPPLE_LIB_COV) {
|
||||
return require('../src-cov/js/ripple/' + name)
|
||||
} else if (!ripple.hasOwnProperty(name)) {
|
||||
return require('../src/js/ripple/' + name);
|
||||
} else {
|
||||
return require('../src/js/ripple')[name];
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var Transaction = utils.load_module('transaction').Transaction;
|
||||
var TransactionQueue = utils.load_module('transactionqueue').TransactionQueue;
|
||||
var Transaction = require('ripple-lib').Transaction;
|
||||
var TransactionQueue = require('ripple-lib').TransactionQueue;
|
||||
|
||||
describe('Transaction queue', function() {
|
||||
it('Push transaction', function() {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
var utils = require('./testutils');
|
||||
var assert = require('assert');
|
||||
var Amount = utils.load_module('amount').Amount;
|
||||
var Transaction = utils.load_module('transaction').Transaction;
|
||||
var TransactionQueue = utils.load_module('transactionqueue').TransactionQueue;
|
||||
var Remote = utils.load_module('remote').Remote;
|
||||
var Server = utils.load_module('server').Server;
|
||||
var Amount = require('ripple-lib').Amount;
|
||||
var Transaction = require('ripple-lib').Transaction;
|
||||
var TransactionQueue = require('ripple-lib').TransactionQueue;
|
||||
var Remote = require('ripple-lib').Remote;
|
||||
var Server = require('ripple-lib').Server;
|
||||
|
||||
var transactionResult = {
|
||||
engine_result: 'tesSUCCESS',
|
||||
@@ -1215,14 +1214,15 @@ describe('Transaction', function() {
|
||||
]);
|
||||
});
|
||||
|
||||
it('Construct AccountSet transaction', function() {
|
||||
var transaction = new Transaction().accountSet('rsLEU1TPdCJPPysqhWYw9jD97xtG5WqSJm');
|
||||
|
||||
it('Set AccountTxnID', function() {
|
||||
var transaction = new Transaction();
|
||||
assert(transaction instanceof Transaction);
|
||||
|
||||
transaction.accountTxnID('75C5A92212AA82A89C3824F6F071FE49C95C45DE9113EB51763A217DBACB5B4F');
|
||||
|
||||
assert.deepEqual(transaction.tx_json, {
|
||||
Flags: 0,
|
||||
TransactionType: 'AccountSet',
|
||||
Account: 'rsLEU1TPdCJPPysqhWYw9jD97xtG5WqSJm'
|
||||
AccountTxnID: '75C5A92212AA82A89C3824F6F071FE49C95C45DE9113EB51763A217DBACB5B4F'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1239,6 +1239,18 @@ describe('Transaction', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Construct AccountSet transaction - with AccountTxnID SetFlag', function() {
|
||||
var transaction = new Transaction().accountSet('rsLEU1TPdCJPPysqhWYw9jD97xtG5WqSJm', 'asfAccountTxnID');
|
||||
|
||||
assert(transaction instanceof Transaction);
|
||||
assert.deepEqual(transaction.tx_json, {
|
||||
Flags: 0,
|
||||
SetFlag: 5,
|
||||
TransactionType: 'AccountSet',
|
||||
Account: 'rsLEU1TPdCJPPysqhWYw9jD97xtG5WqSJm'
|
||||
});
|
||||
});
|
||||
|
||||
it('Construct AccountSet transaction - params object', function() {
|
||||
var transaction = new Transaction().accountSet({
|
||||
account: 'rsLEU1TPdCJPPysqhWYw9jD97xtG5WqSJm',
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils');
|
||||
var UInt128 = utils.load_module('uint128').UInt128;
|
||||
var config = require('./testutils').get_config();
|
||||
var UInt128 = require('ripple-lib').UInt128;
|
||||
|
||||
describe('UInt', function() {
|
||||
describe('128', function() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var fs = require('fs');
|
||||
var assert = require('assert');
|
||||
var utils = require('./testutils').load_module('utils');
|
||||
var utils = require('ripple-lib').utils;
|
||||
|
||||
describe('Utils', function() {
|
||||
describe('hexToString and stringToHex', function() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
var assert = require('assert');
|
||||
var RippleTxt = require('../src/js/ripple/rippletxt').RippleTxt;
|
||||
var AuthInfo = require('../src/js/ripple/authinfo').AuthInfo;
|
||||
var VaultClient = require('../src/js/ripple/vaultclient').VaultClient;
|
||||
var Blob = require('../src/js/ripple/blob').Blob;
|
||||
var UInt256 = require('../src/js/ripple/uint256').UInt256;
|
||||
var sjcl = require('../build/sjcl');
|
||||
var nock = require('nock');
|
||||
var RippleTxt = require('ripple-lib').RippleTxt;
|
||||
var AuthInfo = require('ripple-lib').AuthInfo;
|
||||
var VaultClient = require('ripple-lib').VaultClient;
|
||||
var Blob = require('ripple-lib').Blob;
|
||||
var UInt256 = require('ripple-lib').UInt256;
|
||||
var sjcl = require('ripple-lib').sjcl;
|
||||
var online = process.argv.indexOf('--online-blobvault') !== -1 ? true : false;
|
||||
|
||||
var exampleData = {
|
||||
|
||||
Reference in New Issue
Block a user