@bithomp/xrpl-api 2.6.4 → 2.6.6

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.
@@ -12,6 +12,7 @@ export interface GetTransactionOptions {
12
12
  legacy?: boolean;
13
13
  formatted?: boolean;
14
14
  includeRawTransaction?: boolean;
15
+ definitions?: XrplDefinitionsBase;
15
16
  }
16
17
  export declare function getTransaction(transaction: string, options?: GetTransactionOptions): Promise<TransactionResponse | FormattedTransaction | ErrorResponse>;
17
18
  export declare function getTransactionByCTID(ctid: string, options?: GetTransactionOptions): Promise<TransactionResponse | FormattedTransaction | ErrorResponse>;
@@ -29,7 +30,7 @@ interface LegacyPaymentInterface {
29
30
  secret: string;
30
31
  fee?: string;
31
32
  }
32
- export declare function legacyPayment(data: LegacyPaymentInterface, definitions?: XrplDefinitionsBase): Promise<TransactionResponse | FormattedTransaction | ErrorResponse>;
33
+ export declare function legacyPayment(data: LegacyPaymentInterface, definitions?: XrplDefinitionsBase, validateTx?: boolean): Promise<TransactionResponse | FormattedTransaction | ErrorResponse>;
33
34
  export declare function getAccountPaymentParams(account: string, connection?: Connection): Promise<AccountPaymentParamsInterface | ErrorResponse>;
