@bithomp/xrpl-api 2.7.10 → 2.7.12

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.
Files changed (32) hide show
  1. package/lib/common/utils.js +9 -9
  2. package/lib/ledger/currency.js +2 -2
  3. package/lib/ledger/nft_info.d.ts +1 -1
  4. package/lib/ledger/nft_info.js +1 -1
  5. package/lib/parse/ledger/memos.d.ts +1 -1
  6. package/lib/parse/outcome/balance_changes.js +8 -8
  7. package/lib/parse/outcome/locked_balance_changes.js +6 -6
  8. package/lib/parse/outcome/orderbook_changes.js +21 -21
  9. package/lib/parse/outcome/orderbook_quality.js +6 -6
  10. package/lib/parse/specification/account-delete.js +0 -2
  11. package/lib/parse/specification/remit.d.ts +3 -0
  12. package/lib/parse/specification/remit.js +81 -0
  13. package/lib/parse/specification/unl-report.d.ts +3 -3
  14. package/lib/parse/specification/unl-report.js +2 -2
  15. package/lib/parse/transaction.d.ts +3 -2
  16. package/lib/parse/transaction.js +3 -0
  17. package/lib/v1/common/types/commands/account_objects.d.ts +1 -1
  18. package/lib/v1/common/types/commands/gateway_balances.d.ts +1 -1
  19. package/lib/v1/common/types/commands/path_find.d.ts +7 -7
  20. package/lib/v1/common/types/objects/account.d.ts +0 -1
  21. package/lib/v1/common/types/objects/hooks.d.ts +14 -0
  22. package/lib/v1/common/types/objects/hooks.js +2 -0
  23. package/lib/v1/common/types/objects/index.d.ts +3 -1
  24. package/lib/v1/common/types/objects/index.js +3 -1
  25. package/lib/v1/common/types/objects/ledger.d.ts +3 -3
  26. package/lib/v1/common/types/objects/path_find.d.ts +3 -3
  27. package/lib/v1/common/types/objects/remits.d.ts +18 -0
  28. package/lib/v1/common/types/objects/remits.js +2 -0
  29. package/lib/v1/common/types/objects/unl_reports.d.ts +7 -0
  30. package/lib/v1/common/types/objects/unl_reports.js +2 -0
  31. package/lib/validator.js +2 -3
  32. package/package.json +15 -12
@@ -67,18 +67,18 @@ exports.parseMarker = parseMarker;
67
67
  function dropsToXrp(drops) {
68
68
  if (typeof drops === "string") {
69
69
  if (!drops.match(/^-?[0-9]*\.?[0-9]*$/)) {
70
- throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}',` + ` should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
70
+ throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}', should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
71
71
  }
72
72
  else if (drops === ".") {
73
- throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}',` + ` should be a BigNumber or string-encoded number.`);
73
+ throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}', should be a BigNumber or string-encoded number.`);
74
74
  }
75
75
  }
76
76
  drops = new bignumber_js_1.default(drops).toString(10);
77
77
  if (drops.includes(".")) {
78
- throw new errors_1.ValidationError(`dropsToXrp: value '${drops}' has` + ` too many decimal places.`);
78
+ throw new errors_1.ValidationError(`dropsToXrp: value '${drops}' has too many decimal places.`);
79
79
  }
80
80
  if (!drops.match(/^-?[0-9]+$/)) {
81
- throw new errors_1.ValidationError(`dropsToXrp: failed sanity check -` + ` value '${drops}',` + ` does not match (^-?[0-9]+$).`);
81
+ throw new errors_1.ValidationError(`dropsToXrp: failed sanity check - value '${drops}', does not match (^-?[0-9]+$).`);
82
82
  }
83
83
  return new bignumber_js_1.default(drops).dividedBy(1000000.0).toString(10);
84
84
  }
@@ -86,23 +86,23 @@ exports.dropsToXrp = dropsToXrp;
86
86
  function xrpToDrops(xrp) {
87
87
  if (typeof xrp === "string") {
88
88
  if (!xrp.match(/^-?[0-9]*\.?[0-9]*$/)) {
89
- throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}',` + ` should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
89
+ throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}', should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
90
90
  }
91
91
  else if (xrp === ".") {
92
- throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}',` + ` should be a BigNumber or string-encoded number.`);
92
+ throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}', should be a BigNumber or string-encoded number.`);
93
93
  }
94
94
  }
95
95
  xrp = new bignumber_js_1.default(xrp).toString(10);
96
96
  if (!xrp.match(/^-?[0-9.]+$/)) {
97
- throw new errors_1.ValidationError(`xrpToDrops: failed sanity check -` + ` value '${xrp}',` + ` does not match (^-?[0-9.]+$).`);
97
+ throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}', does not match (^-?[0-9.]+$).`);
98
98
  }
99
99
  const components = xrp.split(".");
