@bithomp/xrpl-api 3.8.8 → 3.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parse/outcome/balance_changes.js +42 -34
- package/lib/parse/outcome/sponsorship_changes.d.ts +1 -1
- package/lib/parse/outcome/sponsorship_changes.js +7 -4
- package/lib/parse/outcome.js +1 -0
- package/lib/parse/specification/confidential-mpt-convert-back.d.ts +3 -0
- package/lib/parse/specification/confidential-mpt-convert-back.js +64 -0
- package/lib/parse/transaction.d.ts +2 -0
- package/lib/parse/transaction.js +3 -0
- package/lib/types/mptokens.d.ts +9 -0
- package/package.json +2 -2
|
@@ -17,7 +17,7 @@ const channel_changes_1 = require("./channel_changes");
|
|
|
17
17
|
const sponsorship_changes_1 = require("./sponsorship_changes");
|
|
18
18
|
const ESCROW_TYPES = ["EscrowFinish", "EscrowCreate", "EscrowCancel"];
|
|
19
19
|
const PAYMENT_CHANNEL_TYPES = ["PaymentChannelClaim", "PaymentChannelCreate", "PaymentChannelFund"];
|
|
20
|
-
const CONFIDENTIAL_MPT_CONVERT_TYPES = ["ConfidentialMPTConvert"];
|
|
20
|
+
const CONFIDENTIAL_MPT_CONVERT_TYPES = ["ConfidentialMPTConvert", "ConfidentialMPTConvertBack"];
|
|
21
21
|
function groupByAddress(balanceChanges) {
|
|
22
22
|
const grouped = lodash_1.default.groupBy(balanceChanges, function (node) {
|
|
23
23
|
return node.address;
|
|
@@ -300,9 +300,6 @@ function adjustBalancesForPaymentChannel(balanceChanges, metadata, nativeCurrenc
|
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
function adjustBalancesForConfidentialMPTConvert(balanceChanges, tx) {
|
|
303
|
-
if (tx.TransactionType !== "ConfidentialMPTConvert") {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
303
|
const amount = tx.MPTAmount;
|
|
307
304
|
const mptIssuanceID = tx.MPTokenIssuanceID;
|
|
308
305
|
if (!amount || !mptIssuanceID) {
|
|
@@ -320,7 +317,12 @@ function adjustBalancesForConfidentialMPTConvert(balanceChanges, tx) {
|
|
|
320
317
|
if (!holderChange) {
|
|
321
318
|
return;
|
|
322
319
|
}
|
|
323
|
-
|
|
320
|
+
if (tx.TransactionType === "ConfidentialMPTConvertBack") {
|
|
321
|
+
adjustBalancesChanges(balanceChanges, holder, [{ value: `-${amount}`, mpt_issuance_id: mptIssuanceID }]);
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
adjustBalancesChanges(balanceChanges, holder, [{ value: `${amount}`, mpt_issuance_id: mptIssuanceID }]);
|
|
325
|
+
}
|
|
324
326
|
}
|
|
325
327
|
function adjustBalancesForConfidentialMPTClawback(balanceChanges, tx) {
|
|
326
328
|
const amount = tx.MPTAmount;
|
|
@@ -345,46 +347,52 @@ function adjustBalancesForConfidentialMPTClawback(balanceChanges, tx) {
|
|
|
345
347
|
}
|
|
346
348
|
function adjustBalancesForSponsorship(balanceChanges, metadata, nativeCurrency, tx) {
|
|
347
349
|
const sponsorshipChanges = (0, sponsorship_changes_1.parseSponsorshipChanges)(metadata);
|
|
348
|
-
if (!sponsorshipChanges) {
|
|
350
|
+
if (!sponsorshipChanges || sponsorshipChanges.length === 0) {
|
|
349
351
|
return;
|
|
350
352
|
}
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
]);
|
|
360
|
-
}
|
|
361
|
-
else if (sponsorshipChanges.status === "modified") {
|
|
362
|
-
if (tx.Account === owner) {
|
|
363
|
-
if (sponsorshipChanges.feeAmountChange) {
|
|
353
|
+
for (const sponsorshipChange of sponsorshipChanges) {
|
|
354
|
+
const owner = sponsorshipChange.owner?.address;
|
|
355
|
+
const sponsee = sponsorshipChange.sponsee?.address;
|
|
356
|
+
if (!owner || !sponsee) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (sponsorshipChange.status === "created") {
|
|
360
|
+
if (sponsorshipChange.feeAmount) {
|
|
364
361
|
adjustBalancesChanges(balanceChanges, owner, [
|
|
365
|
-
{
|
|
366
|
-
currency: sponsorshipChanges.feeAmountChange.currency,
|
|
367
|
-
value: `${sponsorshipChanges.feeAmountChange.value}`,
|
|
368
|
-
},
|
|
362
|
+
{ currency: sponsorshipChange.feeAmount.currency, value: `${sponsorshipChange.feeAmount.value}` },
|
|
369
363
|
]);
|
|
370
364
|
}
|
|
371
365
|
}
|
|
372
|
-
else {
|
|
373
|
-
if (
|
|
366
|
+
else if (sponsorshipChange.status === "modified") {
|
|
367
|
+
if (tx.Account === owner) {
|
|
368
|
+
if (sponsorshipChange.feeAmountChange) {
|
|
369
|
+
adjustBalancesChanges(balanceChanges, owner, [
|
|
370
|
+
{
|
|
371
|
+
currency: sponsorshipChange.feeAmountChange.currency,
|
|
372
|
+
value: `${sponsorshipChange.feeAmountChange.value}`,
|
|
373
|
+
},
|
|
374
|
+
]);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
if (sponsorshipChange.feeAmountChange) {
|
|
379
|
+
adjustBalancesChanges(balanceChanges, owner, [
|
|
380
|
+
{
|
|
381
|
+
currency: sponsorshipChange.feeAmountChange.currency,
|
|
382
|
+
value: sponsorshipChange.feeAmountChange.value,
|
|
383
|
+
},
|
|
384
|
+
]);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else if (sponsorshipChange.status === "deleted") {
|
|
389
|
+
if (sponsorshipChange.feeAmount) {
|
|
374
390
|
adjustBalancesChanges(balanceChanges, owner, [
|
|
375
|
-
{
|
|
376
|
-
currency: sponsorshipChanges.feeAmountChange.currency,
|
|
377
|
-
value: sponsorshipChanges.feeAmountChange.value,
|
|
378
|
-
},
|
|
391
|
+
{ currency: sponsorshipChange.feeAmount.currency, value: `-${sponsorshipChange.feeAmount.value}` },
|
|
379
392
|
]);
|
|
380
393
|
}
|
|
381
394
|
}
|
|
382
395
|
}
|
|
383
|
-
else if (sponsorshipChanges.status === "deleted") {
|
|
384
|
-
adjustBalancesChanges(balanceChanges, owner, [
|
|
385
|
-
{ currency: sponsorshipChanges.feeAmount.currency, value: `-${sponsorshipChanges.feeAmount.value}` },
|
|
386
|
-
]);
|
|
387
|
-
}
|
|
388
396
|
}
|
|
389
397
|
function adjustBalancesChanges(balanceChanges, address, changes) {
|
|
390
398
|
const existingChanges = balanceChanges[address] || [];
|
|
@@ -13,5 +13,5 @@ interface FormattedSponsorshipSummaryInterface {
|
|
|
13
13
|
previousTxnLgrSeq?: number;
|
|
14
14
|
previousTxnID?: string;
|
|
15
15
|
}
|
|
16
|
-
declare function parseSponsorshipChanges(metadata: TransactionMetadata): FormattedSponsorshipSummaryInterface | undefined;
|
|
16
|
+
declare function parseSponsorshipChanges(metadata: TransactionMetadata): FormattedSponsorshipSummaryInterface[] | undefined;
|
|
17
17
|
export { parseSponsorshipChanges };
|
|
@@ -35,7 +35,7 @@ function summarizeSponsorship(node) {
|
|
|
35
35
|
.minus(new bignumber_js_1.default(prev.FeeAmount || 0))
|
|
36
36
|
.toString(10);
|
|
37
37
|
summary.feeAmountChange = (0, amount_1.default)(prev.FeeAmount);
|
|
38
|
-
summary.feeAmountChange.value = new bignumber_js_1.default(summary.feeAmount
|
|
38
|
+
summary.feeAmountChange.value = new bignumber_js_1.default(summary.feeAmount?.value || 0)
|
|
39
39
|
.minus(new bignumber_js_1.default(summary.feeAmountChange.value))
|
|
40
40
|
.toString(10);
|
|
41
41
|
}
|
|
@@ -55,9 +55,12 @@ function parseSponsorshipChanges(metadata) {
|
|
|
55
55
|
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
56
56
|
return node.LedgerEntryType === "Sponsorship";
|
|
57
57
|
});
|
|
58
|
-
if (affectedNodes.length
|
|
58
|
+
if (affectedNodes.length === 0) {
|
|
59
59
|
return undefined;
|
|
60
60
|
}
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
const sponsorshipChanges = affectedNodes.map((affectedNode) => {
|
|
62
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNode);
|
|
63
|
+
return summarizeSponsorship(normalizedNode);
|
|
64
|
+
});
|
|
65
|
+
return sponsorshipChanges;
|
|
63
66
|
}
|
package/lib/parse/outcome.js
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const assert = __importStar(require("assert"));
|
|
37
|
+
const common_1 = require("../../common");
|
|
38
|
+
const tx_global_flags_1 = require("../ledger/tx-global-flags");
|
|
39
|
+
const memos_1 = require("../ledger/memos");
|
|
40
|
+
const signers_1 = require("../ledger/signers");
|
|
41
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
42
|
+
const delegate_1 = require("../ledger/delegate");
|
|
43
|
+
const source_1 = require("../ledger/source");
|
|
44
|
+
function parseConfidentialMPTConvertBack(tx, nativeCurrency) {
|
|
45
|
+
assert.ok(tx.TransactionType === "ConfidentialMPTConvertBack");
|
|
46
|
+
return (0, common_1.removeUndefined)({
|
|
47
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
48
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
49
|
+
delegate: (0, delegate_1.parseDelegate)(tx),
|
|
50
|
+
source: (0, source_1.parseSource)(tx),
|
|
51
|
+
balanceCommitment: tx.BalanceCommitment,
|
|
52
|
+
blindingFactor: tx.BlindingFactor,
|
|
53
|
+
holderEncryptedAmount: tx.HolderEncryptedAmount,
|
|
54
|
+
issuerEncryptedAmount: tx.IssuerEncryptedAmount,
|
|
55
|
+
amount: {
|
|
56
|
+
value: tx.MPTAmount,
|
|
57
|
+
mpt_issuance_id: tx.MPTokenIssuanceID,
|
|
58
|
+
},
|
|
59
|
+
zkProof: tx.ZKProof,
|
|
60
|
+
flags: (0, common_1.emptyObjectToUndefined)((0, tx_global_flags_1.parseTxGlobalFlags)(tx.Flags, { nativeCurrency })),
|
|
61
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.default = parseConfidentialMPTConvertBack;
|
|
@@ -78,6 +78,7 @@ import parseMPTokenAuthorize from "./specification/mptoken-authorize";
|
|
|
78
78
|
import parseMPTokenIssuanceSet from "./specification/mptoken-issuance-set";
|
|
79
79
|
import parseMPTokenIssuanceDestroy from "./specification/mptoken-issuance-destroy";
|
|
80
80
|
import parseConfidentialMPTConvert from "./specification/confidential-mpt-convert";
|
|
81
|
+
import parseConfidentialMPTConvertBack from "./specification/confidential-mpt-convert-back";
|
|
81
82
|
import parseConfidentialMPTClawback from "./specification/confidential-mpt-clawback";
|
|
82
83
|
import parseDelegateSet from "./specification/delegate-set";
|
|
83
84
|
import parseSetRemarks from "./specification/set-remarks";
|
|
@@ -144,6 +145,7 @@ export declare const parserTypeFunc: {
|
|
|
144
145
|
MPTokenIssuanceSet: typeof parseMPTokenIssuanceSet;
|
|
145
146
|
MPTokenIssuanceDestroy: typeof parseMPTokenIssuanceDestroy;
|
|
146
147
|
ConfidentialMPTConvert: typeof parseConfidentialMPTConvert;
|
|
148
|
+
ConfidentialMPTConvertBack: typeof parseConfidentialMPTConvertBack;
|
|
147
149
|
ConfidentialMPTClawback: typeof parseConfidentialMPTClawback;
|
|
148
150
|
CredentialCreate: typeof parseCredentialCreate;
|
|
149
151
|
CredentialAccept: typeof parseCredentialAccept;
|
package/lib/parse/transaction.js
CHANGED
|
@@ -59,6 +59,7 @@ const mptoken_authorize_1 = __importDefault(require("./specification/mptoken-aut
|
|
|
59
59
|
const mptoken_issuance_set_1 = __importDefault(require("./specification/mptoken-issuance-set"));
|
|
60
60
|
const mptoken_issuance_destroy_1 = __importDefault(require("./specification/mptoken-issuance-destroy"));
|
|
61
61
|
const confidential_mpt_convert_1 = __importDefault(require("./specification/confidential-mpt-convert"));
|
|
62
|
+
const confidential_mpt_convert_back_1 = __importDefault(require("./specification/confidential-mpt-convert-back"));
|
|
62
63
|
const confidential_mpt_clawback_1 = __importDefault(require("./specification/confidential-mpt-clawback"));
|
|
63
64
|
const delegate_set_1 = __importDefault(require("./specification/delegate-set"));
|
|
64
65
|
const set_remarks_1 = __importDefault(require("./specification/set-remarks"));
|
|
@@ -126,6 +127,7 @@ const transactionTypeToType = {
|
|
|
126
127
|
MPTokenIssuanceSet: "MPTokenIssuanceSet",
|
|
127
128
|
MPTokenIssuanceDestroy: "MPTokenIssuanceDestroy",
|
|
128
129
|
ConfidentialMPTConvert: "ConfidentialMPTConvert",
|
|
130
|
+
ConfidentialMPTConvertBack: "ConfidentialMPTConvertBack",
|
|
129
131
|
ConfidentialMPTClawback: "ConfidentialMPTClawback",
|
|
130
132
|
CredentialCreate: "CredentialCreate",
|
|
131
133
|
CredentialAccept: "CredentialAccept",
|
|
@@ -195,6 +197,7 @@ exports.parserTypeFunc = {
|
|
|
195
197
|
MPTokenIssuanceSet: mptoken_issuance_set_1.default,
|
|
196
198
|
MPTokenIssuanceDestroy: mptoken_issuance_destroy_1.default,
|
|
197
199
|
ConfidentialMPTConvert: confidential_mpt_convert_1.default,
|
|
200
|
+
ConfidentialMPTConvertBack: confidential_mpt_convert_back_1.default,
|
|
198
201
|
ConfidentialMPTClawback: confidential_mpt_clawback_1.default,
|
|
199
202
|
CredentialCreate: credential_create_1.default,
|
|
200
203
|
CredentialAccept: credential_accept_1.default,
|
package/lib/types/mptokens.d.ts
CHANGED
|
@@ -83,6 +83,15 @@ export type FormattedConfidentialMPTConvertSpecification = {
|
|
|
83
83
|
mptIssuanceID?: string;
|
|
84
84
|
zkProof?: string;
|
|
85
85
|
} & FormattedBaseSpecification;
|
|
86
|
+
export type FormattedConfidentialMPTConvertBackSpecification = {
|
|
87
|
+
balanceCommitment?: string;
|
|
88
|
+
blindingFactor?: string;
|
|
89
|
+
holderEncryptedAmount?: string;
|
|
90
|
+
issuerEncryptedAmount?: string;
|
|
91
|
+
amount?: Amount;
|
|
92
|
+
mptIssuanceID?: string;
|
|
93
|
+
zkProof?: string;
|
|
94
|
+
} & FormattedBaseSpecification;
|
|
86
95
|
export type FormattedConfidentialMPTClawbackSpecification = {
|
|
87
96
|
holder?: string;
|
|
88
97
|
zkProof?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.11",
|
|
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",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
43
43
|
"lint": "eslint",
|
|
44
44
|
"prepare": "npm run build",
|
|
45
|
-
"prepublishOnly": "npm test && npm run lint",
|
|
45
|
+
"-prepublishOnly": "npm test && npm run lint",
|
|
46
46
|
"preversion": "npm run lint",
|
|
47
47
|
"version": "npm run format && git add -A src",
|
|
48
48
|
"postversion": "git push && git push --tags"
|