@bithomp/xrpl-api 3.0.2 → 3.0.4

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.
@@ -0,0 +1,13 @@
1
+ import { Connection } from "../connection";
2
+ import { ErrorResponse } from "../models/base_model";
3
+ import { IssuedCurrency } from "../types";
4
+ import { LedgerIndex } from "../models/ledger";
5
+ export interface GetAmmInfoOptions {
6
+ url?: string;
7
+ type?: string;
8
+ connection?: Connection;
9
+ ledgerIndex?: LedgerIndex;
10
+ account?: string;
11
+ }
12
+ export declare function getAmmInfo(ammAccount: string, options?: GetAmmInfoOptions): Promise<object | ErrorResponse>;
13
+ export declare function getAmmInfoByAssets(asset: string | IssuedCurrency, asset2: string | IssuedCurrency, options?: GetAmmInfoOptions): Promise<object | ErrorResponse>;
@@ -0,0 +1,102 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getAmmInfoByAssets = exports.getAmmInfo = void 0;
27
+ const Client = __importStar(require("../client"));
28
+ async function getAmmInfo(ammAccount, options = {}) {
29
+ const connection = options.connection || Client.findConnection(options.type, options.url, true);
30
+ if (!connection) {
31
+ throw new Error("There is no connection");
32
+ }
33
+ if (!ammAccount) {
34
+ return {
35
+ error: "invalidParams",
36
+ error_code: 31,
37
+ error_message: "Invalid parameters.",
38
+ };
39
+ }
40
+ const response = await connection.request({
41
+ command: "amm_info",
42
+ ledger_index: options.ledgerIndex || "validated",
43
+ account: options.account,
44
+ amm_account: ammAccount,
45
+ });
46
+ if (!response) {
47
+ return {
48
+ status: "error",
49
+ error: "invalidResponse",
50
+ };
51
+ }
52
+ if (response.error) {
53
+ const { error, error_code, error_message, status, validated } = response;
54
+ return {
55
+ error,
56
+ error_code,
57
+ error_message,
58
+ status,
59
+ validated,
60
+ };
61
+ }
62
+ return response?.result;
63
+ }
64
+ exports.getAmmInfo = getAmmInfo;
65
+ async function getAmmInfoByAssets(asset, asset2, options = {}) {
66
+ const connection = options.connection || Client.findConnection(options.type, options.url, true);
67
+ if (!connection) {
68
+ throw new Error("There is no connection");
69
+ }
70
+ if (!asset || !asset2) {
71
+ return {
72
+ error: "invalidParams",
73
+ error_code: 31,
74
+ error_message: "Invalid parameters.",
75
+ };
76
+ }
77
+ const response = await connection.request({
78
+ command: "amm_info",
79
+ ledger_index: options.ledgerIndex || "validated",
80
+ account: options.account,
81
+ asset: asset,
82
+ asset2: asset2,
83
+ });
84
+ if (!response) {
85
+ return {
86
+ status: "error",
87
+ error: "invalidResponse",
88
+ };
89
+ }
90
+ if (response.error) {
91
+ const { error, error_code, error_message, status, validated } = response;
92
+ return {
93
+ error,
94
+ error_code,
95
+ error_message,
96
+ status,
97
+ validated,
98
+ };
99
+ }
100
+ return response?.result;
101
+ }
102
+ exports.getAmmInfoByAssets = getAmmInfoByAssets;
@@ -5,6 +5,7 @@ export * from "./account_nfts";
5
5
  export * from "./account_objects";
6
6
  export * from "./account_offers";
7
7
  export * from "./account_tx";
8
+ export * from "./amm_info";
8
9
  export * from "./book_offers";
9
10
  export * from "./currency";
10
11
  export * from "./fee";
@@ -21,6 +21,7 @@ __exportStar(require("./account_nfts"), exports);
21
21
  __exportStar(require("./account_objects"), exports);
22
22
  __exportStar(require("./account_offers"), exports);
23
23
  __exportStar(require("./account_tx"), exports);
24
+ __exportStar(require("./amm_info"), exports);
24
25
  __exportStar(require("./book_offers"), exports);
25
26
  __exportStar(require("./currency"), exports);
26
27
  __exportStar(require("./fee"), exports);
@@ -142,6 +142,7 @@ async function getTransactionByCTID(ctid, options = {}) {
142
142
  error: "txnNotFound",
143
143
  };
144
144
  }
145
+ ledgerTx.ctid = ctid;
145
146
  const result = (0, transaction_1.ledgerTxToTx)(ledgerTx, ledgerIndex, ledger.close_time);
146
147
  if (formatted === true) {
147
148
  return (0, transaction_1.getTxDetails)(result, options.includeRawTransaction === true, undefined, options.definitions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
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",
@@ -63,21 +63,21 @@
63
63
  "@types/lodash": "^4.17.0",
64
64
  "@types/mocha": "^10.0.6",
65
65
  "@types/nconf": "^0.10.6",
66
- "@types/node": "^20.11.30",
67
- "@typescript-eslint/eslint-plugin": "^7.3.1",
68
- "@typescript-eslint/parser": "^7.3.1",
66
+ "@types/node": "^20.12.7",
67
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
68
+ "@typescript-eslint/parser": "^7.7.0",
69
69
  "chai": "^4.4.1",
70
70
  "chai-as-promised": "^7.1.1",
71
71
  "eslint": "^8.57.0",
72
72
  "eslint-config-prettier": "^9.1.0",
73
73
  "eslint-plugin-chai-friendly": "^0.7.4",
74
74
  "eslint-plugin-import": "^2.29.1",
75
- "eslint-plugin-n": "^16.6.2",
75
+ "eslint-plugin-n": "^17.2.1",
76
76
  "eslint-plugin-promise": "^6.1.1",
77
- "mocha": "^10.3.0",
77
+ "mocha": "^10.4.0",
78
78
  "nconf": "^0.12.1",
79
79
  "ts-jest": "^29.1.2",
80
80
  "ts-node": "^10.9.2",
81
- "typescript": "^5.4.3"
81
+ "typescript": "^5.4.5"
82
82
  }
83
83
  }