You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

accountinfo.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  3. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4. return new (P || (P = Promise))(function (resolve, reject) {
  5. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  6. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  7. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  8. step((generator = generator.apply(thisArg, _arguments || [])).next());
  9. });
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. const common_1 = require("../common");
  13. function formatAccountInfo(response) {
  14. const data = response.account_data;
  15. return common_1.removeUndefined({
  16. sequence: data.Sequence,
  17. xrpBalance: common_1.dropsToXrp(data.Balance),
  18. ownerCount: data.OwnerCount,
  19. previousInitiatedTransactionID: data.AccountTxnID,
  20. previousAffectingTransactionID: data.PreviousTxnID,
  21. previousAffectingTransactionLedgerVersion: data.PreviousTxnLgrSeq
  22. });
  23. }
  24. function getAccountInfo(address, options = {}) {
  25. return __awaiter(this, void 0, void 0, function* () {
  26. common_1.validate.getAccountInfo({ address, options });
  27. address = common_1.ensureClassicAddress(address);
  28. const response = yield this.request('account_info', {
  29. account: address,
  30. ledger_index: options.ledgerVersion || 'validated'
  31. });
  32. return formatAccountInfo(response);
  33. });
  34. }
  35. exports.default = getAccountInfo;
  36. //# sourceMappingURL=accountinfo.js.map