@bithomp/xrpl-api 3.1.7 → 3.1.8

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/client.d.ts CHANGED
@@ -18,6 +18,6 @@ export interface ClientConnection {
18
18
  }
19
19
  export declare function setup(servers: ClientConnection[], options?: ClientOptions): void;
20
20
  export declare function connect(): Promise<void>;
21
- export declare function disconnect(): void;
21
+ export declare function disconnect(): Promise<void>;
22
22
  export declare function getNativeCurrency(): string;
23
23
  export declare function findConnection(type?: string, url?: string, strongFilter?: boolean, hash?: string, networkID?: number): Connection | null;
package/lib/client.js CHANGED
@@ -61,13 +61,13 @@ async function connect() {
61
61
  await connection.connect();
62
62
  }
63
63
  }
64
- function disconnect() {
64
+ async function disconnect() {
65
65
  exports.logger?.debug({
66
66
  service: "Bithomp::XRPL::Client",
67
67
  function: "disconnect",
68
68
  });
69
69
  for (const connection of clientConnections) {
70
- connection.disconnect();
70
+ await connection.disconnect();
71
71
  }
72
72
  }
73
73
  function getNativeCurrency() {
package/lib/connection.js CHANGED
@@ -279,6 +279,9 @@ class Connection extends events_1.EventEmitter {
279
279
  this.client.connection.on("validationReceived", (validation) => {
280
280
  this.emit("validationReceived", validation);
281
281
  });
282
+ this.client.connection.on("manifestReceived", (manifest) => {
283
+ this.emit("manifestReceived", manifest);
284
+ });
282
285
  this.client.connection.on("peerStatusChange", (status) => {
283
286
  this.emit("peerStatusChange", status);
284
287
  });
@@ -355,8 +358,11 @@ class Connection extends events_1.EventEmitter {
355
358
  return { status: "success" };
356
359
  }
357
360
  async subscribe(streams, accounts) {
361
+ if (this.shutdown) {
362
+ return { error: "shutdownConnection", error_message: "Connection is shutdown.", status: "error" };
363
+ }
358
364
  if (this.streamsSubscribed === true && streams === undefined && accounts === undefined) {
359
- return null;
365
+ return { status: "success" };
360
366
  }
361
367
  streams = streams || Object.keys(this.streams);
362
368
  accounts = accounts || Object.keys(this.accounts);
@@ -28,10 +28,17 @@ export interface GetAccountNFTOffersObjectsOptions {
28
28
  marker?: string;
29
29
  }
30
30
  export declare function getAccountNFTOffersObjects(account: string, options?: GetAccountNFTOffersObjectsOptions): Promise<AccountNFTObjectsResponse | ErrorResponse>;
31
+ export interface GetAccountDepositPreauthObjectsOptions {
32
+ ledgerHash?: string;
33
+ ledgerIndex?: LedgerIndex;
34
+ limit?: number;
35
+ marker?: string;
36
+ }
37
+ export declare function getAccountDepositPreauthObjects(account: string, options?: GetAccountDepositPreauthObjectsOptions): Promise<any | ErrorResponse>;
31
38
  export interface GetAccountURITokensObjectsOptions {
32
39
  ledgerHash?: string;
33
40
  ledgerIndex?: LedgerIndex;
34
41
  limit?: number;
35
42
  marker?: string;
36
43
  }
37
- export declare function getAccountURITokensObjects(account: string, options?: GetAccountNFTOffersObjectsOptions): Promise<AccountURITokensObjectsResponse | ErrorResponse>;
44
+ export declare function getAccountURITokensObjects(account: string, options?: GetAccountURITokensObjectsOptions): Promise<AccountURITokensObjectsResponse | ErrorResponse>;
@@ -27,6 +27,7 @@ exports.getAccountObjects = getAccountObjects;
27
27
  exports.getAccountAllObjects = getAccountAllObjects;
28
28
  exports.getAccountLinesObjects = getAccountLinesObjects;
29
29
  exports.getAccountNFTOffersObjects = getAccountNFTOffersObjects;
30
+ exports.getAccountDepositPreauthObjects = getAccountDepositPreauthObjects;
30
31
  exports.getAccountURITokensObjects = getAccountURITokensObjects;
31
32
  const Client = __importStar(require("../client"));
32
33
  const account_object_1 = require("../models/account_object");
@@ -78,7 +79,8 @@ async function getAccountObjects(account, options = {}) {
78
79
  }
79
80
  async function getAccountAllObjects(account, options = {}) {
80
81
  const loadOptions = { ...options };
81
- loadOptions.connection = loadOptions.connection || Client.findConnection("account_objects", undefined, undefined);
82
+ loadOptions.connection =
83
+ loadOptions.connection || Client.findConnection("account_objects", undefined, undefined);
82
84
  const timeStart = new Date();
83
85
  const limit = loadOptions.limit;
84
86
  let response;
@@ -127,7 +129,7 @@ async function getAccountAllObjects(account, options = {}) {
127
129
  };
128
130
  }
129
131
  response.account_objects = accountObjects;
130
- if (!options.hasOwnProperty("limit")) {
132
+ if (!options.hasOwnProperty("limit") || options.limit === undefined) {
131
133
  delete response.limit;
132
134
  }
133
135
  return response;
@@ -172,8 +174,22 @@ async function getAccountNFTOffersObjects(account, options = {}) {
172
174
  nft_offers: nftOffers,
173
175
  };
174
176
  }
177
+ async function getAccountDepositPreauthObjects(account, options = {}) {
178
+ const response = await getAccountAllObjects(account, {
179
+ type: "deposit_preauth",
180
+ ledgerHash: options.ledgerHash,
181
+ ledgerIndex: options.ledgerIndex,
182
+ limit: options.limit,
183
+ marker: options.marker,
184
+ });
185
+ if ("error" in response) {
186
+ return response;
187
+ }
188
+ return response;
189
+ }
175
190
  async function getAccountURITokensObjects(account, options = {}) {
176
191
  const response = await getAccountAllObjects(account, {
192
+ type: "uri_token",
177
193
  ledgerHash: options.ledgerHash,
178
194
  ledgerIndex: options.ledgerIndex,
179
195
  limit: options.limit,
@@ -183,12 +199,12 @@ async function getAccountURITokensObjects(account, options = {}) {
183
199
  return response;
184
200
  }
185
201
  const accountObjects = response.account_objects;
186
- const uriTokens = (0, account_object_1.accountObjectsToURITokens)(accountObjects);
202
+ const uritokens = (0, account_object_1.accountObjectsToURITokens)(accountObjects);
187
203
  return {
188
204
  account: response.account,
189
205
  ledger_hash: response.ledger_hash,
190
206
  ledger_index: response.ledger_index,
191
207
  validated: response.validated,
192
- uritokens: uriTokens,
208
+ uritokens: uritokens,
193
209
  };
194
210
  }
@@ -2,7 +2,7 @@ import { LedgerEntry } from "xrpl";
2
2
  import { Trustline } from "./account_lines";
3
3
  import { Amount } from "../types";
4
4
  export type AccountObject = LedgerEntry.Check | LedgerEntry.DepositPreauth | LedgerEntry.Escrow | LedgerEntry.Offer | LedgerEntry.PayChannel | LedgerEntry.SignerList | LedgerEntry.Ticket | LedgerEntry.RippleState;
5
- export type AccountObjectType = "check" | "escrow" | "offer" | "payment_channel" | "signer_list" | "state" | "ticket" | "nft_offer";
5
+ export type AccountObjectType = Exclude<LedgerEntry.LedgerEntryFilter, "amendments" | "fee" | "hashes"> | "uri_token";
6
6
  export interface AccountObjects {
7
7
  account: string;
8
8
  account_objects: AccountObject[];
@@ -70,7 +70,7 @@ function accountObjectsToURITokens(accountObjects) {
70
70
  const uriTokenObjects = accountObjects.filter((obj) => {
71
71
  return obj.LedgerEntryType === "URIToken";
72
72
  });
73
- const uriTokens = uriTokenObjects.map((obj) => {
73
+ const uritokens = uriTokenObjects.map((obj) => {
74
74
  return (0, common_1.removeUndefined)({
75
75
  flags: obj.Flags,
76
76
  index: obj.index,
@@ -84,5 +84,5 @@ function accountObjectsToURITokens(accountObjects) {
84
84
  transaction_hash: obj.PreviousTxnID,
85
85
  });
86
86
  });
87
- return uriTokens;
87
+ return uritokens;
88
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
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",