mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 04:35:49 +00:00
Add ledgerVersion option to getSettings
This commit is contained in:
@@ -4,6 +4,7 @@ const utils = require('./utils');
|
||||
const flags = utils.common.core.Remote.flags.account_root;
|
||||
const validate = utils.common.validate;
|
||||
const parseFields = require('./parse/fields');
|
||||
const composeAsync = utils.common.composeAsync;
|
||||
|
||||
const AccountFlags = {
|
||||
passwordSpent: flags.PasswordSpent,
|
||||
@@ -26,19 +27,24 @@ function parseFlags(value) {
|
||||
return settings;
|
||||
}
|
||||
|
||||
function getSettings(account, callback) {
|
||||
validate.address(account);
|
||||
|
||||
this.remote.requestAccountInfo({account: account}, function(error, info) {
|
||||
if (error) {
|
||||
return callback(error);
|
||||
}
|
||||
const data = info.account_data;
|
||||
function formatSettings(response) {
|
||||
const data = response.account_data;
|
||||
const parsedFlags = parseFlags(data.Flags);
|
||||
const parsedFields = parseFields(data);
|
||||
const settings = _.assign({}, parsedFlags, parsedFields);
|
||||
callback(null, settings);
|
||||
});
|
||||
return _.assign({}, parsedFlags, parsedFields);
|
||||
}
|
||||
|
||||
function getSettings(account, options, callback) {
|
||||
validate.address(account);
|
||||
validate.options(options);
|
||||
|
||||
const request = {
|
||||
account: account,
|
||||
ledger: options.ledgerVersion
|
||||
};
|
||||
|
||||
this.remote.requestAccountInfo(request,
|
||||
composeAsync(formatSettings, callback));
|
||||
}
|
||||
|
||||
module.exports = utils.wrapCatch(getSettings);
|
||||
|
||||
@@ -133,7 +133,7 @@ describe('RippleAPI', function() {
|
||||
});
|
||||
|
||||
it('getSettings', function(done) {
|
||||
this.api.getSettings(address,
|
||||
this.api.getSettings(address, {},
|
||||
_.partial(checkResult, getSettingsResponse, done));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user