@bithomp/xrpl-api 3.0.0 → 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.
Files changed (43) hide show
  1. package/lib/ledger/transaction.js +1 -1
  2. package/lib/parse/ledger/amm-deposit-flags.d.ts +5 -0
  3. package/lib/parse/ledger/amm-deposit-flags.js +8 -0
  4. package/lib/parse/ledger/amm-withdraw-flags.d.ts +5 -0
  5. package/lib/parse/ledger/amm-withdraw-flags.js +8 -0
  6. package/lib/parse/ledger/asset.d.ts +3 -0
  7. package/lib/parse/ledger/asset.js +18 -0
  8. package/lib/parse/ledger/auth-accounts.d.ts +3 -0
  9. package/lib/parse/ledger/auth-accounts.js +18 -0
  10. package/lib/parse/outcome/amm_changes.d.ts +51 -0
  11. package/lib/parse/outcome/amm_changes.js +205 -0
  12. package/lib/parse/outcome/index.d.ts +1 -0
  13. package/lib/parse/outcome/index.js +3 -1
  14. package/lib/parse/outcome.js +2 -0
  15. package/lib/parse/specification/amm-bid.d.ts +3 -0
  16. package/lib/parse/specification/amm-bid.js +52 -0
  17. package/lib/parse/specification/amm-create.d.ts +3 -0
  18. package/lib/parse/specification/amm-create.js +48 -0
  19. package/lib/parse/specification/amm-delete.d.ts +3 -0
  20. package/lib/parse/specification/amm-delete.js +47 -0
  21. package/lib/parse/specification/amm-deposit.d.ts +3 -0
  22. package/lib/parse/specification/amm-deposit.js +54 -0
  23. package/lib/parse/specification/amm-vote.d.ts +3 -0
  24. package/lib/parse/specification/amm-vote.js +48 -0
  25. package/lib/parse/specification/amm-withdraw.d.ts +3 -0
  26. package/lib/parse/specification/amm-withdraw.js +54 -0
  27. package/lib/parse/specification/clawback.d.ts +3 -0
  28. package/lib/parse/specification/clawback.js +46 -0
  29. package/lib/parse/transaction.d.ts +3 -1
  30. package/lib/parse/transaction.js +28 -6
  31. package/lib/parse/utils.d.ts +2 -1
  32. package/lib/parse/utils.js +14 -1
  33. package/lib/types/amm.d.ts +81 -0
  34. package/lib/types/amm.js +20 -0
  35. package/lib/types/clawback.d.ts +5 -0
  36. package/lib/types/clawback.js +2 -0
  37. package/lib/types/index.d.ts +1 -0
  38. package/lib/types/index.js +1 -0
  39. package/lib/types/outcome.d.ts +1 -0
  40. package/lib/types/specification.d.ts +2 -0
  41. package/lib/wallet.d.ts +8 -2
  42. package/lib/wallet.js +22 -5
  43. package/package.json +10 -10
@@ -196,7 +196,7 @@ async function submitPaymentTransactionV1(data, definitions, validateTx) {
196
196
  }
197
197
  transaction.Sequence = submitParams.sequence;
198
198
  transaction.LastLedgerSequence = submitParams.lastLedgerSequence;
199
- const wallet = (0, wallet_1.walletFromSeed)(data.secret);
199
+ const wallet = (0, wallet_1.walletFromSeed)(data.secret, { seedAddress: transaction.Account });
200
200
  const signedTransaction = (0, wallet_1.signTransaction)(wallet, transaction, false, definitions, validateTx).tx_blob;
201
201
  return await submit(signedTransaction, { connection, definitions });
202
202
  }
