@bithomp/xrpl-api 3.7.17 → 3.7.19

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
@@ -373,6 +373,15 @@ class Connection extends events_1.EventEmitter {
373
373
  });
374
374
  this.client.on("error", (source, message, error) => {
375
375
  try {
376
+ if (source === "noPermission") {
377
+ if (!error.status) {
378
+ error.status = "error";
379
+ }
380
+ if (this.client) {
381
+ this.client.requestManager.handleResponse(error);
382
+ return;
383
+ }
384
+ }
376
385
  this.logger?.error({
377
386
  service: "Bithomp::XRPL::Connection",
378
387
  emit: "error",
@@ -1,8 +1,13 @@
1
1
  import { XrplDefinitionsBase } from "ripple-binary-codec";
2
2
  import { Connection } from "../connection";
3
+ import { ErrorResponse } from "../models/base_model";
3
4
  export interface GetFeeOptions {
4
5
  connection?: Connection;
5
6
  tx?: any;
6
7
  definitions?: XrplDefinitionsBase;
7
8
  }
9
+ export interface GetFeeDataResult {
10
+ fee: string | null;
11
+ }
12
+ export declare function getFeeData(options?: GetFeeOptions): Promise<GetFeeDataResult | ErrorResponse>;
8
13
  export declare function getFee(options?: GetFeeOptions): Promise<string | null>;
package/lib/ledger/fee.js CHANGED
@@ -36,12 +36,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getFeeData = getFeeData;
39
40
  exports.getFee = getFee;
40
41
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
41
42
  const ripple_binary_codec_1 = require("ripple-binary-codec");
42
43
  const Client = __importStar(require("../client"));
43
44
  const common_1 = require("../common");
44
- async function getFee(options = {}) {
45
+ async function getFeeData(options = {}) {
45
46
  const connection = options.connection || Client.findConnection();
46
47
  if (!connection) {
47
48
  throw new Error("There is no connection");
@@ -57,13 +58,42 @@ async function getFee(options = {}) {
57
58
  command: "fee",
58
59
  tx_blob: txBlob,
59
60
  });
61
+ if (!response) {
62
+ return {
63
+ status: "error",
64
+ error: "invalidResponse",
65
+ };
66
+ }
67
+ if (response.error) {
68
+ const { error, error_code, error_message, error_exception, status, validated } = response;
69
+ return (0, common_1.removeUndefined)({
70
+ error,
71
+ error_code,
72
+ error_message,
73
+ error_exception,
74
+ status,
75
+ validated,
76
+ });
77
+ }
60
78
  const openLedgerFee = response?.result?.drops?.open_ledger_fee;
61
79
  if (!openLedgerFee) {
62
- return null;
80
+ return {
81
+ status: "error",
82
+ error: "No open_ledger_fee data in response",
83
+ };
63
84
  }
64
85
  const fee = new bignumber_js_1.default(openLedgerFee)
65
86
  .multipliedBy(Client.feeCushion)
66
87
  .dividedBy(common_1.dropsInXRP)
67
88
  .decimalPlaces(6, bignumber_js_1.default.ROUND_UP);
68
- return fee.toString();
89
+ return {
90
+ fee: fee.toString(),
91
+ };
92
+ }
93
+ async function getFee(options = {}) {
94
+ const response = await getFeeData(options);
95
+ if ("fee" in response) {
96
+ return response.fee;
97
+ }
98
+ return null;
69
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.7.17",
3
+ "version": "3.7.19",
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",