Compare commits

...

19 Commits

Author SHA1 Message Date
Alan Cohen
a53249ccd7 Bump version to 0.13.-rc7 2015-09-03 14:04:07 -07:00
Chris Clark
fb1669b2b3 Merge pull request #534 from clark800/prepare
Return instructions in prepare responses
2015-08-28 15:31:59 -07:00
Chris Clark
b88e9370c6 Return instructions in prepare responses 2015-08-28 14:11:02 -07:00
Chris Clark
a13bfae714 Merge pull request #528 from mDuo13/min_value_abs
remove redundant abs from MIN_IOU_VALUE
2015-08-27 14:27:33 -07:00
mDuo13
877c6bbb2a amount min/max - more tests 2015-08-27 14:06:47 -07:00
Chris Clark
fae5c74487 Merge pull request #530 from clark800/remove-methods
Remove computeLedgerHash and isValidAddress from API
2015-08-26 17:57:15 -07:00
Chris Clark
15c0e6db19 Remove computeLedgerHash and isValidAddress from API 2015-08-26 17:19:09 -07:00
mDuo13
2b600a1e4e more amount minimum abs test fixes 2015-08-26 12:26:47 -07:00
mDuo13
297fb2483d fix test for amount min 2015-08-25 17:38:32 -07:00
mDuo13
5049822415 remove redundant abs from MIN_IOU_VALUE 2015-08-25 17:14:33 -07:00
Chris Clark
e3787e0f4f Merge pull request #527 from clark800/fix-getpaths
Use maxAmount in getPaths results so they can be passed to preparePayment
2015-08-25 15:18:21 -07:00
Chris Clark
683199044b Use maxAmount in getPaths results so they can be passed to preparePayment 2015-08-25 15:14:06 -07:00
sublimator
4f3c3e9f66 Merge pull request #524 from wltsmrz/deprecate-positional-api
Deprecate positional request constructor API
2015-08-25 20:52:59 +07:00
wltsmrz
fc0240c06b Deprecate positional request constructor API 2015-08-25 06:42:47 -07:00
sublimator
6bfa284bac Merge pull request #526 from sublimator/update-legacy-support
Update legacy-support & JSDoc comments
2015-08-25 20:18:06 +07:00
Nicholas Dudfield
dfee9bc578 Update legacy-support & JSDoc comments 2015-08-25 20:14:14 +07:00
Chris Clark
0838a0e865 Merge pull request #525 from clark800/test-compiled
Fix testing of compiled library
2015-08-24 17:57:50 -07:00
Chris Clark
5f61d80e2d Fix bugs in compiled library 2015-08-24 17:38:30 -07:00
Chris Clark
c4fa4c237c Compile test cases to run tests without using Babel 2015-08-24 16:58:50 -07:00
44 changed files with 412 additions and 721 deletions

View File

