@aboutcircles/sdk 0.1.32 → 0.1.33
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/dist/index.js +687 -687
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1063,10 +1063,10 @@ function o0(J, $) {
|
|
|
1063
1063
|
}
|
|
1064
1064
|
function p$(J) {
|
|
1065
1065
|
let { event: $, values: Q } = J, Y = { $event: $, blockNumber: Q.blockNumber ? Q$(Q.blockNumber) : 0, timestamp: Q.timestamp ? Q$(Q.timestamp) : undefined, transactionIndex: Q.transactionIndex ? Q$(Q.transactionIndex) : 0, logIndex: Q.logIndex ? Q$(Q.logIndex) : 0, transactionHash: Q.transactionHash };
|
|
1066
|
-
for (let [
|
|
1067
|
-
if (["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash"].includes(
|
|
1066
|
+
for (let [G, M3] of Object.entries(Q)) {
|
|
1067
|
+
if (["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash"].includes(G))
|
|
1068
1068
|
continue;
|
|
1069
|
-
Y[
|
|
1069
|
+
Y[G] = o0(G, M3);
|
|
1070
1070
|
}
|
|
1071
1071
|
return Y;
|
|
1072
1072
|
}
|
|
@@ -1162,12 +1162,12 @@ class VJ {
|
|
|
1162
1162
|
let Y = await fetch(this.rpcUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(Q) });
|
|
1163
1163
|
if (!Y.ok)
|
|
1164
1164
|
throw c3.connectionFailed(this.rpcUrl, Error(`HTTP ${Y.status}: ${Y.statusText}`));
|
|
1165
|
-
let
|
|
1166
|
-
if (
|
|
1167
|
-
throw c3.fromJsonRpcError(
|
|
1168
|
-
if (
|
|
1169
|
-
throw c3.invalidResponse(J,
|
|
1170
|
-
return
|
|
1165
|
+
let G = await Y.json();
|
|
1166
|
+
if (G.error)
|
|
1167
|
+
throw c3.fromJsonRpcError(G.error);
|
|
1168
|
+
if (G.result === undefined)
|
|
1169
|
+
throw c3.invalidResponse(J, G);
|
|
1170
|
+
return G.result;
|
|
1171
1171
|
} catch (Y) {
|
|
1172
1172
|
if (Y instanceof c3)
|
|
1173
1173
|
throw Y;
|
|
@@ -1190,9 +1190,9 @@ class VJ {
|
|
|
1190
1190
|
this.websocket = new WebSocket(Q), this.websocket.onopen = () => {
|
|
1191
1191
|
console.log("WebSocket connected"), this.websocketConnected = true, this.reconnectAttempt = 0, J();
|
|
1192
1192
|
}, this.websocket.onmessage = (Y) => {
|
|
1193
|
-
let
|
|
1194
|
-
if (
|
|
1195
|
-
this.pendingResponses[
|
|
1193
|
+
let G = JSON.parse(Y.data), { id: M3, method: Z, params: K } = G;
|
|
1194
|
+
if (M3 !== undefined && this.pendingResponses[M3])
|
|
1195
|
+
this.pendingResponses[M3].resolve(G), delete this.pendingResponses[M3];
|
|
1196
1196
|
if (Z === "circles_subscription" && K?.result)
|
|
1197
1197
|
Object.values(this.subscriptionListeners).forEach((X) => {
|
|
1198
1198
|
X.forEach((q) => q(K.result));
|
|
@@ -1229,10 +1229,10 @@ class VJ {
|
|
|
1229
1229
|
this.activeSubscriptions = [];
|
|
1230
1230
|
for (let $ of J)
|
|
1231
1231
|
try {
|
|
1232
|
-
let Q = $.address ? { address: $.address } : {},
|
|
1233
|
-
if (
|
|
1234
|
-
this.subscriptionListeners[
|
|
1235
|
-
this.activeSubscriptions.push({ id:
|
|
1232
|
+
let Q = $.address ? { address: $.address } : {}, G = (await this.sendMessage("circles_subscribe", Q)).result, M3 = this.subscriptionListeners[$.id];
|
|
1233
|
+
if (M3)
|
|
1234
|
+
this.subscriptionListeners[G] = M3, delete this.subscriptionListeners[$.id];
|
|
1235
|
+
this.activeSubscriptions.push({ id: G, address: $.address });
|
|
1236
1236
|
} catch (Q) {
|
|
1237
1237
|
console.error("Failed to re-issue circles_subscribe after reconnect:", Q), this.activeSubscriptions.push($);
|
|
1238
1238
|
}
|
|
@@ -1240,9 +1240,9 @@ class VJ {
|
|
|
1240
1240
|
sendMessage(J, $, Q = 5000) {
|
|
1241
1241
|
if (!this.websocket || this.websocket.readyState !== WebSocket.OPEN)
|
|
1242
1242
|
return Promise.reject(c3.connectionFailed(this.rpcUrl));
|
|
1243
|
-
let Y = this.requestId++,
|
|
1244
|
-
return new Promise((
|
|
1245
|
-
this.pendingResponses[Y] = { resolve:
|
|
1243
|
+
let Y = this.requestId++, G = { jsonrpc: "2.0", method: J, params: $, id: Y };
|
|
1244
|
+
return new Promise((M3, Z) => {
|
|
1245
|
+
this.pendingResponses[Y] = { resolve: M3, reject: Z }, this.websocket.send(JSON.stringify(G)), setTimeout(() => {
|
|
1246
1246
|
if (this.pendingResponses[Y])
|
|
1247
1247
|
this.pendingResponses[Y].reject(c3.timeout(J, Q)), delete this.pendingResponses[Y];
|
|
1248
1248
|
}, Q);
|
|
@@ -1252,12 +1252,12 @@ class VJ {
|
|
|
1252
1252
|
let $ = J?.toLowerCase();
|
|
1253
1253
|
if (!this.websocketConnected)
|
|
1254
1254
|
await this.connect();
|
|
1255
|
-
let Q = lJ.create(), Y = $ ? { address: $ } : {},
|
|
1256
|
-
if (!this.subscriptionListeners[
|
|
1257
|
-
this.subscriptionListeners[
|
|
1258
|
-
return this.subscriptionListeners[
|
|
1255
|
+
let Q = lJ.create(), Y = $ ? { address: $ } : {}, M3 = (await this.sendMessage("circles_subscribe", Y)).result;
|
|
1256
|
+
if (!this.subscriptionListeners[M3])
|
|
1257
|
+
this.subscriptionListeners[M3] = [];
|
|
1258
|
+
return this.subscriptionListeners[M3].push((Z) => {
|
|
1259
1259
|
I$(Z).forEach((K) => Q.emit(K));
|
|
1260
|
-
}), this.activeSubscriptions.push({ id:
|
|
1260
|
+
}), this.activeSubscriptions.push({ id: M3, address: $ }), Q.property;
|
|
1261
1261
|
}
|
|
1262
1262
|
}
|
|
1263
1263
|
var H$ = BigInt(4294967295);
|
|
@@ -1268,12 +1268,12 @@ function s0(J, $ = false) {
|
|
|
1268
1268
|
return { h: Number(J >> g8 & H$) | 0, l: Number(J & H$) | 0 };
|
|
1269
1269
|
}
|
|
1270
1270
|
function v8(J, $ = false) {
|
|
1271
|
-
let Q = J.length, Y = new Uint32Array(Q),
|
|
1272
|
-
for (let
|
|
1273
|
-
let { h: Z, l: K } = s0(J[
|
|
1274
|
-
[Y[
|
|
1271
|
+
let Q = J.length, Y = new Uint32Array(Q), G = new Uint32Array(Q);
|
|
1272
|
+
for (let M3 = 0;M3 < Q; M3++) {
|
|
1273
|
+
let { h: Z, l: K } = s0(J[M3], $);
|
|
1274
|
+
[Y[M3], G[M3]] = [Z, K];
|
|
1275
1275
|
}
|
|
1276
|
-
return [Y,
|
|
1276
|
+
return [Y, G];
|
|
1277
1277
|
}
|
|
1278
1278
|
var u8 = (J, $, Q) => J << Q | $ >>> 32 - Q;
|
|
1279
1279
|
var m8 = (J, $, Q) => $ << Q | J >>> 32 - Q;
|
|
@@ -1290,9 +1290,9 @@ function d$(J, $ = "") {
|
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
1292
|
function S$(J, $, Q = "") {
|
|
1293
|
-
let Y = r0(J),
|
|
1294
|
-
if (!Y ||
|
|
1295
|
-
let Z = Q && `"${Q}" `, K =
|
|
1293
|
+
let Y = r0(J), G = J?.length, M3 = $ !== undefined;
|
|
1294
|
+
if (!Y || M3 && G !== $) {
|
|
1295
|
+
let Z = Q && `"${Q}" `, K = M3 ? ` of length ${$}` : "", X = Y ? `length=${G}` : `type=${typeof J}`;
|
|
1296
1296
|
throw Error(Z + "expected Uint8Array" + K + ", got " + X);
|
|
1297
1297
|
}
|
|
1298
1298
|
return J;
|
|
@@ -1327,25 +1327,25 @@ function $Q(J) {
|
|
|
1327
1327
|
}
|
|
1328
1328
|
var t$ = e0 ? (J) => J : $Q;
|
|
1329
1329
|
function d8(J, $ = {}) {
|
|
1330
|
-
let Q = (
|
|
1331
|
-
return Q.outputLen = Y.outputLen, Q.blockLen = Y.blockLen, Q.create = (
|
|
1330
|
+
let Q = (G, M3) => J(M3).update(G).digest(), Y = J(undefined);
|
|
1331
|
+
return Q.outputLen = Y.outputLen, Q.blockLen = Y.blockLen, Q.create = (G) => J(G), Object.assign(Q, $), Object.freeze(Q);
|
|
1332
1332
|
}
|
|
1333
1333
|
var QQ = BigInt(0);
|
|
1334
|
-
var
|
|
1334
|
+
var G$ = BigInt(1);
|
|
1335
1335
|
var YQ = BigInt(2);
|
|
1336
|
-
var
|
|
1337
|
-
var
|
|
1336
|
+
var GQ = BigInt(7);
|
|
1337
|
+
var MQ = BigInt(256);
|
|
1338
1338
|
var ZQ = BigInt(113);
|
|
1339
1339
|
var t8 = [];
|
|
1340
1340
|
var o8 = [];
|
|
1341
1341
|
var a8 = [];
|
|
1342
|
-
for (let J = 0, $ =
|
|
1342
|
+
for (let J = 0, $ = G$, Q = 1, Y = 0;J < 24; J++) {
|
|
1343
1343
|
[Q, Y] = [Y, (2 * Q + 3 * Y) % 5], t8.push(2 * (5 * Y + Q)), o8.push((J + 1) * (J + 2) / 2 % 64);
|
|
1344
|
-
let
|
|
1345
|
-
for (let
|
|
1346
|
-
if ($ = ($ <<
|
|
1347
|
-
|
|
1348
|
-
a8.push(
|
|
1344
|
+
let G = QQ;
|
|
1345
|
+
for (let M3 = 0;M3 < 7; M3++)
|
|
1346
|
+
if ($ = ($ << G$ ^ ($ >> GQ) * ZQ) % MQ, $ & YQ)
|
|
1347
|
+
G ^= G$ << (G$ << BigInt(M3)) - G$;
|
|
1348
|
+
a8.push(G);
|
|
1349
1349
|
}
|
|
1350
1350
|
var s8 = v8(a8, true);
|
|
1351
1351
|
var XQ = s8[0];
|
|
@@ -1362,10 +1362,10 @@ function qQ(J, $ = 24) {
|
|
|
1362
1362
|
for (let O3 = 0;O3 < 50; O3 += 10)
|
|
1363
1363
|
J[Z + O3] ^= D3, J[Z + O3 + 1] ^= V;
|
|
1364
1364
|
}
|
|
1365
|
-
let
|
|
1365
|
+
let G = J[2], M3 = J[3];
|
|
1366
1366
|
for (let Z = 0;Z < 24; Z++) {
|
|
1367
|
-
let K = o8[Z], X = n8(
|
|
1368
|
-
|
|
1367
|
+
let K = o8[Z], X = n8(G, M3, K), q = i8(G, M3, K), U = t8[Z];
|
|
1368
|
+
G = J[U], M3 = J[U + 1], J[U] = X, J[U + 1] = q;
|
|
1369
1369
|
}
|
|
1370
1370
|
for (let Z = 0;Z < 50; Z += 10) {
|
|
1371
1371
|
for (let K = 0;K < 10; K++)
|
|
@@ -1390,8 +1390,8 @@ class o$ {
|
|
|
1390
1390
|
outputLen;
|
|
1391
1391
|
enableXOF = false;
|
|
1392
1392
|
rounds;
|
|
1393
|
-
constructor(J, $, Q, Y = false,
|
|
1394
|
-
if (this.blockLen = J, this.suffix = $, this.outputLen = Q, this.enableXOF = Y, this.rounds =
|
|
1393
|
+
constructor(J, $, Q, Y = false, G = 24) {
|
|
1394
|
+
if (this.blockLen = J, this.suffix = $, this.outputLen = Q, this.enableXOF = Y, this.rounds = G, d$(Q, "outputLen"), !(0 < J && J < 200))
|
|
1395
1395
|
throw Error("only keccak-f1600 function is supported");
|
|
1396
1396
|
this.state = new Uint8Array(200), this.state32 = p8(this.state);
|
|
1397
1397
|
}
|
|
@@ -1404,10 +1404,10 @@ class o$ {
|
|
|
1404
1404
|
update(J) {
|
|
1405
1405
|
n$(this), S$(J);
|
|
1406
1406
|
let { blockLen: $, state: Q } = this, Y = J.length;
|
|
1407
|
-
for (let
|
|
1408
|
-
let
|
|
1409
|
-
for (let Z = 0;Z <
|
|
1410
|
-
Q[this.pos++] ^= J[
|
|
1407
|
+
for (let G = 0;G < Y; ) {
|
|
1408
|
+
let M3 = Math.min($ - this.pos, Y - G);
|
|
1409
|
+
for (let Z = 0;Z < M3; Z++)
|
|
1410
|
+
Q[this.pos++] ^= J[G++];
|
|
1411
1411
|
if (this.pos === $)
|
|
1412
1412
|
this.keccak();
|
|
1413
1413
|
}
|
|
@@ -1425,11 +1425,11 @@ class o$ {
|
|
|
1425
1425
|
writeInto(J) {
|
|
1426
1426
|
n$(this, false), S$(J), this.finish();
|
|
1427
1427
|
let $ = this.state, { blockLen: Q } = this;
|
|
1428
|
-
for (let Y = 0,
|
|
1428
|
+
for (let Y = 0, G = J.length;Y < G; ) {
|
|
1429
1429
|
if (this.posOut >= Q)
|
|
1430
1430
|
this.keccak();
|
|
1431
|
-
let
|
|
1432
|
-
J.set($.subarray(this.posOut, this.posOut +
|
|
1431
|
+
let M3 = Math.min(Q - this.posOut, G - Y);
|
|
1432
|
+
J.set($.subarray(this.posOut, this.posOut + M3), Y), this.posOut += M3, Y += M3;
|
|
1433
1433
|
}
|
|
1434
1434
|
return J;
|
|
1435
1435
|
}
|
|
@@ -1453,8 +1453,8 @@ class o$ {
|
|
|
1453
1453
|
this.destroyed = true, i$(this.state);
|
|
1454
1454
|
}
|
|
1455
1455
|
_cloneInto(J) {
|
|
1456
|
-
let { blockLen: $, suffix: Q, outputLen: Y, rounds:
|
|
1457
|
-
return J ||= new o$($, Q, Y,
|
|
1456
|
+
let { blockLen: $, suffix: Q, outputLen: Y, rounds: G, enableXOF: M3 } = this;
|
|
1457
|
+
return J ||= new o$($, Q, Y, M3, G), J.state32.set(this.state32), J.pos = this.pos, J.posOut = this.posOut, J.finished = this.finished, J.rounds = G, J.suffix = Q, J.outputLen = Y, J.enableXOF = M3, J.destroyed = this.destroyed, J;
|
|
1458
1458
|
}
|
|
1459
1459
|
}
|
|
1460
1460
|
var UQ = (J, $, Q, Y = {}) => d8(() => new o$($, J, Q), Y);
|
|
@@ -1477,16 +1477,16 @@ function y$(J) {
|
|
|
1477
1477
|
var g3 = 64;
|
|
1478
1478
|
var w$ = 32;
|
|
1479
1479
|
var A$ = (J) => J.startsWith("0x") ? J.slice(2) : J;
|
|
1480
|
-
var
|
|
1480
|
+
var MJ = (J) => J.toString(16).padStart(g3, "0");
|
|
1481
1481
|
function OJ(J) {
|
|
1482
1482
|
let $ = J.toLowerCase().replace("0x", ""), Q = _$(cJ(new TextEncoder().encode($))).slice(2), Y = "0x";
|
|
1483
|
-
for (let
|
|
1484
|
-
Y += parseInt(Q[
|
|
1483
|
+
for (let G = 0;G < $.length; G++)
|
|
1484
|
+
Y += parseInt(Q[G], 16) >= 8 ? $[G].toUpperCase() : $[G];
|
|
1485
1485
|
return Y;
|
|
1486
1486
|
}
|
|
1487
1487
|
function a$(J, $) {
|
|
1488
1488
|
if (J === "tuple" && $)
|
|
1489
|
-
return `(${$.map((
|
|
1489
|
+
return `(${$.map((G) => a$(G.type, G.components)).join(",")})`;
|
|
1490
1490
|
let Q = J.match(/^tuple(\[\d*\])$/);
|
|
1491
1491
|
if (Q && $)
|
|
1492
1492
|
return `${a$("tuple", $)}${Q[1]}`;
|
|
@@ -1526,34 +1526,34 @@ function NJ(J, $, Q) {
|
|
|
1526
1526
|
return VQ(J, $);
|
|
1527
1527
|
}
|
|
1528
1528
|
function zQ(J, $, Q) {
|
|
1529
|
-
let Y = J.slice(0, J.indexOf("[")),
|
|
1530
|
-
if (
|
|
1529
|
+
let Y = J.slice(0, J.indexOf("[")), G = J.endsWith("[]"), M3 = pJ(Y, Q), Z;
|
|
1530
|
+
if (M3) {
|
|
1531
1531
|
let K = $.map((U) => NJ(Y, U, Q)), X = $.length * w$;
|
|
1532
1532
|
Z = K.map((U) => {
|
|
1533
1533
|
let D3 = X;
|
|
1534
|
-
return X += U.length / 2,
|
|
1534
|
+
return X += U.length / 2, MJ(D3);
|
|
1535
1535
|
}).join("") + K.join("");
|
|
1536
1536
|
} else
|
|
1537
1537
|
Z = $.map((K) => NJ(Y, K, Q)).join("");
|
|
1538
|
-
return
|
|
1538
|
+
return G ? MJ($.length) + Z : Z;
|
|
1539
1539
|
}
|
|
1540
1540
|
function DQ(J, $) {
|
|
1541
|
-
let Q = Array.isArray($), Y = [],
|
|
1541
|
+
let Q = Array.isArray($), Y = [], G = [], M3 = [];
|
|
1542
1542
|
for (let Z = 0;Z < J.length; Z++) {
|
|
1543
1543
|
let K = J[Z], X = Q ? $[Z] : $[K.name || ""], q = pJ(K.type, K.components);
|
|
1544
|
-
if (
|
|
1545
|
-
Y.push(""),
|
|
1544
|
+
if (M3.push(q), q)
|
|
1545
|
+
Y.push(""), G.push(NJ(K.type, X, K.components));
|
|
1546
1546
|
else
|
|
1547
1547
|
Y.push(NJ(K.type, X, K.components));
|
|
1548
1548
|
}
|
|
1549
|
-
if (
|
|
1550
|
-
let Z = Y.reduce((q, U, D3) => q + (
|
|
1549
|
+
if (G.length > 0) {
|
|
1550
|
+
let Z = Y.reduce((q, U, D3) => q + (M3[D3] ? w$ : U.length / 2), 0), K = "", X = 0;
|
|
1551
1551
|
for (let q = 0;q < J.length; q++)
|
|
1552
|
-
if (
|
|
1553
|
-
K +=
|
|
1552
|
+
if (M3[q])
|
|
1553
|
+
K += MJ(Z), Z += G[X].length / 2, X++;
|
|
1554
1554
|
else
|
|
1555
1555
|
K += Y[q];
|
|
1556
|
-
return K +
|
|
1556
|
+
return K + G.join("");
|
|
1557
1557
|
}
|
|
1558
1558
|
return Y.join("");
|
|
1559
1559
|
}
|
|
@@ -1561,10 +1561,10 @@ function VQ(J, $) {
|
|
|
1561
1561
|
if (J === "address")
|
|
1562
1562
|
return A$($).toLowerCase().padStart(g3, "0");
|
|
1563
1563
|
if (J === "bool")
|
|
1564
|
-
return
|
|
1564
|
+
return MJ($ ? 1 : 0);
|
|
1565
1565
|
if (J.startsWith("uint")) {
|
|
1566
1566
|
let Q = typeof $ === "bigint" ? $ : BigInt($);
|
|
1567
|
-
return
|
|
1567
|
+
return MJ(Q);
|
|
1568
1568
|
}
|
|
1569
1569
|
if (J.startsWith("int")) {
|
|
1570
1570
|
let Q = typeof $ === "bigint" ? $ : BigInt($);
|
|
@@ -1572,33 +1572,33 @@ function VQ(J, $) {
|
|
|
1572
1572
|
let Y = J === "int" ? 256 : parseInt(J.slice(3));
|
|
1573
1573
|
Q = (1n << BigInt(Y)) + Q;
|
|
1574
1574
|
}
|
|
1575
|
-
return
|
|
1575
|
+
return MJ(Q);
|
|
1576
1576
|
}
|
|
1577
1577
|
if (J.startsWith("bytes") && J !== "bytes")
|
|
1578
1578
|
return A$($).padEnd(g3, "0");
|
|
1579
1579
|
if (J === "bytes") {
|
|
1580
|
-
let Q = A$($), Y =
|
|
1581
|
-
return Y +
|
|
1580
|
+
let Q = A$($), Y = MJ(Q.length / 2), G = Q.padEnd(Math.ceil(Q.length / g3) * g3, "0");
|
|
1581
|
+
return Y + G;
|
|
1582
1582
|
}
|
|
1583
1583
|
if (J === "string") {
|
|
1584
|
-
let Q = Array.from(new TextEncoder().encode($)).map((
|
|
1585
|
-
return Y +
|
|
1584
|
+
let Q = Array.from(new TextEncoder().encode($)).map((M3) => M3.toString(16).padStart(2, "0")).join(""), Y = MJ(Q.length / 2), G = Q.padEnd(Math.ceil(Q.length / g3) * g3, "0");
|
|
1585
|
+
return Y + G;
|
|
1586
1586
|
}
|
|
1587
1587
|
throw Error(`Unsupported type: ${J}`);
|
|
1588
1588
|
}
|
|
1589
|
-
function
|
|
1589
|
+
function M$(J, $, Q = 0, Y) {
|
|
1590
1590
|
if (J === "tuple" && Y)
|
|
1591
1591
|
return OQ(Y, $, Q);
|
|
1592
1592
|
if (J.includes("["))
|
|
1593
1593
|
return NQ(J, $, Q, Y);
|
|
1594
|
-
return
|
|
1594
|
+
return RQ(J, $, Q);
|
|
1595
1595
|
}
|
|
1596
1596
|
function NQ(J, $, Q, Y) {
|
|
1597
|
-
let
|
|
1597
|
+
let G = J.slice(0, J.indexOf("[")), M3 = $.slice(Q, Q + g3);
|
|
1598
1598
|
if (J.endsWith("[]")) {
|
|
1599
|
-
let K = parseInt(
|
|
1599
|
+
let K = parseInt(M3, 16) * 2, X = parseInt($.slice(K, K + g3), 16), q = [], U = K + g3;
|
|
1600
1600
|
for (let D3 = 0;D3 < X; D3++) {
|
|
1601
|
-
let V =
|
|
1601
|
+
let V = M$(G, $, U, Y);
|
|
1602
1602
|
q.push(V.value), U += V.consumed;
|
|
1603
1603
|
}
|
|
1604
1604
|
return { value: q, consumed: g3 };
|
|
@@ -1607,7 +1607,7 @@ function NQ(J, $, Q, Y) {
|
|
|
1607
1607
|
if (Z) {
|
|
1608
1608
|
let K = parseInt(Z[1]), X = [], q = 0;
|
|
1609
1609
|
for (let U = 0;U < K; U++) {
|
|
1610
|
-
let D3 =
|
|
1610
|
+
let D3 = M$(G, $, Q + q, Y);
|
|
1611
1611
|
X.push(D3.value), q += D3.consumed;
|
|
1612
1612
|
}
|
|
1613
1613
|
return { value: X, consumed: q };
|
|
@@ -1615,14 +1615,14 @@ function NQ(J, $, Q, Y) {
|
|
|
1615
1615
|
throw Error(`Invalid array type: ${J}`);
|
|
1616
1616
|
}
|
|
1617
1617
|
function OQ(J, $, Q) {
|
|
1618
|
-
let Y = [],
|
|
1619
|
-
for (let
|
|
1620
|
-
let Z =
|
|
1621
|
-
Y.push(Z.value),
|
|
1618
|
+
let Y = [], G = Q;
|
|
1619
|
+
for (let M3 of J) {
|
|
1620
|
+
let Z = M$(M3.type, $, G, M3.components);
|
|
1621
|
+
Y.push(Z.value), G += Z.consumed;
|
|
1622
1622
|
}
|
|
1623
|
-
return { value: Y, consumed:
|
|
1623
|
+
return { value: Y, consumed: G - Q };
|
|
1624
1624
|
}
|
|
1625
|
-
function
|
|
1625
|
+
function RQ(J, $, Q) {
|
|
1626
1626
|
let Y = $.slice(Q, Q + g3);
|
|
1627
1627
|
if (J === "address")
|
|
1628
1628
|
return { value: OJ("0x" + Y.slice(24)), consumed: g3 };
|
|
@@ -1631,30 +1631,30 @@ function CQ(J, $, Q) {
|
|
|
1631
1631
|
if (J.startsWith("uint"))
|
|
1632
1632
|
return { value: BigInt("0x" + Y), consumed: g3 };
|
|
1633
1633
|
if (J.startsWith("int")) {
|
|
1634
|
-
let
|
|
1635
|
-
return { value:
|
|
1634
|
+
let G = BigInt("0x" + Y), M3 = J === "int" ? 256 : parseInt(J.slice(3)), Z = 1n << BigInt(M3 - 1);
|
|
1635
|
+
return { value: G >= Z ? G - (1n << BigInt(M3)) : G, consumed: g3 };
|
|
1636
1636
|
}
|
|
1637
1637
|
if (J.startsWith("bytes") && J !== "bytes") {
|
|
1638
|
-
let
|
|
1639
|
-
return { value: "0x" + Y.slice(0,
|
|
1638
|
+
let G = parseInt(J.match(/^bytes(\d+)$/)[1]);
|
|
1639
|
+
return { value: "0x" + Y.slice(0, G * 2), consumed: g3 };
|
|
1640
1640
|
}
|
|
1641
1641
|
if (J === "bytes") {
|
|
1642
|
-
let
|
|
1643
|
-
return { value: "0x" + $.slice(
|
|
1642
|
+
let G = parseInt(Y, 16) * 2, M3 = parseInt($.slice(G, G + g3), 16) * 2;
|
|
1643
|
+
return { value: "0x" + $.slice(G + g3, G + g3 + M3), consumed: g3 };
|
|
1644
1644
|
}
|
|
1645
1645
|
if (J === "string") {
|
|
1646
|
-
let
|
|
1646
|
+
let G = parseInt(Y, 16) * 2, M3 = parseInt($.slice(G, G + g3), 16) * 2, Z = $.slice(G + g3, G + g3 + M3), K = new Uint8Array(Z.match(/.{2}/g)?.map((X) => parseInt(X, 16)) || []);
|
|
1647
1647
|
return { value: new TextDecoder().decode(K), consumed: g3 };
|
|
1648
1648
|
}
|
|
1649
1649
|
throw Error(`Unsupported type: ${J}`);
|
|
1650
1650
|
}
|
|
1651
1651
|
function TJ(J) {
|
|
1652
|
-
let { abi: $, functionName: Q, args: Y = [] } = J,
|
|
1653
|
-
if (!
|
|
1652
|
+
let { abi: $, functionName: Q, args: Y = [] } = J, G = $.find((O3) => O3.type === "function" && O3.name === Q);
|
|
1653
|
+
if (!G)
|
|
1654
1654
|
throw Error(`Function "${Q}" not found in ABI`);
|
|
1655
|
-
let
|
|
1655
|
+
let M3 = jQ(G), Z = G.inputs || [];
|
|
1656
1656
|
if (Z.length === 0)
|
|
1657
|
-
return
|
|
1657
|
+
return M3;
|
|
1658
1658
|
if (Y.length !== Z.length)
|
|
1659
1659
|
throw Error(`Expected ${Z.length} arguments, got ${Y.length}`);
|
|
1660
1660
|
let K = [], X = [], q = [];
|
|
@@ -1666,28 +1666,28 @@ function TJ(J) {
|
|
|
1666
1666
|
K.push(NJ(L2.type, Y[O3], N2));
|
|
1667
1667
|
}
|
|
1668
1668
|
if (X.length === 0)
|
|
1669
|
-
return
|
|
1669
|
+
return M3 + K.join("");
|
|
1670
1670
|
let U = K.reduce((O3, L2, N2) => O3 + (q[N2] ? w$ : L2.length / 2), 0), D3 = "", V = 0;
|
|
1671
1671
|
for (let O3 = 0;O3 < Z.length; O3++)
|
|
1672
1672
|
if (q[O3])
|
|
1673
|
-
D3 +=
|
|
1673
|
+
D3 += MJ(U), U += X[V].length / 2, V++;
|
|
1674
1674
|
else
|
|
1675
1675
|
D3 += K[O3];
|
|
1676
|
-
return
|
|
1676
|
+
return M3 + D3 + X.join("");
|
|
1677
1677
|
}
|
|
1678
1678
|
function Z$(J) {
|
|
1679
|
-
let { abi: $, functionName: Q, data: Y } = J,
|
|
1680
|
-
if (!
|
|
1679
|
+
let { abi: $, functionName: Q, data: Y } = J, G = $.find((q) => q.type === "function" && q.name === Q);
|
|
1680
|
+
if (!G)
|
|
1681
1681
|
throw Error(`Function "${Q}" not found in ABI`);
|
|
1682
|
-
let
|
|
1683
|
-
if (
|
|
1682
|
+
let M3 = G.outputs || [];
|
|
1683
|
+
if (M3.length === 0)
|
|
1684
1684
|
return;
|
|
1685
1685
|
let Z = A$(Y);
|
|
1686
|
-
if (
|
|
1687
|
-
return
|
|
1686
|
+
if (M3.length === 1)
|
|
1687
|
+
return M$(M3[0].type, Z, 0, M3[0].components).value;
|
|
1688
1688
|
let K = [], X = 0;
|
|
1689
|
-
for (let q of
|
|
1690
|
-
let U =
|
|
1689
|
+
for (let q of M3) {
|
|
1690
|
+
let U = M$(q.type, Z, X, q.components);
|
|
1691
1691
|
K.push(U.value), X += U.consumed;
|
|
1692
1692
|
}
|
|
1693
1693
|
return K;
|
|
@@ -1695,31 +1695,31 @@ function Z$(J) {
|
|
|
1695
1695
|
function r3(J, $) {
|
|
1696
1696
|
if (J.length !== $.length)
|
|
1697
1697
|
throw Error(`Type/value length mismatch: ${J.length} types, ${$.length} values`);
|
|
1698
|
-
let Q = [], Y = [],
|
|
1698
|
+
let Q = [], Y = [], G = [];
|
|
1699
1699
|
for (let X = 0;X < J.length; X++) {
|
|
1700
1700
|
let q = J[X], U = pJ(q);
|
|
1701
|
-
if (
|
|
1701
|
+
if (G.push(U), U)
|
|
1702
1702
|
Q.push(""), Y.push(NJ(q, $[X]));
|
|
1703
1703
|
else
|
|
1704
1704
|
Q.push(NJ(q, $[X]));
|
|
1705
1705
|
}
|
|
1706
1706
|
if (Y.length === 0)
|
|
1707
1707
|
return "0x" + Q.join("");
|
|
1708
|
-
let
|
|
1708
|
+
let M3 = Q.reduce((X, q, U) => X + (G[U] ? w$ : q.length / 2), 0), Z = "", K = 0;
|
|
1709
1709
|
for (let X = 0;X < J.length; X++)
|
|
1710
|
-
if (
|
|
1711
|
-
Z +=
|
|
1710
|
+
if (G[X])
|
|
1711
|
+
Z += MJ(M3), M3 += Y[K].length / 2, K++;
|
|
1712
1712
|
else
|
|
1713
1713
|
Z += Q[X];
|
|
1714
1714
|
return "0x" + Z + Y.join("");
|
|
1715
1715
|
}
|
|
1716
|
-
function
|
|
1716
|
+
function R3(J) {
|
|
1717
1717
|
return J.toLowerCase();
|
|
1718
1718
|
}
|
|
1719
|
-
function
|
|
1719
|
+
function CQ(J) {
|
|
1720
1720
|
return OJ(J);
|
|
1721
1721
|
}
|
|
1722
|
-
function
|
|
1722
|
+
function PQ(J) {
|
|
1723
1723
|
if (typeof J !== "string")
|
|
1724
1724
|
return false;
|
|
1725
1725
|
let $ = J.replace("0x", "");
|
|
@@ -1728,8 +1728,8 @@ function BQ(J) {
|
|
|
1728
1728
|
function H(J) {
|
|
1729
1729
|
if (J === null || J === undefined)
|
|
1730
1730
|
return J;
|
|
1731
|
-
if (
|
|
1732
|
-
return
|
|
1731
|
+
if (PQ(J))
|
|
1732
|
+
return CQ(J);
|
|
1733
1733
|
if (Array.isArray(J))
|
|
1734
1734
|
return J.map(($) => H($));
|
|
1735
1735
|
if (typeof J === "object" && J !== null) {
|
|
@@ -1742,7 +1742,7 @@ function H(J) {
|
|
|
1742
1742
|
return J;
|
|
1743
1743
|
}
|
|
1744
1744
|
function J0(J) {
|
|
1745
|
-
return { Source:
|
|
1745
|
+
return { Source: R3(J.from), Sink: R3(J.to), TargetFlow: J.targetFlow.toString(), WithWrap: J.useWrappedBalances, FromTokens: J.fromTokens?.map(R3), ToTokens: J.toTokens?.map(R3), ExcludedFromTokens: J.excludeFromTokens?.map(R3), ExcludedToTokens: J.excludeToTokens?.map(R3), SimulatedBalances: J.simulatedBalances?.map(($) => ({ Holder: R3($.holder), Token: R3($.token), Amount: $.amount.toString(), IsWrapped: $.isWrapped, IsStatic: $.isStatic })), SimulatedTrusts: J.simulatedTrusts?.map(($) => ({ Truster: R3($.truster), Trustee: R3($.trustee) })), MaxTransfers: J.maxTransfers };
|
|
1746
1746
|
}
|
|
1747
1747
|
function XJ(J) {
|
|
1748
1748
|
let $ = {};
|
|
@@ -1755,7 +1755,7 @@ function XJ(J) {
|
|
|
1755
1755
|
else if (typeof Y === "object" && !Array.isArray(Y))
|
|
1756
1756
|
$[Q] = XJ(Y);
|
|
1757
1757
|
else if (Array.isArray(Y))
|
|
1758
|
-
$[Q] = Y.map((
|
|
1758
|
+
$[Q] = Y.map((G) => typeof G === "object" && G !== null ? XJ(G) : G);
|
|
1759
1759
|
else
|
|
1760
1760
|
$[Q] = Y;
|
|
1761
1761
|
}
|
|
@@ -1791,23 +1791,23 @@ class K$ {
|
|
|
1791
1791
|
this.client = J;
|
|
1792
1792
|
}
|
|
1793
1793
|
async query(J) {
|
|
1794
|
-
let $ = await this.client.call("circles_query", [J]), { columns: Q, rows: Y } = $,
|
|
1794
|
+
let $ = await this.client.call("circles_query", [J]), { columns: Q, rows: Y } = $, G = Y.map((M3) => {
|
|
1795
1795
|
let Z = {};
|
|
1796
1796
|
return Q.forEach((K, X) => {
|
|
1797
|
-
Z[K] =
|
|
1797
|
+
Z[K] = M3[X];
|
|
1798
1798
|
}), Z;
|
|
1799
1799
|
});
|
|
1800
|
-
return H(
|
|
1800
|
+
return H(G);
|
|
1801
1801
|
}
|
|
1802
1802
|
async tables() {
|
|
1803
1803
|
return this.client.call("circles_tables", []);
|
|
1804
1804
|
}
|
|
1805
|
-
async events(J = null, $ = null, Q = null, Y = null,
|
|
1806
|
-
let X = await this.client.call("circles_events_paginated", [J, $, Q, Y,
|
|
1805
|
+
async events(J = null, $ = null, Q = null, Y = null, G = null, M3 = false, Z = 100, K = null) {
|
|
1806
|
+
let X = await this.client.call("circles_events_paginated", [J, $, Q, Y, G, M3, Z, K]);
|
|
1807
1807
|
return { events: H(X.events), hasMore: X.hasMore, nextCursor: X.nextCursor };
|
|
1808
1808
|
}
|
|
1809
1809
|
}
|
|
1810
|
-
var
|
|
1810
|
+
var BQ = [{ name: "blockNumber", sortOrder: "DESC" }, { name: "transactionIndex", sortOrder: "DESC" }, { name: "logIndex", sortOrder: "DESC" }];
|
|
1811
1811
|
|
|
1812
1812
|
class SJ {
|
|
1813
1813
|
params;
|
|
@@ -1823,7 +1823,7 @@ class SJ {
|
|
|
1823
1823
|
this.client = J, this.params = $, this.rowTransformer = Q || $.rowTransformer, this.orderColumns = $.orderColumns, this.cursorColumns = $.cursorColumns || this.buildEventCursorColumns();
|
|
1824
1824
|
}
|
|
1825
1825
|
buildEventCursorColumns() {
|
|
1826
|
-
let J =
|
|
1826
|
+
let J = BQ.map(($) => ({ ...$, sortOrder: this.params.sortOrder }));
|
|
1827
1827
|
if (this.params.table === "TransferBatch")
|
|
1828
1828
|
J.push({ name: "batchIndex", sortOrder: this.params.sortOrder });
|
|
1829
1829
|
return J;
|
|
@@ -1836,10 +1836,10 @@ class SJ {
|
|
|
1836
1836
|
rowsToObjects(J) {
|
|
1837
1837
|
let { columns: $, rows: Q } = J;
|
|
1838
1838
|
return Q.map((Y) => {
|
|
1839
|
-
let
|
|
1840
|
-
return $.forEach((
|
|
1841
|
-
M3
|
|
1842
|
-
}), this.rowTransformer ? this.rowTransformer(
|
|
1839
|
+
let G = {};
|
|
1840
|
+
return $.forEach((M3, Z) => {
|
|
1841
|
+
G[M3] = Y[Z];
|
|
1842
|
+
}), this.rowTransformer ? this.rowTransformer(G) : G;
|
|
1843
1843
|
});
|
|
1844
1844
|
}
|
|
1845
1845
|
async queryNextPage() {
|
|
@@ -1859,44 +1859,44 @@ class _J {
|
|
|
1859
1859
|
transformQueryResponse(J) {
|
|
1860
1860
|
let { columns: $, rows: Q } = J;
|
|
1861
1861
|
return Q.map((Y) => {
|
|
1862
|
-
let
|
|
1863
|
-
return $.forEach((
|
|
1864
|
-
M3
|
|
1865
|
-
}),
|
|
1862
|
+
let G = {};
|
|
1863
|
+
return $.forEach((M3, Z) => {
|
|
1864
|
+
G[M3] = Y[Z];
|
|
1865
|
+
}), G;
|
|
1866
1866
|
});
|
|
1867
1867
|
}
|
|
1868
1868
|
async getCommonTrust(J, $) {
|
|
1869
|
-
let Q = await this.client.call("circles_getCommonTrust", [
|
|
1869
|
+
let Q = await this.client.call("circles_getCommonTrust", [R3(J), R3($)]);
|
|
1870
1870
|
return H(Q);
|
|
1871
1871
|
}
|
|
1872
1872
|
getTrustRelations(J, $ = 100, Q = "DESC") {
|
|
1873
|
-
let Y =
|
|
1874
|
-
return new SJ(this.client, { namespace: "V_Crc", table: "TrustRelations", sortOrder: Q, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "version", "trustee", "truster", "expiryTime"], filter:
|
|
1873
|
+
let Y = R3(J), G = [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "Conjunction", ConjunctionType: "Or", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "trustee", Value: Y }, { Type: "FilterPredicate", FilterType: "Equals", Column: "truster", Value: Y }] }] }];
|
|
1874
|
+
return new SJ(this.client, { namespace: "V_Crc", table: "TrustRelations", sortOrder: Q, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "version", "trustee", "truster", "expiryTime"], filter: G, limit: $ }, (M3) => H(M3));
|
|
1875
1875
|
}
|
|
1876
1876
|
async getAggregatedTrustRelations(J) {
|
|
1877
|
-
let $ =
|
|
1877
|
+
let $ = R3(J), Q = await this.client.call("circles_getAggregatedTrustRelations", [$]);
|
|
1878
1878
|
return H(Q);
|
|
1879
1879
|
}
|
|
1880
1880
|
async getTrustedBy(J) {
|
|
1881
|
-
let $ =
|
|
1881
|
+
let $ = R3(J), Y = (await this.getAggregatedTrustRelations($)).filter((G) => G.relation === "trustedBy");
|
|
1882
1882
|
return H(Y);
|
|
1883
1883
|
}
|
|
1884
1884
|
async getTrusts(J) {
|
|
1885
|
-
let $ =
|
|
1885
|
+
let $ = R3(J), Y = (await this.getAggregatedTrustRelations($)).filter((G) => G.relation === "trusts");
|
|
1886
1886
|
return H(Y);
|
|
1887
1887
|
}
|
|
1888
1888
|
async getMutualTrusts(J) {
|
|
1889
|
-
let $ =
|
|
1889
|
+
let $ = R3(J), Y = (await this.getAggregatedTrustRelations($)).filter((G) => G.relation === "mutuallyTrusts");
|
|
1890
1890
|
return H(Y);
|
|
1891
1891
|
}
|
|
1892
1892
|
async getTrustNetworkSummary(J, $ = 2) {
|
|
1893
|
-
return this.client.call("circles_getTrustNetworkSummary", [
|
|
1893
|
+
return this.client.call("circles_getTrustNetworkSummary", [R3(J), $]);
|
|
1894
1894
|
}
|
|
1895
1895
|
async getAggregatedTrustRelationsEnriched(J) {
|
|
1896
|
-
return this.client.call("circles_getAggregatedTrustRelationsEnriched", [
|
|
1896
|
+
return this.client.call("circles_getAggregatedTrustRelationsEnriched", [R3(J)]);
|
|
1897
1897
|
}
|
|
1898
1898
|
async getValidInviters(J, $) {
|
|
1899
|
-
let Q = [
|
|
1899
|
+
let Q = [R3(J)];
|
|
1900
1900
|
if ($)
|
|
1901
1901
|
Q.push($);
|
|
1902
1902
|
return this.client.call("circles_getValidInviters", Q);
|
|
@@ -1922,13 +1922,13 @@ class nJ {
|
|
|
1922
1922
|
return J * $ >> 64n;
|
|
1923
1923
|
}
|
|
1924
1924
|
static pow64(J, $) {
|
|
1925
|
-
let Q = J, Y = $,
|
|
1925
|
+
let Q = J, Y = $, G = this.ONE_64;
|
|
1926
1926
|
while (Y > 0n) {
|
|
1927
1927
|
if ((Y & 1n) === 1n)
|
|
1928
|
-
|
|
1928
|
+
G = this.mul64(G, Q);
|
|
1929
1929
|
Q = this.mul64(Q, Q), Y >>= 1n;
|
|
1930
1930
|
}
|
|
1931
|
-
return
|
|
1931
|
+
return G;
|
|
1932
1932
|
}
|
|
1933
1933
|
static ONE_36 = 1000000000000000000000000000000000000000n;
|
|
1934
1934
|
static GAMMA_36 = 999801332008598957430613406568191166n;
|
|
@@ -1937,11 +1937,11 @@ class nJ {
|
|
|
1937
1937
|
return J * $ / this.ONE_36;
|
|
1938
1938
|
}
|
|
1939
1939
|
static pow36(J, $) {
|
|
1940
|
-
let Q = this.ONE_36, Y = J,
|
|
1941
|
-
while (
|
|
1942
|
-
if ((
|
|
1940
|
+
let Q = this.ONE_36, Y = J, G = $;
|
|
1941
|
+
while (G > 0n) {
|
|
1942
|
+
if ((G & 1n) === 1n)
|
|
1943
1943
|
Q = this.mul36(Q, Y);
|
|
1944
|
-
Y = this.mul36(Y, Y),
|
|
1944
|
+
Y = this.mul36(Y, Y), G >>= 1n;
|
|
1945
1945
|
}
|
|
1946
1946
|
return Q;
|
|
1947
1947
|
}
|
|
@@ -2003,16 +2003,16 @@ class nJ {
|
|
|
2003
2003
|
return this.V1_ACCURACY * this.V1_INFLATION_PCT_NUM ** J / this.V1_INFLATION_PCT_DEN ** J;
|
|
2004
2004
|
}
|
|
2005
2005
|
static attoCrcToAttoCircles(J, $) {
|
|
2006
|
-
let Q = $ - this.INFLATION_DAY_ZERO_UNIX, Y = Q / this.PERIOD_SEC,
|
|
2007
|
-
return this.v1ToDemurrage(J,
|
|
2006
|
+
let Q = $ - this.INFLATION_DAY_ZERO_UNIX, Y = Q / this.PERIOD_SEC, G = Q % this.PERIOD_SEC, M3 = this.v1InflateFactor(Y), Z = this.v1InflateFactor(Y + 1n);
|
|
2007
|
+
return this.v1ToDemurrage(J, M3, Z, G, this.PERIOD_SEC);
|
|
2008
2008
|
}
|
|
2009
2009
|
static attoCirclesToAttoCrc(J, $) {
|
|
2010
|
-
let Q = $ - this.INFLATION_DAY_ZERO_UNIX, Y = Q / this.PERIOD_SEC,
|
|
2010
|
+
let Q = $ - this.INFLATION_DAY_ZERO_UNIX, Y = Q / this.PERIOD_SEC, G = Q % this.PERIOD_SEC, M3 = this.v1InflateFactor(Y), Z = this.v1InflateFactor(Y + 1n), K = M3 * (this.PERIOD_SEC - G) + Z * G;
|
|
2011
2011
|
return J * 3n * this.V1_ACCURACY * this.PERIOD_SEC / K;
|
|
2012
2012
|
}
|
|
2013
|
-
static v1ToDemurrage(J, $, Q, Y,
|
|
2014
|
-
let
|
|
2015
|
-
return J * 3n * this.V1_ACCURACY *
|
|
2013
|
+
static v1ToDemurrage(J, $, Q, Y, G) {
|
|
2014
|
+
let M3 = $ * (G - Y) + Q * Y;
|
|
2015
|
+
return J * 3n * this.V1_ACCURACY * G / M3;
|
|
2016
2016
|
}
|
|
2017
2017
|
}
|
|
2018
2018
|
|
|
@@ -2022,11 +2022,11 @@ class yJ {
|
|
|
2022
2022
|
this.client = J;
|
|
2023
2023
|
}
|
|
2024
2024
|
async getTotalBalance(J, $ = true) {
|
|
2025
|
-
let Q = await this.client.call("circlesV2_getTotalBalance", [
|
|
2025
|
+
let Q = await this.client.call("circlesV2_getTotalBalance", [R3(J), $]);
|
|
2026
2026
|
return nJ.circlesToAttoCircles(Q);
|
|
2027
2027
|
}
|
|
2028
2028
|
async getTokenBalances(J) {
|
|
2029
|
-
let Q = (await this.client.call("circles_getTokenBalances", [
|
|
2029
|
+
let Q = (await this.client.call("circles_getTokenBalances", [R3(J)])).map((Y) => XJ(Y));
|
|
2030
2030
|
return H(Q);
|
|
2031
2031
|
}
|
|
2032
2032
|
}
|
|
@@ -2043,7 +2043,7 @@ class q$ {
|
|
|
2043
2043
|
async getAvatarInfoBatch(J) {
|
|
2044
2044
|
if (J.length === 0)
|
|
2045
2045
|
return [];
|
|
2046
|
-
let $ = J.map((Y) =>
|
|
2046
|
+
let $ = J.map((Y) => R3(Y)), Q = await this.client.call("circles_getAvatarInfoBatch", [$]);
|
|
2047
2047
|
return H(Q);
|
|
2048
2048
|
}
|
|
2049
2049
|
async getNetworkSnapshot() {
|
|
@@ -2064,10 +2064,10 @@ class U$ {
|
|
|
2064
2064
|
return this.client.call("circles_getProfileByCidBatch", [J]);
|
|
2065
2065
|
}
|
|
2066
2066
|
async getProfileByAddress(J) {
|
|
2067
|
-
return this.client.call("circles_getProfileByAddress", [
|
|
2067
|
+
return this.client.call("circles_getProfileByAddress", [R3(J)]);
|
|
2068
2068
|
}
|
|
2069
2069
|
async getProfileByAddressBatch(J) {
|
|
2070
|
-
return this.client.call("circles_getProfileByAddressBatch", [J.map(($) => $ === null ? null :
|
|
2070
|
+
return this.client.call("circles_getProfileByAddressBatch", [J.map(($) => $ === null ? null : R3($))]);
|
|
2071
2071
|
}
|
|
2072
2072
|
async searchProfiles(J, $ = 10, Q = 0, Y) {
|
|
2073
2073
|
return this.client.call("circles_searchProfiles", [J.toLowerCase(), $, Q, Y]);
|
|
@@ -2076,7 +2076,7 @@ class U$ {
|
|
|
2076
2076
|
return this.client.call("circles_searchProfileByAddressOrName", Y ? [J, $, Q ?? null, Y] : [J, $, Q ?? null]);
|
|
2077
2077
|
}
|
|
2078
2078
|
async getProfileView(J) {
|
|
2079
|
-
return this.client.call("circles_getProfileView", [
|
|
2079
|
+
return this.client.call("circles_getProfileView", [R3(J)]);
|
|
2080
2080
|
}
|
|
2081
2081
|
}
|
|
2082
2082
|
|
|
@@ -2092,11 +2092,11 @@ class AJ {
|
|
|
2092
2092
|
async getTokenInfoBatch(J) {
|
|
2093
2093
|
if (J.length === 0)
|
|
2094
2094
|
return [];
|
|
2095
|
-
let $ = J.map((
|
|
2095
|
+
let $ = J.map((G) => R3(G)), Y = (await this.client.call("circles_getTokenInfoBatch", [$])).map((G) => XJ(G));
|
|
2096
2096
|
return H(Y);
|
|
2097
2097
|
}
|
|
2098
2098
|
async getTokenHolders(J, $ = 100, Q) {
|
|
2099
|
-
let Y = await this.client.call("circles_getTokenHolders", [
|
|
2099
|
+
let Y = await this.client.call("circles_getTokenHolders", [R3(J), $, Q ?? null]);
|
|
2100
2100
|
return { hasMore: Y.hasMore, nextCursor: Y.nextCursor, results: H(Y.results) };
|
|
2101
2101
|
}
|
|
2102
2102
|
}
|
|
@@ -2107,7 +2107,7 @@ class W$ {
|
|
|
2107
2107
|
this.client = J;
|
|
2108
2108
|
}
|
|
2109
2109
|
async getInvitationOrigin(J) {
|
|
2110
|
-
let $ =
|
|
2110
|
+
let $ = R3(J), Q = await this.client.call("circles_getInvitationOrigin", [$]);
|
|
2111
2111
|
return Q ? H(Q) : null;
|
|
2112
2112
|
}
|
|
2113
2113
|
async getInvitedBy(J) {
|
|
@@ -2117,31 +2117,31 @@ class W$ {
|
|
|
2117
2117
|
return;
|
|
2118
2118
|
}
|
|
2119
2119
|
async getTrustInvitations(J, $) {
|
|
2120
|
-
let Q =
|
|
2120
|
+
let Q = R3(J), Y = await this.client.call("circles_getTrustInvitations", $ ? [Q, $] : [Q]);
|
|
2121
2121
|
return H(Y);
|
|
2122
2122
|
}
|
|
2123
2123
|
async getInvitations(J, $) {
|
|
2124
|
-
let Y = (await this.getValidInviters(J, $)).results.map((
|
|
2124
|
+
let Y = (await this.getValidInviters(J, $)).results.map((G) => G.avatarInfo).filter((G) => G !== undefined && G !== null);
|
|
2125
2125
|
return H(Y);
|
|
2126
2126
|
}
|
|
2127
2127
|
async getValidInviters(J, $) {
|
|
2128
|
-
let Q =
|
|
2128
|
+
let Q = R3(J), Y = await this.client.call("circles_getValidInviters", $ ? [Q, $] : [Q]);
|
|
2129
2129
|
return H(Y);
|
|
2130
2130
|
}
|
|
2131
2131
|
async getInvitationsFrom(J, $ = false) {
|
|
2132
|
-
let Q =
|
|
2132
|
+
let Q = R3(J), Y = await this.client.call("circles_getInvitationsFrom", [Q, $]);
|
|
2133
2133
|
return H(Y);
|
|
2134
2134
|
}
|
|
2135
2135
|
async getEscrowInvitations(J) {
|
|
2136
|
-
let $ =
|
|
2136
|
+
let $ = R3(J), Q = await this.client.call("circles_getEscrowInvitations", [$]);
|
|
2137
2137
|
return H(Q);
|
|
2138
2138
|
}
|
|
2139
2139
|
async getAtScaleInvitations(J) {
|
|
2140
|
-
let $ =
|
|
2140
|
+
let $ = R3(J), Q = await this.client.call("circles_getAtScaleInvitations", [$]);
|
|
2141
2141
|
return H(Q);
|
|
2142
2142
|
}
|
|
2143
2143
|
async getAllInvitations(J, $) {
|
|
2144
|
-
let Q =
|
|
2144
|
+
let Q = R3(J), Y = await this.client.call("circles_getAllInvitations", $ ? [Q, $] : [Q]);
|
|
2145
2145
|
return H(Y);
|
|
2146
2146
|
}
|
|
2147
2147
|
}
|
|
@@ -2152,12 +2152,12 @@ class j$ {
|
|
|
2152
2152
|
this.client = J;
|
|
2153
2153
|
}
|
|
2154
2154
|
async getTransactionHistory(J, $ = 50, Q) {
|
|
2155
|
-
let Y = await this.client.call("circles_getTransactionHistory", [
|
|
2155
|
+
let Y = await this.client.call("circles_getTransactionHistory", [R3(J), $, Q ?? null]);
|
|
2156
2156
|
return { hasMore: Y.hasMore, nextCursor: Y.nextCursor, results: H(Y.results) };
|
|
2157
2157
|
}
|
|
2158
|
-
async getTransactionHistoryEnriched(J, $ = 0, Q = null, Y = 20,
|
|
2159
|
-
let
|
|
2160
|
-
return { hasMore:
|
|
2158
|
+
async getTransactionHistoryEnriched(J, $ = 0, Q = null, Y = 20, G) {
|
|
2159
|
+
let M3 = await this.client.call("circles_getTransactionHistoryEnriched", [R3(J), $, Q, Y, G ?? null]);
|
|
2160
|
+
return { hasMore: M3.hasMore, nextCursor: M3.nextCursor, results: H(M3.results) };
|
|
2161
2161
|
}
|
|
2162
2162
|
}
|
|
2163
2163
|
|
|
@@ -2167,20 +2167,20 @@ class wJ {
|
|
|
2167
2167
|
this.client = J;
|
|
2168
2168
|
}
|
|
2169
2169
|
async findGroups(J = 50, $, Q) {
|
|
2170
|
-
let Y = $ ? { nameStartsWith: $.nameStartsWith, symbolStartsWith: $.symbolStartsWith, ownerIn: $.ownerIn?.map((Z) =>
|
|
2170
|
+
let Y = $ ? { nameStartsWith: $.nameStartsWith, symbolStartsWith: $.symbolStartsWith, ownerIn: $.ownerIn?.map((Z) => R3(Z)) } : undefined, G = await this.client.call("circles_findGroups", [J, Y ?? null, Q ?? null]), M3 = H(G.results).map((Z) => {
|
|
2171
2171
|
let K = Z;
|
|
2172
2172
|
if (!K.owner && K.mint)
|
|
2173
2173
|
return { ...K, owner: K.mint };
|
|
2174
2174
|
return K;
|
|
2175
2175
|
});
|
|
2176
|
-
return { hasMore:
|
|
2176
|
+
return { hasMore: G.hasMore, nextCursor: G.nextCursor, results: M3 };
|
|
2177
2177
|
}
|
|
2178
2178
|
async getGroupMemberships(J, $ = 50, Q) {
|
|
2179
|
-
let Y = await this.client.call("circles_getGroupMemberships", [
|
|
2179
|
+
let Y = await this.client.call("circles_getGroupMemberships", [R3(J), $, Q ?? null]);
|
|
2180
2180
|
return { hasMore: Y.hasMore, nextCursor: Y.nextCursor, results: H(Y.results) };
|
|
2181
2181
|
}
|
|
2182
2182
|
async getGroupMembers(J, $ = 100, Q) {
|
|
2183
|
-
let Y = await this.client.call("circles_getGroupMembers", [
|
|
2183
|
+
let Y = await this.client.call("circles_getGroupMembers", [R3(J), $, Q ?? null]);
|
|
2184
2184
|
return { hasMore: Y.hasMore, nextCursor: Y.nextCursor, results: H(Y.results) };
|
|
2185
2185
|
}
|
|
2186
2186
|
getGroups(J = 50, $, Q = "DESC") {
|
|
@@ -2191,36 +2191,36 @@ class wJ {
|
|
|
2191
2191
|
if ($.symbolStartsWith)
|
|
2192
2192
|
Y.push({ Type: "FilterPredicate", FilterType: "Like", Column: "symbol", Value: $.symbolStartsWith + "%" });
|
|
2193
2193
|
if ($.groupAddressIn && $.groupAddressIn.length > 0) {
|
|
2194
|
-
let
|
|
2195
|
-
if (
|
|
2196
|
-
Y.push(
|
|
2194
|
+
let M3 = $.groupAddressIn.map((Z) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: R3(Z) }));
|
|
2195
|
+
if (M3.length === 1)
|
|
2196
|
+
Y.push(M3[0]);
|
|
2197
2197
|
else
|
|
2198
|
-
Y.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates:
|
|
2198
|
+
Y.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: M3 });
|
|
2199
2199
|
}
|
|
2200
2200
|
if ($.groupTypeIn && $.groupTypeIn.length > 0) {
|
|
2201
|
-
let
|
|
2202
|
-
if (
|
|
2203
|
-
Y.push(
|
|
2201
|
+
let M3 = $.groupTypeIn.map((Z) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "type", Value: Z }));
|
|
2202
|
+
if (M3.length === 1)
|
|
2203
|
+
Y.push(M3[0]);
|
|
2204
2204
|
else
|
|
2205
|
-
Y.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates:
|
|
2205
|
+
Y.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: M3 });
|
|
2206
2206
|
}
|
|
2207
2207
|
if ($.ownerIn && $.ownerIn.length > 0) {
|
|
2208
|
-
let
|
|
2209
|
-
if (
|
|
2210
|
-
Y.push(
|
|
2208
|
+
let M3 = $.ownerIn.map((Z) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "owner", Value: R3(Z) }));
|
|
2209
|
+
if (M3.length === 1)
|
|
2210
|
+
Y.push(M3[0]);
|
|
2211
2211
|
else
|
|
2212
|
-
Y.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates:
|
|
2212
|
+
Y.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: M3 });
|
|
2213
2213
|
}
|
|
2214
2214
|
if ($.mintHandlerEquals)
|
|
2215
|
-
Y.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "mintHandler", Value:
|
|
2215
|
+
Y.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "mintHandler", Value: R3($.mintHandlerEquals) });
|
|
2216
2216
|
if ($.treasuryEquals)
|
|
2217
|
-
Y.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "treasury", Value:
|
|
2217
|
+
Y.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "treasury", Value: R3($.treasuryEquals) });
|
|
2218
2218
|
}
|
|
2219
|
-
let
|
|
2220
|
-
return new SJ(this.client, { namespace: "V_CrcV2", table: "Groups", sortOrder: Q, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "type", "owner", "mintPolicy", "mintHandler", "treasury", "service", "feeCollection", "memberCount", "name", "symbol", "cidV0Digest", "erc20WrapperDemurraged", "erc20WrapperStatic"], filter:
|
|
2219
|
+
let G = Y.length > 1 ? [{ Type: "Conjunction", ConjunctionType: "And", Predicates: Y }] : Y;
|
|
2220
|
+
return new SJ(this.client, { namespace: "V_CrcV2", table: "Groups", sortOrder: Q, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "type", "owner", "mintPolicy", "mintHandler", "treasury", "service", "feeCollection", "memberCount", "name", "symbol", "cidV0Digest", "erc20WrapperDemurraged", "erc20WrapperStatic"], filter: G, limit: J }, (M3) => H(M3));
|
|
2221
2221
|
}
|
|
2222
2222
|
getGroupHolders(J, $ = 100) {
|
|
2223
|
-
let Q =
|
|
2223
|
+
let Q = R3(J);
|
|
2224
2224
|
return new SJ(this.client, { namespace: "V_Crc", table: "TokenBalances", sortOrder: "DESC", columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "token", "account", "balance", "lastChangedAt"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "token", Value: Q }], limit: $ }, (Y) => H(Y));
|
|
2225
2225
|
}
|
|
2226
2226
|
}
|
|
@@ -2231,23 +2231,23 @@ class E$ {
|
|
|
2231
2231
|
this.client = J;
|
|
2232
2232
|
}
|
|
2233
2233
|
async getProfileView(J) {
|
|
2234
|
-
let $ =
|
|
2234
|
+
let $ = R3(J);
|
|
2235
2235
|
return this.client.call("circles_getProfileView", [$]);
|
|
2236
2236
|
}
|
|
2237
2237
|
async getTrustNetworkSummary(J, $ = 2) {
|
|
2238
|
-
let Q =
|
|
2238
|
+
let Q = R3(J);
|
|
2239
2239
|
return this.client.call("circles_getTrustNetworkSummary", [Q, $]);
|
|
2240
2240
|
}
|
|
2241
2241
|
async getAggregatedTrustRelations(J) {
|
|
2242
|
-
let $ =
|
|
2242
|
+
let $ = R3(J);
|
|
2243
2243
|
return this.client.call("circles_getAggregatedTrustRelations", [$]);
|
|
2244
2244
|
}
|
|
2245
2245
|
async getValidInviters(J, $) {
|
|
2246
|
-
let Q =
|
|
2246
|
+
let Q = R3(J), Y = await this.client.call("circles_getValidInviters", $ ? [Q, $] : [Q]);
|
|
2247
2247
|
return H(Y);
|
|
2248
2248
|
}
|
|
2249
|
-
async getTransactionHistoryEnriched(J, $ = 0, Q = null, Y = 50,
|
|
2250
|
-
let
|
|
2249
|
+
async getTransactionHistoryEnriched(J, $ = 0, Q = null, Y = 50, G) {
|
|
2250
|
+
let M3 = R3(J), Z = await this.client.call("circles_getTransactionHistoryEnriched", [M3, $, Q, Y, G ?? null]);
|
|
2251
2251
|
return { hasMore: Z.hasMore, nextCursor: Z.nextCursor, results: H(Z.results) };
|
|
2252
2252
|
}
|
|
2253
2253
|
async searchProfileByAddressOrName(J, $ = 20, Q, Y) {
|
|
@@ -2342,7 +2342,7 @@ class p2 {
|
|
|
2342
2342
|
this.address = J.address, this.abi = J.abi, this.rpcUrl = J.rpcUrl;
|
|
2343
2343
|
}
|
|
2344
2344
|
async read(J, $, Q) {
|
|
2345
|
-
let Y = TJ({ abi: this.abi, functionName: J, args: $ }),
|
|
2345
|
+
let Y = TJ({ abi: this.abi, functionName: J, args: $ }), G = { to: this.address, data: Y, ...Q?.from && { from: Q.from } }, Z = await (await fetch(this.rpcUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_call", params: [G, "latest"] }) })).json();
|
|
2346
2346
|
if (Z.error)
|
|
2347
2347
|
throw Error(`RPC Error: ${Z.error.message}`);
|
|
2348
2348
|
if (!Z.result)
|
|
@@ -2355,7 +2355,7 @@ class p2 {
|
|
|
2355
2355
|
}
|
|
2356
2356
|
var $0 = [{ type: "function", name: "operateFlowMatrix", inputs: [{ name: "_flowVertices", type: "address[]" }, { name: "_flow", type: "tuple[]", components: [{ name: "streamSinkId", type: "uint16" }, { name: "amount", type: "uint192" }] }, { name: "_streams", type: "tuple[]", components: [{ name: "sourceCoordinate", type: "uint16" }, { name: "flowEdgeIds", type: "uint16[]" }, { name: "data", type: "bytes" }] }, { name: "_packedCoordinates", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isApprovedForAll", inputs: [{ name: "_account", type: "address" }, { name: "_operator", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "setApprovalForAll", inputs: [{ name: "_operator", type: "address" }, { name: "_approved", type: "bool" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "wrap", inputs: [{ name: "_avatar", type: "address" }, { name: "_amount", type: "uint256" }, { name: "_type", type: "uint8" }], outputs: [{ type: "address" }], stateMutability: "nonpayable" }, { type: "function", name: "trust", inputs: [{ name: "_trustReceiver", type: "address" }, { name: "_expiry", type: "uint96" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isTrusted", inputs: [{ name: "_truster", type: "address" }, { name: "_trustee", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "toTokenId", inputs: [{ name: "_avatar", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "pure" }, { type: "function", name: "safeTransferFrom", inputs: [{ name: "_from", type: "address" }, { name: "_to", type: "address" }, { name: "_id", type: "uint256" }, { name: "_value", type: "uint256" }, { name: "_data", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isHuman", inputs: [{ name: "_human", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "safeBatchTransferFrom", inputs: [{ name: "_from", type: "address" }, { name: "_to", type: "address" }, { name: "_ids", type: "uint256[]" }, { name: "_values", type: "uint256[]" }, { name: "_data", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }];
|
|
2357
2357
|
|
|
2358
|
-
class
|
|
2358
|
+
class RJ extends p2 {
|
|
2359
2359
|
constructor(J) {
|
|
2360
2360
|
super({ address: J.address, abi: $0, rpcUrl: J.rpcUrl });
|
|
2361
2361
|
}
|
|
@@ -2377,8 +2377,8 @@ class CJ extends p2 {
|
|
|
2377
2377
|
wrap(J, $, Q) {
|
|
2378
2378
|
return { to: this.address, data: this.encodeWrite("wrap", [J, $, Q]), value: 0n };
|
|
2379
2379
|
}
|
|
2380
|
-
safeTransferFrom(J, $, Q, Y,
|
|
2381
|
-
return { to: this.address, data: this.encodeWrite("safeTransferFrom", [J, $, Q, Y,
|
|
2380
|
+
safeTransferFrom(J, $, Q, Y, G = "0x") {
|
|
2381
|
+
return { to: this.address, data: this.encodeWrite("safeTransferFrom", [J, $, Q, Y, G]), value: 0n };
|
|
2382
2382
|
}
|
|
2383
2383
|
operateFlowMatrix(J, $, Q, Y) {
|
|
2384
2384
|
return { to: this.address, data: this.encodeWrite("operateFlowMatrix", [J, $, Q, Y]), value: 0n };
|
|
@@ -2386,8 +2386,8 @@ class CJ extends p2 {
|
|
|
2386
2386
|
async isHuman(J) {
|
|
2387
2387
|
return this.read("isHuman", [J]);
|
|
2388
2388
|
}
|
|
2389
|
-
safeBatchTransferFrom(J, $, Q, Y,
|
|
2390
|
-
return { to: this.address, data: this.encodeWrite("safeBatchTransferFrom", [J, $, Q, Y,
|
|
2389
|
+
safeBatchTransferFrom(J, $, Q, Y, G = "0x") {
|
|
2390
|
+
return { to: this.address, data: this.encodeWrite("safeBatchTransferFrom", [J, $, Q, Y, G]), value: 0n };
|
|
2391
2391
|
}
|
|
2392
2392
|
}
|
|
2393
2393
|
var Q0 = [{ type: "function", name: "erc20Circles", inputs: [{ name: "_circlesType", type: "uint8" }, { name: "_avatar", type: "address" }], outputs: [{ type: "address" }], stateMutability: "view" }];
|
|
@@ -2422,7 +2422,7 @@ class D$ extends p2 {
|
|
|
2422
2422
|
var $8 = [{ type: "function", name: "createAccount", inputs: [{ name: "signer", type: "address" }], outputs: [{ name: "account", type: "address" }], stateMutability: "nonpayable" }, { type: "function", name: "createAccounts", inputs: [{ name: "signers", type: "address[]" }], outputs: [{ name: "_accounts", type: "address[]" }], stateMutability: "nonpayable" }];
|
|
2423
2423
|
var Q8 = [{ type: "function", name: "claimInvite", inputs: [], outputs: [{ name: "id", type: "uint256" }], stateMutability: "nonpayable" }, { type: "function", name: "claimInvites", inputs: [{ name: "numberOfInvites", type: "uint256" }], outputs: [{ name: "ids", type: "uint256[]" }], stateMutability: "nonpayable" }, { type: "function", name: "inviterQuota", inputs: [{ name: "", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "view" }, { type: "function", name: "INVITATION_FEE", inputs: [], outputs: [{ type: "uint256" }], stateMutability: "view" }, { type: "function", name: "invitationModule", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" }];
|
|
2424
2424
|
var Y8 = [{ type: "function", name: "isModuleEnabled", inputs: [{ name: "module", type: "address" }], outputs: [{ name: "", type: "bool" }], stateMutability: "view" }, { type: "function", name: "enableModule", inputs: [{ name: "module", type: "address" }], outputs: [], stateMutability: "nonpayable" }];
|
|
2425
|
-
var
|
|
2425
|
+
var G8 = [{ type: "function", name: "trustInviter", inputs: [{ name: "inviter", type: "address" }], outputs: [], stateMutability: "nonpayable" }];
|
|
2426
2426
|
|
|
2427
2427
|
class iJ extends p2 {
|
|
2428
2428
|
constructor(J) {
|
|
@@ -2471,7 +2471,7 @@ class b$ extends p2 {
|
|
|
2471
2471
|
|
|
2472
2472
|
class F$ extends p2 {
|
|
2473
2473
|
constructor(J) {
|
|
2474
|
-
super({ address: J.address, abi:
|
|
2474
|
+
super({ address: J.address, abi: G8, rpcUrl: J.rpcUrl });
|
|
2475
2475
|
}
|
|
2476
2476
|
trustInviter(J) {
|
|
2477
2477
|
return { to: this.address, data: this.encodeWrite("trustInviter", [J]), value: 0n };
|
|
@@ -2528,7 +2528,7 @@ function oJ(J, $ = true) {
|
|
|
2528
2528
|
if ($ && J.finished)
|
|
2529
2529
|
throw Error("Hash#digest() has already been called");
|
|
2530
2530
|
}
|
|
2531
|
-
function
|
|
2531
|
+
function G0(J, $) {
|
|
2532
2532
|
xJ(J);
|
|
2533
2533
|
let Q = $.outputLen;
|
|
2534
2534
|
if (J.length < Q)
|
|
@@ -2554,16 +2554,16 @@ function N$(J) {
|
|
|
2554
2554
|
J = TQ(J);
|
|
2555
2555
|
return xJ(J), J;
|
|
2556
2556
|
}
|
|
2557
|
-
function
|
|
2557
|
+
function M0(...J) {
|
|
2558
2558
|
let $ = 0;
|
|
2559
2559
|
for (let Y = 0;Y < J.length; Y++) {
|
|
2560
|
-
let
|
|
2561
|
-
xJ(
|
|
2560
|
+
let G = J[Y];
|
|
2561
|
+
xJ(G), $ += G.length;
|
|
2562
2562
|
}
|
|
2563
2563
|
let Q = new Uint8Array($);
|
|
2564
|
-
for (let Y = 0,
|
|
2565
|
-
let
|
|
2566
|
-
Q.set(
|
|
2564
|
+
for (let Y = 0, G = 0;Y < J.length; Y++) {
|
|
2565
|
+
let M3 = J[Y];
|
|
2566
|
+
Q.set(M3, G), G += M3.length;
|
|
2567
2567
|
}
|
|
2568
2568
|
return Q;
|
|
2569
2569
|
}
|
|
@@ -2584,7 +2584,7 @@ function X0(J = 32) {
|
|
|
2584
2584
|
function IQ(J, $, Q, Y) {
|
|
2585
2585
|
if (typeof J.setBigUint64 === "function")
|
|
2586
2586
|
return J.setBigUint64($, Q, Y);
|
|
2587
|
-
let
|
|
2587
|
+
let G = BigInt(32), M3 = BigInt(4294967295), Z = Number(Q >> G & M3), K = Number(Q & M3), X = Y ? 4 : 0, q = Y ? 0 : 4;
|
|
2588
2588
|
J.setUint32($ + X, Z, Y), J.setUint32($ + q, K, Y);
|
|
2589
2589
|
}
|
|
2590
2590
|
function K0(J, $, Q) {
|
|
@@ -2594,35 +2594,35 @@ function q0(J, $, Q) {
|
|
|
2594
2594
|
return J & $ ^ J & Q ^ $ & Q;
|
|
2595
2595
|
}
|
|
2596
2596
|
|
|
2597
|
-
class
|
|
2597
|
+
class M8 extends O$ {
|
|
2598
2598
|
constructor(J, $, Q, Y) {
|
|
2599
2599
|
super();
|
|
2600
2600
|
this.finished = false, this.length = 0, this.pos = 0, this.destroyed = false, this.blockLen = J, this.outputLen = $, this.padOffset = Q, this.isLE = Y, this.buffer = new Uint8Array(J), this.view = g$(this.buffer);
|
|
2601
2601
|
}
|
|
2602
2602
|
update(J) {
|
|
2603
2603
|
oJ(this), J = N$(J), xJ(J);
|
|
2604
|
-
let { view: $, buffer: Q, blockLen: Y } = this,
|
|
2605
|
-
for (let
|
|
2606
|
-
let Z = Math.min(Y - this.pos,
|
|
2604
|
+
let { view: $, buffer: Q, blockLen: Y } = this, G = J.length;
|
|
2605
|
+
for (let M3 = 0;M3 < G; ) {
|
|
2606
|
+
let Z = Math.min(Y - this.pos, G - M3);
|
|
2607
2607
|
if (Z === Y) {
|
|
2608
2608
|
let K = g$(J);
|
|
2609
|
-
for (;Y <=
|
|
2610
|
-
this.process(K,
|
|
2609
|
+
for (;Y <= G - M3; M3 += Y)
|
|
2610
|
+
this.process(K, M3);
|
|
2611
2611
|
continue;
|
|
2612
2612
|
}
|
|
2613
|
-
if (Q.set(J.subarray(
|
|
2613
|
+
if (Q.set(J.subarray(M3, M3 + Z), this.pos), this.pos += Z, M3 += Z, this.pos === Y)
|
|
2614
2614
|
this.process($, 0), this.pos = 0;
|
|
2615
2615
|
}
|
|
2616
2616
|
return this.length += J.length, this.roundClean(), this;
|
|
2617
2617
|
}
|
|
2618
2618
|
digestInto(J) {
|
|
2619
|
-
oJ(this),
|
|
2620
|
-
let { buffer: $, view: Q, blockLen: Y, isLE:
|
|
2621
|
-
if ($[
|
|
2622
|
-
this.process(Q, 0),
|
|
2623
|
-
for (let U =
|
|
2619
|
+
oJ(this), G0(J, this), this.finished = true;
|
|
2620
|
+
let { buffer: $, view: Q, blockLen: Y, isLE: G } = this, { pos: M3 } = this;
|
|
2621
|
+
if ($[M3++] = 128, kJ(this.buffer.subarray(M3)), this.padOffset > Y - M3)
|
|
2622
|
+
this.process(Q, 0), M3 = 0;
|
|
2623
|
+
for (let U = M3;U < Y; U++)
|
|
2624
2624
|
$[U] = 0;
|
|
2625
|
-
IQ(Q, Y - 8, BigInt(this.length * 8),
|
|
2625
|
+
IQ(Q, Y - 8, BigInt(this.length * 8), G), this.process(Q, 0);
|
|
2626
2626
|
let Z = g$(J), K = this.outputLen;
|
|
2627
2627
|
if (K % 4)
|
|
2628
2628
|
throw Error("_sha2: outputLen should be aligned to 32bit");
|
|
@@ -2630,7 +2630,7 @@ class G8 extends O$ {
|
|
|
2630
2630
|
if (X > q.length)
|
|
2631
2631
|
throw Error("_sha2: outputLen bigger than state");
|
|
2632
2632
|
for (let U = 0;U < X; U++)
|
|
2633
|
-
Z.setUint32(4 * U, q[U],
|
|
2633
|
+
Z.setUint32(4 * U, q[U], G);
|
|
2634
2634
|
}
|
|
2635
2635
|
digest() {
|
|
2636
2636
|
let { buffer: J, outputLen: $ } = this;
|
|
@@ -2640,8 +2640,8 @@ class G8 extends O$ {
|
|
|
2640
2640
|
}
|
|
2641
2641
|
_cloneInto(J) {
|
|
2642
2642
|
J || (J = new this.constructor), J.set(...this.get());
|
|
2643
|
-
let { blockLen: $, buffer: Q, length: Y, finished:
|
|
2644
|
-
if (J.destroyed =
|
|
2643
|
+
let { blockLen: $, buffer: Q, length: Y, finished: G, destroyed: M3, pos: Z } = this;
|
|
2644
|
+
if (J.destroyed = M3, J.finished = G, J.length = Y, J.pos = Z, Y % $)
|
|
2645
2645
|
J.buffer.set(Q);
|
|
2646
2646
|
return J;
|
|
2647
2647
|
}
|
|
@@ -2651,36 +2651,36 @@ class G8 extends O$ {
|
|
|
2651
2651
|
}
|
|
2652
2652
|
var qJ = Uint32Array.from([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
|
|
2653
2653
|
var HQ = Uint32Array.from([1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298]);
|
|
2654
|
-
var
|
|
2654
|
+
var CJ = new Uint32Array(64);
|
|
2655
2655
|
|
|
2656
|
-
class U0 extends
|
|
2656
|
+
class U0 extends M8 {
|
|
2657
2657
|
constructor(J = 32) {
|
|
2658
2658
|
super(64, J, 8, false);
|
|
2659
2659
|
this.A = qJ[0] | 0, this.B = qJ[1] | 0, this.C = qJ[2] | 0, this.D = qJ[3] | 0, this.E = qJ[4] | 0, this.F = qJ[5] | 0, this.G = qJ[6] | 0, this.H = qJ[7] | 0;
|
|
2660
2660
|
}
|
|
2661
2661
|
get() {
|
|
2662
|
-
let { A: J, B: $, C: Q, D: Y, E:
|
|
2663
|
-
return [J, $, Q, Y,
|
|
2662
|
+
let { A: J, B: $, C: Q, D: Y, E: G, F: M3, G: Z, H: K } = this;
|
|
2663
|
+
return [J, $, Q, Y, G, M3, Z, K];
|
|
2664
2664
|
}
|
|
2665
|
-
set(J, $, Q, Y,
|
|
2666
|
-
this.A = J | 0, this.B = $ | 0, this.C = Q | 0, this.D = Y | 0, this.E =
|
|
2665
|
+
set(J, $, Q, Y, G, M3, Z, K) {
|
|
2666
|
+
this.A = J | 0, this.B = $ | 0, this.C = Q | 0, this.D = Y | 0, this.E = G | 0, this.F = M3 | 0, this.G = Z | 0, this.H = K | 0;
|
|
2667
2667
|
}
|
|
2668
2668
|
process(J, $) {
|
|
2669
2669
|
for (let U = 0;U < 16; U++, $ += 4)
|
|
2670
|
-
|
|
2670
|
+
CJ[U] = J.getUint32($, false);
|
|
2671
2671
|
for (let U = 16;U < 64; U++) {
|
|
2672
|
-
let D3 =
|
|
2673
|
-
|
|
2672
|
+
let D3 = CJ[U - 15], V = CJ[U - 2], O3 = QJ(D3, 7) ^ QJ(D3, 18) ^ D3 >>> 3, L2 = QJ(V, 17) ^ QJ(V, 19) ^ V >>> 10;
|
|
2673
|
+
CJ[U] = L2 + CJ[U - 7] + O3 + CJ[U - 16] | 0;
|
|
2674
2674
|
}
|
|
2675
|
-
let { A: Q, B: Y, C:
|
|
2675
|
+
let { A: Q, B: Y, C: G, D: M3, E: Z, F: K, G: X, H: q } = this;
|
|
2676
2676
|
for (let U = 0;U < 64; U++) {
|
|
2677
|
-
let D3 = QJ(Z, 6) ^ QJ(Z, 11) ^ QJ(Z, 25), V = q + D3 + K0(Z, K, X) + HQ[U] +
|
|
2678
|
-
q = X, X = K, K = Z, Z =
|
|
2677
|
+
let D3 = QJ(Z, 6) ^ QJ(Z, 11) ^ QJ(Z, 25), V = q + D3 + K0(Z, K, X) + HQ[U] + CJ[U] | 0, L2 = (QJ(Q, 2) ^ QJ(Q, 13) ^ QJ(Q, 22)) + q0(Q, Y, G) | 0;
|
|
2678
|
+
q = X, X = K, K = Z, Z = M3 + V | 0, M3 = G, G = Y, Y = Q, Q = V + L2 | 0;
|
|
2679
2679
|
}
|
|
2680
|
-
Q = Q + this.A | 0, Y = Y + this.B | 0,
|
|
2680
|
+
Q = Q + this.A | 0, Y = Y + this.B | 0, G = G + this.C | 0, M3 = M3 + this.D | 0, Z = Z + this.E | 0, K = K + this.F | 0, X = X + this.G | 0, q = q + this.H | 0, this.set(Q, Y, G, M3, Z, K, X, q);
|
|
2681
2681
|
}
|
|
2682
2682
|
roundClean() {
|
|
2683
|
-
kJ(
|
|
2683
|
+
kJ(CJ);
|
|
2684
2684
|
}
|
|
2685
2685
|
destroy() {
|
|
2686
2686
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), kJ(this.buffer);
|
|
@@ -2696,14 +2696,14 @@ class Z8 extends O$ {
|
|
|
2696
2696
|
if (this.iHash = J.create(), typeof this.iHash.update !== "function")
|
|
2697
2697
|
throw Error("Expected instance of class which extends utils.Hash");
|
|
2698
2698
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
2699
|
-
let Y = this.blockLen,
|
|
2700
|
-
|
|
2701
|
-
for (let
|
|
2702
|
-
M3
|
|
2703
|
-
this.iHash.update(
|
|
2704
|
-
for (let
|
|
2705
|
-
M3
|
|
2706
|
-
this.oHash.update(
|
|
2699
|
+
let Y = this.blockLen, G = new Uint8Array(Y);
|
|
2700
|
+
G.set(Q.length > Y ? J.create().update(Q).digest() : Q);
|
|
2701
|
+
for (let M3 = 0;M3 < G.length; M3++)
|
|
2702
|
+
G[M3] ^= 54;
|
|
2703
|
+
this.iHash.update(G), this.oHash = J.create();
|
|
2704
|
+
for (let M3 = 0;M3 < G.length; M3++)
|
|
2705
|
+
G[M3] ^= 106;
|
|
2706
|
+
this.oHash.update(G), kJ(G);
|
|
2707
2707
|
}
|
|
2708
2708
|
update(J) {
|
|
2709
2709
|
return oJ(this), this.iHash.update(J), this;
|
|
@@ -2717,8 +2717,8 @@ class Z8 extends O$ {
|
|
|
2717
2717
|
}
|
|
2718
2718
|
_cloneInto(J) {
|
|
2719
2719
|
J || (J = Object.create(Object.getPrototypeOf(this), {}));
|
|
2720
|
-
let { oHash: $, iHash: Q, finished: Y, destroyed:
|
|
2721
|
-
return J = J, J.finished = Y, J.destroyed =
|
|
2720
|
+
let { oHash: $, iHash: Q, finished: Y, destroyed: G, blockLen: M3, outputLen: Z } = this;
|
|
2721
|
+
return J = J, J.finished = Y, J.destroyed = G, J.blockLen = M3, J.outputLen = Z, J.oHash = $._cloneInto(J.oHash), J.iHash = Q._cloneInto(J.iHash), J;
|
|
2722
2722
|
}
|
|
2723
2723
|
clone() {
|
|
2724
2724
|
return this._cloneInto();
|
|
@@ -2743,7 +2743,7 @@ function sJ(J, $) {
|
|
|
2743
2743
|
if (typeof $ !== "boolean")
|
|
2744
2744
|
throw Error(J + " boolean expected, got " + $);
|
|
2745
2745
|
}
|
|
2746
|
-
function
|
|
2746
|
+
function R$(J) {
|
|
2747
2747
|
let $ = J.toString(16);
|
|
2748
2748
|
return $.length & 1 ? "0" + $ : $;
|
|
2749
2749
|
}
|
|
@@ -2772,7 +2772,7 @@ function j0(J) {
|
|
|
2772
2772
|
return J - (UJ.a - 10);
|
|
2773
2773
|
return;
|
|
2774
2774
|
}
|
|
2775
|
-
function
|
|
2775
|
+
function C$(J) {
|
|
2776
2776
|
if (typeof J !== "string")
|
|
2777
2777
|
throw Error("hex string expected, got " + typeof J);
|
|
2778
2778
|
if (V0)
|
|
@@ -2781,13 +2781,13 @@ function R$(J) {
|
|
|
2781
2781
|
if ($ % 2)
|
|
2782
2782
|
throw Error("hex string expected, got unpadded hex of length " + $);
|
|
2783
2783
|
let Y = new Uint8Array(Q);
|
|
2784
|
-
for (let
|
|
2785
|
-
let Z = j0(J.charCodeAt(
|
|
2784
|
+
for (let G = 0, M3 = 0;G < Q; G++, M3 += 2) {
|
|
2785
|
+
let Z = j0(J.charCodeAt(M3)), K = j0(J.charCodeAt(M3 + 1));
|
|
2786
2786
|
if (Z === undefined || K === undefined) {
|
|
2787
|
-
let X = J[
|
|
2788
|
-
throw Error('hex string expected, got non-hex character "' + X + '" at index ' +
|
|
2787
|
+
let X = J[M3] + J[M3 + 1];
|
|
2788
|
+
throw Error('hex string expected, got non-hex character "' + X + '" at index ' + M3);
|
|
2789
2789
|
}
|
|
2790
|
-
Y[
|
|
2790
|
+
Y[G] = Z * 16 + K;
|
|
2791
2791
|
}
|
|
2792
2792
|
return Y;
|
|
2793
2793
|
}
|
|
@@ -2798,7 +2798,7 @@ function z8(J) {
|
|
|
2798
2798
|
return j8(J), D0(rJ(Uint8Array.from(J).reverse()));
|
|
2799
2799
|
}
|
|
2800
2800
|
function bJ(J, $) {
|
|
2801
|
-
return
|
|
2801
|
+
return C$(J.toString(16).padStart($ * 2, "0"));
|
|
2802
2802
|
}
|
|
2803
2803
|
function D8(J, $) {
|
|
2804
2804
|
return bJ(J, $).reverse();
|
|
@@ -2807,29 +2807,29 @@ function s2(J, $, Q) {
|
|
|
2807
2807
|
let Y;
|
|
2808
2808
|
if (typeof $ === "string")
|
|
2809
2809
|
try {
|
|
2810
|
-
Y =
|
|
2811
|
-
} catch (
|
|
2812
|
-
throw Error(J + " must be hex string or Uint8Array, cause: " +
|
|
2810
|
+
Y = C$($);
|
|
2811
|
+
} catch (M3) {
|
|
2812
|
+
throw Error(J + " must be hex string or Uint8Array, cause: " + M3);
|
|
2813
2813
|
}
|
|
2814
2814
|
else if (aJ($))
|
|
2815
2815
|
Y = Uint8Array.from($);
|
|
2816
2816
|
else
|
|
2817
2817
|
throw Error(J + " must be hex string or Uint8Array");
|
|
2818
|
-
let
|
|
2819
|
-
if (typeof Q === "number" &&
|
|
2820
|
-
throw Error(J + " of length " + Q + " expected, got " +
|
|
2818
|
+
let G = Y.length;
|
|
2819
|
+
if (typeof Q === "number" && G !== Q)
|
|
2820
|
+
throw Error(J + " of length " + Q + " expected, got " + G);
|
|
2821
2821
|
return Y;
|
|
2822
2822
|
}
|
|
2823
|
-
function
|
|
2823
|
+
function P$(...J) {
|
|
2824
2824
|
let $ = 0;
|
|
2825
2825
|
for (let Y = 0;Y < J.length; Y++) {
|
|
2826
|
-
let
|
|
2827
|
-
j8(
|
|
2826
|
+
let G = J[Y];
|
|
2827
|
+
j8(G), $ += G.length;
|
|
2828
2828
|
}
|
|
2829
2829
|
let Q = new Uint8Array($);
|
|
2830
|
-
for (let Y = 0,
|
|
2831
|
-
let
|
|
2832
|
-
Q.set(
|
|
2830
|
+
for (let Y = 0, G = 0;Y < J.length; Y++) {
|
|
2831
|
+
let M3 = J[Y];
|
|
2832
|
+
Q.set(M3, G), G += M3.length;
|
|
2833
2833
|
}
|
|
2834
2834
|
return Q;
|
|
2835
2835
|
}
|
|
@@ -2857,14 +2857,14 @@ function O0(J, $, Q) {
|
|
|
2857
2857
|
throw Error("qByteLen must be a number");
|
|
2858
2858
|
if (typeof Q !== "function")
|
|
2859
2859
|
throw Error("hmacFn must be a function");
|
|
2860
|
-
let Y = q8(J),
|
|
2861
|
-
Y.fill(1),
|
|
2862
|
-
}, K = (...D3) => Q(
|
|
2863
|
-
if (
|
|
2860
|
+
let Y = q8(J), G = q8(J), M3 = 0, Z = () => {
|
|
2861
|
+
Y.fill(1), G.fill(0), M3 = 0;
|
|
2862
|
+
}, K = (...D3) => Q(G, Y, ...D3), X = (D3 = q8(0)) => {
|
|
2863
|
+
if (G = K(z0([0]), D3), Y = K(), D3.length === 0)
|
|
2864
2864
|
return;
|
|
2865
|
-
|
|
2865
|
+
G = K(z0([1]), D3), Y = K();
|
|
2866
2866
|
}, q = () => {
|
|
2867
|
-
if (
|
|
2867
|
+
if (M3++ >= 1000)
|
|
2868
2868
|
throw Error("drbg: tried 1000 values");
|
|
2869
2869
|
let D3 = 0, V = [];
|
|
2870
2870
|
while (D3 < $) {
|
|
@@ -2872,7 +2872,7 @@ function O0(J, $, Q) {
|
|
|
2872
2872
|
let O3 = Y.slice();
|
|
2873
2873
|
V.push(O3), D3 += Y.length;
|
|
2874
2874
|
}
|
|
2875
|
-
return
|
|
2875
|
+
return P$(...V);
|
|
2876
2876
|
};
|
|
2877
2877
|
return (D3, V) => {
|
|
2878
2878
|
Z(), X(D3);
|
|
@@ -2884,30 +2884,30 @@ function O0(J, $, Q) {
|
|
|
2884
2884
|
}
|
|
2885
2885
|
var _Q = { bigint: (J) => typeof J === "bigint", function: (J) => typeof J === "function", boolean: (J) => typeof J === "boolean", string: (J) => typeof J === "string", stringOrUint8Array: (J) => typeof J === "string" || aJ(J), isSafeInteger: (J) => Number.isSafeInteger(J), array: (J) => Array.isArray(J), field: (J, $) => $.Fp.isValid(J), hash: (J) => typeof J === "function" && Number.isSafeInteger(J.outputLen) };
|
|
2886
2886
|
function gJ(J, $, Q = {}) {
|
|
2887
|
-
let Y = (
|
|
2888
|
-
let K = _Q[
|
|
2887
|
+
let Y = (G, M3, Z) => {
|
|
2888
|
+
let K = _Q[M3];
|
|
2889
2889
|
if (typeof K !== "function")
|
|
2890
2890
|
throw Error("invalid validator function");
|
|
2891
|
-
let X = J[
|
|
2891
|
+
let X = J[G];
|
|
2892
2892
|
if (Z && X === undefined)
|
|
2893
2893
|
return;
|
|
2894
2894
|
if (!K(X, J))
|
|
2895
|
-
throw Error("param " + String(
|
|
2895
|
+
throw Error("param " + String(G) + " is invalid. Expected " + M3 + ", got " + X);
|
|
2896
2896
|
};
|
|
2897
|
-
for (let [
|
|
2898
|
-
Y(
|
|
2899
|
-
for (let [
|
|
2900
|
-
Y(
|
|
2897
|
+
for (let [G, M3] of Object.entries($))
|
|
2898
|
+
Y(G, M3, false);
|
|
2899
|
+
for (let [G, M3] of Object.entries(Q))
|
|
2900
|
+
Y(G, M3, true);
|
|
2901
2901
|
return J;
|
|
2902
2902
|
}
|
|
2903
2903
|
function V8(J) {
|
|
2904
2904
|
let $ = new WeakMap;
|
|
2905
2905
|
return (Q, ...Y) => {
|
|
2906
|
-
let
|
|
2907
|
-
if (
|
|
2908
|
-
return
|
|
2909
|
-
let
|
|
2910
|
-
return $.set(Q,
|
|
2906
|
+
let G = $.get(Q);
|
|
2907
|
+
if (G !== undefined)
|
|
2908
|
+
return G;
|
|
2909
|
+
let M3 = J(Q, ...Y);
|
|
2910
|
+
return $.set(Q, M3), M3;
|
|
2911
2911
|
};
|
|
2912
2912
|
}
|
|
2913
2913
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
@@ -2915,9 +2915,9 @@ var t2 = BigInt(0);
|
|
|
2915
2915
|
var n2 = BigInt(1);
|
|
2916
2916
|
var vJ = BigInt(2);
|
|
2917
2917
|
var yQ = BigInt(3);
|
|
2918
|
-
var
|
|
2919
|
-
var
|
|
2920
|
-
var
|
|
2918
|
+
var C0 = BigInt(4);
|
|
2919
|
+
var P0 = BigInt(5);
|
|
2920
|
+
var B0 = BigInt(8);
|
|
2921
2921
|
function d3(J, $) {
|
|
2922
2922
|
let Q = J % $;
|
|
2923
2923
|
return Q >= t2 ? Q : $ + Q;
|
|
@@ -2933,23 +2933,23 @@ function u$(J, $) {
|
|
|
2933
2933
|
throw Error("invert: expected non-zero number");
|
|
2934
2934
|
if ($ <= t2)
|
|
2935
2935
|
throw Error("invert: expected positive modulus, got " + $);
|
|
2936
|
-
let Q = d3(J, $), Y = $,
|
|
2936
|
+
let Q = d3(J, $), Y = $, G = t2, M3 = n2, Z = n2, K = t2;
|
|
2937
2937
|
while (Q !== t2) {
|
|
2938
|
-
let q = Y / Q, U = Y % Q, D3 =
|
|
2939
|
-
Y = Q, Q = U,
|
|
2938
|
+
let q = Y / Q, U = Y % Q, D3 = G - Z * q, V = M3 - K * q;
|
|
2939
|
+
Y = Q, Q = U, G = Z, M3 = K, Z = D3, K = V;
|
|
2940
2940
|
}
|
|
2941
2941
|
if (Y !== n2)
|
|
2942
2942
|
throw Error("invert: does not exist");
|
|
2943
|
-
return d3(
|
|
2943
|
+
return d3(G, $);
|
|
2944
2944
|
}
|
|
2945
2945
|
function L0(J, $) {
|
|
2946
|
-
let Q = (J.ORDER + n2) /
|
|
2946
|
+
let Q = (J.ORDER + n2) / C0, Y = J.pow($, Q);
|
|
2947
2947
|
if (!J.eql(J.sqr(Y), $))
|
|
2948
2948
|
throw Error("Cannot find square root");
|
|
2949
2949
|
return Y;
|
|
2950
2950
|
}
|
|
2951
2951
|
function AQ(J, $) {
|
|
2952
|
-
let Q = (J.ORDER -
|
|
2952
|
+
let Q = (J.ORDER - P0) / B0, Y = J.mul($, vJ), G = J.pow(Y, Q), M3 = J.mul($, G), Z = J.mul(J.mul(M3, vJ), G), K = J.mul(M3, J.sub(Z, J.ONE));
|
|
2953
2953
|
if (!J.eql(J.sqr(K), $))
|
|
2954
2954
|
throw Error("Cannot find square root");
|
|
2955
2955
|
return K;
|
|
@@ -2960,19 +2960,19 @@ function wQ(J) {
|
|
|
2960
2960
|
let $ = J - n2, Q = 0;
|
|
2961
2961
|
while ($ % vJ === t2)
|
|
2962
2962
|
$ /= vJ, Q++;
|
|
2963
|
-
let Y = vJ,
|
|
2964
|
-
while (
|
|
2963
|
+
let Y = vJ, G = B$(J);
|
|
2964
|
+
while (R0(G, Y) === 1)
|
|
2965
2965
|
if (Y++ > 1000)
|
|
2966
2966
|
throw Error("Cannot find square root: probably non-prime P");
|
|
2967
2967
|
if (Q === 1)
|
|
2968
2968
|
return L0;
|
|
2969
|
-
let
|
|
2969
|
+
let M3 = G.pow(Y, $), Z = ($ + n2) / vJ;
|
|
2970
2970
|
return function(X, q) {
|
|
2971
2971
|
if (X.is0(q))
|
|
2972
2972
|
return q;
|
|
2973
|
-
if (
|
|
2973
|
+
if (R0(X, q) !== 1)
|
|
2974
2974
|
throw Error("Cannot find square root");
|
|
2975
|
-
let U = Q, D3 = X.mul(X.ONE,
|
|
2975
|
+
let U = Q, D3 = X.mul(X.ONE, M3), V = X.pow(q, $), O3 = X.pow(q, Z);
|
|
2976
2976
|
while (!X.eql(V, X.ONE)) {
|
|
2977
2977
|
if (X.is0(V))
|
|
2978
2978
|
return X.ZERO;
|
|
@@ -2987,16 +2987,16 @@ function wQ(J) {
|
|
|
2987
2987
|
};
|
|
2988
2988
|
}
|
|
2989
2989
|
function EQ(J) {
|
|
2990
|
-
if (J %
|
|
2990
|
+
if (J % C0 === yQ)
|
|
2991
2991
|
return L0;
|
|
2992
|
-
if (J %
|
|
2992
|
+
if (J % B0 === P0)
|
|
2993
2993
|
return AQ;
|
|
2994
2994
|
return wQ(J);
|
|
2995
2995
|
}
|
|
2996
2996
|
var xQ = ["create", "isValid", "is0", "neg", "inv", "sqrt", "sqr", "eql", "add", "sub", "mul", "pow", "div", "addN", "subN", "mulN", "sqrN"];
|
|
2997
2997
|
function N8(J) {
|
|
2998
|
-
let $ = { ORDER: "bigint", MASK: "bigint", BYTES: "isSafeInteger", BITS: "isSafeInteger" }, Q = xQ.reduce((Y,
|
|
2999
|
-
return Y[
|
|
2998
|
+
let $ = { ORDER: "bigint", MASK: "bigint", BYTES: "isSafeInteger", BITS: "isSafeInteger" }, Q = xQ.reduce((Y, G) => {
|
|
2999
|
+
return Y[G] = "function", Y;
|
|
3000
3000
|
}, $);
|
|
3001
3001
|
return gJ(J, Q);
|
|
3002
3002
|
}
|
|
@@ -3007,45 +3007,45 @@ function kQ(J, $, Q) {
|
|
|
3007
3007
|
return J.ONE;
|
|
3008
3008
|
if (Q === n2)
|
|
3009
3009
|
return $;
|
|
3010
|
-
let Y = J.ONE,
|
|
3010
|
+
let Y = J.ONE, G = $;
|
|
3011
3011
|
while (Q > t2) {
|
|
3012
3012
|
if (Q & n2)
|
|
3013
|
-
Y = J.mul(Y,
|
|
3014
|
-
|
|
3013
|
+
Y = J.mul(Y, G);
|
|
3014
|
+
G = J.sqr(G), Q >>= n2;
|
|
3015
3015
|
}
|
|
3016
3016
|
return Y;
|
|
3017
3017
|
}
|
|
3018
3018
|
function O8(J, $, Q = false) {
|
|
3019
|
-
let Y = Array($.length).fill(Q ? J.ZERO : undefined),
|
|
3019
|
+
let Y = Array($.length).fill(Q ? J.ZERO : undefined), G = $.reduce((Z, K, X) => {
|
|
3020
3020
|
if (J.is0(K))
|
|
3021
3021
|
return Z;
|
|
3022
3022
|
return Y[X] = Z, J.mul(Z, K);
|
|
3023
|
-
}, J.ONE),
|
|
3023
|
+
}, J.ONE), M3 = J.inv(G);
|
|
3024
3024
|
return $.reduceRight((Z, K, X) => {
|
|
3025
3025
|
if (J.is0(K))
|
|
3026
3026
|
return Z;
|
|
3027
3027
|
return Y[X] = J.mul(Z, Y[X]), J.mul(Z, K);
|
|
3028
|
-
},
|
|
3028
|
+
}, M3), Y;
|
|
3029
3029
|
}
|
|
3030
|
-
function
|
|
3031
|
-
let Q = (J.ORDER - n2) / vJ, Y = J.pow($, Q),
|
|
3032
|
-
if (!
|
|
3030
|
+
function R0(J, $) {
|
|
3031
|
+
let Q = (J.ORDER - n2) / vJ, Y = J.pow($, Q), G = J.eql(Y, J.ONE), M3 = J.eql(Y, J.ZERO), Z = J.eql(Y, J.neg(J.ONE));
|
|
3032
|
+
if (!G && !M3 && !Z)
|
|
3033
3033
|
throw Error("invalid Legendre symbol result");
|
|
3034
|
-
return
|
|
3034
|
+
return G ? 1 : M3 ? 0 : -1;
|
|
3035
3035
|
}
|
|
3036
|
-
function
|
|
3036
|
+
function R8(J, $) {
|
|
3037
3037
|
if ($ !== undefined)
|
|
3038
3038
|
f$($);
|
|
3039
3039
|
let Q = $ !== undefined ? $ : J.toString(2).length, Y = Math.ceil(Q / 8);
|
|
3040
3040
|
return { nBitLength: Q, nByteLength: Y };
|
|
3041
3041
|
}
|
|
3042
|
-
function
|
|
3042
|
+
function B$(J, $, Q = false, Y = {}) {
|
|
3043
3043
|
if (J <= t2)
|
|
3044
3044
|
throw Error("invalid field: expected ORDER > 0, got " + J);
|
|
3045
|
-
let { nBitLength:
|
|
3046
|
-
if (
|
|
3045
|
+
let { nBitLength: G, nByteLength: M3 } = R8(J, $);
|
|
3046
|
+
if (M3 > 2048)
|
|
3047
3047
|
throw Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
3048
|
-
let Z, K = Object.freeze({ ORDER: J, isLE: Q, BITS:
|
|
3048
|
+
let Z, K = Object.freeze({ ORDER: J, isLE: Q, BITS: G, BYTES: M3, MASK: fJ(G), ZERO: t2, ONE: n2, create: (X) => d3(X, J), isValid: (X) => {
|
|
3049
3049
|
if (typeof X !== "bigint")
|
|
3050
3050
|
throw Error("invalid field element: expected bigint, got " + typeof X);
|
|
3051
3051
|
return t2 <= X && X < J;
|
|
@@ -3053,9 +3053,9 @@ function P$(J, $, Q = false, Y = {}) {
|
|
|
3053
3053
|
if (!Z)
|
|
3054
3054
|
Z = EQ(J);
|
|
3055
3055
|
return Z(K, X);
|
|
3056
|
-
}), toBytes: (X) => Q ? D8(X,
|
|
3057
|
-
if (X.length !==
|
|
3058
|
-
throw Error("Field.fromBytes: expected " +
|
|
3056
|
+
}), toBytes: (X) => Q ? D8(X, M3) : bJ(X, M3), fromBytes: (X) => {
|
|
3057
|
+
if (X.length !== M3)
|
|
3058
|
+
throw Error("Field.fromBytes: expected " + M3 + " bytes, got " + X.length);
|
|
3059
3059
|
return Q ? z8(X) : WJ(X);
|
|
3060
3060
|
}, invertBatch: (X) => O8(K, X), cmov: (X, q, U) => U ? q : X });
|
|
3061
3061
|
return Object.freeze(K);
|
|
@@ -3066,21 +3066,21 @@ function T0(J) {
|
|
|
3066
3066
|
let $ = J.toString(2).length;
|
|
3067
3067
|
return Math.ceil($ / 8);
|
|
3068
3068
|
}
|
|
3069
|
-
function
|
|
3069
|
+
function C8(J) {
|
|
3070
3070
|
let $ = T0(J);
|
|
3071
3071
|
return $ + Math.ceil($ / 2);
|
|
3072
3072
|
}
|
|
3073
3073
|
function I0(J, $, Q = false) {
|
|
3074
|
-
let Y = J.length,
|
|
3075
|
-
if (Y < 16 || Y <
|
|
3076
|
-
throw Error("expected " +
|
|
3074
|
+
let Y = J.length, G = T0($), M3 = C8($);
|
|
3075
|
+
if (Y < 16 || Y < M3 || Y > 1024)
|
|
3076
|
+
throw Error("expected " + M3 + "-1024 bytes of input, got " + Y);
|
|
3077
3077
|
let Z = Q ? z8(J) : WJ(J), K = d3(Z, $ - n2) + n2;
|
|
3078
|
-
return Q ? D8(K,
|
|
3078
|
+
return Q ? D8(K, G) : bJ(K, G);
|
|
3079
3079
|
}
|
|
3080
3080
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3081
3081
|
var H0 = BigInt(0);
|
|
3082
3082
|
var I8 = BigInt(1);
|
|
3083
|
-
function
|
|
3083
|
+
function P8(J, $) {
|
|
3084
3084
|
let Q = $.negate();
|
|
3085
3085
|
return J ? Q : $;
|
|
3086
3086
|
}
|
|
@@ -3088,15 +3088,15 @@ function _0(J, $) {
|
|
|
3088
3088
|
if (!Number.isSafeInteger(J) || J <= 0 || J > $)
|
|
3089
3089
|
throw Error("invalid window size, expected [1.." + $ + "], got W=" + J);
|
|
3090
3090
|
}
|
|
3091
|
-
function
|
|
3091
|
+
function B8(J, $) {
|
|
3092
3092
|
_0(J, $);
|
|
3093
|
-
let Q = Math.ceil($ / J) + 1, Y = 2 ** (J - 1),
|
|
3094
|
-
return { windows: Q, windowSize: Y, mask:
|
|
3093
|
+
let Q = Math.ceil($ / J) + 1, Y = 2 ** (J - 1), G = 2 ** J, M3 = fJ(J), Z = BigInt(J);
|
|
3094
|
+
return { windows: Q, windowSize: Y, mask: M3, maxNumber: G, shiftBy: Z };
|
|
3095
3095
|
}
|
|
3096
3096
|
function S0(J, $, Q) {
|
|
3097
|
-
let { windowSize: Y, mask:
|
|
3097
|
+
let { windowSize: Y, mask: G, maxNumber: M3, shiftBy: Z } = Q, K = Number(J & G), X = J >> Z;
|
|
3098
3098
|
if (K > Y)
|
|
3099
|
-
K -=
|
|
3099
|
+
K -= M3, X += I8;
|
|
3100
3100
|
let q = $ * Y, U = q + Math.abs(K) - 1, D3 = K === 0, V = K < 0, O3 = $ % 2 !== 0;
|
|
3101
3101
|
return { nextN: X, offset: U, isZero: D3, isNeg: V, isNegF: O3, offsetF: q };
|
|
3102
3102
|
}
|
|
@@ -3122,74 +3122,74 @@ function T8(J) {
|
|
|
3122
3122
|
return y0.get(J) || 1;
|
|
3123
3123
|
}
|
|
3124
3124
|
function A0(J, $) {
|
|
3125
|
-
return { constTimeNegate:
|
|
3125
|
+
return { constTimeNegate: P8, hasPrecomputes(Q) {
|
|
3126
3126
|
return T8(Q) !== 1;
|
|
3127
|
-
}, unsafeLadder(Q, Y,
|
|
3128
|
-
let
|
|
3127
|
+
}, unsafeLadder(Q, Y, G = J.ZERO) {
|
|
3128
|
+
let M3 = Q;
|
|
3129
3129
|
while (Y > H0) {
|
|
3130
3130
|
if (Y & I8)
|
|
3131
|
-
|
|
3132
|
-
|
|
3131
|
+
G = G.add(M3);
|
|
3132
|
+
M3 = M3.double(), Y >>= I8;
|
|
3133
3133
|
}
|
|
3134
|
-
return
|
|
3134
|
+
return G;
|
|
3135
3135
|
}, precomputeWindow(Q, Y) {
|
|
3136
|
-
let { windows:
|
|
3137
|
-
for (let q = 0;q <
|
|
3136
|
+
let { windows: G, windowSize: M3 } = B8(Y, $), Z = [], K = Q, X = K;
|
|
3137
|
+
for (let q = 0;q < G; q++) {
|
|
3138
3138
|
X = K, Z.push(X);
|
|
3139
|
-
for (let U = 1;U <
|
|
3139
|
+
for (let U = 1;U < M3; U++)
|
|
3140
3140
|
X = X.add(K), Z.push(X);
|
|
3141
3141
|
K = X.double();
|
|
3142
3142
|
}
|
|
3143
3143
|
return Z;
|
|
3144
|
-
}, wNAF(Q, Y,
|
|
3145
|
-
let { ZERO:
|
|
3144
|
+
}, wNAF(Q, Y, G) {
|
|
3145
|
+
let { ZERO: M3, BASE: Z } = J, K = B8(Q, $);
|
|
3146
3146
|
for (let X = 0;X < K.windows; X++) {
|
|
3147
|
-
let { nextN: q, offset: U, isZero: D3, isNeg: V, isNegF: O3, offsetF: L2 } = S0(
|
|
3148
|
-
if (
|
|
3149
|
-
Z = Z.add(
|
|
3147
|
+
let { nextN: q, offset: U, isZero: D3, isNeg: V, isNegF: O3, offsetF: L2 } = S0(G, X, K);
|
|
3148
|
+
if (G = q, D3)
|
|
3149
|
+
Z = Z.add(P8(O3, Y[L2]));
|
|
3150
3150
|
else
|
|
3151
|
-
|
|
3151
|
+
M3 = M3.add(P8(V, Y[U]));
|
|
3152
3152
|
}
|
|
3153
|
-
return { p:
|
|
3154
|
-
}, wNAFUnsafe(Q, Y,
|
|
3155
|
-
let Z =
|
|
3153
|
+
return { p: M3, f: Z };
|
|
3154
|
+
}, wNAFUnsafe(Q, Y, G, M3 = J.ZERO) {
|
|
3155
|
+
let Z = B8(Q, $);
|
|
3156
3156
|
for (let K = 0;K < Z.windows; K++) {
|
|
3157
|
-
if (
|
|
3157
|
+
if (G === H0)
|
|
3158
3158
|
break;
|
|
3159
|
-
let { nextN: X, offset: q, isZero: U, isNeg: D3 } = S0(
|
|
3160
|
-
if (
|
|
3159
|
+
let { nextN: X, offset: q, isZero: U, isNeg: D3 } = S0(G, K, Z);
|
|
3160
|
+
if (G = X, U)
|
|
3161
3161
|
continue;
|
|
3162
3162
|
else {
|
|
3163
3163
|
let V = Y[q];
|
|
3164
|
-
|
|
3164
|
+
M3 = M3.add(D3 ? V.negate() : V);
|
|
3165
3165
|
}
|
|
3166
3166
|
}
|
|
3167
|
-
return
|
|
3168
|
-
}, getPrecomputes(Q, Y,
|
|
3169
|
-
let
|
|
3170
|
-
if (!
|
|
3171
|
-
if (
|
|
3172
|
-
L8.set(Y, M3
|
|
3167
|
+
return M3;
|
|
3168
|
+
}, getPrecomputes(Q, Y, G) {
|
|
3169
|
+
let M3 = L8.get(Y);
|
|
3170
|
+
if (!M3) {
|
|
3171
|
+
if (M3 = this.precomputeWindow(Y, Q), Q !== 1)
|
|
3172
|
+
L8.set(Y, G(M3));
|
|
3173
3173
|
}
|
|
3174
|
-
return
|
|
3175
|
-
}, wNAFCached(Q, Y,
|
|
3176
|
-
let
|
|
3177
|
-
return this.wNAF(
|
|
3178
|
-
}, wNAFCachedUnsafe(Q, Y,
|
|
3174
|
+
return M3;
|
|
3175
|
+
}, wNAFCached(Q, Y, G) {
|
|
3176
|
+
let M3 = T8(Q);
|
|
3177
|
+
return this.wNAF(M3, this.getPrecomputes(M3, Q, G), Y);
|
|
3178
|
+
}, wNAFCachedUnsafe(Q, Y, G, M3) {
|
|
3179
3179
|
let Z = T8(Q);
|
|
3180
3180
|
if (Z === 1)
|
|
3181
|
-
return this.unsafeLadder(Q, Y,
|
|
3182
|
-
return this.wNAFUnsafe(Z, this.getPrecomputes(Z, Q,
|
|
3181
|
+
return this.unsafeLadder(Q, Y, M3);
|
|
3182
|
+
return this.wNAFUnsafe(Z, this.getPrecomputes(Z, Q, G), Y, M3);
|
|
3183
3183
|
}, setWindowSize(Q, Y) {
|
|
3184
3184
|
_0(Y, $), y0.set(Q, Y), L8.delete(Q);
|
|
3185
3185
|
} };
|
|
3186
3186
|
}
|
|
3187
3187
|
function w0(J, $, Q, Y) {
|
|
3188
3188
|
bQ(Q, J), FQ(Y, $);
|
|
3189
|
-
let
|
|
3190
|
-
if (
|
|
3189
|
+
let G = Q.length, M3 = Y.length;
|
|
3190
|
+
if (G !== M3)
|
|
3191
3191
|
throw Error("arrays of points and scalars must have equal length");
|
|
3192
|
-
let Z = J.ZERO, K = N0(BigInt(
|
|
3192
|
+
let Z = J.ZERO, K = N0(BigInt(G)), X = 1;
|
|
3193
3193
|
if (K > 12)
|
|
3194
3194
|
X = K - 3;
|
|
3195
3195
|
else if (K > 4)
|
|
@@ -3199,7 +3199,7 @@ function w0(J, $, Q, Y) {
|
|
|
3199
3199
|
let q = fJ(X), U = Array(Number(q) + 1).fill(Z), D3 = Math.floor(($.BITS - 1) / X) * X, V = Z;
|
|
3200
3200
|
for (let O3 = D3;O3 >= 0; O3 -= X) {
|
|
3201
3201
|
U.fill(Z);
|
|
3202
|
-
for (let N2 = 0;N2 <
|
|
3202
|
+
for (let N2 = 0;N2 < M3; N2++) {
|
|
3203
3203
|
let b3 = Y[N2], y3 = Number(b3 >> BigInt(O3) & q);
|
|
3204
3204
|
U[y3] = U[y3].add(Q[N2]);
|
|
3205
3205
|
}
|
|
@@ -3213,7 +3213,7 @@ function w0(J, $, Q, Y) {
|
|
|
3213
3213
|
return V;
|
|
3214
3214
|
}
|
|
3215
3215
|
function H8(J) {
|
|
3216
|
-
return N8(J.Fp), gJ(J, { n: "bigint", h: "bigint", Gx: "field", Gy: "field" }, { nBitLength: "isSafeInteger", nByteLength: "isSafeInteger" }), Object.freeze({ ...
|
|
3216
|
+
return N8(J.Fp), gJ(J, { n: "bigint", h: "bigint", Gx: "field", Gy: "field" }, { nBitLength: "isSafeInteger", nByteLength: "isSafeInteger" }), Object.freeze({ ...R8(J.n, J.nBitLength), ...J, ...{ p: J.Fp.ORDER } });
|
|
3217
3217
|
}
|
|
3218
3218
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3219
3219
|
function E0(J) {
|
|
@@ -3225,9 +3225,9 @@ function E0(J) {
|
|
|
3225
3225
|
function fQ(J) {
|
|
3226
3226
|
let $ = H8(J);
|
|
3227
3227
|
gJ($, { a: "field", b: "field" }, { allowInfinityPoint: "boolean", allowedPrivateKeyLengths: "array", clearCofactor: "function", fromBytes: "function", isTorsionFree: "function", toBytes: "function", wrapPrivateKey: "boolean" });
|
|
3228
|
-
let { endo: Q, Fp: Y, a:
|
|
3228
|
+
let { endo: Q, Fp: Y, a: G } = $;
|
|
3229
3229
|
if (Q) {
|
|
3230
|
-
if (!Y.eql(
|
|
3230
|
+
if (!Y.eql(G, Y.ZERO))
|
|
3231
3231
|
throw Error("invalid endo: CURVE.a must be 0");
|
|
3232
3232
|
if (typeof Q !== "object" || typeof Q.beta !== "bigint" || typeof Q.splitScalar !== "function")
|
|
3233
3233
|
throw Error('invalid endo: expected "beta": bigint and "splitScalar": function');
|
|
@@ -3246,22 +3246,22 @@ var jJ = { Err: x0, _tlv: { encode: (J, $) => {
|
|
|
3246
3246
|
throw new Q("tlv.encode: wrong tag");
|
|
3247
3247
|
if ($.length & 1)
|
|
3248
3248
|
throw new Q("tlv.encode: unpadded data");
|
|
3249
|
-
let Y = $.length / 2,
|
|
3250
|
-
if (
|
|
3249
|
+
let Y = $.length / 2, G = R$(Y);
|
|
3250
|
+
if (G.length / 2 & 128)
|
|
3251
3251
|
throw new Q("tlv.encode: long form length too big");
|
|
3252
|
-
let
|
|
3253
|
-
return
|
|
3252
|
+
let M3 = Y > 127 ? R$(G.length / 2 | 128) : "";
|
|
3253
|
+
return R$(J) + M3 + G + $;
|
|
3254
3254
|
}, decode(J, $) {
|
|
3255
3255
|
let { Err: Q } = jJ, Y = 0;
|
|
3256
3256
|
if (J < 0 || J > 256)
|
|
3257
3257
|
throw new Q("tlv.encode: wrong tag");
|
|
3258
3258
|
if ($.length < 2 || $[Y++] !== J)
|
|
3259
3259
|
throw new Q("tlv.decode: wrong tlv");
|
|
3260
|
-
let
|
|
3261
|
-
if (!
|
|
3262
|
-
Z =
|
|
3260
|
+
let G = $[Y++], M3 = !!(G & 128), Z = 0;
|
|
3261
|
+
if (!M3)
|
|
3262
|
+
Z = G;
|
|
3263
3263
|
else {
|
|
3264
|
-
let X =
|
|
3264
|
+
let X = G & 127;
|
|
3265
3265
|
if (!X)
|
|
3266
3266
|
throw new Q("tlv.decode(long): indefinite length not supported");
|
|
3267
3267
|
if (X > 4)
|
|
@@ -3284,7 +3284,7 @@ var jJ = { Err: x0, _tlv: { encode: (J, $) => {
|
|
|
3284
3284
|
let { Err: $ } = jJ;
|
|
3285
3285
|
if (J < zJ)
|
|
3286
3286
|
throw new $("integer: negative integers are not allowed");
|
|
3287
|
-
let Q =
|
|
3287
|
+
let Q = R$(J);
|
|
3288
3288
|
if (Number.parseInt(Q[0], 16) & 8)
|
|
3289
3289
|
Q = "00" + Q;
|
|
3290
3290
|
if (Q.length & 1)
|
|
@@ -3298,40 +3298,40 @@ var jJ = { Err: x0, _tlv: { encode: (J, $) => {
|
|
|
3298
3298
|
throw new $("invalid signature integer: unnecessary leading zero");
|
|
3299
3299
|
return WJ(J);
|
|
3300
3300
|
} }, toSig(J) {
|
|
3301
|
-
let { Err: $, _int: Q, _tlv: Y } = jJ,
|
|
3301
|
+
let { Err: $, _int: Q, _tlv: Y } = jJ, G = s2("signature", J), { v: M3, l: Z } = Y.decode(48, G);
|
|
3302
3302
|
if (Z.length)
|
|
3303
3303
|
throw new $("invalid signature: left bytes after parsing");
|
|
3304
|
-
let { v: K, l: X } = Y.decode(2,
|
|
3304
|
+
let { v: K, l: X } = Y.decode(2, M3), { v: q, l: U } = Y.decode(2, X);
|
|
3305
3305
|
if (U.length)
|
|
3306
3306
|
throw new $("invalid signature: left bytes after parsing");
|
|
3307
3307
|
return { r: Q.decode(K), s: Q.decode(q) };
|
|
3308
3308
|
}, hexFromSig(J) {
|
|
3309
|
-
let { _tlv: $, _int: Q } = jJ, Y = $.encode(2, Q.encode(J.r)),
|
|
3310
|
-
return $.encode(48,
|
|
3309
|
+
let { _tlv: $, _int: Q } = jJ, Y = $.encode(2, Q.encode(J.r)), G = $.encode(2, Q.encode(J.s)), M3 = Y + G;
|
|
3310
|
+
return $.encode(48, M3);
|
|
3311
3311
|
} };
|
|
3312
3312
|
function S8(J, $) {
|
|
3313
3313
|
return rJ(bJ(J, $));
|
|
3314
3314
|
}
|
|
3315
3315
|
var zJ = BigInt(0);
|
|
3316
3316
|
var h3 = BigInt(1);
|
|
3317
|
-
var
|
|
3317
|
+
var hM = BigInt(2);
|
|
3318
3318
|
var _8 = BigInt(3);
|
|
3319
3319
|
var gQ = BigInt(4);
|
|
3320
3320
|
function vQ(J) {
|
|
3321
|
-
let $ = fQ(J), { Fp: Q } = $, Y =
|
|
3322
|
-
let
|
|
3323
|
-
return
|
|
3324
|
-
}),
|
|
3325
|
-
let j = W.subarray(1),
|
|
3326
|
-
return { x:
|
|
3321
|
+
let $ = fQ(J), { Fp: Q } = $, Y = B$($.n, $.nBitLength), G = $.toBytes || ((W, j, P3) => {
|
|
3322
|
+
let B3 = j.toAffine();
|
|
3323
|
+
return P$(Uint8Array.from([4]), Q.toBytes(B3.x), Q.toBytes(B3.y));
|
|
3324
|
+
}), M3 = $.fromBytes || ((W) => {
|
|
3325
|
+
let j = W.subarray(1), P3 = Q.fromBytes(j.subarray(0, Q.BYTES)), B3 = Q.fromBytes(j.subarray(Q.BYTES, 2 * Q.BYTES));
|
|
3326
|
+
return { x: P3, y: B3 };
|
|
3327
3327
|
});
|
|
3328
3328
|
function Z(W) {
|
|
3329
|
-
let { a: j, b:
|
|
3330
|
-
return Q.add(Q.add(E3, Q.mul(W, j)),
|
|
3329
|
+
let { a: j, b: P3 } = $, B3 = Q.sqr(W), E3 = Q.mul(B3, W);
|
|
3330
|
+
return Q.add(Q.add(E3, Q.mul(W, j)), P3);
|
|
3331
3331
|
}
|
|
3332
3332
|
function K(W, j) {
|
|
3333
|
-
let
|
|
3334
|
-
return Q.eql(
|
|
3333
|
+
let P3 = Q.sqr(j), B3 = Z(W);
|
|
3334
|
+
return Q.eql(P3, B3);
|
|
3335
3335
|
}
|
|
3336
3336
|
if (!K($.Gx, $.Gy))
|
|
3337
3337
|
throw Error("bad curve params: generator point");
|
|
@@ -3342,21 +3342,21 @@ function vQ(J) {
|
|
|
3342
3342
|
return v$(W, h3, $.n);
|
|
3343
3343
|
}
|
|
3344
3344
|
function D3(W) {
|
|
3345
|
-
let { allowedPrivateKeyLengths: j, nByteLength:
|
|
3345
|
+
let { allowedPrivateKeyLengths: j, nByteLength: P3, wrapPrivateKey: B3, n: E3 } = $;
|
|
3346
3346
|
if (j && typeof W !== "bigint") {
|
|
3347
3347
|
if (aJ(W))
|
|
3348
3348
|
W = rJ(W);
|
|
3349
3349
|
if (typeof W !== "string" || !j.includes(W.length))
|
|
3350
3350
|
throw Error("invalid private key");
|
|
3351
|
-
W = W.padStart(
|
|
3351
|
+
W = W.padStart(P3 * 2, "0");
|
|
3352
3352
|
}
|
|
3353
3353
|
let x3;
|
|
3354
3354
|
try {
|
|
3355
|
-
x3 = typeof W === "bigint" ? W : WJ(s2("private key", W,
|
|
3355
|
+
x3 = typeof W === "bigint" ? W : WJ(s2("private key", W, P3));
|
|
3356
3356
|
} catch (k2) {
|
|
3357
|
-
throw Error("invalid private key, expected hex or " +
|
|
3357
|
+
throw Error("invalid private key, expected hex or " + P3 + " bytes, got " + typeof W);
|
|
3358
3358
|
}
|
|
3359
|
-
if (
|
|
3359
|
+
if (B3)
|
|
3360
3360
|
x3 = d3(x3, E3);
|
|
3361
3361
|
return FJ("private key", x3, h3, E3), x3;
|
|
3362
3362
|
}
|
|
@@ -3365,13 +3365,13 @@ function vQ(J) {
|
|
|
3365
3365
|
throw Error("ProjectivePoint expected");
|
|
3366
3366
|
}
|
|
3367
3367
|
let O3 = V8((W, j) => {
|
|
3368
|
-
let { px:
|
|
3368
|
+
let { px: P3, py: B3, pz: E3 } = W;
|
|
3369
3369
|
if (Q.eql(E3, Q.ONE))
|
|
3370
|
-
return { x:
|
|
3370
|
+
return { x: P3, y: B3 };
|
|
3371
3371
|
let x3 = W.is0();
|
|
3372
3372
|
if (j == null)
|
|
3373
3373
|
j = x3 ? Q.ONE : Q.inv(E3);
|
|
3374
|
-
let k2 = Q.mul(
|
|
3374
|
+
let k2 = Q.mul(P3, j), S3 = Q.mul(B3, j), A3 = Q.mul(E3, j);
|
|
3375
3375
|
if (x3)
|
|
3376
3376
|
return { x: Q.ZERO, y: Q.ZERO };
|
|
3377
3377
|
if (!Q.eql(A3, Q.ONE))
|
|
@@ -3383,10 +3383,10 @@ function vQ(J) {
|
|
|
3383
3383
|
return;
|
|
3384
3384
|
throw Error("bad point: ZERO");
|
|
3385
3385
|
}
|
|
3386
|
-
let { x: j, y:
|
|
3387
|
-
if (!Q.isValid(j) || !Q.isValid(
|
|
3386
|
+
let { x: j, y: P3 } = W.toAffine();
|
|
3387
|
+
if (!Q.isValid(j) || !Q.isValid(P3))
|
|
3388
3388
|
throw Error("bad point: x or y not FE");
|
|
3389
|
-
if (!K(j,
|
|
3389
|
+
if (!K(j, P3))
|
|
3390
3390
|
throw Error("bad point: equation left != right");
|
|
3391
3391
|
if (!W.isTorsionFree())
|
|
3392
3392
|
throw Error("bad point: not in prime-order subgroup");
|
|
@@ -3394,25 +3394,25 @@ function vQ(J) {
|
|
|
3394
3394
|
});
|
|
3395
3395
|
|
|
3396
3396
|
class N2 {
|
|
3397
|
-
constructor(W, j,
|
|
3397
|
+
constructor(W, j, P3) {
|
|
3398
3398
|
if (W == null || !Q.isValid(W))
|
|
3399
3399
|
throw Error("x required");
|
|
3400
3400
|
if (j == null || !Q.isValid(j) || Q.is0(j))
|
|
3401
3401
|
throw Error("y required");
|
|
3402
|
-
if (
|
|
3402
|
+
if (P3 == null || !Q.isValid(P3))
|
|
3403
3403
|
throw Error("z required");
|
|
3404
|
-
this.px = W, this.py = j, this.pz =
|
|
3404
|
+
this.px = W, this.py = j, this.pz = P3, Object.freeze(this);
|
|
3405
3405
|
}
|
|
3406
3406
|
static fromAffine(W) {
|
|
3407
|
-
let { x: j, y:
|
|
3408
|
-
if (!W || !Q.isValid(j) || !Q.isValid(
|
|
3407
|
+
let { x: j, y: P3 } = W || {};
|
|
3408
|
+
if (!W || !Q.isValid(j) || !Q.isValid(P3))
|
|
3409
3409
|
throw Error("invalid affine point");
|
|
3410
3410
|
if (W instanceof N2)
|
|
3411
3411
|
throw Error("projective point not allowed");
|
|
3412
|
-
let
|
|
3413
|
-
if (
|
|
3412
|
+
let B3 = (E3) => Q.eql(E3, Q.ZERO);
|
|
3413
|
+
if (B3(j) && B3(P3))
|
|
3414
3414
|
return N2.ZERO;
|
|
3415
|
-
return new N2(j,
|
|
3415
|
+
return new N2(j, P3, Q.ONE);
|
|
3416
3416
|
}
|
|
3417
3417
|
get x() {
|
|
3418
3418
|
return this.toAffine().x;
|
|
@@ -3421,11 +3421,11 @@ function vQ(J) {
|
|
|
3421
3421
|
return this.toAffine().y;
|
|
3422
3422
|
}
|
|
3423
3423
|
static normalizeZ(W) {
|
|
3424
|
-
let j = O8(Q, W.map((
|
|
3425
|
-
return W.map((
|
|
3424
|
+
let j = O8(Q, W.map((P3) => P3.pz));
|
|
3425
|
+
return W.map((P3, B3) => P3.toAffine(j[B3])).map(N2.fromAffine);
|
|
3426
3426
|
}
|
|
3427
3427
|
static fromHex(W) {
|
|
3428
|
-
let j = N2.fromAffine(
|
|
3428
|
+
let j = N2.fromAffine(M3(s2("pointHex", W)));
|
|
3429
3429
|
return j.assertValidity(), j;
|
|
3430
3430
|
}
|
|
3431
3431
|
static fromPrivateKey(W) {
|
|
@@ -3448,22 +3448,22 @@ function vQ(J) {
|
|
|
3448
3448
|
}
|
|
3449
3449
|
equals(W) {
|
|
3450
3450
|
V(W);
|
|
3451
|
-
let { px: j, py:
|
|
3451
|
+
let { px: j, py: P3, pz: B3 } = this, { px: E3, py: x3, pz: k2 } = W, S3 = Q.eql(Q.mul(j, k2), Q.mul(E3, B3)), A3 = Q.eql(Q.mul(P3, k2), Q.mul(x3, B3));
|
|
3452
3452
|
return S3 && A3;
|
|
3453
3453
|
}
|
|
3454
3454
|
negate() {
|
|
3455
3455
|
return new N2(this.px, Q.neg(this.py), this.pz);
|
|
3456
3456
|
}
|
|
3457
3457
|
double() {
|
|
3458
|
-
let { a: W, b: j } = $,
|
|
3459
|
-
return z = Q.add(z, z), A3 = Q.mul(
|
|
3458
|
+
let { a: W, b: j } = $, P3 = Q.mul(j, _8), { px: B3, py: E3, pz: x3 } = this, k2 = Q.ZERO, S3 = Q.ZERO, A3 = Q.ZERO, _2 = Q.mul(B3, B3), l3 = Q.mul(E3, E3), u2 = Q.mul(x3, x3), z = Q.mul(B3, E3);
|
|
3459
|
+
return z = Q.add(z, z), A3 = Q.mul(B3, x3), A3 = Q.add(A3, A3), k2 = Q.mul(W, A3), S3 = Q.mul(P3, u2), S3 = Q.add(k2, S3), k2 = Q.sub(l3, S3), S3 = Q.add(l3, S3), S3 = Q.mul(k2, S3), k2 = Q.mul(z, k2), A3 = Q.mul(P3, A3), u2 = Q.mul(W, u2), z = Q.sub(_2, u2), z = Q.mul(W, z), z = Q.add(z, A3), A3 = Q.add(_2, _2), _2 = Q.add(A3, _2), _2 = Q.add(_2, u2), _2 = Q.mul(_2, z), S3 = Q.add(S3, _2), u2 = Q.mul(E3, x3), u2 = Q.add(u2, u2), _2 = Q.mul(u2, z), k2 = Q.sub(k2, _2), A3 = Q.mul(u2, l3), A3 = Q.add(A3, A3), A3 = Q.add(A3, A3), new N2(k2, S3, A3);
|
|
3460
3460
|
}
|
|
3461
3461
|
add(W) {
|
|
3462
3462
|
V(W);
|
|
3463
|
-
let { px: j, py:
|
|
3464
|
-
F = Q.mul(F, I2), I2 = Q.add(z,
|
|
3463
|
+
let { px: j, py: P3, pz: B3 } = this, { px: E3, py: x3, pz: k2 } = W, S3 = Q.ZERO, A3 = Q.ZERO, _2 = Q.ZERO, l3 = $.a, u2 = Q.mul($.b, _8), z = Q.mul(j, E3), C3 = Q.mul(P3, x3), T3 = Q.mul(B3, k2), F = Q.add(j, P3), I2 = Q.add(E3, x3);
|
|
3464
|
+
F = Q.mul(F, I2), I2 = Q.add(z, C3), F = Q.sub(F, I2), I2 = Q.add(j, B3);
|
|
3465
3465
|
let w3 = Q.add(E3, k2);
|
|
3466
|
-
return I2 = Q.mul(I2, w3), w3 = Q.add(z, T3), I2 = Q.sub(I2, w3), w3 = Q.add(
|
|
3466
|
+
return I2 = Q.mul(I2, w3), w3 = Q.add(z, T3), I2 = Q.sub(I2, w3), w3 = Q.add(P3, B3), S3 = Q.add(x3, k2), w3 = Q.mul(w3, S3), S3 = Q.add(C3, T3), w3 = Q.sub(w3, S3), _2 = Q.mul(l3, I2), S3 = Q.mul(u2, T3), _2 = Q.add(S3, _2), S3 = Q.sub(C3, _2), _2 = Q.add(C3, _2), A3 = Q.mul(S3, _2), C3 = Q.add(z, z), C3 = Q.add(C3, z), T3 = Q.mul(l3, T3), I2 = Q.mul(u2, I2), C3 = Q.add(C3, T3), T3 = Q.sub(z, T3), T3 = Q.mul(l3, T3), I2 = Q.add(I2, T3), z = Q.mul(C3, I2), A3 = Q.add(A3, z), z = Q.mul(w3, I2), S3 = Q.mul(F, S3), S3 = Q.sub(S3, z), z = Q.mul(F, C3), _2 = Q.mul(w3, _2), _2 = Q.add(_2, z), new N2(S3, A3, _2);
|
|
3467
3467
|
}
|
|
3468
3468
|
subtract(W) {
|
|
3469
3469
|
return this.add(W.negate());
|
|
@@ -3475,16 +3475,16 @@ function vQ(J) {
|
|
|
3475
3475
|
return f3.wNAFCached(this, W, N2.normalizeZ);
|
|
3476
3476
|
}
|
|
3477
3477
|
multiplyUnsafe(W) {
|
|
3478
|
-
let { endo: j, n:
|
|
3479
|
-
FJ("scalar", W, zJ,
|
|
3480
|
-
let
|
|
3478
|
+
let { endo: j, n: P3 } = $;
|
|
3479
|
+
FJ("scalar", W, zJ, P3);
|
|
3480
|
+
let B3 = N2.ZERO;
|
|
3481
3481
|
if (W === zJ)
|
|
3482
|
-
return
|
|
3482
|
+
return B3;
|
|
3483
3483
|
if (this.is0() || W === h3)
|
|
3484
3484
|
return this;
|
|
3485
3485
|
if (!j || f3.hasPrecomputes(this))
|
|
3486
3486
|
return f3.wNAFCachedUnsafe(this, W, N2.normalizeZ);
|
|
3487
|
-
let { k1neg: E3, k1: x3, k2neg: k2, k2: S3 } = j.splitScalar(W), A3 =
|
|
3487
|
+
let { k1neg: E3, k1: x3, k2neg: k2, k2: S3 } = j.splitScalar(W), A3 = B3, _2 = B3, l3 = this;
|
|
3488
3488
|
while (x3 > zJ || S3 > zJ) {
|
|
3489
3489
|
if (x3 & h3)
|
|
3490
3490
|
A3 = A3.add(l3);
|
|
@@ -3499,20 +3499,20 @@ function vQ(J) {
|
|
|
3499
3499
|
return _2 = new N2(Q.mul(_2.px, j.beta), _2.py, _2.pz), A3.add(_2);
|
|
3500
3500
|
}
|
|
3501
3501
|
multiply(W) {
|
|
3502
|
-
let { endo: j, n:
|
|
3503
|
-
FJ("scalar", W, h3,
|
|
3504
|
-
let
|
|
3502
|
+
let { endo: j, n: P3 } = $;
|
|
3503
|
+
FJ("scalar", W, h3, P3);
|
|
3504
|
+
let B3, E3;
|
|
3505
3505
|
if (j) {
|
|
3506
3506
|
let { k1neg: x3, k1: k2, k2neg: S3, k2: A3 } = j.splitScalar(W), { p: _2, f: l3 } = this.wNAF(k2), { p: u2, f: z } = this.wNAF(A3);
|
|
3507
|
-
_2 = f3.constTimeNegate(x3, _2), u2 = f3.constTimeNegate(S3, u2), u2 = new N2(Q.mul(u2.px, j.beta), u2.py, u2.pz),
|
|
3507
|
+
_2 = f3.constTimeNegate(x3, _2), u2 = f3.constTimeNegate(S3, u2), u2 = new N2(Q.mul(u2.px, j.beta), u2.py, u2.pz), B3 = _2.add(u2), E3 = l3.add(z);
|
|
3508
3508
|
} else {
|
|
3509
3509
|
let { p: x3, f: k2 } = this.wNAF(W);
|
|
3510
|
-
|
|
3510
|
+
B3 = x3, E3 = k2;
|
|
3511
3511
|
}
|
|
3512
|
-
return N2.normalizeZ([
|
|
3512
|
+
return N2.normalizeZ([B3, E3])[0];
|
|
3513
3513
|
}
|
|
3514
|
-
multiplyAndAddUnsafe(W, j,
|
|
3515
|
-
let
|
|
3514
|
+
multiplyAndAddUnsafe(W, j, P3) {
|
|
3515
|
+
let B3 = N2.BASE, E3 = (k2, S3) => S3 === zJ || S3 === h3 || !k2.equals(B3) ? k2.multiplyUnsafe(S3) : k2.multiply(S3), x3 = E3(this, j).add(E3(W, P3));
|
|
3516
3516
|
return x3.is0() ? undefined : x3;
|
|
3517
3517
|
}
|
|
3518
3518
|
toAffine(W) {
|
|
@@ -3535,7 +3535,7 @@ function vQ(J) {
|
|
|
3535
3535
|
return this.multiplyUnsafe($.h);
|
|
3536
3536
|
}
|
|
3537
3537
|
toRawBytes(W = true) {
|
|
3538
|
-
return sJ("isCompressed", W), this.assertValidity(),
|
|
3538
|
+
return sJ("isCompressed", W), this.assertValidity(), G(N2, this, W);
|
|
3539
3539
|
}
|
|
3540
3540
|
toHex(W = true) {
|
|
3541
3541
|
return sJ("isCompressed", W), rJ(this.toRawBytes(W));
|
|
@@ -3550,79 +3550,79 @@ function uQ(J) {
|
|
|
3550
3550
|
return gJ($, { hash: "hash", hmac: "function", randomBytes: "function" }, { bits2int: "function", bits2int_modN: "function", lowS: "boolean" }), Object.freeze({ lowS: true, ...$ });
|
|
3551
3551
|
}
|
|
3552
3552
|
function k0(J) {
|
|
3553
|
-
let $ = uQ(J), { Fp: Q, n: Y, nByteLength:
|
|
3553
|
+
let $ = uQ(J), { Fp: Q, n: Y, nByteLength: G, nBitLength: M3 } = $, Z = Q.BYTES + 1, K = 2 * Q.BYTES + 1;
|
|
3554
3554
|
function X(z) {
|
|
3555
3555
|
return d3(z, Y);
|
|
3556
3556
|
}
|
|
3557
3557
|
function q(z) {
|
|
3558
3558
|
return u$(z, Y);
|
|
3559
3559
|
}
|
|
3560
|
-
let { ProjectivePoint: U, normPrivateKeyToScalar: D3, weierstrassEquation: V, isWithinCurveOrder: O3 } = vQ({ ...$, toBytes(z,
|
|
3561
|
-
let F =
|
|
3560
|
+
let { ProjectivePoint: U, normPrivateKeyToScalar: D3, weierstrassEquation: V, isWithinCurveOrder: O3 } = vQ({ ...$, toBytes(z, C3, T3) {
|
|
3561
|
+
let F = C3.toAffine(), I2 = Q.toBytes(F.x), w3 = P$;
|
|
3562
3562
|
if (sJ("isCompressed", T3), T3)
|
|
3563
|
-
return w3(Uint8Array.from([
|
|
3563
|
+
return w3(Uint8Array.from([C3.hasEvenY() ? 2 : 3]), I2);
|
|
3564
3564
|
else
|
|
3565
3565
|
return w3(Uint8Array.from([4]), I2, Q.toBytes(F.y));
|
|
3566
3566
|
}, fromBytes(z) {
|
|
3567
|
-
let
|
|
3568
|
-
if (
|
|
3567
|
+
let C3 = z.length, T3 = z[0], F = z.subarray(1);
|
|
3568
|
+
if (C3 === Z && (T3 === 2 || T3 === 3)) {
|
|
3569
3569
|
let I2 = WJ(F);
|
|
3570
3570
|
if (!v$(I2, h3, Q.ORDER))
|
|
3571
3571
|
throw Error("Point is not on curve");
|
|
3572
3572
|
let w3 = V(I2), $J;
|
|
3573
3573
|
try {
|
|
3574
3574
|
$J = Q.sqrt(w3);
|
|
3575
|
-
} catch (
|
|
3576
|
-
let a2 =
|
|
3575
|
+
} catch (GJ) {
|
|
3576
|
+
let a2 = GJ instanceof Error ? ": " + GJ.message : "";
|
|
3577
3577
|
throw Error("Point is not on curve" + a2);
|
|
3578
3578
|
}
|
|
3579
3579
|
let i2 = ($J & h3) === h3;
|
|
3580
3580
|
if ((T3 & 1) === 1 !== i2)
|
|
3581
3581
|
$J = Q.neg($J);
|
|
3582
3582
|
return { x: I2, y: $J };
|
|
3583
|
-
} else if (
|
|
3583
|
+
} else if (C3 === K && T3 === 4) {
|
|
3584
3584
|
let I2 = Q.fromBytes(F.subarray(0, Q.BYTES)), w3 = Q.fromBytes(F.subarray(Q.BYTES, 2 * Q.BYTES));
|
|
3585
3585
|
return { x: I2, y: w3 };
|
|
3586
3586
|
} else {
|
|
3587
3587
|
let I2 = Z, w3 = K;
|
|
3588
|
-
throw Error("invalid Point, expected length of " + I2 + ", or uncompressed " + w3 + ", got " +
|
|
3588
|
+
throw Error("invalid Point, expected length of " + I2 + ", or uncompressed " + w3 + ", got " + C3);
|
|
3589
3589
|
}
|
|
3590
3590
|
} });
|
|
3591
3591
|
function L2(z) {
|
|
3592
|
-
let
|
|
3593
|
-
return z >
|
|
3592
|
+
let C3 = Y >> h3;
|
|
3593
|
+
return z > C3;
|
|
3594
3594
|
}
|
|
3595
3595
|
function N2(z) {
|
|
3596
3596
|
return L2(z) ? X(-z) : z;
|
|
3597
3597
|
}
|
|
3598
|
-
let b3 = (z,
|
|
3598
|
+
let b3 = (z, C3, T3) => WJ(z.slice(C3, T3));
|
|
3599
3599
|
|
|
3600
3600
|
class y3 {
|
|
3601
|
-
constructor(z,
|
|
3602
|
-
if (FJ("r", z, h3, Y), FJ("s",
|
|
3601
|
+
constructor(z, C3, T3) {
|
|
3602
|
+
if (FJ("r", z, h3, Y), FJ("s", C3, h3, Y), this.r = z, this.s = C3, T3 != null)
|
|
3603
3603
|
this.recovery = T3;
|
|
3604
3604
|
Object.freeze(this);
|
|
3605
3605
|
}
|
|
3606
3606
|
static fromCompact(z) {
|
|
3607
|
-
let
|
|
3608
|
-
return z = s2("compactSignature", z,
|
|
3607
|
+
let C3 = G;
|
|
3608
|
+
return z = s2("compactSignature", z, C3 * 2), new y3(b3(z, 0, C3), b3(z, C3, 2 * C3));
|
|
3609
3609
|
}
|
|
3610
3610
|
static fromDER(z) {
|
|
3611
|
-
let { r:
|
|
3612
|
-
return new y3(
|
|
3611
|
+
let { r: C3, s: T3 } = jJ.toSig(s2("DER", z));
|
|
3612
|
+
return new y3(C3, T3);
|
|
3613
3613
|
}
|
|
3614
3614
|
assertValidity() {}
|
|
3615
3615
|
addRecoveryBit(z) {
|
|
3616
3616
|
return new y3(this.r, this.s, z);
|
|
3617
3617
|
}
|
|
3618
3618
|
recoverPublicKey(z) {
|
|
3619
|
-
let { r:
|
|
3619
|
+
let { r: C3, s: T3, recovery: F } = this, I2 = E3(s2("msgHash", z));
|
|
3620
3620
|
if (F == null || ![0, 1, 2, 3].includes(F))
|
|
3621
3621
|
throw Error("recovery id invalid");
|
|
3622
|
-
let w3 = F === 2 || F === 3 ?
|
|
3622
|
+
let w3 = F === 2 || F === 3 ? C3 + $.n : C3;
|
|
3623
3623
|
if (w3 >= Q.ORDER)
|
|
3624
3624
|
throw Error("recovery id 2 or 3 invalid");
|
|
3625
|
-
let $J = (F & 1) === 0 ? "02" : "03", i2 = U.fromHex($J + S8(w3, Q.BYTES)), YJ = q(w3),
|
|
3625
|
+
let $J = (F & 1) === 0 ? "02" : "03", i2 = U.fromHex($J + S8(w3, Q.BYTES)), YJ = q(w3), GJ = X(-I2 * YJ), a2 = X(T3 * YJ), DJ = U.BASE.multiplyAndAddUnsafe(i2, GJ, a2);
|
|
3626
3626
|
if (!DJ)
|
|
3627
3627
|
throw Error("point at infinify");
|
|
3628
3628
|
return DJ.assertValidity(), DJ;
|
|
@@ -3634,33 +3634,33 @@ function k0(J) {
|
|
|
3634
3634
|
return this.hasHighS() ? new y3(this.r, X(-this.s), this.recovery) : this;
|
|
3635
3635
|
}
|
|
3636
3636
|
toDERRawBytes() {
|
|
3637
|
-
return
|
|
3637
|
+
return C$(this.toDERHex());
|
|
3638
3638
|
}
|
|
3639
3639
|
toDERHex() {
|
|
3640
3640
|
return jJ.hexFromSig(this);
|
|
3641
3641
|
}
|
|
3642
3642
|
toCompactRawBytes() {
|
|
3643
|
-
return
|
|
3643
|
+
return C$(this.toCompactHex());
|
|
3644
3644
|
}
|
|
3645
3645
|
toCompactHex() {
|
|
3646
|
-
let z =
|
|
3646
|
+
let z = G;
|
|
3647
3647
|
return S8(this.r, z) + S8(this.s, z);
|
|
3648
3648
|
}
|
|
3649
3649
|
}
|
|
3650
3650
|
let f3 = { isValidPrivateKey(z) {
|
|
3651
3651
|
try {
|
|
3652
3652
|
return D3(z), true;
|
|
3653
|
-
} catch (
|
|
3653
|
+
} catch (C3) {
|
|
3654
3654
|
return false;
|
|
3655
3655
|
}
|
|
3656
3656
|
}, normPrivateKeyToScalar: D3, randomPrivateKey: () => {
|
|
3657
|
-
let z =
|
|
3657
|
+
let z = C8($.n);
|
|
3658
3658
|
return I0($.randomBytes(z), $.n);
|
|
3659
|
-
}, precompute(z = 8,
|
|
3660
|
-
return
|
|
3659
|
+
}, precompute(z = 8, C3 = U.BASE) {
|
|
3660
|
+
return C3._setWindowSize(z), C3.multiply(BigInt(3)), C3;
|
|
3661
3661
|
} };
|
|
3662
|
-
function W(z,
|
|
3663
|
-
return U.fromPrivateKey(z).toRawBytes(
|
|
3662
|
+
function W(z, C3 = true) {
|
|
3663
|
+
return U.fromPrivateKey(z).toRawBytes(C3);
|
|
3664
3664
|
}
|
|
3665
3665
|
function j(z) {
|
|
3666
3666
|
if (typeof z === "bigint")
|
|
@@ -3668,51 +3668,51 @@ function k0(J) {
|
|
|
3668
3668
|
if (z instanceof U)
|
|
3669
3669
|
return true;
|
|
3670
3670
|
let T3 = s2("key", z).length, F = Q.BYTES, I2 = F + 1, w3 = 2 * F + 1;
|
|
3671
|
-
if ($.allowedPrivateKeyLengths ||
|
|
3671
|
+
if ($.allowedPrivateKeyLengths || G === I2)
|
|
3672
3672
|
return;
|
|
3673
3673
|
else
|
|
3674
3674
|
return T3 === I2 || T3 === w3;
|
|
3675
3675
|
}
|
|
3676
|
-
function
|
|
3676
|
+
function P3(z, C3, T3 = true) {
|
|
3677
3677
|
if (j(z) === true)
|
|
3678
3678
|
throw Error("first arg must be private key");
|
|
3679
|
-
if (j(
|
|
3679
|
+
if (j(C3) === false)
|
|
3680
3680
|
throw Error("second arg must be public key");
|
|
3681
|
-
return U.fromHex(
|
|
3681
|
+
return U.fromHex(C3).multiply(D3(z)).toRawBytes(T3);
|
|
3682
3682
|
}
|
|
3683
|
-
let
|
|
3683
|
+
let B3 = $.bits2int || function(z) {
|
|
3684
3684
|
if (z.length > 8192)
|
|
3685
3685
|
throw Error("input is too large");
|
|
3686
|
-
let
|
|
3687
|
-
return T3 > 0 ?
|
|
3686
|
+
let C3 = WJ(z), T3 = z.length * 8 - M3;
|
|
3687
|
+
return T3 > 0 ? C3 >> BigInt(T3) : C3;
|
|
3688
3688
|
}, E3 = $.bits2int_modN || function(z) {
|
|
3689
|
-
return X(
|
|
3690
|
-
}, x3 = fJ(
|
|
3689
|
+
return X(B3(z));
|
|
3690
|
+
}, x3 = fJ(M3);
|
|
3691
3691
|
function k2(z) {
|
|
3692
|
-
return FJ("num < 2^" +
|
|
3692
|
+
return FJ("num < 2^" + M3, z, zJ, x3), bJ(z, G);
|
|
3693
3693
|
}
|
|
3694
|
-
function S3(z,
|
|
3695
|
-
if (["recovered", "canonical"].some((
|
|
3694
|
+
function S3(z, C3, T3 = A3) {
|
|
3695
|
+
if (["recovered", "canonical"].some((BJ) => (BJ in T3)))
|
|
3696
3696
|
throw Error("sign() legacy options not supported");
|
|
3697
3697
|
let { hash: F, randomBytes: I2 } = $, { lowS: w3, prehash: $J, extraEntropy: i2 } = T3;
|
|
3698
3698
|
if (w3 == null)
|
|
3699
3699
|
w3 = true;
|
|
3700
3700
|
if (z = s2("msgHash", z), E0(T3), $J)
|
|
3701
3701
|
z = s2("prehashed msgHash", F(z));
|
|
3702
|
-
let YJ = E3(z),
|
|
3702
|
+
let YJ = E3(z), GJ = D3(C3), a2 = [k2(GJ), k2(YJ)];
|
|
3703
3703
|
if (i2 != null && i2 !== false) {
|
|
3704
|
-
let
|
|
3705
|
-
a2.push(s2("extraEntropy",
|
|
3704
|
+
let BJ = i2 === true ? I2(Q.BYTES) : i2;
|
|
3705
|
+
a2.push(s2("extraEntropy", BJ));
|
|
3706
3706
|
}
|
|
3707
|
-
let DJ =
|
|
3708
|
-
function l$(
|
|
3709
|
-
let mJ =
|
|
3707
|
+
let DJ = P$(...a2), T$ = YJ;
|
|
3708
|
+
function l$(BJ) {
|
|
3709
|
+
let mJ = B3(BJ);
|
|
3710
3710
|
if (!O3(mJ))
|
|
3711
3711
|
return;
|
|
3712
3712
|
let c$ = q(mJ), J$ = U.BASE.multiply(mJ).toAffine(), LJ = X(J$.x);
|
|
3713
3713
|
if (LJ === zJ)
|
|
3714
3714
|
return;
|
|
3715
|
-
let $$ = X(c$ * X(T$ + LJ *
|
|
3715
|
+
let $$ = X(c$ * X(T$ + LJ * GJ));
|
|
3716
3716
|
if ($$ === zJ)
|
|
3717
3717
|
return;
|
|
3718
3718
|
let hJ = (J$.x === LJ ? 0 : 2) | Number(J$.y & h3), F8 = $$;
|
|
@@ -3723,25 +3723,25 @@ function k0(J) {
|
|
|
3723
3723
|
return { seed: DJ, k2sig: l$ };
|
|
3724
3724
|
}
|
|
3725
3725
|
let A3 = { lowS: $.lowS, prehash: false }, _2 = { lowS: $.lowS, prehash: false };
|
|
3726
|
-
function l3(z,
|
|
3727
|
-
let { seed: F, k2sig: I2 } = S3(z,
|
|
3726
|
+
function l3(z, C3, T3 = A3) {
|
|
3727
|
+
let { seed: F, k2sig: I2 } = S3(z, C3, T3), w3 = $;
|
|
3728
3728
|
return O0(w3.hash.outputLen, w3.nByteLength, w3.hmac)(F, I2);
|
|
3729
3729
|
}
|
|
3730
3730
|
U.BASE._setWindowSize(8);
|
|
3731
|
-
function u2(z,
|
|
3731
|
+
function u2(z, C3, T3, F = _2) {
|
|
3732
3732
|
let I2 = z;
|
|
3733
|
-
|
|
3733
|
+
C3 = s2("msgHash", C3), T3 = s2("publicKey", T3);
|
|
3734
3734
|
let { lowS: w3, prehash: $J, format: i2 } = F;
|
|
3735
3735
|
if (E0(F), "strict" in F)
|
|
3736
3736
|
throw Error("options.strict was renamed to lowS");
|
|
3737
3737
|
if (i2 !== undefined && i2 !== "compact" && i2 !== "der")
|
|
3738
3738
|
throw Error("format must be compact or der");
|
|
3739
|
-
let YJ = typeof I2 === "string" || aJ(I2),
|
|
3740
|
-
if (!YJ && !
|
|
3739
|
+
let YJ = typeof I2 === "string" || aJ(I2), GJ = !YJ && !i2 && typeof I2 === "object" && I2 !== null && typeof I2.r === "bigint" && typeof I2.s === "bigint";
|
|
3740
|
+
if (!YJ && !GJ)
|
|
3741
3741
|
throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
|
3742
3742
|
let a2 = undefined, DJ;
|
|
3743
3743
|
try {
|
|
3744
|
-
if (
|
|
3744
|
+
if (GJ)
|
|
3745
3745
|
a2 = new y3(I2.r, I2.s);
|
|
3746
3746
|
if (YJ) {
|
|
3747
3747
|
try {
|
|
@@ -3763,17 +3763,17 @@ function k0(J) {
|
|
|
3763
3763
|
if (w3 && a2.hasHighS())
|
|
3764
3764
|
return false;
|
|
3765
3765
|
if ($J)
|
|
3766
|
-
|
|
3767
|
-
let { r: T$, s: l$ } = a2,
|
|
3766
|
+
C3 = $.hash(C3);
|
|
3767
|
+
let { r: T$, s: l$ } = a2, BJ = E3(C3), mJ = q(l$), c$ = X(BJ * mJ), J$ = X(T$ * mJ), LJ = U.BASE.multiplyAndAddUnsafe(DJ, c$, J$)?.toAffine();
|
|
3768
3768
|
if (!LJ)
|
|
3769
3769
|
return false;
|
|
3770
3770
|
return X(LJ.x) === T$;
|
|
3771
3771
|
}
|
|
3772
|
-
return { CURVE: $, getPublicKey: W, getSharedSecret:
|
|
3772
|
+
return { CURVE: $, getPublicKey: W, getSharedSecret: P3, sign: l3, verify: u2, ProjectivePoint: U, Signature: y3, utils: f3 };
|
|
3773
3773
|
}
|
|
3774
3774
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3775
3775
|
function mQ(J) {
|
|
3776
|
-
return { hash: J, hmac: ($, ...Q) => X8(J, $,
|
|
3776
|
+
return { hash: J, hmac: ($, ...Q) => X8(J, $, M0(...Q)), randomBytes: X0 };
|
|
3777
3777
|
}
|
|
3778
3778
|
function b0(J, $) {
|
|
3779
3779
|
let Q = (Y) => k0({ ...J, ...mQ(Y) });
|
|
@@ -3787,14 +3787,14 @@ var lQ = BigInt(1);
|
|
|
3787
3787
|
var y8 = BigInt(2);
|
|
3788
3788
|
var f0 = (J, $) => (J + $ / y8) / $;
|
|
3789
3789
|
function cQ(J) {
|
|
3790
|
-
let $ = g0, Q = BigInt(3), Y = BigInt(6),
|
|
3791
|
-
if (!A8.eql(A8.sqr(
|
|
3790
|
+
let $ = g0, Q = BigInt(3), Y = BigInt(6), G = BigInt(11), M3 = BigInt(22), Z = BigInt(23), K = BigInt(44), X = BigInt(88), q = J * J * J % $, U = q * q * J % $, D3 = e2(U, Q, $) * U % $, V = e2(D3, Q, $) * U % $, O3 = e2(V, y8, $) * q % $, L2 = e2(O3, G, $) * O3 % $, N2 = e2(L2, M3, $) * L2 % $, b3 = e2(N2, K, $) * N2 % $, y3 = e2(b3, X, $) * b3 % $, f3 = e2(y3, K, $) * N2 % $, W = e2(f3, Q, $) * U % $, j = e2(W, Z, $) * L2 % $, P3 = e2(j, Y, $) * q % $, B3 = e2(P3, y8, $);
|
|
3791
|
+
if (!A8.eql(A8.sqr(B3), J))
|
|
3792
3792
|
throw Error("Cannot find square root");
|
|
3793
|
-
return
|
|
3793
|
+
return B3;
|
|
3794
3794
|
}
|
|
3795
|
-
var A8 =
|
|
3795
|
+
var A8 = B$(g0, undefined, undefined, { sqrt: cQ });
|
|
3796
3796
|
var w8 = b0({ a: hQ, b: BigInt(7), Fp: A8, n: F0, Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"), Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"), h: BigInt(1), lowS: true, endo: { beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"), splitScalar: (J) => {
|
|
3797
|
-
let $ = F0, Q = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), Y = -lQ * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),
|
|
3797
|
+
let $ = F0, Q = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), Y = -lQ * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), G = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), M3 = Q, Z = BigInt("0x100000000000000000000000000000000"), K = f0(M3 * J, $), X = f0(-Y * J, $), q = d3(J - K * Q - X * G, $), U = d3(-K * Y - X * M3, $), D3 = q > Z, V = U > Z;
|
|
3798
3798
|
if (D3)
|
|
3799
3799
|
q = $ - q;
|
|
3800
3800
|
if (V)
|
|
@@ -3808,7 +3808,7 @@ function m$() {
|
|
|
3808
3808
|
return "0x" + Buffer.from(J).toString("hex");
|
|
3809
3809
|
}
|
|
3810
3810
|
function eJ(J) {
|
|
3811
|
-
let $ = J.startsWith("0x") ? J.slice(2) : J, Q = Buffer.from($, "hex"), Y = w8.getPublicKey(Q, false),
|
|
3811
|
+
let $ = J.startsWith("0x") ? J.slice(2) : J, Q = Buffer.from($, "hex"), Y = w8.getPublicKey(Q, false), M3 = cJ(Y.slice(1)).slice(-20), Z = "0x" + Buffer.from(M3).toString("hex");
|
|
3812
3812
|
return OJ(Z);
|
|
3813
3813
|
}
|
|
3814
3814
|
function h$(J) {
|
|
@@ -3861,9 +3861,9 @@ class v2 extends V$ {
|
|
|
3861
3861
|
static noProxyInviters(J) {
|
|
3862
3862
|
return new v2(`No proxy inviters found for ${J}. The inviter must have mutual trust connections with users who are also trusted by the invitation module, and these users must have sufficient balance.`, { code: "INVITATION_NO_PROXY_INVITERS", source: "VALIDATION", context: { inviter: J } });
|
|
3863
3863
|
}
|
|
3864
|
-
static insufficientBalance(J, $, Q, Y,
|
|
3864
|
+
static insufficientBalance(J, $, Q, Y, G, M3) {
|
|
3865
3865
|
let Z = Number(Q) / 1000000000000000000, K = Number(Y) / 1000000000000000000;
|
|
3866
|
-
return new v2(`Insufficient balance for ${J} invitation(s). Can only afford ${$} invitation(s). Requested: ${Z.toFixed(6)} CRC, Available: ${K.toFixed(6)} CRC.`, { code: "INVITATION_INSUFFICIENT_BALANCE", source: "VALIDATION", context: { from:
|
|
3866
|
+
return new v2(`Insufficient balance for ${J} invitation(s). Can only afford ${$} invitation(s). Requested: ${Z.toFixed(6)} CRC, Available: ${K.toFixed(6)} CRC.`, { code: "INVITATION_INSUFFICIENT_BALANCE", source: "VALIDATION", context: { from: G, to: M3, requestedInvites: J, availableInvites: $, requested: Q.toString(), available: Y.toString(), requestedCrc: Z, availableCrc: K } });
|
|
3867
3867
|
}
|
|
3868
3868
|
static inviteeAlreadyRegistered(J, $) {
|
|
3869
3869
|
return new v2(`Invitee ${$} is already registered as a human in Circles Hub. Cannot invite an already registered user.`, { code: "INVITATION_INVITEE_ALREADY_REGISTERED", source: "VALIDATION", context: { inviter: J, invitee: $ } });
|
|
@@ -3884,8 +3884,8 @@ function L$(J) {
|
|
|
3884
3884
|
function u0(J) {
|
|
3885
3885
|
let $ = new Uint8Array(J.length * 2);
|
|
3886
3886
|
return J.forEach((Q, Y) => {
|
|
3887
|
-
let
|
|
3888
|
-
$[Z] =
|
|
3887
|
+
let G = Q >> 8, M3 = Q & 255, Z = 2 * Y;
|
|
3888
|
+
$[Z] = G, $[Z + 1] = M3;
|
|
3889
3889
|
}), L$($);
|
|
3890
3890
|
}
|
|
3891
3891
|
function m0(J, $, Q) {
|
|
@@ -3893,42 +3893,42 @@ function m0(J, $, Q) {
|
|
|
3893
3893
|
J.forEach((Z) => {
|
|
3894
3894
|
Y.add(Z.from.toLowerCase()), Y.add(Z.to.toLowerCase()), Y.add(Z.tokenOwner.toLowerCase());
|
|
3895
3895
|
});
|
|
3896
|
-
let
|
|
3896
|
+
let G = [...Y].sort((Z, K) => {
|
|
3897
3897
|
let X = BigInt(Z), q = BigInt(K), U = X < q, D3 = X > q;
|
|
3898
3898
|
return U ? -1 : D3 ? 1 : 0;
|
|
3899
|
-
}),
|
|
3900
|
-
return
|
|
3901
|
-
|
|
3902
|
-
}), { sorted:
|
|
3899
|
+
}), M3 = {};
|
|
3900
|
+
return G.forEach((Z, K) => {
|
|
3901
|
+
M3[Z] = K;
|
|
3902
|
+
}), { sorted: G, idx: M3 };
|
|
3903
3903
|
}
|
|
3904
3904
|
function pQ(J, $) {
|
|
3905
|
-
let Q = new Set, Y = [],
|
|
3906
|
-
if (J.forEach((
|
|
3907
|
-
let K =
|
|
3905
|
+
let Q = new Set, Y = [], G = null;
|
|
3906
|
+
if (J.forEach((M3, Z) => {
|
|
3907
|
+
let K = M3.from.toLowerCase(), X = M3.to.toLowerCase();
|
|
3908
3908
|
if (K === $ && X === $)
|
|
3909
|
-
|
|
3909
|
+
G = Z;
|
|
3910
3910
|
else if (X === $)
|
|
3911
3911
|
Y.push(Z);
|
|
3912
|
-
}),
|
|
3913
|
-
Q.add(
|
|
3912
|
+
}), G !== null)
|
|
3913
|
+
Q.add(G);
|
|
3914
3914
|
else
|
|
3915
|
-
Y.forEach((
|
|
3915
|
+
Y.forEach((M3) => Q.add(M3));
|
|
3916
3916
|
return Q;
|
|
3917
3917
|
}
|
|
3918
3918
|
function h0(J, $, Q, Y) {
|
|
3919
|
-
let
|
|
3919
|
+
let G = J.toLowerCase(), M3 = $.toLowerCase(), { sorted: Z, idx: K } = m0(Y, G, M3), X = pQ(Y, M3), q = Y.map((y3, f3) => {
|
|
3920
3920
|
return { streamSinkId: X.has(f3) ? 1 : 0, amount: y3.value };
|
|
3921
3921
|
});
|
|
3922
3922
|
if (X.size === 0)
|
|
3923
|
-
throw Error(`No terminal edges detected. Flow must have at least one edge delivering to receiver ${
|
|
3924
|
-
let U = Array.from(X), D3 = [{ sourceCoordinate: K[
|
|
3923
|
+
throw Error(`No terminal edges detected. Flow must have at least one edge delivering to receiver ${M3}`);
|
|
3924
|
+
let U = Array.from(X), D3 = [{ sourceCoordinate: K[G], flowEdgeIds: U, data: new Uint8Array(0) }], V = [];
|
|
3925
3925
|
Y.forEach((y3) => {
|
|
3926
3926
|
V.push(K[y3.tokenOwner.toLowerCase()]), V.push(K[y3.from.toLowerCase()]), V.push(K[y3.to.toLowerCase()]);
|
|
3927
3927
|
});
|
|
3928
3928
|
let O3 = u0(V), L2 = BigInt(Q), N2 = q.filter((y3) => y3.streamSinkId === 1).reduce((y3, f3) => y3 + BigInt(f3.amount.toString()), BigInt(0));
|
|
3929
3929
|
if (N2 !== L2)
|
|
3930
3930
|
throw Error(`Terminal sum ${N2} does not equal expected ${L2}`);
|
|
3931
|
-
return { flowVertices: Z, flowEdges: q, streams: D3, packedCoordinates: O3, sourceCoordinate: K[
|
|
3931
|
+
return { flowVertices: Z, flowEdges: q, streams: D3, packedCoordinates: O3, sourceCoordinate: K[G] };
|
|
3932
3932
|
}
|
|
3933
3933
|
function l0(J, $) {
|
|
3934
3934
|
let Q = J.streams.map((Y) => ({ sourceCoordinate: Y.sourceCoordinate, flowEdgeIds: Y.flowEdgeIds, data: Y.data instanceof Uint8Array ? L$(Y.data) : Y.data }));
|
|
@@ -3937,11 +3937,11 @@ function l0(J, $) {
|
|
|
3937
3937
|
return Q;
|
|
3938
3938
|
}
|
|
3939
3939
|
async function c0(J, $, Q) {
|
|
3940
|
-
let Y = new Map,
|
|
3940
|
+
let Y = new Map, G = new Set;
|
|
3941
3941
|
return Q.transfers.forEach((K) => {
|
|
3942
3942
|
if (J.toLowerCase() === K.from.toLowerCase())
|
|
3943
|
-
|
|
3944
|
-
}), (await new x$($).token.getTokenInfoBatch(Array.from(
|
|
3943
|
+
G.add(K.tokenOwner.toLowerCase());
|
|
3944
|
+
}), (await new x$($).token.getTokenInfoBatch(Array.from(G))).forEach((K) => {
|
|
3945
3945
|
if (K.isWrapped && !K.isInflationary)
|
|
3946
3946
|
K.tokenType = "CrcV2_ERC20WrapperDeployed_Demurraged";
|
|
3947
3947
|
Y.set(K.tokenAddress.toLowerCase(), K);
|
|
@@ -3950,19 +3950,19 @@ async function c0(J, $, Q) {
|
|
|
3950
3950
|
function p0(J, $) {
|
|
3951
3951
|
let Q = {};
|
|
3952
3952
|
return J.transfers.forEach((Y) => {
|
|
3953
|
-
let
|
|
3954
|
-
if (
|
|
3953
|
+
let G = $.get(Y.tokenOwner.toLowerCase());
|
|
3954
|
+
if (G && G.tokenType.startsWith("CrcV2_ERC20WrapperDeployed")) {
|
|
3955
3955
|
if (!Q[Y.tokenOwner])
|
|
3956
|
-
Q[Y.tokenOwner] = [BigInt(0),
|
|
3956
|
+
Q[Y.tokenOwner] = [BigInt(0), G.tokenType];
|
|
3957
3957
|
Q[Y.tokenOwner][0] += BigInt(Y.value);
|
|
3958
3958
|
}
|
|
3959
3959
|
}), Q;
|
|
3960
3960
|
}
|
|
3961
3961
|
function d0(J, $) {
|
|
3962
3962
|
let Q = J.transfers.map((Y) => {
|
|
3963
|
-
let
|
|
3964
|
-
if (
|
|
3965
|
-
return { ...Y, tokenOwner:
|
|
3963
|
+
let G = $.get(Y.tokenOwner.toLowerCase());
|
|
3964
|
+
if (G && G.tokenType.startsWith("CrcV2_ERC20WrapperDeployed"))
|
|
3965
|
+
return { ...Y, tokenOwner: G.tokenOwner };
|
|
3966
3966
|
return Y;
|
|
3967
3967
|
});
|
|
3968
3968
|
return { ...J, transfers: Q };
|
|
@@ -3976,8 +3976,8 @@ class JJ extends Y$ {
|
|
|
3976
3976
|
return new JJ(`No valid transfer path found from ${J} to ${$}. ${Q || "This could mean there's no trust connection, insufficient balance, or the tokens are not transferable."}`, { code: "TRANSFER_NO_PATH", source: "PATHFINDING", context: { from: J, to: $, reason: Q } });
|
|
3977
3977
|
}
|
|
3978
3978
|
static insufficientBalance(J, $, Q, Y) {
|
|
3979
|
-
let
|
|
3980
|
-
return new JJ(`Insufficient balance for transfer. Requested: ${
|
|
3979
|
+
let G = Number(J) / 1000000000000000000, M3 = Number($) / 1000000000000000000;
|
|
3980
|
+
return new JJ(`Insufficient balance for transfer. Requested: ${G.toFixed(6)} CRC, Available: ${M3.toFixed(6)} CRC.`, { code: "TRANSFER_INSUFFICIENT_BALANCE", source: "VALIDATION", context: { from: Q, to: Y, requested: J.toString(), available: $.toString(), requestedCrc: G, availableCrc: M3 } });
|
|
3981
3981
|
}
|
|
3982
3982
|
static wrappedTokensRequired() {
|
|
3983
3983
|
return new JJ("Insufficient unwrapped token balance for transfer. Your balance contains wrapped tokens (ERC20 wrappers), but useWrappedBalances option is not enabled. Please enable it by passing { useWrappedBalances: true } in the transfer options.", { code: "TRANSFER_WRAPPED_TOKENS_REQUIRED", source: "VALIDATION" });
|
|
@@ -4002,37 +4002,37 @@ class uJ {
|
|
|
4002
4002
|
balance;
|
|
4003
4003
|
group;
|
|
4004
4004
|
constructor(J) {
|
|
4005
|
-
this.config = J, this.hubV2 = new
|
|
4005
|
+
this.config = J, this.hubV2 = new RJ({ address: J.v2HubAddress, rpcUrl: J.circlesRpcUrl }), this.liftERC20 = new k$({ address: J.liftERC20Address, rpcUrl: J.circlesRpcUrl }), this.rpcClient = new VJ(J.circlesRpcUrl), this.pathfinder = new KJ(this.rpcClient), this.balance = new yJ(this.rpcClient), this.group = new wJ(this.rpcClient);
|
|
4006
4006
|
}
|
|
4007
|
-
async buildFlowMatrixTx(J, $, Q, Y,
|
|
4008
|
-
let
|
|
4007
|
+
async buildFlowMatrixTx(J, $, Q, Y, G = false) {
|
|
4008
|
+
let M3 = J.toLowerCase(), Z = $.toLowerCase();
|
|
4009
4009
|
if (!Q.transfers || Q.transfers.length === 0)
|
|
4010
|
-
throw JJ.noPathFound(
|
|
4010
|
+
throw JJ.noPathFound(M3, Z);
|
|
4011
4011
|
let K = { ...Q };
|
|
4012
|
-
if (
|
|
4012
|
+
if (G && Y?.toTokens?.length === 1) {
|
|
4013
4013
|
let f3 = Y.toTokens[0].toLowerCase();
|
|
4014
4014
|
if (Q.maxFlow > 0n)
|
|
4015
4015
|
K.transfers.push({ from: Z, to: Z, tokenOwner: f3, value: Q.maxFlow });
|
|
4016
4016
|
}
|
|
4017
|
-
let X = await c0(
|
|
4017
|
+
let X = await c0(M3, this.config.circlesRpcUrl, K), q = p0(K, X), U = Object.keys(q).length > 0;
|
|
4018
4018
|
if (U && !Y?.useWrappedBalances)
|
|
4019
4019
|
throw JJ.wrappedTokensRequired();
|
|
4020
4020
|
let D3 = [], V = [];
|
|
4021
4021
|
if (U) {
|
|
4022
|
-
let f3 = await this._getTokenBalanceMap(
|
|
4023
|
-
D3 = [...W, ...j], V =
|
|
4022
|
+
let f3 = await this._getTokenBalanceMap(M3), W = this._createDemurragedUnwrapCalls(q), { unwrapCalls: j, wrapCalls: P3 } = this._createInflationaryUnwrapAndWrapCalls(q, X, f3);
|
|
4023
|
+
D3 = [...W, ...j], V = P3, K = d0(K, X);
|
|
4024
4024
|
}
|
|
4025
|
-
let O3 = h0(
|
|
4025
|
+
let O3 = h0(M3, Z, K.maxFlow, K.transfers), L2 = l0(O3, Y?.txData), N2 = this.hubV2.operateFlowMatrix(O3.flowVertices, O3.flowEdges, L2, O3.packedCoordinates), b3 = false;
|
|
4026
4026
|
try {
|
|
4027
|
-
b3 = await this.hubV2.isApprovedForAll(
|
|
4027
|
+
b3 = await this.hubV2.isApprovedForAll(M3, M3);
|
|
4028
4028
|
} catch (f3) {
|
|
4029
4029
|
console.warn("Failed to check approval status, including approval transaction:", f3);
|
|
4030
4030
|
}
|
|
4031
|
-
return [...b3 ? [] : [this.hubV2.setApprovalForAll(
|
|
4031
|
+
return [...b3 ? [] : [this.hubV2.setApprovalForAll(M3, true)], ...D3, N2, ...V];
|
|
4032
4032
|
}
|
|
4033
|
-
async constructAdvancedTransfer(J, $, Q, Y,
|
|
4034
|
-
let
|
|
4035
|
-
if (
|
|
4033
|
+
async constructAdvancedTransfer(J, $, Q, Y, G = false) {
|
|
4034
|
+
let M3 = J.toLowerCase(), Z = $.toLowerCase(), K = BigInt(Q);
|
|
4035
|
+
if (M3 === Z && Y?.fromTokens?.length === 1 && Y?.toTokens?.length === 1) {
|
|
4036
4036
|
let O3 = Y.fromTokens[0], L2 = Y.toTokens[0], [N2, b3] = await Promise.all([this.liftERC20.erc20Circles(0, L2), this.liftERC20.erc20Circles(1, L2)]);
|
|
4037
4037
|
if (O3.toLowerCase() === N2.toLowerCase() && N2 !== IJ) {
|
|
4038
4038
|
let f3 = new z$({ address: O3, rpcUrl: this.config.circlesRpcUrl }).unwrap(K);
|
|
@@ -4043,12 +4043,12 @@ class uJ {
|
|
|
4043
4043
|
return [{ to: W.to, data: W.data, value: W.value ?? 0n }];
|
|
4044
4044
|
}
|
|
4045
4045
|
}
|
|
4046
|
-
let X = this._truncateToSixDecimals(K), q = await this._getDefaultTokenExcludeList(Z, Y?.excludeFromTokens), { ...U } = Y || {}, D3 = { ...U, ...q ? { excludeFromTokens: q } : {} }, V = await this.pathfinder.findPath({ from:
|
|
4046
|
+
let X = this._truncateToSixDecimals(K), q = await this._getDefaultTokenExcludeList(Z, Y?.excludeFromTokens), { ...U } = Y || {}, D3 = { ...U, ...q ? { excludeFromTokens: q } : {} }, V = await this.pathfinder.findPath({ from: M3, to: Z, targetFlow: X, ...D3 });
|
|
4047
4047
|
if (!V.transfers || V.transfers.length === 0)
|
|
4048
|
-
throw JJ.noPathFound(
|
|
4048
|
+
throw JJ.noPathFound(M3, Z);
|
|
4049
4049
|
if (V.maxFlow < X)
|
|
4050
|
-
throw JJ.insufficientBalance(X, V.maxFlow,
|
|
4051
|
-
return this.buildFlowMatrixTx(
|
|
4050
|
+
throw JJ.insufficientBalance(X, V.maxFlow, M3, Z);
|
|
4051
|
+
return this.buildFlowMatrixTx(M3, Z, V, Y, G);
|
|
4052
4052
|
}
|
|
4053
4053
|
async _getTokenBalanceMap(J) {
|
|
4054
4054
|
let $ = await this.balance.getTokenBalances(J), Q = new Map;
|
|
@@ -4058,8 +4058,8 @@ class uJ {
|
|
|
4058
4058
|
}
|
|
4059
4059
|
_createDemurragedUnwrapCalls(J) {
|
|
4060
4060
|
let $ = [];
|
|
4061
|
-
for (let [Q, [Y,
|
|
4062
|
-
if (
|
|
4061
|
+
for (let [Q, [Y, G]] of Object.entries(J)) {
|
|
4062
|
+
if (G !== "CrcV2_ERC20WrapperDeployed_Demurraged")
|
|
4063
4063
|
continue;
|
|
4064
4064
|
let Z = new z$({ address: Q, rpcUrl: this.config.circlesRpcUrl }).unwrap(Y);
|
|
4065
4065
|
$.push({ to: Z.to, data: Z.data, value: Z.value ?? 0n });
|
|
@@ -4067,22 +4067,22 @@ class uJ {
|
|
|
4067
4067
|
return $;
|
|
4068
4068
|
}
|
|
4069
4069
|
_createInflationaryUnwrapAndWrapCalls(J, $, Q) {
|
|
4070
|
-
let Y = [],
|
|
4071
|
-
for (let [
|
|
4070
|
+
let Y = [], G = [];
|
|
4071
|
+
for (let [M3, [Z, K]] of Object.entries(J)) {
|
|
4072
4072
|
if (K !== "CrcV2_ERC20WrapperDeployed_Inflationary")
|
|
4073
4073
|
continue;
|
|
4074
|
-
let X = $.get(
|
|
4074
|
+
let X = $.get(M3.toLowerCase()), q = Q.get(M3.toLowerCase()) || 0n;
|
|
4075
4075
|
if (q === 0n)
|
|
4076
4076
|
continue;
|
|
4077
|
-
let D3 = new D$({ address:
|
|
4077
|
+
let D3 = new D$({ address: M3, rpcUrl: this.config.circlesRpcUrl }).unwrap(q);
|
|
4078
4078
|
Y.push({ to: D3.to, data: D3.data, value: D3.value ?? 0n });
|
|
4079
4079
|
let V = X?.tokenOwner, O3 = nJ.attoStaticCirclesToAttoCircles(q) - Z;
|
|
4080
4080
|
if (O3 > 0n) {
|
|
4081
4081
|
let L2 = this.hubV2.wrap(V, O3, 1);
|
|
4082
|
-
|
|
4082
|
+
G.push({ to: L2.to, data: L2.data, value: L2.value ?? 0n });
|
|
4083
4083
|
}
|
|
4084
4084
|
}
|
|
4085
|
-
return { unwrapCalls: Y, wrapCalls:
|
|
4085
|
+
return { unwrapCalls: Y, wrapCalls: G };
|
|
4086
4086
|
}
|
|
4087
4087
|
_truncateToSixDecimals(J) {
|
|
4088
4088
|
let $ = BigInt(1e6), Q = BigInt(10) ** BigInt(18);
|
|
@@ -4091,13 +4091,13 @@ class uJ {
|
|
|
4091
4091
|
async _getDefaultTokenExcludeList(J, $) {
|
|
4092
4092
|
let Q = await this.group.findGroups(1, { mintHandlerEquals: J }), Y = new Set;
|
|
4093
4093
|
if (Q.results.length > 0) {
|
|
4094
|
-
let
|
|
4095
|
-
if (Y.add(
|
|
4096
|
-
Y.add(
|
|
4097
|
-
if (
|
|
4098
|
-
Y.add(
|
|
4094
|
+
let G = Q.results[0];
|
|
4095
|
+
if (Y.add(G.group.toLowerCase()), G.erc20WrapperDemurraged)
|
|
4096
|
+
Y.add(G.erc20WrapperDemurraged.toLowerCase());
|
|
4097
|
+
if (G.erc20WrapperStatic)
|
|
4098
|
+
Y.add(G.erc20WrapperStatic.toLowerCase());
|
|
4099
4099
|
}
|
|
4100
|
-
if ($?.forEach((
|
|
4100
|
+
if ($?.forEach((G) => Y.add(G.toLowerCase())), Y.size === 0)
|
|
4101
4101
|
return;
|
|
4102
4102
|
return Array.from(Y);
|
|
4103
4103
|
}
|
|
@@ -4117,12 +4117,12 @@ class E8 {
|
|
|
4117
4117
|
constructor(J) {
|
|
4118
4118
|
if (!J.referralsServiceUrl)
|
|
4119
4119
|
throw new v2("referralsServiceUrl is required in config", { code: "INVITATION_MISSING_CONFIG", source: "INVITATIONS", context: { missingField: "referralsServiceUrl" } });
|
|
4120
|
-
this.config = J, this.rpcClient = new VJ(J.circlesRpcUrl), this.pathfinder = new KJ(this.rpcClient), this.trust = new _J(this.rpcClient), this.token = new AJ(this.rpcClient), this.hubV2 = new
|
|
4120
|
+
this.config = J, this.rpcClient = new VJ(J.circlesRpcUrl), this.pathfinder = new KJ(this.rpcClient), this.trust = new _J(this.rpcClient), this.token = new AJ(this.rpcClient), this.hubV2 = new RJ({ address: J.v2HubAddress, rpcUrl: J.circlesRpcUrl }), this.referralsModule = new iJ({ address: J.referralsModuleAddress, rpcUrl: J.circlesRpcUrl }), this.invitationFarm = new tJ({ address: J.invitationFarmAddress, rpcUrl: J.circlesRpcUrl }), this.invitationModuleContract = new F$({ address: J.invitationModuleAddress, rpcUrl: J.circlesRpcUrl });
|
|
4121
4121
|
}
|
|
4122
4122
|
async ensureInviterSetup(J) {
|
|
4123
|
-
let $ = J.toLowerCase(), Q = this.config.invitationModuleAddress, Y = [],
|
|
4124
|
-
if (!await
|
|
4125
|
-
Y.push(
|
|
4123
|
+
let $ = J.toLowerCase(), Q = this.config.invitationModuleAddress, Y = [], G = new b$({ address: $, rpcUrl: this.config.circlesRpcUrl });
|
|
4124
|
+
if (!await G.isModuleEnabled(Q))
|
|
4125
|
+
Y.push(G.enableModule(Q)), Y.push(this.invitationModuleContract.trustInviter($));
|
|
4126
4126
|
else if (!await this.hubV2.isTrusted(Q, $))
|
|
4127
4127
|
Y.push(this.invitationModuleContract.trustInviter($));
|
|
4128
4128
|
return Y;
|
|
@@ -4140,10 +4140,10 @@ class E8 {
|
|
|
4140
4140
|
try {
|
|
4141
4141
|
let Y = new URL(`${this.config.referralsServiceUrl}/list/${J}`);
|
|
4142
4142
|
Y.searchParams.set("limit", String($)), Y.searchParams.set("offset", String(Q));
|
|
4143
|
-
let
|
|
4144
|
-
if (!
|
|
4145
|
-
throw new v2(`HTTP error! status: ${
|
|
4146
|
-
return await
|
|
4143
|
+
let G = await fetch(Y.toString(), { method: "GET", headers: { accept: "application/json" } });
|
|
4144
|
+
if (!G.ok)
|
|
4145
|
+
throw new v2(`HTTP error! status: ${G.status}`, { code: "INVITATION_HTTP_ERROR", source: "INVITATIONS", context: { status: G.status, url: Y.toString() } });
|
|
4146
|
+
return await G.json();
|
|
4147
4147
|
} catch (Y) {
|
|
4148
4148
|
if (Y instanceof v2)
|
|
4149
4149
|
throw Y;
|
|
@@ -4152,11 +4152,11 @@ class E8 {
|
|
|
4152
4152
|
}
|
|
4153
4153
|
orderRealInviters(J, $) {
|
|
4154
4154
|
let Q = $.toLowerCase();
|
|
4155
|
-
return J.sort((Y,
|
|
4156
|
-
let
|
|
4157
|
-
if (
|
|
4155
|
+
return J.sort((Y, G) => {
|
|
4156
|
+
let M3 = Y.address.toLowerCase() === Q, Z = G.address.toLowerCase() === Q;
|
|
4157
|
+
if (M3 && !Z)
|
|
4158
4158
|
return -1;
|
|
4159
|
-
if (!
|
|
4159
|
+
if (!M3 && Z)
|
|
4160
4160
|
return 1;
|
|
4161
4161
|
return 0;
|
|
4162
4162
|
});
|
|
@@ -4165,7 +4165,7 @@ class E8 {
|
|
|
4165
4165
|
let Q = J.toLowerCase(), Y = $.toLowerCase();
|
|
4166
4166
|
if (await this.hubV2.isHuman(Y))
|
|
4167
4167
|
throw v2.inviteeAlreadyRegistered(Q, Y);
|
|
4168
|
-
let
|
|
4168
|
+
let M3 = await this.ensureInviterSetup(Q), Z = await this.getRealInviters(Q), K = [...M3];
|
|
4169
4169
|
if (Z.length > 0) {
|
|
4170
4170
|
console.log("[generateInvite] Using STANDARD PATH (proxy inviters available)");
|
|
4171
4171
|
let X = Z[0].address, q = await this.findInvitePath(Q, X), U = await this.generateInviteData([Y], false), V = await new uJ(this.config).buildFlowMatrixTx(Q, this.config.invitationModuleAddress, q, { toTokens: [X], useWrappedBalances: true, txData: y$(U) }, true);
|
|
@@ -4186,32 +4186,32 @@ class E8 {
|
|
|
4186
4186
|
if ($)
|
|
4187
4187
|
Y = $.toLowerCase();
|
|
4188
4188
|
else {
|
|
4189
|
-
let
|
|
4190
|
-
if (
|
|
4189
|
+
let M3 = await this.getRealInviters(Q);
|
|
4190
|
+
if (M3.length === 0)
|
|
4191
4191
|
throw v2.noPathFound(Q, this.config.invitationModuleAddress);
|
|
4192
|
-
Y =
|
|
4192
|
+
Y = M3[0].address;
|
|
4193
4193
|
}
|
|
4194
|
-
let
|
|
4195
|
-
if (!
|
|
4194
|
+
let G = await this.pathfinder.findPath({ from: Q, to: this.config.invitationModuleAddress, targetFlow: m2, toTokens: [Y], useWrappedBalances: true, simulatedTrusts: [{ truster: this.config.invitationModuleAddress, trustee: Q }] });
|
|
4195
|
+
if (!G.transfers || G.transfers.length === 0)
|
|
4196
4196
|
throw v2.noPathFound(Q, this.config.invitationModuleAddress);
|
|
4197
|
-
if (
|
|
4198
|
-
let Z = Number(
|
|
4199
|
-
throw v2.insufficientBalance(1, Z, m2,
|
|
4197
|
+
if (G.maxFlow < m2) {
|
|
4198
|
+
let Z = Number(G.maxFlow / m2);
|
|
4199
|
+
throw v2.insufficientBalance(1, Z, m2, G.maxFlow, Q, this.config.invitationModuleAddress);
|
|
4200
4200
|
}
|
|
4201
|
-
return
|
|
4201
|
+
return G;
|
|
4202
4202
|
}
|
|
4203
4203
|
async findFarmInvitePath(J) {
|
|
4204
4204
|
let $ = J.toLowerCase(), Q = await this.pathfinder.findPath({ from: $, to: HJ, targetFlow: m2, toTokens: [n0], useWrappedBalances: true });
|
|
4205
4205
|
if (!Q.transfers || Q.transfers.length === 0)
|
|
4206
4206
|
throw v2.noPathFound($, HJ);
|
|
4207
4207
|
if (Q.maxFlow < m2) {
|
|
4208
|
-
let
|
|
4209
|
-
throw v2.insufficientBalance(1,
|
|
4208
|
+
let G = Number(Q.maxFlow / m2);
|
|
4209
|
+
throw v2.insufficientBalance(1, G, m2, Q.maxFlow, $, HJ);
|
|
4210
4210
|
}
|
|
4211
4211
|
return Q;
|
|
4212
4212
|
}
|
|
4213
4213
|
async getRealInviters(J) {
|
|
4214
|
-
let $ = J.toLowerCase(), [Q, Y,
|
|
4214
|
+
let $ = J.toLowerCase(), [Q, Y, G, M3, Z] = await Promise.all([dJ !== "0x0000000000000000000000000000000000000000" ? this.trust.getTrusts(dJ) : Promise.resolve([]), this.trust.getTrustedBy($), this.trust.getMutualTrusts($), this.trust.getTrusts(this.config.invitationModuleAddress), this.trust.getMutualTrusts(this.config.invitationModuleAddress)]), K = new Set(Q.map((j) => j.objectAvatar.toLowerCase())), X = new Set([...Y.map((j) => j.objectAvatar.toLowerCase()), ...G.map((j) => j.objectAvatar.toLowerCase())]), q = new Set([...M3.map((j) => j.objectAvatar.toLowerCase()), ...Z.map((j) => j.objectAvatar.toLowerCase())]), D3 = [...[...X].filter((j) => q.has(j) && !K.has(j)), $];
|
|
4215
4215
|
if (D3.length === 0)
|
|
4216
4216
|
return [];
|
|
4217
4217
|
let V = await this.pathfinder.findPath({ from: $, to: this.config.invitationModuleAddress, useWrappedBalances: true, targetFlow: X$, toTokens: D3, simulatedTrusts: [{ truster: this.config.invitationModuleAddress, trustee: $ }] });
|
|
@@ -4219,28 +4219,28 @@ class E8 {
|
|
|
4219
4219
|
return [];
|
|
4220
4220
|
let O3 = this.config.invitationModuleAddress.toLowerCase(), L2 = V.transfers.filter((j) => j.to.toLowerCase() === O3), N2 = [...new Set(L2.map((j) => j.tokenOwner.toLowerCase()))], b3 = await this.token.getTokenInfoBatch(N2), y3 = new Map;
|
|
4221
4221
|
for (let j of b3) {
|
|
4222
|
-
let
|
|
4223
|
-
if (
|
|
4224
|
-
y3.set(
|
|
4222
|
+
let P3 = j.tokenAddress ?? j.token;
|
|
4223
|
+
if (P3 && j?.tokenOwner)
|
|
4224
|
+
y3.set(P3.toLowerCase(), j.tokenOwner.toLowerCase());
|
|
4225
4225
|
}
|
|
4226
4226
|
let f3 = new Map;
|
|
4227
4227
|
for (let j of L2) {
|
|
4228
|
-
let
|
|
4229
|
-
f3.set(
|
|
4228
|
+
let P3 = j.tokenOwner.toLowerCase(), B3 = y3.get(P3) ?? P3;
|
|
4229
|
+
f3.set(B3, (f3.get(B3) ?? 0n) + j.value);
|
|
4230
4230
|
}
|
|
4231
4231
|
let W = [];
|
|
4232
|
-
for (let [j,
|
|
4233
|
-
let
|
|
4234
|
-
if (
|
|
4235
|
-
W.push({ address: j, possibleInvites:
|
|
4232
|
+
for (let [j, P3] of f3.entries()) {
|
|
4233
|
+
let B3 = Number(P3 / m2);
|
|
4234
|
+
if (B3 >= 1)
|
|
4235
|
+
W.push({ address: j, possibleInvites: B3 });
|
|
4236
4236
|
}
|
|
4237
4237
|
return this.orderRealInviters(W, $);
|
|
4238
4238
|
}
|
|
4239
4239
|
async generateReferral(J) {
|
|
4240
|
-
let $ = J.toLowerCase(), Q = m$(), Y = eJ(Q),
|
|
4241
|
-
if (
|
|
4240
|
+
let $ = J.toLowerCase(), Q = m$(), Y = eJ(Q), G = await this.ensureInviterSetup($), M3 = await this.getRealInviters($), Z = [...G];
|
|
4241
|
+
if (M3.length > 0) {
|
|
4242
4242
|
console.log("[generateReferral] Using STANDARD PATH (proxy inviters available)");
|
|
4243
|
-
let K = new uJ(this.config), X = await this.generateInviteData([Y], true), q =
|
|
4243
|
+
let K = new uJ(this.config), X = await this.generateInviteData([Y], true), q = M3[0].address, U = await this.findInvitePath($, q), D3 = await K.buildFlowMatrixTx($, this.config.invitationModuleAddress, U, { toTokens: [q], useWrappedBalances: true, txData: y$(X) }, true);
|
|
4244
4244
|
Z.push(...D3);
|
|
4245
4245
|
} else {
|
|
4246
4246
|
console.log("[generateReferral] Using FARM FALLBACK PATH (no proxy inviters available)");
|
|
@@ -4270,7 +4270,7 @@ class E8 {
|
|
|
4270
4270
|
}
|
|
4271
4271
|
}
|
|
4272
4272
|
computeAddress(J) {
|
|
4273
|
-
let Q = J.toLowerCase().replace("0x", "").padStart(64, "0"), Y = r$.replace("0x", "") + Q,
|
|
4273
|
+
let Q = J.toLowerCase().replace("0x", "").padStart(64, "0"), Y = r$.replace("0x", "") + Q, G = h$("0x" + Y), M3 = "ff", Z = s$.toLowerCase().replace("0x", ""), K = G.replace("0x", ""), X = e$.replace("0x", ""), q = "ff" + Z + K + X, D3 = "0x" + h$("0x" + q).slice(-40);
|
|
4274
4274
|
return OJ(D3);
|
|
4275
4275
|
}
|
|
4276
4276
|
generateSecrets(J) {
|
|
@@ -4288,7 +4288,7 @@ class nQ {
|
|
|
4288
4288
|
referralsModule;
|
|
4289
4289
|
hubV2;
|
|
4290
4290
|
constructor(J) {
|
|
4291
|
-
this.referralsModuleAddress = J.referralsModuleAddress, this.invitations = new E8(J), this.invitationFarm = new tJ({ address: J.invitationFarmAddress, rpcUrl: J.circlesRpcUrl }), this.referralsModule = new iJ({ address: J.referralsModuleAddress, rpcUrl: J.circlesRpcUrl }), this.hubV2 = new
|
|
4291
|
+
this.referralsModuleAddress = J.referralsModuleAddress, this.invitations = new E8(J), this.invitationFarm = new tJ({ address: J.invitationFarmAddress, rpcUrl: J.circlesRpcUrl }), this.referralsModule = new iJ({ address: J.referralsModuleAddress, rpcUrl: J.circlesRpcUrl }), this.hubV2 = new RJ({ address: J.v2HubAddress, rpcUrl: J.circlesRpcUrl });
|
|
4292
4292
|
}
|
|
4293
4293
|
async getQuota(J) {
|
|
4294
4294
|
return this.invitationFarm.inviterQuota(J);
|
|
@@ -4302,19 +4302,19 @@ class nQ {
|
|
|
4302
4302
|
async generateReferrals(J, $) {
|
|
4303
4303
|
if ($ <= 0)
|
|
4304
4304
|
throw new v2("Count must be greater than 0", { code: "INVITATION_INVALID_COUNT", source: "VALIDATION", context: { count: $ } });
|
|
4305
|
-
let Q = J.toLowerCase(), Y = $ === 1,
|
|
4306
|
-
if (!
|
|
4305
|
+
let Q = J.toLowerCase(), Y = $ === 1, G = await this.simulateClaim(Q, $);
|
|
4306
|
+
if (!G.length)
|
|
4307
4307
|
throw new v2("No invitation IDs returned from claim", { code: "INVITATION_NO_IDS", source: "INVITATIONS", context: { inviter: Q, count: $ } });
|
|
4308
|
-
let
|
|
4309
|
-
return { referrals:
|
|
4308
|
+
let M3 = this.invitations.generateSecrets($), Z = M3.map((U) => U.signer), K = await this.invitationFarm.invitationModule(), X = Y ? this.invitationFarm.claimInvite() : this.invitationFarm.claimInvites(BigInt($)), q = Y ? this.buildReferralTransfer(Q, K, G[0], Z[0]) : this.buildBatchReferralTransfer(Q, K, G, Z);
|
|
4309
|
+
return { referrals: M3, transactions: [X, q] };
|
|
4310
4310
|
}
|
|
4311
4311
|
async generateInvites(J, $) {
|
|
4312
4312
|
if ($.length === 0)
|
|
4313
4313
|
throw new v2("At least one invitee address must be provided", { code: "INVITATION_INVALID_COUNT", source: "VALIDATION", context: { count: 0 } });
|
|
4314
|
-
let Q = J.toLowerCase(), Y = $.map((U) => U.toLowerCase()),
|
|
4314
|
+
let Q = J.toLowerCase(), Y = $.map((U) => U.toLowerCase()), G = Y.length, M3 = G === 1, Z = await this.simulateClaim(Q, G);
|
|
4315
4315
|
if (!Z.length)
|
|
4316
|
-
throw new v2("No invitation IDs returned from claim", { code: "INVITATION_NO_IDS", source: "INVITATIONS", context: { inviter: Q, count:
|
|
4317
|
-
let K = await this.invitationFarm.invitationModule(), X =
|
|
4316
|
+
throw new v2("No invitation IDs returned from claim", { code: "INVITATION_NO_IDS", source: "INVITATIONS", context: { inviter: Q, count: G } });
|
|
4317
|
+
let K = await this.invitationFarm.invitationModule(), X = M3 ? this.invitationFarm.claimInvite() : this.invitationFarm.claimInvites(BigInt(G)), q = M3 ? this.buildInviteTransfer(Q, K, Z[0], Y[0]) : this.buildBatchInviteTransfer(Q, K, Z, Y);
|
|
4318
4318
|
return { invitees: Y, transactions: [X, q] };
|
|
4319
4319
|
}
|
|
4320
4320
|
async listReferrals(J, $ = 10, Q = 0) {
|
|
@@ -4326,20 +4326,20 @@ class nQ {
|
|
|
4326
4326
|
return this.invitationFarm.read("claimInvites", [BigInt($)], { from: J });
|
|
4327
4327
|
}
|
|
4328
4328
|
buildReferralTransfer(J, $, Q, Y) {
|
|
4329
|
-
let
|
|
4330
|
-
return this.hubV2.safeTransferFrom(J, $, Q, m2,
|
|
4329
|
+
let G = this.referralsModule.createAccount(Y).data, M3 = r3(["address", "bytes"], [this.referralsModuleAddress, G]);
|
|
4330
|
+
return this.hubV2.safeTransferFrom(J, $, Q, m2, M3);
|
|
4331
4331
|
}
|
|
4332
4332
|
buildBatchReferralTransfer(J, $, Q, Y) {
|
|
4333
|
-
let
|
|
4334
|
-
return this.hubV2.safeBatchTransferFrom(J, $, Q, Z,
|
|
4333
|
+
let G = this.referralsModule.createAccounts(Y).data, M3 = r3(["address", "bytes"], [this.referralsModuleAddress, G]), Z = Q.map(() => m2);
|
|
4334
|
+
return this.hubV2.safeBatchTransferFrom(J, $, Q, Z, M3);
|
|
4335
4335
|
}
|
|
4336
4336
|
buildInviteTransfer(J, $, Q, Y) {
|
|
4337
|
-
let
|
|
4338
|
-
return this.hubV2.safeTransferFrom(J, $, Q, m2,
|
|
4337
|
+
let G = r3(["address"], [Y]);
|
|
4338
|
+
return this.hubV2.safeTransferFrom(J, $, Q, m2, G);
|
|
4339
4339
|
}
|
|
4340
4340
|
buildBatchInviteTransfer(J, $, Q, Y) {
|
|
4341
|
-
let
|
|
4342
|
-
return this.hubV2.safeBatchTransferFrom(J, $, Q,
|
|
4341
|
+
let G = r3(["address[]"], [Y]), M3 = Q.map(() => m2);
|
|
4342
|
+
return this.hubV2.safeBatchTransferFrom(J, $, Q, M3, G);
|
|
4343
4343
|
}
|
|
4344
4344
|
}
|
|
4345
4345
|
|
|
@@ -4351,7 +4351,7 @@ class x8 {
|
|
|
4351
4351
|
this.address = J.address, this.abi = J.abi, this.rpcUrl = J.rpcUrl;
|
|
4352
4352
|
}
|
|
4353
4353
|
async read(J, $, Q) {
|
|
4354
|
-
let Y = TJ({ abi: this.abi, functionName: J, args: $ }),
|
|
4354
|
+
let Y = TJ({ abi: this.abi, functionName: J, args: $ }), G = { to: this.address, data: Y, ...Q?.from && { from: Q.from } }, Z = await (await fetch(this.rpcUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_call", params: [G, "latest"] }) })).json();
|
|
4355
4355
|
if (Z.error)
|
|
4356
4356
|
throw Error(`RPC Error: ${Z.error.message}`);
|
|
4357
4357
|
if (!Z.result)
|
|
@@ -4380,14 +4380,14 @@ class k8 extends x8 {
|
|
|
4380
4380
|
claimAccount(J, $, Q, Y) {
|
|
4381
4381
|
return { to: this.address, data: this.encodeWrite("claimAccount", [J, $, Q, Y]), value: BigInt(0) };
|
|
4382
4382
|
}
|
|
4383
|
-
claimAccountWithMetadata(J, $, Q, Y,
|
|
4384
|
-
return { to: this.address, data: this.encodeWrite("claimAccount", [J, $, Q, Y,
|
|
4383
|
+
claimAccountWithMetadata(J, $, Q, Y, G) {
|
|
4384
|
+
return { to: this.address, data: this.encodeWrite("claimAccount", [J, $, Q, Y, G]), value: BigInt(0) };
|
|
4385
4385
|
}
|
|
4386
|
-
claimAccountWithAffiliateGroup(J, $, Q, Y,
|
|
4387
|
-
return { to: this.address, data: this.encodeWrite("claimAccount", [J, $, Q, Y,
|
|
4386
|
+
claimAccountWithAffiliateGroup(J, $, Q, Y, G) {
|
|
4387
|
+
return { to: this.address, data: this.encodeWrite("claimAccount", [J, $, Q, Y, G]), value: BigInt(0) };
|
|
4388
4388
|
}
|
|
4389
|
-
claimAccountWithMetadataAndAffiliateGroup(J, $, Q, Y,
|
|
4390
|
-
return { to: this.address, data: this.encodeWrite("claimAccount", [J, $, Q, Y,
|
|
4389
|
+
claimAccountWithMetadataAndAffiliateGroup(J, $, Q, Y, G, M3) {
|
|
4390
|
+
return { to: this.address, data: this.encodeWrite("claimAccount", [J, $, Q, Y, G, M3]), value: BigInt(0) };
|
|
4391
4391
|
}
|
|
4392
4392
|
async accounts(J) {
|
|
4393
4393
|
let [$, Q] = await this.read("accounts", [J]);
|
|
@@ -4466,17 +4466,17 @@ class iQ {
|
|
|
4466
4466
|
return $.json();
|
|
4467
4467
|
}
|
|
4468
4468
|
async retrieve(J) {
|
|
4469
|
-
let $ = eJ(J), { account: Q, claimed: Y } = await this.referralsModule.accounts($),
|
|
4470
|
-
if (
|
|
4471
|
-
let Z = await
|
|
4469
|
+
let $ = eJ(J), { account: Q, claimed: Y } = await this.referralsModule.accounts($), G = await fetch(`${this.getBaseUrl()}/retrieve?key=${encodeURIComponent(J)}`);
|
|
4470
|
+
if (G.ok || G.status === 410 || Y) {
|
|
4471
|
+
let Z = await G.json();
|
|
4472
4472
|
if (Q === IJ)
|
|
4473
4473
|
return { ...Z, error: `Referral not found on-chain for signer ${$}` };
|
|
4474
4474
|
return Z;
|
|
4475
4475
|
}
|
|
4476
4476
|
if (Q === IJ)
|
|
4477
4477
|
return { error: `Referral not found on-chain for signer ${$}` };
|
|
4478
|
-
let
|
|
4479
|
-
throw o3.retrieveFailed(
|
|
4478
|
+
let M3 = await G.json().catch(() => null);
|
|
4479
|
+
throw o3.retrieveFailed(M3?.error || G.statusText, G.status);
|
|
4480
4480
|
}
|
|
4481
4481
|
async listMine(J) {
|
|
4482
4482
|
if (!this.getToken)
|
|
@@ -4490,12 +4490,12 @@ class iQ {
|
|
|
4490
4490
|
$.set("inSession", String(J.inSession));
|
|
4491
4491
|
if (J?.status !== undefined)
|
|
4492
4492
|
$.set("status", J.status);
|
|
4493
|
-
let Q = $.toString() ? `?${$}` : "", Y = await this.getAuthHeaders(),
|
|
4494
|
-
if (!
|
|
4495
|
-
let
|
|
4496
|
-
throw o3.listFailed(
|
|
4493
|
+
let Q = $.toString() ? `?${$}` : "", Y = await this.getAuthHeaders(), G = await fetch(`${this.getBaseUrl()}/my-referrals${Q}`, { headers: Y });
|
|
4494
|
+
if (!G.ok) {
|
|
4495
|
+
let M3 = await G.json();
|
|
4496
|
+
throw o3.listFailed(M3.error || G.statusText);
|
|
4497
4497
|
}
|
|
4498
|
-
return
|
|
4498
|
+
return G.json();
|
|
4499
4499
|
}
|
|
4500
4500
|
async listPublic(J, $) {
|
|
4501
4501
|
let Q = new URLSearchParams;
|
|
@@ -4505,12 +4505,12 @@ class iQ {
|
|
|
4505
4505
|
Q.set("offset", String($.offset));
|
|
4506
4506
|
if ($?.inSession !== undefined)
|
|
4507
4507
|
Q.set("inSession", String($.inSession));
|
|
4508
|
-
let Y = Q.toString() ? `?${Q}` : "",
|
|
4509
|
-
if (!
|
|
4510
|
-
let
|
|
4511
|
-
throw o3.listFailed(
|
|
4508
|
+
let Y = Q.toString() ? `?${Q}` : "", G = await fetch(`${this.getBaseUrl()}/list/${encodeURIComponent(J)}${Y}`);
|
|
4509
|
+
if (!G.ok) {
|
|
4510
|
+
let M3 = await G.json();
|
|
4511
|
+
throw o3.listFailed(M3.error || G.statusText);
|
|
4512
4512
|
}
|
|
4513
|
-
return
|
|
4513
|
+
return G.json();
|
|
4514
4514
|
}
|
|
4515
4515
|
}
|
|
4516
4516
|
|
|
@@ -4842,9 +4842,9 @@ for (let J = 0, Z = I2, $ = 1, Y = 0;J < 24; J++) {
|
|
|
4842
4842
|
W ^= I2 << (I2 << BigInt(G)) - I2;
|
|
4843
4843
|
WJ2.push(W);
|
|
4844
4844
|
}
|
|
4845
|
-
var
|
|
4846
|
-
var BJ =
|
|
4847
|
-
var SJ2 =
|
|
4845
|
+
var GJ = i2(WJ2, true);
|
|
4846
|
+
var BJ = GJ[0];
|
|
4847
|
+
var SJ2 = GJ[1];
|
|
4848
4848
|
var JJ2 = (J, Z, $) => $ > 32 ? t3(J, Z, $) : n3(J, Z, $);
|
|
4849
4849
|
var ZJ = (J, Z, $) => $ > 32 ? a2(J, Z, $) : o4(J, Z, $);
|
|
4850
4850
|
function wJ2(J, Z = 24) {
|
|
@@ -4963,7 +4963,7 @@ function KJ2(J) {
|
|
|
4963
4963
|
Z += VJ2[J[$]];
|
|
4964
4964
|
return Z;
|
|
4965
4965
|
}
|
|
4966
|
-
function
|
|
4966
|
+
function MJ2(J) {
|
|
4967
4967
|
let Z = J.toLowerCase().replace("0x", ""), $ = KJ2(QJ2(new TextEncoder().encode(Z))).slice(2), Y = "0x";
|
|
4968
4968
|
for (let W = 0;W < Z.length; W++)
|
|
4969
4969
|
Y += parseInt($[W], 16) >= 8 ? Z[W].toUpperCase() : Z[W];
|
|
@@ -4973,7 +4973,7 @@ function V(J) {
|
|
|
4973
4973
|
return J.toLowerCase();
|
|
4974
4974
|
}
|
|
4975
4975
|
function gJ2(J) {
|
|
4976
|
-
return
|
|
4976
|
+
return MJ2(J);
|
|
4977
4977
|
}
|
|
4978
4978
|
function AJ2(J) {
|
|
4979
4979
|
if (typeof J !== "string")
|
|
@@ -5101,7 +5101,7 @@ class N2 {
|
|
|
5101
5101
|
}
|
|
5102
5102
|
}
|
|
5103
5103
|
|
|
5104
|
-
class
|
|
5104
|
+
class R4 {
|
|
5105
5105
|
client;
|
|
5106
5106
|
constructor(J) {
|
|
5107
5107
|
this.client = J;
|
|
@@ -5330,7 +5330,7 @@ class T3 {
|
|
|
5330
5330
|
}
|
|
5331
5331
|
}
|
|
5332
5332
|
|
|
5333
|
-
class
|
|
5333
|
+
class C3 {
|
|
5334
5334
|
client;
|
|
5335
5335
|
constructor(J) {
|
|
5336
5336
|
this.client = J;
|
|
@@ -5533,7 +5533,7 @@ class XJ2 {
|
|
|
5533
5533
|
}
|
|
5534
5534
|
get trust() {
|
|
5535
5535
|
if (!this._trust)
|
|
5536
|
-
this._trust = new
|
|
5536
|
+
this._trust = new R4(this.client);
|
|
5537
5537
|
return this._trust;
|
|
5538
5538
|
}
|
|
5539
5539
|
get balance() {
|
|
@@ -5553,7 +5553,7 @@ class XJ2 {
|
|
|
5553
5553
|
}
|
|
5554
5554
|
get token() {
|
|
5555
5555
|
if (!this._token)
|
|
5556
|
-
this._token = new
|
|
5556
|
+
this._token = new C3(this.client);
|
|
5557
5557
|
return this._token;
|
|
5558
5558
|
}
|
|
5559
5559
|
get invitation() {
|
|
@@ -7285,14 +7285,14 @@ var _0x71n = BigInt(113);
|
|
|
7285
7285
|
var SHA3_PI = [];
|
|
7286
7286
|
var SHA3_ROTL = [];
|
|
7287
7287
|
var _SHA3_IOTA = [];
|
|
7288
|
-
for (let round = 0,
|
|
7288
|
+
for (let round = 0, R5 = _1n, x4 = 1, y4 = 0;round < 24; round++) {
|
|
7289
7289
|
[x4, y4] = [y4, (2 * x4 + 3 * y4) % 5];
|
|
7290
7290
|
SHA3_PI.push(2 * (5 * y4 + x4));
|
|
7291
7291
|
SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
|
|
7292
7292
|
let t4 = _0n;
|
|
7293
7293
|
for (let j2 = 0;j2 < 7; j2++) {
|
|
7294
|
-
|
|
7295
|
-
if (
|
|
7294
|
+
R5 = (R5 << _1n ^ (R5 >> _7n) * _0x71n) % _256n;
|
|
7295
|
+
if (R5 & _2n)
|
|
7296
7296
|
t4 ^= _1n << (_1n << /* @__PURE__ */ BigInt(j2)) - _1n;
|
|
7297
7297
|
}
|
|
7298
7298
|
_SHA3_IOTA.push(t4);
|
|
@@ -10715,12 +10715,12 @@ class r5 {
|
|
|
10715
10715
|
var pt = "0x0000000000000000000000000000000000000000";
|
|
10716
10716
|
var Es = BigInt(96) * BigInt(1000000000000000000);
|
|
10717
10717
|
var gs = BigInt("9999999999999999999999999999999999999");
|
|
10718
|
-
var
|
|
10718
|
+
var R5 = BigInt(4294967295);
|
|
10719
10719
|
var nu = BigInt(32);
|
|
10720
10720
|
function By(t4, u3 = false) {
|
|
10721
10721
|
if (u3)
|
|
10722
|
-
return { h: Number(t4 &
|
|
10723
|
-
return { h: Number(t4 >> nu &
|
|
10722
|
+
return { h: Number(t4 & R5), l: Number(t4 >> nu & R5) };
|
|
10723
|
+
return { h: Number(t4 >> nu & R5) | 0, l: Number(t4 & R5) | 0 };
|
|
10724
10724
|
}
|
|
10725
10725
|
function Zy(t4, u3 = false) {
|
|
10726
10726
|
let y4 = t4.length, s4 = new Uint32Array(y4), i3 = new Uint32Array(y4);
|
|
@@ -11312,8 +11312,8 @@ class Ku {
|
|
|
11312
11312
|
throw k3.wrappedTokensRequired();
|
|
11313
11313
|
let d5 = [], S4 = [];
|
|
11314
11314
|
if (m4) {
|
|
11315
|
-
let P4 = await this._getTokenBalanceMap(v4),
|
|
11316
|
-
d5 = [...
|
|
11315
|
+
let P4 = await this._getTokenBalanceMap(v4), C4 = this._createDemurragedUnwrapCalls(p4), { unwrapCalls: xu, wrapCalls: wu } = this._createInflationaryUnwrapAndWrapCalls(p4, a3, P4);
|
|
11316
|
+
d5 = [...C4, ...xu], S4 = wu, b4 = Bt(b4, a3);
|
|
11317
11317
|
}
|
|
11318
11318
|
let h5 = kt(v4, e4, b4.maxFlow, b4.transfers), I3 = Pt(h5, s4?.txData), D4 = this.hubV2.operateFlowMatrix(h5.flowVertices, h5.flowEdges, I3, h5.packedCoordinates), A4 = false;
|
|
11319
11319
|
try {
|
|
@@ -11332,8 +11332,8 @@ class Ku {
|
|
|
11332
11332
|
return [{ to: P4.to, data: P4.data, value: P4.value ?? 0n }];
|
|
11333
11333
|
}
|
|
11334
11334
|
if (h5.toLowerCase() === A4.toLowerCase() && A4 !== pt) {
|
|
11335
|
-
let x4 = new Q({ address: h5, rpcUrl: this.config.circlesRpcUrl }), P4 = r5.attoCirclesToAttoStaticCircles(b4),
|
|
11336
|
-
return [{ to:
|
|
11335
|
+
let x4 = new Q({ address: h5, rpcUrl: this.config.circlesRpcUrl }), P4 = r5.attoCirclesToAttoStaticCircles(b4), C4 = x4.unwrap(P4);
|
|
11336
|
+
return [{ to: C4.to, data: C4.data, value: C4.value ?? 0n }];
|
|
11337
11337
|
}
|
|
11338
11338
|
}
|
|
11339
11339
|
let a3 = this._truncateToSixDecimals(b4), p4 = await this._getDefaultTokenExcludeList(e4, s4?.excludeFromTokens), { ...m4 } = s4 || {}, d5 = { ...m4, ...p4 ? { excludeFromTokens: p4 } : {} }, S4 = await this.pathfinder.findPath({ from: v4, to: e4, targetFlow: a3, ...d5 });
|