mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-16 18:35:50 +00:00
Compare commits
39 Commits
0.13.0-rc5
...
0.13.0-rc8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ad03ca873 | ||
|
|
138914384e | ||
|
|
50acc4c708 | ||
|
|
b5f8ba4817 | ||
|
|
a53249ccd7 | ||
|
|
fb1669b2b3 | ||
|
|
b88e9370c6 | ||
|
|
a13bfae714 | ||
|
|
877c6bbb2a | ||
|
|
fae5c74487 | ||
|
|
255332ea2e | ||
|
|
15c0e6db19 | ||
|
|
2b600a1e4e | ||
|
|
297fb2483d | ||
|
|
5049822415 | ||
|
|
e3787e0f4f | ||
|
|
683199044b | ||
|
|
4f3c3e9f66 | ||
|
|
fc0240c06b | ||
|
|
6bfa284bac | ||
|
|
dfee9bc578 | ||
|
|
0838a0e865 | ||
|
|
5f61d80e2d | ||
|
|
c4fa4c237c | ||
|
|
44d00d5ef4 | ||
|
|
d4d3efcb65 | ||
|
|
f23e105240 | ||
|
|
5a396a7060 | ||
|
|
513632299f | ||
|
|
0d40558f1e | ||
|
|
1ccbaf6776 | ||
|
|
ba6c703163 | ||
|
|
3b9eb02bbb | ||
|
|
bca7382015 | ||
|
|
67672bd389 | ||
|
|
232017d9a2 | ||
|
|
23653f67f0 | ||
|
|
e3b688d1dd | ||
|
|
a94b21ca3c |
@@ -1,5 +1,6 @@
|
||||
##0.13.0 (release candidate)
|
||||
|
||||
+ [Fix: Emit error events and return error on pathfind](https://github.com/ripple/ripple-lib/commit/1ccbaf677631a1944eb05d90f7afc5f3690a03dd)
|
||||
+ [Deprecate core and remove snake case method copying](https://github.com/ripple/ripple-lib/commit/fb8dc44ec1d49bb05cd0cdbe6dd4ab211195868a)
|
||||
+ Add new RippleAPI interface
|
||||
- [RippleAPI README and samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples)
|
||||
|
||||
10
bin/ci.sh
10
bin/ci.sh
@@ -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
18
npm-shrinkwrap.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ripple-lib",
|
||||
"version": "0.13.0-rc5",
|
||||
"version": "0.13.0-rc8",
|
||||
"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",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ripple-lib",
|
||||
"version": "0.13.0-rc5",
|
||||
"version": "0.13.0-rc8",
|
||||
"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",
|
||||
|
||||
@@ -77,13 +77,13 @@ ApiError.prototype = new RippleError();
|
||||
ApiError.prototype.name = 'ApiError';
|
||||
|
||||
module.exports = {
|
||||
ValidationError: ValidationError,
|
||||
NetworkError: NetworkError,
|
||||
TransactionError: TransactionError,
|
||||
RippledNetworkError: RippledNetworkError,
|
||||
NotFoundError: NotFoundError,
|
||||
MissingLedgerHistoryError: MissingLedgerHistoryError,
|
||||
TimeOutError: TimeOutError,
|
||||
ApiError: ApiError,
|
||||
RippleError: RippleError
|
||||
ValidationError,
|
||||
NetworkError,
|
||||
TransactionError,
|
||||
RippledNetworkError,
|
||||
NotFoundError,
|
||||
MissingLedgerHistoryError,
|
||||
TimeOutError,
|
||||
ApiError,
|
||||
RippleError
|
||||
};
|
||||
|
||||
@@ -12,9 +12,9 @@ module.exports = {
|
||||
generateAddress: utils.generateAddress,
|
||||
composeAsync: utils.composeAsync,
|
||||
wrapCatch: utils.wrapCatch,
|
||||
convertErrors: utils.convertErrors,
|
||||
convertExceptions: utils.convertExceptions,
|
||||
convertKeysFromSnakeCaseToCamelCase:
|
||||
utils.convertKeysFromSnakeCaseToCamelCase,
|
||||
promisify: utils.promisify,
|
||||
isValidAddress: require('./schema-validator').isValidAddress
|
||||
promisify: utils.promisify
|
||||
};
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"source": {"$ref": "adjustment"},
|
||||
"source": {"$ref": "maxAdjustment"},
|
||||
"destination": {"$ref": "adjustment"},
|
||||
"paths": {"type": "string"}
|
||||
},
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"load": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"job_types": {
|
||||
"jobTypes": {
|
||||
"type": "array",
|
||||
"items": {"type": "object"}
|
||||
},
|
||||
|
||||
21
src/api/common/schemas/prepare.json
Normal file
21
src/api/common/schemas/prepare.json
Normal 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"]
|
||||
}
|
||||
10
src/api/common/schemas/remote-options.json
Normal file
10
src/api/common/schemas/remote-options.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "remote-options",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"trace": {"type": "boolean"},
|
||||
"servers": {"type": "array", "items": {"type": "string", "format": "uri"}}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -66,6 +66,16 @@ function composeAsync(wrapper: Wrapper, callback: Callback): Callback {
|
||||
};
|
||||
}
|
||||
|
||||
function convertErrors(callback: () => void): () => void {
|
||||
return function(error, data) {
|
||||
if (error && !(error instanceof errors.RippleError)) {
|
||||
callback(new errors.RippleError(error));
|
||||
} else {
|
||||
callback(error, data);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function convertExceptions<T>(f: () => T): () => T {
|
||||
return function() {
|
||||
try {
|
||||
@@ -105,6 +115,7 @@ module.exports = {
|
||||
composeAsync,
|
||||
wrapCatch,
|
||||
convertExceptions,
|
||||
convertErrors,
|
||||
convertKeysFromSnakeCaseToCamelCase,
|
||||
promisify
|
||||
};
|
||||
|
||||
@@ -76,5 +76,6 @@ module.exports = {
|
||||
getTransactionOptions: _.partial(validateOptions, 'transaction-options'),
|
||||
getLedgerOptions: _.partial(validateOptions, 'ledger-options'),
|
||||
options: _.partial(validateOptions, 'options'),
|
||||
remoteOptions: _.partial(schemaValidate, 'remote-options'),
|
||||
instructions: _.partial(schemaValidate, 'instructions')
|
||||
};
|
||||
|
||||
@@ -31,9 +31,9 @@ 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);
|
||||
const _options = _.assign({}, options, {automatic_resubmission: false});
|
||||
this.remote = new common.core.Remote(_options);
|
||||
}
|
||||
@@ -65,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')
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ const utils = require('./utils');
|
||||
const removeUndefined = require('./parse/utils').removeUndefined;
|
||||
const validate = utils.common.validate;
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
|
||||
type AccountData = {
|
||||
Sequence: number,
|
||||
@@ -66,10 +67,10 @@ function getAccountInfoAsync(account: string, options: AccountInfoOptions,
|
||||
};
|
||||
|
||||
this.remote.requestAccountInfo(request,
|
||||
composeAsync(formatAccountInfo, callback));
|
||||
composeAsync(formatAccountInfo, convertErrors(callback)));
|
||||
}
|
||||
|
||||
function getAccountInfo(account: string, options: AccountInfoOptions={}
|
||||
function getAccountInfo(account: string, options: AccountInfoOptions = {}
|
||||
): Promise<AccountInfoResponse> {
|
||||
return utils.promisify(getAccountInfoAsync).call(this, account, options);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ const utils = require('./utils');
|
||||
const getTrustlines = require('./trustlines');
|
||||
const validate = utils.common.validate;
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
|
||||
function getTrustlineBalanceAmount(trustline) {
|
||||
return {
|
||||
@@ -39,10 +40,10 @@ function getBalancesAsync(account, options, callback) {
|
||||
async.parallel({
|
||||
xrp: _.partial(utils.getXRPBalance, this.remote, account, ledgerVersion),
|
||||
trustlines: _.partial(getTrustlinesAsync.bind(this), account, options)
|
||||
}, composeAsync(formatBalances, callback));
|
||||
}, composeAsync(formatBalances, convertErrors(callback)));
|
||||
}
|
||||
|
||||
function getBalances(account: string, options={}) {
|
||||
function getBalances(account: string, options = {}) {
|
||||
return utils.promisify(getBalancesAsync).call(this, account, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
const utils = require('./utils');
|
||||
const validate = utils.common.validate;
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
const parseLedger = require('./parse/ledger');
|
||||
|
||||
function getLedgerAsync(options, callback) {
|
||||
@@ -16,10 +17,11 @@ function getLedgerAsync(options, callback) {
|
||||
};
|
||||
|
||||
this.remote.requestLedger(request,
|
||||
composeAsync(response => parseLedger(response.ledger), callback));
|
||||
composeAsync(response => parseLedger(response.ledger),
|
||||
convertErrors(callback)));
|
||||
}
|
||||
|
||||
function getLedger(options={}) {
|
||||
function getLedger(options = {}) {
|
||||
return utils.promisify(getLedgerAsync).call(this, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
const _ = require('lodash');
|
||||
const async = require('async');
|
||||
const utils = require('./utils');
|
||||
const parseOrderbookOrder = require('./parse/orderbook-order');
|
||||
const validate = utils.common.validate;
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
const parseOrderbookOrder = require('./parse/orderbook-order');
|
||||
|
||||
// account is to specify a "perspective", which affects which unfunded offers
|
||||
// are returned
|
||||
@@ -18,7 +19,7 @@ function getBookOffers(remote, account, ledgerVersion, limit,
|
||||
ledger: ledgerVersion || 'validated',
|
||||
limit: limit,
|
||||
taker: account
|
||||
}), composeAsync(data => data.offers, callback));
|
||||
}), composeAsync(data => data.offers, convertErrors(callback)));
|
||||
}
|
||||
|
||||
function isSameIssue(a, b) {
|
||||
@@ -77,7 +78,7 @@ function getOrderbookAsync(account, orderbook, options, callback) {
|
||||
callback));
|
||||
}
|
||||
|
||||
function getOrderbook(account: string, orderbook: Object, options={}) {
|
||||
function getOrderbook(account: string, orderbook: Object, options = {}) {
|
||||
return utils.promisify(getOrderbookAsync).call(this,
|
||||
account, orderbook, options);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ const _ = require('lodash');
|
||||
const utils = require('./utils');
|
||||
const validate = utils.common.validate;
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
const parseAccountOrder = require('./parse/account-order');
|
||||
|
||||
function requestAccountOffers(remote, address, ledgerVersion, options,
|
||||
marker, limit, callback
|
||||
function requestAccountOffers(remote, address, ledgerVersion, marker, limit,
|
||||
callback
|
||||
) {
|
||||
remote.requestAccountOffers({
|
||||
account: address,
|
||||
@@ -18,7 +19,7 @@ function requestAccountOffers(remote, address, ledgerVersion, options,
|
||||
composeAsync((data) => ({
|
||||
marker: data.marker,
|
||||
results: data.offers.map(_.partial(parseAccountOrder, address))
|
||||
}), callback));
|
||||
}), convertErrors(callback)));
|
||||
}
|
||||
|
||||
function getOrdersAsync(account, options, callback) {
|
||||
@@ -28,13 +29,13 @@ function getOrdersAsync(account, options, callback) {
|
||||
const ledgerVersion = options.ledgerVersion
|
||||
|| this.remote.getLedgerSequence();
|
||||
const getter = _.partial(requestAccountOffers, this.remote, account,
|
||||
ledgerVersion, options);
|
||||
ledgerVersion);
|
||||
utils.getRecursive(getter, options.limit,
|
||||
composeAsync((orders) => _.sortBy(orders,
|
||||
(order) => order.properties.sequence), callback));
|
||||
}
|
||||
|
||||
function getOrders(account: string, options={}) {
|
||||
function getOrders(account: string, options = {}) {
|
||||
return utils.promisify(getOrdersAsync).call(this, account, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -8,6 +8,7 @@ const validate = utils.common.validate;
|
||||
const parsePathfind = require('./parse/pathfind');
|
||||
const NotFoundError = utils.common.errors.NotFoundError;
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
|
||||
type PathFindParams = {
|
||||
src_currencies?: Array<string>, src_account: string, dst_amount: string,
|
||||
@@ -47,7 +48,7 @@ function requestPathFind(remote, pathfind: PathFind, callback) {
|
||||
}
|
||||
|
||||
remote.createPathFind(params,
|
||||
composeAsync(_.partial(addParams, params), callback));
|
||||
composeAsync(_.partial(addParams, params), convertErrors(callback)));
|
||||
}
|
||||
|
||||
function addDirectXrpPath(paths, xrpBalance) {
|
||||
@@ -83,7 +84,8 @@ function formatResponse(pathfind, paths) {
|
||||
const address = pathfind.source.address;
|
||||
return parsePathfind(address, pathfind.destination.amount, paths);
|
||||
}
|
||||
if (!_.includes(paths.destination_currencies,
|
||||
if (paths.destination_currencies !== undefined &&
|
||||
!_.includes(paths.destination_currencies,
|
||||
pathfind.destination.amount.currency)) {
|
||||
throw new NotFoundError('No paths found. ' +
|
||||
'The destination_account does not accept ' +
|
||||
|
||||
@@ -6,6 +6,7 @@ const validate = utils.common.validate;
|
||||
const parseFields = require('./parse/fields');
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
const AccountFlags = utils.common.constants.AccountFlags;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
|
||||
function parseFlags(value) {
|
||||
const settings = {};
|
||||
@@ -34,10 +35,10 @@ function getSettingsAsync(account, options, callback) {
|
||||
};
|
||||
|
||||
this.remote.requestAccountInfo(request,
|
||||
composeAsync(formatSettings, callback));
|
||||
composeAsync(formatSettings, convertErrors(callback)));
|
||||
}
|
||||
|
||||
function getSettings(account: string, options={}) {
|
||||
function getSettings(account: string, options = {}) {
|
||||
return utils.promisify(getSettingsAsync).call(this, account, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ const utils = require('./utils');
|
||||
const parseTransaction = require('./parse/transaction');
|
||||
const validate = utils.common.validate;
|
||||
const errors = utils.common.errors;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
const RippleError = require('../../core/rippleerror').RippleError;
|
||||
|
||||
import type {Remote} from '../../core/remote';
|
||||
@@ -69,9 +70,9 @@ function getTransactionAsync(identifier: string, options: TransactionOptions,
|
||||
} else if (!error && tx && !isTransactionInRange(tx, options)) {
|
||||
callback(new errors.NotFoundError('Transaction not found'));
|
||||
} else if (error) {
|
||||
callback(error);
|
||||
convertErrors(callback)(error);
|
||||
} else if (!tx) {
|
||||
callback(new Error('Internal error'));
|
||||
callback(new errors.ApiError('Internal error'));
|
||||
} else {
|
||||
callback(error, parseTransaction(tx));
|
||||
}
|
||||
@@ -85,7 +86,7 @@ function getTransactionAsync(identifier: string, options: TransactionOptions,
|
||||
}
|
||||
|
||||
function getTransaction(identifier: string,
|
||||
options: TransactionOptions={}
|
||||
options: TransactionOptions = {}
|
||||
): Promise<GetTransactionResponse> {
|
||||
return utils.promisify(getTransactionAsync).call(this, identifier, options);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ const parseTransaction = require('./parse/transaction');
|
||||
const getTransaction = require('./transaction');
|
||||
const validate = utils.common.validate;
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
|
||||
function parseAccountTxTransaction(tx) {
|
||||
// rippled uses a different response format for 'account_tx' than 'tx'
|
||||
@@ -55,6 +56,17 @@ function orderFilter(options, tx) {
|
||||
utils.compareTransactions(tx, options.startTx) < 0);
|
||||
}
|
||||
|
||||
function formatPartialResponse(address, options, data) {
|
||||
return {
|
||||
marker: data.marker,
|
||||
results: data.transactions
|
||||
.filter((tx) => tx.validated)
|
||||
.map(parseAccountTxTransaction)
|
||||
.filter(_.partial(transactionFilter, address, options))
|
||||
.filter(_.partial(orderFilter, options))
|
||||
};
|
||||
}
|
||||
|
||||
function getAccountTx(remote, address, options, marker, limit, callback) {
|
||||
const params = {
|
||||
account: address,
|
||||
@@ -66,16 +78,9 @@ function getAccountTx(remote, address, options, marker, limit, callback) {
|
||||
marker: marker
|
||||
};
|
||||
|
||||
remote.requestAccountTx(params, (error, data) => {
|
||||
return error ? callback(error) : callback(null, {
|
||||
marker: data.marker,
|
||||
results: data.transactions
|
||||
.filter((tx) => tx.validated)
|
||||
.map(parseAccountTxTransaction)
|
||||
.filter(_.partial(transactionFilter, address, options))
|
||||
.filter(_.partial(orderFilter, options))
|
||||
});
|
||||
});
|
||||
remote.requestAccountTx(params,
|
||||
composeAsync(_.partial(formatPartialResponse, address, options),
|
||||
convertErrors(callback)));
|
||||
}
|
||||
|
||||
function checkForLedgerGaps(remote, options, transactions) {
|
||||
@@ -131,7 +136,7 @@ function getTransactionsAsync(account, options, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
function getTransactions(account: string, options={}) {
|
||||
function getTransactions(account: string, options = {}) {
|
||||
return utils.promisify(getTransactionsAsync).call(this, account, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,22 @@
|
||||
const _ = require('lodash');
|
||||
const utils = require('./utils');
|
||||
const validate = utils.common.validate;
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
const parseAccountTrustline = require('./parse/account-trustline');
|
||||
|
||||
function currencyFilter(currency, trustline) {
|
||||
return currency === null || trustline.specification.currency === currency;
|
||||
}
|
||||
|
||||
function formatResponse(options, data) {
|
||||
return {
|
||||
marker: data.marker,
|
||||
results: data.lines.map(parseAccountTrustline)
|
||||
.filter(_.partial(currencyFilter, options.currency || null))
|
||||
};
|
||||
}
|
||||
|
||||
function getAccountLines(remote, address, ledgerVersion, options, marker, limit,
|
||||
callback
|
||||
) {
|
||||
@@ -20,14 +30,9 @@ function getAccountLines(remote, address, ledgerVersion, options, marker, limit,
|
||||
peer: options.counterparty
|
||||
};
|
||||
|
||||
remote.requestAccountLines(requestOptions, (error, data) => {
|
||||
return error ? callback(error) :
|
||||
callback(null, {
|
||||
marker: data.marker,
|
||||
results: data.lines.map(parseAccountTrustline)
|
||||
.filter(_.partial(currencyFilter, options.currency || null))
|
||||
});
|
||||
});
|
||||
remote.requestAccountLines(requestOptions,
|
||||
composeAsync(_.partial(formatResponse, options),
|
||||
convertErrors(callback)));
|
||||
}
|
||||
|
||||
function getTrustlinesAsync(account: string, options: {currency: string,
|
||||
@@ -44,7 +49,7 @@ function getTrustlinesAsync(account: string, options: {currency: string,
|
||||
utils.getRecursive(getter, options.limit, callback);
|
||||
}
|
||||
|
||||
function getTrustlines(account: string, options={}) {
|
||||
function getTrustlines(account: string, options = {}) {
|
||||
return utils.promisify(getTrustlinesAsync).call(this, account, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -3,16 +3,17 @@
|
||||
const utils = require('./utils');
|
||||
const validate = utils.common.validate;
|
||||
const Request = utils.common.core.Request;
|
||||
const convertErrors = utils.common.convertErrors;
|
||||
|
||||
function submitAsync(txBlob: string, callback: (err: any, data: any) => void):
|
||||
void {
|
||||
function submitAsync(txBlob: string, callback: (err: any, data: any) => void
|
||||
): void {
|
||||
validate.blob(txBlob);
|
||||
const request = new Request(this.remote, 'submit');
|
||||
request.message.tx_blob = txBlob;
|
||||
request.request(null,
|
||||
utils.common.composeAsync(
|
||||
data => utils.common.convertKeysFromSnakeCaseToCamelCase(data),
|
||||
callback));
|
||||
convertErrors(callback)));
|
||||
}
|
||||
|
||||
function submit(txBlob: string) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const _ = require('lodash');
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const util = require('util');
|
||||
const async = require('async');
|
||||
@@ -62,6 +63,10 @@ Request.prototype.request = function(servers, callback) {
|
||||
return this;
|
||||
};
|
||||
|
||||
function isResponseNotError(res) {
|
||||
return typeof res === 'object' && !res.hasOwnProperty('error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast request to all servers, filter responses if a function is
|
||||
* provided. Return first response that satisfies the filter. Pre-filter
|
||||
@@ -73,22 +78,23 @@ Request.prototype.request = function(servers, callback) {
|
||||
* @param [Function] fn
|
||||
*/
|
||||
|
||||
|
||||
Request.prototype.filter =
|
||||
Request.prototype.addFilter =
|
||||
Request.prototype.broadcast = function(filterFn=Boolean) {
|
||||
Request.prototype.broadcast = function(isResponseSuccess = isResponseNotError) {
|
||||
const self = this;
|
||||
|
||||
if (!this.requested) {
|
||||
// Defer until requested, and prevent the normal request() from executing
|
||||
this.once('before', function() {
|
||||
self.requested = true;
|
||||
self.broadcast(filterFn);
|
||||
self.broadcast(isResponseSuccess);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
let lastResponse = new Error('No servers available');
|
||||
let connectTimeouts = { };
|
||||
const connectTimeouts = { };
|
||||
const emit = this.emit;
|
||||
|
||||
this.emit = function(event, a, b) {
|
||||
@@ -110,7 +116,7 @@ Request.prototype.broadcast = function(filterFn=Boolean) {
|
||||
// Listen for proxied success/error event and apply filter
|
||||
self.once('proposed', function(res) {
|
||||
lastResponse = res;
|
||||
callback(filterFn(res));
|
||||
callback(isResponseSuccess(res));
|
||||
});
|
||||
|
||||
return server._request(self);
|
||||
@@ -266,26 +272,13 @@ Request.prototype.timeout = function(duration, callback) {
|
||||
Request.prototype.setServer = function(server) {
|
||||
let selected = null;
|
||||
|
||||
switch (typeof server) {
|
||||
case 'object':
|
||||
selected = server;
|
||||
break;
|
||||
|
||||
case 'string':
|
||||
// Find server by URL
|
||||
const servers = this.remote._servers;
|
||||
|
||||
for (let i = 0, s; (s = servers[i]); i++) {
|
||||
if (s._url === server) {
|
||||
selected = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (_.isString(server)) {
|
||||
selected = _.find(this.remote._servers, s => s._url === server) || null;
|
||||
} else if (_.isObject(server)) {
|
||||
selected = server;
|
||||
}
|
||||
|
||||
this.server = selected;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -336,26 +329,30 @@ Request.prototype.ledgerIndex = function(ledger_index) {
|
||||
/**
|
||||
* Set either ledger_index or ledger_hash based on heuristic
|
||||
*
|
||||
* @param {Number|String} ledger identifier
|
||||
* @param {Number|String} ledger - identifier
|
||||
* @param {Object} options -
|
||||
* @param {Number|String} defaultValue - default if `ledger` unspecifed
|
||||
*/
|
||||
Request.prototype.ledgerSelect =
|
||||
Request.prototype.selectLedger = function(ledger, defaultValue) {
|
||||
const selected = ledger || defaultValue;
|
||||
|
||||
Request.prototype.selectLedger =
|
||||
Request.prototype.ledgerSelect = function(ledger) {
|
||||
switch (ledger) {
|
||||
switch (selected) {
|
||||
case 'current':
|
||||
case 'closed':
|
||||
case 'validated':
|
||||
this.message.ledger_index = ledger;
|
||||
this.message.ledger_index = selected;
|
||||
break;
|
||||
default:
|
||||
if (Number(ledger) && isFinite(Number(ledger))) {
|
||||
this.message.ledger_index = Number(ledger);
|
||||
} else if (/^[A-F0-9]{64}$/.test(ledger)) {
|
||||
this.message.ledger_hash = ledger;
|
||||
if (Number(selected) && isFinite(Number(selected))) {
|
||||
this.message.ledger_index = Number(selected);
|
||||
} else if (/^[A-F0-9]{64}$/.test(selected)) {
|
||||
this.message.ledger_hash = selected;
|
||||
} else if (selected !== undefined) {
|
||||
throw new Error('unknown ledger format: ' + selected);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -535,7 +532,7 @@ Request.prototype.addStream = function(stream, values) {
|
||||
break;
|
||||
}
|
||||
} else if (arguments.length > 1) {
|
||||
for (let arg in arguments) {
|
||||
for (const arg in arguments) {
|
||||
this.addStream(arguments[arg]);
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
const _ = require('lodash');
|
||||
const assert = require('assert');
|
||||
const util = require('util');
|
||||
@@ -49,6 +48,14 @@ function Server(remote, opts_) {
|
||||
'Server host is malformed, use "host" and "port" server configuration');
|
||||
}
|
||||
|
||||
if (typeof opts.secure !== 'boolean') {
|
||||
opts.secure = true;
|
||||
}
|
||||
|
||||
if (!Boolean(opts.port)) {
|
||||
opts.port = opts.secure ? 443 : 80;
|
||||
}
|
||||
|
||||
// We want to allow integer strings as valid port numbers for backward
|
||||
// compatibility
|
||||
opts.port = Number(opts.port);
|
||||
@@ -60,10 +67,6 @@ function Server(remote, opts_) {
|
||||
throw new TypeError('Server "port" must be an integer in range 1-65535');
|
||||
}
|
||||
|
||||
if (typeof opts.secure !== 'boolean') {
|
||||
opts.secure = true;
|
||||
}
|
||||
|
||||
this._remote = remote;
|
||||
this._opts = opts;
|
||||
this._ws = undefined;
|
||||
@@ -127,6 +130,7 @@ function Server(remote, opts_) {
|
||||
});
|
||||
|
||||
this.on('response_ping', function onPingResponse(message, request) {
|
||||
_.noop(message);
|
||||
self._updateScore('response', request);
|
||||
});
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
@@ -391,7 +393,7 @@ describe('RippleAPI', function() {
|
||||
return this.api.getTransactions(address, options).then(() => {
|
||||
assert(false, 'Should throw RippleError');
|
||||
}).catch(error => {
|
||||
assert(error instanceof common.core.RippleError);
|
||||
assert(error instanceof this.api.errors.RippleError);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -552,6 +554,14 @@ describe('RippleAPI', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('getPaths - error: srcActNotFound', function() {
|
||||
const pathfind = _.assign({}, requests.getPaths.normal,
|
||||
{source: {address: addresses.NOTFOUND}});
|
||||
return this.api.getPaths(pathfind).catch(error => {
|
||||
assert(error instanceof this.api.errors.RippleError);
|
||||
});
|
||||
});
|
||||
|
||||
it('getLedgerVersion', function() {
|
||||
assert.strictEqual(this.api.getLedgerVersion(), 8819951);
|
||||
});
|
||||
@@ -573,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');
|
||||
});
|
||||
@@ -767,55 +777,55 @@ 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));
|
||||
assert.throws(() => RippleAPI._PRIVATE.computeLedgerHash(header));
|
||||
});
|
||||
|
||||
it('isValidAddress - valid', function() {
|
||||
const api = new RippleAPI();
|
||||
assert(api.isValidAddress(address));
|
||||
/* eslint-disable no-unused-vars */
|
||||
it('RippleAPI - implicit server port', function() {
|
||||
const api = new RippleAPI({servers: ['wss://s1.ripple.com']});
|
||||
});
|
||||
/* eslint-enable no-unused-vars */
|
||||
it('RippleAPI invalid options', function() {
|
||||
assert.throws(() => new RippleAPI({invalid: true}));
|
||||
});
|
||||
|
||||
it('isValidAddress - invalid', function() {
|
||||
const api = new RippleAPI();
|
||||
assert(!api.isValidAddress(address.slice(0, -1) + 'a'));
|
||||
it('RippleAPI valid options', function() {
|
||||
const api = new RippleAPI({trace: true, servers: ['wss://s:1']});
|
||||
assert(api.remote.trace);
|
||||
assert.deepEqual(api.remote.servers, ['wss://s:1']);
|
||||
});
|
||||
|
||||
it('isValidAddress - invalid - hex representation', function() {
|
||||
const api = new RippleAPI();
|
||||
const hex = '6e3efa86a5eb0a3c5dc9beb3a204783bb00e1913';
|
||||
assert(!api.isValidAddress(hex));
|
||||
it('RippleAPI invalid server uri', function() {
|
||||
assert.throws(() => new RippleAPI({servers: ['wss//s:1']}));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
13
test/fixtures/api/requests/sign.json
vendored
13
test/fixtures/api/requests/sign.json
vendored
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"source": {
|
||||
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"amount": {
|
||||
"maxAmount": {
|
||||
"currency": "USD",
|
||||
"value": "0.000001002",
|
||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"source": {
|
||||
"address": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
|
||||
"amount": {
|
||||
"maxAmount": {
|
||||
"currency": "XRP",
|
||||
"value": "0.000002"
|
||||
}
|
||||
|
||||
6
test/fixtures/api/responses/get-paths.json
vendored
6
test/fixtures/api/responses/get-paths.json
vendored
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
18
test/fixtures/api/responses/prepare-order.json
vendored
18
test/fixtures/api/responses/prepare-order.json
vendored
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
23
test/fixtures/api/responses/prepare-payment.json
vendored
23
test/fixtures/api/responses/prepare-payment.json
vendored
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
4
test/fixtures/api/rippled/account-tx.js
vendored
4
test/fixtures/api/rippled/account-tx.js
vendored
@@ -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: {
|
||||
|
||||
3
test/fixtures/api/rippled/index.js
vendored
3
test/fixtures/api/rippled/index.js
vendored
@@ -19,7 +19,8 @@ module.exports = {
|
||||
path_find: {
|
||||
generate: require('./path-find'),
|
||||
sendUSD: require('./path-find-send-usd'),
|
||||
XrpToXrp: require('./path-find-xrp-to-xrp')
|
||||
XrpToXrp: require('./path-find-xrp-to-xrp'),
|
||||
srcActNotFound: require('./path-find-srcActNotFound')
|
||||
},
|
||||
tx: {
|
||||
Payment: require('./tx/payment.json'),
|
||||
|
||||
20
test/fixtures/api/rippled/path-find-srcActNotFound.json
vendored
Normal file
20
test/fixtures/api/rippled/path-find-srcActNotFound.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"error": "srcActNotFound",
|
||||
"error_code": 58,
|
||||
"error_message": "Source account not found.",
|
||||
"id": 0,
|
||||
"request": {
|
||||
"command": "path_find",
|
||||
"destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"destination_amount": {
|
||||
"currency": "USD",
|
||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"value": "5"
|
||||
},
|
||||
"id": 1,
|
||||
"source_account": "rajTAg3hon5Lcu1RxQQPxTgHvqfhc1EaUS",
|
||||
"subcommand": "create"
|
||||
},
|
||||
"status": "error",
|
||||
"type": "response"
|
||||
}
|
||||
@@ -18,7 +18,7 @@ function isBTC(json) {
|
||||
return json === 'BTC' || json === '0000000000000000000000004254430000000000';
|
||||
}
|
||||
|
||||
function createResponse(request, response, overrides={}) {
|
||||
function createResponse(request, response, overrides = {}) {
|
||||
const result = _.assign({}, response.result, overrides);
|
||||
const change = response.result && !_.isEmpty(overrides) ?
|
||||
{id: request.id, result: result} : {id: request.id};
|
||||
@@ -253,7 +253,9 @@ module.exports = function(port) {
|
||||
if (request.subcommand === 'close') {
|
||||
return;
|
||||
}
|
||||
if (request.source_account === addresses.OTHER_ACCOUNT) {
|
||||
if (request.source_account === addresses.NOTFOUND) {
|
||||
response = createResponse(request, fixtures.path_find.srcActNotFound);
|
||||
} else if (request.source_account === addresses.OTHER_ACCOUNT) {
|
||||
response = createResponse(request, fixtures.path_find.sendUSD);
|
||||
} else if (request.source_account === addresses.THIRD_ACCOUNT) {
|
||||
response = createResponse(request, fixtures.path_find.XrpToXrp, {
|
||||
|
||||
@@ -106,7 +106,7 @@ describe('Remote', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
new Remote({
|
||||
servers: [{host: 's-west.ripple.com', port: null, secure: true}]
|
||||
servers: [{host: 's-west.ripple.com', port: 'null', secure: true}]
|
||||
});
|
||||
}, TypeError);
|
||||
});
|
||||
@@ -148,21 +148,26 @@ describe('Remote', function() {
|
||||
);
|
||||
});
|
||||
|
||||
/*
|
||||
"url" module used in server parses such urls with error, it return
|
||||
null for port, so in this case default port will be used
|
||||
|
||||
it('Server initialization -- url string -- invalid port', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
new Remote({
|
||||
servers: ['ws://s-west.ripple.com:null']
|
||||
servers: ['ws://s-west.ripple.com:invalid']
|
||||
});
|
||||
}, Error
|
||||
);
|
||||
});
|
||||
*/
|
||||
|
||||
it('Server initialization -- url string -- port out of range', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
new Remote({
|
||||
servers: ['ws://s-west.ripple.com:65537:']
|
||||
servers: ['ws://s-west.ripple.com:65537']
|
||||
});
|
||||
}, Error
|
||||
);
|
||||
@@ -1258,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);
|
||||
@@ -1298,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() {
|
||||
@@ -1357,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() {
|
||||
@@ -1367,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);
|
||||
@@ -1416,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,
|
||||
@@ -1431,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({
|
||||
@@ -1663,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,
|
||||
@@ -1921,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'
|
||||
}]
|
||||
});
|
||||
@@ -1969,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'
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user