@bithomp/xrpl-api 3.6.5 → 3.6.9
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/models/index.d.ts +2 -1
- package/lib/models/index.js +3 -1
- package/lib/parse/ledger/mptoken-flags.d.ts +6 -0
- package/lib/parse/ledger/mptoken-flags.js +8 -0
- package/lib/parse/outcome/balance_changes.js +40 -4
- package/lib/parse/outcome/mptoken_changes.js +9 -4
- package/lib/types/mptokens.d.ts +8 -0
- package/lib/types/mptokens.js +5 -1
- package/package.json +5 -5
package/lib/models/index.d.ts
CHANGED
|
@@ -34,4 +34,5 @@ import parseTrustlineFlags from "../parse/ledger/trustline-flags";
|
|
|
34
34
|
import parseOfferFlags from "../parse/ledger/offer-flags";
|
|
35
35
|
import parseCredentialFlags from "../parse/ledger/credential-flags";
|
|
36
36
|
import parseMPTokenIssuanceFlags from "../parse/ledger/mptoken-issuance-flags";
|
|
37
|
-
|
|
37
|
+
import parseMPTokenFlags from "../parse/ledger/mptoken-flags";
|
|
38
|
+
export { parseNFTokenMint, parseNFTokenBurn, parseNFTokenFlags, parseNFTOfferFlags, parseNFTokenAcceptOffer, parseNFTokenCancelOffer, parseNFTokenCreateOffer, parseURITokenFlags, parseTrustlineFlags, parseOfferFlags, parseCredentialFlags, parseMPTokenIssuanceFlags, parseMPTokenFlags, };
|
package/lib/models/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.parseMPTokenIssuanceFlags = exports.parseCredentialFlags = exports.parseOfferFlags = exports.parseTrustlineFlags = exports.parseURITokenFlags = exports.parseNFTokenCreateOffer = exports.parseNFTokenCancelOffer = exports.parseNFTokenAcceptOffer = exports.parseNFTOfferFlags = exports.parseNFTokenFlags = exports.parseNFTokenBurn = exports.parseNFTokenMint = exports.parseMPTokenChanges = exports.parseMPTokenIssuanceChanges = exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseFinalBalances = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
20
|
+
exports.parseMPTokenFlags = exports.parseMPTokenIssuanceFlags = exports.parseCredentialFlags = exports.parseOfferFlags = exports.parseTrustlineFlags = exports.parseURITokenFlags = exports.parseNFTokenCreateOffer = exports.parseNFTokenCancelOffer = exports.parseNFTokenAcceptOffer = exports.parseNFTOfferFlags = exports.parseNFTokenFlags = exports.parseNFTokenBurn = exports.parseNFTokenMint = exports.parseMPTokenChanges = exports.parseMPTokenIssuanceChanges = exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseFinalBalances = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
21
21
|
__exportStar(require("./account_info"), exports);
|
|
22
22
|
__exportStar(require("./account_nfts"), exports);
|
|
23
23
|
__exportStar(require("./account_object"), exports);
|
|
@@ -78,3 +78,5 @@ const credential_flags_1 = __importDefault(require("../parse/ledger/credential-f
|
|
|
78
78
|
exports.parseCredentialFlags = credential_flags_1.default;
|
|
79
79
|
const mptoken_issuance_flags_1 = __importDefault(require("../parse/ledger/mptoken-issuance-flags"));
|
|
80
80
|
exports.parseMPTokenIssuanceFlags = mptoken_issuance_flags_1.default;
|
|
81
|
+
const mptoken_flags_1 = __importDefault(require("../parse/ledger/mptoken-flags"));
|
|
82
|
+
exports.parseMPTokenFlags = mptoken_flags_1.default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mptokens_1 = require("../../types/mptokens");
|
|
4
|
+
const flags_1 = require("./flags");
|
|
5
|
+
function parseMPTokenFlags(value, options = {}) {
|
|
6
|
+
return (0, flags_1.parseFlags)(value, mptokens_1.MPTokenFlagsKeys, options);
|
|
7
|
+
}
|
|
8
|
+
exports.default = parseMPTokenFlags;
|
|
@@ -10,6 +10,7 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
|
10
10
|
const common_1 = require("../../common");
|
|
11
11
|
const client_1 = require("../../client");
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
|
+
const mptoken_1 = require("../../models/mptoken");
|
|
13
14
|
function groupByAddress(balanceChanges) {
|
|
14
15
|
const grouped = lodash_1.default.groupBy(balanceChanges, function (node) {
|
|
15
16
|
return node.address;
|
|
@@ -27,7 +28,7 @@ function parseValue(value) {
|
|
|
27
28
|
if (typeof value === "string" || typeof value === "number") {
|
|
28
29
|
return new bignumber_js_1.default(value);
|
|
29
30
|
}
|
|
30
|
-
return new bignumber_js_1.default(value.value ??
|
|
31
|
+
return new bignumber_js_1.default(value.value ?? 0);
|
|
31
32
|
}
|
|
32
33
|
function computeBalanceChange(node) {
|
|
33
34
|
let value = null;
|
|
@@ -41,7 +42,16 @@ function computeBalanceChange(node) {
|
|
|
41
42
|
value = parseValue(node.finalFields.Balance).minus(parseValue(node.previousFields.Balance));
|
|
42
43
|
}
|
|
43
44
|
else if (node.previousFields.MPTAmount || node.finalFields.MPTAmount) {
|
|
44
|
-
value = parseValue(node.finalFields).minus(parseValue(node.previousFields));
|
|
45
|
+
value = parseValue(node.finalFields.MPTAmount ?? 0).minus(parseValue(node.previousFields.MPTAmount ?? 0));
|
|
46
|
+
}
|
|
47
|
+
else if (node.newFields.MaximumAmount) {
|
|
48
|
+
value = parseValue(node.newFields.MaximumAmount);
|
|
49
|
+
}
|
|
50
|
+
else if (node.diffType === "DeletedNode" && node.finalFields.MaximumAmount) {
|
|
51
|
+
value = parseValue(node.finalFields.MaximumAmount).multipliedBy(-1);
|
|
52
|
+
}
|
|
53
|
+
else if (node.previousFields.OutstandingAmount) {
|
|
54
|
+
value = parseValue(node.previousFields.OutstandingAmount ?? 0).minus(parseValue(node.finalFields.OutstandingAmount ?? 0));
|
|
45
55
|
}
|
|
46
56
|
return value === null ? null : value.isZero() ? null : value;
|
|
47
57
|
}
|
|
@@ -53,7 +63,16 @@ function parseFinalBalance(node) {
|
|
|
53
63
|
return parseValue(node.finalFields.Balance);
|
|
54
64
|
}
|
|
55
65
|
else if (node.finalFields.MPTAmount) {
|
|
56
|
-
return parseValue(node.finalFields);
|
|
66
|
+
return parseValue(node.finalFields.MPTAmount);
|
|
67
|
+
}
|
|
68
|
+
else if (node.newFields.MaximumAmount) {
|
|
69
|
+
return parseValue(node.newFields.MaximumAmount);
|
|
70
|
+
}
|
|
71
|
+
else if (node.diffType === "DeletedNode" && node.finalFields.MaximumAmount) {
|
|
72
|
+
return new bignumber_js_1.default(0);
|
|
73
|
+
}
|
|
74
|
+
else if (node.finalFields.MaximumAmount) {
|
|
75
|
+
return parseValue(node.finalFields.MaximumAmount).minus(parseValue(node.finalFields.OutstandingAmount));
|
|
57
76
|
}
|
|
58
77
|
return null;
|
|
59
78
|
}
|
|
@@ -125,10 +144,24 @@ function parseMPTQuantity(node, valueParser) {
|
|
|
125
144
|
},
|
|
126
145
|
};
|
|
127
146
|
}
|
|
147
|
+
function parseMPTokenIssuanceQuantity(node, valueParser) {
|
|
148
|
+
const value = valueParser(node);
|
|
149
|
+
if (value === null) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
|
|
153
|
+
return {
|
|
154
|
+
address: fields.Issuer,
|
|
155
|
+
balance: {
|
|
156
|
+
value: value.toString(),
|
|
157
|
+
mpt_issuance_id: (0, mptoken_1.buildMPTokenIssuanceID)(fields.Sequence, fields.Issuer),
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
128
161
|
function parseQuantities(metadata, valueParser, nativeCurrency) {
|
|
129
162
|
const values = metadata.AffectedNodes.map(function (affectedNode) {
|
|
130
163
|
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
131
|
-
if (!["AccountRoot", "RippleState", "MPToken"].includes(node.LedgerEntryType)) {
|
|
164
|
+
if (!["AccountRoot", "RippleState", "MPToken", "MPTokenIssuance"].includes(node.LedgerEntryType)) {
|
|
132
165
|
return [];
|
|
133
166
|
}
|
|
134
167
|
const normalizedNode = (0, utils_1.normalizeNode)(affectedNode);
|
|
@@ -141,6 +174,9 @@ function parseQuantities(metadata, valueParser, nativeCurrency) {
|
|
|
141
174
|
else if (node.LedgerEntryType === "MPToken") {
|
|
142
175
|
return [parseMPTQuantity(normalizedNode, valueParser)];
|
|
143
176
|
}
|
|
177
|
+
else if (node.LedgerEntryType === "MPTokenIssuance") {
|
|
178
|
+
return [parseMPTokenIssuanceQuantity(normalizedNode, valueParser)];
|
|
179
|
+
}
|
|
144
180
|
return [];
|
|
145
181
|
});
|
|
146
182
|
return groupByAddress(lodash_1.default.compact(lodash_1.default.flatten(values)));
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.parseMPTokenChanges = parseMPTokenChanges;
|
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
8
|
const common_1 = require("../../common");
|
|
9
|
+
const mptoken_flags_1 = __importDefault(require("../ledger/mptoken-flags"));
|
|
9
10
|
function parseMPTokenChanges(tx) {
|
|
10
11
|
return new MPTokenChanges(tx).call();
|
|
11
12
|
}
|
|
@@ -45,7 +46,7 @@ class MPTokenChanges {
|
|
|
45
46
|
const account = node.NewFields.Account;
|
|
46
47
|
this.addChange(mptIssuanceID, account, {
|
|
47
48
|
status: "added",
|
|
48
|
-
flags: node.NewFields.Flags,
|
|
49
|
+
flags: (0, mptoken_flags_1.default)(node.NewFields.Flags),
|
|
49
50
|
mptIssuanceID,
|
|
50
51
|
account,
|
|
51
52
|
amount: node.NewFields.MPTAmount,
|
|
@@ -60,14 +61,18 @@ class MPTokenChanges {
|
|
|
60
61
|
if (amountChange === "0") {
|
|
61
62
|
amountChange = undefined;
|
|
62
63
|
}
|
|
64
|
+
let flagsChange;
|
|
65
|
+
if (node.PreviousFields?.Flags !== undefined) {
|
|
66
|
+
flagsChange = (0, mptoken_flags_1.default)(node.PreviousFields.Flags);
|
|
67
|
+
}
|
|
63
68
|
this.addChange(mptIssuanceID, account, {
|
|
64
69
|
status: "modified",
|
|
65
|
-
flags: node.FinalFields.Flags,
|
|
70
|
+
flags: (0, mptoken_flags_1.default)(node.FinalFields.Flags),
|
|
66
71
|
mptIssuanceID,
|
|
67
72
|
account,
|
|
68
73
|
amount: node.FinalFields.MPTAmount,
|
|
69
74
|
amountChange,
|
|
70
|
-
flagsChange
|
|
75
|
+
flagsChange,
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
78
|
if (affectedNode.DeletedNode) {
|
|
@@ -75,7 +80,7 @@ class MPTokenChanges {
|
|
|
75
80
|
const account = node.FinalFields.Account;
|
|
76
81
|
this.addChange(mptIssuanceID, account, {
|
|
77
82
|
status: "removed",
|
|
78
|
-
flags: node.FinalFields.Flags,
|
|
83
|
+
flags: (0, mptoken_flags_1.default)(node.FinalFields.Flags),
|
|
79
84
|
mptIssuanceID,
|
|
80
85
|
account,
|
|
81
86
|
amount: node.FinalFields.MPTAmount,
|
package/lib/types/mptokens.d.ts
CHANGED
|
@@ -74,3 +74,11 @@ export type FormattedMPTokenIssuanceSetSpecification = {
|
|
|
74
74
|
holder?: string;
|
|
75
75
|
mptIssuanceID?: string;
|
|
76
76
|
} & FormattedBaseSpecification;
|
|
77
|
+
export declare const MPTokenFlagsKeys: {
|
|
78
|
+
locked: number;
|
|
79
|
+
authorized: number;
|
|
80
|
+
};
|
|
81
|
+
export interface MPTokenFlagsKeysInterface {
|
|
82
|
+
locked?: boolean;
|
|
83
|
+
authorized?: boolean;
|
|
84
|
+
}
|
package/lib/types/mptokens.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MPTokenAuthorizeFlagsKeys = exports.MPTokenIssuanceSetFlagsKeys = exports.MPTokenIssuanceCreateFlagsKeys = exports.MPTokenIssuanceFlagsKeys = void 0;
|
|
3
|
+
exports.MPTokenFlagsKeys = exports.MPTokenAuthorizeFlagsKeys = exports.MPTokenIssuanceSetFlagsKeys = exports.MPTokenIssuanceCreateFlagsKeys = exports.MPTokenIssuanceFlagsKeys = void 0;
|
|
4
4
|
exports.getMPTokenIssuanceCreateFlagsKeys = getMPTokenIssuanceCreateFlagsKeys;
|
|
5
5
|
exports.getMPTokenIssuanceSetFlagsKeys = getMPTokenIssuanceSetFlagsKeys;
|
|
6
6
|
exports.getMPTokenAuthorizeFlagsKeys = getMPTokenAuthorizeFlagsKeys;
|
|
@@ -70,3 +70,7 @@ function getMPTokenAuthorizeFlagsKeys(nativeCurrency) {
|
|
|
70
70
|
}
|
|
71
71
|
return nativeCurrencyMPTokenAuthorizeFlags[nativeCurrency];
|
|
72
72
|
}
|
|
73
|
+
exports.MPTokenFlagsKeys = {
|
|
74
|
+
locked: 0x00000001,
|
|
75
|
+
authorized: 0x00000002,
|
|
76
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.9",
|
|
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",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
44
44
|
"lint": "eslint",
|
|
45
45
|
"prepare": "npm run build",
|
|
46
|
-
"
|
|
46
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
47
47
|
"preversion": "npm run lint",
|
|
48
48
|
"version": "npm run format && git add -A src",
|
|
49
49
|
"postversion": "git push && git push --tags"
|
|
@@ -74,16 +74,16 @@
|
|
|
74
74
|
"@typescript-eslint/parser": "^8.45.0",
|
|
75
75
|
"chai": "^6.2.0",
|
|
76
76
|
"chai-as-promised": "^8.0.2",
|
|
77
|
-
"eslint": "^9.
|
|
77
|
+
"eslint": "^9.37.0",
|
|
78
78
|
"eslint-config-prettier": "^10.1.8",
|
|
79
79
|
"eslint-plugin-chai-friendly": "^1.1.0",
|
|
80
80
|
"eslint-plugin-import": "^2.32.0",
|
|
81
81
|
"eslint-plugin-n": "^17.23.1",
|
|
82
82
|
"eslint-plugin-promise": "^7.2.1",
|
|
83
|
-
"mocha": "^11.7.
|
|
83
|
+
"mocha": "^11.7.4",
|
|
84
84
|
"nconf": "^0.13.0",
|
|
85
85
|
"ts-jest": "^29.4.4",
|
|
86
86
|
"ts-node": "^10.9.2",
|
|
87
|
-
"typescript": "^5.9.
|
|
87
|
+
"typescript": "^5.9.3"
|
|
88
88
|
}
|
|
89
89
|
}
|