@bithomp/xrpl-api 2.6.3 → 2.6.5
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/models/transaction.d.ts +2 -2
- package/lib/models/transaction.js +4 -4
- package/lib/parse/ledger/import.js +9 -0
- package/lib/parse/outcome/balance_changes.d.ts +1 -1
- package/lib/parse/outcome/balance_changes.js +6 -6
- package/lib/parse/outcome.d.ts +1 -1
- package/lib/parse/outcome.js +2 -2
- package/lib/parse/transaction.d.ts +1 -1
- package/lib/parse/transaction.js +2 -2
- package/lib/v1/common/types/objects/import.d.ts +5 -0
- package/package.json +2 -1
|
@@ -32,8 +32,8 @@ export interface AccountPaymentParamsInterface {
|
|
|
32
32
|
lastLedgerSequence?: number;
|
|
33
33
|
networkID?: number;
|
|
34
34
|
}
|
|
35
|
-
export declare function getTxDetails(tx: TransactionResponse, includeRawTransaction: boolean): FormattedTransaction;
|
|
36
|
-
export declare function getAccountTxDetails(tx: AccountTransaction, includeRawTransaction: boolean): FormattedTransaction;
|
|
35
|
+
export declare function getTxDetails(tx: TransactionResponse, includeRawTransaction: boolean, nativeCurrency?: string): FormattedTransaction;
|
|
36
|
+
export declare function getAccountTxDetails(tx: AccountTransaction, includeRawTransaction: boolean, nativeCurrency?: string): FormattedTransaction;
|
|
37
37
|
export declare function getLedgerTxDetails(tx: LedgerTransaction, ledgerIndex: number, closeTime: number, includeRawTransaction: boolean): FormattedTransaction;
|
|
38
38
|
export declare function getStreamTxDetails(tx: StreamTransaction, includeRawTransaction: boolean): FormattedTransaction;
|
|
39
39
|
export declare function accountTxToTx(accountTx: AccountTransaction): TransactionResponse;
|
|
@@ -7,12 +7,12 @@ 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) {
|
|
11
|
+
return (0, transaction_1.parseTransaction)(tx, includeRawTransaction, nativeCurrency);
|
|
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
18
|
function getLedgerTxDetails(tx, ledgerIndex, closeTime, includeRawTransaction) {
|
|
@@ -2,7 +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
|
+
const ripple_hashes_1 = require("ripple-hashes");
|
|
5
6
|
const vl_1 = require("../../models/vl");
|
|
7
|
+
const transaction_1 = require("../../models/transaction");
|
|
8
|
+
const MAINNET_NATIVE_CURRENCY = "XRP";
|
|
6
9
|
function parseImportBlob(blob) {
|
|
7
10
|
try {
|
|
8
11
|
const decodedBlob = JSON.parse(Buffer.from(blob, "hex").toString("utf8"));
|
|
@@ -12,6 +15,9 @@ function parseImportBlob(blob) {
|
|
|
12
15
|
data[key] = (0, ripple_binary_codec_1.decode)(data[key]);
|
|
13
16
|
}
|
|
14
17
|
}
|
|
18
|
+
const tx = (0, ripple_binary_codec_1.decode)(decodedBlob.transaction.blob);
|
|
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, MAINNET_NATIVE_CURRENCY);
|
|
15
21
|
return {
|
|
16
22
|
ledger: decodedBlob.ledger,
|
|
17
23
|
validation: {
|
|
@@ -19,9 +25,12 @@ function parseImportBlob(blob) {
|
|
|
19
25
|
unl: (0, vl_1.parseVL)(decodedBlob.validation.unl),
|
|
20
26
|
},
|
|
21
27
|
transaction: {
|
|
28
|
+
id: (0, ripple_hashes_1.computeBinaryTransactionHash)(decodedBlob.transaction.blob),
|
|
22
29
|
tx: (0, ripple_binary_codec_1.decode)(decodedBlob.transaction.blob),
|
|
23
30
|
meta: (0, ripple_binary_codec_1.decode)(decodedBlob.transaction.meta),
|
|
24
31
|
proof: decodedBlob.transaction.proof,
|
|
32
|
+
specification: parsedTX.specification,
|
|
33
|
+
outcome: parsedTX.outcome,
|
|
25
34
|
},
|
|
26
35
|
};
|
|
27
36
|
}
|
|
@@ -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) {
|
package/lib/parse/outcome.d.ts
CHANGED
package/lib/parse/outcome.js
CHANGED
|
@@ -60,12 +60,12 @@ function parseDeliveredAmount(tx) {
|
|
|
60
60
|
}
|
|
61
61
|
return undefined;
|
|
62
62
|
}
|
|
63
|
-
function parseOutcome(tx) {
|
|
63
|
+
function parseOutcome(tx, nativeCurrency) {
|
|
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);
|
|
@@ -26,5 +26,5 @@ export interface FormattedTransaction {
|
|
|
26
26
|
outcome?: Outcome;
|
|
27
27
|
rawTransaction?: string;
|
|
28
28
|
}
|
|
29
|
-
declare function parseTransaction(tx: any, includeRawTransaction: boolean): FormattedTransaction;
|
|
29
|
+
declare function parseTransaction(tx: any, includeRawTransaction: boolean, nativeCurrency?: string): FormattedTransaction;
|
|
30
30
|
export { parseTransactionType, parseTransaction };
|
package/lib/parse/transaction.js
CHANGED
|
@@ -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) {
|
|
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);
|
|
125
125
|
return (0, common_1.removeUndefined)({
|
|
126
126
|
type: type,
|
|
127
127
|
address: tx.Account,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { FormattedBaseSpecification } from "./specification";
|
|
2
2
|
import { FormattedSourceAddress } from "./account";
|
|
3
|
+
import { FormattedSpecification } from "../../../../parse/transaction";
|
|
4
|
+
import { Outcome } from "../../../../v1/transaction/types";
|
|
3
5
|
export type FormattedImportBlobSpecification = {
|
|
4
6
|
ledger: number;
|
|
5
7
|
validation: {
|
|
@@ -7,9 +9,12 @@ export type FormattedImportBlobSpecification = {
|
|
|
7
9
|
unl: any;
|
|
8
10
|
};
|
|
9
11
|
transaction: {
|
|
12
|
+
id: string;
|
|
10
13
|
tx: any;
|
|
11
14
|
meta: any;
|
|
12
15
|
proof: any;
|
|
16
|
+
specification: FormattedSpecification;
|
|
17
|
+
outcome?: Outcome;
|
|
13
18
|
};
|
|
14
19
|
};
|
|
15
20
|
export type FormattedImportSpecification = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5",
|
|
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",
|
|
@@ -54,6 +54,7 @@
|
|
|
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",
|
|
57
58
|
"xrpl": "^2.13.0"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|