100
100
  if (components.length > 2) {
101
- throw new errors_1.ValidationError(`xrpToDrops: failed sanity check -` + ` value '${xrp}' has` + ` too many decimal points.`);
101
+ throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}' has too many decimal points.`);
102
102
  }
103
103
  const fraction = components[1] || "0";
104
104
  if (fraction.length > 6) {
105
- throw new errors_1.ValidationError(`xrpToDrops: value '${xrp}' has` + ` too many decimal places.`);
105
+ throw new errors_1.ValidationError(`xrpToDrops: value '${xrp}' has too many decimal places.`);
106
106
  }
107
107
  return new bignumber_js_1.default(xrp).times(1000000.0).integerValue(bignumber_js_1.default.ROUND_FLOOR).toString(10);
108
108
  }
@@ -70,7 +70,7 @@ async function decodeXlf15d(currencyCode) {
70
70
  const currencyHex = hex.substring(16, hex.length);
71
71
  const currency = (0, utils_1.hexToString)(currencyHex)?.trim()?.replace(/\0/g, "");
72
72
  const ledgerInfo = await getLedger(ctiLedger);
73
- const ledger = ledgerInfo.ledger;
73
+ const ledger = ledgerInfo?.ledger;
74
74
  let ctiVerified = false;
75
75
  let ctiValid = false;
76
76
  let timestamp;
@@ -101,7 +101,7 @@ async function decodeXlf15d(currencyCode) {
101
101
  ctiTransactionCheck(cti) === ctiTransactionCheckGen(ctiTx.hash);
102
102
  }
103
103
  }