@@ -0,0 +1,5 @@
1
+ import { AMMDepositFlagsKeysInterface } from "../../types/amm";
2
+ declare function parseAmmDepositFlags(value: number, options?: {
3
+ excludeFalse?: boolean;
4
+ }): AMMDepositFlagsKeysInterface;
5
+ export 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 parseAmmDepositFlags(value, options = {}) {
6
+ return (0, flags_1.parseFlags)(value, amm_1.AMMDepositFlagsKeys, options);
7
+ }
8
+ exports.default = parseAmmDepositFlags;
@@ -0,0 +1,5 @@
1
+ import { AMMDepositFlagsKeysInterface } from "../../types/amm";
2
+ declare function parseAmmWithdrawFlags(value: number, options?: {
3
+ excludeFalse?: boolean;
4
+ }): AMMDepositFlagsKeysInterface;
5
+ export default parseAmmWithdrawFlags;
@@ -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,3 @@
1
+ import { FormattedIssuedCurrency, IssuedCurrency } from "../../types";
2
+ declare function parseAsset(asset: IssuedCurrency): FormattedIssuedCurrency | undefined;
3
+ export default parseAsset;
@@ -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,3 @@
1
+ import { AuthAccount } from "xrpl";
2
+ declare function parseAuthAccounts(authAccounts?: AuthAccount[]): string[] | undefined;
3
+ export default parseAuthAccounts;
@@ -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; } });
@@ -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,3 @@
1
+ import { FormattedAmmBidSpecification } from "../../types/amm";
2
+ declare function parseAmmBid(tx: any): FormattedAmmBidSpecification;
3
+ export default parseAmmBid;
@@ -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,3 @@
1
+ import { FormattedAmmCreateSpecification } from "../../types/amm";
2
+ declare function parseAmmCreate(tx: any): FormattedAmmCreateSpecification;
3
+ export default parseAmmCreate;
@@ -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,3 @@
1
+ import { FormattedAmmDeleteSpecification } from "../../types/amm";
2
+ declare function parseAmmDelete(tx: any): FormattedAmmDeleteSpecification;
3
+ export default parseAmmDelete;
@@ -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,3 @@
1
+ import { FormattedAmmDepositSpecification } from "../../types/amm";
2
+ declare function parseAmmDeposit(tx: any): FormattedAmmDepositSpecification;
3
+ export default parseAmmDeposit;
@@ -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,3 @@
1
+ import { FormattedAmmVoteSpecification } from "../../types/amm";
2
+ declare function parseAmmVote(tx: any): FormattedAmmVoteSpecification;
3
+ export default parseAmmVote;
@@ -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,3 @@
1
+ import { FormattedAmmWithdrawSpecification } from "../../types/amm";
2
+ declare function parseAmmDeposit(tx: any): FormattedAmmWithdrawSpecification;
3
+ export default parseAmmDeposit;
@@ -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,3 @@
1
+ import { FormattedClawbackSpecification } from "../../types/clawback";
2
+ declare function parseClawback(tx: any): FormattedClawbackSpecification;
3
+ export default parseClawback;
@@ -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;
@@ -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
  }
@@ -10,6 +10,7 @@ declare function normalizeNodes(metadata: TransactionMetadata): any[];
10
10
  declare function hexToString(hex: string | undefined): string | undefined;
11
11
  declare function stringToHex(value: string | undefined): string | undefined;
12
12
  declare function bytesToHex(value: Uint8Array | ArrayBufferLike): string;
13
+ declare function hexToBytes(value: string): Uint8Array;
13
14
  declare function parseUint32(buf: Buffer, cur: number): string;
14
15
  declare function parseUint64(buf: Buffer, cur: number): string;
15
- export { parseQuality, parseTimestamp, adjustQualityForXRP, isPartialPayment, removeGenericCounterparty, normalizeNodes, hexToString, stringToHex, bytesToHex, parseUint32, parseUint64, };
16
+ export { parseQuality, parseTimestamp, adjustQualityForXRP, isPartialPayment, removeGenericCounterparty, normalizeNodes, hexToString, stringToHex, bytesToHex, hexToBytes, parseUint32, parseUint64, };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseUint64 = exports.parseUint32 = exports.bytesToHex = exports.stringToHex = exports.hexToString = exports.normalizeNodes = exports.removeGenericCounterparty = exports.isPartialPayment = exports.adjustQualityForXRP = exports.parseTimestamp = exports.parseQuality = void 0;
6
+ exports.parseUint64 = exports.parseUint32 = exports.hexToBytes = exports.bytesToHex = exports.stringToHex = exports.hexToString = exports.normalizeNodes = exports.removeGenericCounterparty = exports.isPartialPayment = exports.adjustQualityForXRP = exports.parseTimestamp = exports.parseQuality = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
9
  const xrpl_1 = require("xrpl");
@@ -69,6 +69,19 @@ function bytesToHex(value) {
69
69
  return Buffer.from(value).toString("hex").toUpperCase();
70
70
  }
71
71
  exports.bytesToHex = bytesToHex;
72
+ function hexToBytes(value) {
73
+ if (value.length % 2 !== 0) {
74
+ throw new Error("Invalid hex string length");
75
+ }
76
+ if (!/^[0-9a-fA-F]*$/.test(value)) {
77
+ throw new Error("Invalid hex string");
78
+ }
79
+ if (value.length === 0) {
80
+ return new Uint8Array(0);
81
+ }
82
+ return Uint8Array.from(Buffer.from(value, "hex"));
83
+ }
84
+ exports.hexToBytes = hexToBytes;
72
85
  function parseUint32(buf, cur) {
73
86
  return ((BigInt(buf[cur]) << 24n) + (BigInt(buf[cur + 1]) << 16n) + (BigInt(buf[cur + 2]) << 8n) + BigInt(buf[cur + 3]) + "");
74
87
  }
@@ -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;
@@ -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
+ };
@@ -0,0 +1,5 @@
1
+ import { FormattedBaseSpecification } from "./specification";
2
+ import { FormattedAmount } from "./amounts";
3
+ export type FormattedClawbackSpecification = {
4
+ amount?: FormattedAmount;
5
+ } & FormattedBaseSpecification;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -22,3 +22,4 @@ export * from "./invoke";
22
22
  export * from "./unl_reports";
