@bithomp/xrpl-api 3.3.10 → 3.4.1
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/ledger/account_tx.d.ts +8 -0
- package/lib/ledger/account_tx.js +56 -6
- package/lib/ledger/transaction.js +9 -0
- package/lib/models/transaction.d.ts +1 -0
- package/lib/models/transaction.js +24 -0
- package/lib/models/transactions/SetRemarks.d.ts +3 -0
- package/lib/models/transactions/SetRemarks.js +2 -0
- package/lib/parse/ledger/delegate.d.ts +2 -0
- package/lib/parse/ledger/delegate.js +11 -0
- package/lib/parse/ledger/index.d.ts +2 -1
- package/lib/parse/ledger/index.js +4 -1
- package/lib/parse/ledger/permissions.d.ts +2 -0
- package/lib/parse/ledger/permissions.js +9 -0
- package/lib/parse/ledger/remark-flags.d.ts +5 -0
- package/lib/parse/ledger/remark-flags.js +8 -0
- package/lib/parse/ledger/remarks.d.ts +3 -0
- package/lib/parse/ledger/remarks.js +47 -0
- package/lib/parse/outcome/delegate_changes.d.ts +12 -0
- package/lib/parse/outcome/delegate_changes.js +59 -0
- package/lib/parse/outcome/index.d.ts +2 -0
- package/lib/parse/outcome/index.js +5 -1
- package/lib/parse/outcome/oracle_changes.d.ts +3 -3
- package/lib/parse/outcome/remarks_changes.d.ts +14 -0
- package/lib/parse/outcome/remarks_changes.js +68 -0
- package/lib/parse/outcome.js +22 -0
- package/lib/parse/specification/account-delete.d.ts +2 -1
- package/lib/parse/specification/account-delete.js +2 -0
- package/lib/parse/specification/amm-bid.d.ts +2 -1
- package/lib/parse/specification/amm-bid.js +2 -0
- package/lib/parse/specification/amm-clawback.d.ts +2 -1
- package/lib/parse/specification/amm-clawback.js +2 -0
- package/lib/parse/specification/amm-create.d.ts +2 -1
- package/lib/parse/specification/amm-create.js +2 -0
- package/lib/parse/specification/amm-delete.d.ts +2 -1
- package/lib/parse/specification/amm-delete.js +2 -0
- package/lib/parse/specification/amm-deposit.d.ts +2 -1
- package/lib/parse/specification/amm-deposit.js +2 -0
- package/lib/parse/specification/amm-vote.d.ts +2 -1
- package/lib/parse/specification/amm-vote.js +2 -0
- package/lib/parse/specification/amm-withdraw.d.ts +2 -1
- package/lib/parse/specification/amm-withdraw.js +2 -0
- package/lib/parse/specification/check-cancel.d.ts +2 -1
- package/lib/parse/specification/check-cancel.js +2 -0
- package/lib/parse/specification/check-cash.d.ts +2 -1
- package/lib/parse/specification/check-cash.js +2 -0
- package/lib/parse/specification/check-create.d.ts +2 -1
- package/lib/parse/specification/check-create.js +2 -0
- package/lib/parse/specification/clawback.d.ts +2 -1
- package/lib/parse/specification/clawback.js +2 -0
- package/lib/parse/specification/delegate-set.d.ts +4 -0
- package/lib/parse/specification/delegate-set.js +58 -0
- package/lib/parse/specification/deposit-preauth.d.ts +2 -1
- package/lib/parse/specification/deposit-preauth.js +2 -0
- package/lib/parse/specification/did-delete.d.ts +2 -1
- package/lib/parse/specification/did-delete.js +2 -0
- package/lib/parse/specification/did-set.d.ts +2 -1
- package/lib/parse/specification/did-set.js +2 -0
- package/lib/parse/specification/escrow-cancel.d.ts +2 -1
- package/lib/parse/specification/escrow-cancel.js +2 -0
- package/lib/parse/specification/escrow-create.d.ts +2 -1
- package/lib/parse/specification/escrow-create.js +2 -0
- package/lib/parse/specification/escrow-finish.d.ts +2 -1
- package/lib/parse/specification/escrow-finish.js +2 -0
- package/lib/parse/specification/mptoken-authorize.d.ts +2 -1
- package/lib/parse/specification/mptoken-authorize.js +2 -0
- package/lib/parse/specification/mptoken-issuance-create.d.ts +2 -1
- package/lib/parse/specification/mptoken-issuance-create.js +2 -0
- package/lib/parse/specification/mptoken-issuance-destroy.d.ts +2 -1
- package/lib/parse/specification/mptoken-issuance-destroy.js +2 -0
- package/lib/parse/specification/mptoken-issuance-set.d.ts +2 -1
- package/lib/parse/specification/mptoken-issuance-set.js +2 -0
- package/lib/parse/specification/nftoken-accept-offer.d.ts +2 -1
- package/lib/parse/specification/nftoken-accept-offer.js +2 -0
- package/lib/parse/specification/nftoken-burn.d.ts +2 -1
- package/lib/parse/specification/nftoken-burn.js +2 -0
- package/lib/parse/specification/nftoken-cancel-offer.d.ts +2 -1
- package/lib/parse/specification/nftoken-cancel-offer.js +2 -0
- package/lib/parse/specification/nftoken-create-offer.d.ts +2 -1
- package/lib/parse/specification/nftoken-create-offer.js +2 -0
- package/lib/parse/specification/nftoken-mint.d.ts +2 -1
- package/lib/parse/specification/nftoken-mint.js +2 -0
- package/lib/parse/specification/nftoken-modify.d.ts +2 -1
- package/lib/parse/specification/nftoken-modify.js +2 -0
- package/lib/parse/specification/offer-cancel.d.ts +2 -1
- package/lib/parse/specification/offer-cancel.js +2 -0
- package/lib/parse/specification/offer-create.d.ts +3 -2
- package/lib/parse/specification/offer-create.js +2 -0
- package/lib/parse/specification/oracle-delete.d.ts +2 -1
- package/lib/parse/specification/oracle-delete.js +2 -0
- package/lib/parse/specification/oracle-set.d.ts +2 -1
- package/lib/parse/specification/oracle-set.js +2 -0
- package/lib/parse/specification/payment-channel-claim.d.ts +2 -1
- package/lib/parse/specification/payment-channel-claim.js +2 -2
- package/lib/parse/specification/payment-channel-create.d.ts +2 -1
- package/lib/parse/specification/payment-channel-create.js +2 -0
- package/lib/parse/specification/payment-channel-fund.d.ts +2 -1
- package/lib/parse/specification/payment-channel-fund.js +2 -0
- package/lib/parse/specification/payment.d.ts +2 -1
- package/lib/parse/specification/payment.js +2 -0
- package/lib/parse/specification/set-remarks.d.ts +3 -0
- package/lib/parse/specification/set-remarks.js +56 -0
- package/lib/parse/specification/settings.js +2 -0
- package/lib/parse/specification/ticket-create.d.ts +2 -1
- package/lib/parse/specification/ticket-create.js +2 -0
- package/lib/parse/specification/trust-set.d.ts +4 -0
- package/lib/parse/specification/trust-set.js +74 -0
- package/lib/parse/specification/trustline.js +2 -0
- package/lib/parse/specification/unrecognized.d.ts +2 -1
- package/lib/parse/specification/unrecognized.js +2 -0
- package/lib/parse/specification/uritoken-burn.d.ts +2 -2
- package/lib/parse/specification/uritoken-burn.js +2 -2
- package/lib/parse/specification/uritoken-buy.d.ts +2 -2
- package/lib/parse/specification/uritoken-buy.js +2 -2
- package/lib/parse/specification/uritoken-cancel-sell-offer.d.ts +2 -2
- package/lib/parse/specification/uritoken-cancel-sell-offer.js +2 -2
- package/lib/parse/specification/uritoken-create-sell-offer.d.ts +2 -2
- package/lib/parse/specification/uritoken-create-sell-offer.js +2 -2
- package/lib/parse/specification/uritoken-mint.d.ts +2 -2
- package/lib/parse/specification/uritoken-mint.js +2 -2
- package/lib/parse/transaction.d.ts +3 -1
- package/lib/parse/transaction.js +8 -2
- package/lib/types/checks.d.ts +4 -4
- package/lib/types/delegate.d.ts +5 -0
- package/lib/types/delegate.js +2 -0
- package/lib/types/deposits.d.ts +2 -2
- package/lib/types/did.d.ts +3 -3
- package/lib/types/escrows.d.ts +3 -3
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.js +2 -1
- package/lib/types/mptokens.d.ts +1 -1
- package/lib/types/nftokens.d.ts +3 -3
- package/lib/types/oracle.d.ts +4 -12
- package/lib/types/payment_channels.d.ts +2 -4
- package/lib/types/remarks.d.ts +24 -0
- package/lib/types/remarks.js +6 -0
- package/lib/types/specification.d.ts +1 -0
- package/package.json +12 -12
|
@@ -26,4 +26,12 @@ export interface FindTransactionsOptions extends GetTransactionsOptions {
|
|
|
26
26
|
legacy?: boolean;
|
|
27
27
|
formatted?: boolean;
|
|
28
28
|
}
|
|
29
|
+
interface FindTransactionsResponse {
|
|
30
|
+
account: string;
|
|
31
|
+
transactions: any[];
|
|
32
|
+
marker?: any;
|
|
33
|
+
validated?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function findTransactionsExt(account: string, options?: FindTransactionsOptions): Promise<FindTransactionsResponse | ErrorResponse>;
|
|
29
36
|
export declare function findTransactions(account: string, options?: FindTransactionsOptions): Promise<object[] | ErrorResponse>;
|
|
37
|
+
export {};
|
package/lib/ledger/account_tx.js
CHANGED
|
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getTransactions = getTransactions;
|
|
40
|
+
exports.findTransactionsExt = findTransactionsExt;
|
|
40
41
|
exports.findTransactions = findTransactions;
|
|
41
42
|
const lodash_1 = __importDefault(require("lodash"));
|
|
42
43
|
const xrpl_1 = require("xrpl");
|
|
@@ -76,7 +77,7 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
|
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
79
|
if (response.error) {
|
|
79
|
-
const { error, error_code, error_message, error_exception, status, validated } = response;
|
|
80
|
+
const { error, error_code, error_message, error_exception, status, validated, warnings } = response;
|
|
80
81
|
return (0, utils_1.removeUndefined)({
|
|
81
82
|
account,
|
|
82
83
|
error,
|
|
@@ -85,15 +86,17 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
|
|
|
85
86
|
error_exception,
|
|
86
87
|
status,
|
|
87
88
|
validated,
|
|
89
|
+
warnings,
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
92
|
const result = response?.result;
|
|
91
93
|
if (!result) {
|
|
92
|
-
return {
|
|
94
|
+
return (0, utils_1.removeUndefined)({
|
|
93
95
|
account,
|
|
94
96
|
status: "error",
|
|
95
97
|
error: "invalidResponse",
|
|
96
|
-
|
|
98
|
+
warnings: response.warnings,
|
|
99
|
+
});
|
|
97
100
|
}
|
|
98
101
|
if (Array.isArray(result.transactions)) {
|
|
99
102
|
if (options.balanceChanges === true || options.specification === true) {
|
|
@@ -112,13 +115,27 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
|
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
}
|
|
118
|
+
if (Array.isArray(result.transactions)) {
|
|
119
|
+
for (const transaction of result.transactions) {
|
|
120
|
+
const tx = transaction.tx || transaction;
|
|
121
|
+
if (!tx.hasOwnProperty("ctid")) {
|
|
122
|
+
const ctid = (0, transaction_1.encodeCTIDforTransaction)(transaction, connection.getNetworkID());
|
|
123
|
+
if (ctid) {
|
|
124
|
+
tx.ctid = ctid;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
115
129
|
const newMarker = (0, utils_1.createMarker)(connection.hash, result.marker);
|
|
116
130
|
if (newMarker) {
|
|
117
131
|
result.marker = newMarker;
|
|
118
132
|
}
|
|
133
|
+
if (response.warnings && response.warnings.length > 0) {
|
|
134
|
+
result.warnings = response.warnings;
|
|
135
|
+
}
|
|
119
136
|
return result;
|
|
120
137
|
}
|
|
121
|
-
async function
|
|
138
|
+
async function findTransactionsExt(account, options = { limit: DEFAULT_LIMIT, timeout: 15000 }) {
|
|
122
139
|
let transactions = [];
|
|
123
140
|
let accountTransactionsError = null;
|
|
124
141
|
const timeStart = new Date();
|
|
@@ -134,6 +151,9 @@ async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeo
|
|
|
134
151
|
if (loadOptions.sourceTag || loadOptions.destinationTag) {
|
|
135
152
|
getTransactionsLimit += LIMIT_INCREASE_COUNT;
|
|
136
153
|
}
|
|
154
|
+
if (loadOptions.types) {
|
|
155
|
+
getTransactionsLimit += LIMIT_INCREASE_COUNT;
|
|
156
|
+
}
|
|
137
157
|
if (getTransactionsLimit > MAX_LIMIT) {
|
|
138
158
|
getTransactionsLimit = MAX_LIMIT;
|
|
139
159
|
}
|
|
@@ -182,8 +202,26 @@ async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeo
|
|
|
182
202
|
}
|
|
183
203
|
}
|
|
184
204
|
if (newTransactions.length > 0) {
|
|
205
|
+
const transactionsToTake = loadOptions.limit - transactions.length;
|
|
206
|
+
if (transactionsToTake !== newTransactions.length) {
|
|
207
|
+
const isClio = accountTransactions.warnings?.some((w) => w.id === 2001);
|
|
208
|
+
let markerTransaction = null;
|
|
209
|
+
if (isClio) {
|
|
210
|
+
markerTransaction = newTransactions[transactionsToTake - 1];
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
markerTransaction = newTransactions[transactionsToTake];
|
|
214
|
+
}
|
|
215
|
+
if (markerTransaction) {
|
|
216
|
+
loadOptions.marker = {
|
|
217
|
+
ledger: markerTransaction.tx.ledger_index,
|
|
218
|
+
seq: markerTransaction.meta.TransactionIndex,
|
|
219
|
+
bithompHash: loadOptions.marker.bithompHash,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
newTransactions = newTransactions.slice(0, transactionsToTake);
|
|
185
224
|
transactions = transactions.concat(newTransactions);
|
|
186
|
-
transactions = transactions.slice(0, loadOptions.limit);
|
|
187
225
|
}
|
|
188
226
|
if (loadOptions.marker === undefined) {
|
|
189
227
|
break;
|
|
@@ -202,7 +240,19 @@ async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeo
|
|
|
202
240
|
if (formatted === true) {
|
|
203
241
|
transactions = transactions.map((transaction) => (0, transaction_1.getAccountTxDetails)(transaction, loadOptions.includeRawTransactions === true));
|
|
204
242
|
}
|
|
205
|
-
return
|
|
243
|
+
return {
|
|
244
|
+
account,
|
|
245
|
+
transactions,
|
|
246
|
+
marker: loadOptions.marker,
|
|
247
|
+
validated: true,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeout: 15000 }) {
|
|
251
|
+
const result = await findTransactionsExt(account, options);
|
|
252
|
+
if (result.error) {
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
return result.transactions || [];
|
|
206
256
|
}
|
|
207
257
|
function applyLimitOptions(options) {
|
|
208
258
|
if (options.sourceTag > 0 || options.destinationTag > 0) {
|
|
@@ -102,6 +102,15 @@ async function getTransaction(transaction, options = {}) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
+
if (!result.hasOwnProperty("ctid")) {
|
|
106
|
+
const ctid = (0, transaction_1.encodeCTIDforTransaction)(result, connection.getNetworkID());
|
|
107
|
+
if (ctid) {
|
|
108
|
+
result.ctid = ctid;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (result.hasOwnProperty("tx_json") && result.tx_json.hasOwnProperty("ctid")) {
|
|
112
|
+
delete result.tx_json.ctid;
|
|
113
|
+
}
|
|
105
114
|
return result;
|
|
106
115
|
}
|
|
107
116
|
async function getTransactionByCTID(ctid, options = {}) {
|
|
@@ -41,6 +41,7 @@ export declare function accountTxToTx(accountTx: AccountTransaction): Transactio
|
|
|
41
41
|
export declare function ledgerTxToTx(ledgerTx: LedgerTransaction, ledgerIndex: number, closeTime: number): TransactionResponse;
|
|
42
42
|
export declare function streamTxToTx(streamTx: StreamTransaction): TransactionResponse;
|
|
43
43
|
export declare function isCTID(ctid: string | bigint): boolean;
|
|
44
|
+
export declare function encodeCTIDforTransaction(transaction: TransactionResponse, networkID: number): string | undefined;
|
|
44
45
|
export declare function encodeCTID(ledgerIndex: number, txIndex: number, networkID: number): string;
|
|
45
46
|
export interface DecodeCTIDInterface {
|
|
46
47
|
ledgerIndex: number;
|
|
@@ -11,6 +11,7 @@ exports.accountTxToTx = accountTxToTx;
|
|
|
11
11
|
exports.ledgerTxToTx = ledgerTxToTx;
|
|
12
12
|
exports.streamTxToTx = streamTxToTx;
|
|
13
13
|
exports.isCTID = isCTID;
|
|
14
|
+
exports.encodeCTIDforTransaction = encodeCTIDforTransaction;
|
|
14
15
|
exports.encodeCTID = encodeCTID;
|
|
15
16
|
exports.decodeCTID = decodeCTID;
|
|
16
17
|
const lodash_1 = __importDefault(require("lodash"));
|
|
@@ -66,6 +67,29 @@ function isCTID(ctid) {
|
|
|
66
67
|
}
|
|
67
68
|
return true;
|
|
68
69
|
}
|
|
70
|
+
function encodeCTIDforTransaction(transaction, networkID) {
|
|
71
|
+
let ledgerIndex;
|
|
72
|
+
if (transaction.ledger_index) {
|
|
73
|
+
ledgerIndex = transaction.ledger_index;
|
|
74
|
+
}
|
|
75
|
+
else if (transaction.tx && transaction.tx.ledger_index) {
|
|
76
|
+
ledgerIndex = transaction.tx.ledger_index;
|
|
77
|
+
}
|
|
78
|
+
else if (transaction.tx_json && transaction.tx_json.ledger_index) {
|
|
79
|
+
ledgerIndex = transaction.tx_json.ledger_index;
|
|
80
|
+
}
|
|
81
|
+
if (typeof ledgerIndex !== "number") {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const meta = (transaction.meta || transaction.metaData);
|
|
85
|
+
if (!meta || !meta.TransactionIndex) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
if (typeof networkID !== "number") {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return encodeCTID(ledgerIndex, meta.TransactionIndex, networkID);
|
|
92
|
+
}
|
|
69
93
|
function encodeCTID(ledgerIndex, txIndex, networkID) {
|
|
70
94
|
if (typeof ledgerIndex !== "number") {
|
|
71
95
|
throw new Error("ledgerIndex must be a number.");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseDelegate = parseDelegate;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
function parseDelegate(tx) {
|
|
6
|
+
if (tx && tx.Delegate) {
|
|
7
|
+
return (0, common_1.removeUndefined)({
|
|
8
|
+
address: tx.Delegate,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import parseAmount from "./amount";
|
|
2
2
|
import { parseMemos } from "./memos";
|
|
3
|
+
import { parseRemarks, REMARKS_SUPPORTED_ENTRIES } from "./remarks";
|
|
3
4
|
export * from "./account";
|
|
4
5
|
export * from "../utils";
|
|
5
|
-
export { parseAmount, parseMemos };
|
|
6
|
+
export { parseAmount, parseMemos, parseRemarks, REMARKS_SUPPORTED_ENTRIES };
|
|
@@ -17,10 +17,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.parseMemos = exports.parseAmount = void 0;
|
|
20
|
+
exports.REMARKS_SUPPORTED_ENTRIES = exports.parseRemarks = exports.parseMemos = exports.parseAmount = void 0;
|
|
21
21
|
const amount_1 = __importDefault(require("./amount"));
|
|
22
22
|
exports.parseAmount = amount_1.default;
|
|
23
23
|
const memos_1 = require("./memos");
|
|
24
24
|
Object.defineProperty(exports, "parseMemos", { enumerable: true, get: function () { return memos_1.parseMemos; } });
|
|
25
|
+
const remarks_1 = require("./remarks");
|
|
26
|
+
Object.defineProperty(exports, "parseRemarks", { enumerable: true, get: function () { return remarks_1.parseRemarks; } });
|
|
27
|
+
Object.defineProperty(exports, "REMARKS_SUPPORTED_ENTRIES", { enumerable: true, get: function () { return remarks_1.REMARKS_SUPPORTED_ENTRIES; } });
|
|
25
28
|
__exportStar(require("./account"), exports);
|
|
26
29
|
__exportStar(require("../utils"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePermissions = parsePermissions;
|
|
4
|
+
function parsePermissions(permissions) {
|
|
5
|
+
if (!permissions) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
return permissions.map((perm) => perm.Permission.PermissionValue).sort();
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const remarks_1 = require("../../types/remarks");
|
|
4
|
+
const flags_1 = require("./flags");
|
|
5
|
+
function parseRemarkFlags(value, options = {}) {
|
|
6
|
+
return (0, flags_1.parseFlags)(value, remarks_1.RemarksFlagsKeys, options);
|
|
7
|
+
}
|
|
8
|
+
exports.default = parseRemarkFlags;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.REMARKS_SUPPORTED_ENTRIES = void 0;
|
|
7
|
+
exports.parseRemarks = parseRemarks;
|
|
8
|
+
const common_1 = require("../../common");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const remark_flags_1 = __importDefault(require("./remark-flags"));
|
|
11
|
+
exports.REMARKS_SUPPORTED_ENTRIES = [
|
|
12
|
+
"AccountRoot",
|
|
13
|
+
"Offer",
|
|
14
|
+
"Escrow",
|
|
15
|
+
"Ticket",
|
|
16
|
+
"PayChannel",
|
|
17
|
+
"Check",
|
|
18
|
+
"DepositPreauth",
|
|
19
|
+
"URIToken",
|
|
20
|
+
"RippleState",
|
|
21
|
+
];
|
|
22
|
+
function parseRemarks(remarks) {
|
|
23
|
+
if (!Array.isArray(remarks)) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return remarks.map((remark) => {
|
|
27
|
+
return (0, common_1.removeUndefined)(parseRemark(remark));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function parseRemark(remark) {
|
|
31
|
+
const { RemarkName, RemarkValue, Flags } = remark.Remark;
|
|
32
|
+
return (0, common_1.removeUndefined)({
|
|
33
|
+
name: (0, utils_1.hexToString)(RemarkName),
|
|
34
|
+
value: decodeData(RemarkValue),
|
|
35
|
+
flags: (0, remark_flags_1.default)(Flags),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function decodeData(data) {
|
|
39
|
+
if (!data) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const decoded = (0, utils_1.hexToString)(data);
|
|
43
|
+
if (decoded && decoded.includes("�")) {
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
return decoded;
|
|
47
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
2
|
+
interface FormattedDelegateSummaryInterface {
|
|
3
|
+
status?: "created" | "modified" | "deleted";
|
|
4
|
+
delegateIndex: string;
|
|
5
|
+
account?: string;
|
|
6
|
+
authorize?: string;
|
|
7
|
+
permissions?: string[];
|
|
8
|
+
permissionsChange?: string[];
|
|
9
|
+
previousTxnID?: string;
|
|
10
|
+
}
|
|
11
|
+
declare function parseDelegateChanges(metadata: TransactionMetadata): FormattedDelegateSummaryInterface | undefined;
|
|
12
|
+
export { parseDelegateChanges };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseDelegateChanges = parseDelegateChanges;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const permissions_1 = require("../ledger/permissions");
|
|
6
|
+
function parseDelegateStatus(node) {
|
|
7
|
+
if (node.diffType === "CreatedNode") {
|
|
8
|
+
return "created";
|
|
9
|
+
}
|
|
10
|
+
if (node.diffType === "ModifiedNode") {
|
|
11
|
+
return "modified";
|
|
12
|
+
}
|
|
13
|
+
if (node.diffType === "DeletedNode") {
|
|
14
|
+
return "deleted";
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
function summarizeDelegate(node) {
|
|
19
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
20
|
+
const prev = node.previousFields;
|
|
21
|
+
const summary = {
|
|
22
|
+
status: parseDelegateStatus(node),
|
|
23
|
+
delegateIndex: node.ledgerIndex,
|
|
24
|
+
account: final.Account,
|
|
25
|
+
authorize: final.Authorize,
|
|
26
|
+
permissions: (0, permissions_1.parsePermissions)(final.Permissions),
|
|
27
|
+
};
|
|
28
|
+
if (node.diffType === "ModifiedNode") {
|
|
29
|
+
summary.permissionsChange = [];
|
|
30
|
+
const prevPermissions = (0, permissions_1.parsePermissions)(prev.Permissions);
|
|
31
|
+
const finalPermissions = summary.permissions || [];
|
|
32
|
+
const addedPermissions = finalPermissions.filter((perm) => !prevPermissions.includes(perm));
|
|
33
|
+
const removedPermissions = prevPermissions.filter((perm) => !finalPermissions.includes(perm));
|
|
34
|
+
if (addedPermissions.length > 0) {
|
|
35
|
+
summary.permissionsChange.push(...addedPermissions);
|
|
36
|
+
}
|
|
37
|
+
if (removedPermissions.length > 0) {
|
|
38
|
+
summary.permissionsChange.push(...removedPermissions);
|
|
39
|
+
}
|
|
40
|
+
if (summary.permissionsChange.length === 0) {
|
|
41
|
+
summary.permissionsChange = undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (node.PreviousTxnID) {
|
|
45
|
+
summary.previousTxnID = node.PreviousTxnID;
|
|
46
|
+
}
|
|
47
|
+
return summary;
|
|
48
|
+
}
|
|
49
|
+
function parseDelegateChanges(metadata) {
|
|
50
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
51
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
52
|
+
return node.LedgerEntryType === "Delegate";
|
|
53
|
+
});
|
|
54
|
+
if (affectedNodes.length !== 1) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
58
|
+
return summarizeDelegate(normalizedNode);
|
|
59
|
+
}
|
|
@@ -18,3 +18,5 @@ export { parseOracleChanges } from "./oracle_changes";
|
|
|
18
18
|
export { parseDeliveredAmount } from "./delivered_amount";
|
|
19
19
|
export { parseMPTokenIssuanceChanges } from "./mptoken_issuance_changes";
|
|
20
20
|
export { parseMPTokenChanges } from "./mptoken_changes";
|
|
21
|
+
export { parseDelegateChanges } from "./delegate_changes";
|
|
22
|
+
export { parseRemarksChanges } from "./remarks_changes";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseMPTokenChanges = exports.parseMPTokenIssuanceChanges = exports.parseDeliveredAmount = exports.parseOracleChanges = exports.parseDIDChanges = exports.parseAmmChanges = exports.parseUNLReportChanges = exports.parseEscrowChanges = exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseCheckChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
3
|
+
exports.parseRemarksChanges = exports.parseDelegateChanges = exports.parseMPTokenChanges = exports.parseMPTokenIssuanceChanges = exports.parseDeliveredAmount = exports.parseOracleChanges = exports.parseDIDChanges = exports.parseAmmChanges = exports.parseUNLReportChanges = exports.parseEscrowChanges = exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseCheckChanges = 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");
|
|
@@ -41,3 +41,7 @@ var mptoken_issuance_changes_1 = require("./mptoken_issuance_changes");
|
|
|
41
41
|
Object.defineProperty(exports, "parseMPTokenIssuanceChanges", { enumerable: true, get: function () { return mptoken_issuance_changes_1.parseMPTokenIssuanceChanges; } });
|
|
42
42
|
var mptoken_changes_1 = require("./mptoken_changes");
|
|
43
43
|
Object.defineProperty(exports, "parseMPTokenChanges", { enumerable: true, get: function () { return mptoken_changes_1.parseMPTokenChanges; } });
|
|
44
|
+
var delegate_changes_1 = require("./delegate_changes");
|
|
45
|
+
Object.defineProperty(exports, "parseDelegateChanges", { enumerable: true, get: function () { return delegate_changes_1.parseDelegateChanges; } });
|
|
46
|
+
var remarks_changes_1 = require("./remarks_changes");
|
|
47
|
+
Object.defineProperty(exports, "parseRemarksChanges", { enumerable: true, get: function () { return remarks_changes_1.parseRemarksChanges; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TransactionMetadata } from "xrpl";
|
|
2
|
-
import {
|
|
1
|
+
import { TransactionMetadata, PriceData } from "xrpl";
|
|
2
|
+
import { FormattedOraclePriceDataSeriesInterface } from "../../types";
|
|
3
3
|
interface FormattedOracleSummaryInterface {
|
|
4
4
|
status?: "created" | "modified" | "deleted";
|
|
5
5
|
oracleID?: string;
|
|
@@ -24,6 +24,6 @@ interface FormattedPriceDataSeriesChanges {
|
|
|
24
24
|
scaleChange?: number;
|
|
25
25
|
originalPriceChange?: string;
|
|
26
26
|
}
|
|
27
|
-
declare function parsePriceDataSeries(series:
|
|
27
|
+
declare function parsePriceDataSeries(series: PriceData): FormattedOraclePriceDataSeriesInterface;
|
|
28
28
|
declare function parseOracleChanges(metadata: TransactionMetadata): FormattedOracleSummaryInterface | undefined;
|
|
29
29
|
export { parseOracleChanges, parsePriceDataSeries };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FormattedRemark } from "../../types";
|
|
2
|
+
type FormattedRemarkSummaryInterface = {
|
|
3
|
+
status?: "created" | "modified" | "deleted";
|
|
4
|
+
previousValue?: string;
|
|
5
|
+
} & FormattedRemark;
|
|
6
|
+
interface FormattedRemarksSummaryInterface {
|
|
7
|
+
status?: "created" | "modified" | "deleted";
|
|
8
|
+
objectID: string;
|
|
9
|
+
entryType?: string;
|
|
10
|
+
remarks?: FormattedRemarkSummaryInterface[];
|
|
11
|
+
previousTxnID?: string;
|
|
12
|
+
}
|
|
13
|
+
declare function parseRemarksChanges(tx: any): FormattedRemarksSummaryInterface | undefined;
|
|
14
|
+
export { parseRemarksChanges };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseRemarksChanges = parseRemarksChanges;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const remarks_1 = require("../ledger/remarks");
|
|
6
|
+
function parseEntryRemarks(node) {
|
|
7
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
8
|
+
const prev = node.previousFields;
|
|
9
|
+
if (!final.Remarks && !prev.Remarks) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const remarks = ((0, remarks_1.parseRemarks)(final.Remarks) || []);
|
|
13
|
+
if (prev.Remarks) {
|
|
14
|
+
const previousRemarks = (0, remarks_1.parseRemarks)(prev.Remarks) || [];
|
|
15
|
+
remarks.forEach((remark) => {
|
|
16
|
+
const previousRemark = previousRemarks.find((r) => r.name === remark.name);
|
|
17
|
+
if (previousRemark) {
|
|
18
|
+
if (previousRemark.value !== remark.value) {
|
|
19
|
+
remark.status = "modified";
|
|
20
|
+
remark.previousValue = previousRemark.value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
remark.status = "created";
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
previousRemarks.forEach((previousRemark) => {
|
|
28
|
+
if (!remarks.some((r) => r.name === previousRemark.name)) {
|
|
29
|
+
remarks.push({
|
|
30
|
+
...previousRemark,
|
|
31
|
+
status: "deleted",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
remarks.forEach((remark) => {
|
|
38
|
+
remark.status = "created";
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return remarks;
|
|
42
|
+
}
|
|
43
|
+
function summarizeRemarks(node) {
|
|
44
|
+
const summary = {
|
|
45
|
+
objectID: node.ledgerIndex,
|
|
46
|
+
entryType: node.entryType,
|
|
47
|
+
remarks: parseEntryRemarks(node),
|
|
48
|
+
};
|
|
49
|
+
if (node.PreviousTxnID) {
|
|
50
|
+
summary.previousTxnID = node.PreviousTxnID;
|
|
51
|
+
}
|
|
52
|
+
return summary;
|
|
53
|
+
}
|
|
54
|
+
function parseRemarksChanges(tx) {
|
|
55
|
+
if (!tx.ObjectID || !tx.meta || !Array.isArray(tx.meta.AffectedNodes)) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const metadata = tx.meta;
|
|
59
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
60
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
61
|
+
return node.LedgerIndex === tx.ObjectID;
|
|
62
|
+
});
|
|
63
|
+
if (affectedNodes.length !== 1) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
67
|
+
return summarizeRemarks(normalizedNode);
|
|
68
|
+
}
|
package/lib/parse/outcome.js
CHANGED
|
@@ -36,6 +36,8 @@ const MPTOKEN_TYPES = [
|
|
|
36
36
|
"Payment",
|
|
37
37
|
"Clawback",
|
|
38
38
|
];
|
|
39
|
+
const DELEGATE_TYPES = ["DelegateSet"];
|
|
40
|
+
const REMARKS_TYPES = ["SetRemarks"];
|
|
39
41
|
function parseOutcome(tx, nativeCurrency, definitions) {
|
|
40
42
|
const metadata = tx.meta || tx.metaData;
|
|
41
43
|
if (!metadata) {
|
|
@@ -62,6 +64,8 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
62
64
|
oracleChanges: getOracleChanges(tx),
|
|
63
65
|
mptokenIssuanceChanges: getMPTokenIssuanceChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
64
66
|
mptokenChanges: getMPTokenChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
67
|
+
delegateChanges: getDelegateChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
68
|
+
remarksChanges: getRemarksChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
65
69
|
unlReportChanges: getUNLReportChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
66
70
|
hooksExecutions: getHooksExecutions(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
67
71
|
emittedTxns: getEmittedTxns(tx, nativeCurrency || (0, client_1.getNativeCurrency)(), definitions),
|
|
@@ -198,3 +202,21 @@ function getMPTokenIssuanceChanges(tx, nativeCurrency) {
|
|
|
198
202
|
const mptokenIssuanceChanges = (0, index_1.parseMPTokenIssuanceChanges)(tx);
|
|
199
203
|
return Object.keys(mptokenIssuanceChanges).length > 0 ? mptokenIssuanceChanges : undefined;
|
|
200
204
|
}
|
|
205
|
+
function getDelegateChanges(tx, nativeCurrency) {
|
|
206
|
+
if (nativeCurrency !== "XRP") {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
if (!DELEGATE_TYPES.includes(tx.TransactionType)) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
return (0, index_1.parseDelegateChanges)(tx.meta);
|
|
213
|
+
}
|
|
214
|
+
function getRemarksChanges(tx, nativeCurrency) {
|
|
215
|
+
if (nativeCurrency !== "XAH") {
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
if (!REMARKS_TYPES.includes(tx.TransactionType)) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
return (0, index_1.parseRemarksChanges)(tx);
|
|
222
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AccountDelete } from "xrpl";
|
|
1
2
|
import { FormattedAccountDeleteSpecification } from "../../types/account";
|
|
2
|
-
declare function parseAccountDelete(tx:
|
|
3
|
+
declare function parseAccountDelete(tx: AccountDelete): FormattedAccountDeleteSpecification;
|
|
3
4
|
export default parseAccountDelete;
|
|
@@ -39,6 +39,7 @@ const emit_details_1 = require("../ledger/emit_details");
|
|
|
39
39
|
const memos_1 = require("../ledger/memos");
|
|
40
40
|
const signers_1 = require("../ledger/signers");
|
|
41
41
|
const regular_key_1 = require("../ledger/regular-key");
|
|
42
|
+
const delegate_1 = require("../ledger/delegate");
|
|
42
43
|
const source_1 = require("../ledger/source");
|
|
43
44
|
const destination_1 = require("../ledger/destination");
|
|
44
45
|
function parseAccountDelete(tx) {
|
|
@@ -46,6 +47,7 @@ function parseAccountDelete(tx) {
|
|
|
46
47
|
return (0, common_1.removeUndefined)({
|
|
47
48
|
signers: (0, signers_1.parseSigners)(tx),
|
|
48
49
|
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
50
|
+
delegate: (0, delegate_1.parseDelegate)(tx),
|
|
49
51
|
source: (0, source_1.parseSource)(tx),
|
|
50
52
|
destination: (0, destination_1.parseDestination)(tx),
|
|
51
53
|
emittedDetails: (0, emit_details_1.parseEmittedDetails)(tx),
|
|
@@ -44,12 +44,14 @@ const auth_accounts_1 = __importDefault(require("../ledger/auth-accounts"));
|
|
|
44
44
|
const memos_1 = require("../ledger/memos");
|
|
45
45
|
const signers_1 = require("../ledger/signers");
|
|
46
46
|
const regular_key_1 = require("../ledger/regular-key");
|
|
47
|
+
const delegate_1 = require("../ledger/delegate");
|
|
47
48
|
const source_1 = require("../ledger/source");
|
|
48
49
|
function parseAmmBid(tx) {
|
|
49
50
|
assert.ok(tx.TransactionType === "AMMBid");
|
|
50
51
|
return (0, common_1.removeUndefined)({
|
|
51
52
|
signers: (0, signers_1.parseSigners)(tx),
|
|
52
53
|
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
54
|
+
delegate: (0, delegate_1.parseDelegate)(tx),
|
|
53
55
|
source: (0, source_1.parseSource)(tx),
|
|
54
56
|
asset: (0, asset_1.default)(tx.Asset),
|
|
55
57
|
asset2: (0, asset_1.default)(tx.Asset2),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AMMClawback } from "xrpl";
|
|
1
2
|
import { FormattedAmmClawbackSpecification } from "../../types/amm";
|
|
2
|
-
declare function parseAmmClawback(tx:
|
|
3
|
+
declare function parseAmmClawback(tx: AMMClawback): FormattedAmmClawbackSpecification;
|
|
3
4
|
export default parseAmmClawback;
|
|
@@ -44,6 +44,7 @@ const memos_1 = require("../ledger/memos");
|
|
|
44
44
|
const account_1 = require("../ledger/account");
|
|
45
45
|
const signers_1 = require("../ledger/signers");
|
|
46
46
|
const regular_key_1 = require("../ledger/regular-key");
|
|
47
|
+
const delegate_1 = require("../ledger/delegate");
|
|
47
48
|
const source_1 = require("../ledger/source");
|
|
48
49
|
const amm_clawback_flags_1 = __importDefault(require("../ledger/amm-clawback-flags"));
|
|
49
50
|
function parseAmmClawback(tx) {
|
|
@@ -51,6 +52,7 @@ function parseAmmClawback(tx) {
|
|
|
51
52
|
return (0, common_1.removeUndefined)({
|
|
52
53
|
signers: (0, signers_1.parseSigners)(tx),
|
|
53
54
|
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
55
|
+
delegate: (0, delegate_1.parseDelegate)(tx),
|
|
54
56
|
source: (0, source_1.parseSource)(tx),
|
|
55
57
|
asset: (0, asset_1.default)(tx.Asset),
|
|
56
58
|
asset2: (0, asset_1.default)(tx.Asset2),
|