@bithomp/xrpl-api 3.4.5 → 3.5.0

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.
@@ -32,7 +32,7 @@ declare class Connection extends EventEmitter {
32
32
  types: string[];
33
33
  latency: LatencyInfo[];
34
34
  readonly logger?: any;
35
- readonly timeout?: number;
35
+ readonly timeout: number;
36
36
  readonly connectionTimeout: number;
37
37
  readonly hash?: string;
38
38
  private onlineSince;
package/lib/connection.js CHANGED
@@ -45,7 +45,7 @@ const common_1 = require("./common");
45
45
  const utils_1 = require("./common/utils");
46
46
  const XRPLConnection = __importStar(require("xrpl/dist/npm/client/connection"));
47
47
  const RECONNECT_TIMEOUT = 1000 * 5;
48
- const LEDGER_CLOSED_TIMEOUT = 1000 * 15;
48
+ const LEDGER_CLOSED_TIMEOUT = 1000 * 20;
49
49
  const SERVER_INFO_UPDATE_INTERVAL = 1000 * 60 * 5;
50
50
  const AVAILABLE_LEDGER_INDEX_WINDOW = 1000;
51
51
  exports.DEFAULT_API_VERSION = xrpl_1.RIPPLED_API_V1;
@@ -64,7 +64,7 @@ class Connection extends events_1.EventEmitter {
64
64
  this.updateTypes();
65
65
  this.client = null;
66
66
  this.logger = options.logger;
67
- this.timeout = options.timeout;
67
+ this.timeout = options.timeout || LEDGER_CLOSED_TIMEOUT;
68
68
  this.connectionTimeout = options.connectionTimeout || RECONNECT_TIMEOUT;
69
69
  this.hash = crypto_1.default.createHash("sha256").update(url).digest("hex");
70
70
  if (typeof options.networkID === "number") {
@@ -114,7 +114,7 @@ class Connection extends events_1.EventEmitter {
114
114
  async request(request, options) {
115
115
  const result = await this._request(request, options);
116
116
  if (result?.error === "timeout") {
117
- const timeouts = this.latency.filter((info) => info.delta >= this.connectionTimeout).length;
117
+ const timeouts = this.latency.filter((info) => info.delta >= this.timeout).length;
118
118
  if (timeouts >= 3) {
119
119
  this.logger?.debug({
120
120
  service: "Bithomp::XRPL::Connection",
@@ -153,7 +153,7 @@ class Connection extends events_1.EventEmitter {
153
153
  return response;
154
154
  }
155
155
  catch (err) {
156
- this.updateLatency(RECONNECT_TIMEOUT);
156
+ this.updateLatency(err.name === "TimeoutError" ? this.timeout : this.connectionTimeout);
157
157
  this.logger?.debug({
158
158
  service: "Bithomp::XRPL::Connection",
159
159
  function: "request",
@@ -176,7 +176,6 @@ class Connection extends events_1.EventEmitter {
176
176
  return await this.request({ command: "submit", tx_blob: transaction });
177
177
  }
178
178
  catch (err) {
179
- this.updateLatency(1000);
180
179
  this.logger?.debug({
181
180
  service: "Bithomp::XRPL::Connection",
182
181
  function: "submit",
@@ -333,12 +333,24 @@ function counterpartyFilter(options, transaction) {
333
333
  if (transaction.tx.Destination === options.counterparty) {
334
334
  return true;
335
335
  }
336
+ if (transaction.tx.Delegate === options.counterparty) {
337
+ return true;
338
+ }
339
+ if (transaction.tx.Subject === options.counterparty) {
340
+ return true;
341
+ }
336
342
  if (transaction.tx.Amount?.issuer === options.counterparty) {
337
343
  return true;
338
344
  }
339
345
  if (transaction.tx.SendMax?.issuer === options.counterparty) {
340
346
  return true;
341
347
  }
348
+ if (typeof transaction.tx.TakerGets === "object" && transaction.tx.TakerGets?.issuer === options.counterparty) {
349
+ return true;
350
+ }
351
+ if (typeof transaction.tx.TakerPays === "object" && transaction.tx.TakerPays?.issuer === options.counterparty) {
352
+ return true;
353
+ }
342
354
  if (transaction.tx.LimitAmount?.issuer === options.counterparty) {
343
355
  return true;
344
356
  }
@@ -0,0 +1,5 @@
1
+ import { CredentialFlagsKeysInterface } from "../../types/credentials";
2
+ declare function parseCredentialFlags(value: number, options?: {
3
+ excludeFalse?: boolean;
4
+ }): CredentialFlagsKeysInterface;
5
+ export default parseCredentialFlags;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const credentials_1 = require("../../types/credentials");
4
+ const flags_1 = require("./flags");
5
+ function parseCredentialFlags(value, options = {}) {
6
+ return (0, flags_1.parseFlags)(value, credentials_1.CredentialFlagsKeys, options);
7
+ }
8
+ exports.default = parseCredentialFlags;
@@ -12,7 +12,7 @@ function parseMemos(tx) {
12
12
  return (0, common_1.removeUndefined)({
13
13
  type: (0, utils_1.hexToString)(m.Memo.MemoType),
14
14
  format: (0, utils_1.hexToString)(m.Memo.MemoFormat),
15
- data: decodeData(m.Memo.MemoData),
15
+ data: (0, utils_1.decodeHexData)(m.Memo.MemoData),
16
16
  });
17
17
  });
18
18
  }
@@ -25,13 +25,3 @@ function formattedMemoToMemo(memo) {
25
25
  }),
26
26
  };
27
27
  }
28
- function decodeData(data) {
29
- if (!data) {
30
- return undefined;
31
- }
32
- const decoded = (0, utils_1.hexToString)(data);
33
- if (decoded && decoded.includes("�")) {
34
- return data;
35
- }
36
- return decoded;
37
- }
@@ -31,17 +31,7 @@ function parseRemark(remark) {
31
31
  const { RemarkName, RemarkValue, Flags } = remark.Remark;
32
32
  return (0, common_1.removeUndefined)({
33
33
  name: (0, utils_1.hexToString)(RemarkName),
34
- value: decodeData(RemarkValue),
34
+ value: (0, utils_1.decodeHexData)(RemarkValue),
35
35
  flags: (0, remark_flags_1.default)(Flags),
36
36
  });
37
37
  }
38
- function decodeData(data) {
39
- if (!data) {
40
- return undefined;
41
- }
42
- const decoded = (0, utils_1.hexToString)(data);
43
- if (decoded && decoded.includes("�")) {
44
- return data;
45
- }
46
- return decoded;
47
- }
@@ -0,0 +1,16 @@
1
+ import { TransactionMetadata } from "xrpl";
2
+ import { CredentialFlagsKeysInterface } from "../../types";
3
+ interface FormattedCredentialSummaryInterface {
4
+ status?: "created" | "modified" | "deleted";
5
+ credentialIndex: string;
6
+ issuer?: string;
7
+ subject?: string;
8
+ credentialType?: string;
9
+ expiration?: number;
10
+ uri?: string;
11
+ flags?: CredentialFlagsKeysInterface;
12
+ previousTxnID?: string;
13
+ flagsChange?: CredentialFlagsKeysInterface;
14
+ }
15
+ declare function parseCredentialChanges(metadata: TransactionMetadata): FormattedCredentialSummaryInterface | undefined;
16
+ export { parseCredentialChanges };
@@ -0,0 +1,59 @@
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.parseCredentialChanges = parseCredentialChanges;
7
+ const models_1 = require("../../models");
8
+ const utils_1 = require("../utils");
9
+ const credential_flags_1 = __importDefault(require("../ledger/credential-flags"));
10
+ function parseCredentialStatus(node) {
11
+ if (node.diffType === "CreatedNode") {
12
+ return "created";
13
+ }
14
+ if (node.diffType === "ModifiedNode") {
15
+ return "modified";
16
+ }
17
+ if (node.diffType === "DeletedNode") {
18
+ return "deleted";
19
+ }
20
+ return undefined;
21
+ }
22
+ function summarizeCredential(node) {
23
+ const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
24
+ const prev = node.previousFields;
25
+ const summary = {
26
+ status: parseCredentialStatus(node),
27
+ credentialIndex: node.ledgerIndex,
28
+ issuer: final.Issuer,
29
+ subject: final.Subject,
30
+ credentialType: (0, utils_1.decodeHexData)(final.CredentialType),
31
+ flags: (0, credential_flags_1.default)(final.Flags, { excludeFalse: false }),
32
+ };
33
+ if (final.Expiration !== undefined) {
34
+ summary.expiration = (0, models_1.ledgerTimeToUnixTime)(final.Expiration);
35
+ }
36
+ if (final.URI !== undefined) {
37
+ summary.uri = final.URI;
38
+ }
39
+ if (node.diffType === "ModifiedNode") {
40
+ if (prev.Flags !== undefined) {
41
+ summary.flagsChange = (0, credential_flags_1.default)(prev.Flags, { excludeFalse: false });
42
+ }
43
+ }
44
+ if (node.PreviousTxnID) {
45
+ summary.previousTxnID = node.PreviousTxnID;
46
+ }
47
+ return summary;
48
+ }
49
+ function parseCredentialChanges(metadata) {
50
+ const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
51
+ const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
52
+ return node.LedgerEntryType === "Credential";
53
+ });
54
+ if (affectedNodes.length !== 1) {
55
+ return undefined;
56
+ }
57
+ const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
58
+ return summarizeCredential(normalizedNode);
59
+ }
@@ -18,5 +18,6 @@ export { parseOracleChanges } from "./oracle_changes";
18
18
  export { parseDeliveredAmount } from "./delivered_amount";
19
19
  export { parseMPTokenIssuanceChanges } from "./mptoken_issuance_changes";
20
20
  export { parseMPTokenChanges } from "./mptoken_changes";
21
+ export { parseCredentialChanges } from "./credential_changes";
21
22
  export { parseDelegateChanges } from "./delegate_changes";
22
23
  export { parseRemarksChanges } from "./remarks_changes";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseRemarksChanges = exports.parseDelegateChanges = exports.parseMPTokenChanges = exports.parseMPTokenIssuanceChanges = exports.parseDeliveredAmount = exports.parseOracleChanges = exports.parseDIDChanges = exports.parseAmmChanges = exports.parseUNLReportChanges = exports.parseEscrowChanges = exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseCheckChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
3
+ exports.parseRemarksChanges = exports.parseDelegateChanges = exports.parseCredentialChanges = exports.parseMPTokenChanges = exports.parseMPTokenIssuanceChanges = exports.parseDeliveredAmount = exports.parseOracleChanges = exports.parseDIDChanges = exports.parseAmmChanges = exports.parseUNLReportChanges = exports.parseEscrowChanges = exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseCheckChanges = 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");
@@ -41,6 +41,8 @@ var mptoken_issuance_changes_1 = require("./mptoken_issuance_changes");
41
41
  Object.defineProperty(exports, "parseMPTokenIssuanceChanges", { enumerable: true, get: function () { return mptoken_issuance_changes_1.parseMPTokenIssuanceChanges; } });
42
42
  var mptoken_changes_1 = require("./mptoken_changes");
43
43
  Object.defineProperty(exports, "parseMPTokenChanges", { enumerable: true, get: function () { return mptoken_changes_1.parseMPTokenChanges; } });
44
+ var credential_changes_1 = require("./credential_changes");
45
+ Object.defineProperty(exports, "parseCredentialChanges", { enumerable: true, get: function () { return credential_changes_1.parseCredentialChanges; } });
44
46
  var delegate_changes_1 = require("./delegate_changes");
45
47
  Object.defineProperty(exports, "parseDelegateChanges", { enumerable: true, get: function () { return delegate_changes_1.parseDelegateChanges; } });
46
48
  var remarks_changes_1 = require("./remarks_changes");
@@ -36,6 +36,7 @@ const MPTOKEN_TYPES = [
36
36
  "Payment",
37
37
  "Clawback",
38
38
  ];
39
+ const CREDENTIAL_TYPES = ["CredentialCreate", "CredentialAccept", "CredentialDelete"];
39
40
  const DELEGATE_TYPES = ["DelegateSet"];
40
41
  const REMARKS_TYPES = ["SetRemarks"];
41
42
  function parseOutcome(tx, nativeCurrency, definitions) {
@@ -64,6 +65,7 @@ function parseOutcome(tx, nativeCurrency, definitions) {
64
65
  oracleChanges: getOracleChanges(tx),
65
66
  mptokenIssuanceChanges: getMPTokenIssuanceChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
66
67
  mptokenChanges: getMPTokenChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
68
+ credentialChanges: getCredentialChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
67
69
  delegateChanges: getDelegateChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
68
70
  remarksChanges: getRemarksChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
69
71
  unlReportChanges: getUNLReportChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
@@ -202,6 +204,15 @@ function getMPTokenIssuanceChanges(tx, nativeCurrency) {
202
204
  const mptokenIssuanceChanges = (0, index_1.parseMPTokenIssuanceChanges)(tx);
203
205
  return Object.keys(mptokenIssuanceChanges).length > 0 ? mptokenIssuanceChanges : undefined;
204
206
  }
207
+ function getCredentialChanges(tx, nativeCurrency) {
208
+ if (nativeCurrency !== "XRP") {
209
+ return undefined;
210
+ }
211
+ if (!CREDENTIAL_TYPES.includes(tx.TransactionType)) {
212
+ return undefined;
213
+ }
214
+ return (0, index_1.parseCredentialChanges)(tx.meta);
215
+ }
205
216
  function getDelegateChanges(tx, nativeCurrency) {
206
217
  if (nativeCurrency !== "XRP") {
207
218
  return undefined;
@@ -0,0 +1,3 @@
1
+ import { FormattedCredentialAcceptSpecification } from "../../types/credentials";
2
+ declare function parseCredentialAccept(tx: any): FormattedCredentialAcceptSpecification;
3
+ export default parseCredentialAccept;
@@ -0,0 +1,54 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const assert = __importStar(require("assert"));
37
+ const common_1 = require("../../common");
38
+ const memos_1 = require("../ledger/memos");
39
+ const signers_1 = require("../ledger/signers");
40
+ const regular_key_1 = require("../ledger/regular-key");
41
+ const source_1 = require("../ledger/source");
42
+ const utils_1 = require("../utils");
43
+ function parseCredentialAccept(tx) {
44
+ assert.ok(tx.TransactionType === "CredentialAccept");
45
+ return (0, common_1.removeUndefined)({
46
+ source: (0, source_1.parseSource)(tx),
47
+ signers: (0, signers_1.parseSigners)(tx),
48
+ signer: (0, regular_key_1.parseSignerRegularKey)(tx),
49
+ issuer: tx.Issuer,
50
+ credentialType: (0, utils_1.hexToString)(tx.CredentialType),
51
+ memos: (0, memos_1.parseMemos)(tx),
52
+ });
53
+ }
54
+ exports.default = parseCredentialAccept;
@@ -0,0 +1,3 @@
1
+ import { FormattedCredentialCreateSpecification } from "../../types/credentials";
2
+ declare function parseCredentialCreate(tx: any): FormattedCredentialCreateSpecification;
3
+ export default parseCredentialCreate;
@@ -0,0 +1,56 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const assert = __importStar(require("assert"));
37
+ const common_1 = require("../../common");
38
+ const memos_1 = require("../ledger/memos");
39
+ const signers_1 = require("../ledger/signers");
40
+ const regular_key_1 = require("../ledger/regular-key");
41
+ const source_1 = require("../ledger/source");
42
+ const utils_1 = require("../utils");
43
+ function parseCredentialCreate(tx) {
44
+ assert.ok(tx.TransactionType === "CredentialCreate");
45
+ return (0, common_1.removeUndefined)({
46
+ source: (0, source_1.parseSource)(tx),
47
+ signers: (0, signers_1.parseSigners)(tx),
48
+ signer: (0, regular_key_1.parseSignerRegularKey)(tx),
49
+ subject: tx.Subject,
50
+ credentialType: (0, utils_1.decodeHexData)(tx.CredentialType),
51
+ expiration: tx.Expiration && (0, utils_1.parseTimestamp)(tx.Expiration),
52
+ uri: tx.URI,
53
+ memos: (0, memos_1.parseMemos)(tx),
54
+ });
55
+ }
56
+ exports.default = parseCredentialCreate;
@@ -0,0 +1,3 @@
1
+ import { FormattedCredentialDeleteSpecification } from "../../types/credentials";
2
+ declare function parseCredentialDelete(tx: any): FormattedCredentialDeleteSpecification;
3
+ export default parseCredentialDelete;
@@ -0,0 +1,55 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const assert = __importStar(require("assert"));
37
+ const common_1 = require("../../common");
38
+ const memos_1 = require("../ledger/memos");
39
+ const signers_1 = require("../ledger/signers");
40
+ const regular_key_1 = require("../ledger/regular-key");
41
+ const source_1 = require("../ledger/source");
42
+ const utils_1 = require("../utils");
43
+ function parseCredentialDelete(tx) {
44
+ assert.ok(tx.TransactionType === "CredentialDelete");
45
+ return (0, common_1.removeUndefined)({
46
+ source: (0, source_1.parseSource)(tx),
47
+ signers: (0, signers_1.parseSigners)(tx),
48
+ signer: (0, regular_key_1.parseSignerRegularKey)(tx),
49
+ issuer: tx.issuer,
50
+ subject: tx.Subject,
51
+ credentialType: (0, utils_1.hexToString)(tx.CredentialType),
52
+ memos: (0, memos_1.parseMemos)(tx),
53
+ });
54
+ }
55
+ exports.default = parseCredentialDelete;
@@ -22,13 +22,14 @@ import { FormattedAmmBidSpecification, FormattedAmmCreateSpecification, Formatte
22
22
  import { FormattedDIDSetSpecification, FormattedDIDDeleteSpecification } from "../types/did";
23
23
  import { FormattedOracleSetSpecification, FormattedOracleDeleteSpecification } from "../types/oracle";
24
24
  import { FormattedMPTokenIssuanceCreateSpecification, FormattedMPTokenAuthorizeSpecification, FormattedMPTokenIssuanceSetSpecification, FormattedMPTokenIssuanceDestroySpecification } from "../types/mptokens";
25
+ import { FormattedCredentialCreateSpecification, FormattedCredentialAcceptSpecification, FormattedCredentialDeleteSpecification } from "../types/credentials";
25
26
  import { FormattedDelegateSetSpecification } from "../types/delegate";
26
27
  import { FormattedSetRemarksSpecification } from "../types/remarks";
27
28
  import { FormattedGenesisMintSpecification } from "../types/genesis_mint";
28
29
  import { FormattedAmendmentSpecification } from "../types/amendments";
29
30
  import { FormattedFeeUpdateSpecification } from "../types/fees";
30
31
  declare function parseTransactionType(type: string): string;
31
- export type FormattedSpecification = FormattedUnrecognizedParserSpecification | FormattedSettingsSpecification | FormattedAccountDeleteSpecification | FormattedCheckCancelSpecification | FormattedCheckCashSpecification | FormattedCheckCreateSpecification | FormattedDepositPreauthSpecification | FormattedEscrowCancelSpecification | FormattedEscrowCreateSpecification | FormattedEscrowFinishSpecification | FormattedOfferCancelSpecification | FormattedOfferCreateSpecification | FormattedPaymentSpecification | FormattedPaymentChannelClaimSpecification | FormattedPaymentChannelCreateSpecification | FormattedPaymentChannelFundSpecification | FormattedTicketCreateSpecification | FormattedTrustlineSpecification | FormattedNFTokenBurnSpecification | FormattedNFTokenMintSpecification | FormattedNFTokenModifySpecification | FormattedNFTokenCancelOfferSpecification | FormattedNFTokenCreateOfferSpecification | FormattedNFTokenAcceptOfferSpecification | FormattedURITokenBurnSpecification | FormattedURITokenBuySpecification | FormattedURITokenCreateSellOfferSpecification | FormattedURITokenCancelSellOfferSpecification | FormattedURITokenMintSpecification | FormattedImportSpecification | FormattedInvokeSpecification | FormattedUNLReportSpecification | FormattedRemitsSpecification | FormattedClawbackSpecification | FormattedAmmBidSpecification | FormattedAmmCreateSpecification | FormattedAmmDeleteSpecification | FormattedAmmDepositSpecification | FormattedAmmWithdrawSpecification | FormattedAmmVoteSpecification | FormattedAmmClawbackSpecification | FormattedGenesisMintSpecification | FormattedAmendmentSpecification | FormattedFeeUpdateSpecification | FormattedDIDSetSpecification | FormattedDIDDeleteSpecification | FormattedOracleSetSpecification | FormattedOracleDeleteSpecification | FormattedMPTokenIssuanceCreateSpecification | FormattedMPTokenAuthorizeSpecification | FormattedMPTokenIssuanceSetSpecification | FormattedMPTokenIssuanceDestroySpecification | FormattedDelegateSetSpecification | FormattedSetRemarksSpecification;
32
+ export type FormattedSpecification = FormattedUnrecognizedParserSpecification | FormattedSettingsSpecification | FormattedAccountDeleteSpecification | FormattedCheckCancelSpecification | FormattedCheckCashSpecification | FormattedCheckCreateSpecification | FormattedDepositPreauthSpecification | FormattedEscrowCancelSpecification | FormattedEscrowCreateSpecification | FormattedEscrowFinishSpecification | FormattedOfferCancelSpecification | FormattedOfferCreateSpecification | FormattedPaymentSpecification | FormattedPaymentChannelClaimSpecification | FormattedPaymentChannelCreateSpecification | FormattedPaymentChannelFundSpecification | FormattedTicketCreateSpecification | FormattedTrustlineSpecification | FormattedNFTokenBurnSpecification | FormattedNFTokenMintSpecification | FormattedNFTokenModifySpecification | FormattedNFTokenCancelOfferSpecification | FormattedNFTokenCreateOfferSpecification | FormattedNFTokenAcceptOfferSpecification | FormattedURITokenBurnSpecification | FormattedURITokenBuySpecification | FormattedURITokenCreateSellOfferSpecification | FormattedURITokenCancelSellOfferSpecification | FormattedURITokenMintSpecification | FormattedImportSpecification | FormattedInvokeSpecification | FormattedUNLReportSpecification | FormattedRemitsSpecification | FormattedClawbackSpecification | FormattedAmmBidSpecification | FormattedAmmCreateSpecification | FormattedAmmDeleteSpecification | FormattedAmmDepositSpecification | FormattedAmmWithdrawSpecification | FormattedAmmVoteSpecification | FormattedAmmClawbackSpecification | FormattedGenesisMintSpecification | FormattedAmendmentSpecification | FormattedFeeUpdateSpecification | FormattedDIDSetSpecification | FormattedDIDDeleteSpecification | FormattedOracleSetSpecification | FormattedOracleDeleteSpecification | FormattedMPTokenIssuanceCreateSpecification | FormattedMPTokenAuthorizeSpecification | FormattedMPTokenIssuanceSetSpecification | FormattedMPTokenIssuanceDestroySpecification | FormattedCredentialCreateSpecification | FormattedCredentialAcceptSpecification | FormattedCredentialDeleteSpecification | FormattedDelegateSetSpecification | FormattedSetRemarksSpecification;
32
33
  export interface FormattedTransaction {
33
34
  type: string;
34
35
  address: string;
@@ -59,6 +59,9 @@ const mptoken_issuance_set_1 = __importDefault(require("./specification/mptoken-
59
59
  const mptoken_issuance_destroy_1 = __importDefault(require("./specification/mptoken-issuance-destroy"));
60
60
  const delegate_set_1 = __importDefault(require("./specification/delegate-set"));
61
61
  const set_remarks_1 = __importDefault(require("./specification/set-remarks"));
62
+ const credential_create_1 = __importDefault(require("./specification/credential-create"));
63
+ const credential_accept_1 = __importDefault(require("./specification/credential-accept"));
64
+ const credential_delete_1 = __importDefault(require("./specification/credential-delete"));
62
65
  const genesis_mint_1 = __importDefault(require("./specification/genesis-mint"));
63
66
  const amendment_1 = __importDefault(require("./specification/amendment"));
64
67
  const fee_update_1 = __importDefault(require("./specification/fee-update"));
@@ -113,6 +116,9 @@ const transactionTypeToType = {
113
116
  MPTokenAuthorize: "MPTokenAuthorize",
114
117
  MPTokenIssuanceSet: "MPTokenIssuanceSet",
115
118
  MPTokenIssuanceDestroy: "MPTokenIssuanceDestroy",
119
+ CredentialCreate: "CredentialCreate",
120
+ CredentialAccept: "CredentialAccept",
121
+ CredentialDelete: "CredentialDelete",
116
122
  DelegateSet: "DelegateSet",
117
123
  SetRemarks: "SetRemarks",
118
124
  GenesisMint: "genesisMint",
@@ -171,6 +177,9 @@ const parserTypeFunc = {
171
177
  MPTokenAuthorize: mptoken_authorize_1.default,
172
178
  MPTokenIssuanceSet: mptoken_issuance_set_1.default,
173
179
  MPTokenIssuanceDestroy: mptoken_issuance_destroy_1.default,
180
+ CredentialCreate: credential_create_1.default,
181
+ CredentialAccept: credential_accept_1.default,
182
+ CredentialDelete: credential_delete_1.default,
174
183
  DelegateSet: delegate_set_1.default,
175
184
  SetRemarks: set_remarks_1.default,
176
185
  genesisMint: genesis_mint_1.default,
@@ -24,9 +24,10 @@ declare function removeGenericCounterparty(amount: IssuedCurrencyAmount | Format
24
24
  declare function normalizeNode(affectedNode: Node): NormalizedNode;
25
25
  declare function normalizeNodes(metadata: TransactionMetadata): NormalizedNode[];
26
26
  declare function hexToString(hex: string | undefined): string | undefined;
27
+ declare function decodeHexData(data?: string): string | undefined;
27
28
  declare function stringToHex(value: string | undefined): string | undefined;
28
29
  declare function bytesToHex(value: Uint8Array | ArrayBufferLike): string;
29
30
  declare function hexToBytes(value: string): Uint8Array;
30
31
  declare function parseUint32(buf: Buffer, cur: number): string;
31
32
  declare function parseUint64(buf: Buffer, cur: number): string;
32
- export { NormalizedNode, parseQuality, parseTimestamp, adjustQualityForXRP, isPartialPayment, removeGenericCounterparty, normalizeNodes, normalizeNode, hexToString, stringToHex, bytesToHex, hexToBytes, parseUint32, parseUint64, };
33
+ export { NormalizedNode, parseQuality, parseTimestamp, adjustQualityForXRP, isPartialPayment, removeGenericCounterparty, normalizeNodes, normalizeNode, hexToString, decodeHexData, stringToHex, bytesToHex, hexToBytes, parseUint32, parseUint64, };
@@ -11,6 +11,7 @@ exports.removeGenericCounterparty = removeGenericCounterparty;
11
11
  exports.normalizeNodes = normalizeNodes;
12
12
  exports.normalizeNode = normalizeNode;
13
13
  exports.hexToString = hexToString;
14
+ exports.decodeHexData = decodeHexData;
14
15
  exports.stringToHex = stringToHex;
15
16
  exports.bytesToHex = bytesToHex;
16
17
  exports.hexToBytes = hexToBytes;
@@ -72,11 +73,23 @@ function normalizeNodes(metadata) {
72
73
  function hexToString(hex) {
73
74
  return hex ? Buffer.from(hex, "hex").toString("utf-8") : undefined;
74
75
  }
76
+ function decodeHexData(data) {
77
+ if (!data) {
78
+ return undefined;
79
+ }
80
+ const decoded = hexToString(data);
81
+ if (decoded && decoded.includes("�")) {
82
+ return data;
83
+ }
84
+ return decoded;
85
+ }
75
86
  function stringToHex(value) {
76
87
  return value ? Buffer.from(value, "utf8").toString("hex").toUpperCase() : undefined;
77
88
  }
78
89
  function bytesToHex(value) {
79
- return Buffer.from(value).toString("hex").toUpperCase();
90
+ return Buffer.from(value)
91
+ .toString("hex")
92
+ .toUpperCase();
80
93
  }
81
94
  function hexToBytes(value) {
82
95
  if (value.length % 2 !== 0) {
@@ -0,0 +1,25 @@
1
+ import { FormattedBaseSpecification } from "./specification";
2
+ export declare enum CredentialFlags {
3
+ lsfAccepted = 65536
4
+ }
5
+ export declare const CredentialFlagsKeys: {
6
+ accepted: CredentialFlags;
7
+ };
8
+ export interface CredentialFlagsKeysInterface {
9
+ accepted: boolean;
10
+ }
11
+ export type FormattedCredentialCreateSpecification = {
12
+ subject?: string;
13
+ credentialType?: string;
14
+ expiration?: number;
15
+ uri?: string;
16
+ } & FormattedBaseSpecification;
17
+ export type FormattedCredentialAcceptSpecification = {
18
+ issuer?: string;
19
+ credentialType?: string;
20
+ } & FormattedBaseSpecification;
21
+ export type FormattedCredentialDeleteSpecification = {
22
+ issuer?: string;
23
+ subject?: string;
24
+ credentialType?: string;
25
+ } & FormattedBaseSpecification;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CredentialFlagsKeys = exports.CredentialFlags = void 0;
4
+ var CredentialFlags;
5
+ (function (CredentialFlags) {
6
+ CredentialFlags[CredentialFlags["lsfAccepted"] = 65536] = "lsfAccepted";
7
+ })(CredentialFlags || (exports.CredentialFlags = CredentialFlags = {}));
8
+ exports.CredentialFlagsKeys = {
9
+ accepted: CredentialFlags.lsfAccepted,
10
+ };
@@ -26,5 +26,6 @@ export * from "./invoke";
26
26
  export * from "./unl_reports";
27
27
  export * from "./remits";
28
28
  export * from "./hooks";
29
+ export * from "./credentials";
29
30
  export * from "./delegate";
30
31
  export * from "./remarks";
@@ -42,5 +42,6 @@ __exportStar(require("./invoke"), exports);
42
42
  __exportStar(require("./unl_reports"), exports);
43
43
  __exportStar(require("./remits"), exports);
44
44
  __exportStar(require("./hooks"), exports);
45
+ __exportStar(require("./credentials"), exports);
45
46
  __exportStar(require("./delegate"), exports);
46
47
  __exportStar(require("./remarks"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.4.5",
3
+ "version": "3.5.0",
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",
@@ -43,7 +43,7 @@
43
43
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
44
44
  "lint": "eslint",
45
45
  "prepare": "npm run build",
46
- "-prepublishOnly": "npm test && npm run lint",
46
+ "prepublishOnly": "npm test && npm run lint",
47
47
  "preversion": "npm run lint",
48
48
  "version": "npm run format && git add -A src",
49
49
  "postversion": "git push && git push --tags"