@bithomp/xrpl-api 3.2.13 → 3.2.15
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/README.md
CHANGED
|
@@ -168,7 +168,7 @@ const vl = await BithompXRPL.Client.createVLv2(vk, sk, [publishBlob, publishBlob
|
|
|
168
168
|
|
|
169
169
|
// vl will contain the signed validator list with
|
|
170
170
|
// {
|
|
171
|
-
// "
|
|
171
|
+
// "blobs_v2": "...",
|
|
172
172
|
// "manifest": "...", // signed with vk.privateKey and sk.privateKey
|
|
173
173
|
// "version": 2,
|
|
174
174
|
// "public_key": "..." // vk.publicKey
|
package/lib/ledger/vl-v2.js
CHANGED
|
@@ -107,7 +107,7 @@ async function createVLv2(masterKey, ephemeralKey, publishBlobs) {
|
|
|
107
107
|
MasterPrivateKey: masterKey.privateKey,
|
|
108
108
|
});
|
|
109
109
|
return {
|
|
110
|
-
"
|
|
110
|
+
"blobs_v2": blobs,
|
|
111
111
|
manifest: globalManifest,
|
|
112
112
|
public_key: masterKey.publicKey,
|
|
113
113
|
version: 2,
|
package/lib/models/vl.d.ts
CHANGED
package/lib/models/vl.js
CHANGED
|
@@ -102,10 +102,13 @@ function parseVL(vl) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
else if (decoded.version === 2) {
|
|
105
|
-
const blobs = vl["blobs-v2"];
|
|
105
|
+
const blobs = (vl["blobs-v2"] || vl["blobs_v2"]);
|
|
106
106
|
if (!decoded.blobs) {
|
|
107
107
|
decoded.blobs = [];
|
|
108
108
|
}
|
|
109
|
+
if (!blobs) {
|
|
110
|
+
return decoded;
|
|
111
|
+
}
|
|
109
112
|
for (const blobInfo of blobs) {
|
|
110
113
|
const blob = decodeVLBlob(blobInfo.blob);
|
|
111
114
|
error = isValidVLBlob(blob);
|
|
@@ -188,7 +191,10 @@ function isValidVL(vl) {
|
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
193
|
else if (vl.version === 2) {
|
|
191
|
-
const blobs = vl["blobs-v2"];
|
|
194
|
+
const blobs = (vl["blobs-v2"] || vl["blobs_v2"]);
|
|
195
|
+
if (!blobs) {
|
|
196
|
+
return "blobs_v2 missing from vl";
|
|
197
|
+
}
|
|
192
198
|
for (const blobInfo of blobs) {
|
|
193
199
|
const blob = decodeVLBlob(blobInfo.blob);
|
|
194
200
|
error = isValidVLBlob(blob);
|
|
@@ -226,17 +232,18 @@ function isValidVLFormat(vl) {
|
|
|
226
232
|
}
|
|
227
233
|
}
|
|
228
234
|
else if (version === 2) {
|
|
235
|
+
const blobs = (vl["blobs-v2"] || vl["blobs_v2"]);
|
|
229
236
|
if (blob !== undefined) {
|
|
230
237
|
error = "Blob should not be present in vl version 2";
|
|
231
238
|
}
|
|
232
|
-
else if (
|
|
233
|
-
error = "
|
|
239
|
+
else if (blobs === undefined) {
|
|
240
|
+
error = "blobs_v2 missing from vl";
|
|
234
241
|
}
|
|
235
|
-
else if (!Array.isArray(
|
|
236
|
-
error = "
|
|
242
|
+
else if (!Array.isArray(blobs)) {
|
|
243
|
+
error = "blobs_v2 should be an array";
|
|
237
244
|
}
|
|
238
|
-
else if (
|
|
239
|
-
error = "
|
|
245
|
+
else if (blobs.length === 0) {
|
|
246
|
+
error = "blobs_v2 should not be empty";
|
|
240
247
|
}
|
|
241
248
|
}
|
|
242
249
|
else {
|
|
@@ -75,7 +75,7 @@ function flipTrustlinePerspective(quantity) {
|
|
|
75
75
|
return {
|
|
76
76
|
address: quantity.balance.issuer,
|
|
77
77
|
balance: {
|
|
78
|
-
issuer: quantity.
|
|
78
|
+
issuer: quantity.balance.issuer,
|
|
79
79
|
currency: quantity.balance.currency,
|
|
80
80
|
value: negatedBalance.toString(),
|
|
81
81
|
counterparty: quantity.address,
|
|
@@ -88,13 +88,25 @@ function parseTrustlineQuantity(node, valueParser) {
|
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
90
|
const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
|
|
91
|
+
const previousFields = node.previousFields;
|
|
92
|
+
let viewLowest = true;
|
|
93
|
+
if (previousFields && previousFields.Balance && previousFields.Balance.value !== "0") {
|
|
94
|
+
viewLowest = previousFields.Balance.value[0] !== "-";
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
viewLowest = fields.Balance.value[0] !== "-";
|
|
98
|
+
}
|
|
99
|
+
const sign = viewLowest ? 1 : -1;
|
|
100
|
+
const currency = fields.Balance.currency;
|
|
101
|
+
const issuer = viewLowest ? fields.HighLimit.issuer : fields.LowLimit.issuer;
|
|
102
|
+
const holder = viewLowest ? fields.LowLimit.issuer : fields.HighLimit.issuer;
|
|
91
103
|
const result = {
|
|
92
|
-
address:
|
|
104
|
+
address: holder,
|
|
93
105
|
balance: {
|
|
94
|
-
issuer
|
|
95
|
-
currency
|
|
96
|
-
value: value.toString(),
|
|
97
|
-
counterparty:
|
|
106
|
+
issuer,
|
|
107
|
+
currency,
|
|
108
|
+
value: value.times(sign).toString(),
|
|
109
|
+
counterparty: issuer,
|
|
98
110
|
},
|
|
99
111
|
};
|
|
100
112
|
return [result, flipTrustlinePerspective(result)];
|
|
@@ -49,14 +49,25 @@ function parseTrustlineQuantity(node, valueParser) {
|
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
51
|
const fields = lodash_1.default.isEmpty(node.newFields) ? node.finalFields : node.newFields;
|
|
52
|
-
const
|
|
52
|
+
const previousFields = node.previousFields;
|
|
53
|
+
let viewLowest = true;
|
|
54
|
+
if (previousFields && previousFields.Balance && previousFields.Balance.value !== "0") {
|
|
55
|
+
viewLowest = previousFields.Balance.value[0] !== "-";
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
viewLowest = fields.Balance.value[0] !== "-";
|
|
59
|
+
}
|
|
60
|
+
const sign = viewLowest ? 1 : -1;
|
|
61
|
+
const currency = fields.Balance.currency;
|
|
62
|
+
const issuer = viewLowest ? fields.HighLimit.issuer : fields.LowLimit.issuer;
|
|
63
|
+
const holder = viewLowest ? fields.LowLimit.issuer : fields.HighLimit.issuer;
|
|
53
64
|
const result = {
|
|
54
|
-
address:
|
|
65
|
+
address: holder,
|
|
55
66
|
lockedBalance: {
|
|
56
|
-
issuer
|
|
57
|
-
currency
|
|
58
|
-
value: value.toString(),
|
|
59
|
-
counterparty:
|
|
67
|
+
issuer,
|
|
68
|
+
currency,
|
|
69
|
+
value: value.times(sign).toString(),
|
|
70
|
+
counterparty: issuer,
|
|
60
71
|
},
|
|
61
72
|
};
|
|
62
73
|
return [result];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.15",
|
|
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",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"elliptic": "^6.6.1",
|
|
59
59
|
"lodash": "^4.17.21",
|
|
60
60
|
"ripple-address-codec": "^5.0.0",
|
|
61
|
-
"ripple-binary-codec": "^2.
|
|
62
|
-
"xrpl": "^4.
|
|
61
|
+
"ripple-binary-codec": "^2.3.0",
|
|
62
|
+
"xrpl": "^4.2.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@eslint/eslintrc": "^3.2.0",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"@types/lodash": "^4.17.15",
|
|
69
69
|
"@types/mocha": "^10.0.10",
|
|
70
70
|
"@types/nconf": "^0.10.7",
|
|
71
|
-
"@types/node": "^22.13.
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
73
|
-
"@typescript-eslint/parser": "^8.
|
|
71
|
+
"@types/node": "^22.13.4",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^8.24.1",
|
|
73
|
+
"@typescript-eslint/parser": "^8.24.1",
|
|
74
74
|
"chai": "^4.5.0",
|
|
75
75
|
"chai-as-promised": "^7.1.2",
|
|
76
|
-
"eslint": "^9.20.
|
|
76
|
+
"eslint": "^9.20.1",
|
|
77
77
|
"eslint-config-prettier": "^10.0.1",
|
|
78
78
|
"eslint-plugin-chai-friendly": "^1.0.1",
|
|
79
79
|
"eslint-plugin-import": "^2.31.0",
|