@bithomp/xrpl-api 2.7.11 → 2.7.14
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/common/utils.js +9 -9
- package/lib/ledger/fee.d.ts +3 -0
- package/lib/ledger/fee.js +15 -3
- package/lib/ledger/nft_info.d.ts +1 -1
- package/lib/ledger/nft_info.js +1 -1
- package/lib/ledger/transaction.d.ts +1 -0
- package/lib/ledger/transaction.js +108 -22
- package/lib/parse/ledger/memos.d.ts +1 -1
- package/lib/parse/outcome/balance_changes.d.ts +3 -2
- package/lib/parse/outcome/balance_changes.js +8 -8
- package/lib/parse/outcome/locked_balance_changes.d.ts +3 -2
- package/lib/parse/outcome/locked_balance_changes.js +12 -8
- package/lib/parse/outcome/orderbook_changes.js +21 -21
- package/lib/parse/outcome/orderbook_quality.js +6 -6
- package/lib/parse/specification/account-delete.js +0 -2
- package/lib/parse/specification/remit.d.ts +3 -0
- package/lib/parse/specification/remit.js +81 -0
- package/lib/parse/specification/unl-report.d.ts +3 -3
- package/lib/parse/specification/unl-report.js +2 -2
- package/lib/parse/transaction.d.ts +3 -2
- package/lib/parse/transaction.js +4 -0
- package/lib/v1/common/types/commands/account_objects.d.ts +1 -1
- package/lib/v1/common/types/commands/gateway_balances.d.ts +1 -1
- package/lib/v1/common/types/commands/path_find.d.ts +7 -7
- package/lib/v1/common/types/objects/account.d.ts +0 -1
- package/lib/v1/common/types/objects/hooks.d.ts +14 -0
- package/lib/v1/common/types/objects/hooks.js +2 -0
- package/lib/v1/common/types/objects/index.d.ts +3 -1
- package/lib/v1/common/types/objects/index.js +3 -1
- package/lib/v1/common/types/objects/ledger.d.ts +3 -3
- package/lib/v1/common/types/objects/path_find.d.ts +3 -3
- package/lib/v1/common/types/objects/remits.d.ts +18 -0
- package/lib/v1/common/types/objects/remits.js +2 -0
- package/lib/v1/common/types/objects/unl_reports.d.ts +7 -0
- package/lib/v1/common/types/objects/unl_reports.js +2 -0
- package/lib/v1/common/utils.d.ts +2 -1
- package/lib/validator.js +2 -3
- package/package.json +15 -12
package/lib/common/utils.js
CHANGED
|
@@ -67,18 +67,18 @@ exports.parseMarker = parseMarker;
|
|
|
67
67
|
function dropsToXrp(drops) {
|
|
68
68
|
if (typeof drops === "string") {
|
|
69
69
|
if (!drops.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
|
70
|
-
throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}'
|
|
70
|
+
throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}', should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
|
|
71
71
|
}
|
|
72
72
|
else if (drops === ".") {
|
|
73
|
-
throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}'
|
|
73
|
+
throw new errors_1.ValidationError(`dropsToXrp: invalid value '${drops}', should be a BigNumber or string-encoded number.`);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
drops = new bignumber_js_1.default(drops).toString(10);
|
|
77
77
|
if (drops.includes(".")) {
|
|
78
|
-
throw new errors_1.ValidationError(`dropsToXrp: value '${drops}' has
|
|
78
|
+
throw new errors_1.ValidationError(`dropsToXrp: value '${drops}' has too many decimal places.`);
|
|
79
79
|
}
|
|
80
80
|
if (!drops.match(/^-?[0-9]+$/)) {
|
|
81
|
-
throw new errors_1.ValidationError(`dropsToXrp: failed sanity check
|
|
81
|
+
throw new errors_1.ValidationError(`dropsToXrp: failed sanity check - value '${drops}', does not match (^-?[0-9]+$).`);
|
|
82
82
|
}
|
|
83
83
|
return new bignumber_js_1.default(drops).dividedBy(1000000.0).toString(10);
|
|
84
84
|
}
|
|
@@ -86,23 +86,23 @@ exports.dropsToXrp = dropsToXrp;
|
|
|
86
86
|
function xrpToDrops(xrp) {
|
|
87
87
|
if (typeof xrp === "string") {
|
|
88
88
|
if (!xrp.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
|
89
|
-
throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}'
|
|
89
|
+
throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}', should be a number matching (^-?[0-9]*\\.?[0-9]*$).`);
|
|
90
90
|
}
|
|
91
91
|
else if (xrp === ".") {
|
|
92
|
-
throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}'
|
|
92
|
+
throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrp}', should be a BigNumber or string-encoded number.`);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
xrp = new bignumber_js_1.default(xrp).toString(10);
|
|
96
96
|
if (!xrp.match(/^-?[0-9.]+$/)) {
|
|
97
|
-
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check
|
|
97
|
+
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}', does not match (^-?[0-9.]+$).`);
|
|
98
98
|
}
|
|
99
99
|
const components = xrp.split(".");
|
|
100
100
|
if (components.length > 2) {
|
|
101
|
-
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check
|
|
101
|
+
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}' has too many decimal points.`);
|
|
102
102
|
}
|
|
103
103
|
const fraction = components[1] || "0";
|
|
104
104
|
if (fraction.length > 6) {
|
|
105
|
-
throw new errors_1.ValidationError(`xrpToDrops: value '${xrp}' has
|
|
105
|
+
throw new errors_1.ValidationError(`xrpToDrops: value '${xrp}' has too many decimal places.`);
|
|
106
106
|
}
|
|
107
107
|
return new bignumber_js_1.default(xrp).times(1000000.0).integerValue(bignumber_js_1.default.ROUND_FLOOR).toString(10);
|
|
108
108
|
}
|
package/lib/ledger/fee.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { XrplDefinitionsBase } from "ripple-binary-codec";
|
|
1
2
|
import { Connection } from "../connection";
|
|
2
3
|
export interface GetFeeOptions {
|
|
3
4
|
connection?: Connection;
|
|
5
|
+
tx?: any;
|
|
6
|
+
definitions?: XrplDefinitionsBase;
|
|
4
7
|
}
|
|
5
8
|
export declare function getFee(options?: GetFeeOptions): Promise<string | null>;
|
package/lib/ledger/fee.js
CHANGED
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getFee = void 0;
|
|
27
27
|
const bignumber_js_1 = require("bignumber.js");
|
|
28
|
+
const ripple_binary_codec_1 = require("ripple-binary-codec");
|
|
28
29
|
const Client = __importStar(require("../client"));
|
|
29
30
|
const common_1 = require("../common");
|
|
30
31
|
async function getFee(options = {}) {
|
|
@@ -32,14 +33,25 @@ async function getFee(options = {}) {
|
|
|
32
33
|
if (!connection) {
|
|
33
34
|
throw new Error("There is no connection");
|
|
34
35
|
}
|
|
36
|
+
let txBlob;
|
|
37
|
+
if (typeof options.tx === "string") {
|
|
38
|
+
txBlob = options.tx;
|
|
39
|
+
}
|
|
40
|
+
else if (typeof options.tx === "object") {
|
|
41
|
+
txBlob = (0, ripple_binary_codec_1.encode)(options.tx, options.definitions);
|
|
42
|
+
}
|
|
35
43
|
const response = await connection.request({
|
|
36
44
|
command: "fee",
|
|
45
|
+
tx_blob: txBlob,
|
|
37
46
|
});
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
47
|
+
const openLedgerFee = response?.result?.drops?.open_ledger_fee;
|
|
48
|
+
if (!openLedgerFee) {
|
|
40
49
|
return null;
|
|
41
50
|
}
|
|
42
|
-
const fee = new bignumber_js_1.BigNumber(
|
|
51
|
+
const fee = new bignumber_js_1.BigNumber(openLedgerFee)
|
|
52
|
+
.multipliedBy(Client.feeCushion)
|
|
53
|
+
.dividedBy(common_1.dropsInXRP)
|
|
54
|
+
.decimalPlaces(6, bignumber_js_1.BigNumber.ROUND_UP);
|
|
43
55
|
return fee.toString();
|
|
44
56
|
}
|
|
45
57
|
exports.getFee = getFee;
|
package/lib/ledger/nft_info.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ErrorResponse } from "../models/base_model";
|
|
2
2
|
export interface GetNftInfoOptions {
|
|
3
3
|
}
|
|
4
|
-
export declare function getNftInfo(nft_id: string,
|
|
4
|
+
export declare function getNftInfo(nft_id: string, _options?: GetNftInfoOptions): Promise<object | ErrorResponse>;
|
package/lib/ledger/nft_info.js
CHANGED
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getNftInfo = void 0;
|
|
27
27
|
const Client = __importStar(require("../client"));
|
|
28
|
-
async function getNftInfo(nft_id,
|
|
28
|
+
async function getNftInfo(nft_id, _options = {}) {
|
|
29
29
|
const connection = Client.findConnection("clio", undefined, true);
|
|
30
30
|
if (!connection) {
|
|
31
31
|
throw new Error("There is no connection");
|
|
@@ -32,6 +32,7 @@ interface LegacyPaymentInterface {
|
|
|
32
32
|
}
|
|
33
33
|
export declare function legacyPayment(data: LegacyPaymentInterface, definitions?: XrplDefinitionsBase, validateTx?: boolean): Promise<TransactionResponse | FormattedTransaction | ErrorResponse>;
|
|
34
34
|
export declare function getAccountPaymentParams(account: string, connection?: Connection): Promise<AccountPaymentParamsInterface | ErrorResponse>;
|
|
35
|
+
export declare function getTxSubmitParams(account: string, tx?: string | any, definitions?: XrplDefinitionsBase, connection?: Connection): Promise<AccountPaymentParamsInterface | ErrorResponse>;
|
|
35
36
|
export interface SubmitOptionsInterface {
|
|
36
37
|
connection?: Connection;
|
|
37
38
|
definitions?: XrplDefinitionsBase;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.submit = exports.getAccountPaymentParams = exports.legacyPayment = exports.getTransactionByCTID = exports.getTransaction = void 0;
|
|
26
|
+
exports.submit = exports.getTxSubmitParams = exports.getAccountPaymentParams = exports.legacyPayment = exports.getTransactionByCTID = exports.getTransaction = void 0;
|
|
27
27
|
const xrpl = __importStar(require("xrpl"));
|
|
28
28
|
const ripple_binary_codec_1 = require("ripple-binary-codec");
|
|
29
29
|
const Client = __importStar(require("../client"));
|
|
@@ -184,18 +184,18 @@ async function legacyPayment(data, definitions, validateTx) {
|
|
|
184
184
|
memos: data.memos,
|
|
185
185
|
};
|
|
186
186
|
const transaction = (0, payment_1.createPaymentTransaction)(data.sourceAddress, txPayment);
|
|
187
|
-
const
|
|
188
|
-
if ("error" in
|
|
189
|
-
return
|
|
187
|
+
const submitParams = await getTxSubmitParams(data.sourceAddress, transaction, definitions, connection);
|
|
188
|
+
if ("error" in submitParams) {
|
|
189
|
+
return submitParams;
|
|
190
190
|
}
|
|
191
191
|
if (data.fee) {
|
|
192
192
|
transaction.Fee = (0, common_1.xrpToDrops)(data.fee);
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
195
|
-
transaction.Fee =
|
|
195
|
+
transaction.Fee = submitParams.fee;
|
|
196
196
|
}
|
|
197
|
-
transaction.Sequence =
|
|
198
|
-
transaction.LastLedgerSequence =
|
|
197
|
+
transaction.Sequence = submitParams.sequence;
|
|
198
|
+
transaction.LastLedgerSequence = submitParams.lastLedgerSequence;
|
|
199
199
|
const wallet = xrpl.Wallet.fromSeed(data.secret);
|
|
200
200
|
const signedTransaction = (0, wallet_1.signTransaction)(wallet, transaction, false, definitions, validateTx).tx_blob;
|
|
201
201
|
return await submit(signedTransaction, { connection, definitions });
|
|
@@ -213,24 +213,34 @@ async function getAccountPaymentParams(account, connection) {
|
|
|
213
213
|
if (fee > FEE_LIMIT) {
|
|
214
214
|
fee = FEE_LIMIT;
|
|
215
215
|
}
|
|
216
|
-
resolve((0, common_1.xrpToDrops)(fee));
|
|
216
|
+
resolve((0, common_1.xrpToDrops)(fee.toString()));
|
|
217
217
|
});
|
|
218
218
|
const sequencePromise = new Promise(async (resolve, rejects) => {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
try {
|
|
220
|
+
const accountData = await Client.getAccountInfoData(account, { connection });
|
|
221
|
+
if (!accountData) {
|
|
222
|
+
return rejects(new Error("Account not found"));
|
|
223
|
+
}
|
|
224
|
+
if ("error" in accountData) {
|
|
225
|
+
return rejects(new Error(accountData.error));
|
|
226
|
+
}
|
|
227
|
+
resolve(accountData.Sequence);
|
|
222
228
|
}
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
catch (e) {
|
|
230
|
+
rejects(e);
|
|
225
231
|
}
|
|
226
|
-
resolve(accountInfo?.account_data?.Sequence);
|
|
227
232
|
});
|
|
228
233
|
const lastLedgerSequencePromise = new Promise(async (resolve) => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
234
|
+
try {
|
|
235
|
+
const ledgerIndex = await Client.getLedgerIndex();
|
|
236
|
+
if (ledgerIndex !== undefined) {
|
|
237
|
+
resolve(ledgerIndex + MAX_LEDGERS_AWAIT);
|
|
238
|
+
}
|
|
239
|
+
resolve(undefined);
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
resolve(undefined);
|
|
232
243
|
}
|
|
233
|
-
resolve(undefined);
|
|
234
244
|
});
|
|
235
245
|
const result = await Promise.all([feePromise, sequencePromise, lastLedgerSequencePromise]);
|
|
236
246
|
return {
|
|
@@ -249,6 +259,72 @@ async function getAccountPaymentParams(account, connection) {
|
|
|
249
259
|
}
|
|
250
260
|
}
|
|
251
261
|
exports.getAccountPaymentParams = getAccountPaymentParams;
|
|
262
|
+
async function getTxSubmitParams(account, tx, definitions, connection) {
|
|
263
|
+
try {
|
|
264
|
+
connection = connection || Client.findConnection("submit") || undefined;
|
|
265
|
+
if (!connection) {
|
|
266
|
+
throw new Error("There is no connection");
|
|
267
|
+
}
|
|
268
|
+
const feePromise = new Promise(async (resolve, rejects) => {
|
|
269
|
+
try {
|
|
270
|
+
if (tx && typeof tx === "object") {
|
|
271
|
+
tx = { ...tx, Sequence: 0, Fee: "0", SigningPubKey: "" };
|
|
272
|
+
}
|
|
273
|
+
const baseFee = await Client.getFee({ connection, tx, definitions });
|
|
274
|
+
let fee = parseFloat(baseFee);
|
|
275
|
+
if (fee > FEE_LIMIT) {
|
|
276
|
+
fee = FEE_LIMIT;
|
|
277
|
+
}
|
|
278
|
+
resolve((0, common_1.xrpToDrops)(fee.toString()));
|
|
279
|
+
}
|
|
280
|
+
catch (e) {
|
|
281
|
+
rejects(e);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
const sequencePromise = new Promise(async (resolve, rejects) => {
|
|
285
|
+
try {
|
|
286
|
+
const accountData = await Client.getAccountInfoData(account, { connection });
|
|
287
|
+
if (!accountData) {
|
|
288
|
+
return rejects(new Error("Account not found"));
|
|
289
|
+
}
|
|
290
|
+
if ("error" in accountData) {
|
|
291
|
+
return rejects(new Error(accountData.error));
|
|
292
|
+
}
|
|
293
|
+
resolve(accountData.Sequence);
|
|
294
|
+
}
|
|
295
|
+
catch (e) {
|
|
296
|
+
rejects(e);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
const lastLedgerSequencePromise = new Promise(async (resolve) => {
|
|
300
|
+
try {
|
|
301
|
+
const ledgerIndex = await Client.getLedgerIndex();
|
|
302
|
+
if (ledgerIndex !== undefined) {
|
|
303
|
+
resolve(ledgerIndex + MAX_LEDGERS_AWAIT);
|
|
304
|
+
}
|
|
305
|
+
resolve(undefined);
|
|
306
|
+
}
|
|
307
|
+
catch (e) {
|
|
308
|
+
resolve(undefined);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
const result = await Promise.all([feePromise, sequencePromise, lastLedgerSequencePromise]);
|
|
312
|
+
return {
|
|
313
|
+
fee: result[0],
|
|
314
|
+
sequence: result[1],
|
|
315
|
+
lastLedgerSequence: result[2],
|
|
316
|
+
networkID: connection.getNetworkID(),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
catch (e) {
|
|
320
|
+
return {
|
|
321
|
+
account,
|
|
322
|
+
status: "error",
|
|
323
|
+
error: e.message,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.getTxSubmitParams = getTxSubmitParams;
|
|
252
328
|
async function submit(signedTransaction, options = {}) {
|
|
253
329
|
const connection = options.connection || Client.findConnection("submit");
|
|
254
330
|
if (!connection) {
|
|
@@ -259,11 +335,11 @@ async function submit(signedTransaction, options = {}) {
|
|
|
259
335
|
return response;
|
|
260
336
|
}
|
|
261
337
|
const result = response?.result;
|
|
262
|
-
const resultGroup = result?.engine_result
|
|
338
|
+
const resultGroup = result?.engine_result?.slice(0, 3);
|
|
263
339
|
if ((submitErrorsGroup.includes(resultGroup) && result?.engine_result !== "terQUEUED") || result?.kept === false) {
|
|
264
340
|
return result;
|
|
265
341
|
}
|
|
266
|
-
const txHash = result
|
|
342
|
+
const txHash = result?.tx_json?.hash;
|
|
267
343
|
if (!txHash) {
|
|
268
344
|
return result;
|
|
269
345
|
}
|
|
@@ -275,10 +351,12 @@ async function submit(signedTransaction, options = {}) {
|
|
|
275
351
|
else {
|
|
276
352
|
const ledgerIndex = await Client.getLedgerIndex();
|
|
277
353
|
if (ledgerIndex !== undefined) {
|
|
278
|
-
|
|
354
|
+
const ledgersToWait = MAX_LEDGERS_AWAIT * 2;
|
|
355
|
+
lastLedger = ledgerIndex + ledgersToWait;
|
|
279
356
|
}
|
|
280
357
|
}
|
|
281
|
-
|
|
358
|
+
const finalResult = await waitForFinalTransactionOutcome(txHash, lastLedger);
|
|
359
|
+
return finalResult;
|
|
282
360
|
}
|
|
283
361
|
exports.submit = submit;
|
|
284
362
|
async function waitForFinalTransactionOutcome(txHash, lastLedger) {
|
|
@@ -294,5 +372,13 @@ async function waitForFinalTransactionOutcome(txHash, lastLedger) {
|
|
|
294
372
|
return waitForFinalTransactionOutcome(txHash, lastLedger);
|
|
295
373
|
}
|
|
296
374
|
}
|
|
375
|
+
if (tx && !tx.hasOwnProperty("error") && tx.validated === false) {
|
|
376
|
+
if (tx.hasOwnProperty("LastLedgerSequence")) {
|
|
377
|
+
return { ...tx, status: "timeout", error: "lastLedgerIndexReached" };
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
return { ...tx, status: "timeout", error: "waitingForValidation" };
|
|
381
|
+
}
|
|
382
|
+
}
|
|
297
383
|
return tx;
|
|
298
384
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
2
|
+
declare function parseBalanceChanges(metadata: TransactionMetadata, nativeCurrency?: string): {
|
|
2
3
|
[x: string]: any[];
|
|
3
4
|
};
|
|
4
|
-
declare function parseFinalBalances(metadata:
|
|
5
|
+
declare function parseFinalBalances(metadata: TransactionMetadata): {
|
|
5
6
|
[x: string]: any[];
|
|
6
7
|
};
|
|
7
8
|
export { parseBalanceChanges, parseFinalBalances };
|
|
@@ -10,7 +10,7 @@ const common_1 = require("../../common");
|
|
|
10
10
|
const utils_1 = require("../../v1/common/utils");
|
|
11
11
|
const client_1 = require("../../client");
|
|
12
12
|
function groupByAddress(balanceChanges) {
|
|
13
|
-
|
|
13
|
+
const grouped = lodash_1.default.groupBy(balanceChanges, function (node) {
|
|
14
14
|
return node.address;
|
|
15
15
|
});
|
|
16
16
|
return lodash_1.default.mapValues(grouped, function (group) {
|
|
@@ -23,7 +23,7 @@ function parseValue(value) {
|
|
|
23
23
|
return new bignumber_js_1.default(value.value || value);
|
|
24
24
|
}
|
|
25
25
|
function computeBalanceChange(node) {
|
|
26
|
-
|
|
26
|
+
let value = null;
|
|
27
27
|
if (node.newFields.Balance) {
|
|
28
28
|
value = parseValue(node.newFields.Balance);
|
|
29
29
|
}
|
|
@@ -42,7 +42,7 @@ function parseFinalBalance(node) {
|
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
function parseXRPQuantity(node, valueParser, nativeCurrency) {
|
|
45
|
-
|
|
45
|
+
const value = valueParser(node);
|
|
46
46
|
if (value === null) {
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
@@ -56,7 +56,7 @@ function parseXRPQuantity(node, valueParser, nativeCurrency) {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
function flipTrustlinePerspective(quantity) {
|
|
59
|
-
|
|
59
|
+
const negatedBalance = new bignumber_js_1.default(quantity.balance.value).negated();
|
|
60
60
|
return {
|
|
61
61
|
address: quantity.balance.counterparty,
|
|
62
62
|
balance: {
|
|
@@ -67,12 +67,12 @@ function flipTrustlinePerspective(quantity) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
function parseTrustlineQuantity(node, valueParser) {
|
|
70
|
-
|
|
70
|
+
const value = valueParser(node);
|
|
71
71
|
if (value === null) {
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
|
|
75
|
+
const result = {
|
|
76
76
|
address: fields.LowLimit.issuer,
|
|
77
77
|
balance: {
|
|
78
78
|
counterparty: fields.HighLimit.issuer,
|
|
@@ -83,7 +83,7 @@ function parseTrustlineQuantity(node, valueParser) {
|
|
|
83
83
|
return [result, flipTrustlinePerspective(result)];
|
|
84
84
|
}
|
|
85
85
|
function parseQuantities(metadata, valueParser, nativeCurrency) {
|
|
86
|
-
|
|
86
|
+
const values = (0, utils_1.normalizeNodes)(metadata).map(function (node) {
|
|
87
87
|
if (node.entryType === "AccountRoot") {
|
|
88
88
|
return [parseXRPQuantity(node, valueParser, nativeCurrency)];
|
|
89
89
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
2
|
+
declare function parseLockedBalanceChanges(metadata: TransactionMetadata): {
|
|
2
3
|
[x: string]: any[];
|
|
3
4
|
};
|
|
4
|
-
declare function parseFinalLockedBalances(metadata:
|
|
5
|
+
declare function parseFinalLockedBalances(metadata: TransactionMetadata): {
|
|
5
6
|
[x: string]: any[];
|
|
6
7
|
};
|
|
7
8
|
export { parseLockedBalanceChanges, parseFinalLockedBalances };
|
|
@@ -23,13 +23,16 @@ function parseValue(value) {
|
|
|
23
23
|
return new bignumber_js_1.default(value.value || value);
|
|
24
24
|
}
|
|
25
25
|
function computeBalanceChange(node) {
|
|
26
|
-
|
|
26
|
+
let value = null;
|
|
27
27
|
if (node.newFields.LockedBalance) {
|
|
28
28
|
value = parseValue(node.newFields.LockedBalance);
|
|
29
29
|
}
|
|
30
30
|
else if (node.previousFields.LockedBalance && node.finalFields.LockedBalance) {
|
|
31
31
|
value = parseValue(node.finalFields.LockedBalance).minus(parseValue(node.previousFields.LockedBalance));
|
|
32
32
|
}
|
|
33
|
+
else if (node.previousFields.LockedBalance) {
|
|
34
|
+
value = parseValue(node.previousFields.LockedBalance).negated();
|
|
35
|
+
}
|
|
33
36
|
return value === null ? null : value.isZero() ? null : value;
|
|
34
37
|
}
|
|
35
38
|
function parseFinalBalance(node) {
|
|
@@ -42,7 +45,7 @@ function parseFinalBalance(node) {
|
|
|
42
45
|
return null;
|
|
43
46
|
}
|
|
44
47
|
function parseXRPQuantity(node, valueParser) {
|
|
45
|
-
|
|
48
|
+
const value = valueParser(node);
|
|
46
49
|
if (value === null) {
|
|
47
50
|
return null;
|
|
48
51
|
}
|
|
@@ -56,23 +59,24 @@ function parseXRPQuantity(node, valueParser) {
|
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
61
|
function parseTrustlineQuantity(node, valueParser) {
|
|
59
|
-
|
|
62
|
+
const value = valueParser(node);
|
|
60
63
|
if (value === null) {
|
|
61
64
|
return null;
|
|
62
65
|
}
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
|
|
67
|
+
const LockedBalanceFields = lodash_1.default.isEmpty(node.newFields?.LockedBalance) ? lodash_1.default.isEmpty(node.finalFields?.LockedBalance) ? node.previousFields : node.finalFields : node.newFields;
|
|
68
|
+
const result = {
|
|
65
69
|
address: fields.LowLimit.issuer,
|
|
66
70
|
lockedBalance: {
|
|
67
|
-
counterparty:
|
|
68
|
-
currency:
|
|
71
|
+
counterparty: LockedBalanceFields.LockedBalance.issuer,
|
|
72
|
+
currency: LockedBalanceFields.LockedBalance.currency,
|
|
69
73
|
value: value.toString(),
|
|
70
74
|
},
|
|
71
75
|
};
|
|
72
76
|
return [result];
|
|
73
77
|
}
|
|
74
78
|
function parseQuantities(metadata, valueParser) {
|
|
75
|
-
|
|
79
|
+
const values = (0, utils_1.normalizeNodes)(metadata).map(function (node) {
|
|
76
80
|
if (node.entryType === "AccountRoot") {
|
|
77
81
|
return [parseXRPQuantity(node, valueParser)];
|
|
78
82
|
}
|
|
@@ -15,11 +15,11 @@ const currency_amount_1 = __importDefault(require("../ledger/currency-amount"));
|
|
|
15
15
|
const client_1 = require("../../client");
|
|
16
16
|
const lsfSell = 0x00020000;
|
|
17
17
|
function convertOrderChange(order) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const takerGets = order.taker_gets;
|
|
19
|
+
const takerPays = order.taker_pays;
|
|
20
|
+
const direction = order.sell ? "sell" : "buy";
|
|
21
|
+
const quantity = direction === "buy" ? takerPays : takerGets;
|
|
22
|
+
const totalPrice = direction === "buy" ? takerGets : takerPays;
|
|
23
23
|
return (0, common_1.removeUndefined)({
|
|
24
24
|
direction: direction,
|
|
25
25
|
quantity: quantity,
|
|
@@ -31,19 +31,19 @@ function convertOrderChange(order) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
function getExpirationTime(node) {
|
|
34
|
-
|
|
34
|
+
const expirationTime = node.finalFields.Expiration || node.newFields.Expiration;
|
|
35
35
|
if (expirationTime === undefined) {
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
38
|
return new Date((0, models_1.ledgerTimeToTimestamp)(expirationTime)).toISOString();
|
|
39
39
|
}
|
|
40
40
|
function getQuality(node) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const takerGets = node.finalFields.TakerGets || node.newFields.TakerGets;
|
|
42
|
+
const takerPays = node.finalFields.TakerPays || node.newFields.TakerPays;
|
|
43
|
+
const takerGetsCurrency = takerGets.currency || (0, client_1.getNativeCurrency)();
|
|
44
|
+
const takerPaysCurrency = takerPays.currency || (0, client_1.getNativeCurrency)();
|
|
45
|
+
const bookDirectory = node.finalFields.BookDirectory || node.newFields.BookDirectory;
|
|
46
|
+
const qualityHex = bookDirectory.substring(bookDirectory.length - 16);
|
|
47
47
|
return (0, orderbook_quality_1.parseOrderbookQuality)(qualityHex, takerGetsCurrency, takerPaysCurrency);
|
|
48
48
|
}
|
|
49
49
|
function parseOrderStatus(node) {
|
|
@@ -63,27 +63,27 @@ function parseOrderStatus(node) {
|
|
|
63
63
|
}
|
|
64
64
|
function calculateDelta(finalAmount, previousAmount) {
|
|
65
65
|
if (previousAmount) {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const finalValue = new BigNumber(finalAmount.value);
|
|
67
|
+
const previousValue = new BigNumber(previousAmount.value);
|
|
68
68
|
return finalValue.minus(previousValue).abs().toString();
|
|
69
69
|
}
|
|
70
70
|
return "0";
|
|
71
71
|
}
|
|
72
72
|
function parseChangeAmount(node, type) {
|
|
73
|
-
|
|
73
|
+
const status = parseOrderStatus(node);
|
|
74
74
|
if (status === "cancelled") {
|
|
75
75
|
return (0, currency_amount_1.default)(node.finalFields[type]);
|
|
76
76
|
}
|
|
77
77
|
else if (status === "created") {
|
|
78
78
|
return (0, currency_amount_1.default)(node.newFields[type]);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const finalAmount = (0, currency_amount_1.default)(node.finalFields[type]);
|
|
81
|
+
const previousAmount = (0, currency_amount_1.default)(node.previousFields[type]);
|
|
82
|
+
const value = calculateDelta(finalAmount, previousAmount);
|
|
83
83
|
return lodash_1.default.assign({}, finalAmount, { value: value });
|
|
84
84
|
}
|
|
85
85
|
function parseOrderChange(node) {
|
|
86
|
-
|
|
86
|
+
const orderChange = convertOrderChange({
|
|
87
87
|
taker_pays: parseChangeAmount(node, "TakerPays"),
|
|
88
88
|
taker_gets: parseChangeAmount(node, "TakerGets"),
|
|
89
89
|
sell: (node.finalFields.Flags & lsfSell) !== 0,
|
|
@@ -103,8 +103,8 @@ function groupByAddress(orderChanges) {
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
function parseOrderbookChanges(metadata) {
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
const nodes = (0, utils_1.normalizeNodes)(metadata);
|
|
107
|
+
const orderChanges = lodash_1.default.map(lodash_1.default.filter(nodes, function (node) {
|
|
108
108
|
return node.entryType === "Offer";
|
|
109
109
|
}), parseOrderChange);
|
|
110
110
|
return groupByAddress(orderChanges);
|
|
@@ -31,16 +31,16 @@ const assert = __importStar(require("assert"));
|
|
|
31
31
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
32
32
|
const client_1 = require("../../client");
|
|
33
33
|
function adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const numeratorShift = takerPaysCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
|
|
35
|
+
const denominatorShift = takerGetsCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
|
|
36
|
+
const shift = numeratorShift - denominatorShift;
|
|
37
37
|
return shift === 0 ? new bignumber_js_1.default(quality).toString() : new bignumber_js_1.default(quality).shiftedBy(shift).toString();
|
|
38
38
|
}
|
|
39
39
|
function parseOrderbookQuality(qualityHex, takerGetsCurrency, takerPaysCurrency) {
|
|
40
40
|
assert.ok(qualityHex.length === 16);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const mantissa = new bignumber_js_1.default(qualityHex.substring(2), 16);
|
|
42
|
+
const offset = parseInt(qualityHex.substring(0, 2), 16) - 100;
|
|
43
|
+
const quality = mantissa.toString() + "e" + offset.toString();
|
|
44
44
|
return adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency);
|
|
45
45
|
}
|
|
46
46
|
exports.parseOrderbookQuality = parseOrderbookQuality;
|
|
@@ -28,7 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const assert = __importStar(require("assert"));
|
|
30
30
|
const common_1 = require("../../common");
|
|
31
|
-
const ripple_address_codec_1 = require("ripple-address-codec");
|
|
32
31
|
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
33
32
|
function parseAccountDelete(tx) {
|
|
34
33
|
assert.ok(tx.TransactionType === "AccountDelete");
|
|
@@ -36,7 +35,6 @@ function parseAccountDelete(tx) {
|
|
|
36
35
|
memos: (0, memos_1.default)(tx),
|
|
37
36
|
destination: tx.Destination,
|
|
38
37
|
destinationTag: tx.DestinationTag,
|
|
39
|
-
destinationXAddress: (0, ripple_address_codec_1.classicAddressToXAddress)(tx.Destination, tx.DestinationTag == null ? false : tx.DestinationTag, false),
|
|
40
38
|
});
|
|
41
39
|
}
|
|
42
40
|
exports.default = parseAccountDelete;
|
|
@@ -0,0 +1,81 @@
|
|
|
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 memos_1 = __importDefault(require("../ledger/memos"));
|
|
32
|
+
const account_1 = require("../ledger/account");
|
|
33
|
+
const uritoken_flags_1 = __importDefault(require("../ledger/uritoken-flags"));
|
|
34
|
+
function parseAmounts(amounts) {
|
|
35
|
+
if (!amounts) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const result = [];
|
|
39
|
+
for (const amount of amounts) {
|
|
40
|
+
if (amount.AmountEntry.Amount) {
|
|
41
|
+
result.push(amount.AmountEntry.Amount);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (result.length === 0) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
function parseMintURIToken(mintURIToken) {
|
|
50
|
+
if (!mintURIToken) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return (0, common_1.removeUndefined)({
|
|
54
|
+
uri: mintURIToken.URI,
|
|
55
|
+
flags: (0, uritoken_flags_1.default)(mintURIToken.Flags ?? 0),
|
|
56
|
+
digest: mintURIToken.Digest,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function parseRemit(tx) {
|
|
60
|
+
assert.ok(tx.TransactionType === "Remit");
|
|
61
|
+
const source = {
|
|
62
|
+
address: (0, account_1.parseAccount)(tx.Account),
|
|
63
|
+
tag: tx.SourceTag,
|
|
64
|
+
};
|
|
65
|
+
const destination = {
|
|
66
|
+
address: tx.Destination,
|
|
67
|
+
tag: tx.DestinationTag,
|
|
68
|
+
};
|
|
69
|
+
return (0, common_1.removeUndefined)({
|
|
70
|
+
source: (0, common_1.removeUndefined)(source),
|
|
71
|
+
destination: (0, common_1.removeUndefined)(destination),
|
|
72
|
+
amounts: parseAmounts(tx.Amounts),
|
|
73
|
+
uritokenIDs: tx.URITokenIDs,
|
|
74
|
+
uritokenMint: parseMintURIToken(tx.MintURIToken),
|
|
75
|
+
blob: tx.Blob,
|
|
76
|
+
inform: tx.Inform,
|
|
77
|
+
invoiceID: tx.InvoiceID,
|
|
78
|
+
memos: (0, memos_1.default)(tx),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
exports.default = parseRemit;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FormattedUNLReportSpecification } from "../../v1/common/types/objects/
|
|
2
|
-
declare function
|
|
3
|
-
export default
|
|
1
|
+
import { FormattedUNLReportSpecification } from "../../v1/common/types/objects/unl_reports";
|
|
2
|
+
declare function parseUNLReport(tx: any): FormattedUNLReportSpecification;
|
|
3
|
+
export default parseUNLReport;
|
|
@@ -30,7 +30,7 @@ const assert = __importStar(require("assert"));
|
|
|
30
30
|
const common_1 = require("../../common");
|
|
31
31
|
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
32
32
|
const account_1 = require("../ledger/account");
|
|
33
|
-
function
|
|
33
|
+
function parseUNLReport(tx) {
|
|
34
34
|
assert.ok(tx.TransactionType === "UNLReport");
|
|
35
35
|
const source = {
|
|
36
36
|
address: (0, account_1.parseAccount)(tx.Account),
|
|
@@ -44,4 +44,4 @@ function parseImport(tx) {
|
|
|
44
44
|
memos: (0, memos_1.default)(tx),
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
exports.default =
|
|
47
|
+
exports.default = parseUNLReport;
|
|
@@ -14,11 +14,12 @@ import { FormattedNFTokenBurnSpecification, FormattedNFTokenMintSpecification, F
|
|
|
14
14
|
import { FormattedURITokenBurnSpecification, FormattedURITokenBuySpecification, FormattedURITokenCreateSellOfferSpecification, FormattedURITokenCancelSellOfferSpecification, FormattedURITokenMintSpecification } from "../v1/common/types/objects/uritokens";
|
|
15
15
|
import { FormattedImportSpecification } from "../v1/common/types/objects/import";
|
|
16
16
|
import { FormattedInvokeSpecification } from "../v1/common/types/objects/invoke";
|
|
17
|
-
import { FormattedUNLReportSpecification } from "../v1/common/types/objects/
|
|
17
|
+
import { FormattedUNLReportSpecification } from "../v1/common/types/objects/unl_reports";
|
|
18
|
+
import { FormattedRemitsSpecification } from "../v1/common/types/objects/remits";
|
|
18
19
|
import { FormattedAmendmentSpecification } from "../v1/common/types/objects/amendments";
|
|
19
20
|
import { FormattedFeeUpdateSpecification } from "../v1/common/types/objects/fees";
|
|
20
21
|
declare function parseTransactionType(type: string): string;
|
|
21
|
-
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 | FormattedAmendmentSpecification | FormattedFeeUpdateSpecification;
|
|
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;
|
|
22
23
|
export interface FormattedTransaction {
|
|
23
24
|
type: string;
|
|
24
25
|
address: string;
|
package/lib/parse/transaction.js
CHANGED
|
@@ -37,6 +37,7 @@ const uritoken_mint_1 = __importDefault(require("./specification/uritoken-mint")
|
|
|
37
37
|
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
|
+
const remit_1 = __importDefault(require("./specification/remit"));
|
|
40
41
|
const amendment_1 = __importDefault(require("./specification/amendment"));
|
|
41
42
|
const fee_update_1 = __importDefault(require("./specification/fee-update"));
|
|
42
43
|
const transactionTypeToType = {
|
|
@@ -72,6 +73,7 @@ const transactionTypeToType = {
|
|
|
72
73
|
Import: "import",
|
|
73
74
|
Invoke: "invoke",
|
|
74
75
|
UNLReport: "unlReport",
|
|
76
|
+
Remit: "remit",
|
|
75
77
|
EnableAmendment: "amendment",
|
|
76
78
|
SetFee: "feeUpdate",
|
|
77
79
|
};
|
|
@@ -110,6 +112,7 @@ const parserTypeFunc = {
|
|
|
110
112
|
import: import_1.default,
|
|
111
113
|
invoke: invoke_1.default,
|
|
112
114
|
unlReport: unl_report_1.default,
|
|
115
|
+
remit: remit_1.default,
|
|
113
116
|
amendment: amendment_1.default,
|
|
114
117
|
feeUpdate: fee_update_1.default,
|
|
115
118
|
};
|
|
@@ -131,6 +134,7 @@ function parseTransaction(tx, includeRawTransaction, nativeCurrency, definitions
|
|
|
131
134
|
address: (0, account_1.parseAccount)(tx.Account),
|
|
132
135
|
sequence: tx.Sequence,
|
|
133
136
|
id: tx.hash,
|
|
137
|
+
ctid: tx.ctid,
|
|
134
138
|
specification: (0, common_1.removeUndefined)(specification),
|
|
135
139
|
outcome: outcome ? (0, common_1.removeUndefined)(outcome) : undefined,
|
|
136
140
|
rawTransaction: includeRawTransaction ? JSON.stringify(tx) : undefined,
|
|
@@ -16,7 +16,7 @@ export interface AccountObjectsRequest {
|
|
|
16
16
|
}
|
|
17
17
|
export interface AccountObjects {
|
|
18
18
|
account: string;
|
|
19
|
-
account_objects:
|
|
19
|
+
account_objects: (CheckLedgerEntry | RippleStateLedgerEntry | OfferLedgerEntry | SignerListLedgerEntry | EscrowLedgerEntry | PayChannelLedgerEntry | DepositPreauthLedgerEntry)[];
|
|
20
20
|
ledger_hash?: string;
|
|
21
21
|
ledger_index?: number;
|
|
22
22
|
ledger_current_index?: number;
|
|
@@ -2,7 +2,7 @@ import { FormattedIssuedCurrencyAmount } from "../objects";
|
|
|
2
2
|
export interface GatewayBalancesRequest {
|
|
3
3
|
account: string;
|
|
4
4
|
strict?: boolean;
|
|
5
|
-
hotwallet: string |
|
|
5
|
+
hotwallet: string | string[];
|
|
6
6
|
ledger_hash?: string;
|
|
7
7
|
ledger_index?: number | ("validated" | "closed" | "current");
|
|
8
8
|
}
|
|
@@ -11,23 +11,23 @@ export type PathFindRequest = {
|
|
|
11
11
|
send_max?: Amount;
|
|
12
12
|
};
|
|
13
13
|
export type RippledPathsResponse = {
|
|
14
|
-
alternatives:
|
|
15
|
-
paths_computed:
|
|
14
|
+
alternatives: {
|
|
15
|
+
paths_computed: {
|
|
16
16
|
type: number;
|
|
17
17
|
type_hex: string;
|
|
18
18
|
account?: string;
|
|
19
19
|
issuer?: string;
|
|
20
20
|
currency?: string;
|
|
21
|
-
}
|
|
21
|
+
}[][];
|
|
22
22
|
source_amount: Amount;
|
|
23
|
-
}
|
|
23
|
+
}[];
|
|
24
24
|
type: string;
|
|
25
25
|
destination_account: string;
|
|
26
26
|
destination_amount: Amount;
|
|
27
|
-
destination_currencies?:
|
|
27
|
+
destination_currencies?: string[];
|
|
28
28
|
source_account: string;
|
|
29
|
-
source_currencies?:
|
|
29
|
+
source_currencies?: {
|
|
30
30
|
currency: string;
|
|
31
|
-
}
|
|
31
|
+
}[];
|
|
32
32
|
full_reply?: boolean;
|
|
33
33
|
};
|
|
@@ -3,7 +3,6 @@ import { FormattedIssuedCurrencyAmount } from "../../../../types";
|
|
|
3
3
|
export type FormattedAccountDeleteSpecification = {
|
|
4
4
|
destination: string;
|
|
5
5
|
destinationTag?: number;
|
|
6
|
-
destinationXAddress: string;
|
|
7
6
|
} & FormattedBaseSpecification;
|
|
8
7
|
export type FormattedSourceAddress = {
|
|
9
8
|
address: string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface HookExecutionObjectInterface {
|
|
2
|
+
HookExecution: HookExecutionInterface;
|
|
3
|
+
}
|
|
4
|
+
export interface HookExecutionInterface {
|
|
5
|
+
HookAccount: string;
|
|
6
|
+
HookEmitCount: number;
|
|
7
|
+
HookExecutionIndex: number;
|
|
8
|
+
HookHash: string;
|
|
9
|
+
HookInstructionCount: string;
|
|
10
|
+
HookResult: number;
|
|
11
|
+
HookReturnCode: string;
|
|
12
|
+
HookReturnString: string;
|
|
13
|
+
HookStateChangeCount: number;
|
|
14
|
+
}
|
|
@@ -18,5 +18,7 @@ export * from "./amendments";
|
|
|
18
18
|
export * from "./fees";
|
|
19
19
|
export * from "./import";
|
|
20
20
|
export * from "./invoke";
|
|
21
|
-
export * from "./
|
|
21
|
+
export * from "./unl_reports";
|
|
22
|
+
export * from "./remits";
|
|
23
|
+
export * from "./hooks";
|
|
22
24
|
export * from "../../../../types";
|
|
@@ -34,5 +34,7 @@ __exportStar(require("./amendments"), exports);
|
|
|
34
34
|
__exportStar(require("./fees"), exports);
|
|
35
35
|
__exportStar(require("./import"), exports);
|
|
36
36
|
__exportStar(require("./invoke"), exports);
|
|
37
|
-
__exportStar(require("./
|
|
37
|
+
__exportStar(require("./unl_reports"), exports);
|
|
38
|
+
__exportStar(require("./remits"), exports);
|
|
39
|
+
__exportStar(require("./hooks"), exports);
|
|
38
40
|
__exportStar(require("../../../../types"), exports);
|
|
@@ -26,10 +26,10 @@ export type FormattedLedger = {
|
|
|
26
26
|
parentCloseTime: string;
|
|
27
27
|
totalDrops: string;
|
|
28
28
|
transactionHash: string;
|
|
29
|
-
transactions?:
|
|
30
|
-
transactionHashes?:
|
|
29
|
+
transactions?: object[];
|
|
30
|
+
transactionHashes?: string[];
|
|
31
31
|
rawState?: string;
|
|
32
|
-
stateHashes?:
|
|
32
|
+
stateHashes?: string[];
|
|
33
33
|
};
|
|
34
34
|
export type LedgerClosedEvent = {
|
|
35
35
|
type: "ledgerClosed";
|
|
@@ -10,15 +10,15 @@ export type Path = {
|
|
|
10
10
|
destination: Adjustment | MinAdjustment;
|
|
11
11
|
paths: string;
|
|
12
12
|
};
|
|
13
|
-
export type GetPaths =
|
|
13
|
+
export type GetPaths = Path[];
|
|
14
14
|
export type PathFind = {
|
|
15
15
|
source: {
|
|
16
16
|
address: string;
|
|
17
17
|
amount?: FormattedIssuedCurrencyAmount;
|
|
18
|
-
currencies?:
|
|
18
|
+
currencies?: {
|
|
19
19
|
currency: string;
|
|
20
20
|
counterparty?: string;
|
|
21
|
-
}
|
|
21
|
+
}[];
|
|
22
22
|
};
|
|
23
23
|
destination: {
|
|
24
24
|
address: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FormattedBaseSpecification } from "./specification";
|
|
2
|
+
import { FormattedDestinationAddress, FormattedSourceAddress } from "./account";
|
|
3
|
+
import { Amount } from "../../../../types";
|
|
4
|
+
import { URITokenFlagsKeysInterface } from "./uritokens";
|
|
5
|
+
export type FormattedRemitsSpecification = {
|
|
6
|
+
source: FormattedSourceAddress;
|
|
7
|
+
destination: FormattedDestinationAddress;
|
|
8
|
+
amounts?: Amount[];
|
|
9
|
+
uritokenIDs?: string[];
|
|
10
|
+
uritokenMint?: {
|
|
11
|
+
uri: string;
|
|
12
|
+
flags?: URITokenFlagsKeysInterface;
|
|
13
|
+
digest?: string;
|
|
14
|
+
};
|
|
15
|
+
blob?: string;
|
|
16
|
+
inform?: string;
|
|
17
|
+
invoiceID?: string;
|
|
18
|
+
} & FormattedBaseSpecification;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormattedBaseSpecification } from "./specification";
|
|
2
|
+
import { FormattedSourceAddress } from "./account";
|
|
3
|
+
export type FormattedUNLReportSpecification = {
|
|
4
|
+
source: FormattedSourceAddress;
|
|
5
|
+
activeValidator?: string;
|
|
6
|
+
importVLKey?: string;
|
|
7
|
+
} & FormattedBaseSpecification;
|
package/lib/v1/common/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
1
2
|
import { Amount, FormattedIssuedCurrencyAmount } from "./types/objects";
|
|
2
3
|
declare function isValidSecret(secret: string): boolean;
|
|
3
4
|
declare function toRippledAmount(amount: Amount | FormattedIssuedCurrencyAmount): Amount;
|
|
4
5
|
declare function iso8601ToRippleTime(iso8601: string): number;
|
|
5
|
-
declare function normalizeNodes(metadata:
|
|
6
|
+
declare function normalizeNodes(metadata: TransactionMetadata): any[];
|
|
6
7
|
export { toRippledAmount, iso8601ToRippleTime, isValidSecret, normalizeNodes };
|
package/lib/validator.js
CHANGED
|
@@ -31,7 +31,6 @@ const assert = __importStar(require("assert"));
|
|
|
31
31
|
const ripple_address_codec_1 = require("ripple-address-codec");
|
|
32
32
|
const Crypto = __importStar(require("crypto"));
|
|
33
33
|
const Base58 = __importStar(require("./base58"));
|
|
34
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
35
34
|
const elliptic_1 = __importDefault(require("elliptic"));
|
|
36
35
|
const secp256k1 = new elliptic_1.default.ec("secp256k1");
|
|
37
36
|
const ed25519 = new elliptic_1.default.eddsa("ed25519");
|
|
@@ -63,7 +62,7 @@ function classicAddressFromValidatorPK(pk) {
|
|
|
63
62
|
}
|
|
64
63
|
exports.classicAddressFromValidatorPK = classicAddressFromValidatorPK;
|
|
65
64
|
function generateSecrets() {
|
|
66
|
-
const keypair =
|
|
65
|
+
const keypair = Crypto.generateKeyPairSync("ed25519", {
|
|
67
66
|
privateKeyEncoding: { format: "der", type: "pkcs8" },
|
|
68
67
|
publicKeyEncoding: { format: "der", type: "spki" },
|
|
69
68
|
});
|
|
@@ -123,7 +122,7 @@ function verify2(message, signature, publicKey) {
|
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
else {
|
|
126
|
-
const computedHash =
|
|
125
|
+
const computedHash = Crypto.createHash("sha512").update(message).digest().toString("hex").slice(0, 64);
|
|
127
126
|
const verifyKey = secp256k1.keyFromPublic(publicKey, "hex");
|
|
128
127
|
if (verifyKey.verify(computedHash, signature)) {
|
|
129
128
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.14",
|
|
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",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"test": "node ./node_modules/mocha/bin/mocha",
|
|
38
38
|
"build": "tsc",
|
|
39
39
|
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
40
|
-
"lint": "
|
|
40
|
+
"lint": "eslint -c .eslintrc.json --ext .ts src/",
|
|
41
41
|
"prepare": "npm run build",
|
|
42
42
|
"prepublishOnly": "npm test && npm run lint",
|
|
43
43
|
"preversion": "npm run lint",
|
|
@@ -58,23 +58,26 @@
|
|
|
58
58
|
"xrpl": "^2.14.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@types/chai": "^4.3.
|
|
61
|
+
"@types/chai": "^4.3.11",
|
|
62
62
|
"@types/chai-as-promised": "^7.1.8",
|
|
63
|
-
"@types/lodash": "^4.14.
|
|
64
|
-
"@types/mocha": "^10.0.
|
|
63
|
+
"@types/lodash": "^4.14.202",
|
|
64
|
+
"@types/mocha": "^10.0.6",
|
|
65
65
|
"@types/nconf": "^0.10.6",
|
|
66
|
-
"@types/node": "^20.
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
68
|
-
"@typescript-eslint/parser": "^6.
|
|
66
|
+
"@types/node": "^20.10.3",
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
|
68
|
+
"@typescript-eslint/parser": "^6.13.2",
|
|
69
69
|
"chai": "^4.3.10",
|
|
70
70
|
"chai-as-promised": "^7.1.1",
|
|
71
|
+
"eslint": "^8.55.0",
|
|
72
|
+
"eslint-config-prettier": "^9.1.0",
|
|
73
|
+
"eslint-plugin-chai-friendly": "^0.7.2",
|
|
74
|
+
"eslint-plugin-import": "^2.29.0",
|
|
75
|
+
"eslint-plugin-n": "^16.3.1",
|
|
76
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
71
77
|
"mocha": "^10.2.0",
|
|
72
78
|
"nconf": "^0.12.1",
|
|
73
|
-
"prettier": "2.8.8",
|
|
74
79
|
"ts-jest": "^29.1.1",
|
|
75
80
|
"ts-node": "^10.9.1",
|
|
76
|
-
"
|
|
77
|
-
"tslint-config-prettier": "^1.18.0",
|
|
78
|
-
"typescript": "^5.2.2"
|
|
81
|
+
"typescript": "^5.3.2"
|
|
79
82
|
}
|
|
80
83
|
}
|