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 flags = utils.common.core.Remote.flags.account_root;
|
||||||
const validate = utils.common.validate;
|
const validate = utils.common.validate;
|
||||||
const parseFields = require('./parse/fields');
|
const parseFields = require('./parse/fields');
|
||||||
|
const composeAsync = utils.common.composeAsync;
|
||||||
|
|
||||||
const AccountFlags = {
|
const AccountFlags = {
|
||||||
passwordSpent: flags.PasswordSpent,
|
passwordSpent: flags.PasswordSpent,
|
||||||
@@ -26,19 +27,24 @@ function parseFlags(value) {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSettings(account, callback) {
|
function formatSettings(response) {
|
||||||
validate.address(account);
|
const data = response.account_data;
|
||||||
|
const parsedFlags = parseFlags(data.Flags);
|
||||||
|
const parsedFields = parseFields(data);
|
||||||
|
return _.assign({}, parsedFlags, parsedFields);
|
||||||
|
}
|
||||||
|
|
||||||
this.remote.requestAccountInfo({account: account}, function(error, info) {
|
function getSettings(account, options, callback) {
|
||||||
if (error) {
|
validate.address(account);
|
||||||
return callback(error);
|
validate.options(options);
|
||||||
}
|
|
||||||
const data = info.account_data;
|
const request = {
|
||||||
const parsedFlags = parseFlags(data.Flags);
|
account: account,
|
||||||
const parsedFields = parseFields(data);
|
ledger: options.ledgerVersion
|
||||||
const settings = _.assign({}, parsedFlags, parsedFields);
|
};
|
||||||
callback(null, settings);
|
|
||||||
});
|
this.remote.requestAccountInfo(request,
|
||||||
|
composeAsync(formatSettings, callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = utils.wrapCatch(getSettings);
|
module.exports = utils.wrapCatch(getSettings);
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ describe('RippleAPI', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('getSettings', function(done) {
|
it('getSettings', function(done) {
|
||||||
this.api.getSettings(address,
|
this.api.getSettings(address, {},
|
||||||
_.partial(checkResult, getSettingsResponse, done));
|
_.partial(checkResult, getSettingsResponse, done));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user