@aboutcircles/sdk 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +273 -270
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12656,9 +12656,9 @@ class R03 {
|
|
|
12656
12656
|
if (Y2 !== undefined && this.pendingResponses[Y2])
|
|
12657
12657
|
this.pendingResponses[Y2].resolve(G2), delete this.pendingResponses[Y2];
|
|
12658
12658
|
if (Z3 === "eth_subscription" && K3) {
|
|
12659
|
-
let { subscription:
|
|
12660
|
-
if (this.subscriptionListeners[
|
|
12661
|
-
this.subscriptionListeners[
|
|
12659
|
+
let { subscription: q3, result: X4 } = K3;
|
|
12660
|
+
if (this.subscriptionListeners[q3])
|
|
12661
|
+
this.subscriptionListeners[q3].forEach((M2) => M2(X4));
|
|
12662
12662
|
}
|
|
12663
12663
|
}, this.websocket.onclose = () => {
|
|
12664
12664
|
console.warn("WebSocket closed"), this.websocketConnected = false;
|
|
@@ -12701,7 +12701,7 @@ class R03 {
|
|
|
12701
12701
|
if (!this.subscriptionListeners[Z3])
|
|
12702
12702
|
this.subscriptionListeners[Z3] = [];
|
|
12703
12703
|
return this.subscriptionListeners[Z3].push((K3) => {
|
|
12704
|
-
z$2(K3).forEach((
|
|
12704
|
+
z$2(K3).forEach((q3) => Q4.emit(q3));
|
|
12705
12705
|
}), Q4.property;
|
|
12706
12706
|
}
|
|
12707
12707
|
}
|
|
@@ -12715,8 +12715,8 @@ function A8($3, J2 = false) {
|
|
|
12715
12715
|
function EJ3($3, J2 = false) {
|
|
12716
12716
|
let Q4 = $3.length, G2 = new Uint32Array(Q4), Y2 = new Uint32Array(Q4);
|
|
12717
12717
|
for (let Z3 = 0;Z3 < Q4; Z3++) {
|
|
12718
|
-
let { h: K3, l:
|
|
12719
|
-
[G2[Z3], Y2[Z3]] = [K3,
|
|
12718
|
+
let { h: K3, l: q3 } = A8($3[Z3], J2);
|
|
12719
|
+
[G2[Z3], Y2[Z3]] = [K3, q3];
|
|
12720
12720
|
}
|
|
12721
12721
|
return [G2, Y2];
|
|
12722
12722
|
}
|
|
@@ -12844,20 +12844,20 @@ function l82($3, J2 = 24) {
|
|
|
12844
12844
|
for (let K3 = 0;K3 < 10; K3++)
|
|
12845
12845
|
Q4[K3] = $3[K3] ^ $3[K3 + 10] ^ $3[K3 + 20] ^ $3[K3 + 30] ^ $3[K3 + 40];
|
|
12846
12846
|
for (let K3 = 0;K3 < 10; K3 += 2) {
|
|
12847
|
-
let
|
|
12847
|
+
let q3 = (K3 + 8) % 10, X4 = (K3 + 2) % 10, M2 = Q4[X4], j4 = Q4[X4 + 1], N = gJ3(M2, j4, 1) ^ Q4[q3], D3 = vJ3(M2, j4, 1) ^ Q4[q3 + 1];
|
|
12848
12848
|
for (let V2 = 0;V2 < 50; V2 += 10)
|
|
12849
12849
|
$3[K3 + V2] ^= N, $3[K3 + V2 + 1] ^= D3;
|
|
12850
12850
|
}
|
|
12851
12851
|
let Y2 = $3[2], Z3 = $3[3];
|
|
12852
12852
|
for (let K3 = 0;K3 < 24; K3++) {
|
|
12853
|
-
let
|
|
12854
|
-
Y2 = $3[j4], Z3 = $3[j4 + 1], $3[j4] =
|
|
12853
|
+
let q3 = mJ2[K3], X4 = gJ3(Y2, Z3, q3), M2 = vJ3(Y2, Z3, q3), j4 = hJ[K3];
|
|
12854
|
+
Y2 = $3[j4], Z3 = $3[j4 + 1], $3[j4] = X4, $3[j4 + 1] = M2;
|
|
12855
12855
|
}
|
|
12856
12856
|
for (let K3 = 0;K3 < 50; K3 += 10) {
|
|
12857
|
-
for (let
|
|
12858
|
-
Q4[
|
|
12859
|
-
for (let
|
|
12860
|
-
$3[K3 +
|
|
12857
|
+
for (let q3 = 0;q3 < 10; q3++)
|
|
12858
|
+
Q4[q3] = $3[K3 + q3];
|
|
12859
|
+
for (let q3 = 0;q3 < 10; q3++)
|
|
12860
|
+
$3[K3 + q3] ^= ~Q4[(q3 + 2) % 10] & Q4[(q3 + 4) % 10];
|
|
12861
12861
|
}
|
|
12862
12862
|
$3[0] ^= u83[G2], $3[1] ^= c82[G2];
|
|
12863
12863
|
}
|
|
@@ -13004,32 +13004,32 @@ function C03($3, J2, Q4) {
|
|
|
13004
13004
|
function n82($3, J2, Q4) {
|
|
13005
13005
|
let G2 = $3.slice(0, $3.indexOf("[")), Y2 = $3.endsWith("[]"), Z3 = u03(G2, Q4), K3;
|
|
13006
13006
|
if (Z3) {
|
|
13007
|
-
let
|
|
13008
|
-
K3 =
|
|
13009
|
-
let N =
|
|
13010
|
-
return
|
|
13011
|
-
}).join("") +
|
|
13007
|
+
let q3 = J2.map((j4) => C03(G2, j4, Q4)), X4 = J2.length * B$2;
|
|
13008
|
+
K3 = q3.map((j4) => {
|
|
13009
|
+
let N = X4;
|
|
13010
|
+
return X4 += j4.length / 2, K02(N);
|
|
13011
|
+
}).join("") + q3.join("");
|
|
13012
13012
|
} else
|
|
13013
|
-
K3 = J2.map((
|
|
13013
|
+
K3 = J2.map((q3) => C03(G2, q3, Q4)).join("");
|
|
13014
13014
|
return Y2 ? K02(J2.length) + K3 : K3;
|
|
13015
13015
|
}
|
|
13016
13016
|
function o82($3, J2) {
|
|
13017
13017
|
let Q4 = Array.isArray(J2), G2 = [], Y2 = [], Z3 = [];
|
|
13018
13018
|
for (let K3 = 0;K3 < $3.length; K3++) {
|
|
13019
|
-
let
|
|
13019
|
+
let q3 = $3[K3], X4 = Q4 ? J2[K3] : J2[q3.name || ""], M2 = u03(q3.type, q3.components);
|
|
13020
13020
|
if (Z3.push(M2), M2)
|
|
13021
|
-
G2.push(""), Y2.push(C03(
|
|
13021
|
+
G2.push(""), Y2.push(C03(q3.type, X4, q3.components));
|
|
13022
13022
|
else
|
|
13023
|
-
G2.push(C03(
|
|
13023
|
+
G2.push(C03(q3.type, X4, q3.components));
|
|
13024
13024
|
}
|
|
13025
13025
|
if (Y2.length > 0) {
|
|
13026
|
-
let K3 = G2.reduce((M2, j4, N) => M2 + (Z3[N] ? B$2 : j4.length / 2), 0),
|
|
13026
|
+
let K3 = G2.reduce((M2, j4, N) => M2 + (Z3[N] ? B$2 : j4.length / 2), 0), q3 = "", X4 = 0;
|
|
13027
13027
|
for (let M2 = 0;M2 < $3.length; M2++)
|
|
13028
13028
|
if (Z3[M2])
|
|
13029
|
-
|
|
13029
|
+
q3 += K02(K3), K3 += Y2[X4].length / 2, X4++;
|
|
13030
13030
|
else
|
|
13031
|
-
|
|
13032
|
-
return
|
|
13031
|
+
q3 += G2[M2];
|
|
13032
|
+
return q3 + Y2.join("");
|
|
13033
13033
|
}
|
|
13034
13034
|
return G2.join("");
|
|
13035
13035
|
}
|
|
@@ -13072,8 +13072,8 @@ function e03($3, J2, Q4 = 0, G2) {
|
|
|
13072
13072
|
function a82($3, J2, Q4, G2) {
|
|
13073
13073
|
let Y2 = $3.slice(0, $3.indexOf("[")), Z3 = J2.slice(Q4, Q4 + u4);
|
|
13074
13074
|
if ($3.endsWith("[]")) {
|
|
13075
|
-
let
|
|
13076
|
-
for (let N = 0;N <
|
|
13075
|
+
let q3 = parseInt(Z3, 16) * 2, X4 = parseInt(J2.slice(q3, q3 + u4), 16), M2 = [], j4 = q3 + u4;
|
|
13076
|
+
for (let N = 0;N < X4; N++) {
|
|
13077
13077
|
let D3 = e03(Y2, J2, j4, G2);
|
|
13078
13078
|
M2.push(D3.value), j4 += D3.consumed;
|
|
13079
13079
|
}
|
|
@@ -13081,12 +13081,12 @@ function a82($3, J2, Q4, G2) {
|
|
|
13081
13081
|
}
|
|
13082
13082
|
let K3 = $3.match(/\[(\d+)\]$/);
|
|
13083
13083
|
if (K3) {
|
|
13084
|
-
let
|
|
13085
|
-
for (let j4 = 0;j4 <
|
|
13084
|
+
let q3 = parseInt(K3[1]), X4 = [], M2 = 0;
|
|
13085
|
+
for (let j4 = 0;j4 < q3; j4++) {
|
|
13086
13086
|
let N = e03(Y2, J2, Q4 + M2, G2);
|
|
13087
|
-
|
|
13087
|
+
X4.push(N.value), M2 += N.consumed;
|
|
13088
13088
|
}
|
|
13089
|
-
return { value:
|
|
13089
|
+
return { value: X4, consumed: M2 };
|
|
13090
13090
|
}
|
|
13091
13091
|
throw Error(`Invalid array type: ${$3}`);
|
|
13092
13092
|
}
|
|
@@ -13119,8 +13119,8 @@ function r82($3, J2, Q4) {
|
|
|
13119
13119
|
return { value: "0x" + J2.slice(Y2 + u4, Y2 + u4 + Z3), consumed: u4 };
|
|
13120
13120
|
}
|
|
13121
13121
|
if ($3 === "string") {
|
|
13122
|
-
let Y2 = parseInt(G2, 16) * 2, Z3 = parseInt(J2.slice(Y2, Y2 + u4), 16) * 2, K3 = J2.slice(Y2 + u4, Y2 + u4 + Z3),
|
|
13123
|
-
return { value: new TextDecoder().decode(
|
|
13122
|
+
let Y2 = parseInt(G2, 16) * 2, Z3 = parseInt(J2.slice(Y2, Y2 + u4), 16) * 2, K3 = J2.slice(Y2 + u4, Y2 + u4 + Z3), q3 = new Uint8Array(K3.match(/.{2}/g)?.map((X4) => parseInt(X4, 16)) || []);
|
|
13123
|
+
return { value: new TextDecoder().decode(q3), consumed: u4 };
|
|
13124
13124
|
}
|
|
13125
13125
|
throw Error(`Unsupported type: ${$3}`);
|
|
13126
13126
|
}
|
|
@@ -13133,23 +13133,23 @@ function H$2($3) {
|
|
|
13133
13133
|
return Z3;
|
|
13134
13134
|
if (G2.length !== K3.length)
|
|
13135
13135
|
throw Error(`Expected ${K3.length} arguments, got ${G2.length}`);
|
|
13136
|
-
let
|
|
13136
|
+
let q3 = [], X4 = [], M2 = [];
|
|
13137
13137
|
for (let V2 = 0;V2 < K3.length; V2++) {
|
|
13138
13138
|
let B4 = K3[V2], z2 = B4.components, A3 = u03(B4.type, z2);
|
|
13139
13139
|
if (M2.push(A3), A3)
|
|
13140
|
-
|
|
13140
|
+
q3.push(""), X4.push(C03(B4.type, G2[V2], z2));
|
|
13141
13141
|
else
|
|
13142
|
-
|
|
13142
|
+
q3.push(C03(B4.type, G2[V2], z2));
|
|
13143
13143
|
}
|
|
13144
|
-
if (
|
|
13145
|
-
return Z3 +
|
|
13146
|
-
let j4 =
|
|
13144
|
+
if (X4.length === 0)
|
|
13145
|
+
return Z3 + q3.join("");
|
|
13146
|
+
let j4 = q3.reduce((V2, B4, z2) => V2 + (M2[z2] ? B$2 : B4.length / 2), 0), N = "", D3 = 0;
|
|
13147
13147
|
for (let V2 = 0;V2 < K3.length; V2++)
|
|
13148
13148
|
if (M2[V2])
|
|
13149
|
-
N += K02(j4), j4 +=
|
|
13149
|
+
N += K02(j4), j4 += X4[D3].length / 2, D3++;
|
|
13150
13150
|
else
|
|
13151
|
-
N +=
|
|
13152
|
-
return Z3 + N +
|
|
13151
|
+
N += q3[V2];
|
|
13152
|
+
return Z3 + N + X4.join("");
|
|
13153
13153
|
}
|
|
13154
13154
|
function m$2($3) {
|
|
13155
13155
|
let { abi: J2, functionName: Q4, data: G2 } = $3, Y2 = J2.find((M2) => M2.type === "function" && M2.name === Q4);
|
|
@@ -13161,32 +13161,32 @@ function m$2($3) {
|
|
|
13161
13161
|
let K3 = P$2(G2);
|
|
13162
13162
|
if (Z3.length === 1)
|
|
13163
13163
|
return e03(Z3[0].type, K3, 0, Z3[0].components).value;
|
|
13164
|
-
let
|
|
13164
|
+
let q3 = [], X4 = 0;
|
|
13165
13165
|
for (let M2 of Z3) {
|
|
13166
|
-
let j4 = e03(M2.type, K3,
|
|
13167
|
-
|
|
13166
|
+
let j4 = e03(M2.type, K3, X4, M2.components);
|
|
13167
|
+
q3.push(j4.value), X4 += j4.consumed;
|
|
13168
13168
|
}
|
|
13169
|
-
return
|
|
13169
|
+
return q3;
|
|
13170
13170
|
}
|
|
13171
13171
|
function M03($3, J2) {
|
|
13172
13172
|
if ($3.length !== J2.length)
|
|
13173
13173
|
throw Error(`Type/value length mismatch: ${$3.length} types, ${J2.length} values`);
|
|
13174
13174
|
let Q4 = [], G2 = [], Y2 = [];
|
|
13175
|
-
for (let
|
|
13176
|
-
let M2 = $3[
|
|
13175
|
+
for (let X4 = 0;X4 < $3.length; X4++) {
|
|
13176
|
+
let M2 = $3[X4], j4 = u03(M2);
|
|
13177
13177
|
if (Y2.push(j4), j4)
|
|
13178
|
-
Q4.push(""), G2.push(C03(M2, J2[
|
|
13178
|
+
Q4.push(""), G2.push(C03(M2, J2[X4]));
|
|
13179
13179
|
else
|
|
13180
|
-
Q4.push(C03(M2, J2[
|
|
13180
|
+
Q4.push(C03(M2, J2[X4]));
|
|
13181
13181
|
}
|
|
13182
13182
|
if (G2.length === 0)
|
|
13183
13183
|
return "0x" + Q4.join("");
|
|
13184
|
-
let Z3 = Q4.reduce((
|
|
13185
|
-
for (let
|
|
13186
|
-
if (Y2[
|
|
13187
|
-
K3 += K02(Z3), Z3 += G2[
|
|
13184
|
+
let Z3 = Q4.reduce((X4, M2, j4) => X4 + (Y2[j4] ? B$2 : M2.length / 2), 0), K3 = "", q3 = 0;
|
|
13185
|
+
for (let X4 = 0;X4 < $3.length; X4++)
|
|
13186
|
+
if (Y2[X4])
|
|
13187
|
+
K3 += K02(Z3), Z3 += G2[q3].length / 2, q3++;
|
|
13188
13188
|
else
|
|
13189
|
-
K3 += Q4[
|
|
13189
|
+
K3 += Q4[X4];
|
|
13190
13190
|
return "0x" + K3 + G2.join("");
|
|
13191
13191
|
}
|
|
13192
13192
|
function L3($3) {
|
|
@@ -13241,7 +13241,7 @@ var S$2 = "0x0000000000000000000000000000000000000000";
|
|
|
13241
13241
|
var X03 = BigInt(96) * BigInt(1000000000000000000);
|
|
13242
13242
|
var $$ = BigInt("9999999999999999999999999999999999999");
|
|
13243
13243
|
var u$2 = "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67";
|
|
13244
|
-
var c$2 = "
|
|
13244
|
+
var c$2 = "0x89867a67674bd4bf33165a653cde826b696ab7d050166b71066dfa0b9b6f90f4";
|
|
13245
13245
|
var l$ = "0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee";
|
|
13246
13246
|
|
|
13247
13247
|
class U03 {
|
|
@@ -13323,9 +13323,9 @@ class $03 {
|
|
|
13323
13323
|
else {
|
|
13324
13324
|
let Z3 = [];
|
|
13325
13325
|
for (let K3 = 0;K3 < Q4; K3++) {
|
|
13326
|
-
let
|
|
13327
|
-
if (
|
|
13328
|
-
Z3.push(this.createEqualityPredicate(
|
|
13326
|
+
let q3 = this.cursorColumns[K3], X4 = $3[q3.name];
|
|
13327
|
+
if (X4 !== undefined)
|
|
13328
|
+
Z3.push(this.createEqualityPredicate(q3, X4));
|
|
13329
13329
|
}
|
|
13330
13330
|
Z3.push(this.createComparisonPredicate(G2, Y2)), J2.push({ Type: "Conjunction", ConjunctionType: "And", Predicates: Z3 });
|
|
13331
13331
|
}
|
|
@@ -13406,22 +13406,22 @@ class x03 {
|
|
|
13406
13406
|
break;
|
|
13407
13407
|
let Y2 = {};
|
|
13408
13408
|
G2.forEach((K3) => {
|
|
13409
|
-
let
|
|
13409
|
+
let q3 = L3(K3.truster), X4 = L3(K3.trustee), M2 = q3 !== J2 ? K3.truster : K3.trustee;
|
|
13410
13410
|
if (!Y2[M2])
|
|
13411
13411
|
Y2[M2] = [];
|
|
13412
13412
|
Y2[M2].push(K3);
|
|
13413
13413
|
});
|
|
13414
|
-
let Z3 = Object.entries(Y2).filter(([K3]) => L3(K3) !== J2).map(([K3,
|
|
13415
|
-
let
|
|
13416
|
-
if (
|
|
13414
|
+
let Z3 = Object.entries(Y2).filter(([K3]) => L3(K3) !== J2).map(([K3, q3]) => {
|
|
13415
|
+
let X4 = Math.max(...q3.map((j4) => j4.timestamp)), M2;
|
|
13416
|
+
if (q3.length === 2)
|
|
13417
13417
|
M2 = "mutuallyTrusts";
|
|
13418
|
-
else if (L3(
|
|
13418
|
+
else if (L3(q3[0]?.trustee) === J2)
|
|
13419
13419
|
M2 = "trustedBy";
|
|
13420
|
-
else if (L3(
|
|
13420
|
+
else if (L3(q3[0]?.truster) === J2)
|
|
13421
13421
|
M2 = "trusts";
|
|
13422
13422
|
else
|
|
13423
13423
|
throw Error("Unexpected trust list row. Couldn't determine trust relation.");
|
|
13424
|
-
return { subjectAvatar: J2, relation: M2, objectAvatar: K3, timestamp:
|
|
13424
|
+
return { subjectAvatar: J2, relation: M2, objectAvatar: K3, timestamp: X4 };
|
|
13425
13425
|
});
|
|
13426
13426
|
return f2(Z3);
|
|
13427
13427
|
}
|
|
@@ -13543,8 +13543,8 @@ class d4 {
|
|
|
13543
13543
|
return this.v1ToDemurrage($3, Z3, K3, Y2, this.PERIOD_SEC);
|
|
13544
13544
|
}
|
|
13545
13545
|
static attoCirclesToAttoCrc($3, J2) {
|
|
13546
|
-
let Q4 = J2 - this.INFLATION_DAY_ZERO_UNIX, G2 = Q4 / this.PERIOD_SEC, Y2 = Q4 % this.PERIOD_SEC, Z3 = this.v1InflateFactor(G2), K3 = this.v1InflateFactor(G2 + 1n),
|
|
13547
|
-
return $3 * 3n * this.V1_ACCURACY * this.PERIOD_SEC /
|
|
13546
|
+
let Q4 = J2 - this.INFLATION_DAY_ZERO_UNIX, G2 = Q4 / this.PERIOD_SEC, Y2 = Q4 % this.PERIOD_SEC, Z3 = this.v1InflateFactor(G2), K3 = this.v1InflateFactor(G2 + 1n), q3 = Z3 * (this.PERIOD_SEC - Y2) + K3 * Y2;
|
|
13547
|
+
return $3 * 3n * this.V1_ACCURACY * this.PERIOD_SEC / q3;
|
|
13548
13548
|
}
|
|
13549
13549
|
static v1ToDemurrage($3, J2, Q4, G2, Y2) {
|
|
13550
13550
|
let Z3 = J2 * (Y2 - G2) + Q4 * G2;
|
|
@@ -13614,9 +13614,9 @@ class G$ {
|
|
|
13614
13614
|
try {
|
|
13615
13615
|
let K3 = await this.getProfileByAddress($3);
|
|
13616
13616
|
if (K3) {
|
|
13617
|
-
let
|
|
13618
|
-
if (!G2 || !
|
|
13619
|
-
Y2.push(
|
|
13617
|
+
let q3 = { ...K3, address: $3 };
|
|
13618
|
+
if (!G2 || !q3.avatarType || G2.includes(q3.avatarType))
|
|
13619
|
+
Y2.push(q3);
|
|
13620
13620
|
}
|
|
13621
13621
|
} catch (K3) {
|
|
13622
13622
|
console.warn("Failed to get profile by address:", K3);
|
|
@@ -13624,8 +13624,8 @@ class G$ {
|
|
|
13624
13624
|
try {
|
|
13625
13625
|
let K3 = await this.searchProfiles($3, J2, Q4, G2);
|
|
13626
13626
|
if (Z3 && Y2.length > 0) {
|
|
13627
|
-
let
|
|
13628
|
-
Y2.push(...
|
|
13627
|
+
let q3 = $3.toLowerCase(), X4 = K3.filter((M2) => M2.address?.toLowerCase() !== q3);
|
|
13628
|
+
Y2.push(...X4);
|
|
13629
13629
|
} else
|
|
13630
13630
|
Y2.push(...K3);
|
|
13631
13631
|
} catch (K3) {
|
|
@@ -13680,11 +13680,11 @@ class Z$ {
|
|
|
13680
13680
|
let J2 = L3($3), Q4 = 96, G2 = await this.client.call("circles_getAvatarInfoBatch", [[J2]]);
|
|
13681
13681
|
if ((G2.length > 0 ? G2[0] : undefined)?.version === 2)
|
|
13682
13682
|
return [];
|
|
13683
|
-
let Z3 = await this.client.call("circles_query", [{ Namespace: "V_Crc", Table: "TrustRelations", Columns: ["truster", "trustee"], Filter: [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "trustee", Value: J2 }] }], Order: [] }]),
|
|
13684
|
-
if (
|
|
13683
|
+
let Z3 = await this.client.call("circles_query", [{ Namespace: "V_Crc", Table: "TrustRelations", Columns: ["truster", "trustee"], Filter: [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "trustee", Value: J2 }] }], Order: [] }]), q3 = this.transformQueryResponse(Z3).map((j4) => j4.truster);
|
|
13684
|
+
if (q3.length === 0)
|
|
13685
13685
|
return [];
|
|
13686
|
-
let
|
|
13687
|
-
for (let j4 of
|
|
13686
|
+
let X4 = await this.client.call("circles_getAvatarInfoBatch", [q3]), M2 = [];
|
|
13687
|
+
for (let j4 of X4) {
|
|
13688
13688
|
if (!j4?.isHuman)
|
|
13689
13689
|
continue;
|
|
13690
13690
|
let D3 = (await this.client.call("circles_getTokenBalances", [j4.avatar])).find((V2) => L3(V2.tokenAddress) === L3(j4.avatar));
|
|
@@ -13702,14 +13702,14 @@ class Z$ {
|
|
|
13702
13702
|
let G2 = await this.client.call("circles_query", [{ Namespace: "V_Crc", Table: "TrustRelations", Columns: ["trustee", "truster"], Filter: [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "truster", Value: Q4 }] }], Order: [] }]), Z3 = this.transformQueryResponse(G2).map((M2) => M2.trustee);
|
|
13703
13703
|
if (Z3.length === 0)
|
|
13704
13704
|
return [];
|
|
13705
|
-
let K3 = await this.client.call("circles_getAvatarInfoBatch", [Z3]),
|
|
13706
|
-
return f2(
|
|
13705
|
+
let K3 = await this.client.call("circles_getAvatarInfoBatch", [Z3]), q3 = new Set(K3.filter((M2) => M2 !== null).map((M2) => L3(M2.avatar))), X4 = Z3.filter((M2) => !q3.has(L3(M2)));
|
|
13706
|
+
return f2(X4);
|
|
13707
13707
|
}
|
|
13708
13708
|
}
|
|
13709
13709
|
}
|
|
13710
13710
|
function QQ($3, J2) {
|
|
13711
|
-
let Q4 = BigInt($3), G2 = d4.attoCirclesToCircles(Q4), Y2 = d4.attoCirclesToAttoCrc(Q4, BigInt(J2)), Z3 = d4.attoCirclesToCircles(Y2), K3 = d4.attoCirclesToAttoStaticCircles(Q4, BigInt(J2)),
|
|
13712
|
-
return { attoCircles: Q4, circles: G2, staticAttoCircles: K3, staticCircles:
|
|
13711
|
+
let Q4 = BigInt($3), G2 = d4.attoCirclesToCircles(Q4), Y2 = d4.attoCirclesToAttoCrc(Q4, BigInt(J2)), Z3 = d4.attoCirclesToCircles(Y2), K3 = d4.attoCirclesToAttoStaticCircles(Q4, BigInt(J2)), q3 = d4.attoCirclesToCircles(K3);
|
|
13712
|
+
return { attoCircles: Q4, circles: G2, staticAttoCircles: K3, staticCircles: q3, attoCrc: Y2, crc: Z3 };
|
|
13713
13713
|
}
|
|
13714
13714
|
|
|
13715
13715
|
class K$2 {
|
|
@@ -13720,8 +13720,8 @@ class K$2 {
|
|
|
13720
13720
|
getTransactionHistory($3, J2 = 50, Q4 = "DESC") {
|
|
13721
13721
|
let G2 = L3($3), Y2 = [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "Conjunction", ConjunctionType: "Or", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "from", Value: G2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "to", Value: G2 }] }] }];
|
|
13722
13722
|
return new $03(this.client, { namespace: "V_Crc", table: "TransferSummary", sortOrder: Q4, columns: [], filter: Y2, limit: J2 }, (Z3) => {
|
|
13723
|
-
let K3 = QQ(Z3.value, Z3.timestamp),
|
|
13724
|
-
return f2(
|
|
13723
|
+
let K3 = QQ(Z3.value, Z3.timestamp), q3 = { ...Z3, ...K3 };
|
|
13724
|
+
return f2(q3);
|
|
13725
13725
|
});
|
|
13726
13726
|
}
|
|
13727
13727
|
}
|
|
@@ -14015,8 +14015,8 @@ Context: ${JSON.stringify(this.context, null, 2)}`;
|
|
|
14015
14015
|
function GQ2($3, J2, Q4, G2) {
|
|
14016
14016
|
if (typeof $3.setBigUint64 === "function")
|
|
14017
14017
|
return $3.setBigUint64(J2, Q4, G2);
|
|
14018
|
-
let Y2 = BigInt(32), Z3 = BigInt(4294967295), K3 = Number(Q4 >> Y2 & Z3),
|
|
14019
|
-
$3.setUint32(J2 +
|
|
14018
|
+
let Y2 = BigInt(32), Z3 = BigInt(4294967295), K3 = Number(Q4 >> Y2 & Z3), q3 = Number(Q4 & Z3), X4 = G2 ? 4 : 0, M2 = G2 ? 0 : 4;
|
|
14019
|
+
$3.setUint32(J2 + X4, K3, G2), $3.setUint32(J2 + M2, q3, G2);
|
|
14020
14020
|
}
|
|
14021
14021
|
function oJ2($3, J2, Q4) {
|
|
14022
14022
|
return $3 & J2 ^ ~$3 & Q4;
|
|
@@ -14036,9 +14036,9 @@ class n$2 extends E03 {
|
|
|
14036
14036
|
for (let Z3 = 0;Z3 < Y2; ) {
|
|
14037
14037
|
let K3 = Math.min(G2 - this.pos, Y2 - Z3);
|
|
14038
14038
|
if (K3 === G2) {
|
|
14039
|
-
let
|
|
14039
|
+
let q3 = O$2($3);
|
|
14040
14040
|
for (;G2 <= Y2 - Z3; Z3 += G2)
|
|
14041
|
-
this.process(
|
|
14041
|
+
this.process(q3, Z3);
|
|
14042
14042
|
continue;
|
|
14043
14043
|
}
|
|
14044
14044
|
if (Q4.set($3.subarray(Z3, Z3 + K3), this.pos), this.pos += K3, Z3 += K3, this.pos === G2)
|
|
@@ -14054,13 +14054,13 @@ class n$2 extends E03 {
|
|
|
14054
14054
|
for (let j4 = Z3;j4 < G2; j4++)
|
|
14055
14055
|
J2[j4] = 0;
|
|
14056
14056
|
GQ2(Q4, G2 - 8, BigInt(this.length * 8), Y2), this.process(Q4, 0);
|
|
14057
|
-
let K3 = O$2($3),
|
|
14058
|
-
if (
|
|
14057
|
+
let K3 = O$2($3), q3 = this.outputLen;
|
|
14058
|
+
if (q3 % 4)
|
|
14059
14059
|
throw Error("_sha2: outputLen should be aligned to 32bit");
|
|
14060
|
-
let
|
|
14061
|
-
if (
|
|
14060
|
+
let X4 = q3 / 4, M2 = this.get();
|
|
14061
|
+
if (X4 > M2.length)
|
|
14062
14062
|
throw Error("_sha2: outputLen bigger than state");
|
|
14063
|
-
for (let j4 = 0;j4 <
|
|
14063
|
+
for (let j4 = 0;j4 < X4; j4++)
|
|
14064
14064
|
K3.setUint32(4 * j4, M2[j4], Y2);
|
|
14065
14065
|
}
|
|
14066
14066
|
digest() {
|
|
@@ -14090,11 +14090,11 @@ class aJ extends n$2 {
|
|
|
14090
14090
|
this.A = W03[0] | 0, this.B = W03[1] | 0, this.C = W03[2] | 0, this.D = W03[3] | 0, this.E = W03[4] | 0, this.F = W03[5] | 0, this.G = W03[6] | 0, this.H = W03[7] | 0;
|
|
14091
14091
|
}
|
|
14092
14092
|
get() {
|
|
14093
|
-
let { A: $3, B: J2, C: Q4, D: G2, E: Y2, F: Z3, G: K3, H:
|
|
14094
|
-
return [$3, J2, Q4, G2, Y2, Z3, K3,
|
|
14093
|
+
let { A: $3, B: J2, C: Q4, D: G2, E: Y2, F: Z3, G: K3, H: q3 } = this;
|
|
14094
|
+
return [$3, J2, Q4, G2, Y2, Z3, K3, q3];
|
|
14095
14095
|
}
|
|
14096
|
-
set($3, J2, Q4, G2, Y2, Z3, K3,
|
|
14097
|
-
this.A = $3 | 0, this.B = J2 | 0, this.C = Q4 | 0, this.D = G2 | 0, this.E = Y2 | 0, this.F = Z3 | 0, this.G = K3 | 0, this.H =
|
|
14096
|
+
set($3, J2, Q4, G2, Y2, Z3, K3, q3) {
|
|
14097
|
+
this.A = $3 | 0, this.B = J2 | 0, this.C = Q4 | 0, this.D = G2 | 0, this.E = Y2 | 0, this.F = Z3 | 0, this.G = K3 | 0, this.H = q3 | 0;
|
|
14098
14098
|
}
|
|
14099
14099
|
process($3, J2) {
|
|
14100
14100
|
for (let j4 = 0;j4 < 16; j4++, J2 += 4)
|
|
@@ -14103,12 +14103,12 @@ class aJ extends n$2 {
|
|
|
14103
14103
|
let N = B0[j4 - 15], D3 = B0[j4 - 2], V2 = G03(N, 7) ^ G03(N, 18) ^ N >>> 3, B4 = G03(D3, 17) ^ G03(D3, 19) ^ D3 >>> 10;
|
|
14104
14104
|
B0[j4] = B4 + B0[j4 - 7] + V2 + B0[j4 - 16] | 0;
|
|
14105
14105
|
}
|
|
14106
|
-
let { A: Q4, B: G2, C: Y2, D: Z3, E: K3, F:
|
|
14106
|
+
let { A: Q4, B: G2, C: Y2, D: Z3, E: K3, F: q3, G: X4, H: M2 } = this;
|
|
14107
14107
|
for (let j4 = 0;j4 < 64; j4++) {
|
|
14108
|
-
let N = G03(K3, 6) ^ G03(K3, 11) ^ G03(K3, 25), D3 = M2 + N + oJ2(K3,
|
|
14109
|
-
M2 =
|
|
14108
|
+
let N = G03(K3, 6) ^ G03(K3, 11) ^ G03(K3, 25), D3 = M2 + N + oJ2(K3, q3, X4) + YQ2[j4] + B0[j4] | 0, B4 = (G03(Q4, 2) ^ G03(Q4, 13) ^ G03(Q4, 22)) + tJ2(Q4, G2, Y2) | 0;
|
|
14109
|
+
M2 = X4, X4 = q3, q3 = K3, K3 = Z3 + D3 | 0, Z3 = Y2, Y2 = G2, G2 = Q4, Q4 = D3 + B4 | 0;
|
|
14110
14110
|
}
|
|
14111
|
-
Q4 = Q4 + this.A | 0, G2 = G2 + this.B | 0, Y2 = Y2 + this.C | 0, Z3 = Z3 + this.D | 0, K3 = K3 + this.E | 0,
|
|
14111
|
+
Q4 = Q4 + this.A | 0, G2 = G2 + this.B | 0, Y2 = Y2 + this.C | 0, Z3 = Z3 + this.D | 0, K3 = K3 + this.E | 0, q3 = q3 + this.F | 0, X4 = X4 + this.G | 0, M2 = M2 + this.H | 0, this.set(Q4, G2, Y2, Z3, K3, q3, X4, M2);
|
|
14112
14112
|
}
|
|
14113
14113
|
roundClean() {
|
|
14114
14114
|
Z03(B0);
|
|
@@ -14213,12 +14213,12 @@ function q$($3) {
|
|
|
14213
14213
|
throw Error("hex string expected, got unpadded hex of length " + J2);
|
|
14214
14214
|
let G2 = new Uint8Array(Q4);
|
|
14215
14215
|
for (let Y2 = 0, Z3 = 0;Y2 < Q4; Y2++, Z3 += 2) {
|
|
14216
|
-
let K3 = rJ2($3.charCodeAt(Z3)),
|
|
14217
|
-
if (K3 === undefined ||
|
|
14218
|
-
let
|
|
14219
|
-
throw Error('hex string expected, got non-hex character "' +
|
|
14216
|
+
let K3 = rJ2($3.charCodeAt(Z3)), q3 = rJ2($3.charCodeAt(Z3 + 1));
|
|
14217
|
+
if (K3 === undefined || q3 === undefined) {
|
|
14218
|
+
let X4 = $3[Z3] + $3[Z3 + 1];
|
|
14219
|
+
throw Error('hex string expected, got non-hex character "' + X4 + '" at index ' + Z3);
|
|
14220
14220
|
}
|
|
14221
|
-
G2[Y2] = K3 * 16 +
|
|
14221
|
+
G2[Y2] = K3 * 16 + q3;
|
|
14222
14222
|
}
|
|
14223
14223
|
return G2;
|
|
14224
14224
|
}
|
|
@@ -14290,40 +14290,40 @@ function G82($3, J2, Q4) {
|
|
|
14290
14290
|
throw Error("hmacFn must be a function");
|
|
14291
14291
|
let G2 = s$2($3), Y2 = s$2($3), Z3 = 0, K3 = () => {
|
|
14292
14292
|
G2.fill(1), Y2.fill(0), Z3 = 0;
|
|
14293
|
-
},
|
|
14294
|
-
if (Y2 =
|
|
14293
|
+
}, q3 = (...N) => Q4(Y2, G2, ...N), X4 = (N = s$2(0)) => {
|
|
14294
|
+
if (Y2 = q3(eJ2([0]), N), G2 = q3(), N.length === 0)
|
|
14295
14295
|
return;
|
|
14296
|
-
Y2 =
|
|
14296
|
+
Y2 = q3(eJ2([1]), N), G2 = q3();
|
|
14297
14297
|
}, M2 = () => {
|
|
14298
14298
|
if (Z3++ >= 1000)
|
|
14299
14299
|
throw Error("drbg: tried 1000 values");
|
|
14300
14300
|
let N = 0, D3 = [];
|
|
14301
14301
|
while (N < J2) {
|
|
14302
|
-
G2 =
|
|
14302
|
+
G2 = q3();
|
|
14303
14303
|
let V2 = G2.slice();
|
|
14304
14304
|
D3.push(V2), N += G2.length;
|
|
14305
14305
|
}
|
|
14306
14306
|
return M$(...D3);
|
|
14307
14307
|
};
|
|
14308
14308
|
return (N, D3) => {
|
|
14309
|
-
K3(),
|
|
14309
|
+
K3(), X4(N);
|
|
14310
14310
|
let V2 = undefined;
|
|
14311
14311
|
while (!(V2 = D3(M2())))
|
|
14312
|
-
|
|
14312
|
+
X4();
|
|
14313
14313
|
return K3(), V2;
|
|
14314
14314
|
};
|
|
14315
14315
|
}
|
|
14316
14316
|
var KQ2 = { bigint: ($3) => typeof $3 === "bigint", function: ($3) => typeof $3 === "function", boolean: ($3) => typeof $3 === "boolean", string: ($3) => typeof $3 === "string", stringOrUint8Array: ($3) => typeof $3 === "string" || d03($3), isSafeInteger: ($3) => Number.isSafeInteger($3), array: ($3) => Array.isArray($3), field: ($3, J2) => J2.Fp.isValid($3), hash: ($3) => typeof $3 === "function" && Number.isSafeInteger($3.outputLen) };
|
|
14317
14317
|
function b03($3, J2, Q4 = {}) {
|
|
14318
14318
|
let G2 = (Y2, Z3, K3) => {
|
|
14319
|
-
let
|
|
14320
|
-
if (typeof
|
|
14319
|
+
let q3 = KQ2[Z3];
|
|
14320
|
+
if (typeof q3 !== "function")
|
|
14321
14321
|
throw Error("invalid validator function");
|
|
14322
|
-
let
|
|
14323
|
-
if (K3 &&
|
|
14322
|
+
let X4 = $3[Y2];
|
|
14323
|
+
if (K3 && X4 === undefined)
|
|
14324
14324
|
return;
|
|
14325
|
-
if (!X4
|
|
14326
|
-
throw Error("param " + String(Y2) + " is invalid. Expected " + Z3 + ", got " +
|
|
14325
|
+
if (!q3(X4, $3))
|
|
14326
|
+
throw Error("param " + String(Y2) + " is invalid. Expected " + Z3 + ", got " + X4);
|
|
14327
14327
|
};
|
|
14328
14328
|
for (let [Y2, Z3] of Object.entries(J2))
|
|
14329
14329
|
G2(Y2, Z3, false);
|
|
@@ -14364,10 +14364,10 @@ function A$2($3, J2) {
|
|
|
14364
14364
|
throw Error("invert: expected non-zero number");
|
|
14365
14365
|
if (J2 <= a4)
|
|
14366
14366
|
throw Error("invert: expected positive modulus, got " + J2);
|
|
14367
|
-
let Q4 = i4($3, J2), G2 = J2, Y2 = a4, Z3 = n4, K3 = n4,
|
|
14367
|
+
let Q4 = i4($3, J2), G2 = J2, Y2 = a4, Z3 = n4, K3 = n4, q3 = a4;
|
|
14368
14368
|
while (Q4 !== a4) {
|
|
14369
|
-
let M2 = G2 / Q4, j4 = G2 % Q4, N = Y2 - K3 * M2, D3 = Z3 -
|
|
14370
|
-
G2 = Q4, Q4 = j4, Y2 = K3, Z3 =
|
|
14369
|
+
let M2 = G2 / Q4, j4 = G2 % Q4, N = Y2 - K3 * M2, D3 = Z3 - q3 * M2;
|
|
14370
|
+
G2 = Q4, Q4 = j4, Y2 = K3, Z3 = q3, K3 = N, q3 = D3;
|
|
14371
14371
|
}
|
|
14372
14372
|
if (G2 !== n4)
|
|
14373
14373
|
throw Error("invert: does not exist");
|
|
@@ -14380,10 +14380,10 @@ function q82($3, J2) {
|
|
|
14380
14380
|
return G2;
|
|
14381
14381
|
}
|
|
14382
14382
|
function qQ2($3, J2) {
|
|
14383
|
-
let Q4 = ($3.ORDER - K82) / X82, G2 = $3.mul(J2, f03), Y2 = $3.pow(G2, Q4), Z3 = $3.mul(J2, Y2), K3 = $3.mul($3.mul(Z3, f03), Y2),
|
|
14384
|
-
if (!$3.eql($3.sqr(
|
|
14383
|
+
let Q4 = ($3.ORDER - K82) / X82, G2 = $3.mul(J2, f03), Y2 = $3.pow(G2, Q4), Z3 = $3.mul(J2, Y2), K3 = $3.mul($3.mul(Z3, f03), Y2), q3 = $3.mul(Z3, $3.sub(K3, $3.ONE));
|
|
14384
|
+
if (!$3.eql($3.sqr(q3), J2))
|
|
14385
14385
|
throw Error("Cannot find square root");
|
|
14386
|
-
return
|
|
14386
|
+
return q3;
|
|
14387
14387
|
}
|
|
14388
14388
|
function MQ($3) {
|
|
14389
14389
|
if ($3 < BigInt(3))
|
|
@@ -14398,21 +14398,21 @@ function MQ($3) {
|
|
|
14398
14398
|
if (Q4 === 1)
|
|
14399
14399
|
return q82;
|
|
14400
14400
|
let Z3 = Y2.pow(G2, J2), K3 = (J2 + n4) / f03;
|
|
14401
|
-
return function(
|
|
14402
|
-
if (
|
|
14401
|
+
return function(X4, M2) {
|
|
14402
|
+
if (X4.is0(M2))
|
|
14403
14403
|
return M2;
|
|
14404
|
-
if (Y8(
|
|
14404
|
+
if (Y8(X4, M2) !== 1)
|
|
14405
14405
|
throw Error("Cannot find square root");
|
|
14406
|
-
let j4 = Q4, N =
|
|
14407
|
-
while (!
|
|
14408
|
-
if (
|
|
14409
|
-
return
|
|
14410
|
-
let B4 = 1, z2 =
|
|
14411
|
-
while (!
|
|
14412
|
-
if (B4++, z2 =
|
|
14406
|
+
let j4 = Q4, N = X4.mul(X4.ONE, Z3), D3 = X4.pow(M2, J2), V2 = X4.pow(M2, K3);
|
|
14407
|
+
while (!X4.eql(D3, X4.ONE)) {
|
|
14408
|
+
if (X4.is0(D3))
|
|
14409
|
+
return X4.ZERO;
|
|
14410
|
+
let B4 = 1, z2 = X4.sqr(D3);
|
|
14411
|
+
while (!X4.eql(z2, X4.ONE))
|
|
14412
|
+
if (B4++, z2 = X4.sqr(z2), B4 === j4)
|
|
14413
14413
|
throw Error("Cannot find square root");
|
|
14414
|
-
let A3 = n4 << BigInt(j4 - B4 - 1), H4 =
|
|
14415
|
-
j4 = B4, N =
|
|
14414
|
+
let A3 = n4 << BigInt(j4 - B4 - 1), H4 = X4.pow(N, A3);
|
|
14415
|
+
j4 = B4, N = X4.sqr(H4), D3 = X4.mul(D3, N), V2 = X4.mul(V2, H4);
|
|
14416
14416
|
}
|
|
14417
14417
|
return V2;
|
|
14418
14418
|
};
|
|
@@ -14447,15 +14447,15 @@ function WQ2($3, J2, Q4) {
|
|
|
14447
14447
|
return G2;
|
|
14448
14448
|
}
|
|
14449
14449
|
function ZJ3($3, J2, Q4 = false) {
|
|
14450
|
-
let G2 = Array(J2.length).fill(Q4 ? $3.ZERO : undefined), Y2 = J2.reduce((K3,
|
|
14451
|
-
if ($3.is0(
|
|
14450
|
+
let G2 = Array(J2.length).fill(Q4 ? $3.ZERO : undefined), Y2 = J2.reduce((K3, q3, X4) => {
|
|
14451
|
+
if ($3.is0(q3))
|
|
14452
14452
|
return K3;
|
|
14453
|
-
return G2[
|
|
14453
|
+
return G2[X4] = K3, $3.mul(K3, q3);
|
|
14454
14454
|
}, $3.ONE), Z3 = $3.inv(Y2);
|
|
14455
|
-
return J2.reduceRight((K3,
|
|
14456
|
-
if ($3.is0(
|
|
14455
|
+
return J2.reduceRight((K3, q3, X4) => {
|
|
14456
|
+
if ($3.is0(q3))
|
|
14457
14457
|
return K3;
|
|
14458
|
-
return G2[
|
|
14458
|
+
return G2[X4] = $3.mul(K3, G2[X4]), $3.mul(K3, q3);
|
|
14459
14459
|
}, Z3), G2;
|
|
14460
14460
|
}
|
|
14461
14461
|
function Y8($3, J2) {
|
|
@@ -14476,20 +14476,20 @@ function j$2($3, J2, Q4 = false, G2 = {}) {
|
|
|
14476
14476
|
let { nBitLength: Y2, nByteLength: Z3 } = KJ3($3, J2);
|
|
14477
14477
|
if (Z3 > 2048)
|
|
14478
14478
|
throw Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
14479
|
-
let K3,
|
|
14480
|
-
if (typeof
|
|
14481
|
-
throw Error("invalid field element: expected bigint, got " + typeof
|
|
14482
|
-
return a4 <=
|
|
14483
|
-
}, is0: (
|
|
14479
|
+
let K3, q3 = Object.freeze({ ORDER: $3, isLE: Q4, BITS: Y2, BYTES: Z3, MASK: F03(Y2), ZERO: a4, ONE: n4, create: (X4) => i4(X4, $3), isValid: (X4) => {
|
|
14480
|
+
if (typeof X4 !== "bigint")
|
|
14481
|
+
throw Error("invalid field element: expected bigint, got " + typeof X4);
|
|
14482
|
+
return a4 <= X4 && X4 < $3;
|
|
14483
|
+
}, is0: (X4) => X4 === a4, isOdd: (X4) => (X4 & n4) === n4, neg: (X4) => i4(-X4, $3), eql: (X4, M2) => X4 === M2, sqr: (X4) => i4(X4 * X4, $3), add: (X4, M2) => i4(X4 + M2, $3), sub: (X4, M2) => i4(X4 - M2, $3), mul: (X4, M2) => i4(X4 * M2, $3), pow: (X4, M2) => WQ2(q3, X4, M2), div: (X4, M2) => i4(X4 * A$2(M2, $3), $3), sqrN: (X4) => X4 * X4, addN: (X4, M2) => X4 + M2, subN: (X4, M2) => X4 - M2, mulN: (X4, M2) => X4 * M2, inv: (X4) => A$2(X4, $3), sqrt: G2.sqrt || ((X4) => {
|
|
14484
14484
|
if (!K3)
|
|
14485
14485
|
K3 = jQ($3);
|
|
14486
|
-
return K3(
|
|
14487
|
-
}), toBytes: (
|
|
14488
|
-
if (
|
|
14489
|
-
throw Error("Field.fromBytes: expected " + Z3 + " bytes, got " +
|
|
14490
|
-
return Q4 ? JJ2(
|
|
14491
|
-
}, invertBatch: (
|
|
14492
|
-
return Object.freeze(
|
|
14486
|
+
return K3(q3, X4);
|
|
14487
|
+
}), toBytes: (X4) => Q4 ? QJ3(X4, Z3) : w03(X4, Z3), fromBytes: (X4) => {
|
|
14488
|
+
if (X4.length !== Z3)
|
|
14489
|
+
throw Error("Field.fromBytes: expected " + Z3 + " bytes, got " + X4.length);
|
|
14490
|
+
return Q4 ? JJ2(X4) : z02(X4);
|
|
14491
|
+
}, invertBatch: (X4) => ZJ3(q3, X4), cmov: (X4, M2, j4) => j4 ? M2 : X4 });
|
|
14492
|
+
return Object.freeze(q3);
|
|
14493
14493
|
}
|
|
14494
14494
|
function M82($3) {
|
|
14495
14495
|
if (typeof $3 !== "bigint")
|
|
@@ -14505,8 +14505,8 @@ function j82($3, J2, Q4 = false) {
|
|
|
14505
14505
|
let G2 = $3.length, Y2 = M82(J2), Z3 = XJ3(J2);
|
|
14506
14506
|
if (G2 < 16 || G2 < Z3 || G2 > 1024)
|
|
14507
14507
|
throw Error("expected " + Z3 + "-1024 bytes of input, got " + G2);
|
|
14508
|
-
let K3 = Q4 ? JJ2($3) : z02($3),
|
|
14509
|
-
return Q4 ? QJ3(
|
|
14508
|
+
let K3 = Q4 ? JJ2($3) : z02($3), q3 = i4(K3, J2 - n4) + n4;
|
|
14509
|
+
return Q4 ? QJ3(q3, Y2) : w03(q3, Y2);
|
|
14510
14510
|
}
|
|
14511
14511
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14512
14512
|
var U82 = BigInt(0);
|
|
@@ -14525,11 +14525,11 @@ function MJ2($3, J2) {
|
|
|
14525
14525
|
return { windows: Q4, windowSize: G2, mask: Z3, maxNumber: Y2, shiftBy: K3 };
|
|
14526
14526
|
}
|
|
14527
14527
|
function W82($3, J2, Q4) {
|
|
14528
|
-
let { windowSize: G2, mask: Y2, maxNumber: Z3, shiftBy: K3 } = Q4,
|
|
14529
|
-
if (
|
|
14530
|
-
|
|
14531
|
-
let M2 = J2 * G2, j4 = M2 + Math.abs(
|
|
14532
|
-
return { nextN:
|
|
14528
|
+
let { windowSize: G2, mask: Y2, maxNumber: Z3, shiftBy: K3 } = Q4, q3 = Number($3 & Y2), X4 = $3 >> K3;
|
|
14529
|
+
if (q3 > G2)
|
|
14530
|
+
q3 -= Z3, X4 += WJ2;
|
|
14531
|
+
let M2 = J2 * G2, j4 = M2 + Math.abs(q3) - 1, N = q3 === 0, D3 = q3 < 0, V2 = J2 % 2 !== 0;
|
|
14532
|
+
return { nextN: X4, offset: j4, isZero: N, isNeg: D3, isNegF: V2, offsetF: M2 };
|
|
14533
14533
|
}
|
|
14534
14534
|
function NQ2($3, J2) {
|
|
14535
14535
|
if (!Array.isArray($3))
|
|
@@ -14564,18 +14564,18 @@ function D82($3, J2) {
|
|
|
14564
14564
|
}
|
|
14565
14565
|
return Y2;
|
|
14566
14566
|
}, precomputeWindow(Q4, G2) {
|
|
14567
|
-
let { windows: Y2, windowSize: Z3 } = MJ2(G2, J2), K3 = [],
|
|
14567
|
+
let { windows: Y2, windowSize: Z3 } = MJ2(G2, J2), K3 = [], q3 = Q4, X4 = q3;
|
|
14568
14568
|
for (let M2 = 0;M2 < Y2; M2++) {
|
|
14569
|
-
|
|
14569
|
+
X4 = q3, K3.push(X4);
|
|
14570
14570
|
for (let j4 = 1;j4 < Z3; j4++)
|
|
14571
|
-
|
|
14572
|
-
|
|
14571
|
+
X4 = X4.add(q3), K3.push(X4);
|
|
14572
|
+
q3 = X4.double();
|
|
14573
14573
|
}
|
|
14574
14574
|
return K3;
|
|
14575
14575
|
}, wNAF(Q4, G2, Y2) {
|
|
14576
|
-
let { ZERO: Z3, BASE: K3 } = $3,
|
|
14577
|
-
for (let
|
|
14578
|
-
let { nextN: M2, offset: j4, isZero: N, isNeg: D3, isNegF: V2, offsetF: B4 } = W82(Y2,
|
|
14576
|
+
let { ZERO: Z3, BASE: K3 } = $3, q3 = MJ2(Q4, J2);
|
|
14577
|
+
for (let X4 = 0;X4 < q3.windows; X4++) {
|
|
14578
|
+
let { nextN: M2, offset: j4, isZero: N, isNeg: D3, isNegF: V2, offsetF: B4 } = W82(Y2, X4, q3);
|
|
14579
14579
|
if (Y2 = M2, N)
|
|
14580
14580
|
K3 = K3.add(qJ3(V2, G2[B4]));
|
|
14581
14581
|
else
|
|
@@ -14584,11 +14584,11 @@ function D82($3, J2) {
|
|
|
14584
14584
|
return { p: Z3, f: K3 };
|
|
14585
14585
|
}, wNAFUnsafe(Q4, G2, Y2, Z3 = $3.ZERO) {
|
|
14586
14586
|
let K3 = MJ2(Q4, J2);
|
|
14587
|
-
for (let
|
|
14587
|
+
for (let q3 = 0;q3 < K3.windows; q3++) {
|
|
14588
14588
|
if (Y2 === U82)
|
|
14589
14589
|
break;
|
|
14590
|
-
let { nextN:
|
|
14591
|
-
if (Y2 =
|
|
14590
|
+
let { nextN: X4, offset: M2, isZero: j4, isNeg: N } = W82(Y2, q3, K3);
|
|
14591
|
+
if (Y2 = X4, j4)
|
|
14592
14592
|
continue;
|
|
14593
14593
|
else {
|
|
14594
14594
|
let D3 = G2[M2];
|
|
@@ -14620,15 +14620,15 @@ function V82($3, J2, Q4, G2) {
|
|
|
14620
14620
|
let Y2 = Q4.length, Z3 = G2.length;
|
|
14621
14621
|
if (Y2 !== Z3)
|
|
14622
14622
|
throw Error("arrays of points and scalars must have equal length");
|
|
14623
|
-
let K3 = $3.ZERO,
|
|
14624
|
-
if (
|
|
14625
|
-
|
|
14626
|
-
else if (
|
|
14627
|
-
|
|
14628
|
-
else if (
|
|
14629
|
-
|
|
14630
|
-
let M2 = F03(
|
|
14631
|
-
for (let V2 = N;V2 >= 0; V2 -=
|
|
14623
|
+
let K3 = $3.ZERO, q3 = Q82(BigInt(Y2)), X4 = 1;
|
|
14624
|
+
if (q3 > 12)
|
|
14625
|
+
X4 = q3 - 3;
|
|
14626
|
+
else if (q3 > 4)
|
|
14627
|
+
X4 = q3 - 2;
|
|
14628
|
+
else if (q3 > 0)
|
|
14629
|
+
X4 = 2;
|
|
14630
|
+
let M2 = F03(X4), j4 = Array(Number(M2) + 1).fill(K3), N = Math.floor((J2.BITS - 1) / X4) * X4, D3 = K3;
|
|
14631
|
+
for (let V2 = N;V2 >= 0; V2 -= X4) {
|
|
14632
14632
|
j4.fill(K3);
|
|
14633
14633
|
for (let z2 = 0;z2 < Z3; z2++) {
|
|
14634
14634
|
let A3 = G2[z2], H4 = Number(A3 >> BigInt(V2) & M2);
|
|
@@ -14638,7 +14638,7 @@ function V82($3, J2, Q4, G2) {
|
|
|
14638
14638
|
for (let z2 = j4.length - 1, A3 = K3;z2 > 0; z2--)
|
|
14639
14639
|
A3 = A3.add(j4[z2]), B4 = B4.add(A3);
|
|
14640
14640
|
if (D3 = D3.add(B4), V2 !== 0)
|
|
14641
|
-
for (let z2 = 0;z2 <
|
|
14641
|
+
for (let z2 = 0;z2 < X4; z2++)
|
|
14642
14642
|
D3 = D3.double();
|
|
14643
14643
|
}
|
|
14644
14644
|
return D3;
|
|
@@ -14692,25 +14692,25 @@ var D03 = { Err: R8, _tlv: { encode: ($3, J2) => {
|
|
|
14692
14692
|
if (!Z3)
|
|
14693
14693
|
K3 = Y2;
|
|
14694
14694
|
else {
|
|
14695
|
-
let
|
|
14696
|
-
if (!
|
|
14695
|
+
let X4 = Y2 & 127;
|
|
14696
|
+
if (!X4)
|
|
14697
14697
|
throw new Q4("tlv.decode(long): indefinite length not supported");
|
|
14698
|
-
if (
|
|
14698
|
+
if (X4 > 4)
|
|
14699
14699
|
throw new Q4("tlv.decode(long): byte length is too big");
|
|
14700
|
-
let M2 = J2.subarray(G2, G2 +
|
|
14701
|
-
if (M2.length !==
|
|
14700
|
+
let M2 = J2.subarray(G2, G2 + X4);
|
|
14701
|
+
if (M2.length !== X4)
|
|
14702
14702
|
throw new Q4("tlv.decode: length bytes not complete");
|
|
14703
14703
|
if (M2[0] === 0)
|
|
14704
14704
|
throw new Q4("tlv.decode(long): zero leftmost byte");
|
|
14705
14705
|
for (let j4 of M2)
|
|
14706
14706
|
K3 = K3 << 8 | j4;
|
|
14707
|
-
if (G2 +=
|
|
14707
|
+
if (G2 += X4, K3 < 128)
|
|
14708
14708
|
throw new Q4("tlv.decode(long): not minimal encoding");
|
|
14709
14709
|
}
|
|
14710
|
-
let
|
|
14711
|
-
if (
|
|
14710
|
+
let q3 = J2.subarray(G2, G2 + K3);
|
|
14711
|
+
if (q3.length !== K3)
|
|
14712
14712
|
throw new Q4("tlv.decode: wrong value length");
|
|
14713
|
-
return { v:
|
|
14713
|
+
return { v: q3, l: J2.subarray(G2 + K3) };
|
|
14714
14714
|
} }, _int: { encode($3) {
|
|
14715
14715
|
let { Err: J2 } = D03;
|
|
14716
14716
|
if ($3 < V03)
|
|
@@ -14732,10 +14732,10 @@ var D03 = { Err: R8, _tlv: { encode: ($3, J2) => {
|
|
|
14732
14732
|
let { Err: J2, _int: Q4, _tlv: G2 } = D03, Y2 = e5("signature", $3), { v: Z3, l: K3 } = G2.decode(48, Y2);
|
|
14733
14733
|
if (K3.length)
|
|
14734
14734
|
throw new J2("invalid signature: left bytes after parsing");
|
|
14735
|
-
let { v:
|
|
14735
|
+
let { v: q3, l: X4 } = G2.decode(2, Z3), { v: M2, l: j4 } = G2.decode(2, X4);
|
|
14736
14736
|
if (j4.length)
|
|
14737
14737
|
throw new J2("invalid signature: left bytes after parsing");
|
|
14738
|
-
return { r: Q4.decode(
|
|
14738
|
+
return { r: Q4.decode(q3), s: Q4.decode(M2) };
|
|
14739
14739
|
}, hexFromSig($3) {
|
|
14740
14740
|
let { _tlv: J2, _int: Q4 } = D03, G2 = J2.encode(2, Q4.encode($3.r)), Y2 = J2.encode(2, Q4.encode($3.s)), Z3 = G2 + Y2;
|
|
14741
14741
|
return J2.encode(48, Z3);
|
|
@@ -14760,14 +14760,14 @@ function OQ($3) {
|
|
|
14760
14760
|
let { a: R4, b: P } = J2, S3 = Q4.sqr(U2), w3 = Q4.mul(S3, U2);
|
|
14761
14761
|
return Q4.add(Q4.add(w3, Q4.mul(U2, R4)), P);
|
|
14762
14762
|
}
|
|
14763
|
-
function
|
|
14763
|
+
function q3(U2, R4) {
|
|
14764
14764
|
let P = Q4.sqr(R4), S3 = K3(U2);
|
|
14765
14765
|
return Q4.eql(P, S3);
|
|
14766
14766
|
}
|
|
14767
|
-
if (!
|
|
14767
|
+
if (!q3(J2.Gx, J2.Gy))
|
|
14768
14768
|
throw Error("bad curve params: generator point");
|
|
14769
|
-
let
|
|
14770
|
-
if (Q4.is0(Q4.add(
|
|
14769
|
+
let X4 = Q4.mul(Q4.pow(J2.a, DJ3), VQ), M2 = Q4.mul(Q4.sqr(J2.b), BigInt(27));
|
|
14770
|
+
if (Q4.is0(Q4.add(X4, M2)))
|
|
14771
14771
|
throw Error("bad curve params: a or b");
|
|
14772
14772
|
function j4(U2) {
|
|
14773
14773
|
return x$2(U2, p5, J2.n);
|
|
@@ -14817,7 +14817,7 @@ function OQ($3) {
|
|
|
14817
14817
|
let { x: R4, y: P } = U2.toAffine();
|
|
14818
14818
|
if (!Q4.isValid(R4) || !Q4.isValid(P))
|
|
14819
14819
|
throw Error("bad point: x or y not FE");
|
|
14820
|
-
if (!
|
|
14820
|
+
if (!q3(R4, P))
|
|
14821
14821
|
throw Error("bad point: equation left != right");
|
|
14822
14822
|
if (!U2.isTorsionFree())
|
|
14823
14823
|
throw Error("bad point: not in prime-order subgroup");
|
|
@@ -14981,8 +14981,8 @@ function RQ($3) {
|
|
|
14981
14981
|
return b03(J2, { hash: "hash", hmac: "function", randomBytes: "function" }, { bits2int: "function", bits2int_modN: "function", lowS: "boolean" }), Object.freeze({ lowS: true, ...J2 });
|
|
14982
14982
|
}
|
|
14983
14983
|
function C8($3) {
|
|
14984
|
-
let J2 = RQ($3), { Fp: Q4, n: G2, nByteLength: Y2, nBitLength: Z3 } = J2, K3 = Q4.BYTES + 1,
|
|
14985
|
-
function
|
|
14984
|
+
let J2 = RQ($3), { Fp: Q4, n: G2, nByteLength: Y2, nBitLength: Z3 } = J2, K3 = Q4.BYTES + 1, q3 = 2 * Q4.BYTES + 1;
|
|
14985
|
+
function X4(W3) {
|
|
14986
14986
|
return i4(W3, G2);
|
|
14987
14987
|
}
|
|
14988
14988
|
function M2(W3) {
|
|
@@ -15011,11 +15011,11 @@ function C8($3) {
|
|
|
15011
15011
|
if ((I4 & 1) === 1 !== m3)
|
|
15012
15012
|
b4 = Q4.neg(b4);
|
|
15013
15013
|
return { x: T3, y: b4 };
|
|
15014
|
-
} else if (C3 ===
|
|
15014
|
+
} else if (C3 === q3 && I4 === 4) {
|
|
15015
15015
|
let T3 = Q4.fromBytes(F2.subarray(0, Q4.BYTES)), O4 = Q4.fromBytes(F2.subarray(Q4.BYTES, 2 * Q4.BYTES));
|
|
15016
15016
|
return { x: T3, y: O4 };
|
|
15017
15017
|
} else {
|
|
15018
|
-
let T3 = K3, O4 =
|
|
15018
|
+
let T3 = K3, O4 = q3;
|
|
15019
15019
|
throw Error("invalid Point, expected length of " + T3 + ", or uncompressed " + O4 + ", got " + C3);
|
|
15020
15020
|
}
|
|
15021
15021
|
} });
|
|
@@ -15024,7 +15024,7 @@ function C8($3) {
|
|
|
15024
15024
|
return W3 > C3;
|
|
15025
15025
|
}
|
|
15026
15026
|
function z2(W3) {
|
|
15027
|
-
return B4(W3) ?
|
|
15027
|
+
return B4(W3) ? X4(-W3) : W3;
|
|
15028
15028
|
}
|
|
15029
15029
|
let A3 = (W3, C3, I4) => z02(W3.slice(C3, I4));
|
|
15030
15030
|
|
|
@@ -15053,7 +15053,7 @@ function C8($3) {
|
|
|
15053
15053
|
let O4 = F2 === 2 || F2 === 3 ? C3 + J2.n : C3;
|
|
15054
15054
|
if (O4 >= Q4.ORDER)
|
|
15055
15055
|
throw Error("recovery id 2 or 3 invalid");
|
|
15056
|
-
let b4 = (F2 & 1) === 0 ? "02" : "03", m3 = j4.fromHex(b4 + zJ3(O4, Q4.BYTES)), l4 = M2(O4), s3 =
|
|
15056
|
+
let b4 = (F2 & 1) === 0 ? "02" : "03", m3 = j4.fromHex(b4 + zJ3(O4, Q4.BYTES)), l4 = M2(O4), s3 = X4(-T3 * l4), r4 = X4(I4 * l4), O03 = j4.BASE.multiplyAndAddUnsafe(m3, s3, r4);
|
|
15057
15057
|
if (!O03)
|
|
15058
15058
|
throw Error("point at infinify");
|
|
15059
15059
|
return O03.assertValidity(), O03;
|
|
@@ -15062,7 +15062,7 @@ function C8($3) {
|
|
|
15062
15062
|
return B4(this.s);
|
|
15063
15063
|
}
|
|
15064
15064
|
normalizeS() {
|
|
15065
|
-
return this.hasHighS() ? new H4(this.r,
|
|
15065
|
+
return this.hasHighS() ? new H4(this.r, X4(-this.s), this.recovery) : this;
|
|
15066
15066
|
}
|
|
15067
15067
|
toDERRawBytes() {
|
|
15068
15068
|
return q$(this.toDERHex());
|
|
@@ -15117,7 +15117,7 @@ function C8($3) {
|
|
|
15117
15117
|
let C3 = z02(W3), I4 = W3.length * 8 - Z3;
|
|
15118
15118
|
return I4 > 0 ? C3 >> BigInt(I4) : C3;
|
|
15119
15119
|
}, w3 = J2.bits2int_modN || function(W3) {
|
|
15120
|
-
return
|
|
15120
|
+
return X4(S3(W3));
|
|
15121
15121
|
}, E4 = F03(Z3);
|
|
15122
15122
|
function y4(W3) {
|
|
15123
15123
|
return y03("num < 2^" + Z3, W3, V03, E4), w03(W3, Y2);
|
|
@@ -15140,10 +15140,10 @@ function C8($3) {
|
|
|
15140
15140
|
let g03 = S3(H03);
|
|
15141
15141
|
if (!V2(g03))
|
|
15142
15142
|
return;
|
|
15143
|
-
let b$2 = M2(g03), o03 = j4.BASE.multiply(g03).toAffine(), S03 =
|
|
15143
|
+
let b$2 = M2(g03), o03 = j4.BASE.multiply(g03).toAffine(), S03 = X4(o03.x);
|
|
15144
15144
|
if (S03 === V03)
|
|
15145
15145
|
return;
|
|
15146
|
-
let t03 =
|
|
15146
|
+
let t03 = X4(b$2 * X4(N$2 + S03 * s3));
|
|
15147
15147
|
if (t03 === V03)
|
|
15148
15148
|
return;
|
|
15149
15149
|
let v03 = (o03.x === S03 ? 0 : 2) | Number(o03.y & p5), IJ3 = t03;
|
|
@@ -15195,10 +15195,10 @@ function C8($3) {
|
|
|
15195
15195
|
return false;
|
|
15196
15196
|
if (b4)
|
|
15197
15197
|
C3 = J2.hash(C3);
|
|
15198
|
-
let { r: N$2, s: F$2 } = r4, H03 = w3(C3), g03 = M2(F$2), b$2 =
|
|
15198
|
+
let { r: N$2, s: F$2 } = r4, H03 = w3(C3), g03 = M2(F$2), b$2 = X4(H03 * g03), o03 = X4(N$2 * g03), S03 = j4.BASE.multiplyAndAddUnsafe(O03, b$2, o03)?.toAffine();
|
|
15199
15199
|
if (!S03)
|
|
15200
15200
|
return false;
|
|
15201
|
-
return
|
|
15201
|
+
return X4(S03.x) === N$2;
|
|
15202
15202
|
}
|
|
15203
15203
|
return { CURVE: J2, getPublicKey: U2, getSharedSecret: P, sign: c4, verify: v3, ProjectivePoint: j4, Signature: H4, utils: h4 };
|
|
15204
15204
|
}
|
|
@@ -15218,14 +15218,14 @@ var PQ2 = BigInt(1);
|
|
|
15218
15218
|
var VJ3 = BigInt(2);
|
|
15219
15219
|
var B8 = ($3, J2) => ($3 + J2 / VJ3) / J2;
|
|
15220
15220
|
function BQ2($3) {
|
|
15221
|
-
let J2 = H8, Q4 = BigInt(3), G2 = BigInt(6), Y2 = BigInt(11), Z3 = BigInt(22), K3 = BigInt(23),
|
|
15221
|
+
let J2 = H8, Q4 = BigInt(3), G2 = BigInt(6), Y2 = BigInt(11), Z3 = BigInt(22), K3 = BigInt(23), q3 = BigInt(44), X4 = BigInt(88), M2 = $3 * $3 * $3 % J2, j4 = M2 * M2 * $3 % J2, N = J02(j4, Q4, J2) * j4 % J2, D3 = J02(N, Q4, J2) * j4 % J2, V2 = J02(D3, VJ3, J2) * M2 % J2, B4 = J02(V2, Y2, J2) * V2 % J2, z2 = J02(B4, Z3, J2) * B4 % J2, A3 = J02(z2, q3, J2) * z2 % J2, H4 = J02(A3, X4, J2) * A3 % J2, h4 = J02(H4, q3, J2) * z2 % J2, U2 = J02(h4, Q4, J2) * j4 % J2, R4 = J02(U2, K3, J2) * B4 % J2, P = J02(R4, G2, J2) * M2 % J2, S3 = J02(P, VJ3, J2);
|
|
15222
15222
|
if (!OJ3.eql(OJ3.sqr(S3), $3))
|
|
15223
15223
|
throw Error("Cannot find square root");
|
|
15224
15224
|
return S3;
|
|
15225
15225
|
}
|
|
15226
15226
|
var OJ3 = j$2(H8, undefined, undefined, { sqrt: BQ2 });
|
|
15227
15227
|
var RJ3 = L8({ a: LQ, b: BigInt(7), Fp: OJ3, n: P8, Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"), Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"), h: BigInt(1), lowS: true, endo: { beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"), splitScalar: ($3) => {
|
|
15228
|
-
let J2 = P8, Q4 = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), G2 = -PQ2 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), Y2 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), Z3 = Q4, K3 = BigInt("0x100000000000000000000000000000000"),
|
|
15228
|
+
let J2 = P8, Q4 = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), G2 = -PQ2 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), Y2 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), Z3 = Q4, K3 = BigInt("0x100000000000000000000000000000000"), q3 = B8(Z3 * $3, J2), X4 = B8(-G2 * $3, J2), M2 = i4($3 - q3 * Q4 - X4 * Y2, J2), j4 = i4(-q3 * G2 - X4 * Z3, J2), N = M2 > K3, D3 = j4 > K3;
|
|
15229
15229
|
if (N)
|
|
15230
15230
|
M2 = J2 - M2;
|
|
15231
15231
|
if (D3)
|
|
@@ -15264,8 +15264,8 @@ class g3 extends E$2 {
|
|
|
15264
15264
|
return new g3(`No proxy inviters found for ${$3}. 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: $3 } });
|
|
15265
15265
|
}
|
|
15266
15266
|
static insufficientBalance($3, J2, Q4, G2, Y2, Z3) {
|
|
15267
|
-
let K3 = Number(Q4) / 1000000000000000000,
|
|
15268
|
-
return new g3(`Insufficient balance for ${$3} invitation(s). Can only afford ${J2} invitation(s). Requested: ${K3.toFixed(6)} CRC, Available: ${
|
|
15267
|
+
let K3 = Number(Q4) / 1000000000000000000, q3 = Number(G2) / 1000000000000000000;
|
|
15268
|
+
return new g3(`Insufficient balance for ${$3} invitation(s). Can only afford ${J2} invitation(s). Requested: ${K3.toFixed(6)} CRC, Available: ${q3.toFixed(6)} CRC.`, { code: "INVITATION_INSUFFICIENT_BALANCE", source: "VALIDATION", context: { from: Y2, to: Z3, requestedInvites: $3, availableInvites: J2, requested: Q4.toString(), available: G2.toString(), requestedCrc: K3, availableCrc: q3 } });
|
|
15269
15269
|
}
|
|
15270
15270
|
static inviteeAlreadyRegistered($3, J2) {
|
|
15271
15271
|
return new g3(`Invitee ${J2} is already registered as a human in Circles Hub. Cannot invite an already registered user.`, { code: "INVITATION_INVITEE_ALREADY_REGISTERED", source: "VALIDATION", context: { inviter: $3, invitee: J2 } });
|
|
@@ -15295,21 +15295,21 @@ function T82($3, J2, Q4) {
|
|
|
15295
15295
|
$3.forEach((K3) => {
|
|
15296
15296
|
G2.add(K3.from.toLowerCase()), G2.add(K3.to.toLowerCase()), G2.add(K3.tokenOwner.toLowerCase());
|
|
15297
15297
|
});
|
|
15298
|
-
let Y2 = [...G2].sort((K3,
|
|
15299
|
-
let
|
|
15298
|
+
let Y2 = [...G2].sort((K3, q3) => {
|
|
15299
|
+
let X4 = BigInt(K3), M2 = BigInt(q3), j4 = X4 < M2, N = X4 > M2;
|
|
15300
15300
|
return j4 ? -1 : N ? 1 : 0;
|
|
15301
15301
|
}), Z3 = {};
|
|
15302
|
-
return Y2.forEach((K3,
|
|
15303
|
-
Z3[K3] =
|
|
15302
|
+
return Y2.forEach((K3, q3) => {
|
|
15303
|
+
Z3[K3] = q3;
|
|
15304
15304
|
}), { sorted: Y2, idx: Z3 };
|
|
15305
15305
|
}
|
|
15306
15306
|
function HQ2($3, J2) {
|
|
15307
15307
|
let Q4 = new Set, G2 = [], Y2 = null;
|
|
15308
15308
|
if ($3.forEach((Z3, K3) => {
|
|
15309
|
-
let
|
|
15310
|
-
if (
|
|
15309
|
+
let q3 = Z3.from.toLowerCase(), X4 = Z3.to.toLowerCase();
|
|
15310
|
+
if (q3 === J2 && X4 === J2)
|
|
15311
15311
|
Y2 = K3;
|
|
15312
|
-
else if (
|
|
15312
|
+
else if (X4 === J2)
|
|
15313
15313
|
G2.push(K3);
|
|
15314
15314
|
}), Y2 !== null)
|
|
15315
15315
|
Q4.add(Y2);
|
|
@@ -15318,19 +15318,19 @@ function HQ2($3, J2) {
|
|
|
15318
15318
|
return Q4;
|
|
15319
15319
|
}
|
|
15320
15320
|
function CJ2($3, J2, Q4, G2) {
|
|
15321
|
-
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), { sorted: K3, idx:
|
|
15322
|
-
return { streamSinkId:
|
|
15321
|
+
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), { sorted: K3, idx: q3 } = T82(G2, Y2, Z3), X4 = HQ2(G2, Z3), M2 = G2.map((H4, h4) => {
|
|
15322
|
+
return { streamSinkId: X4.has(h4) ? 1 : 0, amount: H4.value };
|
|
15323
15323
|
});
|
|
15324
|
-
if (
|
|
15324
|
+
if (X4.size === 0)
|
|
15325
15325
|
throw Error(`No terminal edges detected. Flow must have at least one edge delivering to receiver ${Z3}`);
|
|
15326
|
-
let j4 = Array.from(
|
|
15326
|
+
let j4 = Array.from(X4), N = [{ sourceCoordinate: q3[Y2], flowEdgeIds: j4, data: new Uint8Array(0) }], D3 = [];
|
|
15327
15327
|
G2.forEach((H4) => {
|
|
15328
|
-
D3.push(
|
|
15328
|
+
D3.push(q3[H4.tokenOwner.toLowerCase()]), D3.push(q3[H4.from.toLowerCase()]), D3.push(q3[H4.to.toLowerCase()]);
|
|
15329
15329
|
});
|
|
15330
15330
|
let V2 = I82(D3), B4 = BigInt(Q4), z2 = M2.filter((H4) => H4.streamSinkId === 1).reduce((H4, h4) => H4 + BigInt(h4.amount.toString()), BigInt(0));
|
|
15331
15331
|
if (z2 !== B4)
|
|
15332
15332
|
throw Error(`Terminal sum ${z2} does not equal expected ${B4}`);
|
|
15333
|
-
return { flowVertices: K3, flowEdges: M2, streams: N, packedCoordinates: V2, sourceCoordinate:
|
|
15333
|
+
return { flowVertices: K3, flowEdges: M2, streams: N, packedCoordinates: V2, sourceCoordinate: q3[Y2] };
|
|
15334
15334
|
}
|
|
15335
15335
|
function LJ3($3, J2) {
|
|
15336
15336
|
let Q4 = $3.streams.map((G2) => ({ sourceCoordinate: G2.sourceCoordinate, flowEdgeIds: G2.flowEdgeIds, data: G2.data instanceof Uint8Array ? U$(G2.data) : G2.data }));
|
|
@@ -15340,13 +15340,13 @@ function LJ3($3, J2) {
|
|
|
15340
15340
|
}
|
|
15341
15341
|
async function PJ2($3, J2, Q4) {
|
|
15342
15342
|
let G2 = new Map, Y2 = new Set;
|
|
15343
|
-
return Q4.transfers.forEach((
|
|
15344
|
-
if ($3.toLowerCase() ===
|
|
15345
|
-
Y2.add(
|
|
15346
|
-
}), (await new I$2(J2).token.getTokenInfoBatch(Array.from(Y2))).forEach((
|
|
15347
|
-
if (
|
|
15348
|
-
|
|
15349
|
-
G2.set(
|
|
15343
|
+
return Q4.transfers.forEach((q3) => {
|
|
15344
|
+
if ($3.toLowerCase() === q3.from.toLowerCase())
|
|
15345
|
+
Y2.add(q3.tokenOwner.toLowerCase());
|
|
15346
|
+
}), (await new I$2(J2).token.getTokenInfoBatch(Array.from(Y2))).forEach((q3) => {
|
|
15347
|
+
if (q3.isWrapped && !q3.isInflationary)
|
|
15348
|
+
q3.tokenType = "CrcV2_ERC20WrapperDeployed_Demurraged";
|
|
15349
|
+
G2.set(q3.tokenAddress.toLowerCase(), q3);
|
|
15350
15350
|
}), G2;
|
|
15351
15351
|
}
|
|
15352
15352
|
function BJ2($3, J2) {
|
|
@@ -15410,21 +15410,21 @@ class W$ {
|
|
|
15410
15410
|
let Z3 = $3.toLowerCase(), K3 = J2.toLowerCase();
|
|
15411
15411
|
if (!Q4.transfers || Q4.transfers.length === 0)
|
|
15412
15412
|
throw o5.noPathFound(Z3, K3);
|
|
15413
|
-
let
|
|
15413
|
+
let q3 = { ...Q4 };
|
|
15414
15414
|
if (Y2 && G2?.toTokens?.length === 1) {
|
|
15415
15415
|
let h4 = G2.toTokens[0].toLowerCase();
|
|
15416
15416
|
if (Q4.maxFlow > 0n)
|
|
15417
|
-
|
|
15417
|
+
q3.transfers.push({ from: K3, to: K3, tokenOwner: h4, value: Q4.maxFlow });
|
|
15418
15418
|
}
|
|
15419
|
-
let
|
|
15419
|
+
let X4 = await PJ2(Z3, this.config.circlesRpcUrl, q3), M2 = BJ2(q3, X4), j4 = Object.keys(M2).length > 0;
|
|
15420
15420
|
if (j4 && !G2?.useWrappedBalances)
|
|
15421
15421
|
throw o5.wrappedTokensRequired();
|
|
15422
15422
|
let N = [], D3 = [];
|
|
15423
15423
|
if (j4) {
|
|
15424
|
-
let h4 = await this._getTokenBalanceMap(Z3), U2 = this._createDemurragedUnwrapCalls(M2), { unwrapCalls: R4, wrapCalls: P } = this._createInflationaryUnwrapAndWrapCalls(M2,
|
|
15425
|
-
N = [...U2, ...R4], D3 = P,
|
|
15424
|
+
let h4 = await this._getTokenBalanceMap(Z3), U2 = this._createDemurragedUnwrapCalls(M2), { unwrapCalls: R4, wrapCalls: P } = this._createInflationaryUnwrapAndWrapCalls(M2, X4, h4);
|
|
15425
|
+
N = [...U2, ...R4], D3 = P, q3 = HJ3(q3, X4);
|
|
15426
15426
|
}
|
|
15427
|
-
let V2 = CJ2(Z3, K3,
|
|
15427
|
+
let V2 = CJ2(Z3, K3, q3.maxFlow, q3.transfers), B4 = LJ3(V2, G2?.txData), z2 = this.hubV2.operateFlowMatrix(V2.flowVertices, V2.flowEdges, B4, V2.packedCoordinates), A3 = false;
|
|
15428
15428
|
try {
|
|
15429
15429
|
A3 = await this.hubV2.isApprovedForAll(Z3, Z3);
|
|
15430
15430
|
} catch (h4) {
|
|
@@ -15433,27 +15433,27 @@ class W$ {
|
|
|
15433
15433
|
return [...A3 ? [] : [this.hubV2.setApprovalForAll(Z3, true)], ...N, z2, ...D3];
|
|
15434
15434
|
}
|
|
15435
15435
|
async constructAdvancedTransfer($3, J2, Q4, G2, Y2 = false) {
|
|
15436
|
-
let Z3 = $3.toLowerCase(), K3 = J2.toLowerCase(),
|
|
15436
|
+
let Z3 = $3.toLowerCase(), K3 = J2.toLowerCase(), q3 = BigInt(Q4);
|
|
15437
15437
|
if (Z3 === K3 && G2?.fromTokens?.length === 1 && G2?.toTokens?.length === 1) {
|
|
15438
15438
|
let V2 = G2.fromTokens[0], B4 = G2.toTokens[0], [z2, A3] = await Promise.all([this.liftERC20.erc20Circles(0, B4), this.liftERC20.erc20Circles(1, B4)]);
|
|
15439
15439
|
if (V2.toLowerCase() === z2.toLowerCase() && z2 !== S$2) {
|
|
15440
|
-
let h4 = new c03({ address: V2, rpcUrl: this.config.circlesRpcUrl }).unwrap(
|
|
15440
|
+
let h4 = new c03({ address: V2, rpcUrl: this.config.circlesRpcUrl }).unwrap(q3);
|
|
15441
15441
|
return [{ to: h4.to, data: h4.data, value: h4.value ?? 0n }];
|
|
15442
15442
|
}
|
|
15443
15443
|
if (V2.toLowerCase() === A3.toLowerCase() && A3 !== S$2) {
|
|
15444
|
-
let H4 = new l03({ address: V2, rpcUrl: this.config.circlesRpcUrl }), h4 = d4.attoCirclesToAttoStaticCircles(
|
|
15444
|
+
let H4 = new l03({ address: V2, rpcUrl: this.config.circlesRpcUrl }), h4 = d4.attoCirclesToAttoStaticCircles(q3), U2 = H4.unwrap(h4);
|
|
15445
15445
|
return [{ to: U2.to, data: U2.data, value: U2.value ?? 0n }];
|
|
15446
15446
|
}
|
|
15447
15447
|
}
|
|
15448
|
-
let
|
|
15448
|
+
let X4 = this._truncateToSixDecimals(q3), M2 = await this._getDefaultTokenExcludeList(K3, G2?.excludeFromTokens), { ...j4 } = G2 || {}, N = { ...j4, ...M2 ? { excludeFromTokens: M2 } : {} }, D3 = await this.pathfinder.findPath({ from: Z3, to: K3, targetFlow: X4, ...N });
|
|
15449
15449
|
if (!D3.transfers || D3.transfers.length === 0)
|
|
15450
15450
|
throw o5.noPathFound(Z3, K3);
|
|
15451
|
-
if (D3.maxFlow <
|
|
15452
|
-
throw o5.insufficientBalance(
|
|
15451
|
+
if (D3.maxFlow < X4)
|
|
15452
|
+
throw o5.insufficientBalance(X4, D3.maxFlow, Z3, K3);
|
|
15453
15453
|
return this.buildFlowMatrixTx(Z3, K3, D3, G2, Y2);
|
|
15454
15454
|
}
|
|
15455
15455
|
async constructReplenish($3, J2, Q4, G2) {
|
|
15456
|
-
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), K3 = (G2 || $3).toLowerCase(),
|
|
15456
|
+
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), K3 = (G2 || $3).toLowerCase(), q3 = BigInt(Q4), M2 = (await this.balance.getTokenBalances(Y2)).filter((O4) => O4.tokenOwner.toLowerCase() === Z3), j4 = 0n, N = 0n, D3 = 0n, V2 = null, B4 = null;
|
|
15457
15457
|
for (let O4 of M2)
|
|
15458
15458
|
if (O4.isWrapped)
|
|
15459
15459
|
if (O4.tokenType.includes("Demurrage"))
|
|
@@ -15463,15 +15463,15 @@ class W$ {
|
|
|
15463
15463
|
else
|
|
15464
15464
|
j4 = BigInt(O4.attoCircles);
|
|
15465
15465
|
let z2 = j4 + N + d4.attoStaticCirclesToAttoCircles(D3), A3 = [];
|
|
15466
|
-
if (j4 >=
|
|
15467
|
-
if (console.log(`✓ Already have ${Number(j4) / 1000000000000000000} CRC unwrapped (target: ${Number(
|
|
15468
|
-
let O4 = await this.hubV2.toTokenId(Z3), b4 = this.hubV2.safeTransferFrom(Y2, K3, O4,
|
|
15466
|
+
if (j4 >= q3) {
|
|
15467
|
+
if (console.log(`✓ Already have ${Number(j4) / 1000000000000000000} CRC unwrapped (target: ${Number(q3) / 1000000000000000000} CRC). No replenish needed.`), K3 !== Y2) {
|
|
15468
|
+
let O4 = await this.hubV2.toTokenId(Z3), b4 = this.hubV2.safeTransferFrom(Y2, K3, O4, q3);
|
|
15469
15469
|
A3.push({ to: b4.to, data: b4.data, value: b4.value ?? 0n });
|
|
15470
15470
|
}
|
|
15471
15471
|
return A3;
|
|
15472
15472
|
}
|
|
15473
|
-
let H4 =
|
|
15474
|
-
if (console.log(`Current unwrapped: ${Number(j4) / 1000000000000000000} CRC`), console.log(`Target amount: ${Number(
|
|
15473
|
+
let H4 = q3 - j4;
|
|
15474
|
+
if (console.log(`Current unwrapped: ${Number(j4) / 1000000000000000000} CRC`), console.log(`Target amount: ${Number(q3) / 1000000000000000000} CRC`), console.log(`Need to acquire: ${Number(H4) / 1000000000000000000} CRC`), z2 >= q3) {
|
|
15475
15475
|
let O4 = H4;
|
|
15476
15476
|
if (N > 0n && V2 && O4 > 0n) {
|
|
15477
15477
|
let b4 = O4 > N ? N : O4, l4 = new c03({ address: V2, rpcUrl: this.config.circlesRpcUrl }).unwrap(b4);
|
|
@@ -15482,7 +15482,7 @@ class W$ {
|
|
|
15482
15482
|
A3.push({ to: s3.to, data: s3.data, value: s3.value ?? 0n });
|
|
15483
15483
|
}
|
|
15484
15484
|
if (K3 !== Y2) {
|
|
15485
|
-
let b4 = await this.hubV2.toTokenId(Z3), m3 = this.hubV2.safeTransferFrom(Y2, K3, b4,
|
|
15485
|
+
let b4 = await this.hubV2.toTokenId(Z3), m3 = this.hubV2.safeTransferFrom(Y2, K3, b4, q3);
|
|
15486
15486
|
A3.push({ to: m3.to, data: m3.data, value: m3.value ?? 0n });
|
|
15487
15487
|
}
|
|
15488
15488
|
return A3;
|
|
@@ -15491,8 +15491,8 @@ class W$ {
|
|
|
15491
15491
|
try {
|
|
15492
15492
|
E4 = await this.pathfinder.findPath({ from: Y2, to: K3, targetFlow: w3, toTokens: [Z3], useWrappedBalances: true, simulatedTrusts: U2 ? [{ truster: Y2, trustee: Z3 }] : undefined });
|
|
15493
15493
|
} catch (O4) {
|
|
15494
|
-
let b4 = Number(z2) / 1000000000000000000, m3 = Number(
|
|
15495
|
-
throw new o5(`Insufficient tokens to replenish. Target: ${m3.toFixed(6)} CRC, Current unwrapped: ${Number(j4) / 1000000000000000000} CRC, Need: ${l4.toFixed(6)} CRC, Available (including all paths): ${b4.toFixed(6)} CRC. Cannot acquire the remaining ${(Number(H4 - (z2 - j4)) / 1000000000000000000).toFixed(6)} CRC.`, { code: "REPLENISH_INSUFFICIENT_TOKENS", source: "VALIDATION", context: { from: Y2, tokenId: Z3, target:
|
|
15494
|
+
let b4 = Number(z2) / 1000000000000000000, m3 = Number(q3) / 1000000000000000000, l4 = Number(H4) / 1000000000000000000;
|
|
15495
|
+
throw new o5(`Insufficient tokens to replenish. Target: ${m3.toFixed(6)} CRC, Current unwrapped: ${Number(j4) / 1000000000000000000} CRC, Need: ${l4.toFixed(6)} CRC, Available (including all paths): ${b4.toFixed(6)} CRC. Cannot acquire the remaining ${(Number(H4 - (z2 - j4)) / 1000000000000000000).toFixed(6)} CRC.`, { code: "REPLENISH_INSUFFICIENT_TOKENS", source: "VALIDATION", context: { from: Y2, tokenId: Z3, target: q3.toString(), unwrapped: j4.toString(), deficit: H4.toString(), available: z2.toString(), targetCrc: m3, unwrappedCrc: Number(j4) / 1000000000000000000, deficitCrc: l4, availableCrc: b4 } });
|
|
15496
15496
|
}
|
|
15497
15497
|
if (!E4.transfers || E4.transfers.length === 0)
|
|
15498
15498
|
throw o5.noPathFound(Y2, K3, `No path to acquire token ${Z3}`);
|
|
@@ -15540,15 +15540,15 @@ class W$ {
|
|
|
15540
15540
|
}
|
|
15541
15541
|
_createInflationaryUnwrapAndWrapCalls($3, J2, Q4) {
|
|
15542
15542
|
let G2 = [], Y2 = [];
|
|
15543
|
-
for (let [Z3, [K3,
|
|
15544
|
-
if (
|
|
15543
|
+
for (let [Z3, [K3, q3]] of Object.entries($3)) {
|
|
15544
|
+
if (q3 !== "CrcV2_ERC20WrapperDeployed_Inflationary")
|
|
15545
15545
|
continue;
|
|
15546
|
-
let
|
|
15546
|
+
let X4 = J2.get(Z3.toLowerCase()), M2 = Q4.get(Z3.toLowerCase()) || 0n;
|
|
15547
15547
|
if (M2 === 0n)
|
|
15548
15548
|
continue;
|
|
15549
15549
|
let N = new l03({ address: Z3, rpcUrl: this.config.circlesRpcUrl }).unwrap(M2);
|
|
15550
15550
|
G2.push({ to: N.to, data: N.data, value: N.value ?? 0n });
|
|
15551
|
-
let D3 =
|
|
15551
|
+
let D3 = X4?.tokenOwner, V2 = d4.attoStaticCirclesToAttoCircles(M2) - K3;
|
|
15552
15552
|
if (V2 > 0n) {
|
|
15553
15553
|
let B4 = this.hubV2.wrap(D3, V2, 1);
|
|
15554
15554
|
Y2.push({ to: B4.to, data: B4.data, value: B4.value ?? 0n });
|
|
@@ -15625,11 +15625,11 @@ class SJ3 {
|
|
|
15625
15625
|
let Q4 = $3.toLowerCase(), G2 = J2.toLowerCase();
|
|
15626
15626
|
if (await this.hubV2.isHuman(G2))
|
|
15627
15627
|
throw g3.inviteeAlreadyRegistered(Q4, G2);
|
|
15628
|
-
let Z3 = await this.findInvitePath(Q4), K3 = await this.generateInviteData([G2], false),
|
|
15629
|
-
if (
|
|
15628
|
+
let Z3 = await this.findInvitePath(Q4), K3 = await this.generateInviteData([G2], false), q3 = new W$(this.config), X4 = await this.getRealInviters(Q4);
|
|
15629
|
+
if (X4.length === 0)
|
|
15630
15630
|
throw g3.noPathFound(Q4, this.config.invitationModuleAddress);
|
|
15631
|
-
let M2 =
|
|
15632
|
-
return await
|
|
15631
|
+
let M2 = X4[0].address;
|
|
15632
|
+
return await q3.buildFlowMatrixTx(Q4, this.config.invitationModuleAddress, Z3, { toTokens: [M2], useWrappedBalances: true, txData: L$2(K3) }, true);
|
|
15633
15633
|
}
|
|
15634
15634
|
async findInvitePath($3, J2) {
|
|
15635
15635
|
let Q4 = $3.toLowerCase(), G2;
|
|
@@ -15651,11 +15651,14 @@ class SJ3 {
|
|
|
15651
15651
|
return Y2;
|
|
15652
15652
|
}
|
|
15653
15653
|
async getRealInviters($3) {
|
|
15654
|
-
let J2 = $3.toLowerCase(), Q4 = await this.trust.getTrustedBy(J2), G2 = await this.trust.getMutualTrusts(J2), Y2 = new Set([...Q4.map((z2) => z2.objectAvatar.toLowerCase()), ...G2.map((z2) => z2.objectAvatar.toLowerCase())]), Z3 = await this.trust.getTrusts(this.config.invitationModuleAddress), K3 =
|
|
15654
|
+
let J2 = $3.toLowerCase(), Q4 = await this.trust.getTrustedBy(J2), G2 = await this.trust.getMutualTrusts(J2), Y2 = new Set([...Q4.map((z2) => z2.objectAvatar.toLowerCase()), ...G2.map((z2) => z2.objectAvatar.toLowerCase())]), Z3 = await this.trust.getTrusts(this.config.invitationModuleAddress), K3 = new Set([...Z3.map((z2) => z2.objectAvatar.toLowerCase())]);
|
|
15655
|
+
if (!K3.has(J2))
|
|
15656
|
+
throw new g3("Inviter must enable the invitation module before creating invitations", { code: "INVITATION_MODULE_NOT_ENABLED", source: "INVITATIONS", context: { inviter: J2, invitationModule: this.config.invitationModuleAddress } });
|
|
15657
|
+
let X4 = [];
|
|
15655
15658
|
for (let z2 of Y2)
|
|
15656
|
-
if (
|
|
15657
|
-
|
|
15658
|
-
let M2 = [...
|
|
15659
|
+
if (K3.has(z2))
|
|
15660
|
+
X4.push(z2);
|
|
15661
|
+
let M2 = [...X4, J2];
|
|
15659
15662
|
if (M2.length === 0)
|
|
15660
15663
|
return [];
|
|
15661
15664
|
let j4 = await this.pathfinder.findPath({ from: J2, to: this.config.invitationModuleAddress, useWrappedBalances: true, targetFlow: $$, toTokens: M2 });
|
|
@@ -15679,7 +15682,7 @@ class SJ3 {
|
|
|
15679
15682
|
let J2 = $3.toLowerCase(), Q4 = k$2(), G2 = w$2(Q4), Y2 = await this.getRealInviters(J2);
|
|
15680
15683
|
if (Y2.length === 0)
|
|
15681
15684
|
throw g3.noProxyInviters(J2);
|
|
15682
|
-
let K3 = Y2[0].address,
|
|
15685
|
+
let K3 = Y2[0].address, q3 = await this.findInvitePath(J2, K3), X4 = new W$(this.config), M2 = await this.generateInviteData([G2], true), j4 = await X4.buildFlowMatrixTx(J2, this.config.invitationModuleAddress, q3, { toTokens: [K3], useWrappedBalances: true, txData: L$2(M2) }, true);
|
|
15683
15686
|
await this.saveReferralData(J2, Q4);
|
|
15684
15687
|
let N = [];
|
|
15685
15688
|
return N.push(...j4), { transactions: N, privateKey: Q4 };
|
|
@@ -15701,7 +15704,7 @@ class SJ3 {
|
|
|
15701
15704
|
}
|
|
15702
15705
|
}
|
|
15703
15706
|
computeAddress($3) {
|
|
15704
|
-
let Q4 = $3.toLowerCase().replace("0x", "").padStart(64, "0"), G2 = c$2.replace("0x", "") + Q4, Y2 = y$2("0x" + G2), Z3 = "ff", K3 = u$2.toLowerCase().replace("0x", ""),
|
|
15707
|
+
let Q4 = $3.toLowerCase().replace("0x", "").padStart(64, "0"), G2 = c$2.replace("0x", "") + Q4, Y2 = y$2("0x" + G2), Z3 = "ff", K3 = u$2.toLowerCase().replace("0x", ""), q3 = Y2.replace("0x", ""), X4 = l$.replace("0x", ""), M2 = "ff" + K3 + q3 + X4, N = "0x" + y$2("0x" + M2).slice(-40);
|
|
15705
15708
|
return L03(N);
|
|
15706
15709
|
}
|
|
15707
15710
|
generateSecrets($3) {
|
|
@@ -15736,8 +15739,8 @@ class IQ {
|
|
|
15736
15739
|
let Q4 = $3.toLowerCase(), G2 = J2 === 1, Y2 = await this.simulateClaim(Q4, J2);
|
|
15737
15740
|
if (!Y2.length)
|
|
15738
15741
|
throw new g3("No invitation IDs returned from claim", { code: "INVITATION_NO_IDS", source: "INVITATIONS", context: { inviter: Q4, count: J2 } });
|
|
15739
|
-
let Z3 = this.invitations.generateSecrets(J2), K3 = Z3.map((j4) => j4.signer),
|
|
15740
|
-
return await Promise.all(Z3.map((j4) => this.invitations.saveReferralData(Q4, j4.secret))), { invites: Z3, transactions: [
|
|
15742
|
+
let Z3 = this.invitations.generateSecrets(J2), K3 = Z3.map((j4) => j4.signer), q3 = await this.invitationFarm.invitationModule(), X4 = G2 ? this.invitationFarm.claimInvite() : this.invitationFarm.claimInvites(BigInt(J2)), M2 = G2 ? this.buildSingleTransfer(Q4, q3, Y2[0], K3[0]) : this.buildBatchTransfer(Q4, q3, Y2, K3);
|
|
15743
|
+
return await Promise.all(Z3.map((j4) => this.invitations.saveReferralData(Q4, j4.secret))), { invites: Z3, transactions: [X4, M2] };
|
|
15741
15744
|
}
|
|
15742
15745
|
async listReferrals($3, J2 = 10, Q4 = 0) {
|
|
15743
15746
|
return this.invitations.listReferrals($3, J2, Q4);
|