34
35
  export interface SubmitOptionsInterface {
35
36
  connection?: Connection;
@@ -72,13 +72,13 @@ async function getTransaction(transaction, options = {}) {
72
72
  const result = response?.result;
73
73
  if (typeof result === "object") {
74
74
  if (formatted === true) {
75
- return (0, transaction_1.getTxDetails)(result, options.includeRawTransaction === true);
75
+ return (0, transaction_1.getTxDetails)(result, options.includeRawTransaction === true, undefined, options.definitions);
76
76
  }
77
77
  if (options.balanceChanges === true && typeof result.meta === "object") {
78
78
  result.balanceChanges = xrpl.getBalanceChanges(result.meta);
79
79
  }
80
80
  if (options.specification === true) {
81
- const details = (0, transaction_1.getTxDetails)(result, true);
81
+ const details = (0, transaction_1.getTxDetails)(result, true, undefined, options.definitions);
82
82
  result.specification = details.specification;
83
83
  result.outcome = details.outcome;
84
84
  result.rawTransaction = details.rawTransaction;
@@ -144,13 +144,13 @@ async function getTransactionByCTID(ctid, options = {}) {
144
144
  }
145
145
  const result = (0, transaction_1.ledgerTxToTx)(ledgerTx, ledgerIndex, ledger.close_time);
146
146
  if (formatted === true) {
147
- return (0, transaction_1.getTxDetails)(result, options.includeRawTransaction === true);
147
+ return (0, transaction_1.getTxDetails)(result, options.includeRawTransaction === true, undefined, options.definitions);
148
148
  }
149
149
  if (options.balanceChanges === true && typeof result.meta === "object") {
150
150
  result.balanceChanges = xrpl.getBalanceChanges(result.meta);
151
151
  }
152
152
  if (options.specification === true) {
153
- const details = (0, transaction_1.getTxDetails)(result, true);
153
+ const details = (0, transaction_1.getTxDetails)(result, true, undefined, options.definitions);
154
154
  result.specification = details.specification;
155
155
  result.outcome = details.outcome;
156
156
  result.rawTransaction = details.rawTransaction;
@@ -158,7 +158,7 @@ async function getTransactionByCTID(ctid, options = {}) {
158
158
  return result;
159
159
  }
160
160
  exports.getTransactionByCTID = getTransactionByCTID;
161
- async function legacyPayment(data, definitions) {
161
+ async function legacyPayment(data, definitions, validateTx) {
162
162
  const connection = Client.findConnection("payment, submit, !clio");
163
163
  if (!connection) {
164
164
  throw new Error("There is no connection");
@@ -197,7 +197,7 @@ async function legacyPayment(data, definitions) {
197
197
  transaction.Sequence = paymentParams.sequence;
198
198
  transaction.LastLedgerSequence = paymentParams.lastLedgerSequence;
199
199
  const wallet = xrpl.Wallet.fromSeed(data.secret);
200
- const signedTransaction = (0, wallet_1.signTransaction)(wallet, transaction, false, definitions).tx_blob;
200
+ const signedTransaction = (0, wallet_1.signTransaction)(wallet, transaction, false, definitions, validateTx).tx_blob;
201
201
  return await submit(signedTransaction, { connection, definitions });
202
202
  }
203
203
  exports.legacyPayment = legacyPayment;
@@ -1,4 +1,5 @@
1
1
  import { Transaction, TransactionMetadata } from "xrpl";
2
+ import { XrplDefinitionsBase } from "ripple-binary-codec";
2
3
  import { FormattedSpecification, FormattedTransaction } from "../parse/transaction";
3
4
  export { FormattedTransaction } from "../parse/transaction";
4
5
  import { Outcome } from "../v1/transaction/types";
@@ -32,10 +33,10 @@ export interface AccountPaymentParamsInterface {
32
33
  lastLedgerSequence?: number;
33
34
  networkID?: number;
34
35
  }
35
- export declare function getTxDetails(tx: TransactionResponse, includeRawTransaction: boolean): FormattedTransaction;
36
- export declare function getAccountTxDetails(tx: AccountTransaction, includeRawTransaction: boolean): FormattedTransaction;
37
- export declare function getLedgerTxDetails(tx: LedgerTransaction, ledgerIndex: number, closeTime: number, includeRawTransaction: boolean): FormattedTransaction;
38
- export declare function getStreamTxDetails(tx: StreamTransaction, includeRawTransaction: boolean): FormattedTransaction;
36
+ export declare function getTxDetails(tx: TransactionResponse, includeRawTransaction: boolean, nativeCurrency?: string, definitions?: XrplDefinitionsBase): FormattedTransaction;
37
+ export declare function getAccountTxDetails(tx: AccountTransaction, includeRawTransaction: boolean, nativeCurrency?: string): FormattedTransaction;
38
+ export declare function getLedgerTxDetails(tx: LedgerTransaction, ledgerIndex: number, closeTime: number, includeRawTransaction: boolean, nativeCurrency?: string, definitions?: XrplDefinitionsBase): FormattedTransaction;
39
+ export declare function getStreamTxDetails(tx: StreamTransaction, includeRawTransaction: boolean, nativeCurrency?: string, definitions?: XrplDefinitionsBase): FormattedTransaction;
39
40
  export declare function accountTxToTx(accountTx: AccountTransaction): TransactionResponse;
40
41
  export declare function ledgerTxToTx(ledgerTx: LedgerTransaction, ledgerIndex: number, closeTime: number): TransactionResponse;
41
42
  export declare function streamTxToTx(streamTx: StreamTransaction): TransactionResponse;
@@ -7,20 +7,20 @@ exports.decodeCTID = exports.encodeCTID = exports.isCTID = exports.streamTxToTx
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const transaction_1 = require("../parse/transaction");
9
9
  const CTID_REGEX = /^[cC]{1}[a-fA-F0-9]{15}$/;
10
- function getTxDetails(tx, includeRawTransaction) {
11
- return (0, transaction_1.parseTransaction)(tx, includeRawTransaction);
10
+ function getTxDetails(tx, includeRawTransaction, nativeCurrency, definitions) {
11
+ return (0, transaction_1.parseTransaction)(tx, includeRawTransaction, nativeCurrency, definitions);
12
12
  }
13
13
  exports.getTxDetails = getTxDetails;
14
- function getAccountTxDetails(tx, includeRawTransaction) {
15
- return getTxDetails(accountTxToTx(tx), includeRawTransaction);
14
+ function getAccountTxDetails(tx, includeRawTransaction, nativeCurrency) {
15
+ return getTxDetails(accountTxToTx(tx), includeRawTransaction, nativeCurrency);
16
16
  }
17
17
  exports.getAccountTxDetails = getAccountTxDetails;
18
- function getLedgerTxDetails(tx, ledgerIndex, closeTime, includeRawTransaction) {
19
- return getTxDetails(ledgerTxToTx(tx, ledgerIndex, closeTime), includeRawTransaction);
18
+ function getLedgerTxDetails(tx, ledgerIndex, closeTime, includeRawTransaction, nativeCurrency, definitions) {
19
+ return getTxDetails(ledgerTxToTx(tx, ledgerIndex, closeTime), includeRawTransaction, nativeCurrency, definitions);
20
20
  }
21
21
  exports.getLedgerTxDetails = getLedgerTxDetails;
22
- function getStreamTxDetails(tx, includeRawTransaction) {
23
- return getTxDetails(streamTxToTx(tx), includeRawTransaction);
22
+ function getStreamTxDetails(tx, includeRawTransaction, nativeCurrency, definitions) {
23
+ return getTxDetails(streamTxToTx(tx), includeRawTransaction, nativeCurrency, definitions);
24
24
  }
25
25
  exports.getStreamTxDetails = getStreamTxDetails;
26
26
  function accountTxToTx(accountTx) {
@@ -0,0 +1,2 @@
1
+ import { FormattedEmitDetails } from "../../v1/common/types/objects/emit_details";
2
+ export declare function parseEmittedDetails(tx: any): FormattedEmitDetails | undefined;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseEmittedDetails = void 0;
4
+ function parseEmittedDetails(tx) {
5
+ if (tx && tx.EmitDetails) {
6
+ return {
7
+ emitBurden: tx.EmitDetails.EmitBurden,
8
+ emitGeneration: tx.EmitDetails.EmitGeneration,
9
+ emitHookHash: tx.EmitDetails.EmitHookHash,
10
+ emitNonce: tx.EmitDetails.EmitNonce,
11
+ emitParentTxnID: tx.EmitDetails.EmitParentTxnID,
12
+ };
13
+ }
14
+ }
15
+ exports.parseEmittedDetails = parseEmittedDetails;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseImportBlob = void 0;
4
4
  const ripple_binary_codec_1 = require("ripple-binary-codec");
5
- ;
6
- const ripple_hashes_1 = require("ripple-hashes");
5
+ const wallet_1 = require("../../wallet");
7
6
  const vl_1 = require("../../models/vl");
8
7
  const transaction_1 = require("../../models/transaction");
8
+ const MAINNET_NATIVE_CURRENCY = "XRP";
9
9
  function parseImportBlob(blob) {
10
10
  try {
11
11
  const decodedBlob = JSON.parse(Buffer.from(blob, "hex").toString("utf8"));
@@ -17,7 +17,7 @@ function parseImportBlob(blob) {
17
17
  }
18
18
  const tx = (0, ripple_binary_codec_1.decode)(decodedBlob.transaction.blob);
19
19
  const meta = (0, ripple_binary_codec_1.decode)(decodedBlob.transaction.meta);
20
- const parsedTX = (0, transaction_1.getAccountTxDetails)({ tx: tx, meta: meta, validated: true }, false);
20
+ const parsedTX = (0, transaction_1.getAccountTxDetails)({ tx: tx, meta: meta, validated: true }, false, MAINNET_NATIVE_CURRENCY);
21
21
  return {
22
22
  ledger: decodedBlob.ledger,
23
23
  validation: {
@@ -25,7 +25,7 @@ function parseImportBlob(blob) {
25
25
  unl: (0, vl_1.parseVL)(decodedBlob.validation.unl),
26
26
  },
27
27
  transaction: {
28
- id: (0, ripple_hashes_1.computeBinaryTransactionHash)(decodedBlob.transaction.blob),
28
+ id: (0, wallet_1.hashSignedTx)(decodedBlob.transaction.blob),
29
29
  tx: (0, ripple_binary_codec_1.decode)(decodedBlob.transaction.blob),
30
30
  meta: (0, ripple_binary_codec_1.decode)(decodedBlob.transaction.meta),
31
31
  proof: decodedBlob.transaction.proof,
@@ -1,4 +1,4 @@
1
- declare function parseBalanceChanges(metadata: any): {
1
+ declare function parseBalanceChanges(metadata: any, nativeCurrency?: string): {
2
2
  [x: string]: any[];
3
3
  };
4
4
  declare function parseFinalBalances(metadata: any): {
@@ -41,7 +41,7 @@ function parseFinalBalance(node) {
41
41
  }
42
42
  return null;
43
43
  }
44
- function parseXRPQuantity(node, valueParser) {
44
+ function parseXRPQuantity(node, valueParser, nativeCurrency) {
45
45
  var value = valueParser(node);
46
46
  if (value === null) {
47
47
  return null;
@@ -50,7 +50,7 @@ function parseXRPQuantity(node, valueParser) {
50
50
  address: node.finalFields.Account || node.newFields.Account,
51
51
  balance: {
52
52
  counterparty: "",
53
- currency: (0, client_1.getNativeCurrency)(),
53
+ currency: nativeCurrency || (0, client_1.getNativeCurrency)(),
54
54
  value: (0, common_1.dropsToXrp)(value).toString(),
55
55
  },
56
56
  };
@@ -82,10 +82,10 @@ function parseTrustlineQuantity(node, valueParser) {
82
82
  };
83
83
  return [result, flipTrustlinePerspective(result)];
84
84
  }
85
- function parseQuantities(metadata, valueParser) {
85
+ function parseQuantities(metadata, valueParser, nativeCurrency) {
86
86
  var values = (0, utils_1.normalizeNodes)(metadata).map(function (node) {
87
87
  if (node.entryType === "AccountRoot") {
88
- return [parseXRPQuantity(node, valueParser)];
88
+ return [parseXRPQuantity(node, valueParser, nativeCurrency)];
89
89
  }
90
90
  else if (node.entryType === "RippleState") {
91
91
  return parseTrustlineQuantity(node, valueParser);
@@ -94,8 +94,8 @@ function parseQuantities(metadata, valueParser) {
94
94
  });
95
95
  return groupByAddress(lodash_1.default.compact(lodash_1.default.flatten(values)));
96
96
  }
97
- function parseBalanceChanges(metadata) {
98
- return parseQuantities(metadata, computeBalanceChange);
97
+ function parseBalanceChanges(metadata, nativeCurrency) {
98
+ return parseQuantities(metadata, computeBalanceChange, nativeCurrency);
99
99
  }
100
100
  exports.parseBalanceChanges = parseBalanceChanges;
101
101
  function parseFinalBalances(metadata) {
@@ -0,0 +1,9 @@
1
+ import { XrplDefinitionsBase } from "ripple-binary-codec";
2
+ import { FormattedSpecification } from "../../parse/transaction";
3
+ interface FormattedEmittedTxnInterface {
4
+ id?: string | undefined;
5
+ specification: FormattedSpecification;
6
+ tx: any;
7
+ }
8
+ export declare function parseEmittedTxns(tx: any, definitions?: XrplDefinitionsBase): FormattedEmittedTxnInterface[] | undefined;
9
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseEmittedTxns = void 0;
4
+ const common_1 = require("../../common");
5
+ const wallet_1 = require("../../wallet");
6
+ const transaction_1 = require("../../parse/transaction");
7
+ function parseEmittedTxns(tx, definitions) {
8
+ return new EmittedTxns(tx, definitions).call();
9
+ }
10
+ exports.parseEmittedTxns = parseEmittedTxns;
11
+ class EmittedTxns {
12
+ constructor(tx, definitions) {
13
+ this.tx = tx;
14
+ this.emittedTxns = [];
15
+ this.definitions = definitions;
16
+ }
17
+ call() {
18
+ if (this.hasAffectedNodes() === false) {
19
+ return undefined;
20
+ }
21
+ this.parseAffectedNodes();
22
+ if (this.emittedTxns.length === 0) {
23
+ return undefined;
24
+ }
25
+ return this.emittedTxns;
26
+ }
27
+ hasAffectedNodes() {
28
+ if (this.tx.meta?.AffectedNodes === undefined) {
29
+ return false;
30
+ }
31
+ if (this.tx.meta?.AffectedNodes?.length === 0) {
32
+ return false;
33
+ }
34
+ return true;
35
+ }
36
+ parseAffectedNodes() {
37
+ for (const affectedNode of this.tx.meta.AffectedNodes) {
38
+ const node = affectedNode.CreatedNode;
39
+ if (node?.LedgerEntryType === "EmittedTxn" && node?.LedgerIndex) {
40
+ if (affectedNode.CreatedNode) {
41
+ const tx = node.NewFields.EmittedTxn;
42
+ let id;
43
+ try {
44
+ id = (0, wallet_1.hashSignedTx)(tx, this.definitions, false);
45
+ }
46
+ catch (err) {
47
+ }
48
+ this.emittedTxns.push((0, common_1.removeUndefined)({
49
+ id,
50
+ specification: (0, transaction_1.parseTransaction)(tx, false).specification,
51
+ tx,
52
+ }));
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
@@ -8,3 +8,4 @@ export { parseLockedBalanceChanges } from "./locked_balance_changes";
8
8
  export { parseChannelChanges } from "./channel_changes";
9
9
  export { parseOrderbookChanges } from "./orderbook_changes";
10
10
  export { parseHooksExecutions } from "./hooks_executions";
11
+ export { parseEmittedTxns } from "./emitted_txns";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
3
+ exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = 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");
@@ -21,3 +21,5 @@ var orderbook_changes_1 = require("./orderbook_changes");
21
21
  Object.defineProperty(exports, "parseOrderbookChanges", { enumerable: true, get: function () { return orderbook_changes_1.parseOrderbookChanges; } });
22
22
  var hooks_executions_1 = require("./hooks_executions");
23
23
  Object.defineProperty(exports, "parseHooksExecutions", { enumerable: true, get: function () { return hooks_executions_1.parseHooksExecutions; } });
24
+ var emitted_txns_1 = require("./emitted_txns");
25
+ Object.defineProperty(exports, "parseEmittedTxns", { enumerable: true, get: function () { return emitted_txns_1.parseEmittedTxns; } });
@@ -1,3 +1,4 @@
1
+ import { XrplDefinitionsBase } from "ripple-binary-codec";
1
2
  import { Outcome } from "../v1/transaction/types";
2
- declare function parseOutcome(tx: any): Outcome | undefined;
3
+ declare function parseOutcome(tx: any, nativeCurrency?: string, definitions?: XrplDefinitionsBase): Outcome | undefined;
3
4
  export { parseOutcome };
@@ -60,12 +60,12 @@ function parseDeliveredAmount(tx) {
60
60
  }
61
61
  return undefined;
62
62
  }
63
- function parseOutcome(tx) {
63
+ function parseOutcome(tx, nativeCurrency, definitions) {
64
64
  const metadata = tx.meta || tx.metaData;
65
65
  if (!metadata) {
66
66
  return undefined;
67
67
  }
68
- const balanceChanges = (0, index_1.parseBalanceChanges)(metadata);
68
+ const balanceChanges = (0, index_1.parseBalanceChanges)(metadata, nativeCurrency);
69
69
  const lockedBalanceChanges = (0, index_1.parseLockedBalanceChanges)(metadata);
70
70
  const orderbookChanges = (0, index_1.parseOrderbookChanges)(metadata);
71
71
  const channelChanges = (0, index_1.parseChannelChanges)(metadata);
@@ -75,6 +75,7 @@ function parseOutcome(tx) {
75
75
  const uritokenSellOfferChanges = (0, index_1.parseURITokenSellOfferChanges)(tx);
76
76
  const affectedObjects = (0, index_1.parseAffectedObjects)(tx);
77
77
  const hooksExecutions = (0, index_1.parseHooksExecutions)(tx);
78
+ const emittedTxns = (0, index_1.parseEmittedTxns)(tx, definitions);
78
79
  removeEmptyCounterpartyInBalanceChanges(balanceChanges);
79
80
  removeEmptyCounterpartyInBalanceChanges(lockedBalanceChanges);
80
81
  removeEmptyCounterpartyInOrderbookChanges(orderbookChanges);
@@ -92,6 +93,7 @@ function parseOutcome(tx) {
92
93
  uritokenSellOfferChanges: Object.keys(uritokenSellOfferChanges).length > 0 ? uritokenSellOfferChanges : undefined,
93
94
  affectedObjects: affectedObjects ? (0, common_1.removeUndefined)(affectedObjects) : undefined,
94
95
  hooksExecutions,
96
+ emittedTxns,
95
97
  ledgerVersion: tx.ledger_index,
96
98
  indexInLedger: tx.meta.TransactionIndex,
97
99
  deliveredAmount: parseDeliveredAmount(tx),
@@ -36,10 +36,10 @@ function parseImport(tx) {
36
36
  address: tx.Account,
37
37
  tag: tx.SourceTag,
38
38
  };
39
- return {
39
+ return (0, common_1.removeUndefined)({
40
40
  blob: (0, import_1.parseImportBlob)(tx.Blob),
41
41
  source: (0, common_1.removeUndefined)(source),
42
42
  memos: (0, memos_1.default)(tx),
43
- };
43
+ });
44
44
  }
45
45
  exports.default = parseImport;
@@ -30,14 +30,17 @@ const assert = __importStar(require("assert"));
30
30
  const common_1 = require("../../common");
31
31
  const memos_1 = __importDefault(require("../ledger/memos"));
32
32
  const uritoken_flags_1 = __importDefault(require("../ledger/uritoken-flags"));
33
+ const emit_details_1 = require("../ledger/emit_details");
33
34
  function parseNFTokenBurn(tx) {
34
35
  assert.ok(tx.TransactionType === "URITokenMint");
36
+ const emittedDetails = (0, emit_details_1.parseEmittedDetails)(tx);
35
37
  return (0, common_1.removeUndefined)({
36
38
  uri: tx.URI,
37
39
  flags: (0, uritoken_flags_1.default)(tx.Flags),
38
40
  digest: tx.Digest,
39
41
  amount: tx.Amount,
40
42
  destination: tx.Destination,
43
+ emittedDetails,
41
44
  memos: (0, memos_1.default)(tx),
42
45
  });
43
46
  }
@@ -1,3 +1,4 @@
1
+ import { XrplDefinitionsBase } from "ripple-binary-codec";
1
2
  import { Outcome } from "../v1/transaction/types";
2
3
  import { FormattedAccountDeleteSpecification } from "../v1/common/types/objects/account";
3
4
  import { FormattedSettingsSpecification } from "../v1/common/types/objects/settings";
@@ -26,5 +27,5 @@ export interface FormattedTransaction {
26
27
  outcome?: Outcome;
27
28
  rawTransaction?: string;
28
29
  }
29
- declare function parseTransaction(tx: any, includeRawTransaction: boolean): FormattedTransaction;
30
+ declare function parseTransaction(tx: any, includeRawTransaction: boolean, nativeCurrency?: string, definitions?: XrplDefinitionsBase): FormattedTransaction;
30
31
  export { parseTransactionType, parseTransaction };
@@ -109,7 +109,7 @@ const parserTypeFunc = {
109
109
  amendment: amendment_1.default,
110
110
  feeUpdate: fee_update_1.default,
111
111
  };
112
- function parseTransaction(tx, includeRawTransaction) {
112
+ function parseTransaction(tx, includeRawTransaction, nativeCurrency, definitions) {
113
113
  const type = parseTransactionType(tx.TransactionType);
114
114
  const parser = parserTypeFunc[type];
115
115
  const specification = parser
@@ -121,7 +121,7 @@ function parseTransaction(tx, includeRawTransaction) {
121
121
  if (!parser) {
122
122
  includeRawTransaction = true;
123
123
  }
124
- const outcome = (0, outcome_1.parseOutcome)(tx);
124
+ const outcome = (0, outcome_1.parseOutcome)(tx, nativeCurrency, definitions);
125
125
  return (0, common_1.removeUndefined)({
126
126
  type: type,
127
127
  address: tx.Account,
@@ -0,0 +1,7 @@
1
+ export type FormattedEmitDetails = {
2
+ emitBurden: string;
3
+ emitGeneration: number;
4
+ emitHookHash: string;
5
+ emitNonce: string;
6
+ emitParentTxnID: string;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/wallet.d.ts CHANGED
@@ -14,4 +14,5 @@ export declare function signTransaction(wallet: Wallet, transaction: Transaction
14
14
  tx_blob: string;
15
15
  hash: string;
16
16
  };
17
- export { XrplDefinitionsBase, XrplDefinitions, DEFAULT_DEFINITIONS };
17
+ declare function hashSignedTx(tx: Transaction | string, definitions?: XrplDefinitionsBase, validateTx?: boolean): string;
18
+ export { XrplDefinitionsBase, XrplDefinitions, DEFAULT_DEFINITIONS, hashSignedTx };
package/lib/wallet.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.DEFAULT_DEFINITIONS = exports.XrplDefinitions = exports.XrplDefinitionsBase = exports.signTransaction = exports.checksumClassicAddress = exports.isValidClassicAddress = exports.generateAddress = void 0;
29
+ exports.hashSignedTx = exports.DEFAULT_DEFINITIONS = exports.XrplDefinitions = exports.XrplDefinitionsBase = exports.signTransaction = exports.checksumClassicAddress = exports.isValidClassicAddress = exports.generateAddress = void 0;
30
30
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
31
31
  const omitBy_1 = __importDefault(require("lodash/omitBy"));
32
32
  const Crypto = __importStar(require("crypto"));
@@ -126,7 +126,7 @@ function removeTrailingZeros(tx) {
126
126
  tx.Amount.value = new bignumber_js_1.default(tx.Amount.value).toString();
127
127
  }
128
128
  }
129
- function hashSignedTx(tx, definitions) {
129
+ function hashSignedTx(tx, definitions, validateTx) {
130
130
  let txBlob;
131
131
  let txObject;
132
132
  if (typeof tx === "string") {
@@ -134,12 +134,15 @@ function hashSignedTx(tx, definitions) {
134
134
  txObject = (0, ripple_binary_codec_1.decode)(tx, definitions);
135
135
  }
136
136
  else {
137
- txBlob = (0, ripple_binary_codec_1.encode)(tx);
137
+ txBlob = (0, ripple_binary_codec_1.encode)(tx, definitions);
138
138
  txObject = tx;
139
139
  }
140
- if (txObject.TxnSignature === undefined && txObject.Signers === undefined) {
141
- throw new xrpl_1.ValidationError("The transaction must be signed to hash it.");
140
+ if (validateTx !== false) {
141
+ if (txObject.TxnSignature === undefined && txObject.Signers === undefined) {
142
+ throw new xrpl_1.ValidationError("The transaction must be signed to hash it.");
143
+ }
142
144
  }
143
145
  const prefix = HashPrefix.TRANSACTION_ID.toString(16).toUpperCase();
144
146
  return (0, common_1.sha512Half)(prefix.concat(txBlob));
145
147
  }
148
+ exports.hashSignedTx = hashSignedTx;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "2.6.4",
3
+ "version": "2.6.6",
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",
@@ -38,7 +38,7 @@
38
38
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
39
39
  "lint": "tslint -p tsconfig.json",
40
40
  "prepare": "npm run build",
41
- "-prepublishOnly": "npm test && npm run lint",
41
+ "prepublishOnly": "npm test && npm run lint",
42
42
  "preversion": "npm run lint",
43
43
  "version": "npm run format && git add -A src",
44
44
  "postversion": "git push && git push --tags"
@@ -47,25 +47,24 @@
47
47
  "lib/**/*"
48
48
  ],
49
49
  "dependencies": {
50
- "axios": "^1.5.1",
50
+ "axios": "^1.6.1",
51
51
  "base-x": "^4.0.0",
52
52
  "bignumber.js": "^9.1.2",
53
53
  "elliptic": "^6.5.4",
54
54
  "lodash": "^4.17.21",
55
55
  "ripple-address-codec": "^4.3.1",
56
56
  "ripple-binary-codec": "^1.10.0",
57
- "ripple-hashes": "^0.3.4",
58
57
  "xrpl": "^2.13.0"
59
58
  },
60
59
  "devDependencies": {
61
- "@types/chai": "^4.3.9",
62
- "@types/chai-as-promised": "^7.1.7",
63
- "@types/lodash": "^4.14.200",
64
- "@types/mocha": "^10.0.3",
65
- "@types/nconf": "^0.10.5",
66
- "@types/node": "^20.8.9",
67
- "@typescript-eslint/eslint-plugin": "^6.9.0",
68
- "@typescript-eslint/parser": "^6.9.0",
60
+ "@types/chai": "^4.3.10",
61
+ "@types/chai-as-promised": "^7.1.8",
62
+ "@types/lodash": "^4.14.201",
63
+ "@types/mocha": "^10.0.4",
64
+ "@types/nconf": "^0.10.6",
65
+ "@types/node": "^20.9.0",
66
+ "@typescript-eslint/eslint-plugin": "^6.10.0",
67
+ "@typescript-eslint/parser": "^6.10.0",
69
68
  "chai": "^4.3.10",
70
69
  "chai-as-promised": "^7.1.1",
71
70
  "mocha": "^10.2.0",