@bithomp/xrpl-api 3.1.16 → 3.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/connection.js CHANGED
@@ -99,6 +99,7 @@ class Connection extends events_1.EventEmitter {
99
99
  }
100
100
  const response = await this.client.connection.request(request);
101
101
  this.updateLatency((0, utils_1.getTimestamp)() - startTimestamp);
102
+ this.connectionValidation();
102
103
  return response;
103
104
  }
104
105
  catch (err) {
@@ -45,7 +45,7 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
45
45
  if (!connection) {
46
46
  throw new Error("There is no connection");
47
47
  }
48
- const response = await connection.request({
48
+ const command = {
49
49
  command: "account_tx",
50
50
  account,
51
51
  ledger_index_min: options.ledgerIndexMin,
@@ -56,7 +56,8 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
56
56
  forward: !!options.forward,
57
57
  limit: options.limit,
58
58
  marker: options.marker,
59
- });
59
+ };
60
+ const response = await connection.request(command);
60
61
  if (!response) {
61
62
  return {
62
63
  account,
@@ -1,5 +1,9 @@
1
1
  import { LedgerEntry, AccountSetAsfFlags } from "xrpl";
2
2
  import { QueueData } from "../types/queue_data";
3
+ export declare enum XahauAccountRootFlags {
4
+ lsfURITokenIssuer = 1073741824,
5
+ lsfDisallowIncomingRemit = 2147483648
6
+ }
3
7
  export declare const AccountRootFlagsKeys: {
4
8
  passwordSpent: LedgerEntry.AccountRootFlags;
5
9
  requireDestTag: LedgerEntry.AccountRootFlags;
@@ -15,6 +19,41 @@ export declare const AccountRootFlagsKeys: {
15
19
  disallowIncomingPayChan: LedgerEntry.AccountRootFlags;
16
20
  disallowIncomingTrustline: LedgerEntry.AccountRootFlags;
17
21
  };
22
+ export declare const XRPLAccountRootFlagsKeys: {
23
+ amm: LedgerEntry.AccountRootFlags;
24
+ allowTrustLineClawback: LedgerEntry.AccountRootFlags;
25
+ passwordSpent: LedgerEntry.AccountRootFlags;
26
+ requireDestTag: LedgerEntry.AccountRootFlags;
27
+ requireAuth: LedgerEntry.AccountRootFlags;
28
+ depositAuth: LedgerEntry.AccountRootFlags;
29
+ disallowXRP: LedgerEntry.AccountRootFlags;
30
+ disableMaster: LedgerEntry.AccountRootFlags;
31
+ noFreeze: LedgerEntry.AccountRootFlags;
32
+ globalFreeze: LedgerEntry.AccountRootFlags;
33
+ defaultRipple: LedgerEntry.AccountRootFlags;
34
+ disallowIncomingNFTokenOffer: LedgerEntry.AccountRootFlags;
35
+ disallowIncomingCheck: LedgerEntry.AccountRootFlags;
36
+ disallowIncomingPayChan: LedgerEntry.AccountRootFlags;
37
+ disallowIncomingTrustline: LedgerEntry.AccountRootFlags;
38
+ };
39
+ export declare const XahauAccountRootFlagsKeys: {
40
+ uriTokenIssuer: XahauAccountRootFlags;
41
+ disallowIncomingRemit: XahauAccountRootFlags;
42
+ passwordSpent: LedgerEntry.AccountRootFlags;
43
+ requireDestTag: LedgerEntry.AccountRootFlags;
44
+ requireAuth: LedgerEntry.AccountRootFlags;
45
+ depositAuth: LedgerEntry.AccountRootFlags;
46
+ disallowXRP: LedgerEntry.AccountRootFlags;
47
+ disableMaster: LedgerEntry.AccountRootFlags;
48
+ noFreeze: LedgerEntry.AccountRootFlags;
49
+ globalFreeze: LedgerEntry.AccountRootFlags;
50
+ defaultRipple: LedgerEntry.AccountRootFlags;
51
+ disallowIncomingNFTokenOffer: LedgerEntry.AccountRootFlags;
52
+ disallowIncomingCheck: LedgerEntry.AccountRootFlags;
53
+ disallowIncomingPayChan: LedgerEntry.AccountRootFlags;
54
+ disallowIncomingTrustline: LedgerEntry.AccountRootFlags;
55
+ };
56
+ export declare function getAccountRootFlagsKeys(): Record<string, number>;
18
57
  export interface AccountRootFlagsKeysInterface {
19
58
  passwordSpent?: boolean;
20
59
  requireDestTag?: boolean;
@@ -29,6 +68,13 @@ export interface AccountRootFlagsKeysInterface {
29
68
  disallowIncomingCheck?: boolean;
30
69
  disallowIncomingPayChan?: boolean;
31
70
  disallowIncomingTrustline?: boolean;
71
+ amm?: boolean;
72
+ allowTrustLineClawback?: boolean;
73
+ uriTokenIssuer?: boolean;
74
+ disallowIncomingRemit?: boolean;
75
+ }
76
+ export declare enum XahauAccountSetAsfFlags {
77
+ asfDisallowIncomingRemit = 16
32
78
  }
33
79
  export declare const AccountSetFlags: {
34
80
  requireDestinationTag: AccountSetAsfFlags;
@@ -45,6 +91,8 @@ export declare const AccountSetFlags: {
45
91
  disallowIncomingCheck: AccountSetAsfFlags;
46
92
  disallowIncomingPayChan: AccountSetAsfFlags;
47
93
  disallowIncomingTrustline: AccountSetAsfFlags;
94
+ allowTrustLineClawback: AccountSetAsfFlags;
95
+ disallowIncomingRemit: XahauAccountSetAsfFlags;
48
96
  };
49
97
  export declare const SignerListFlagsKeys: {
50
98
  oneOwnerCount: LedgerEntry.SignerListFlags;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AccountFields = exports.SignerListFlagsKeys = exports.AccountSetFlags = exports.AccountRootFlagsKeys = void 0;
6
+ exports.AccountFields = exports.SignerListFlagsKeys = exports.AccountSetFlags = exports.XahauAccountSetAsfFlags = exports.XahauAccountRootFlagsKeys = exports.XRPLAccountRootFlagsKeys = exports.AccountRootFlagsKeys = exports.XahauAccountRootFlags = void 0;
7
+ exports.getAccountRootFlagsKeys = getAccountRootFlagsKeys;
7
8
  exports.getSettings = getSettings;
8
9
  exports.parseAccountFlags = parseAccountFlags;
9
10
  exports.parseAccountFields = parseAccountFields;
@@ -12,6 +13,12 @@ const xrpl_1 = require("xrpl");
12
13
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
13
14
  const common_1 = require("../common");
14
15
  const flags_1 = require("../parse/ledger/flags");
16
+ const client_1 = require("../client");
17
+ var XahauAccountRootFlags;
18
+ (function (XahauAccountRootFlags) {
19
+ XahauAccountRootFlags[XahauAccountRootFlags["lsfURITokenIssuer"] = 1073741824] = "lsfURITokenIssuer";
20
+ XahauAccountRootFlags[XahauAccountRootFlags["lsfDisallowIncomingRemit"] = 2147483648] = "lsfDisallowIncomingRemit";
21
+ })(XahauAccountRootFlags || (exports.XahauAccountRootFlags = XahauAccountRootFlags = {}));
15
22
  exports.AccountRootFlagsKeys = {
16
23
  passwordSpent: xrpl_1.LedgerEntry.AccountRootFlags.lsfPasswordSpent,
17
24
  requireDestTag: xrpl_1.LedgerEntry.AccountRootFlags.lsfRequireDestTag,
@@ -27,6 +34,29 @@ exports.AccountRootFlagsKeys = {
27
34
  disallowIncomingPayChan: xrpl_1.LedgerEntry.AccountRootFlags.lsfDisallowIncomingPayChan,
28
35
  disallowIncomingTrustline: xrpl_1.LedgerEntry.AccountRootFlags.lsfDisallowIncomingTrustline,
29
36
  };
37
+ exports.XRPLAccountRootFlagsKeys = {
38
+ ...exports.AccountRootFlagsKeys,
39
+ amm: xrpl_1.LedgerEntry.AccountRootFlags.lsfAMM,
40
+ allowTrustLineClawback: xrpl_1.LedgerEntry.AccountRootFlags.lsfAllowTrustLineClawback,
41
+ };
42
+ exports.XahauAccountRootFlagsKeys = {
43
+ ...exports.AccountRootFlagsKeys,
44
+ uriTokenIssuer: XahauAccountRootFlags.lsfURITokenIssuer,
45
+ disallowIncomingRemit: XahauAccountRootFlags.lsfDisallowIncomingRemit,
46
+ };
47
+ function getAccountRootFlagsKeys() {
48
+ const nativeCurrency = (0, client_1.getNativeCurrency)();
49
+ if (nativeCurrency === "XAH") {
50
+ return exports.XahauAccountRootFlagsKeys;
51
+ }
52
+ else {
53
+ return exports.XRPLAccountRootFlagsKeys;
54
+ }
55
+ }
56
+ var XahauAccountSetAsfFlags;
57
+ (function (XahauAccountSetAsfFlags) {
58
+ XahauAccountSetAsfFlags[XahauAccountSetAsfFlags["asfDisallowIncomingRemit"] = 16] = "asfDisallowIncomingRemit";
59
+ })(XahauAccountSetAsfFlags || (exports.XahauAccountSetAsfFlags = XahauAccountSetAsfFlags = {}));
30
60
  exports.AccountSetFlags = {
31
61
  requireDestinationTag: xrpl_1.AccountSetAsfFlags.asfRequireDest,
32
62
  requireAuthorization: xrpl_1.AccountSetAsfFlags.asfRequireAuth,
@@ -42,6 +72,8 @@ exports.AccountSetFlags = {
42
72
  disallowIncomingCheck: xrpl_1.AccountSetAsfFlags.asfDisallowIncomingCheck,
43
73
  disallowIncomingPayChan: xrpl_1.AccountSetAsfFlags.asfDisallowIncomingPayChan,
44
74
  disallowIncomingTrustline: xrpl_1.AccountSetAsfFlags.asfDisallowIncomingTrustline,
75
+ allowTrustLineClawback: xrpl_1.AccountSetAsfFlags.asfAllowTrustLineClawback,
76
+ disallowIncomingRemit: XahauAccountSetAsfFlags.asfDisallowIncomingRemit,
45
77
  };
46
78
  exports.SignerListFlagsKeys = {
47
79
  oneOwnerCount: xrpl_1.LedgerEntry.SignerListFlags.lsfOneOwnerCount,
@@ -65,7 +97,7 @@ function getSettings(accountInfo, excludeFalse = true) {
65
97
  };
66
98
  }
67
99
  function parseAccountFlags(value, options = {}) {
68
- return (0, flags_1.parseFlags)(value, exports.AccountRootFlagsKeys, options);
100
+ return (0, flags_1.parseFlags)(value, getAccountRootFlagsKeys(), options);
69
101
  }
70
102
  function parseAccountFields(accountInfo, options = {}) {
71
103
  const settings = {};
@@ -0,0 +1,3 @@
1
+ import { FormattedIssuedCurrencyAmount } from "../../types";
2
+ declare function parseDeliveredAmount(tx: any): FormattedIssuedCurrencyAmount | undefined;
3
+ export { parseDeliveredAmount };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseDeliveredAmount = parseDeliveredAmount;
7
+ const import_1 = require("../ledger/import");
8
+ const amount_1 = __importDefault(require("../ledger/amount"));
9
+ const utils_1 = require("../utils");
10
+ const balance_changes_1 = require("./balance_changes");
11
+ function parseDeliveredAmount(tx) {
12
+ if (!["Import", "Payment"].includes(tx.TransactionType) || tx.meta.TransactionResult !== "tesSUCCESS") {
13
+ return undefined;
14
+ }
15
+ if (tx.meta.delivered_amount && tx.meta.delivered_amount === "unavailable") {
16
+ return undefined;
17
+ }
18
+ if (tx.meta.delivered_amount) {
19
+ return (0, amount_1.default)(tx.meta.delivered_amount);
20
+ }
21
+ if (tx.meta.DeliveredAmount) {
22
+ return (0, amount_1.default)(tx.meta.DeliveredAmount);
23
+ }
24
+ if (tx.Amount && !(0, utils_1.isPartialPayment)(tx)) {
25
+ return (0, amount_1.default)(tx.Amount);
26
+ }
27
+ if (tx.TransactionType === "Import") {
28
+ const balanceChanges = (0, balance_changes_1.parseBalanceChanges)(tx.meta);
29
+ const blob = (0, import_1.parseImportBlob)(tx.Blob);
30
+ if (typeof blob === "string") {
31
+ return undefined;
32
+ }
33
+ const account = blob.transaction.tx.Account;
34
+ const balanceChange = balanceChanges[account];
35
+ if (!balanceChange || balanceChange.length !== 1) {
36
+ return undefined;
37
+ }
38
+ return {
39
+ currency: balanceChange[0].currency,
40
+ value: balanceChange[0].value,
41
+ };
42
+ }
43
+ return undefined;
44
+ }
@@ -14,3 +14,4 @@ export { parseUNLReportChanges } from "./unl_report_changes";
14
14
  export { parseAmmChanges } from "./amm_changes";
15
15
  export { parseDIDChanges } from "./did_changes";
16
16
  export { parseOracleChanges } from "./oracle_changes";
17
+ export { parseDeliveredAmount } from "./delivered_amount";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseOracleChanges = exports.parseDIDChanges = exports.parseAmmChanges = exports.parseUNLReportChanges = exports.parseEscrowChanges = exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
3
+ exports.parseDeliveredAmount = exports.parseOracleChanges = exports.parseDIDChanges = exports.parseAmmChanges = exports.parseUNLReportChanges = exports.parseEscrowChanges = exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
4
4
  var affected_objects_1 = require("./affected_objects");
5
5
  Object.defineProperty(exports, "parseAffectedObjects", { enumerable: true, get: function () { return affected_objects_1.parseAffectedObjects; } });
6
6
  var nftoken_changes_1 = require("./nftoken_changes");
@@ -33,3 +33,5 @@ var did_changes_1 = require("./did_changes");
33
33
  Object.defineProperty(exports, "parseDIDChanges", { enumerable: true, get: function () { return did_changes_1.parseDIDChanges; } });
34
34
  var oracle_changes_1 = require("./oracle_changes");
35
35
  Object.defineProperty(exports, "parseOracleChanges", { enumerable: true, get: function () { return oracle_changes_1.parseOracleChanges; } });
36
+ var delivered_amount_1 = require("./delivered_amount");
37
+ Object.defineProperty(exports, "parseDeliveredAmount", { enumerable: true, get: function () { return delivered_amount_1.parseDeliveredAmount; } });
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.parseOutcome = parseOutcome;
7
4
  const index_1 = require("./outcome/index");
8
- const import_1 = require("./ledger/import");
9
- const amount_1 = __importDefault(require("./ledger/amount"));
10
5
  const utils_1 = require("./utils");
11
6
  const common_1 = require("../common");
12
7
  function removeEmptyCounterparty(amount) {
@@ -26,40 +21,6 @@ function removeEmptyCounterpartyInOrderbookChanges(orderbookChanges) {
26
21
  });
27
22
  });
28
23
  }
29
- function parseDeliveredAmount(tx) {
30
- if (!["Import", "Payment"].includes(tx.TransactionType) || tx.meta.TransactionResult !== "tesSUCCESS") {
31
- return undefined;
32
- }
33
- if (tx.meta.delivered_amount && tx.meta.delivered_amount === "unavailable") {
34
- return undefined;
35
- }
36
- if (tx.meta.delivered_amount) {
37
- return (0, amount_1.default)(tx.meta.delivered_amount);
38
- }
39
- if (tx.meta.DeliveredAmount) {
40
- return (0, amount_1.default)(tx.meta.DeliveredAmount);
41
- }
42
- if (tx.Amount && !(0, utils_1.isPartialPayment)(tx)) {
43
- return (0, amount_1.default)(tx.Amount);
44
- }
45
- if (tx.TransactionType === "Import") {
46
- const balanceChanges = (0, index_1.parseBalanceChanges)(tx.meta);
47
- const blob = (0, import_1.parseImportBlob)(tx.Blob);
48
- if (typeof blob === "string") {
49
- return undefined;
50
- }
51
- const account = blob.transaction.tx.Account;
52
- const balanceChange = balanceChanges[account];
53
- if (!balanceChange || balanceChange.length !== 1) {
54
- return undefined;
55
- }
56
- return {
57
- currency: balanceChange[0].currency,
58
- value: balanceChange[0].value,
59
- };
60
- }
61
- return undefined;
62
- }
63
24
  function parseOutcome(tx, nativeCurrency, definitions) {
64
25
  const metadata = tx.meta || tx.metaData;
65
26
  if (!metadata) {
@@ -106,6 +67,6 @@ function parseOutcome(tx, nativeCurrency, definitions) {
106
67
  emittedTxns,
107
68
  ledgerVersion: tx.ledger_index,
108
69
  indexInLedger: tx.meta.TransactionIndex,
109
- deliveredAmount: parseDeliveredAmount(tx),
70
+ deliveredAmount: (0, index_1.parseDeliveredAmount)(tx),
110
71
  });
111
72
  }
@@ -50,7 +50,7 @@ function parseSettingsFlags(tx) {
50
50
  const changedFlags = oldFlags ^ newFlags;
51
51
  const setFlags = newFlags & changedFlags;
52
52
  const clearedFlags = oldFlags & changedFlags;
53
- Object.entries(account_info_1.AccountRootFlagsKeys).forEach((entry) => {
53
+ Object.entries((0, account_info_1.getAccountRootFlagsKeys)()).forEach((entry) => {
54
54
  const [flagName, flagValue] = entry;
55
55
  if (setFlags & flagValue) {
56
56
  settings[flagName] = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.1.16",
3
+ "version": "3.1.17",
4
4
  "description": "A Bithomp JavaScript/TypeScript library for interacting with the XRP Ledger",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -64,12 +64,12 @@
64
64
  "devDependencies": {
65
65
  "@types/chai": "^4.3.19",
66
66
  "@types/chai-as-promised": "^7.1.8",
67
- "@types/lodash": "^4.17.12",
67
+ "@types/lodash": "^4.17.13",
68
68
  "@types/mocha": "^10.0.9",
69
69
  "@types/nconf": "^0.10.7",
70
70
  "@types/node": "^20.14.15",
71
- "@typescript-eslint/eslint-plugin": "^8.10.0",
72
- "@typescript-eslint/parser": "^8.10.0",
71
+ "@typescript-eslint/eslint-plugin": "^8.13.0",
72
+ "@typescript-eslint/parser": "^8.13.0",
73
73
  "chai": "^4.5.0",
74
74
  "chai-as-promised": "^7.1.2",
75
75
  "eslint": "^8.57.0",