23
23
  export * from "./remits";
24
24
  export * from "./hooks";
25
+ export * from "./amm";
@@ -38,3 +38,4 @@ __exportStar(require("./invoke"), exports);
38
38
  __exportStar(require("./unl_reports"), exports);
39
39
  __exportStar(require("./remits"), exports);
40
40
  __exportStar(require("./hooks"), exports);
41
+ __exportStar(require("./amm"), exports);
@@ -24,6 +24,7 @@ export type Outcome = {
24
24
  uritokenChanges?: object;
25
25
  uritokenSellOfferChanges?: object;
26
26
  affectedObjects?: object;
27
+ ammChanges?: object;
27
28
  deliveredAmount?: {
28
29
  currency: string;
29
30
  counterparty?: string;
@@ -1,4 +1,6 @@
1
+ import { FormattedSourceAddress } from "./account";
1
2
  import { FormattedMemo } from "./memos";
2
3
  export type FormattedBaseSpecification = {
4
+ source?: FormattedSourceAddress;
3
5
  memos?: FormattedMemo[];
4
6
  };
package/lib/wallet.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Wallet, Transaction } from "xrpl";
2
+ import { Wallet, Transaction, ECDSA } from "xrpl";
3
3
  import { XrplDefinitionsBase, XrplDefinitions, DEFAULT_DEFINITIONS } from "ripple-binary-codec";
4
4
  interface GenerateAddressInterface {
5
5
  publicKey: string;
@@ -8,7 +8,13 @@ interface GenerateAddressInterface {
8
8
  seed: string;
9
9
  }
10
10
  export declare function isValidSecret(secret: string): boolean;
11
- export declare function walletFromSeed(seed: string): Wallet;
11
+ export interface WalletFromSeedInterface {
12
+ masterAddress?: string;
13
+ algorithm?: ECDSA;
14
+ seedAddress?: string;
15
+ ignoreSeedPayload?: boolean;
16
+ }
17
+ export declare function walletFromSeed(seed: string, options?: WalletFromSeedInterface): Wallet;
12
18
  export declare function generateAddress(): GenerateAddressInterface;
13
19
  export declare function isValidClassicAddress(address: string): boolean;
14
20
  export declare function checksumClassicAddress(buffer: Buffer): Buffer;
package/lib/wallet.js CHANGED
@@ -53,11 +53,28 @@ function isValidSecret(secret) {
53
53
  return false;
54
54
  }
55
55
  exports.isValidSecret = isValidSecret;
56
- function walletFromSeed(seed) {
57
- const decodedSeed = (0, ripple_address_codec_1.decodeSeed)(seed);
58
- const wallet = xrpl_1.Wallet.fromSeed(seed, {
59
- algorithm: decodedSeed.type === "ed25519" ? xrpl_1.ECDSA.ed25519 : xrpl_1.ECDSA.secp256k1,
60
- });
56
+ function walletFromSeed(seed, options) {
57
+ options = { ignoreSeedPayload: false, ...options };
58
+ let algorithm = options.algorithm;
59
+ if (!options.ignoreSeedPayload && !options.algorithm) {
60
+ const decodedSeed = (0, ripple_address_codec_1.decodeSeed)(seed);
61
+ if (decodedSeed.type === "secp256k1") {
62
+ if (options.seedAddress) {
63
+ const { publicKey } = (0, ripple_keypairs_1.deriveKeypair)(seed, { algorithm: xrpl_1.ECDSA.secp256k1 });
64
+ const classicAddress = (0, ripple_keypairs_1.deriveAddress)(publicKey);
65
+ if (classicAddress === options.seedAddress) {
66
+ algorithm = xrpl_1.ECDSA.secp256k1;
67
+ }
68
+ else {
69
+ algorithm = xrpl_1.ECDSA.ed25519;
70
+ }
71
+ }
72
+ else {
73
+ algorithm = xrpl_1.ECDSA.secp256k1;
74
+ }
75
+ }
76
+ }
77
+ const wallet = xrpl_1.Wallet.fromSeed(seed, { algorithm, masterAddress: options.masterAddress });
61
78
  return wallet;
62
79
  }
63
80
  exports.walletFromSeed = walletFromSeed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.0.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.7",
51
+ "axios": "^1.6.8",
52
52
  "base-x": "^4.0.0",
53
53
  "bignumber.js": "^9.1.2",
54
- "elliptic": "^6.5.4",
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.11",
61
+ "@types/chai": "^4.3.14",
62
62
  "@types/chai-as-promised": "^7.1.8",
63
- "@types/lodash": "^4.14.202",
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.19",
67
- "@typescript-eslint/eslint-plugin": "^7.0.2",
68
- "@typescript-eslint/parser": "^7.0.2",
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.56.0",
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.3.3"
81
+ "typescript": "^5.4.3"
82
82
  }
83
83
  }