@@ -24,9 +24,13 @@ unittest() {
npm run coveralls
# test compiled version in "dist/npm"
ln -nfs ../../dist/npm/core test/node_modules/ripple-lib
ln -nfs ../../dist/npm test/node_modules/ripple-api
npm test
babel -D --optional runtime --ignore "**/node_modules/**" -d test-compiled/ test/
echo "--reporter spec --timeout 5000 --slow 500" > test-compiled/mocha.opts
mkdir -p test-compiled/node_modules
ln -nfs ../../dist/npm/core test-compiled/node_modules/ripple-lib
ln -nfs ../../dist/npm test-compiled/node_modules/ripple-api
mocha --opts test-compiled/mocha.opts test-compiled
rm -rf test-compiled
}
oneNode() {

18
npm-shrinkwrap.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "ripple-lib",
"version": "0.13.0-rc6",
"version": "0.13.0-rc7",
"npm-shrinkwrap-version": "5.4.0",
"node-version": "v0.12.7",
"dependencies": {
@@ -13,8 +13,8 @@
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.20.tgz",
"dependencies": {
"core-js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.0.1.tgz"
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.1.2.tgz"
}
}
},
@@ -23,8 +23,8 @@
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.0.7.tgz"
},
"bn.js": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.1.1.tgz"
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.1.2.tgz"
},
"es6-promisify": {
"version": "2.0.0",
@@ -81,8 +81,8 @@
}
},
"is-my-json-valid": {
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.1.tgz",
"version": "2.12.2",
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.2.tgz",
"dependencies": {
"generate-function": {
"version": "2.0.0",
@@ -99,8 +99,8 @@
}
},
"jsonpointer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-1.1.0.tgz"
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz"
},
"xtend": {
"version": "4.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "ripple-lib",
"version": "0.13.0-rc6",
"version": "0.13.0-rc7",
"license": "ISC",
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
"files": [
@@ -39,7 +39,7 @@
"babel-eslint": "^4.0.5",
"babel-loader": "^5.3.2",
"coveralls": "~2.10.0",
"eslint": "^1.2.0",
"eslint": "^1.3.0",
"eslint-plugin-flowtype": "^1.0.0",
"eventemitter2": "^0.4.14",
"flow-bin": "^0.14",

View File

@@ -16,6 +16,5 @@ module.exports = {
convertExceptions: utils.convertExceptions,
convertKeysFromSnakeCaseToCamelCase:
utils.convertKeysFromSnakeCaseToCamelCase,
promisify: utils.promisify,
isValidAddress: require('./schema-validator').isValidAddress
promisify: utils.promisify
};

View File

@@ -70,7 +70,6 @@ function schemaValidate(schemaName: string, object: any): void {
SCHEMAS = loadSchemas(path.join(__dirname, './schemas'));
module.exports = {
schemaValidate: schemaValidate,
isValidAddress: isValidAddress,
loadSchema: loadSchema,
SCHEMAS: SCHEMAS
};

View File

@@ -5,7 +5,7 @@
"items": {
"type": "object",
"properties": {
"source": {"$ref": "adjustment"},
"source": {"$ref": "maxAdjustment"},
"destination": {"$ref": "adjustment"},
"paths": {"type": "string"}
},

View File

@@ -0,0 +1,21 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "prepare",
"description": "Result of prepare function",
"type": "object",
"properties": {
"txJSON": {"type": "string"},
"instructions": {
"type": "object",
"properties": {
"fee": {"$ref": "value"},
"sequence": {"$ref": "sequence"},
"maxLedgerVersion": {"$ref": "ledgerVersion"}
},
"additionalProperties": false,
"required": ["fee", "sequence"]
}
},
"additionalProperties": false,
"required": ["txJSON", "instructions"]
}

View File

@@ -31,7 +31,6 @@ const convertExceptions = require('./common').convertExceptions;
const generateAddress = convertExceptions(common.generateAddress);
const computeLedgerHash = require('./offline/ledgerhash');
const getLedger = require('./ledger/ledger');
const isValidAddress = common.isValidAddress;
function RippleAPI(options: {}) {
common.validate.remoteOptions(options);
@@ -66,15 +65,14 @@ RippleAPI.prototype = {
sign,
submit,
computeLedgerHash,
isValidAddress,
generateAddress,
errors
};
// these are exposed only for use by unit tests; they are not part of the API
RippleAPI._PRIVATE = {
common: common,
common,
computeLedgerHash,
ledgerUtils: require('./ledger/utils'),
schemaValidator: require('./common/schema-validator')
};

View File

@@ -9,12 +9,13 @@ function parsePaths(paths) {
}
function parsePathfind(sourceAddress: string,
destinationAmount: Object, pathfindResult: Object): Object {
destinationAmount: Object, pathfindResult: Object
): Object {
return pathfindResult.alternatives.map(function(alternative) {
return {
source: {
address: sourceAddress,
amount: parseAmount(alternative.source_amount)
maxAmount: parseAmount(alternative.source_amount)
},
destination: {
address: pathfindResult.destination_account,

View File

@@ -32,10 +32,10 @@ function createOrderTransaction(account, order) {
function prepareOrderAsync(account, order, instructions, callback) {
const transaction = createOrderTransaction(account, order);
utils.createTxJSON(transaction, this.remote, instructions, callback);
utils.prepareTransaction(transaction, this.remote, instructions, callback);
}
function prepareOrder(account: string, order: Object, instructions={}) {
function prepareOrder(account: string, order: Object, instructions = {}) {
return utils.promisify(prepareOrderAsync.bind(this))(
account, order, instructions);
}

View File

@@ -14,13 +14,15 @@ function createOrderCancellationTransaction(account, sequence) {
}
function prepareOrderCancellationAsync(account, sequence, instructions,
callback) {
callback
) {
const transaction = createOrderCancellationTransaction(account, sequence);
utils.createTxJSON(transaction, this.remote, instructions, callback);
utils.prepareTransaction(transaction, this.remote, instructions, callback);
}
function prepareOrderCancellation(account: string, sequence: number,
instructions={}) {
instructions = {}
) {
return utils.promisify(prepareOrderCancellationAsync.bind(this))(
account, sequence, instructions);
}

View File

@@ -83,10 +83,10 @@ function createPaymentTransaction(account, payment) {
function preparePaymentAsync(account, payment, instructions, callback) {
const transaction = createPaymentTransaction(account, payment);
utils.createTxJSON(transaction, this.remote, instructions, callback);
utils.prepareTransaction(transaction, this.remote, instructions, callback);
}
function preparePayment(account: string, payment: Object, instructions={}) {
function preparePayment(account: string, payment: Object, instructions = {}) {
return utils.promisify(preparePaymentAsync.bind(this))(
account, payment, instructions);
}

View File

@@ -92,10 +92,10 @@ function createSettingsTransaction(account, settings) {
function prepareSettingsAsync(account, settings, instructions, callback) {
const transaction = createSettingsTransaction(account, settings);
utils.createTxJSON(transaction, this.remote, instructions, callback);
utils.prepareTransaction(transaction, this.remote, instructions, callback);
}
function prepareSettings(account: string, settings: Object, instructions={}) {
function prepareSettings(account: string, settings: Object, instructions = {}) {
return utils.promisify(prepareSettingsAsync.bind(this))(
account, settings, instructions);
}

View File

@@ -40,18 +40,18 @@ function computeSignature(txJSON, keypair) {
return keypair.signHex(signingData(txJSON));
}
function sign(txJSON: {Account: string; SigningPubKey: string,
TxnSignature: string}, secret: string):
{signedTransaction: string; id: string} {
validate.txJSON(txJSON);
function sign(txJSON: string, secret: string
): {signedTransaction: string; id: string} {
const tx = JSON.parse(txJSON);
validate.txJSON(tx);
validate.secret(secret);
const keypair = getKeyPair(secret);
if (txJSON.SigningPubKey === undefined) {
txJSON.SigningPubKey = getPublicKeyHex(keypair);
if (tx.SigningPubKey === undefined) {
tx.SigningPubKey = getPublicKeyHex(keypair);
}
txJSON.TxnSignature = computeSignature(txJSON, keypair);
const serialized = serialize(txJSON);
tx.TxnSignature = computeSignature(tx, keypair);
const serialized = serialize(tx);
return {
signedTransaction: serialized.to_hex(),
id: hashSerialization(serialized, HASH_TX_ID)

View File

@@ -35,10 +35,11 @@ function createTrustlineTransaction(account, trustline) {
function prepareTrustlineAsync(account, trustline, instructions, callback) {
const transaction = createTrustlineTransaction(account, trustline);
utils.createTxJSON(transaction, this.remote, instructions, callback);
utils.prepareTransaction(transaction, this.remote, instructions, callback);
}
function prepareTrustline(account: string, trustline: Object, instructions={}) {
function prepareTrustline(account: string, trustline: Object, instructions = {}
) {
return utils.promisify(prepareTrustlineAsync.bind(this))(
account, trustline, instructions);
}

View File

@@ -1,10 +1,11 @@
/* @flow */
'use strict';
const _ = require('lodash');
const BigNumber = require('bignumber.js');
const common = require('../common');
function setTransactionBitFlags(transaction: any, values: any, flags: any):
void {
function setTransactionBitFlags(transaction: any, values: any, flags: any
): void {
for (const flagName in flags) {
const flagValue = values[flagName];
const flagConversions = flags[flagName];
@@ -23,8 +24,22 @@ function getFeeDrops(remote) {
return remote.feeTx(feeUnits).to_text();
}
function createTxJSON(transaction: any, remote: any, instructions: any,
callback: (err: ?(typeof Error), data: {tx_json: any}) => void): void {
function formatPrepareResponse(txJSON) {
const instructions = {
fee: txJSON.Fee,
sequence: txJSON.Sequence,
maxLedgerVersion: txJSON.LastLedgerSequence
};
return {
txJSON: JSON.stringify(txJSON),
instructions: _.omit(instructions, _.isUndefined)
};
}
type Callback = (err: ?(typeof Error),
data: {txJSON: string, instructions: any}) => void;
function prepareTransaction(transaction: any, remote: any, instructions: any,
callback: Callback): void {
common.validate.instructions(instructions);
transaction.complete();
@@ -53,18 +68,18 @@ function createTxJSON(transaction: any, remote: any, instructions: any,
if (instructions.sequence !== undefined) {
txJSON.Sequence = parseInt(instructions.sequence, 10);
callback(null, txJSON);
callback(null, formatPrepareResponse(txJSON));
} else {
remote.findAccount(account).getNextSequence(function(error, sequence) {
txJSON.Sequence = sequence;
callback(null, txJSON);
callback(error, formatPrepareResponse(txJSON));
});
}
}
module.exports = {
setTransactionBitFlags: setTransactionBitFlags,
createTxJSON: createTxJSON,
common: common,
setTransactionBitFlags,
prepareTransaction,
common,
promisify: common.promisify
};

View File

@@ -49,13 +49,13 @@ const consts = {
// Maximum possible amount for non-XRP currencies using the maximum mantissa
// with maximum exponent. Corresponds to hex 0xEC6386F26FC0FFFF.
max_value: '9999999999999999e80',
// Minimum possible amount for non-XRP currencies.
min_value: '-1000000000000000e-96'
// Minimum nonzero absolute value for non-XRP currencies.
min_value: '1000000000000000e-96'
};
const MAX_XRP_VALUE = new XRPValue(1e11);
const MAX_IOU_VALUE = new IOUValue(consts.max_value);
const MIN_IOU_VALUE = new IOUValue(consts.min_value).abs();
const MIN_IOU_VALUE = new IOUValue(consts.min_value);
const bi_xns_unit = new IOUValue(1e6);

View File

@@ -28,6 +28,3 @@ exports._test = {
};
exports.types = require('./serializedtypes');
// This patches remote with legacy support for positional arguments
require('./legacy-support.js')(exports);

View File

@@ -1,201 +0,0 @@
'use strict';
const _ = require('lodash');
const log = require('./log');
function wrapRemote(Remote) {
/**
* Create options object from positional function arguments
*
* @param {Array} params function parameters
* @param {Array} args function arguments
* @return {Object} keyed options
*/
function makeOptions(command, params, args) {
const result = {};
log.warn(
'DEPRECATED: First argument to ' + command
+ ' request constructor must be an object containing'
+ ' request properties: '
+ params.join(', ')
);
if (_.isFunction(_.last(args))) {
result.callback = args.pop();
}
return _.merge(result, _.zipObject(params, args));
}
function shiftFront(list, e) {
let ix = 0;
while (list[0] === e) {
list.shift();
ix++;
}
return ix;
}
function addBackwardsCompatibility(compatParams) {
const {method,
command,
staticMethod = false,
positionals = [],
mappings = {},
hasCallback = true,
aliases = []} = compatParams;
const positionalsStartIx = shiftFront(positionals, '*');
const needsWrapping = positionals.length ||
Object.keys(mappings).length;
function wrapFunction(func) {
return function() {
const optionsArg = arguments[positionalsStartIx];
const options = {};
if (hasCallback) {
options.callback = arguments[positionalsStartIx + 1];
}
if (_.isPlainObject(optionsArg)) {
const mapped = _.transform(optionsArg, (result, v, k) => {
const to = mappings[k];
result[to !== undefined ? to : k] = v;
});
_.merge(options, mapped);
} else {
// This hack handles accountRequest type helper helpers
const commandName = positionalsStartIx ? arguments[0] : command;
const args = _.slice(arguments, positionalsStartIx);
const positionalOptions = makeOptions(commandName, positionals, args);
_.merge(options, positionalOptions);
}
// Only some `positionals` get remapped to options
const alwaysPositional = _.slice(arguments, 0, positionalsStartIx);
const args = alwaysPositional.concat([options, options.callback]);
return func.apply(this, args);
};
}
const obj = staticMethod ? Remote : Remote.prototype;
// Wrap the function and set the aliases
const wrapped = needsWrapping ? wrapFunction(obj[method]) : obj[method];
aliases.concat(method).forEach((name) => {
obj[name] = wrapped;
});
}
const remoteMethods = [
{
method: 'requestPathFindCreate',
command: 'path_find',
positionals: ['source_account',
'destination_account',
'destination_amount',
'source_currencies'],
mappings: {
src_currencies: 'source_currencies',
src_account: 'source_account',
dst_amount: 'destination_amount',
dst_account: 'destination_account'
}
},
{
method: 'requestRipplePathFind',
command: 'ripple_path_find',
positionals: ['source_account',
'destination_account',
'destination_amount',
'source_currencies'],
mappings: {
src_currencies: 'source_currencies',
src_account: 'source_account',
dst_amount: 'destination_amount',
dst_account: 'destination_account'
}
},
{
method: 'createPathFind',
aliases: ['pathFind'],
command: 'pathfind',
positionals: ['src_account',
'dst_account',
'dst_amount',
'src_currencies']
},
{
method: 'requestTransactionEntry',
command: 'transaction_entry',
positionals: ['hash', 'ledger'],
mappings: {ledger_index: 'ledger', ledger_hash: 'ledger'}
},
{
method: 'requestTransaction',
command: 'tx',
positionals: ['hash', 'ledger'],
mappings: {ledger_index: 'ledger', ledger_hash: 'ledger'},
aliases: ['requestTx']
},
{
method: 'requestBookOffers',
command: 'book_offers',
positionals: ['gets', 'pays', 'taker', 'ledger', 'limit'],
mappings: {taker_pays: 'pays', taker_gets: 'gets'}
},
{
method: 'createOrderBook',
hasCallback: false,
command: 'orderbook',
positionals: ['currency_gets', 'issuer_gets',
'currency_pays', 'issuer_pays']
},
{
method: 'requestTransactionHistory',
command: 'tx_history',
positionals: ['start'],
aliases: ['requestTxHistory']
},
{
method: 'requestWalletAccounts',
command: 'wallet_accounts',
positionals: ['seed']
},
{
method: 'requestSign',
command: 'sign',
positionals: ['secret', 'tx_json']
},
{
method: 'accountSeqCache',
command: 'accountseqcache',
positionals: ['account', 'ledger']
},
{
method: 'requestRippleBalance',
command: 'ripplebalance',
positionals: ['account', 'issuer', 'currency', 'ledger']
},
{
staticMethod: true,
method: 'accountRequest',
command: 'accountrequest(*)',
positionals: ['*', 'account', 'ledger', 'peer', 'limit', 'marker']
},
{
staticMethod: true,
method: 'accountRootRequest',
command: 'accountRootRequest(*)',
positionals: ['*', '*', 'account', 'ledger']
}
];
remoteMethods.forEach(addBackwardsCompatibility);
}
module.exports = function wrapAPI(index) {
wrapRemote(index.Remote);
};

View File

@@ -419,7 +419,7 @@ Remote.prototype.reconnect = function() {
/**
* Connect to the Ripple network
*
* @param {Function} callback
* @param {Function} [callback]
* @api public
*/
@@ -444,7 +444,7 @@ Remote.prototype.connect = function(callback) {
/**
* Disconnect from the Ripple network.
*
* @param {Function} callback
* @param {Function} [callback]
* @api public
*/
@@ -784,8 +784,8 @@ Remote.prototype.request = function(request) {
/**
* Request ping
*
* @param [String] server host
* @param [Function] callback
* @param {String} [server] host
* @param {Function} [callback]
* @return {Request} request
*/
@@ -817,7 +817,7 @@ Remote.prototype.requestPing = function(host, callback_) {
/**
* Request server_info
*
* @param [Function] callback
* @param {Function} [callback]
* @return {Request} request
*/
@@ -887,7 +887,7 @@ Remote.prototype.requestLedger = function(options, callback_) {
/**
* Request ledger_closed
*
* @param [Function] callback
* @param {Function} [callback]
* @return {Request} request
*/
@@ -900,7 +900,7 @@ Remote.prototype.requestLedgerHash = function(callback) {
/**
* Request ledger_header
*
* @param [Function] callback
* @param {Function} [callback]
* @return {Request} request
*/
@@ -916,7 +916,7 @@ Remote.prototype.requestLedgerHeader = function(callback) {
*
* Only for unit testing.
*
* @param [Function] callback
* @param {Function} [callback]
* @return {Request} request
*/
@@ -930,13 +930,13 @@ Remote.prototype.requestLedgerCurrent = function(callback) {
* Get the contents of a specified ledger
*
* @param {Object} options
* @property {Boolean} [options.binary]- Flag which determines if rippled
* returns binary or parsed JSON
* @property {String|Number} [options.ledger] - Hash or sequence of a ledger
* to get contents for
* @property {Number} [options.limit] - Number of contents to retrieve
* from the ledger
* @property {Function} callback
* @param {Boolean} [options.binary]- Flag which determines if rippled
* returns binary or parsed JSON
* @param {String|Number} [options.ledger] - Hash or sequence of a ledger
* to get contents for
* @param {Number} [options.limit] - Number of contents to retrieve
* from the ledger
* @param {Function} callback
*
* @callback
* @param {Error} error
@@ -984,8 +984,8 @@ Remote.prototype.requestLedgerData = function(options, callback) {
/**
* Request ledger_entry
*
* @param [String] type
* @param [Function] callback
* @param {String} [type]
* @param {Function} [callback]
* @return {Request} request
*/
@@ -1056,7 +1056,7 @@ Remote.prototype.requestLedgerEntry = function(type, callback_) {
* Request subscribe
*
* @param {Array} streams
* @param [Function] callback
* @param {Function} [callback]
* @return {Request} request
*/
@@ -1076,7 +1076,7 @@ Remote.prototype.requestSubscribe = function(streams, callback) {
* Request usubscribe
*
* @param {Array} streams
* @param [Function] callback
* @param {Function} [callback]
* @return {Request} request
*/
@@ -1098,7 +1098,7 @@ Remote.prototype.requestUnsubscribe = function(streams, callback) {
* @param {Object} options -
* @param {String} [options.transaction] - hash
* @param {String|Number} [options.ledger='validated'] - hash or sequence
* @param [Function] callback
* @param {Function} [callback]
* @return {Request} request
*/
@@ -1113,14 +1113,15 @@ Remote.prototype.requestTransactionEntry = function(options, callback) {
/**
* Request tx
*
* @param {Object|String} hash
* @property {String} hash.hash - Transaction hash
* @property {Boolean} [hash.binary=true] - Flag which determines if rippled
* returns binary or parsed JSON
* @param [Function] callback
* @param {Object} options -
* @property {String} [options.hash] - Transaction hash
* @property {Boolean} [options.binary=true] - Flag which determines if rippled
* returns binary or parsed JSON
* @param {Function} [callback]
* @return {Request} request
*/
Remote.prototype.requestTx =
Remote.prototype.requestTransaction = function(options, callback) {
const request = new Request(this, 'tx');
request.message.binary = options.binary !== false;
@@ -1151,17 +1152,17 @@ Remote.prototype.requestTransaction = function(options, callback) {
*
* @param {String} command - request command, e.g. 'account_lines'
* @param {Object} options - all optional
* @param {String} account - ripple address
* @param {String} peer - ripple address
* @param [String|Number] ledger identifier
* @param [Number] limit - max results per response
* @param {String} marker - start position in response paging
* @param [Function] callback
* @param {String} options.account - ripple address
* @param {String} [options.peer] - ripple address
* @param {String|Number} [options.ledger] - identifier
* @param {Number} [options.limit] - max results per response
* @param {String} [options.marker] - start position in response paging
* @param {Function} [callback]
* @return {Request}
* @throws {Error} if a marker is provided, but no ledger_index or ledger_hash
*/
Remote.accountRequest = function(command, options, callback) {
Remote.prototype._accountRequest = function(command, options, callback) {
if (options.marker) {
if (!(Number(options.ledger) > 0) && !UInt256.is_valid(options.ledger)) {
throw new Error(
@@ -1207,33 +1208,31 @@ Remote.accountRequest = function(command, options, callback) {
/**
* Request account_info
*
* @param {Object} options
* @param {String} account - ripple address
* @param {String} peer - ripple address
* @param [String|Number] ledger identifier
* @param [Function] callback
* @param {Object} options -
* @param {String} options.account - ripple address
* @param {String} [options.peer] - ripple address
* @param {String|Number} [options.ledger] - identifier
* @param {Function} [callback]
* @return {Request}
*/
Remote.prototype.requestAccountInfo = function(...args) {
const options = ['account_info', ...args];
return Remote.accountRequest.apply(this, options);
Remote.prototype.requestAccountInfo = function(options, callback) {
return this._accountRequest('account_info', options, callback);
};
/**
* Request account_currencies
*
* @param {Object} options
* @param {String} account - ripple address
* @param {String} peer - ripple address
* @param [String|Number] ledger identifier
* @param [Function] callback
* @param {String} options.account - ripple address
* @param {String} [options.peer] - ripple address
* @param {String|Number} [options.ledger] - identifier
* @param {Function} [callback]
* @return {Request}
*/
Remote.prototype.requestAccountCurrencies = function(...args) {
const options = ['account_currencies', ...args];
return Remote.accountRequest.apply(this, options);
Remote.prototype.requestAccountCurrencies = function(options, callback) {
return this._accountRequest('account_currencies', options, callback);
};
/**
@@ -1247,33 +1246,19 @@ Remote.prototype.requestAccountCurrencies = function(...args) {
* when paging to ensure a complete response
*
* @param {Object} options
* @param {String} account - ripple address
* @param {String} peer - ripple address
* @param [String|Number] ledger identifier
* @param [Number] limit - max results per response
* @param {String} marker - start position in response paging
* @param [Function] callback
* @param {String} options.account - ripple address
* @param {String} [options.peer] - ripple address
* @param {String|Number} [options.ledger] identifier
* @param {Number} [options.limit] - max results per response
* @param {String} [options.marker] - start position in response paging
* @param {Function} [callback]
* @return {Request}
*/
Remote.prototype.requestAccountLines = function(...args) {
Remote.prototype.requestAccountLines = function(options, callback) {
// XXX Does this require the server to be trusted?
// utils.assert(this.trusted);
let options = ['account_lines'];
if (_.isPlainObject(args[0])) {
options = options.concat(args);
} else {
const [account, peer, ledger] = args;
options = options.concat([
account,
ledger,
peer,
...args.slice(3)
]);
}
return Remote.accountRequest.apply(this, options);
return this._accountRequest('account_lines', options, callback);
};
/**
@@ -1287,17 +1272,16 @@ Remote.prototype.requestAccountLines = function(...args) {
* when paging to ensure a complete response
*
* @param {Object} options
* @param {String} account - ripple address
* @param [String|Number] ledger identifier
* @param [Number] limit - max results per response
* @param {String} marker - start position in response paging
* @param [Function] callback
* @param {String} options.account - ripple address
* @param {String|Number} [options.ledger] identifier
* @param {Number} [options.limit] - max results per response
* @param {String} [options.marker] - start position in response paging
* @param {Function} [callback]
* @return {Request}
*/
Remote.prototype.requestAccountOffers = function(...args) {
const options = ['account_offers', ...args];
return Remote.accountRequest.apply(this, options);
Remote.prototype.requestAccountOffers = function(options, callback) {
return this._accountRequest('account_offers', options, callback);
};
/**
@@ -1305,17 +1289,17 @@ Remote.prototype.requestAccountOffers = function(...args) {
*
* @param {Object} options
*
* @param {String} account
* @param [Number] ledger_index_min defaults to -1
* @param [Number] ledger_index_max defaults to -1
* @param [Boolean] binary, defaults to true
* @param [Boolean] parseBinary, defaults to true
* @param [Boolean] count, defaults to false
* @param [Boolean] descending, defaults to false
* @param [Number] offset, defaults to 0
* @param [Number] limit
* @param {String} options.account
* @param {Number} [options.ledger_index_min=-1]
* @param {Number} [options.ledger_index_max=-1]
* @param {Boolean} [options.binary=true]
* @param {Boolean} [options.parseBinary=true]
* @param {Boolean} [options.count=false]
* @param {Boolean} [options.descending=false]
* @param {Number} [options.offset=0]
* @param {Number} [options.limit]
*
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -1474,8 +1458,8 @@ Remote.parseBinaryLedgerData = function(ledgerData) {
* Returns a list of transactions that happened recently on the network. The
* default number of transactions to be returned is 20.
*
* @param [Number] start
* @param [Function] callback
* @param {Number} [start]
* @param {Function} [callback]
* @return {Request}
*/
@@ -1493,33 +1477,42 @@ Remote.prototype.requestTransactionHistory = function(options, callback) {
* Request book_offers
*
* @param {Object} options
* @param {Object} options.gets - taker_gets with issuer and currency
* @param {Object} options.pays - taker_pays with issuer and currency
* @param {Object} options.taker_gets - taker_gets with issuer and currency
* @param {Object} options.taker_pays - taker_pays with issuer and currency
* @param {String} [options.taker]
* @param {String} [options.ledger]
* @param {String|Number} [options.limit]
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
Remote.prototype.requestBookOffers = function(options, callback) {
const {gets, pays, taker, ledger, limit} = options;
const {taker, ledger, limit} = options;
let {taker_gets, taker_pays} = options;
if (taker_gets === undefined) {
taker_gets = options.gets;
}
if (taker_pays === undefined) {
taker_pays = options.pays;
}
const request = new Request(this, 'book_offers');
request.message.taker_gets = {
currency: Currency.json_rewrite(gets.currency, {force_hex: true})
currency: Currency.json_rewrite(taker_gets.currency, {force_hex: true})
};
if (!Currency.from_json(request.message.taker_gets.currency).is_native()) {
request.message.taker_gets.issuer = UInt160.json_rewrite(gets.issuer);
request.message.taker_gets.issuer = UInt160.json_rewrite(taker_gets.issuer);
}
request.message.taker_pays = {
currency: Currency.json_rewrite(pays.currency, {force_hex: true})
currency: Currency.json_rewrite(taker_pays.currency, {force_hex: true})
};
if (!Currency.from_json(request.message.taker_pays.currency).is_native()) {
request.message.taker_pays.issuer = UInt160.json_rewrite(pays.issuer);
request.message.taker_pays.issuer = UInt160.json_rewrite(taker_pays.issuer);
}
request.message.taker = taker ? taker : UInt160.ACCOUNT_ONE;
@@ -1543,6 +1536,7 @@ Remote.prototype.requestBookOffers = function(options, callback) {
}
request.callback(callback);
return request;
};
@@ -1550,7 +1544,7 @@ Remote.prototype.requestBookOffers = function(options, callback) {
* Request wallet_accounts
*
* @param {String} seed
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -1568,7 +1562,7 @@ Remote.prototype.requestWalletAccounts = function(options, callback) {
*
* @param {String} secret
* @param {Object} tx_json
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -1586,7 +1580,7 @@ Remote.prototype.requestSign = function(options, callback) {
/**
* Request submit
*
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -1602,7 +1596,7 @@ Remote.prototype.requestSubmit = function(callback) {
*
* This function will create and return the request, but not submit it.
*
* @param [Function] callback
* @param {Function} [callback]
* @api private
*/
@@ -1645,7 +1639,7 @@ Remote.prototype._serverPrepareSubscribe = function(server, callback_) {
* to 'ledger_hash' events. A good way to be notified of the result of this is:
* remote.on('ledger_closed', function(ledger_closed, ledger_index) { ... } );
*
* @param [Function] callback
* @param {Function} [callback]
*/
Remote.prototype.ledgerAccept =
@@ -1677,7 +1671,8 @@ Remote.prototype.requestLedgerAccept = function(callback) {
* @api private
*/
Remote.accountRootRequest = function(command, filter, options, callback) {
Remote.prototype._accountRootRequest = function(command, filter,
options, callback) {
const request = this.requestLedgerEntry('account_root');
request.accountRoot(options.account);
request.selectLedger(options.ledger);
@@ -1694,55 +1689,55 @@ Remote.accountRootRequest = function(command, filter, options, callback) {
/**
* Request account balance
*
* @param {String} account
* @param [String|Number] ledger
* @param [Function] callback
* @param {Object} options
* @param {String} options.account -
* @param {String|Number} [options.ledger] -
* @param {Function} [callback]
* @return {Request}
*/
Remote.prototype.requestAccountBalance = function(...args) {
Remote.prototype.requestAccountBalance = function(options, callback) {
function responseFilter(message) {
return Amount.from_json(message.node.Balance);
}
const options = ['account_balance', responseFilter, ...args];
return Remote.accountRootRequest.apply(this, options);
return this._accountRootRequest(
'account_balance', responseFilter, options, callback);
};
/**
* Request account flags
*
* @param {String} account
* @param [String|Number] ledger
* @param [Function] callback
* @param {Object} options
* @param {String} options.account -
* @param {String|Number} [options.ledger] -
* @param {Function} [callback]
* @return {Request}
*/
Remote.prototype.requestAccountFlags = function(...args) {
Remote.prototype.requestAccountFlags = function(options, callback) {
function responseFilter(message) {
return message.node.Flags;
}
const options = ['account_flags', responseFilter, ...args];
return Remote.accountRootRequest.apply(this, options);
return this._accountRootRequest(
'account_flags', responseFilter, options, callback);
};
/**
* Request owner count
*
* @param {String} account
* @param [String|Number] ledger
* @param [Function] callback
* @param {Object} options
* @param {String} options.account
* @param {String|Number} [options.ledger]
* @param {Function} [callback]
* @return {Request}
*/
Remote.prototype.requestOwnerCount = function(...args) {
Remote.prototype.requestOwnerCount = function(options, callback) {
function responseFilter(message) {
return message.node.OwnerCount;
}
const options = ['owner_count', responseFilter, ...args];
return Remote.accountRootRequest.apply(this, options);
return this._accountRootRequest(
'owner_count', responseFilter, options, callback);
};
/**
@@ -1792,7 +1787,7 @@ Remote.prototype.findAccount = function(accountID) {
* Create a pathfind
*
* @param {Object} options -
* @param {Function} callback -
* @param {Function} [callback] -
* @return {PathFind} -
*/
Remote.prototype.createPathFind = function(options, callback) {
@@ -1904,9 +1899,10 @@ Remote.prototype.setAccountSeq = function(account_, sequence) {
/**
* Refresh an account's sequence from server
*
* @param {String} account
* @param [String|Number] ledger
* @param [Function] callback
* @param {Object} options
* @param {String} options.account
* @param {String|Number} [options.ledger]
* @param {Function} [callback]
* @return {Request}
*/
@@ -2004,11 +2000,12 @@ Remote.prototype.requestOffer = function(options, callback) {
/**
* Get an account's balance
*
* @param {String} account
* @param [String] issuer
* @param [String] currency
* @param [String|Number] ledger
* @param [Function] callback
* @param {Object} options
* @param {String} options.account
* @param {String} [options.issuer]
* @param {String} [options.currency]
* @param {String|Number} [options.ledger]
* @param {Function} [callback]
* @return {Request}
*/
@@ -2088,7 +2085,7 @@ Remote.prepareCurrencies = function(currency) {
* Request ripple_path_find
*
* @param {Object} options
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -2117,7 +2114,7 @@ Remote.prototype.requestRipplePathFind = function(options, callback) {
* Request path_find/create
*
* @param {Object} options
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -2145,7 +2142,7 @@ Remote.prototype.requestPathFindCreate = function(options, callback) {
/**
* Request path_find/close
*
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -2166,7 +2163,7 @@ Remote.prototype.requestPathFindClose = function(callback) {
/**
* Request unl_list
*
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -2179,7 +2176,7 @@ Remote.prototype.requestUnlList = function(callback) {
*
* @param {String} address
* @param {String} comment
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -2202,7 +2199,7 @@ Remote.prototype.requestUnlAdd = function(address, comment, callback) {
* Request unl_delete
*
* @param {String} node
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -2218,7 +2215,7 @@ Remote.prototype.requestUnlDelete = function(node, callback) {
/**
* Request peers
*
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/
@@ -2231,7 +2228,7 @@ Remote.prototype.requestPeers = function(callback) {
*
* @param {String} ip
* @param {Number} port
* @param [Function] callback
* @param {Function} [callback]
* @return {Request}
*/

View File

@@ -8,6 +8,7 @@
* SerializedObject.parse() or SerializedObject.serialize().
*/
const _ = require('lodash');
const assert = require('assert');
const extend = require('extend');
const BN = require('bn.js');
@@ -404,7 +405,7 @@ exports.Quality = new SerializedType({
serialize: function(so, val) {
let value;
// if in format: amount/currency/issuer
if (val.includes('/')) {
if (_.includes(val, '/')) {
const amount = Amount.from_json(val);
if (!amount.is_valid()) {

View File

@@ -1223,29 +1223,52 @@ describe('Amount', function() {
});
});
it('from_json minimum IOU', function() {
const amt = Amount.from_json('-1e-81/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
assert.strictEqual(amt.to_text(), '-1000000000000000e-96');
it('from_json minimum positive IOU', function() {
const amt = Amount.from_json('1e-81/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
assert.strictEqual(amt.to_text(), '1000000000000000e-96');
assert.strictEqual(amt.to_text(), Amount.min_value);
});
it('from_json exceed minimum IOU', function() {
assert.throws(function() {
Amount.from_json('-1e-82/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
}, 'Exceeding min value of ' + Amount.min_value);
it('from_json smallest-absolute-value negative IOU', function() {
const amt = Amount.from_json('-1e-81/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
assert.strictEqual(amt.to_text(), '-1000000000000000e-96');
assert.strictEqual(amt.negate().to_text(), Amount.min_value);
});
it('from_json maximum IOU', function() {
it('from_json exceeding minimum positive IOU', function() {
assert.throws(function() {
Amount.from_json('1e-82/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
}, 'Exceeding min absolute value of ' + Amount.min_value);
});
it('from_json exceeding minimum-absolute-value negative IOU', function() {
assert.throws(function() {
Amount.from_json('-1e-82/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
}, 'Exceeding min absolute value of ' + Amount.min_value);
});
it('from_json maximum positive IOU', function() {
const amt = Amount.from_json('9999999999999999e80/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
assert.strictEqual(amt.to_text(), '9999999999999999e80');
});
it('from_json exceed maximum IOU', function() {
it('from_json exceed maximum positive IOU', function() {
assert.throws(function() {
Amount.from_json('9999999999999999e81/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
}, 'Exceeding max value of ' + Amount.max_value);
});
it('from_json largest-absolute-value negative IOU', function() {
const amt = Amount.from_json('-9999999999999999e80/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
assert.strictEqual(amt.to_text(), '-9999999999999999e80');
});
it('from_json exceed largest-absolute-value negative IOU', function() {
assert.throws(function() {
Amount.from_json('-9999999999999999e81/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
}, 'Exceeding max value of ' + Amount.max_value);
});
it('from_json normalize mantissa to valid max range, lost significant digits', function() {
const amt = Amount.from_json('99999999999999999999999999999999/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
assert.strictEqual(amt.to_text(), '9999999999999999e16');

View File

@@ -48,7 +48,7 @@ describe('RippleAPI', function() {
}, instructions);
return this.api.preparePayment(
address, requests.preparePayment, localInstructions).then(
_.partial(checkResult, responses.preparePayment, 'tx'));
_.partial(checkResult, responses.preparePayment, 'prepare'));
});
it('preparePayment with all options specified', function() {
@@ -58,72 +58,73 @@ describe('RippleAPI', function() {
};
return this.api.preparePayment(
address, requests.preparePaymentAllOptions, localInstructions).then(
_.partial(checkResult, responses.preparePaymentAllOptions, 'tx'));
_.partial(checkResult, responses.preparePaymentAllOptions, 'prepare'));
});
it('preparePayment without counterparty set', function() {
const localInstructions = _.defaults({sequence: 23}, instructions);
return this.api.preparePayment(
address, requests.preparePaymentNoCounterparty, localInstructions).then(
_.partial(checkResult, responses.preparePaymentNoCounterparty, 'tx'));
_.partial(checkResult, responses.preparePaymentNoCounterparty,
'prepare'));
});
it('prepareOrder - buy order', function() {
return this.api.prepareOrder(address, requests.prepareOrder, instructions)
.then(_.partial(checkResult, responses.prepareOrder, 'tx'));
.then(_.partial(checkResult, responses.prepareOrder, 'prepare'));
});
it('prepareOrder - sell order', function() {
return this.api.prepareOrder(
address, requests.prepareOrderSell, instructions).then(
_.partial(checkResult, responses.prepareOrderSell, 'tx'));
_.partial(checkResult, responses.prepareOrderSell, 'prepare'));
});
it('prepareOrderCancellation', function() {
return this.api.prepareOrderCancellation(address, 23, instructions).then(
_.partial(checkResult, responses.prepareOrderCancellation, 'tx'));
_.partial(checkResult, responses.prepareOrderCancellation, 'prepare'));
});
it('prepareTrustline - simple', function() {
return this.api.prepareTrustline(
address, requests.prepareTrustline.simple, instructions).then(
_.partial(checkResult, responses.prepareTrustline.simple, 'tx'));
_.partial(checkResult, responses.prepareTrustline.simple, 'prepare'));
});
it('prepareTrustline - complex', function() {
return this.api.prepareTrustline(
address, requests.prepareTrustline.complex, instructions).then(
_.partial(checkResult, responses.prepareTrustline.complex, 'tx'));
_.partial(checkResult, responses.prepareTrustline.complex, 'prepare'));
});
it('prepareSettings', function() {
return this.api.prepareSettings(
address, requests.prepareSettings, instructions).then(
_.partial(checkResult, responses.prepareSettings.flags, 'tx'));
_.partial(checkResult, responses.prepareSettings.flags, 'prepare'));
});
it('prepareSettings - regularKey', function() {
const regularKey = {regularKey: 'rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD'};
return this.api.prepareSettings(address, regularKey, instructions).then(
_.partial(checkResult, responses.prepareSettings.regularKey, 'tx'));
_.partial(checkResult, responses.prepareSettings.regularKey, 'prepare'));
});
it('prepareSettings - flag set', function() {
const settings = {requireDestinationTag: true};
return this.api.prepareSettings(address, settings, instructions).then(
_.partial(checkResult, responses.prepareSettings.flagSet, 'tx'));
_.partial(checkResult, responses.prepareSettings.flagSet, 'prepare'));
});
it('prepareSettings - flag clear', function() {
const settings = {requireDestinationTag: false};
return this.api.prepareSettings(address, settings, instructions).then(
_.partial(checkResult, responses.prepareSettings.flagClear, 'tx'));
_.partial(checkResult, responses.prepareSettings.flagClear, 'prepare'));
});
it('prepareSettings - string field clear', function() {
const settings = {walletLocator: null};
return this.api.prepareSettings(address, settings, instructions).then(
_.partial(checkResult, responses.prepareSettings.fieldClear, 'tx'));
_.partial(checkResult, responses.prepareSettings.fieldClear, 'prepare'));
});
it('prepareSettings - integer field clear', function() {
@@ -131,19 +132,20 @@ describe('RippleAPI', function() {
return this.api.prepareSettings(address, settings, instructions)
.then(data => {
assert(data);
assert.strictEqual(data.WalletSize, 0);
assert.strictEqual(JSON.parse(data.txJSON).WalletSize, 0);
});
});
it('prepareSettings - set transferRate', function() {
const settings = {transferRate: 1};
return this.api.prepareSettings(address, settings, instructions).then(
_.partial(checkResult, responses.prepareSettings.setTransferRate, 'tx'));
_.partial(checkResult, responses.prepareSettings.setTransferRate,
'prepare'));
});
it('sign', function() {
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
const result = this.api.sign(requests.sign, secret);
const result = this.api.sign(requests.sign.txJSON, secret);
assert.deepEqual(result, responses.sign);
schemaValidator.schemaValidate('sign', result);
});
@@ -581,7 +583,7 @@ describe('RippleAPI', function() {
.then(response => {
const ledger = _.assign({}, response,
{parentCloseTime: response.closeTime});
const hash = this.api.computeLedgerHash(ledger);
const hash = RippleAPI._PRIVATE.computeLedgerHash(ledger);
assert.strictEqual(hash,
'E6DB7365949BF9814D76BCC730B01818EB9136A89DB224F3F9F5AAE4569D758E');
});
@@ -775,55 +777,36 @@ describe('RippleAPI - offline', function() {
maxLedgerVersion: 8820051,
fee: '0.000012'
};
return api.prepareSettings(address, settings, instructions).then(txJSON => {
assert.deepEqual(txJSON, responses.prepareSettings.flags);
assert.deepEqual(api.sign(txJSON, secret), responses.sign);
return api.prepareSettings(address, settings, instructions).then(data => {
assert.deepEqual(data, responses.prepareSettings.flags);
assert.deepEqual(api.sign(data.txJSON, secret), responses.sign);
});
});
it('computeLedgerHash', function() {
const api = new RippleAPI();
const header = requests.computeLedgerHash.header;
const ledgerHash = api.computeLedgerHash(header);
const ledgerHash = RippleAPI._PRIVATE.computeLedgerHash(header);
assert.strictEqual(ledgerHash,
'F4D865D83EB88C1A1911B9E90641919A1314F36E1B099F8E95FE3B7C77BE3349');
});
it('computeLedgerHash - with transactions', function() {
const api = new RippleAPI();
const header = _.omit(requests.computeLedgerHash.header,
'transactionHash');
header.rawTransactions = JSON.stringify(
requests.computeLedgerHash.transactions);
const ledgerHash = api.computeLedgerHash(header);
const ledgerHash = RippleAPI._PRIVATE.computeLedgerHash(header);
assert.strictEqual(ledgerHash,
'F4D865D83EB88C1A1911B9E90641919A1314F36E1B099F8E95FE3B7C77BE3349');
});
it('computeLedgerHash - incorrent transaction_hash', function() {
const api = new RippleAPI();
const header = _.assign({}, requests.computeLedgerHash.header,
{transactionHash:
'325EACC5271322539EEEC2D6A5292471EF1B3E72AE7180533EFC3B8F0AD435C9'});
header.rawTransactions = JSON.stringify(
requests.computeLedgerHash.transactions);
assert.throws(() => api.computeLedgerHash(header));
});
it('isValidAddress - valid', function() {
const api = new RippleAPI();
assert(api.isValidAddress(address));
});
it('isValidAddress - invalid', function() {
const api = new RippleAPI();
assert(!api.isValidAddress(address.slice(0, -1) + 'a'));
});
it('isValidAddress - invalid - hex representation', function() {
const api = new RippleAPI();
const hex = '6e3efa86a5eb0a3c5dc9beb3a204783bb00e1913';
assert(!api.isValidAddress(hex));
assert.throws(() => RippleAPI._PRIVATE.computeLedgerHash(header));
});
/* eslint-disable no-unused-vars */

View File

@@ -1,9 +1,8 @@
{
"Flags": 0,
"TransactionType": "AccountSet",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"Domain": "726970706C652E636F6D",
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Domain\":\"726970706C652E636F6D\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -2,7 +2,7 @@
{
"source": {
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"amount": {
"maxAmount": {
"currency": "USD",
"value": "0.000001002",
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo"

View File

@@ -2,7 +2,7 @@
{
"source": {
"address": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"amount": {
"maxAmount": {
"currency": "XRP",
"value": "0.000002"
}

View File

@@ -2,7 +2,7 @@
{
"source": {
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"amount": {
"maxAmount": {
"currency": "JPY",
"value": "0.1117218827811721",
"counterparty": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
@@ -21,7 +21,7 @@
{
"source": {
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"amount": {
"maxAmount": {
"currency": "USD",
"value": "0.001002",
"counterparty": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
@@ -40,7 +40,7 @@
{
"source": {
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"amount": {
"maxAmount": {
"currency": "XRP",
"value": "0.207669"
}

View File

@@ -1,9 +1,8 @@
{
"Flags": 0,
"TransactionType": "OfferCancel",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"OfferSequence": 23,
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":0,\"TransactionType\":\"OfferCancel\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":23,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,14 +1,8 @@
{
"Flags": 655360,
"TransactionType": "OfferCreate",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"TakerGets": {
"value": "10.1",
"currency": "USD",
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
},
"TakerPays": "2000000",
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
}
"txJSON": "{\"Flags\":655360,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"TakerPays\":\"2000000\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,14 +1,8 @@
{
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"Fee": "12",
"Flags": 131072,
"LastLedgerSequence": 8820051,
"Sequence": 23,
"TakerGets": "2000000",
"TakerPays": {
"currency": "USD",
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
"value": "10.1"
},
"TransactionType": "OfferCreate"
"txJSON": "{\"Flags\":131072,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,22 +1,8 @@
{
"Flags": 458752,
"TransactionType": "Payment",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"Amount": "10000",
"InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
"SourceTag": 14,
"DestinationTag": 58,
"Memos": [
{
"Memo": {
"MemoType": "74657374",
"MemoFormat": "706C61696E2F74657874",
"MemoData": "7465787465642064617461"
}
}
],
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":458752,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\",\"MemoData\":\"7465787465642064617461\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,52 +1,8 @@
{
"Flags": 458752,
"TransactionType": "Payment",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"Amount": {
"value": "0.01",
"currency": "LTC",
"issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo"
},
"InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
"SourceTag": 14,
"DestinationTag": 58,
"Paths": [
[
{
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"currency": "USD",
"type_hex": "0000000000000031"
},
{
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
"currency": "LTC",
"type_hex": "0000000000000030"
},
{
"account": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
"currency": "LTC",
"type_hex": "0000000000000031"
}
]
],
"Memos": [
{
"Memo": {
"MemoType": "74657374",
"MemoFormat": "706C61696E2F74657874",
"MemoData": "7465787465642064617461"
}
}
],
"SendMax": {
"value": "0.01",
"currency": "USD",
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
},
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
}
"txJSON": "{\"Flags\":458752,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"LTC\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\",\"MemoData\":\"7465787465642064617461\"}}],\"SendMax\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"},\"Paths\":[[{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\",\"type_hex\":\"0000000000000031\"},{\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\",\"type_hex\":\"0000000000000030\"},{\"account\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\",\"type_hex\":\"0000000000000031\"}]],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,19 +1,8 @@
{
"Flags": 0,
"TransactionType": "Payment",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"Amount": {
"value": "0.01",
"currency": "USD",
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
},
"LastLedgerSequence": 8820051,
"SendMax": {
"currency": "USD",
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
"value": "0.01"
},
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":0,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"SendMax\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,9 +1,8 @@
{
"Flags": 0,
"TransactionType": "AccountSet",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"WalletLocator": "0",
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
}
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"WalletLocator\":\"0\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,9 +1,8 @@
{
"Flags": 0,
"TransactionType": "AccountSet",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"ClearFlag": 1,
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"ClearFlag\":1,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,9 +1,8 @@
{
"Flags": 0,
"TransactionType": "AccountSet",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"SetFlag": 1,
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"SetFlag\":1,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,9 +1,8 @@
{
"Flags": 0,
"TransactionType": "SetRegularKey",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"RegularKey": "rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD",
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":0,\"TransactionType\":\"SetRegularKey\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"RegularKey\":\"rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,9 +1,8 @@
{
"Flags": 0,
"TransactionType": "AccountSet",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"TransferRate": 1000000000,
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
}
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TransferRate\":1000000000,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,10 +1,8 @@
{
"Flags": 1048576,
"TransactionType": "AccountSet",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"Domain": "726970706C652E636F6D",
"Flags": 0,
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Domain\":\"726970706C652E636F6D\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,13 +1,8 @@
{
"Flags": 0,
"TransactionType": "TrustSet",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"LimitAmount": {
"value": "0.1",
"currency": "BTC",
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
},
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":0,\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"value\":\"0.1\",\"currency\":\"BTC\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -1,15 +1,8 @@
{
"Flags": 2228224,
"TransactionType": "TrustSet",
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"LimitAmount": {
"value": "10000",
"currency": "USD",
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
},
"QualityIn": 910000000,
"QualityOut": 870000000,
"LastLedgerSequence": 8820051,
"Fee": "12",
"Sequence": 23
"txJSON": "{\"Flags\":2228224,\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"value\":\"10000\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"QualityIn\":910000000,\"QualityOut\":870000000,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
"instructions": {
"fee": "12",
"sequence": 23,
"maxLedgerVersion": 8820051
}
}

View File

@@ -3,11 +3,11 @@
const _ = require('lodash');
const hashes = require('../../hashes');
const addresses = require('../../addresses');
const SerializedObject = require('../../../../src/core').SerializedObject;
const SerializedObject = require('ripple-lib').SerializedObject;
const AccountSet = require('./tx/account-set.json');
const NotFound = require('./tx/not-found.json');
module.exports = function(request, options={}) {
module.exports = function(request, options = {}) {
_.defaults(options, {
memos: [{
Memo: {

View File

@@ -1263,39 +1263,27 @@ describe('Remote', function() {
});
});
it('Construct account_currencies request', function() {
let request = remote.requestAccountCurrencies({
const request = remote.requestAccountCurrencies({
account: ADDRESS
}, lodash.noop);
assert.strictEqual(request.message.command, 'account_currencies');
assert.strictEqual(request.message.account, ADDRESS);
assert.strictEqual(request.requested, true);
Log.setEngine(Log.engines.none);
request = remote.requestAccountCurrencies(ADDRESS, lodash.noop);
assert.strictEqual(request.message.command, 'account_currencies');
assert.strictEqual(request.message.account, ADDRESS);
assert.strictEqual(request.requested, true);
});
it('Construct account_info request', function() {
let request = remote.requestAccountInfo({
const request = remote.requestAccountInfo({
account: ADDRESS
}, lodash.noop);
assert.strictEqual(request.message.command, 'account_info');
assert.strictEqual(request.message.account, ADDRESS);
assert.strictEqual(request.requested, true);
Log.setEngine(Log.engines.none);
request = remote.requestAccountInfo(ADDRESS, lodash.noop);
assert.strictEqual(request.message.command, 'account_info');
assert.strictEqual(request.message.account, ADDRESS);
assert.strictEqual(request.requested, true);
});
it('Construct account_info request -- with ledger index', function() {
let request = remote.requestAccountInfo({
const request = remote.requestAccountInfo({
account: ADDRESS,
ledger: 9592219
}, lodash.noop);
@@ -1303,14 +1291,6 @@ describe('Remote', function() {
assert.strictEqual(request.message.account, ADDRESS);
assert.strictEqual(request.message.ledger_index, 9592219);
assert.strictEqual(request.requested, true);
Log.setEngine(Log.engines.none);
request = remote.requestAccountInfo(ADDRESS, 9592219, lodash.noop);
assert.strictEqual(request.requested, true);
assert.strictEqual(request.message.command, 'account_info');
assert.strictEqual(request.message.account, ADDRESS);
assert.strictEqual(request.message.ledger_index, 9592219);
});
it('Construct account_info request -- with ledger hash', function() {
@@ -1362,7 +1342,7 @@ describe('Remote', function() {
assert.strictEqual(request.message.command, 'ledger_entry');
assert.strictEqual(request.message.account_root, ADDRESS);
assert.strictEqual(request.message.ledger_index, 'validated');
assert.strictEqual(request.requested, true);
assert.strictEqual(request.requested, true);
});
it('Construct account flags request', function() {
@@ -1372,14 +1352,7 @@ describe('Remote', function() {
assert.strictEqual(request.requested, true);
});
it('Construct account owner count request', function() {
let request = remote.requestOwnerCount({account: ADDRESS}, lodash.noop);
assert.strictEqual(request.message.command, 'ledger_entry');
assert.strictEqual(request.message.account_root, ADDRESS);
assert.strictEqual(request.requested, true);
Log.setEngine(Log.engines.none);
request = remote.requestOwnerCount(ADDRESS, lodash.noop);
const request = remote.requestOwnerCount({account: ADDRESS}, lodash.noop);
assert.strictEqual(request.message.command, 'ledger_entry');
assert.strictEqual(request.message.account_root, ADDRESS);
assert.strictEqual(request.requested, true);
@@ -1421,7 +1394,7 @@ describe('Remote', function() {
assert.strictEqual(request.requested, true);
});
it('Construct account_lines request -- with limit and marker', function() {
let request = remote.requestAccountLines({
const request = remote.requestAccountLines({
account: ADDRESS,
limit: 100,
marker: PAGING_MARKER,
@@ -1436,26 +1409,6 @@ describe('Remote', function() {
ledger_index: 9592219
});
assert.strictEqual(request.requested, true);
Log.setEngine(Log.engines.none);
request = remote.requestAccountLines(
ADDRESS,
null,
9592219,
100,
PAGING_MARKER,
lodash.noop
);
assert.deepEqual(request.message, {
command: 'account_lines',
id: undefined,
account: ADDRESS,
limit: 100,
marker: PAGING_MARKER,
ledger_index: 9592219
});
assert.strictEqual(request.requested, true);
});
it('Construct account_lines request -- with min limit', function() {
assert.strictEqual(remote.requestAccountLines({
@@ -1668,11 +1621,11 @@ describe('Remote', function() {
it('Construct book_offers request -- with ledger and limit', function() {
const request = remote.requestBookOffers({
taker_gets: {
gets: {
currency: 'USD',
issuer: ADDRESS
},
taker_pays: {
pays: {
currency: 'XRP'
},
ledger: LEDGER_HASH,
@@ -1926,10 +1879,10 @@ describe('Remote', function() {
it('Construct ripple_path_find request', function() {
const request = remote.requestRipplePathFind({
src_account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
dst_account: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6',
dst_amount: '1/USD/rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
src_currencies: [{
source_account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
destination_account: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6',
destination_amount: '1/USD/rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
source_currencies: [{
currency: 'BTC', issuer: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6'
}]
});
@@ -1974,10 +1927,10 @@ describe('Remote', function() {
it('Construct path_find create request', function() {
const request = remote.requestPathFindCreate({
src_account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
dst_account: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6',
dst_amount: '1/USD/rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
src_currencies: [{
source_account: 'rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
destination_account: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6',
destination_amount: '1/USD/rGr9PjmVe7MqEXTSbd3njhgJc2s5vpHV54',
source_currencies: [{
currency: 'BTC', issuer: 'rwxBjBC9fPzyQ9GgPZw6YYLNeRTSx5c2W6'
}]
});

View File

@@ -1,7 +1,7 @@
'use strict';
/* eslint-disable max-len */
const _ = require('lodash');
const assert = require('assert-diff');
const lodash = require('lodash');
const ripple = require('ripple-lib');
@@ -75,11 +75,11 @@ function makeTests(uIntType) {
case undefined:
switch (test.outputMethod) {
case 'to_bytes':
test.expected = Array(rippleType.width).fill(0);
test.expected = _.fill(Array(rippleType.width), 0);
break;
case 'to_json':
case 'to_hex':
test.expected = Array(rippleType.width * 2).fill(0).join('');
test.expected = _.fill(Array(rippleType.width * 2), 0).join('');
break;
}
}