104
- else if (ledgerInfo.error === "lgrNotFound") {
104
+ else if (ledgerInfo?.error === "lgrNotFound") {
105
105
  ctiVerified = true;
106
106
  }
107
107
  return {
@@ -1,4 +1,4 @@
1
1
  import { ErrorResponse } from "../models/base_model";
2
2
  export interface GetNftInfoOptions {
3
3
  }
4
- export declare function getNftInfo(nft_id: string, options?: GetNftInfoOptions): Promise<object | ErrorResponse>;
4
+ export declare function getNftInfo(nft_id: string, _options?: GetNftInfoOptions): Promise<object | ErrorResponse>;
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getNftInfo = void 0;
27
27
  const Client = __importStar(require("../client"));
28
- async function getNftInfo(nft_id, options = {}) {
28
+ async function getNftInfo(nft_id, _options = {}) {
29
29
  const connection = Client.findConnection("clio", undefined, true);
30
30
  if (!connection) {
31
31
  throw new Error("There is no connection");
@@ -1,3 +1,3 @@
1
1
  import { FormattedMemo } from "../../v1/common/types/objects";
2
- declare function parseMemos(tx: any): Array<FormattedMemo> | undefined;
2
+ declare function parseMemos(tx: any): FormattedMemo[] | undefined;
3
3
  export default parseMemos;
@@ -10,7 +10,7 @@ const common_1 = require("../../common");
10
10
  const utils_1 = require("../../v1/common/utils");
11
11
  const client_1 = require("../../client");
12
12
  function groupByAddress(balanceChanges) {
13
- var grouped = lodash_1.default.groupBy(balanceChanges, function (node) {
13
+ const grouped = lodash_1.default.groupBy(balanceChanges, function (node) {
14
14
  return node.address;
15
15
  });
16
16
  return lodash_1.default.mapValues(grouped, function (group) {
@@ -23,7 +23,7 @@ function parseValue(value) {
23
23
  return new bignumber_js_1.default(value.value || value);
24
24
  }
25
25
  function computeBalanceChange(node) {
26
- var value = null;
26
+ let value = null;
27
27
  if (node.newFields.Balance) {
28
28
  value = parseValue(node.newFields.Balance);
29
29
  }
@@ -42,7 +42,7 @@ function parseFinalBalance(node) {
42
42
  return null;
43
43
  }
44
44
  function parseXRPQuantity(node, valueParser, nativeCurrency) {
45
- var value = valueParser(node);
45
+ const value = valueParser(node);
46
46
  if (value === null) {
47
47
  return null;
48
48
  }
@@ -56,7 +56,7 @@ function parseXRPQuantity(node, valueParser, nativeCurrency) {
56
56
  };
57
57
  }
58
58
  function flipTrustlinePerspective(quantity) {
59
- var negatedBalance = new bignumber_js_1.default(quantity.balance.value).negated();
59
+ const negatedBalance = new bignumber_js_1.default(quantity.balance.value).negated();
60
60
  return {
61
61
  address: quantity.balance.counterparty,
62
62
  balance: {
@@ -67,12 +67,12 @@ function flipTrustlinePerspective(quantity) {
67
67
  };
68
68
  }
69
69
  function parseTrustlineQuantity(node, valueParser) {
70
- var value = valueParser(node);
70
+ const value = valueParser(node);
71
71
  if (value === null) {
72
72
  return null;
73
73
  }
74
- var fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
75
- var result = {
74
+ const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
75
+ const result = {
76
76
  address: fields.LowLimit.issuer,
77
77
  balance: {
78
78
  counterparty: fields.HighLimit.issuer,
@@ -83,7 +83,7 @@ function parseTrustlineQuantity(node, valueParser) {
83
83
  return [result, flipTrustlinePerspective(result)];
84
84
  }
85
85
  function parseQuantities(metadata, valueParser, nativeCurrency) {
86
- var values = (0, utils_1.normalizeNodes)(metadata).map(function (node) {
86
+ const values = (0, utils_1.normalizeNodes)(metadata).map(function (node) {
87
87
  if (node.entryType === "AccountRoot") {
88
88
  return [parseXRPQuantity(node, valueParser, nativeCurrency)];
89
89
  }
@@ -23,7 +23,7 @@ function parseValue(value) {
23
23
  return new bignumber_js_1.default(value.value || value);
24
24
  }
25
25
  function computeBalanceChange(node) {
26
- var value = null;
26
+ let value = null;
27
27
  if (node.newFields.LockedBalance) {
28
28
  value = parseValue(node.newFields.LockedBalance);
29
29
  }
@@ -42,7 +42,7 @@ function parseFinalBalance(node) {
42
42
  return null;
43
43
  }
44
44
  function parseXRPQuantity(node, valueParser) {
45
- var value = valueParser(node);
45
+ const value = valueParser(node);
46
46
  if (value === null) {
47
47
  return null;
48
48
  }
@@ -56,12 +56,12 @@ function parseXRPQuantity(node, valueParser) {
56
56
  };
57
57
  }
58
58
  function parseTrustlineQuantity(node, valueParser) {
59
- var value = valueParser(node);
59
+ const value = valueParser(node);
60
60
  if (value === null) {
61
61
  return null;
62
62
  }
63
- var fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
64
- var result = {
63
+ const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
64
+ const result = {
65
65
  address: fields.LowLimit.issuer,
66
66
  lockedBalance: {
67
67
  counterparty: fields.HighLimit.issuer,
@@ -72,7 +72,7 @@ function parseTrustlineQuantity(node, valueParser) {
72
72
  return [result];
73
73
  }
74
74
  function parseQuantities(metadata, valueParser) {
75
- var values = (0, utils_1.normalizeNodes)(metadata).map(function (node) {
75
+ const values = (0, utils_1.normalizeNodes)(metadata).map(function (node) {
76
76
  if (node.entryType === "AccountRoot") {
77
77
  return [parseXRPQuantity(node, valueParser)];
78
78
  }
@@ -15,11 +15,11 @@ const currency_amount_1 = __importDefault(require("../ledger/currency-amount"));
15
15
  const client_1 = require("../../client");
16
16
  const lsfSell = 0x00020000;
17
17
  function convertOrderChange(order) {
18
- var takerGets = order.taker_gets;
19
- var takerPays = order.taker_pays;
20
- var direction = order.sell ? "sell" : "buy";
21
- var quantity = direction === "buy" ? takerPays : takerGets;
22
- var totalPrice = direction === "buy" ? takerGets : takerPays;
18
+ const takerGets = order.taker_gets;
19
+ const takerPays = order.taker_pays;
20
+ const direction = order.sell ? "sell" : "buy";
21
+ const quantity = direction === "buy" ? takerPays : takerGets;
22
+ const totalPrice = direction === "buy" ? takerGets : takerPays;
23
23
  return (0, common_1.removeUndefined)({
24
24
  direction: direction,
25
25
  quantity: quantity,
@@ -31,19 +31,19 @@ function convertOrderChange(order) {
31
31
  });
32
32
  }
33
33
  function getExpirationTime(node) {
34
- var expirationTime = node.finalFields.Expiration || node.newFields.Expiration;
34
+ const expirationTime = node.finalFields.Expiration || node.newFields.Expiration;
35
35
  if (expirationTime === undefined) {
36
36
  return undefined;
37
37
  }
38
38
  return new Date((0, models_1.ledgerTimeToTimestamp)(expirationTime)).toISOString();
39
39
  }
40
40
  function getQuality(node) {
41
- var takerGets = node.finalFields.TakerGets || node.newFields.TakerGets;
42
- var takerPays = node.finalFields.TakerPays || node.newFields.TakerPays;
43
- var takerGetsCurrency = takerGets.currency || (0, client_1.getNativeCurrency)();
44
- var takerPaysCurrency = takerPays.currency || (0, client_1.getNativeCurrency)();
45
- var bookDirectory = node.finalFields.BookDirectory || node.newFields.BookDirectory;
46
- var qualityHex = bookDirectory.substring(bookDirectory.length - 16);
41
+ const takerGets = node.finalFields.TakerGets || node.newFields.TakerGets;
42
+ const takerPays = node.finalFields.TakerPays || node.newFields.TakerPays;
43
+ const takerGetsCurrency = takerGets.currency || (0, client_1.getNativeCurrency)();
44
+ const takerPaysCurrency = takerPays.currency || (0, client_1.getNativeCurrency)();
45
+ const bookDirectory = node.finalFields.BookDirectory || node.newFields.BookDirectory;
46
+ const qualityHex = bookDirectory.substring(bookDirectory.length - 16);
47
47
  return (0, orderbook_quality_1.parseOrderbookQuality)(qualityHex, takerGetsCurrency, takerPaysCurrency);
48
48
  }
49
49
  function parseOrderStatus(node) {
@@ -63,27 +63,27 @@ function parseOrderStatus(node) {
63
63
  }
64
64
  function calculateDelta(finalAmount, previousAmount) {
65
65
  if (previousAmount) {
66
- var finalValue = new BigNumber(finalAmount.value);
67
- var previousValue = new BigNumber(previousAmount.value);
66
+ const finalValue = new BigNumber(finalAmount.value);
67
+ const previousValue = new BigNumber(previousAmount.value);
68
68
  return finalValue.minus(previousValue).abs().toString();
69
69
  }
70
70
  return "0";
71
71
  }
72
72
  function parseChangeAmount(node, type) {
73
- var status = parseOrderStatus(node);
73
+ const status = parseOrderStatus(node);
74
74
  if (status === "cancelled") {
75
75
  return (0, currency_amount_1.default)(node.finalFields[type]);
76
76
  }
77
77
  else if (status === "created") {
78
78
  return (0, currency_amount_1.default)(node.newFields[type]);
79
79
  }
80
- var finalAmount = (0, currency_amount_1.default)(node.finalFields[type]);
81
- var previousAmount = (0, currency_amount_1.default)(node.previousFields[type]);
82
- var value = calculateDelta(finalAmount, previousAmount);
80
+ const finalAmount = (0, currency_amount_1.default)(node.finalFields[type]);
81
+ const previousAmount = (0, currency_amount_1.default)(node.previousFields[type]);
82
+ const value = calculateDelta(finalAmount, previousAmount);
83
83
  return lodash_1.default.assign({}, finalAmount, { value: value });
84
84
  }
85
85
  function parseOrderChange(node) {
86
- var orderChange = convertOrderChange({
86
+ const orderChange = convertOrderChange({
87
87
  taker_pays: parseChangeAmount(node, "TakerPays"),
88
88
  taker_gets: parseChangeAmount(node, "TakerGets"),
89
89
  sell: (node.finalFields.Flags & lsfSell) !== 0,
@@ -103,8 +103,8 @@ function groupByAddress(orderChanges) {
103
103
  });
104
104
  }
105
105
  function parseOrderbookChanges(metadata) {
106
- var nodes = (0, utils_1.normalizeNodes)(metadata);
107
- var orderChanges = lodash_1.default.map(lodash_1.default.filter(nodes, function (node) {
106
+ const nodes = (0, utils_1.normalizeNodes)(metadata);
107
+ const orderChanges = lodash_1.default.map(lodash_1.default.filter(nodes, function (node) {
108
108
  return node.entryType === "Offer";
109
109
  }), parseOrderChange);
110
110
  return groupByAddress(orderChanges);
@@ -31,16 +31,16 @@ const assert = __importStar(require("assert"));
31
31
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
32
32
  const client_1 = require("../../client");
33
33
  function adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency) {
34
- var numeratorShift = takerPaysCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
35
- var denominatorShift = takerGetsCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
36
- var shift = numeratorShift - denominatorShift;
34
+ const numeratorShift = takerPaysCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
35
+ const denominatorShift = takerGetsCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
36
+ const shift = numeratorShift - denominatorShift;
37
37
  return shift === 0 ? new bignumber_js_1.default(quality).toString() : new bignumber_js_1.default(quality).shiftedBy(shift).toString();
38
38
  }
39
39
  function parseOrderbookQuality(qualityHex, takerGetsCurrency, takerPaysCurrency) {
40
40
  assert.ok(qualityHex.length === 16);
41
- var mantissa = new bignumber_js_1.default(qualityHex.substring(2), 16);
42
- var offset = parseInt(qualityHex.substring(0, 2), 16) - 100;
43
- var quality = mantissa.toString() + "e" + offset.toString();
41
+ const mantissa = new bignumber_js_1.default(qualityHex.substring(2), 16);
42
+ const offset = parseInt(qualityHex.substring(0, 2), 16) - 100;
43
+ const quality = mantissa.toString() + "e" + offset.toString();
44
44
  return adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency);
45
45
  }
46
46
  exports.parseOrderbookQuality = parseOrderbookQuality;
@@ -28,7 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const assert = __importStar(require("assert"));
30
30
  const common_1 = require("../../common");
31
- const ripple_address_codec_1 = require("ripple-address-codec");
32
31
  const memos_1 = __importDefault(require("../ledger/memos"));
33
32
  function parseAccountDelete(tx) {
34
33
  assert.ok(tx.TransactionType === "AccountDelete");
@@ -36,7 +35,6 @@ function parseAccountDelete(tx) {
36
35
  memos: (0, memos_1.default)(tx),
37
36
  destination: tx.Destination,
38
37
  destinationTag: tx.DestinationTag,
39
- destinationXAddress: (0, ripple_address_codec_1.classicAddressToXAddress)(tx.Destination, tx.DestinationTag == null ? false : tx.DestinationTag, false),
40
38
  });
41
39
  }
42
40
  exports.default = parseAccountDelete;
@@ -0,0 +1,3 @@
1
+ import { FormattedRemitsSpecification } from "../../v1/common/types/objects/remits";
2
+ declare function parseRemit(tx: any): FormattedRemitsSpecification;
3
+ export default parseRemit;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const assert = __importStar(require("assert"));
30
+ const common_1 = require("../../common");
31
+ const memos_1 = __importDefault(require("../ledger/memos"));
32
+ const account_1 = require("../ledger/account");
33
+ const uritoken_flags_1 = __importDefault(require("../ledger/uritoken-flags"));
34
+ function parseAmounts(amounts) {
35
+ if (!amounts) {
36
+ return undefined;
37
+ }
38
+ const result = [];
39
+ for (const amount of amounts) {
40
+ if (amount.AmountEntry.Amount) {
41
+ result.push(amount.AmountEntry.Amount);
42
+ }
43
+ }
44
+ if (result.length === 0) {
45
+ return undefined;
46
+ }
47
+ return result;
48
+ }
49
+ function parseMintURIToken(mintURIToken) {
50
+ if (!mintURIToken) {
51
+ return undefined;
52
+ }
53
+ return (0, common_1.removeUndefined)({
54
+ uri: mintURIToken.URI,
55
+ flags: (0, uritoken_flags_1.default)(mintURIToken.Flags ?? 0),
56
+ digest: mintURIToken.Digest,
57
+ });
58
+ }
59
+ function parseRemit(tx) {
60
+ assert.ok(tx.TransactionType === "Remit");
61
+ const source = {
62
+ address: (0, account_1.parseAccount)(tx.Account),
63
+ tag: tx.SourceTag,
64
+ };
65
+ const destination = {
66
+ address: tx.Destination,
67
+ tag: tx.DestinationTag,
68
+ };
69
+ return (0, common_1.removeUndefined)({
70
+ source: (0, common_1.removeUndefined)(source),
71
+ destination: (0, common_1.removeUndefined)(destination),
72
+ amounts: parseAmounts(tx.Amounts),
73
+ uritokenIDs: tx.URITokenIDs,
74
+ uritokenMint: parseMintURIToken(tx.MintURIToken),
75
+ blob: tx.Blob,
76
+ inform: tx.Inform,
77
+ invoiceID: tx.InvoiceID,
78
+ memos: (0, memos_1.default)(tx),
79
+ });
80
+ }
81
+ exports.default = parseRemit;
@@ -1,3 +1,3 @@
1
- import { FormattedUNLReportSpecification } from "../../v1/common/types/objects/unl_report";
2
- declare function parseImport(tx: any): FormattedUNLReportSpecification;
3
- export default parseImport;
1
+ import { FormattedUNLReportSpecification } from "../../v1/common/types/objects/unl_reports";
2
+ declare function parseUNLReport(tx: any): FormattedUNLReportSpecification;
3
+ export default parseUNLReport;
@@ -30,7 +30,7 @@ const assert = __importStar(require("assert"));
30
30
  const common_1 = require("../../common");
31
31
  const memos_1 = __importDefault(require("../ledger/memos"));
32
32
  const account_1 = require("../ledger/account");
33
- function parseImport(tx) {
33
+ function parseUNLReport(tx) {
34
34
  assert.ok(tx.TransactionType === "UNLReport");
35
35
  const source = {
36
36
  address: (0, account_1.parseAccount)(tx.Account),
@@ -44,4 +44,4 @@ function parseImport(tx) {
44
44
  memos: (0, memos_1.default)(tx),
45
45
  });
46
46
  }
47
- exports.default = parseImport;
47
+ exports.default = parseUNLReport;
@@ -14,11 +14,12 @@ import { FormattedNFTokenBurnSpecification, FormattedNFTokenMintSpecification, F
14
14
  import { FormattedURITokenBurnSpecification, FormattedURITokenBuySpecification, FormattedURITokenCreateSellOfferSpecification, FormattedURITokenCancelSellOfferSpecification, FormattedURITokenMintSpecification } from "../v1/common/types/objects/uritokens";
15
15
  import { FormattedImportSpecification } from "../v1/common/types/objects/import";
16
16
  import { FormattedInvokeSpecification } from "../v1/common/types/objects/invoke";
17
- import { FormattedUNLReportSpecification } from "../v1/common/types/objects/unl_report";
17
+ import { FormattedUNLReportSpecification } from "../v1/common/types/objects/unl_reports";
18
+ import { FormattedRemitsSpecification } from "../v1/common/types/objects/remits";
18
19
  import { FormattedAmendmentSpecification } from "../v1/common/types/objects/amendments";
19
20
  import { FormattedFeeUpdateSpecification } from "../v1/common/types/objects/fees";
20
21
  declare function parseTransactionType(type: string): string;
21
- export type FormattedSpecification = FormattedSettingsSpecification | FormattedAccountDeleteSpecification | FormattedCheckCancelSpecification | FormattedCheckCashSpecification | FormattedCheckCreateSpecification | FormattedDepositPreauthSpecification | FormattedEscrowCancelSpecification | FormattedEscrowCreateSpecification | FormattedEscrowFinishSpecification | FormattedOfferCancelSpecification | FormattedOfferCreateSpecification | FormattedPaymentSpecification | FormattedPaymentChannelClaimSpecification | FormattedPaymentChannelCreateSpecification | FormattedPaymentChannelFundSpecification | FormattedTicketCreateSpecification | FormattedTrustlineSpecification | FormattedNFTokenBurnSpecification | FormattedNFTokenMintSpecification | FormattedNFTokenCancelOfferSpecification | FormattedNFTokenCreateOfferSpecification | FormattedNFTokenAcceptOfferSpecification | FormattedURITokenBurnSpecification | FormattedURITokenBuySpecification | FormattedURITokenCreateSellOfferSpecification | FormattedURITokenCancelSellOfferSpecification | FormattedURITokenMintSpecification | FormattedImportSpecification | FormattedInvokeSpecification | FormattedUNLReportSpecification | FormattedAmendmentSpecification | FormattedFeeUpdateSpecification;
22
+ export type FormattedSpecification = FormattedSettingsSpecification | FormattedAccountDeleteSpecification | FormattedCheckCancelSpecification | FormattedCheckCashSpecification | FormattedCheckCreateSpecification | FormattedDepositPreauthSpecification | FormattedEscrowCancelSpecification | FormattedEscrowCreateSpecification | FormattedEscrowFinishSpecification | FormattedOfferCancelSpecification | FormattedOfferCreateSpecification | FormattedPaymentSpecification | FormattedPaymentChannelClaimSpecification | FormattedPaymentChannelCreateSpecification | FormattedPaymentChannelFundSpecification | FormattedTicketCreateSpecification | FormattedTrustlineSpecification | FormattedNFTokenBurnSpecification | FormattedNFTokenMintSpecification | FormattedNFTokenCancelOfferSpecification | FormattedNFTokenCreateOfferSpecification | FormattedNFTokenAcceptOfferSpecification | FormattedURITokenBurnSpecification | FormattedURITokenBuySpecification | FormattedURITokenCreateSellOfferSpecification | FormattedURITokenCancelSellOfferSpecification | FormattedURITokenMintSpecification | FormattedImportSpecification | FormattedInvokeSpecification | FormattedUNLReportSpecification | FormattedRemitsSpecification | FormattedAmendmentSpecification | FormattedFeeUpdateSpecification;
22
23
  export interface FormattedTransaction {
23
24
  type: string;
24
25
  address: string;
@@ -37,6 +37,7 @@ const uritoken_mint_1 = __importDefault(require("./specification/uritoken-mint")
37
37
  const import_1 = __importDefault(require("./specification/import"));
38
38
  const invoke_1 = __importDefault(require("./specification/invoke"));
39
39
  const unl_report_1 = __importDefault(require("./specification/unl-report"));
40
+ const remit_1 = __importDefault(require("./specification/remit"));
40
41
  const amendment_1 = __importDefault(require("./specification/amendment"));
41
42
  const fee_update_1 = __importDefault(require("./specification/fee-update"));
42
43
  const transactionTypeToType = {
@@ -72,6 +73,7 @@ const transactionTypeToType = {
72
73
  Import: "import",
73
74
  Invoke: "invoke",
74
75
  UNLReport: "unlReport",
76
+ Remit: "remit",
75
77
  EnableAmendment: "amendment",
76
78
  SetFee: "feeUpdate",
77
79
  };
@@ -110,6 +112,7 @@ const parserTypeFunc = {
110
112
  import: import_1.default,
111
113
  invoke: invoke_1.default,
112
114
  unlReport: unl_report_1.default,
115
+ remit: remit_1.default,
113
116
  amendment: amendment_1.default,
114
117
  feeUpdate: fee_update_1.default,
115
118
  };
@@ -16,7 +16,7 @@ export interface AccountObjectsRequest {
16
16
  }
17
17
  export interface AccountObjects {
18
18
  account: string;
19
- account_objects: Array<CheckLedgerEntry | RippleStateLedgerEntry | OfferLedgerEntry | SignerListLedgerEntry | EscrowLedgerEntry | PayChannelLedgerEntry | DepositPreauthLedgerEntry>;
19
+ account_objects: (CheckLedgerEntry | RippleStateLedgerEntry | OfferLedgerEntry | SignerListLedgerEntry | EscrowLedgerEntry | PayChannelLedgerEntry | DepositPreauthLedgerEntry)[];
20
20
  ledger_hash?: string;
21
21
  ledger_index?: number;
22
22
  ledger_current_index?: number;
@@ -2,7 +2,7 @@ import { FormattedIssuedCurrencyAmount } from "../objects";
2
2
  export interface GatewayBalancesRequest {
3
3
  account: string;
4
4
  strict?: boolean;
5
- hotwallet: string | Array<string>;
5
+ hotwallet: string | string[];
6
6
  ledger_hash?: string;
7
7
  ledger_index?: number | ("validated" | "closed" | "current");
8
8
  }
@@ -11,23 +11,23 @@ export type PathFindRequest = {
11
11
  send_max?: Amount;
12
12
  };
13
13
  export type RippledPathsResponse = {
14
- alternatives: Array<{
15
- paths_computed: Array<Array<{
14
+ alternatives: {
15
+ paths_computed: {
16
16
  type: number;
17
17
  type_hex: string;
18
18
  account?: string;
19
19
  issuer?: string;
20
20
  currency?: string;
21
- }>>;
21
+ }[][];
22
22
  source_amount: Amount;
23
- }>;
23
+ }[];
24
24
  type: string;
25
25
  destination_account: string;
26
26
  destination_amount: Amount;
27
- destination_currencies?: Array<string>;
27
+ destination_currencies?: string[];
28
28
  source_account: string;
29
- source_currencies?: Array<{
29
+ source_currencies?: {
30
30
  currency: string;
31
- }>;
31
+ }[];
32
32
  full_reply?: boolean;
33
33
  };
@@ -3,7 +3,6 @@ import { FormattedIssuedCurrencyAmount } from "../../../../types";
3
3
  export type FormattedAccountDeleteSpecification = {
4
4
  destination: string;
5
5
  destinationTag?: number;
6
- destinationXAddress: string;
7
6
  } & FormattedBaseSpecification;
8
7
  export type FormattedSourceAddress = {
9
8
  address: string;
@@ -0,0 +1,14 @@
1
+ export interface HookExecutionObjectInterface {
2
+ HookExecution: HookExecutionInterface;
3
+ }
4
+ export interface HookExecutionInterface {
5
+ HookAccount: string;
6
+ HookEmitCount: number;
7
+ HookExecutionIndex: number;
8
+ HookHash: string;
9
+ HookInstructionCount: string;
10
+ HookResult: number;
11
+ HookReturnCode: string;
12
+ HookReturnString: string;
13
+ HookStateChangeCount: number;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -18,5 +18,7 @@ export * from "./amendments";
18
18
  export * from "./fees";
19
19
  export * from "./import";
20
20
  export * from "./invoke";
21
- export * from "./hook";
21
+ export * from "./unl_reports";
22
+ export * from "./remits";
23
+ export * from "./hooks";
22
24
  export * from "../../../../types";
@@ -34,5 +34,7 @@ __exportStar(require("./amendments"), exports);
34
34
  __exportStar(require("./fees"), exports);
35
35
  __exportStar(require("./import"), exports);
36
36
  __exportStar(require("./invoke"), exports);
37
- __exportStar(require("./hook"), exports);
37
+ __exportStar(require("./unl_reports"), exports);
38
+ __exportStar(require("./remits"), exports);
39
+ __exportStar(require("./hooks"), exports);
38
40
  __exportStar(require("../../../../types"), exports);
@@ -26,10 +26,10 @@ export type FormattedLedger = {
26
26
  parentCloseTime: string;
27
27
  totalDrops: string;
28
28
  transactionHash: string;
29
- transactions?: Array<object>;
30
- transactionHashes?: Array<string>;
29
+ transactions?: object[];
30
+ transactionHashes?: string[];
31
31
  rawState?: string;
32
- stateHashes?: Array<string>;
32
+ stateHashes?: string[];
33
33
  };
34
34
  export type LedgerClosedEvent = {
35
35
  type: "ledgerClosed";
@@ -10,15 +10,15 @@ export type Path = {
10
10
  destination: Adjustment | MinAdjustment;
11
11
  paths: string;
12
12
  };
13
- export type GetPaths = Array<Path>;
13
+ export type GetPaths = Path[];
14
14
  export type PathFind = {
15
15
  source: {
16
16
  address: string;
17
17
  amount?: FormattedIssuedCurrencyAmount;
18
- currencies?: Array<{
18
+ currencies?: {
19
19
  currency: string;
20
20
  counterparty?: string;
21
- }>;
21
+ }[];
22
22
  };
23
23
  destination: {
24
24
  address: string;
@@ -0,0 +1,18 @@
1
+ import { FormattedBaseSpecification } from "./specification";
2
+ import { FormattedDestinationAddress, FormattedSourceAddress } from "./account";
3
+ import { Amount } from "../../../../types";
4
+ import { URITokenFlagsKeysInterface } from "./uritokens";
5
+ export type FormattedRemitsSpecification = {
6
+ source: FormattedSourceAddress;
7
+ destination: FormattedDestinationAddress;
8
+ amounts?: Amount[];
9
+ uritokenIDs?: string[];
10
+ uritokenMint?: {
11
+ uri: string;
12
+ flags?: URITokenFlagsKeysInterface;
13
+ digest?: string;
14
+ };
15
+ blob?: string;
16
+ inform?: string;
17
+ invoiceID?: string;
18
+ } & FormattedBaseSpecification;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { FormattedBaseSpecification } from "./specification";
2
+ import { FormattedSourceAddress } from "./account";
3
+ export type FormattedUNLReportSpecification = {
4
+ source: FormattedSourceAddress;
5
+ activeValidator?: string;
6
+ importVLKey?: string;
7
+ } & FormattedBaseSpecification;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/validator.js CHANGED
@@ -31,7 +31,6 @@ const assert = __importStar(require("assert"));
31
31
  const ripple_address_codec_1 = require("ripple-address-codec");
32
32
  const Crypto = __importStar(require("crypto"));
33
33
  const Base58 = __importStar(require("./base58"));
34
- const crypto_1 = __importDefault(require("crypto"));
35
34
  const elliptic_1 = __importDefault(require("elliptic"));
36
35
  const secp256k1 = new elliptic_1.default.ec("secp256k1");
37
36
  const ed25519 = new elliptic_1.default.eddsa("ed25519");
@@ -63,7 +62,7 @@ function classicAddressFromValidatorPK(pk) {
63
62
  }
64
63
  exports.classicAddressFromValidatorPK = classicAddressFromValidatorPK;
65
64
  function generateSecrets() {
66
- const keypair = crypto_1.default.generateKeyPairSync("ed25519", {
65
+ const keypair = Crypto.generateKeyPairSync("ed25519", {
67
66
  privateKeyEncoding: { format: "der", type: "pkcs8" },
68
67
  publicKeyEncoding: { format: "der", type: "spki" },
69
68
  });
@@ -123,7 +122,7 @@ function verify2(message, signature, publicKey) {
123
122
  }
124
123
  }
125
124
  else {
126
- const computedHash = crypto_1.default.createHash("sha512").update(message).digest().toString("hex").slice(0, 64);
125
+ const computedHash = Crypto.createHash("sha512").update(message).digest().toString("hex").slice(0, 64);
127
126
  const verifyKey = secp256k1.keyFromPublic(publicKey, "hex");
128
127
  if (verifyKey.verify(computedHash, signature)) {
129
128
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "2.7.10",
3
+ "version": "2.7.12",
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",
@@ -37,7 +37,7 @@
37
37
  "test": "node ./node_modules/mocha/bin/mocha",
38
38
  "build": "tsc",
39
39
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
40
- "lint": "tslint -p tsconfig.json",
40
+ "lint": "eslint -c .eslintrc.json --ext .ts src/",
41
41
  "prepare": "npm run build",
42
42
  "prepublishOnly": "npm test && npm run lint",
43
43
  "preversion": "npm run lint",
@@ -58,23 +58,26 @@
58
58
  "xrpl": "^2.14.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@types/chai": "^4.3.10",
61
+ "@types/chai": "^4.3.11",
62
62
  "@types/chai-as-promised": "^7.1.8",
63
- "@types/lodash": "^4.14.201",
64
- "@types/mocha": "^10.0.4",
63
+ "@types/lodash": "^4.14.202",
64
+ "@types/mocha": "^10.0.6",
65
65
  "@types/nconf": "^0.10.6",
66
- "@types/node": "^20.9.0",
67
- "@typescript-eslint/eslint-plugin": "^6.11.0",
68
- "@typescript-eslint/parser": "^6.11.0",
66
+ "@types/node": "^20.10.3",
67
+ "@typescript-eslint/eslint-plugin": "^6.13.2",
68
+ "@typescript-eslint/parser": "^6.13.2",
69
69
  "chai": "^4.3.10",
70
70
  "chai-as-promised": "^7.1.1",
71
+ "eslint": "^8.55.0",
72
+ "eslint-config-prettier": "^9.1.0",
73
+ "eslint-plugin-chai-friendly": "^0.7.2",
74
+ "eslint-plugin-import": "^2.29.0",
75
+ "eslint-plugin-n": "^16.3.1",
76
+ "eslint-plugin-promise": "^6.1.1",
71
77
  "mocha": "^10.2.0",
72
78
  "nconf": "^0.12.1",
73
- "prettier": "2.8.8",
74
79
  "ts-jest": "^29.1.1",
75
80
  "ts-node": "^10.9.1",
76
- "tslint": "^6.1.3",
77
- "tslint-config-prettier": "^1.18.0",
78
- "typescript": "^5.2.2"
81
+ "typescript": "^5.3.2"
79
82
  }
80
83
  }