@bithomp/xrpl-api 3.0.1 → 3.0.2
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/parse/ledger/amm-deposit-flags.d.ts +5 -0
- package/lib/parse/ledger/amm-deposit-flags.js +8 -0
- package/lib/parse/ledger/amm-withdraw-flags.d.ts +5 -0
- package/lib/parse/ledger/amm-withdraw-flags.js +8 -0
- package/lib/parse/ledger/asset.d.ts +3 -0
- package/lib/parse/ledger/asset.js +18 -0
- package/lib/parse/ledger/auth-accounts.d.ts +3 -0
- package/lib/parse/ledger/auth-accounts.js +18 -0
- package/lib/parse/outcome/amm_changes.d.ts +51 -0
- package/lib/parse/outcome/amm_changes.js +205 -0
- package/lib/parse/outcome/index.d.ts +1 -0
- package/lib/parse/outcome/index.js +3 -1
- package/lib/parse/outcome.js +2 -0
- package/lib/parse/specification/amm-bid.d.ts +3 -0
- package/lib/parse/specification/amm-bid.js +52 -0
- package/lib/parse/specification/amm-create.d.ts +3 -0
- package/lib/parse/specification/amm-create.js +48 -0
- package/lib/parse/specification/amm-delete.d.ts +3 -0
- package/lib/parse/specification/amm-delete.js +47 -0
- package/lib/parse/specification/amm-deposit.d.ts +3 -0
- package/lib/parse/specification/amm-deposit.js +54 -0
- package/lib/parse/specification/amm-vote.d.ts +3 -0
- package/lib/parse/specification/amm-vote.js +48 -0
- package/lib/parse/specification/amm-withdraw.d.ts +3 -0
- package/lib/parse/specification/amm-withdraw.js +54 -0
- package/lib/parse/specification/clawback.d.ts +3 -0
- package/lib/parse/specification/clawback.js +46 -0
- package/lib/parse/transaction.d.ts +3 -1
- package/lib/parse/transaction.js +28 -6
- package/lib/types/amm.d.ts +81 -0
- package/lib/types/amm.js +20 -0
- package/lib/types/clawback.d.ts +5 -0
- package/lib/types/clawback.js +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/outcome.d.ts +1 -0
- package/lib/types/specification.d.ts +2 -0
- package/package.json +10 -10
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const amm_1 = require("../../types/amm");
|
|
4
|
+
const flags_1 = require("./flags");
|
|
5
|
+
function parseAmmDepositFlags(value, options = {}) {
|
|
6
|
+
return (0, flags_1.parseFlags)(value, amm_1.AMMDepositFlagsKeys, options);
|
|
7
|
+
}
|
|
8
|
+
exports.default = parseAmmDepositFlags;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const amm_1 = require("../../types/amm");
|
|
4
|
+
const flags_1 = require("./flags");
|
|
5
|
+
function parseAmmWithdrawFlags(value, options = {}) {
|
|
6
|
+
return (0, flags_1.parseFlags)(value, amm_1.AMMWithdrawFlagsKeys, options);
|
|
7
|
+
}
|
|
8
|
+
exports.default = parseAmmWithdrawFlags;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_1 = require("../../client");
|
|
4
|
+
function parseAsset(asset) {
|
|
5
|
+
if (asset === undefined) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
if (asset.currency === (0, client_1.getNativeCurrency)()) {
|
|
9
|
+
return {
|
|
10
|
+
currency: asset.currency,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
currency: asset.currency,
|
|
15
|
+
counterparty: asset.issuer,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.default = parseAsset;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function parseAuthAccounts(authAccounts) {
|
|
4
|
+
if (!authAccounts) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const result = [];
|
|
8
|
+
for (const authAccount of authAccounts) {
|
|
9
|
+
if (authAccount.AuthAccount.Account) {
|
|
10
|
+
result.push(authAccount.AuthAccount.Account);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (result.length === 0) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
exports.default = parseAuthAccounts;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FormattedIssuedCurrency, FormattedAmount } from "../../types";
|
|
2
|
+
interface FormattedAuctionSlot {
|
|
3
|
+
account: string;
|
|
4
|
+
authAccounts?: string[];
|
|
5
|
+
discountedFee?: number;
|
|
6
|
+
expiration?: number;
|
|
7
|
+
price?: FormattedAmount;
|
|
8
|
+
timeInterval?: number;
|
|
9
|
+
}
|
|
10
|
+
interface FormattedVoteSlot {
|
|
11
|
+
account: string;
|
|
12
|
+
tradingFee?: number;
|
|
13
|
+
voteWeight?: number;
|
|
14
|
+
}
|
|
15
|
+
interface FormattedAmmSummaryInterface {
|
|
16
|
+
status?: "created" | "modified" | "deleted";
|
|
17
|
+
ammID?: string;
|
|
18
|
+
account?: string;
|
|
19
|
+
asset?: FormattedIssuedCurrency;
|
|
20
|
+
asset2?: FormattedIssuedCurrency;
|
|
21
|
+
auctionSlot: FormattedAuctionSlot;
|
|
22
|
+
lpTokenBalance: FormattedAmount;
|
|
23
|
+
tradingFee: number;
|
|
24
|
+
ownerNode: string;
|
|
25
|
+
voteSlots: FormattedVoteSlot[];
|
|
26
|
+
lpTokenBalanceChange?: FormattedAmount;
|
|
27
|
+
tradingFeeChanges?: number;
|
|
28
|
+
voteSlotsChanges?: FormattedAmmVoteSlotChanges[];
|
|
29
|
+
auctionSlotChanges?: FormattedAuctionSlotChanges;
|
|
30
|
+
}
|
|
31
|
+
interface FormattedAuctionSlotChanges {
|
|
32
|
+
accountChanges?: string;
|
|
33
|
+
authAccountsChanges?: {
|
|
34
|
+
status: string;
|
|
35
|
+
account: string;
|
|
36
|
+
}[];
|
|
37
|
+
discountedFeeChange?: number;
|
|
38
|
+
expirationChange?: number;
|
|
39
|
+
priceChange?: FormattedAmount;
|
|
40
|
+
timeIntervalChange?: number;
|
|
41
|
+
}
|
|
42
|
+
interface FormattedAmmVoteSlotChanges {
|
|
43
|
+
status: "added" | "modified" | "removed";
|
|
44
|
+
account: string;
|
|
45
|
+
tradingFee?: number;
|
|
46
|
+
voteWeight?: number;
|
|
47
|
+
tradingFeeChange?: number;
|
|
48
|
+
voteWeightChange?: number;
|
|
49
|
+
}
|
|
50
|
+
declare function parseAmmChanges(metadata: any): FormattedAmmSummaryInterface | undefined;
|
|
51
|
+
export { parseAmmChanges };
|
|
@@ -0,0 +1,205 @@
|
|
|
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.parseAmmChanges = void 0;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const common_1 = require("../../common");
|
|
10
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
11
|
+
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
12
|
+
const auth_accounts_1 = __importDefault(require("../ledger/auth-accounts"));
|
|
13
|
+
const client_1 = require("../../client");
|
|
14
|
+
function parseAmmStatus(node) {
|
|
15
|
+
if (node.diffType === "CreatedNode") {
|
|
16
|
+
return "created";
|
|
17
|
+
}
|
|
18
|
+
if (node.diffType === "ModifiedNode") {
|
|
19
|
+
return "modified";
|
|
20
|
+
}
|
|
21
|
+
if (node.diffType === "DeletedNode") {
|
|
22
|
+
return "deleted";
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function parseAuctionSlot(auctionSlot) {
|
|
27
|
+
const slot = {
|
|
28
|
+
account: auctionSlot.Account,
|
|
29
|
+
authAccounts: (0, auth_accounts_1.default)(auctionSlot.AuthAccounts),
|
|
30
|
+
discountedFee: auctionSlot.DiscountedFee,
|
|
31
|
+
expiration: auctionSlot.Expiration,
|
|
32
|
+
price: auctionSlot.Price,
|
|
33
|
+
timeInterval: auctionSlot.TimeInterval,
|
|
34
|
+
};
|
|
35
|
+
return (0, common_1.removeUndefined)(slot);
|
|
36
|
+
}
|
|
37
|
+
function parseVoteSlot(voteSlot) {
|
|
38
|
+
return {
|
|
39
|
+
account: voteSlot.VoteEntry.Account,
|
|
40
|
+
tradingFee: voteSlot.VoteEntry.TradingFee,
|
|
41
|
+
voteWeight: voteSlot.VoteEntry.VoteWeight,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function summarizeVoteSlotsChanges(node) {
|
|
45
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
46
|
+
const prev = node.previousFields || {};
|
|
47
|
+
const changes = final.VoteSlots.reduce((acc, slot) => {
|
|
48
|
+
const prevSlot = prev.VoteSlots.find((s) => s.VoteEntry.Account === slot.VoteEntry.Account);
|
|
49
|
+
if (!prevSlot) {
|
|
50
|
+
return acc.concat({
|
|
51
|
+
status: "added",
|
|
52
|
+
account: slot.VoteEntry.Account,
|
|
53
|
+
tradingFee: slot.VoteEntry.TradingFee,
|
|
54
|
+
voteWeight: slot.VoteEntry.VoteWeight,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const tradingFeeChange = slot.VoteEntry.TradingFee - prevSlot.VoteEntry.TradingFee;
|
|
58
|
+
const voteWeightChange = slot.VoteEntry.VoteWeight - prevSlot.VoteEntry.VoteWeight;
|
|
59
|
+
if (tradingFeeChange !== 0 || voteWeightChange !== 0) {
|
|
60
|
+
return acc.concat((0, common_1.removeUndefined)({
|
|
61
|
+
status: "modified",
|
|
62
|
+
account: slot.VoteEntry.Account,
|
|
63
|
+
tradingFeeChange: tradingFeeChange || undefined,
|
|
64
|
+
voteWeightChange: voteWeightChange || undefined,
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
return acc;
|
|
68
|
+
}, []);
|
|
69
|
+
const removed = prev.VoteSlots.filter((s) => {
|
|
70
|
+
return !final.VoteSlots.find((slot) => slot.VoteEntry.Account === s.VoteEntry.Account);
|
|
71
|
+
});
|
|
72
|
+
if (removed.length > 0) {
|
|
73
|
+
return changes.concat(removed.map((s) => {
|
|
74
|
+
return {
|
|
75
|
+
status: "removed",
|
|
76
|
+
account: s.VoteEntry.Account,
|
|
77
|
+
tradingFee: s.VoteEntry.TradingFee,
|
|
78
|
+
voteWeight: s.VoteEntry.VoteWeight,
|
|
79
|
+
};
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
if (changes.length === 0) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
return changes;
|
|
86
|
+
}
|
|
87
|
+
function summarizeActionSlotChanges(node) {
|
|
88
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
89
|
+
const prev = node.previousFields || {};
|
|
90
|
+
const changes = {};
|
|
91
|
+
if (prev.AuctionSlot) {
|
|
92
|
+
if (final.AuctionSlot.Account !== prev.AuctionSlot.Account) {
|
|
93
|
+
changes.accountChanges = final.AuctionSlot.Account;
|
|
94
|
+
}
|
|
95
|
+
if (final.AuctionSlot.DiscountedFee !== prev.AuctionSlot.DiscountedFee) {
|
|
96
|
+
changes.discountedFeeChange = final.AuctionSlot.DiscountedFee - prev.AuctionSlot.DiscountedFee;
|
|
97
|
+
}
|
|
98
|
+
if (final.AuctionSlot.Expiration !== prev.AuctionSlot.Expiration) {
|
|
99
|
+
changes.expirationChange = final.AuctionSlot.Expiration - prev.AuctionSlot.Expiration;
|
|
100
|
+
}
|
|
101
|
+
if (final.AuctionSlot.Price.value !== prev.AuctionSlot.Price.value) {
|
|
102
|
+
changes.priceChange = {
|
|
103
|
+
currency: final.AuctionSlot.Price.currency,
|
|
104
|
+
counterparty: final.AuctionSlot.Price.issuer,
|
|
105
|
+
value: new bignumber_js_1.default(final.AuctionSlot.Price.value)
|
|
106
|
+
.minus(new bignumber_js_1.default(prev.AuctionSlot.Price.value))
|
|
107
|
+
.toString(10),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (final.AuctionSlot.TimeInterval !== prev.AuctionSlot.TimeInterval) {
|
|
111
|
+
changes.timeIntervalChange = final.AuctionSlot.TimeInterval - prev.AuctionSlot.TimeInterval;
|
|
112
|
+
}
|
|
113
|
+
if (!isEqualAuthAccounts(final.AuctionSlot.AuthAccounts, prev.AuctionSlot.AuthAccounts)) {
|
|
114
|
+
const prevAuthAccounts = prev.AuctionSlot.AuthAccounts || [];
|
|
115
|
+
const finalAuthAccounts = final.AuctionSlot.AuthAccounts || [];
|
|
116
|
+
let authAccountsChanges = finalAuthAccounts.map((auth) => {
|
|
117
|
+
if (!prevAuthAccounts.includes(auth.AuthAccount.Account)) {
|
|
118
|
+
return {
|
|
119
|
+
status: "added",
|
|
120
|
+
account: auth.AuthAccount.Account,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
const removed = prevAuthAccounts.filter((auth) => {
|
|
125
|
+
return !finalAuthAccounts.includes(auth.AuthAccount.Account);
|
|
126
|
+
});
|
|
127
|
+
if (removed.length > 0) {
|
|
128
|
+
authAccountsChanges = authAccountsChanges.concat(removed.map((account) => {
|
|
129
|
+
return {
|
|
130
|
+
status: "removed",
|
|
131
|
+
account: account.AuthAccount.Account,
|
|
132
|
+
};
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
changes.authAccountsChanges = authAccountsChanges;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (Object.keys(changes).length === 0) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
return (0, common_1.removeUndefined)(changes);
|
|
142
|
+
}
|
|
143
|
+
function isEqualAuthAccounts(obj1, obj2) {
|
|
144
|
+
if (obj1 === undefined && obj2 === undefined) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
if ((obj1 === undefined && obj2 !== undefined) || (obj1 !== undefined && obj2 === undefined)) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (obj1.length !== obj2.length) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
const obj1Sorted = obj1.sort((a, b) => a.AuthAccount.Account.localeCompare(b.AuthAccount.Account));
|
|
154
|
+
const obj2Sorted = obj2.sort((a, b) => a.AuthAccount.Account.localeCompare(b.AuthAccount.Account));
|
|
155
|
+
for (let i = 0; i < obj1Sorted.length; i++) {
|
|
156
|
+
if (obj1Sorted[i].AuthAccount.Account !== obj2Sorted[i].AuthAccount.Account) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
function summarizeAmm(node) {
|
|
163
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
164
|
+
const prev = node.previousFields || {};
|
|
165
|
+
let asset = (0, asset_1.default)(final.Asset);
|
|
166
|
+
if (node.diffType === "CreatedNode" && !asset) {
|
|
167
|
+
asset = { currency: (0, client_1.getNativeCurrency)() };
|
|
168
|
+
}
|
|
169
|
+
const summary = {
|
|
170
|
+
status: parseAmmStatus(node),
|
|
171
|
+
ammID: node.LedgerIndex,
|
|
172
|
+
account: final.Account,
|
|
173
|
+
asset: asset,
|
|
174
|
+
asset2: (0, asset_1.default)(final.Asset2),
|
|
175
|
+
auctionSlot: parseAuctionSlot(final.AuctionSlot),
|
|
176
|
+
lpTokenBalance: (0, amount_1.default)(final.LPTokenBalance),
|
|
177
|
+
tradingFee: final.TradingFee,
|
|
178
|
+
ownerNode: final.OwnerNode,
|
|
179
|
+
voteSlots: final.VoteSlots ? final.VoteSlots.map(parseVoteSlot) : undefined,
|
|
180
|
+
};
|
|
181
|
+
if (prev.LPTokenBalance) {
|
|
182
|
+
summary.lpTokenBalanceChange = {
|
|
183
|
+
currency: final.LPTokenBalance.currency,
|
|
184
|
+
counterparty: final.LPTokenBalance.issuer,
|
|
185
|
+
value: new bignumber_js_1.default(final.LPTokenBalance.value).minus(new bignumber_js_1.default(prev.LPTokenBalance.value)).toString(10),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (prev.VoteSlots) {
|
|
189
|
+
summary.voteSlotsChanges = summarizeVoteSlotsChanges(node);
|
|
190
|
+
}
|
|
191
|
+
if (prev.TradingFee) {
|
|
192
|
+
summary.tradingFeeChanges = final.TradingFee - (prev.TradingFee || 0);
|
|
193
|
+
}
|
|
194
|
+
if (prev.AuctionSlot) {
|
|
195
|
+
summary.auctionSlotChanges = summarizeActionSlotChanges(node);
|
|
196
|
+
}
|
|
197
|
+
return (0, common_1.removeUndefined)(summary);
|
|
198
|
+
}
|
|
199
|
+
function parseAmmChanges(metadata) {
|
|
200
|
+
const amms = (0, utils_1.normalizeNodes)(metadata).filter((n) => {
|
|
201
|
+
return n.entryType === "AMM";
|
|
202
|
+
});
|
|
203
|
+
return amms.length === 1 ? summarizeAmm(amms[0]) : undefined;
|
|
204
|
+
}
|
|
205
|
+
exports.parseAmmChanges = parseAmmChanges;
|
|
@@ -11,3 +11,4 @@ export { parseHooksExecutions } from "./hooks_executions";
|
|
|
11
11
|
export { parseEmittedTxns } from "./emitted_txns";
|
|
12
12
|
export { parseEscrowChanges } from "./escrow_changes";
|
|
13
13
|
export { parseUNLReportChanges } from "./unl_report_changes";
|
|
14
|
+
export { parseAmmChanges } from "./amm_changes";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseUNLReportChanges = exports.parseEscrowChanges = exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
3
|
+
exports.parseAmmChanges = exports.parseUNLReportChanges = exports.parseEscrowChanges = 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");
|
|
@@ -27,3 +27,5 @@ var escrow_changes_1 = require("./escrow_changes");
|
|
|
27
27
|
Object.defineProperty(exports, "parseEscrowChanges", { enumerable: true, get: function () { return escrow_changes_1.parseEscrowChanges; } });
|
|
28
28
|
var unl_report_changes_1 = require("./unl_report_changes");
|
|
29
29
|
Object.defineProperty(exports, "parseUNLReportChanges", { enumerable: true, get: function () { return unl_report_changes_1.parseUNLReportChanges; } });
|
|
30
|
+
var amm_changes_1 = require("./amm_changes");
|
|
31
|
+
Object.defineProperty(exports, "parseAmmChanges", { enumerable: true, get: function () { return amm_changes_1.parseAmmChanges; } });
|
package/lib/parse/outcome.js
CHANGED
|
@@ -78,6 +78,7 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
78
78
|
const hooksExecutions = (0, index_1.parseHooksExecutions)(tx);
|
|
79
79
|
const emittedTxns = (0, index_1.parseEmittedTxns)(tx, definitions);
|
|
80
80
|
const unlReportChanges = (0, index_1.parseUNLReportChanges)(tx);
|
|
81
|
+
const ammChanges = (0, index_1.parseAmmChanges)(metadata);
|
|
81
82
|
removeEmptyCounterpartyInBalanceChanges(balanceChanges);
|
|
82
83
|
removeEmptyCounterpartyInBalanceChanges(lockedBalanceChanges);
|
|
83
84
|
removeEmptyCounterpartyInOrderbookChanges(orderbookChanges);
|
|
@@ -95,6 +96,7 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
95
96
|
uritokenChanges: Object.keys(uritokenChanges).length > 0 ? uritokenChanges : undefined,
|
|
96
97
|
uritokenSellOfferChanges: Object.keys(uritokenSellOfferChanges).length > 0 ? uritokenSellOfferChanges : undefined,
|
|
97
98
|
affectedObjects: affectedObjects ? (0, common_1.removeUndefined)(affectedObjects) : undefined,
|
|
99
|
+
ammChanges: ammChanges ? (0, common_1.removeUndefined)(ammChanges) : undefined,
|
|
98
100
|
unlReportChanges,
|
|
99
101
|
hooksExecutions,
|
|
100
102
|
emittedTxns,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
32
|
+
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
33
|
+
const auth_accounts_1 = __importDefault(require("../ledger/auth-accounts"));
|
|
34
|
+
const memos_1 = require("../ledger/memos");
|
|
35
|
+
const account_1 = require("../ledger/account");
|
|
36
|
+
function parseAmmBid(tx) {
|
|
37
|
+
assert.ok(tx.TransactionType === "AMMBid");
|
|
38
|
+
const source = (0, common_1.removeUndefined)({
|
|
39
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
40
|
+
tag: tx.SourceTag,
|
|
41
|
+
});
|
|
42
|
+
return (0, common_1.removeUndefined)({
|
|
43
|
+
source: Object.keys(source).length > 0 ? source : undefined,
|
|
44
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
45
|
+
asset: (0, asset_1.default)(tx.Asset),
|
|
46
|
+
asset2: (0, asset_1.default)(tx.Asset2),
|
|
47
|
+
bidMin: tx.BidMin ? (0, amount_1.default)(tx.BidMin) : undefined,
|
|
48
|
+
bidMax: tx.BidMax ? (0, amount_1.default)(tx.BidMax) : undefined,
|
|
49
|
+
authAccounts: (0, auth_accounts_1.default)(tx.AuthAccounts),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.default = parseAmmBid;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
32
|
+
const memos_1 = require("../ledger/memos");
|
|
33
|
+
const account_1 = require("../ledger/account");
|
|
34
|
+
function parseAmmCreate(tx) {
|
|
35
|
+
assert.ok(tx.TransactionType === "AMMCreate");
|
|
36
|
+
const source = (0, common_1.removeUndefined)({
|
|
37
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
38
|
+
tag: tx.SourceTag,
|
|
39
|
+
});
|
|
40
|
+
return (0, common_1.removeUndefined)({
|
|
41
|
+
source: Object.keys(source).length > 0 ? source : undefined,
|
|
42
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
43
|
+
amount: (0, amount_1.default)(tx.Amount),
|
|
44
|
+
amount2: (0, amount_1.default)(tx.Amount2),
|
|
45
|
+
tradingFee: tx.TradingFee,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
exports.default = parseAmmCreate;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
32
|
+
const memos_1 = require("../ledger/memos");
|
|
33
|
+
const account_1 = require("../ledger/account");
|
|
34
|
+
function parseAmmDelete(tx) {
|
|
35
|
+
assert.ok(tx.TransactionType === "AMMDelete");
|
|
36
|
+
const source = (0, common_1.removeUndefined)({
|
|
37
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
38
|
+
tag: tx.SourceTag,
|
|
39
|
+
});
|
|
40
|
+
return (0, common_1.removeUndefined)({
|
|
41
|
+
source: Object.keys(source).length > 0 ? source : undefined,
|
|
42
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
43
|
+
asset: (0, asset_1.default)(tx.Asset),
|
|
44
|
+
asset2: (0, asset_1.default)(tx.Asset2),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.default = parseAmmDelete;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
32
|
+
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
33
|
+
const memos_1 = require("../ledger/memos");
|
|
34
|
+
const account_1 = require("../ledger/account");
|
|
35
|
+
const amm_deposit_flags_1 = __importDefault(require("../ledger/amm-deposit-flags"));
|
|
36
|
+
function parseAmmDeposit(tx) {
|
|
37
|
+
assert.ok(tx.TransactionType === "AMMDeposit");
|
|
38
|
+
const source = (0, common_1.removeUndefined)({
|
|
39
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
40
|
+
tag: tx.SourceTag,
|
|
41
|
+
});
|
|
42
|
+
return (0, common_1.removeUndefined)({
|
|
43
|
+
source: Object.keys(source).length > 0 ? source : undefined,
|
|
44
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
45
|
+
asset: (0, asset_1.default)(tx.Asset),
|
|
46
|
+
asset2: (0, asset_1.default)(tx.Asset2),
|
|
47
|
+
amount: tx.Amount ? (0, amount_1.default)(tx.Amount) : undefined,
|
|
48
|
+
amount2: tx.Amount2 ? (0, amount_1.default)(tx.Amount2) : undefined,
|
|
49
|
+
ePrice: tx.EPrice ? (0, amount_1.default)(tx.EPrice) : undefined,
|
|
50
|
+
lpTokenOut: tx.LPTokenOut ? (0, amount_1.default)(tx.LPTokenOut) : undefined,
|
|
51
|
+
flags: (0, amm_deposit_flags_1.default)(tx.Flags),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.default = parseAmmDeposit;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
32
|
+
const memos_1 = require("../ledger/memos");
|
|
33
|
+
const account_1 = require("../ledger/account");
|
|
34
|
+
function parseAmmVote(tx) {
|
|
35
|
+
assert.ok(tx.TransactionType === "AMMVote");
|
|
36
|
+
const source = (0, common_1.removeUndefined)({
|
|
37
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
38
|
+
tag: tx.SourceTag,
|
|
39
|
+
});
|
|
40
|
+
return (0, common_1.removeUndefined)({
|
|
41
|
+
source: Object.keys(source).length > 0 ? source : undefined,
|
|
42
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
43
|
+
asset: (0, asset_1.default)(tx.Asset),
|
|
44
|
+
asset2: (0, asset_1.default)(tx.Asset2),
|
|
45
|
+
tradingFee: tx.TradingFee,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
exports.default = parseAmmVote;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
32
|
+
const asset_1 = __importDefault(require("../ledger/asset"));
|
|
33
|
+
const memos_1 = require("../ledger/memos");
|
|
34
|
+
const account_1 = require("../ledger/account");
|
|
35
|
+
const amm_withdraw_flags_1 = __importDefault(require("../ledger/amm-withdraw-flags"));
|
|
36
|
+
function parseAmmDeposit(tx) {
|
|
37
|
+
assert.ok(tx.TransactionType === "AMMWithdraw");
|
|
38
|
+
const source = (0, common_1.removeUndefined)({
|
|
39
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
40
|
+
tag: tx.SourceTag,
|
|
41
|
+
});
|
|
42
|
+
return (0, common_1.removeUndefined)({
|
|
43
|
+
source: Object.keys(source).length > 0 ? source : undefined,
|
|
44
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
45
|
+
asset: (0, asset_1.default)(tx.Asset),
|
|
46
|
+
asset2: (0, asset_1.default)(tx.Asset2),
|
|
47
|
+
amount: tx.Amount ? (0, amount_1.default)(tx.Amount) : undefined,
|
|
48
|
+
amount2: tx.Amount2 ? (0, amount_1.default)(tx.Amount2) : undefined,
|
|
49
|
+
ePrice: tx.EPrice ? (0, amount_1.default)(tx.EPrice) : undefined,
|
|
50
|
+
lpTokenIn: tx.LPTokenOut ? (0, amount_1.default)(tx.LPTokenIn) : undefined,
|
|
51
|
+
flags: (0, amm_withdraw_flags_1.default)(tx.Flags),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.default = parseAmmDeposit;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
32
|
+
const memos_1 = require("../ledger/memos");
|
|
33
|
+
const account_1 = require("../ledger/account");
|
|
34
|
+
function parseClawback(tx) {
|
|
35
|
+
assert.ok(tx.TransactionType === "Clawback");
|
|
36
|
+
const source = (0, common_1.removeUndefined)({
|
|
37
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
38
|
+
tag: tx.SourceTag,
|
|
39
|
+
});
|
|
40
|
+
return (0, common_1.removeUndefined)({
|
|
41
|
+
source: Object.keys(source).length > 0 ? source : undefined,
|
|
42
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
43
|
+
amount: tx.Amount ? (0, amount_1.default)(tx.Amount) : undefined,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.default = parseClawback;
|
|
@@ -16,10 +16,12 @@ import { FormattedImportSpecification } from "../types/import";
|
|
|
16
16
|
import { FormattedInvokeSpecification } from "../types/invoke";
|
|
17
17
|
import { FormattedUNLReportSpecification } from "../types/unl_reports";
|
|
18
18
|
import { FormattedRemitsSpecification } from "../types/remits";
|
|
19
|
+
import { FormattedClawbackSpecification } from "../types/clawback";
|
|
20
|
+
import { FormattedAmmBidSpecification, FormattedAmmCreateSpecification, FormattedAmmDeleteSpecification, FormattedAmmDepositSpecification, FormattedAmmWithdrawSpecification, FormattedAmmVoteSpecification } from "../types/amm";
|
|
19
21
|
import { FormattedAmendmentSpecification } from "../types/amendments";
|
|
20
22
|
import { FormattedFeeUpdateSpecification } from "../types/fees";
|
|
21
23
|
declare function parseTransactionType(type: string): string;
|
|
22
|
-
export type FormattedSpecification = FormattedSettingsSpecification | FormattedAccountDeleteSpecification | FormattedCheckCancelSpecification | FormattedCheckCashSpecification | FormattedCheckCreateSpecification | FormattedDepositPreauthSpecification | FormattedEscrowCancelSpecification | FormattedEscrowCreateSpecification | FormattedEscrowFinishSpecification | FormattedOfferCancelSpecification | FormattedOfferCreateSpecification | FormattedPaymentSpecification | FormattedPaymentChannelClaimSpecification | FormattedPaymentChannelCreateSpecification | FormattedPaymentChannelFundSpecification | FormattedTicketCreateSpecification | FormattedTrustlineSpecification | FormattedNFTokenBurnSpecification | FormattedNFTokenMintSpecification | FormattedNFTokenCancelOfferSpecification | FormattedNFTokenCreateOfferSpecification | FormattedNFTokenAcceptOfferSpecification | FormattedURITokenBurnSpecification | FormattedURITokenBuySpecification | FormattedURITokenCreateSellOfferSpecification | FormattedURITokenCancelSellOfferSpecification | FormattedURITokenMintSpecification | FormattedImportSpecification | FormattedInvokeSpecification | FormattedUNLReportSpecification | FormattedRemitsSpecification | FormattedAmendmentSpecification | FormattedFeeUpdateSpecification;
|
|
24
|
+
export type FormattedSpecification = FormattedSettingsSpecification | FormattedAccountDeleteSpecification | FormattedCheckCancelSpecification | FormattedCheckCashSpecification | FormattedCheckCreateSpecification | FormattedDepositPreauthSpecification | FormattedEscrowCancelSpecification | FormattedEscrowCreateSpecification | FormattedEscrowFinishSpecification | FormattedOfferCancelSpecification | FormattedOfferCreateSpecification | FormattedPaymentSpecification | FormattedPaymentChannelClaimSpecification | FormattedPaymentChannelCreateSpecification | FormattedPaymentChannelFundSpecification | FormattedTicketCreateSpecification | FormattedTrustlineSpecification | FormattedNFTokenBurnSpecification | FormattedNFTokenMintSpecification | FormattedNFTokenCancelOfferSpecification | FormattedNFTokenCreateOfferSpecification | FormattedNFTokenAcceptOfferSpecification | FormattedURITokenBurnSpecification | FormattedURITokenBuySpecification | FormattedURITokenCreateSellOfferSpecification | FormattedURITokenCancelSellOfferSpecification | FormattedURITokenMintSpecification | FormattedImportSpecification | FormattedInvokeSpecification | FormattedUNLReportSpecification | FormattedRemitsSpecification | FormattedClawbackSpecification | FormattedAmmBidSpecification | FormattedAmmCreateSpecification | FormattedAmmDeleteSpecification | FormattedAmmDepositSpecification | FormattedAmmWithdrawSpecification | FormattedAmmVoteSpecification | FormattedAmendmentSpecification | FormattedFeeUpdateSpecification;
|
|
23
25
|
export interface FormattedTransaction {
|
|
24
26
|
type: string;
|
|
25
27
|
address: string;
|
package/lib/parse/transaction.js
CHANGED
|
@@ -38,6 +38,13 @@ const import_1 = __importDefault(require("./specification/import"));
|
|
|
38
38
|
const invoke_1 = __importDefault(require("./specification/invoke"));
|
|
39
39
|
const unl_report_1 = __importDefault(require("./specification/unl-report"));
|
|
40
40
|
const remit_1 = __importDefault(require("./specification/remit"));
|
|
41
|
+
const clawback_1 = __importDefault(require("./specification/clawback"));
|
|
42
|
+
const amm_bid_1 = __importDefault(require("./specification/amm-bid"));
|
|
43
|
+
const amm_create_1 = __importDefault(require("./specification/amm-create"));
|
|
44
|
+
const amm_delete_1 = __importDefault(require("./specification/amm-delete"));
|
|
45
|
+
const amm_deposit_1 = __importDefault(require("./specification/amm-deposit"));
|
|
46
|
+
const amm_withdraw_1 = __importDefault(require("./specification/amm-withdraw"));
|
|
47
|
+
const amm_vote_1 = __importDefault(require("./specification/amm-vote"));
|
|
41
48
|
const amendment_1 = __importDefault(require("./specification/amendment"));
|
|
42
49
|
const fee_update_1 = __importDefault(require("./specification/fee-update"));
|
|
43
50
|
const transactionTypeToType = {
|
|
@@ -74,6 +81,13 @@ const transactionTypeToType = {
|
|
|
74
81
|
Invoke: "invoke",
|
|
75
82
|
UNLReport: "unlReport",
|
|
76
83
|
Remit: "remit",
|
|
84
|
+
Clawback: "clawback",
|
|
85
|
+
AMMBid: "ammBid",
|
|
86
|
+
AMMCreate: "ammCreate",
|
|
87
|
+
AMMDelete: "ammDelete",
|
|
88
|
+
AMMDeposit: "ammDeposit",
|
|
89
|
+
AMMWithdraw: "ammWithdraw",
|
|
90
|
+
AMMVote: "ammVote",
|
|
77
91
|
EnableAmendment: "amendment",
|
|
78
92
|
SetFee: "feeUpdate",
|
|
79
93
|
};
|
|
@@ -113,18 +127,26 @@ const parserTypeFunc = {
|
|
|
113
127
|
invoke: invoke_1.default,
|
|
114
128
|
unlReport: unl_report_1.default,
|
|
115
129
|
remit: remit_1.default,
|
|
130
|
+
clawback: clawback_1.default,
|
|
131
|
+
ammBid: amm_bid_1.default,
|
|
132
|
+
ammCreate: amm_create_1.default,
|
|
133
|
+
ammDelete: amm_delete_1.default,
|
|
134
|
+
ammDeposit: amm_deposit_1.default,
|
|
135
|
+
ammWithdraw: amm_withdraw_1.default,
|
|
136
|
+
ammVote: amm_vote_1.default,
|
|
116
137
|
amendment: amendment_1.default,
|
|
117
138
|
feeUpdate: fee_update_1.default,
|
|
118
139
|
};
|
|
140
|
+
function unrecognizedParser(_tx) {
|
|
141
|
+
return {
|
|
142
|
+
UNAVAILABLE: "Unrecognized transaction type.",
|
|
143
|
+
SEE_RAW_TRANSACTION: "Since this type is unrecognized, `rawTransaction` is included in this response.",
|
|
144
|
+
};
|
|
145
|
+
}
|
|
119
146
|
function parseTransaction(tx, includeRawTransaction, nativeCurrency, definitions) {
|
|
120
147
|
const type = parseTransactionType(tx.TransactionType);
|
|
121
148
|
const parser = parserTypeFunc[type];
|
|
122
|
-
const specification = parser
|
|
123
|
-
? parser(tx)
|
|
124
|
-
: {
|
|
125
|
-
UNAVAILABLE: "Unrecognized transaction type.",
|
|
126
|
-
SEE_RAW_TRANSACTION: "Since this type is unrecognized, `rawTransaction` is included in this response.",
|
|
127
|
-
};
|
|
149
|
+
const specification = parser ? parser(tx) : unrecognizedParser(tx);
|
|
128
150
|
if (!parser) {
|
|
129
151
|
includeRawTransaction = true;
|
|
130
152
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AMMDepositFlags, AMMWithdrawFlags } from "xrpl";
|
|
2
|
+
import { FormattedBaseSpecification } from "./specification";
|
|
3
|
+
import { FormattedAmount, FormattedIssuedCurrency } from "./amounts";
|
|
4
|
+
export interface VoteSlotInterface {
|
|
5
|
+
VoteEntry: {
|
|
6
|
+
Account: string;
|
|
7
|
+
TradingFee: number;
|
|
8
|
+
VoteWeight: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare const AMMDepositFlagsKeys: {
|
|
12
|
+
lpToken: AMMDepositFlags;
|
|
13
|
+
singleAsset: AMMDepositFlags;
|
|
14
|
+
twoAsset: AMMDepositFlags;
|
|
15
|
+
oneAssetLPToken: AMMDepositFlags;
|
|
16
|
+
limitLPToken: AMMDepositFlags;
|
|
17
|
+
};
|
|
18
|
+
export interface AMMDepositFlagsKeysInterface {
|
|
19
|
+
lpToken?: boolean;
|
|
20
|
+
singleAsset?: boolean;
|
|
21
|
+
twoAsset?: boolean;
|
|
22
|
+
oneAssetLPToken?: boolean;
|
|
23
|
+
limitLPToken?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const AMMWithdrawFlagsKeys: {
|
|
26
|
+
lpToken: AMMWithdrawFlags;
|
|
27
|
+
withdrawAll: AMMWithdrawFlags;
|
|
28
|
+
oneAssetWithdrawAll: AMMWithdrawFlags;
|
|
29
|
+
singleAsset: AMMWithdrawFlags;
|
|
30
|
+
twoAsset: AMMWithdrawFlags;
|
|
31
|
+
oneAssetLPToken: AMMWithdrawFlags;
|
|
32
|
+
limitLPToken: AMMWithdrawFlags;
|
|
33
|
+
};
|
|
34
|
+
export interface AMMWithdrawFlagsKeysInterface {
|
|
35
|
+
lpToken?: boolean;
|
|
36
|
+
withdrawAll?: boolean;
|
|
37
|
+
oneAssetWithdrawAll?: boolean;
|
|
38
|
+
singleAsset?: boolean;
|
|
39
|
+
twoAsset?: boolean;
|
|
40
|
+
oneAssetLPToken?: boolean;
|
|
41
|
+
limitLPToken?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export type FormattedAmmBidSpecification = {
|
|
44
|
+
asset?: FormattedIssuedCurrency;
|
|
45
|
+
asset2?: FormattedIssuedCurrency;
|
|
46
|
+
bidMin?: FormattedAmount;
|
|
47
|
+
bidMax?: FormattedAmount;
|
|
48
|
+
authorizedAccounts?: string[];
|
|
49
|
+
} & FormattedBaseSpecification;
|
|
50
|
+
export type FormattedAmmCreateSpecification = {
|
|
51
|
+
amount: FormattedAmount;
|
|
52
|
+
amount2: FormattedAmount;
|
|
53
|
+
tradingFee: Number;
|
|
54
|
+
} & FormattedBaseSpecification;
|
|
55
|
+
export type FormattedAmmDeleteSpecification = {
|
|
56
|
+
asset?: FormattedIssuedCurrency;
|
|
57
|
+
asset2?: FormattedIssuedCurrency;
|
|
58
|
+
} & FormattedBaseSpecification;
|
|
59
|
+
export type FormattedAmmDepositSpecification = {
|
|
60
|
+
asset?: FormattedIssuedCurrency;
|
|
61
|
+
asset2?: FormattedIssuedCurrency;
|
|
62
|
+
amount?: FormattedAmount;
|
|
63
|
+
amount2?: FormattedAmount;
|
|
64
|
+
ePrice?: FormattedAmount;
|
|
65
|
+
lpTokenOut?: FormattedAmount;
|
|
66
|
+
flags?: AMMDepositFlagsKeysInterface;
|
|
67
|
+
} & FormattedBaseSpecification;
|
|
68
|
+
export type FormattedAmmWithdrawSpecification = {
|
|
69
|
+
asset?: FormattedIssuedCurrency;
|
|
70
|
+
asset2?: FormattedIssuedCurrency;
|
|
71
|
+
amount?: FormattedAmount;
|
|
72
|
+
amount2?: FormattedAmount;
|
|
73
|
+
ePrice?: FormattedAmount;
|
|
74
|
+
lpTokenIn?: FormattedAmount;
|
|
75
|
+
flags?: AMMWithdrawFlagsKeysInterface;
|
|
76
|
+
} & FormattedBaseSpecification;
|
|
77
|
+
export type FormattedAmmVoteSpecification = {
|
|
78
|
+
asset?: FormattedIssuedCurrency;
|
|
79
|
+
asset2?: FormattedIssuedCurrency;
|
|
80
|
+
tradingFee: Number;
|
|
81
|
+
} & FormattedBaseSpecification;
|
package/lib/types/amm.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AMMWithdrawFlagsKeys = exports.AMMDepositFlagsKeys = void 0;
|
|
4
|
+
const xrpl_1 = require("xrpl");
|
|
5
|
+
exports.AMMDepositFlagsKeys = {
|
|
6
|
+
lpToken: xrpl_1.AMMDepositFlags.tfLPToken,
|
|
7
|
+
singleAsset: xrpl_1.AMMDepositFlags.tfSingleAsset,
|
|
8
|
+
twoAsset: xrpl_1.AMMDepositFlags.tfTwoAsset,
|
|
9
|
+
oneAssetLPToken: xrpl_1.AMMDepositFlags.tfOneAssetLPToken,
|
|
10
|
+
limitLPToken: xrpl_1.AMMDepositFlags.tfLimitLPToken,
|
|
11
|
+
};
|
|
12
|
+
exports.AMMWithdrawFlagsKeys = {
|
|
13
|
+
lpToken: xrpl_1.AMMWithdrawFlags.tfLPToken,
|
|
14
|
+
withdrawAll: xrpl_1.AMMWithdrawFlags.tfWithdrawAll,
|
|
15
|
+
oneAssetWithdrawAll: xrpl_1.AMMWithdrawFlags.tfOneAssetWithdrawAll,
|
|
16
|
+
singleAsset: xrpl_1.AMMWithdrawFlags.tfSingleAsset,
|
|
17
|
+
twoAsset: xrpl_1.AMMWithdrawFlags.tfTwoAsset,
|
|
18
|
+
oneAssetLPToken: xrpl_1.AMMWithdrawFlags.tfOneAssetLPToken,
|
|
19
|
+
limitLPToken: xrpl_1.AMMWithdrawFlags.tfLimitLPToken,
|
|
20
|
+
};
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
package/lib/types/outcome.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
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",
|
|
@@ -48,27 +48,27 @@
|
|
|
48
48
|
"lib/**/*"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"axios": "^1.6.
|
|
51
|
+
"axios": "^1.6.8",
|
|
52
52
|
"base-x": "^4.0.0",
|
|
53
53
|
"bignumber.js": "^9.1.2",
|
|
54
|
-
"elliptic": "^6.5.
|
|
54
|
+
"elliptic": "^6.5.5",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
56
|
"ripple-address-codec": "^5.0.0",
|
|
57
57
|
"ripple-binary-codec": "^2.0.0",
|
|
58
58
|
"xrpl": "^3.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@types/chai": "^4.3.
|
|
61
|
+
"@types/chai": "^4.3.14",
|
|
62
62
|
"@types/chai-as-promised": "^7.1.8",
|
|
63
|
-
"@types/lodash": "^4.
|
|
63
|
+
"@types/lodash": "^4.17.0",
|
|
64
64
|
"@types/mocha": "^10.0.6",
|
|
65
65
|
"@types/nconf": "^0.10.6",
|
|
66
|
-
"@types/node": "^20.11.
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
68
|
-
"@typescript-eslint/parser": "^7.
|
|
66
|
+
"@types/node": "^20.11.30",
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
68
|
+
"@typescript-eslint/parser": "^7.3.1",
|
|
69
69
|
"chai": "^4.4.1",
|
|
70
70
|
"chai-as-promised": "^7.1.1",
|
|
71
|
-
"eslint": "^8.
|
|
71
|
+
"eslint": "^8.57.0",
|
|
72
72
|
"eslint-config-prettier": "^9.1.0",
|
|
73
73
|
"eslint-plugin-chai-friendly": "^0.7.4",
|
|
74
74
|
"eslint-plugin-import": "^2.29.1",
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
"nconf": "^0.12.1",
|
|
79
79
|
"ts-jest": "^29.1.2",
|
|
80
80
|
"ts-node": "^10.9.2",
|
|
81
|
-
"typescript": "^5.
|
|
81
|
+
"typescript": "^5.4.3"
|
|
82
82
|
}
|
|
83
83
|
}
|