@bithomp/xrpl-api 3.2.9 → 3.2.11
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/transaction.js +6 -0
- package/lib/parse/ledger/destination.d.ts +2 -0
- package/lib/parse/ledger/destination.js +12 -0
- package/lib/parse/ledger/regular-key.d.ts +2 -0
- package/lib/parse/ledger/regular-key.js +14 -0
- package/lib/parse/ledger/signers.d.ts +2 -0
- package/lib/parse/ledger/signers.js +12 -0
- package/lib/parse/ledger/source.d.ts +3 -0
- package/lib/parse/ledger/source.js +28 -0
- package/lib/parse/outcome/amm_changes.js +13 -8
- package/lib/parse/outcome/balance_changes.d.ts +1 -3
- package/lib/parse/outcome/balance_changes.js +14 -9
- package/lib/parse/outcome/channel_changes.d.ts +3 -2
- package/lib/parse/outcome/channel_changes.js +9 -4
- package/lib/parse/outcome/did_changes.js +10 -5
- package/lib/parse/outcome/escrow_changes.d.ts +1 -1
- package/lib/parse/outcome/escrow_changes.js +8 -3
- package/lib/parse/outcome/locked_balance_changes.js +8 -3
- package/lib/parse/outcome/oracle_changes.js +11 -6
- package/lib/parse/outcome/orderbook_changes.js +13 -9
- package/lib/parse/outcome/unl_report_changes.js +8 -3
- package/lib/parse/specification/account-delete.js +8 -11
- package/lib/parse/specification/amm-bid.js +6 -6
- package/lib/parse/specification/amm-clawback.js +6 -5
- package/lib/parse/specification/amm-create.js +6 -6
- package/lib/parse/specification/amm-delete.js +6 -6
- package/lib/parse/specification/amm-deposit.js +6 -6
- package/lib/parse/specification/amm-vote.js +6 -6
- package/lib/parse/specification/amm-withdraw.js +6 -6
- package/lib/parse/specification/check-cancel.js +6 -0
- package/lib/parse/specification/check-cash.js +6 -0
- package/lib/parse/specification/check-create.js +8 -11
- package/lib/parse/specification/clawback.js +6 -6
- package/lib/parse/specification/deposit-preauth.js +6 -0
- package/lib/parse/specification/did-delete.js +6 -6
- package/lib/parse/specification/did-set.js +6 -6
- package/lib/parse/specification/escrow-cancel.js +6 -5
- package/lib/parse/specification/escrow-create.js +8 -10
- package/lib/parse/specification/escrow-finish.js +6 -5
- package/lib/parse/specification/fee-update.js +2 -0
- package/lib/parse/specification/genesis-mint.js +2 -0
- package/lib/parse/specification/import.js +6 -5
- package/lib/parse/specification/invoke.js +8 -10
- package/lib/parse/specification/mptoken-authorize.js +6 -6
- package/lib/parse/specification/mptoken-issuance-create.js +6 -6
- package/lib/parse/specification/mptoken-issuance-destroy.js +6 -6
- package/lib/parse/specification/mptoken-issuance-set.js +6 -6
- package/lib/parse/specification/nftoken-accept-offer.js +6 -5
- package/lib/parse/specification/nftoken-burn.js +6 -5
- package/lib/parse/specification/nftoken-cancel-offer.js +6 -5
- package/lib/parse/specification/nftoken-create-offer.js +8 -10
- package/lib/parse/specification/nftoken-mint.js +8 -10
- package/lib/parse/specification/offer-cancel.js +8 -5
- package/lib/parse/specification/offer-create.js +8 -5
- package/lib/parse/specification/oracle-delete.js +6 -6
- package/lib/parse/specification/oracle-set.js +6 -6
- package/lib/parse/specification/payment-channel-claim.js +6 -0
- package/lib/parse/specification/payment-channel-create.js +8 -11
- package/lib/parse/specification/payment-channel-fund.js +6 -0
- package/lib/parse/specification/payment.js +8 -15
- package/lib/parse/specification/remit.js +8 -11
- package/lib/parse/specification/settings.js +6 -0
- package/lib/parse/specification/ticket-create.js +6 -0
- package/lib/parse/specification/trustline.js +6 -0
- package/lib/parse/specification/unl-report.js +2 -7
- package/lib/parse/specification/unrecognized.js +6 -6
- package/lib/parse/specification/uritoken-burn.js +6 -0
- package/lib/parse/specification/uritoken-buy.js +6 -0
- package/lib/parse/specification/uritoken-cancel-sell-offer.js +6 -0
- package/lib/parse/specification/uritoken-create-sell-offer.js +8 -10
- package/lib/parse/specification/uritoken-mint.js +8 -10
- package/lib/parse/utils.d.ts +20 -3
- package/lib/parse/utils.js +1 -0
- package/lib/types/account.d.ts +5 -2
- package/lib/types/escrows.d.ts +0 -5
- package/lib/types/import.d.ts +0 -2
- package/lib/types/invoke.d.ts +2 -3
- package/lib/types/payments.d.ts +2 -2
- package/lib/types/remits.d.ts +0 -3
- package/lib/types/signers.d.ts +16 -0
- package/lib/types/specification.d.ts +4 -1
- package/lib/types/unl_reports.d.ts +0 -2
- package/package.json +2 -2
|
@@ -245,6 +245,9 @@ async function getAccountPaymentParams(account, connection) {
|
|
|
245
245
|
if (fee > FEE_LIMIT) {
|
|
246
246
|
fee = FEE_LIMIT;
|
|
247
247
|
}
|
|
248
|
+
if (!fee) {
|
|
249
|
+
throw new Error("Fee is not defined");
|
|
250
|
+
}
|
|
248
251
|
resolve((0, common_1.xrpToDrops)(fee.toString()));
|
|
249
252
|
});
|
|
250
253
|
const sequencePromise = new Promise(async (resolve, rejects) => {
|
|
@@ -310,6 +313,9 @@ async function getTxSubmitParams(account, tx, definitions, connection, skip) {
|
|
|
310
313
|
if (fee > FEE_LIMIT) {
|
|
311
314
|
fee = FEE_LIMIT;
|
|
312
315
|
}
|
|
316
|
+
if (!fee) {
|
|
317
|
+
throw new Error("Fee is not defined");
|
|
318
|
+
}
|
|
313
319
|
resolve((0, common_1.xrpToDrops)(fee.toString()));
|
|
314
320
|
}
|
|
315
321
|
catch (e) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseDestination = parseDestination;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
function parseDestination(tx) {
|
|
6
|
+
if (tx && tx.Destination) {
|
|
7
|
+
return (0, common_1.removeUndefined)({
|
|
8
|
+
address: tx.Destination,
|
|
9
|
+
tag: tx.DestinationTag,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSignerRegularKey = parseSignerRegularKey;
|
|
4
|
+
const ripple_keypairs_1 = require("ripple-keypairs");
|
|
5
|
+
function parseSignerRegularKey(tx) {
|
|
6
|
+
if (tx && tx.SigningPubKey && !tx.Signers) {
|
|
7
|
+
const signedBy = (0, ripple_keypairs_1.deriveAddress)(tx.SigningPubKey);
|
|
8
|
+
if (signedBy !== tx.Account) {
|
|
9
|
+
return {
|
|
10
|
+
address: signedBy,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSigners = parseSigners;
|
|
4
|
+
function parseSigners(tx) {
|
|
5
|
+
if (tx && tx.Signers) {
|
|
6
|
+
return tx.Signers.map((signer) => {
|
|
7
|
+
return {
|
|
8
|
+
address: signer.Signer.Account,
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.parseSourceWithAmount = parseSourceWithAmount;
|
|
7
|
+
exports.parseSource = parseSource;
|
|
8
|
+
const common_1 = require("../../common");
|
|
9
|
+
const amount_1 = __importDefault(require("./amount"));
|
|
10
|
+
const account_1 = require("./account");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
function parseSourceWithAmount(tx) {
|
|
13
|
+
if (tx && (tx.Account || tx.Account === "")) {
|
|
14
|
+
return (0, common_1.removeUndefined)({
|
|
15
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
16
|
+
maxAmount: (0, utils_1.removeGenericCounterparty)((0, amount_1.default)(tx.SendMax || tx.DeliverMax || tx.Amount), tx.Account),
|
|
17
|
+
tag: tx.SourceTag,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function parseSource(tx) {
|
|
22
|
+
if (tx && (tx.Account || tx.Account === "")) {
|
|
23
|
+
return (0, common_1.removeUndefined)({
|
|
24
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
25
|
+
tag: tx.SourceTag,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseAmmChanges = parseAmmChanges;
|
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
8
|
const common_1 = require("../../common");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
10
|
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
11
11
|
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
12
12
|
const auth_accounts_1 = __importDefault(require("../ledger/auth-accounts"));
|
|
@@ -44,7 +44,7 @@ function parseVoteSlot(voteSlot) {
|
|
|
44
44
|
}
|
|
45
45
|
function summarizeVoteSlotsChanges(node) {
|
|
46
46
|
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
47
|
-
const prev = node.previousFields
|
|
47
|
+
const prev = node.previousFields;
|
|
48
48
|
const changes = final.VoteSlots.reduce((acc, slot) => {
|
|
49
49
|
const prevSlot = prev.VoteSlots.find((s) => s.VoteEntry.Account === slot.VoteEntry.Account);
|
|
50
50
|
if (!prevSlot) {
|
|
@@ -89,7 +89,7 @@ function summarizeVoteSlotsChanges(node) {
|
|
|
89
89
|
}
|
|
90
90
|
function summarizeActionSlotChanges(node) {
|
|
91
91
|
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
92
|
-
const prev = node.previousFields
|
|
92
|
+
const prev = node.previousFields;
|
|
93
93
|
const changes = {};
|
|
94
94
|
if (prev.AuctionSlot) {
|
|
95
95
|
if (final.AuctionSlot.Account !== prev.AuctionSlot.Account) {
|
|
@@ -165,14 +165,14 @@ function isEqualAuthAccounts(obj1, obj2) {
|
|
|
165
165
|
}
|
|
166
166
|
function summarizeAmm(node) {
|
|
167
167
|
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
168
|
-
const prev = node.previousFields
|
|
168
|
+
const prev = node.previousFields;
|
|
169
169
|
let asset = (0, asset_1.default)(final.Asset);
|
|
170
170
|
if (node.diffType === "CreatedNode" && !asset) {
|
|
171
171
|
asset = { currency: (0, client_1.getNativeCurrency)() };
|
|
172
172
|
}
|
|
173
173
|
const summary = {
|
|
174
174
|
status: parseAmmStatus(node),
|
|
175
|
-
ammID: node.
|
|
175
|
+
ammID: node.ledgerIndex,
|
|
176
176
|
account: final.Account,
|
|
177
177
|
asset: asset,
|
|
178
178
|
asset2: (0, asset_1.default)(final.Asset2),
|
|
@@ -202,8 +202,13 @@ function summarizeAmm(node) {
|
|
|
202
202
|
return (0, common_1.removeUndefined)(summary);
|
|
203
203
|
}
|
|
204
204
|
function parseAmmChanges(metadata) {
|
|
205
|
-
const
|
|
206
|
-
|
|
205
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
206
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
207
|
+
return node.LedgerEntryType === "AMM";
|
|
207
208
|
});
|
|
208
|
-
|
|
209
|
+
if (affectedNodes.length !== 1) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
213
|
+
return summarizeAmm(normalizedNode);
|
|
209
214
|
}
|
|
@@ -13,9 +13,7 @@ export interface AddressBalanceChangeQuantity {
|
|
|
13
13
|
export interface BalanceChanges {
|
|
14
14
|
[key: string]: BalanceChangeQuantity[];
|
|
15
15
|
}
|
|
16
|
-
declare function parseBalanceChanges(metadata: TransactionMetadata, nativeCurrency?: string):
|
|
17
|
-
[x: string]: BalanceChangeQuantity[];
|
|
18
|
-
};
|
|
16
|
+
declare function parseBalanceChanges(metadata: TransactionMetadata, nativeCurrency?: string): BalanceChanges;
|
|
19
17
|
declare function parseFinalBalances(metadata: TransactionMetadata, nativeCurrency?: string): {
|
|
20
18
|
[x: string]: BalanceChangeQuantity[];
|
|
21
19
|
};
|
|
@@ -8,8 +8,8 @@ exports.parseFinalBalances = parseFinalBalances;
|
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
10
10
|
const common_1 = require("../../common");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
11
|
const client_1 = require("../../client");
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
13
|
function groupByAddress(balanceChanges) {
|
|
14
14
|
const grouped = lodash_1.default.groupBy(balanceChanges, function (node) {
|
|
15
15
|
return node.address;
|
|
@@ -63,7 +63,7 @@ function parseXRPQuantity(node, valueParser, nativeCurrency) {
|
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
return {
|
|
66
|
-
address: node.finalFields.Account || node.newFields.Account,
|
|
66
|
+
address: (node.finalFields.Account || node.newFields.Account),
|
|
67
67
|
balance: {
|
|
68
68
|
currency: nativeCurrency || (0, client_1.getNativeCurrency)(),
|
|
69
69
|
value: (0, common_1.dropsToXrp)(value).toString(),
|
|
@@ -114,15 +114,20 @@ function parseMPTQuantity(node, valueParser) {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
function parseQuantities(metadata, valueParser, nativeCurrency) {
|
|
117
|
-
const values =
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const values = metadata.AffectedNodes.map(function (affectedNode) {
|
|
118
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
119
|
+
if (!["AccountRoot", "RippleState", "MPToken"].includes(node.LedgerEntryType)) {
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNode);
|
|
123
|
+
if (node.LedgerEntryType === "AccountRoot") {
|
|
124
|
+
return [parseXRPQuantity(normalizedNode, valueParser, nativeCurrency)];
|
|
120
125
|
}
|
|
121
|
-
else if (node.
|
|
122
|
-
return parseTrustlineQuantity(
|
|
126
|
+
else if (node.LedgerEntryType === "RippleState") {
|
|
127
|
+
return parseTrustlineQuantity(normalizedNode, valueParser);
|
|
123
128
|
}
|
|
124
|
-
else if (node.
|
|
125
|
-
return [parseMPTQuantity(
|
|
129
|
+
else if (node.LedgerEntryType === "MPToken") {
|
|
130
|
+
return [parseMPTQuantity(normalizedNode, valueParser)];
|
|
126
131
|
}
|
|
127
132
|
return [];
|
|
128
133
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
2
|
+
declare function parseChannelChanges(metadata: TransactionMetadata): {
|
|
2
3
|
status: string | undefined;
|
|
3
|
-
channelId:
|
|
4
|
+
channelId: string;
|
|
4
5
|
source: any;
|
|
5
6
|
destination: any;
|
|
6
7
|
channelAmountDrops: string;
|
|
@@ -20,7 +20,7 @@ function parsePaymentChannelStatus(node) {
|
|
|
20
20
|
}
|
|
21
21
|
function summarizePaymentChannel(node) {
|
|
22
22
|
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
23
|
-
const prev = node.previousFields
|
|
23
|
+
const prev = node.previousFields;
|
|
24
24
|
const summary = {
|
|
25
25
|
status: parsePaymentChannelStatus(node),
|
|
26
26
|
channelId: node.ledgerIndex,
|
|
@@ -45,8 +45,13 @@ function summarizePaymentChannel(node) {
|
|
|
45
45
|
return summary;
|
|
46
46
|
}
|
|
47
47
|
function parseChannelChanges(metadata) {
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
49
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
50
|
+
return node.LedgerEntryType === "PayChannel";
|
|
50
51
|
});
|
|
51
|
-
|
|
52
|
+
if (affectedNodes.length !== 1) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
56
|
+
return summarizePaymentChannel(normalizedNode);
|
|
52
57
|
}
|
|
@@ -17,10 +17,10 @@ function parseDIDStatus(node) {
|
|
|
17
17
|
}
|
|
18
18
|
function summarizeDID(node) {
|
|
19
19
|
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
20
|
-
const prev = node.previousFields
|
|
20
|
+
const prev = node.previousFields;
|
|
21
21
|
const summary = {
|
|
22
22
|
status: parseDIDStatus(node),
|
|
23
|
-
didID: node.
|
|
23
|
+
didID: node.ledgerIndex,
|
|
24
24
|
account: final.Account,
|
|
25
25
|
uri: final.URI,
|
|
26
26
|
data: final.Data,
|
|
@@ -38,8 +38,13 @@ function summarizeDID(node) {
|
|
|
38
38
|
return (0, common_1.removeUndefined)(summary);
|
|
39
39
|
}
|
|
40
40
|
function parseDIDChanges(metadata) {
|
|
41
|
-
const
|
|
42
|
-
|
|
41
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
42
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
43
|
+
return node.LedgerEntryType === "DID";
|
|
43
44
|
});
|
|
44
|
-
|
|
45
|
+
if (affectedNodes.length !== 1) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
49
|
+
return summarizeDID(normalizedNode);
|
|
45
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormattedSourceAddress, FormattedDestinationAddress } from "../../types/account";
|
|
2
2
|
interface FormattedEscrowSummaryInterface {
|
|
3
3
|
status?: "created" | "cancelled" | "executed" | "deleted";
|
|
4
|
-
escrowIndex?:
|
|
4
|
+
escrowIndex?: string;
|
|
5
5
|
escrowSequence?: number;
|
|
6
6
|
amount?: string;
|
|
7
7
|
condition?: string;
|
|
@@ -63,8 +63,13 @@ function summarizeEscrow(tx, node) {
|
|
|
63
63
|
return (0, common_1.removeUndefined)(summary);
|
|
64
64
|
}
|
|
65
65
|
function parseEscrowChanges(tx) {
|
|
66
|
-
const
|
|
67
|
-
|
|
66
|
+
const affectedNodes = tx.meta.AffectedNodes.filter((affectedNode) => {
|
|
67
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
68
|
+
return node.LedgerEntryType === "Escrow";
|
|
68
69
|
});
|
|
69
|
-
|
|
70
|
+
if (affectedNodes.length !== 1) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
74
|
+
return summarizeEscrow(tx, normalizedNode);
|
|
70
75
|
}
|
|
@@ -62,9 +62,14 @@ function parseTrustlineQuantity(node, valueParser) {
|
|
|
62
62
|
return [result];
|
|
63
63
|
}
|
|
64
64
|
function parseQuantities(metadata, valueParser) {
|
|
65
|
-
const values =
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const values = metadata.AffectedNodes.map(function (affectedNode) {
|
|
66
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
67
|
+
if (node.LedgerEntryType !== "RippleState") {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNode);
|
|
71
|
+
if (node.LedgerEntryType === "RippleState") {
|
|
72
|
+
return parseTrustlineQuantity(normalizedNode, valueParser);
|
|
68
73
|
}
|
|
69
74
|
return [];
|
|
70
75
|
});
|
|
@@ -55,7 +55,7 @@ function parsePriceDataSeries(series) {
|
|
|
55
55
|
}
|
|
56
56
|
function summarizePriceDataSeriesChanges(node) {
|
|
57
57
|
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
58
|
-
const prev = node.previousFields
|
|
58
|
+
const prev = node.previousFields;
|
|
59
59
|
const changes = final.PriceDataSeries.reduce((acc, series) => {
|
|
60
60
|
const prevSeries = prev.PriceDataSeries.find((s) => s.PriceData.BaseAsset === series.PriceData.BaseAsset && s.PriceData.QuoteAsset === series.PriceData.QuoteAsset);
|
|
61
61
|
const priceFinal = hexPriceToBigNumber(series.PriceData.AssetPrice) || new bignumber_js_1.default(0);
|
|
@@ -115,10 +115,10 @@ function summarizePriceDataSeriesChanges(node) {
|
|
|
115
115
|
}
|
|
116
116
|
function summarizeOracle(node) {
|
|
117
117
|
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
118
|
-
const prev = node.previousFields
|
|
118
|
+
const prev = node.previousFields;
|
|
119
119
|
const summary = {
|
|
120
120
|
status: parseOracleStatus(node),
|
|
121
|
-
oracleID: node.
|
|
121
|
+
oracleID: node.ledgerIndex,
|
|
122
122
|
oracleDocumentID: final.OracleDocumentID,
|
|
123
123
|
provider: final.Provider,
|
|
124
124
|
uri: final.URI,
|
|
@@ -138,8 +138,13 @@ function summarizeOracle(node) {
|
|
|
138
138
|
return (0, common_1.removeUndefined)(summary);
|
|
139
139
|
}
|
|
140
140
|
function parseOracleChanges(metadata) {
|
|
141
|
-
const
|
|
142
|
-
|
|
141
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
142
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
143
|
+
return node.LedgerEntryType === "Oracle";
|
|
143
144
|
});
|
|
144
|
-
|
|
145
|
+
if (affectedNodes.length !== 1) {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
149
|
+
return summarizeOracle(normalizedNode);
|
|
145
150
|
}
|
|
@@ -31,18 +31,18 @@ function convertOrderChange(order) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
function getExpirationTime(node) {
|
|
34
|
-
const expirationTime = node.finalFields.Expiration || node.newFields.Expiration;
|
|
34
|
+
const expirationTime = (node.finalFields.Expiration || node.newFields.Expiration);
|
|
35
35
|
if (expirationTime === undefined) {
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
38
|
return new Date((0, models_1.ledgerTimeToTimestamp)(expirationTime)).toISOString();
|
|
39
39
|
}
|
|
40
40
|
function getQuality(node) {
|
|
41
|
-
const takerGets = node.finalFields.TakerGets || node.newFields.TakerGets;
|
|
42
|
-
const takerPays = node.finalFields.TakerPays || node.newFields.TakerPays;
|
|
41
|
+
const takerGets = (node.finalFields.TakerGets || node.newFields.TakerGets);
|
|
42
|
+
const takerPays = (node.finalFields.TakerPays || node.newFields.TakerPays);
|
|
43
43
|
const takerGetsCurrency = takerGets.currency || (0, client_1.getNativeCurrency)();
|
|
44
44
|
const takerPaysCurrency = takerPays.currency || (0, client_1.getNativeCurrency)();
|
|
45
|
-
const bookDirectory = node.finalFields.BookDirectory || node.newFields.BookDirectory;
|
|
45
|
+
const bookDirectory = (node.finalFields.BookDirectory || node.newFields.BookDirectory);
|
|
46
46
|
const qualityHex = bookDirectory.substring(bookDirectory.length - 16);
|
|
47
47
|
return (0, orderbook_quality_1.parseOrderbookQuality)(qualityHex, takerGetsCurrency, takerPaysCurrency);
|
|
48
48
|
}
|
|
@@ -87,7 +87,7 @@ function parseOrderChange(node) {
|
|
|
87
87
|
taker_pays: parseChangeAmount(node, "TakerPays"),
|
|
88
88
|
taker_gets: parseChangeAmount(node, "TakerGets"),
|
|
89
89
|
sell: (node.finalFields.Flags & xrpl_1.LedgerEntry.OfferFlags.lsfSell) !== 0,
|
|
90
|
-
sequence: node.finalFields.Sequence || node.newFields.Sequence,
|
|
90
|
+
sequence: (node.finalFields.Sequence || node.newFields.Sequence),
|
|
91
91
|
status: parseOrderStatus(node),
|
|
92
92
|
quality: getQuality(node),
|
|
93
93
|
expiration: getExpirationTime(node),
|
|
@@ -103,9 +103,13 @@ function groupByAddress(orderChanges) {
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
function parseOrderbookChanges(metadata) {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
return node.
|
|
109
|
-
})
|
|
106
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
107
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
108
|
+
return node.LedgerEntryType === "Offer";
|
|
109
|
+
});
|
|
110
|
+
const orderChanges = affectedNodes.map((affectedNode) => {
|
|
111
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNode);
|
|
112
|
+
return parseOrderChange(normalizedNode);
|
|
113
|
+
});
|
|
110
114
|
return groupByAddress(orderChanges);
|
|
111
115
|
}
|
|
@@ -36,8 +36,13 @@ function summarizeUNLReport(tx, node) {
|
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
38
|
function parseUNLReportChanges(tx) {
|
|
39
|
-
const
|
|
40
|
-
|
|
39
|
+
const affectedNodes = tx.meta.AffectedNodes.filter((affectedNode) => {
|
|
40
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
41
|
+
return node.LedgerEntryType === "UNLReport";
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
+
if (affectedNodes.length !== 1) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
47
|
+
return summarizeUNLReport(tx, normalizedNode);
|
|
43
48
|
}
|
|
@@ -37,20 +37,17 @@ const assert = __importStar(require("assert"));
|
|
|
37
37
|
const common_1 = require("../../common");
|
|
38
38
|
const emit_details_1 = require("../ledger/emit_details");
|
|
39
39
|
const memos_1 = require("../ledger/memos");
|
|
40
|
-
const
|
|
40
|
+
const signers_1 = require("../ledger/signers");
|
|
41
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
42
|
+
const source_1 = require("../ledger/source");
|
|
43
|
+
const destination_1 = require("../ledger/destination");
|
|
41
44
|
function parseAccountDelete(tx) {
|
|
42
45
|
assert.ok(tx.TransactionType === "AccountDelete");
|
|
43
|
-
const source = (0, common_1.removeUndefined)({
|
|
44
|
-
address: (0, account_1.parseAccount)(tx.Account),
|
|
45
|
-
tag: tx.SourceTag,
|
|
46
|
-
});
|
|
47
|
-
const destination = (0, common_1.removeUndefined)({
|
|
48
|
-
address: tx.Destination,
|
|
49
|
-
tag: tx.DestinationTag,
|
|
50
|
-
});
|
|
51
46
|
return (0, common_1.removeUndefined)({
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
48
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
49
|
+
source: (0, source_1.parseSource)(tx),
|
|
50
|
+
destination: (0, destination_1.parseDestination)(tx),
|
|
54
51
|
emittedDetails: (0, emit_details_1.parseEmittedDetails)(tx),
|
|
55
52
|
memos: (0, memos_1.parseMemos)(tx),
|
|
56
53
|
});
|
|
@@ -42,15 +42,15 @@ const amount_1 = __importDefault(require("../ledger/amount"));
|
|
|
42
42
|
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
43
43
|
const auth_accounts_1 = __importDefault(require("../ledger/auth-accounts"));
|
|
44
44
|
const memos_1 = require("../ledger/memos");
|
|
45
|
-
const
|
|
45
|
+
const signers_1 = require("../ledger/signers");
|
|
46
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
47
|
+
const source_1 = require("../ledger/source");
|
|
46
48
|
function parseAmmBid(tx) {
|
|
47
49
|
assert.ok(tx.TransactionType === "AMMBid");
|
|
48
|
-
const source = (0, common_1.removeUndefined)({
|
|
49
|
-
address: (0, account_1.parseAccount)(tx.Account),
|
|
50
|
-
tag: tx.SourceTag,
|
|
51
|
-
});
|
|
52
50
|
return (0, common_1.removeUndefined)({
|
|
53
|
-
|
|
51
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
52
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
53
|
+
source: (0, source_1.parseSource)(tx),
|
|
54
54
|
asset: (0, asset_1.default)(tx.Asset),
|
|
55
55
|
asset2: (0, asset_1.default)(tx.Asset2),
|
|
56
56
|
bidMin: tx.BidMin ? (0, amount_1.default)(tx.BidMin) : undefined,
|
|
@@ -42,15 +42,16 @@ const amount_1 = __importDefault(require("../ledger/amount"));
|
|
|
42
42
|
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
43
43
|
const memos_1 = require("../ledger/memos");
|
|
44
44
|
const account_1 = require("../ledger/account");
|
|
45
|
+
const signers_1 = require("../ledger/signers");
|
|
46
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
47
|
+
const source_1 = require("../ledger/source");
|
|
45
48
|
const amm_clawback_flags_1 = __importDefault(require("../ledger/amm-clawback-flags"));
|
|
46
49
|
function parseAmmClawback(tx) {
|
|
47
50
|
assert.ok(tx.TransactionType === "AMMClawback");
|
|
48
|
-
const source = (0, common_1.removeUndefined)({
|
|
49
|
-
address: (0, account_1.parseAccount)(tx.Account),
|
|
50
|
-
tag: tx.SourceTag,
|
|
51
|
-
});
|
|
52
51
|
return (0, common_1.removeUndefined)({
|
|
53
|
-
|
|
52
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
53
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
54
|
+
source: (0, source_1.parseSource)(tx),
|
|
54
55
|
asset: (0, asset_1.default)(tx.Asset),
|
|
55
56
|
asset2: (0, asset_1.default)(tx.Asset2),
|
|
56
57
|
amount: tx.Amount ? (0, amount_1.default)(tx.Amount) : undefined,
|
|
@@ -40,15 +40,15 @@ const assert = __importStar(require("assert"));
|
|
|
40
40
|
const common_1 = require("../../common");
|
|
41
41
|
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
42
42
|
const memos_1 = require("../ledger/memos");
|
|
43
|
-
const
|
|
43
|
+
const signers_1 = require("../ledger/signers");
|
|
44
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
45
|
+
const source_1 = require("../ledger/source");
|
|
44
46
|
function parseAmmCreate(tx) {
|
|
45
47
|
assert.ok(tx.TransactionType === "AMMCreate");
|
|
46
|
-
const source = (0, common_1.removeUndefined)({
|
|
47
|
-
address: (0, account_1.parseAccount)(tx.Account),
|
|
48
|
-
tag: tx.SourceTag,
|
|
49
|
-
});
|
|
50
48
|
return (0, common_1.removeUndefined)({
|
|
51
|
-
|
|
49
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
50
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
51
|
+
source: (0, source_1.parseSource)(tx),
|
|
52
52
|
amount: (0, amount_1.default)(tx.Amount),
|
|
53
53
|
amount2: (0, amount_1.default)(tx.Amount2),
|
|
54
54
|
tradingFee: tx.TradingFee,
|
|
@@ -40,15 +40,15 @@ const assert = __importStar(require("assert"));
|
|
|
40
40
|
const common_1 = require("../../common");
|
|
41
41
|
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
42
42
|
const memos_1 = require("../ledger/memos");
|
|
43
|
-
const
|
|
43
|
+
const signers_1 = require("../ledger/signers");
|
|
44
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
45
|
+
const source_1 = require("../ledger/source");
|
|
44
46
|
function parseAmmDelete(tx) {
|
|
45
47
|
assert.ok(tx.TransactionType === "AMMDelete");
|
|
46
|
-
const source = (0, common_1.removeUndefined)({
|
|
47
|
-
address: (0, account_1.parseAccount)(tx.Account),
|
|
48
|
-
tag: tx.SourceTag,
|
|
49
|
-
});
|
|
50
48
|
return (0, common_1.removeUndefined)({
|
|
51
|
-
|
|
49
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
50
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
51
|
+
source: (0, source_1.parseSource)(tx),
|
|
52
52
|
asset: (0, asset_1.default)(tx.Asset),
|
|
53
53
|
asset2: (0, asset_1.default)(tx.Asset2),
|
|
54
54
|
memos: (0, memos_1.parseMemos)(tx),
|
|
@@ -41,16 +41,16 @@ const common_1 = require("../../common");
|
|
|
41
41
|
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
42
42
|
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
43
43
|
const memos_1 = require("../ledger/memos");
|
|
44
|
-
const
|
|
44
|
+
const signers_1 = require("../ledger/signers");
|
|
45
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
46
|
+
const source_1 = require("../ledger/source");
|
|
45
47
|
const amm_deposit_flags_1 = __importDefault(require("../ledger/amm-deposit-flags"));
|
|
46
48
|
function parseAmmDeposit(tx) {
|
|
47
49
|
assert.ok(tx.TransactionType === "AMMDeposit");
|
|
48
|
-
const source = (0, common_1.removeUndefined)({
|
|
49
|
-
address: (0, account_1.parseAccount)(tx.Account),
|
|
50
|
-
tag: tx.SourceTag,
|
|
51
|
-
});
|
|
52
50
|
return (0, common_1.removeUndefined)({
|
|
53
|
-
|
|
51
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
52
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
53
|
+
source: (0, source_1.parseSource)(tx),
|
|
54
54
|
asset: (0, asset_1.default)(tx.Asset),
|
|
55
55
|
asset2: (0, asset_1.default)(tx.Asset2),
|
|
56
56
|
amount: tx.Amount ? (0, amount_1.default)(tx.Amount) : undefined,
|
|
@@ -40,15 +40,15 @@ const assert = __importStar(require("assert"));
|
|
|
40
40
|
const common_1 = require("../../common");
|
|
41
41
|
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
42
42
|
const memos_1 = require("../ledger/memos");
|
|
43
|
-
const
|
|
43
|
+
const signers_1 = require("../ledger/signers");
|
|
44
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
45
|
+
const source_1 = require("../ledger/source");
|
|
44
46
|
function parseAmmVote(tx) {
|
|
45
47
|
assert.ok(tx.TransactionType === "AMMVote");
|
|
46
|
-
const source = (0, common_1.removeUndefined)({
|
|
47
|
-
address: (0, account_1.parseAccount)(tx.Account),
|
|
48
|
-
tag: tx.SourceTag,
|
|
49
|
-
});
|
|
50
48
|
return (0, common_1.removeUndefined)({
|
|
51
|
-
|
|
49
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
50
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
51
|
+
source: (0, source_1.parseSource)(tx),
|
|
52
52
|
asset: (0, asset_1.default)(tx.Asset),
|
|
53
53
|
asset2: (0, asset_1.default)(tx.Asset2),
|
|
54
54
|
tradingFee: tx.TradingFee,
|