@aboutcircles/sdk 0.1.19 → 0.1.20
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 +579 -589
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12484,7 +12484,7 @@ class CommonAvatar {
|
|
|
12484
12484
|
}
|
|
12485
12485
|
// ../invitations/dist/index.js
|
|
12486
12486
|
var wJ3 = ($3) => BigInt($3);
|
|
12487
|
-
var
|
|
12487
|
+
var J$2 = ($3) => parseInt($3, 16);
|
|
12488
12488
|
var b82 = ($3) => {
|
|
12489
12489
|
if ($3.startsWith("0x"))
|
|
12490
12490
|
$3 = $3.slice(2);
|
|
@@ -12510,7 +12510,7 @@ function F82($3, J2) {
|
|
|
12510
12510
|
}
|
|
12511
12511
|
}
|
|
12512
12512
|
try {
|
|
12513
|
-
let Y2 =
|
|
12513
|
+
let Y2 = J$2(J2);
|
|
12514
12514
|
if (Y2 < Number.MAX_SAFE_INTEGER)
|
|
12515
12515
|
return Y2;
|
|
12516
12516
|
return wJ3(J2);
|
|
@@ -12525,7 +12525,7 @@ function F82($3, J2) {
|
|
|
12525
12525
|
return J2;
|
|
12526
12526
|
}
|
|
12527
12527
|
function m$2($3) {
|
|
12528
|
-
let { event: J2, values: Q3 } = $3, Y2 = { $event: J2, blockNumber: Q3.blockNumber ?
|
|
12528
|
+
let { event: J2, values: Q3 } = $3, Y2 = { $event: J2, blockNumber: Q3.blockNumber ? J$2(Q3.blockNumber) : 0, timestamp: Q3.timestamp ? J$2(Q3.timestamp) : undefined, transactionIndex: Q3.transactionIndex ? J$2(Q3.transactionIndex) : 0, logIndex: Q3.logIndex ? J$2(Q3.logIndex) : 0, transactionHash: Q3.transactionHash };
|
|
12529
12529
|
for (let [G2, Z3] of Object.entries(Q3)) {
|
|
12530
12530
|
if (["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash"].includes(G2))
|
|
12531
12531
|
continue;
|
|
@@ -12537,7 +12537,7 @@ function O$2($3) {
|
|
|
12537
12537
|
return $3.map(m$2);
|
|
12538
12538
|
}
|
|
12539
12539
|
|
|
12540
|
-
class
|
|
12540
|
+
class c03 {
|
|
12541
12541
|
_subscribers = [];
|
|
12542
12542
|
subscribe($3) {
|
|
12543
12543
|
return this._subscribers.push($3), () => {
|
|
@@ -12553,12 +12553,12 @@ class u03 {
|
|
|
12553
12553
|
this._subscribers.forEach((J2) => J2($3));
|
|
12554
12554
|
}
|
|
12555
12555
|
static create() {
|
|
12556
|
-
let $3 = new
|
|
12556
|
+
let $3 = new c03;
|
|
12557
12557
|
return { property: $3, emit: (J2) => $3.emit(J2) };
|
|
12558
12558
|
}
|
|
12559
12559
|
}
|
|
12560
12560
|
|
|
12561
|
-
class
|
|
12561
|
+
class Q$ extends Error {
|
|
12562
12562
|
name;
|
|
12563
12563
|
code;
|
|
12564
12564
|
source;
|
|
@@ -12583,7 +12583,7 @@ Context: ${JSON.stringify(this.context, null, 2)}`;
|
|
|
12583
12583
|
}
|
|
12584
12584
|
}
|
|
12585
12585
|
|
|
12586
|
-
class s3 extends
|
|
12586
|
+
class s3 extends Q$ {
|
|
12587
12587
|
constructor($3, J2) {
|
|
12588
12588
|
super("RpcError", $3, { ...J2, source: J2?.source ?? "RPC_REQUEST" });
|
|
12589
12589
|
}
|
|
@@ -12697,7 +12697,7 @@ class R03 {
|
|
|
12697
12697
|
let J2 = $3?.toLowerCase();
|
|
12698
12698
|
if (!this.websocketConnected)
|
|
12699
12699
|
await this.connect();
|
|
12700
|
-
let Q3 =
|
|
12700
|
+
let Q3 = c03.create(), Y2 = JSON.stringify(J2 ? { address: J2 } : {}), Z3 = (await this.sendMessage("eth_subscribe", ["circles", Y2])).result;
|
|
12701
12701
|
if (!this.subscriptionListeners[Z3])
|
|
12702
12702
|
this.subscriptionListeners[Z3] = [];
|
|
12703
12703
|
return this.subscriptionListeners[Z3].push((K2) => {
|
|
@@ -12750,7 +12750,7 @@ function M03($3, J2 = true) {
|
|
|
12750
12750
|
if (J2 && $3.finished)
|
|
12751
12751
|
throw Error("Hash#digest() has already been called");
|
|
12752
12752
|
}
|
|
12753
|
-
function
|
|
12753
|
+
function B$2($3, J2) {
|
|
12754
12754
|
K02($3);
|
|
12755
12755
|
let Q3 = J2.outputLen;
|
|
12756
12756
|
if ($3.length < Q3)
|
|
@@ -12763,7 +12763,7 @@ function X03(...$3) {
|
|
|
12763
12763
|
for (let J2 = 0;J2 < $3.length; J2++)
|
|
12764
12764
|
$3[J2].fill(0);
|
|
12765
12765
|
}
|
|
12766
|
-
function
|
|
12766
|
+
function C$2($3) {
|
|
12767
12767
|
return new DataView($3.buffer, $3.byteOffset, $3.byteLength);
|
|
12768
12768
|
}
|
|
12769
12769
|
function Z03($3, J2) {
|
|
@@ -12817,7 +12817,7 @@ function cJ2($3 = 32) {
|
|
|
12817
12817
|
throw Error("crypto.getRandomValues must be defined");
|
|
12818
12818
|
}
|
|
12819
12819
|
var l82 = BigInt(0);
|
|
12820
|
-
var
|
|
12820
|
+
var Y$2 = BigInt(1);
|
|
12821
12821
|
var p82 = BigInt(2);
|
|
12822
12822
|
var d82 = BigInt(7);
|
|
12823
12823
|
var i82 = BigInt(256);
|
|
@@ -12825,12 +12825,12 @@ var n82 = BigInt(113);
|
|
|
12825
12825
|
var dJ2 = [];
|
|
12826
12826
|
var iJ2 = [];
|
|
12827
12827
|
var nJ2 = [];
|
|
12828
|
-
for (let $3 = 0, J2 =
|
|
12828
|
+
for (let $3 = 0, J2 = Y$2, Q3 = 1, Y2 = 0;$3 < 24; $3++) {
|
|
12829
12829
|
[Q3, Y2] = [Y2, (2 * Q3 + 3 * Y2) % 5], dJ2.push(2 * (5 * Y2 + Q3)), iJ2.push(($3 + 1) * ($3 + 2) / 2 % 64);
|
|
12830
12830
|
let G2 = l82;
|
|
12831
12831
|
for (let Z3 = 0;Z3 < 7; Z3++)
|
|
12832
|
-
if (J2 = (J2 <<
|
|
12833
|
-
G2 ^=
|
|
12832
|
+
if (J2 = (J2 << Y$2 ^ (J2 >> d82) * n82) % i82, J2 & p82)
|
|
12833
|
+
G2 ^= Y$2 << (Y$2 << BigInt(Z3)) - Y$2;
|
|
12834
12834
|
nJ2.push(G2);
|
|
12835
12835
|
}
|
|
12836
12836
|
var oJ2 = bJ2(nJ2, true);
|
|
@@ -12844,9 +12844,9 @@ function a82($3, J2 = 24) {
|
|
|
12844
12844
|
for (let K2 = 0;K2 < 10; K2++)
|
|
12845
12845
|
Q3[K2] = $3[K2] ^ $3[K2 + 10] ^ $3[K2 + 20] ^ $3[K2 + 30] ^ $3[K2 + 40];
|
|
12846
12846
|
for (let K2 = 0;K2 < 10; K2 += 2) {
|
|
12847
|
-
let X4 = (K2 + 8) % 10, q3 = (K2 + 2) % 10, M2 = Q3[q3], j3 = Q3[q3 + 1],
|
|
12848
|
-
for (let
|
|
12849
|
-
$3[K2 +
|
|
12847
|
+
let X4 = (K2 + 8) % 10, q3 = (K2 + 2) % 10, M2 = Q3[q3], j3 = Q3[q3 + 1], N = lJ2(M2, j3, 1) ^ Q3[X4], D3 = pJ2(M2, j3, 1) ^ Q3[X4 + 1];
|
|
12848
|
+
for (let O4 = 0;O4 < 50; O4 += 10)
|
|
12849
|
+
$3[K2 + O4] ^= N, $3[K2 + O4 + 1] ^= D3;
|
|
12850
12850
|
}
|
|
12851
12851
|
let G2 = $3[2], Z3 = $3[3];
|
|
12852
12852
|
for (let K2 = 0;K2 < 24; K2++) {
|
|
@@ -12918,7 +12918,7 @@ class c$2 extends x03 {
|
|
|
12918
12918
|
return T03($3), this.xofInto(new Uint8Array($3));
|
|
12919
12919
|
}
|
|
12920
12920
|
digestInto($3) {
|
|
12921
|
-
if (
|
|
12921
|
+
if (B$2($3, this), this.finished)
|
|
12922
12922
|
throw Error("digest() was already called");
|
|
12923
12923
|
return this.writeInto($3), this.destroy(), $3;
|
|
12924
12924
|
}
|
|
@@ -12934,7 +12934,7 @@ class c$2 extends x03 {
|
|
|
12934
12934
|
}
|
|
12935
12935
|
}
|
|
12936
12936
|
var s82 = ($3, J2, Q3) => P$2(() => new c$2(J2, $3, Q3));
|
|
12937
|
-
var
|
|
12937
|
+
var l03 = (() => s82(1, 136, 32))();
|
|
12938
12938
|
var tJ2 = [];
|
|
12939
12939
|
for (let $3 = 0;$3 < 256; $3++)
|
|
12940
12940
|
tJ2[$3] = $3.toString(16).padStart(2, "0");
|
|
@@ -12954,8 +12954,8 @@ var u4 = 64;
|
|
|
12954
12954
|
var I$2 = 32;
|
|
12955
12955
|
var S$2 = ($3) => $3.startsWith("0x") ? $3.slice(2) : $3;
|
|
12956
12956
|
var q03 = ($3) => $3.toString(16).padStart(u4, "0");
|
|
12957
|
-
function
|
|
12958
|
-
let J2 = $3.toLowerCase().replace("0x", ""), Q3 = L$2(
|
|
12957
|
+
function C03($3) {
|
|
12958
|
+
let J2 = $3.toLowerCase().replace("0x", ""), Q3 = L$2(l03(new TextEncoder().encode(J2))).slice(2), Y2 = "0x";
|
|
12959
12959
|
for (let G2 = 0;G2 < J2.length; G2++)
|
|
12960
12960
|
Y2 += parseInt(Q3[G2], 16) >= 8 ? J2[G2].toUpperCase() : J2[G2];
|
|
12961
12961
|
return Y2;
|
|
@@ -12973,10 +12973,10 @@ function r82($3) {
|
|
|
12973
12973
|
return `${$3.name}(${Q3.join(",")})`;
|
|
12974
12974
|
}
|
|
12975
12975
|
function e82($3) {
|
|
12976
|
-
let J2 = r82($3), Q3 =
|
|
12976
|
+
let J2 = r82($3), Q3 = l03(new TextEncoder().encode(J2));
|
|
12977
12977
|
return L$2(Q3.slice(0, 4));
|
|
12978
12978
|
}
|
|
12979
|
-
function
|
|
12979
|
+
function p03($3, J2) {
|
|
12980
12980
|
if ($3 === "string" || $3 === "bytes")
|
|
12981
12981
|
return true;
|
|
12982
12982
|
if ($3.includes("[")) {
|
|
@@ -12985,16 +12985,16 @@ function l03($3, J2) {
|
|
|
12985
12985
|
return true;
|
|
12986
12986
|
if (Q3 === "tuple")
|
|
12987
12987
|
return aJ(J2);
|
|
12988
|
-
return
|
|
12988
|
+
return p03(Q3);
|
|
12989
12989
|
}
|
|
12990
12990
|
if ($3 === "tuple")
|
|
12991
12991
|
return aJ(J2);
|
|
12992
12992
|
return false;
|
|
12993
12993
|
}
|
|
12994
12994
|
function aJ($3) {
|
|
12995
|
-
return $3?.some((J2) =>
|
|
12995
|
+
return $3?.some((J2) => p03(J2.type, J2.components)) ?? false;
|
|
12996
12996
|
}
|
|
12997
|
-
function
|
|
12997
|
+
function B02($3, J2, Q3) {
|
|
12998
12998
|
if ($3 === "tuple" && Q3)
|
|
12999
12999
|
return JQ2(Q3, J2);
|
|
13000
13000
|
if ($3.includes("["))
|
|
@@ -13002,28 +13002,28 @@ function C03($3, J2, Q3) {
|
|
|
13002
13002
|
return QQ($3, J2);
|
|
13003
13003
|
}
|
|
13004
13004
|
function $Q2($3, J2, Q3) {
|
|
13005
|
-
let Y2 = $3.slice(0, $3.indexOf("[")), G2 = $3.endsWith("[]"), Z3 =
|
|
13005
|
+
let Y2 = $3.slice(0, $3.indexOf("[")), G2 = $3.endsWith("[]"), Z3 = p03(Y2, Q3), K2;
|
|
13006
13006
|
if (Z3) {
|
|
13007
|
-
let X4 = J2.map((j3) =>
|
|
13007
|
+
let X4 = J2.map((j3) => B02(Y2, j3, Q3)), q3 = J2.length * I$2;
|
|
13008
13008
|
K2 = X4.map((j3) => {
|
|
13009
|
-
let
|
|
13010
|
-
return q3 += j3.length / 2, q03(
|
|
13009
|
+
let N = q3;
|
|
13010
|
+
return q3 += j3.length / 2, q03(N);
|
|
13011
13011
|
}).join("") + X4.join("");
|
|
13012
13012
|
} else
|
|
13013
|
-
K2 = J2.map((X4) =>
|
|
13013
|
+
K2 = J2.map((X4) => B02(Y2, X4, Q3)).join("");
|
|
13014
13014
|
return G2 ? q03(J2.length) + K2 : K2;
|
|
13015
13015
|
}
|
|
13016
13016
|
function JQ2($3, J2) {
|
|
13017
13017
|
let Q3 = Array.isArray(J2), Y2 = [], G2 = [], Z3 = [];
|
|
13018
13018
|
for (let K2 = 0;K2 < $3.length; K2++) {
|
|
13019
|
-
let X4 = $3[K2], q3 = Q3 ? J2[K2] : J2[X4.name || ""], M2 =
|
|
13019
|
+
let X4 = $3[K2], q3 = Q3 ? J2[K2] : J2[X4.name || ""], M2 = p03(X4.type, X4.components);
|
|
13020
13020
|
if (Z3.push(M2), M2)
|
|
13021
|
-
Y2.push(""), G2.push(
|
|
13021
|
+
Y2.push(""), G2.push(B02(X4.type, q3, X4.components));
|
|
13022
13022
|
else
|
|
13023
|
-
Y2.push(
|
|
13023
|
+
Y2.push(B02(X4.type, q3, X4.components));
|
|
13024
13024
|
}
|
|
13025
13025
|
if (G2.length > 0) {
|
|
13026
|
-
let K2 = Y2.reduce((M2, j3,
|
|
13026
|
+
let K2 = Y2.reduce((M2, j3, N) => M2 + (Z3[N] ? I$2 : j3.length / 2), 0), X4 = "", q3 = 0;
|
|
13027
13027
|
for (let M2 = 0;M2 < $3.length; M2++)
|
|
13028
13028
|
if (Z3[M2])
|
|
13029
13029
|
X4 += q03(K2), K2 += G2[q3].length / 2, q3++;
|
|
@@ -13062,7 +13062,7 @@ function QQ($3, J2) {
|
|
|
13062
13062
|
}
|
|
13063
13063
|
throw Error(`Unsupported type: ${$3}`);
|
|
13064
13064
|
}
|
|
13065
|
-
function
|
|
13065
|
+
function G$($3, J2, Q3 = 0, Y2) {
|
|
13066
13066
|
if ($3 === "tuple" && Y2)
|
|
13067
13067
|
return GQ2(Y2, J2, Q3);
|
|
13068
13068
|
if ($3.includes("["))
|
|
@@ -13073,9 +13073,9 @@ function YQ2($3, J2, Q3, Y2) {
|
|
|
13073
13073
|
let G2 = $3.slice(0, $3.indexOf("[")), Z3 = J2.slice(Q3, Q3 + u4);
|
|
13074
13074
|
if ($3.endsWith("[]")) {
|
|
13075
13075
|
let X4 = parseInt(Z3, 16) * 2, q3 = parseInt(J2.slice(X4, X4 + u4), 16), M2 = [], j3 = X4 + u4;
|
|
13076
|
-
for (let
|
|
13077
|
-
let
|
|
13078
|
-
M2.push(
|
|
13076
|
+
for (let N = 0;N < q3; N++) {
|
|
13077
|
+
let D3 = G$(G2, J2, j3, Y2);
|
|
13078
|
+
M2.push(D3.value), j3 += D3.consumed;
|
|
13079
13079
|
}
|
|
13080
13080
|
return { value: M2, consumed: u4 };
|
|
13081
13081
|
}
|
|
@@ -13083,8 +13083,8 @@ function YQ2($3, J2, Q3, Y2) {
|
|
|
13083
13083
|
if (K2) {
|
|
13084
13084
|
let X4 = parseInt(K2[1]), q3 = [], M2 = 0;
|
|
13085
13085
|
for (let j3 = 0;j3 < X4; j3++) {
|
|
13086
|
-
let
|
|
13087
|
-
q3.push(
|
|
13086
|
+
let N = G$(G2, J2, Q3 + M2, Y2);
|
|
13087
|
+
q3.push(N.value), M2 += N.consumed;
|
|
13088
13088
|
}
|
|
13089
13089
|
return { value: q3, consumed: M2 };
|
|
13090
13090
|
}
|
|
@@ -13093,7 +13093,7 @@ function YQ2($3, J2, Q3, Y2) {
|
|
|
13093
13093
|
function GQ2($3, J2, Q3) {
|
|
13094
13094
|
let Y2 = [], G2 = Q3;
|
|
13095
13095
|
for (let Z3 of $3) {
|
|
13096
|
-
let K2 =
|
|
13096
|
+
let K2 = G$(Z3.type, J2, G2, Z3.components);
|
|
13097
13097
|
Y2.push(K2.value), G2 += K2.consumed;
|
|
13098
13098
|
}
|
|
13099
13099
|
return { value: Y2, consumed: G2 - Q3 };
|
|
@@ -13101,7 +13101,7 @@ function GQ2($3, J2, Q3) {
|
|
|
13101
13101
|
function ZQ2($3, J2, Q3) {
|
|
13102
13102
|
let Y2 = J2.slice(Q3, Q3 + u4);
|
|
13103
13103
|
if ($3 === "address")
|
|
13104
|
-
return { value:
|
|
13104
|
+
return { value: C03("0x" + Y2.slice(24)), consumed: u4 };
|
|
13105
13105
|
if ($3 === "bool")
|
|
13106
13106
|
return { value: parseInt(Y2, 16) !== 0, consumed: u4 };
|
|
13107
13107
|
if ($3.startsWith("uint"))
|
|
@@ -13125,7 +13125,7 @@ function ZQ2($3, J2, Q3) {
|
|
|
13125
13125
|
throw Error(`Unsupported type: ${$3}`);
|
|
13126
13126
|
}
|
|
13127
13127
|
function T$2($3) {
|
|
13128
|
-
let { abi: J2, functionName: Q3, args: Y2 = [] } = $3, G2 = J2.find((
|
|
13128
|
+
let { abi: J2, functionName: Q3, args: Y2 = [] } = $3, G2 = J2.find((O4) => O4.type === "function" && O4.name === Q3);
|
|
13129
13129
|
if (!G2)
|
|
13130
13130
|
throw Error(`Function "${Q3}" not found in ABI`);
|
|
13131
13131
|
let Z3 = e82(G2), K2 = G2.inputs || [];
|
|
@@ -13134,22 +13134,22 @@ function T$2($3) {
|
|
|
13134
13134
|
if (Y2.length !== K2.length)
|
|
13135
13135
|
throw Error(`Expected ${K2.length} arguments, got ${Y2.length}`);
|
|
13136
13136
|
let X4 = [], q3 = [], M2 = [];
|
|
13137
|
-
for (let
|
|
13138
|
-
let P = K2[
|
|
13137
|
+
for (let O4 = 0;O4 < K2.length; O4++) {
|
|
13138
|
+
let P = K2[O4], V3 = P.components, k4 = p03(P.type, V3);
|
|
13139
13139
|
if (M2.push(k4), k4)
|
|
13140
|
-
X4.push(""), q3.push(
|
|
13140
|
+
X4.push(""), q3.push(B02(P.type, Y2[O4], V3));
|
|
13141
13141
|
else
|
|
13142
|
-
X4.push(
|
|
13142
|
+
X4.push(B02(P.type, Y2[O4], V3));
|
|
13143
13143
|
}
|
|
13144
13144
|
if (q3.length === 0)
|
|
13145
13145
|
return Z3 + X4.join("");
|
|
13146
|
-
let j3 = X4.reduce((
|
|
13147
|
-
for (let
|
|
13148
|
-
if (M2[
|
|
13149
|
-
|
|
13146
|
+
let j3 = X4.reduce((O4, P, V3) => O4 + (M2[V3] ? I$2 : P.length / 2), 0), N = "", D3 = 0;
|
|
13147
|
+
for (let O4 = 0;O4 < K2.length; O4++)
|
|
13148
|
+
if (M2[O4])
|
|
13149
|
+
N += q03(j3), j3 += q3[D3].length / 2, D3++;
|
|
13150
13150
|
else
|
|
13151
|
-
|
|
13152
|
-
return Z3 +
|
|
13151
|
+
N += X4[O4];
|
|
13152
|
+
return Z3 + N + q3.join("");
|
|
13153
13153
|
}
|
|
13154
13154
|
function p$2($3) {
|
|
13155
13155
|
let { abi: J2, functionName: Q3, data: Y2 } = $3, G2 = J2.find((M2) => M2.type === "function" && M2.name === Q3);
|
|
@@ -13160,10 +13160,10 @@ function p$2($3) {
|
|
|
13160
13160
|
return;
|
|
13161
13161
|
let K2 = S$2(Y2);
|
|
13162
13162
|
if (Z3.length === 1)
|
|
13163
|
-
return
|
|
13163
|
+
return G$(Z3[0].type, K2, 0, Z3[0].components).value;
|
|
13164
13164
|
let X4 = [], q3 = 0;
|
|
13165
13165
|
for (let M2 of Z3) {
|
|
13166
|
-
let j3 =
|
|
13166
|
+
let j3 = G$(M2.type, K2, q3, M2.components);
|
|
13167
13167
|
X4.push(j3.value), q3 += j3.consumed;
|
|
13168
13168
|
}
|
|
13169
13169
|
return X4;
|
|
@@ -13173,11 +13173,11 @@ function Q03($3, J2) {
|
|
|
13173
13173
|
throw Error(`Type/value length mismatch: ${$3.length} types, ${J2.length} values`);
|
|
13174
13174
|
let Q3 = [], Y2 = [], G2 = [];
|
|
13175
13175
|
for (let q3 = 0;q3 < $3.length; q3++) {
|
|
13176
|
-
let M2 = $3[q3], j3 =
|
|
13176
|
+
let M2 = $3[q3], j3 = p03(M2);
|
|
13177
13177
|
if (G2.push(j3), j3)
|
|
13178
|
-
Q3.push(""), Y2.push(
|
|
13178
|
+
Q3.push(""), Y2.push(B02(M2, J2[q3]));
|
|
13179
13179
|
else
|
|
13180
|
-
Q3.push(
|
|
13180
|
+
Q3.push(B02(M2, J2[q3]));
|
|
13181
13181
|
}
|
|
13182
13182
|
if (Y2.length === 0)
|
|
13183
13183
|
return "0x" + Q3.join("");
|
|
@@ -13189,11 +13189,11 @@ function Q03($3, J2) {
|
|
|
13189
13189
|
K2 += Q3[q3];
|
|
13190
13190
|
return "0x" + K2 + Y2.join("");
|
|
13191
13191
|
}
|
|
13192
|
-
function
|
|
13192
|
+
function H5($3) {
|
|
13193
13193
|
return $3.toLowerCase();
|
|
13194
13194
|
}
|
|
13195
13195
|
function KQ2($3) {
|
|
13196
|
-
return
|
|
13196
|
+
return C03($3);
|
|
13197
13197
|
}
|
|
13198
13198
|
function XQ2($3) {
|
|
13199
13199
|
if (typeof $3 !== "string")
|
|
@@ -13201,24 +13201,24 @@ function XQ2($3) {
|
|
|
13201
13201
|
let J2 = $3.replace("0x", "");
|
|
13202
13202
|
return J2.length === 40 && /^[0-9a-fA-F]{40}$/.test(J2);
|
|
13203
13203
|
}
|
|
13204
|
-
function
|
|
13204
|
+
function g2($3) {
|
|
13205
13205
|
if ($3 === null || $3 === undefined)
|
|
13206
13206
|
return $3;
|
|
13207
13207
|
if (XQ2($3))
|
|
13208
13208
|
return KQ2($3);
|
|
13209
13209
|
if (Array.isArray($3))
|
|
13210
|
-
return $3.map((J2) =>
|
|
13210
|
+
return $3.map((J2) => g2(J2));
|
|
13211
13211
|
if (typeof $3 === "object" && $3 !== null) {
|
|
13212
13212
|
let J2 = {};
|
|
13213
13213
|
for (let Q3 in $3)
|
|
13214
13214
|
if (Object.prototype.hasOwnProperty.call($3, Q3))
|
|
13215
|
-
J2[Q3] =
|
|
13215
|
+
J2[Q3] = g2($3[Q3]);
|
|
13216
13216
|
return J2;
|
|
13217
13217
|
}
|
|
13218
13218
|
return $3;
|
|
13219
13219
|
}
|
|
13220
13220
|
function sJ2($3) {
|
|
13221
|
-
return { Source:
|
|
13221
|
+
return { Source: H5($3.from), Sink: H5($3.to), TargetFlow: $3.targetFlow.toString(), WithWrap: $3.useWrappedBalances, FromTokens: $3.fromTokens?.map(H5), ToTokens: $3.toTokens?.map(H5), ExcludedFromTokens: $3.excludeFromTokens?.map(H5), ExcludedToTokens: $3.excludeToTokens?.map(H5), SimulatedBalances: $3.simulatedBalances?.map((J2) => ({ Holder: H5(J2.holder), Token: H5(J2.token), Amount: J2.amount.toString(), IsWrapped: J2.isWrapped, IsStatic: J2.isStatic })), SimulatedTrusts: $3.simulatedTrusts?.map((J2) => ({ Truster: H5(J2.truster), Trustee: H5(J2.trustee) })), MaxTransfers: $3.maxTransfers };
|
|
13222
13222
|
}
|
|
13223
13223
|
function j03($3) {
|
|
13224
13224
|
let J2 = {};
|
|
@@ -13239,11 +13239,11 @@ function j03($3) {
|
|
|
13239
13239
|
}
|
|
13240
13240
|
var _$2 = "0x0000000000000000000000000000000000000000";
|
|
13241
13241
|
var p5 = BigInt(96) * BigInt(1000000000000000000);
|
|
13242
|
-
var
|
|
13242
|
+
var Z$ = BigInt("9999999999999999999999999999999999999");
|
|
13243
13243
|
var d$2 = "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67";
|
|
13244
13244
|
var i$2 = "0x89867a67674bd4bf33165a653cde826b696ab7d050166b71066dfa0b9b6f90f4";
|
|
13245
13245
|
var n$2 = "0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee";
|
|
13246
|
-
var
|
|
13246
|
+
var d03 = "0xc19bc204eb1c1d5b3fe500e5e5dfabab625f286c";
|
|
13247
13247
|
var E03 = "0x9Eb51E6A39B3F17bB1883B80748b56170039ff1d";
|
|
13248
13248
|
|
|
13249
13249
|
class W03 {
|
|
@@ -13253,29 +13253,29 @@ class W03 {
|
|
|
13253
13253
|
}
|
|
13254
13254
|
async findPath($3) {
|
|
13255
13255
|
let J2 = sJ2($3), Q3 = await this.client.call("circlesV2_findPath", [J2]), Y2 = j03(Q3);
|
|
13256
|
-
return
|
|
13256
|
+
return g2(Y2);
|
|
13257
13257
|
}
|
|
13258
13258
|
async findMaxFlow($3) {
|
|
13259
|
-
let J2 = await this.findPath({ ...$3, targetFlow:
|
|
13259
|
+
let J2 = await this.findPath({ ...$3, targetFlow: Z$ });
|
|
13260
13260
|
return BigInt(J2.maxFlow);
|
|
13261
13261
|
}
|
|
13262
13262
|
}
|
|
13263
13263
|
|
|
13264
|
-
class
|
|
13264
|
+
class K$2 {
|
|
13265
13265
|
client;
|
|
13266
13266
|
constructor($3) {
|
|
13267
13267
|
this.client = $3;
|
|
13268
13268
|
}
|
|
13269
13269
|
async query($3) {
|
|
13270
13270
|
let J2 = await this.client.call("circles_query", [$3]);
|
|
13271
|
-
return
|
|
13271
|
+
return g2(J2);
|
|
13272
13272
|
}
|
|
13273
13273
|
async tables() {
|
|
13274
13274
|
return this.client.call("circles_tables", []);
|
|
13275
13275
|
}
|
|
13276
13276
|
async events($3, J2, Q3 = null, Y2 = null, G2 = false) {
|
|
13277
13277
|
let Z3 = await this.client.call("circles_events", [$3, J2, Q3, Y2, G2]);
|
|
13278
|
-
return
|
|
13278
|
+
return g2(Z3);
|
|
13279
13279
|
}
|
|
13280
13280
|
}
|
|
13281
13281
|
var qQ2 = [{ name: "blockNumber", sortOrder: "DESC" }, { name: "transactionIndex", sortOrder: "DESC" }, { name: "logIndex", sortOrder: "DESC" }];
|
|
@@ -13394,50 +13394,50 @@ class k03 {
|
|
|
13394
13394
|
});
|
|
13395
13395
|
}
|
|
13396
13396
|
async getCommonTrust($3, J2) {
|
|
13397
|
-
let Q3 = await this.client.call("circles_getCommonTrust", [
|
|
13398
|
-
return
|
|
13397
|
+
let Q3 = await this.client.call("circles_getCommonTrust", [H5($3), H5(J2)]);
|
|
13398
|
+
return g2(Q3);
|
|
13399
13399
|
}
|
|
13400
13400
|
getTrustRelations($3, J2 = 100, Q3 = "DESC") {
|
|
13401
|
-
let Y2 =
|
|
13402
|
-
return new Y03(this.client, { namespace: "V_Crc", table: "TrustRelations", sortOrder: Q3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "version", "trustee", "truster", "expiryTime"], filter: G2, limit: J2 }, (Z3) =>
|
|
13401
|
+
let Y2 = H5($3), G2 = [{ 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: Y2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "truster", Value: Y2 }] }] }];
|
|
13402
|
+
return new Y03(this.client, { namespace: "V_Crc", table: "TrustRelations", sortOrder: Q3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "version", "trustee", "truster", "expiryTime"], filter: G2, limit: J2 }, (Z3) => g2(Z3));
|
|
13403
13403
|
}
|
|
13404
13404
|
async getAggregatedTrustRelations($3) {
|
|
13405
|
-
let J2 =
|
|
13405
|
+
let J2 = H5($3), Q3 = this.getTrustRelations(J2, 1000), Y2 = [];
|
|
13406
13406
|
while (await Q3.queryNextPage())
|
|
13407
13407
|
if (Y2.push(...Q3.currentPage.results), !Q3.currentPage.hasMore)
|
|
13408
13408
|
break;
|
|
13409
13409
|
let G2 = {};
|
|
13410
13410
|
Y2.forEach((K2) => {
|
|
13411
|
-
let X4 =
|
|
13411
|
+
let X4 = H5(K2.truster), q3 = H5(K2.trustee), M2 = X4 !== J2 ? K2.truster : K2.trustee;
|
|
13412
13412
|
if (!G2[M2])
|
|
13413
13413
|
G2[M2] = [];
|
|
13414
13414
|
G2[M2].push(K2);
|
|
13415
13415
|
});
|
|
13416
|
-
let Z3 = Object.entries(G2).filter(([K2]) =>
|
|
13416
|
+
let Z3 = Object.entries(G2).filter(([K2]) => H5(K2) !== J2).map(([K2, X4]) => {
|
|
13417
13417
|
let q3 = Math.max(...X4.map((j3) => j3.timestamp)), M2;
|
|
13418
13418
|
if (X4.length === 2)
|
|
13419
13419
|
M2 = "mutuallyTrusts";
|
|
13420
|
-
else if (
|
|
13420
|
+
else if (H5(X4[0]?.trustee) === J2)
|
|
13421
13421
|
M2 = "trustedBy";
|
|
13422
|
-
else if (
|
|
13422
|
+
else if (H5(X4[0]?.truster) === J2)
|
|
13423
13423
|
M2 = "trusts";
|
|
13424
13424
|
else
|
|
13425
13425
|
throw Error("Unexpected trust list row. Couldn't determine trust relation.");
|
|
13426
13426
|
return { subjectAvatar: J2, relation: M2, objectAvatar: K2, timestamp: q3 };
|
|
13427
13427
|
});
|
|
13428
|
-
return
|
|
13428
|
+
return g2(Z3);
|
|
13429
13429
|
}
|
|
13430
13430
|
async getTrustedBy($3) {
|
|
13431
|
-
let J2 =
|
|
13432
|
-
return
|
|
13431
|
+
let J2 = H5($3), Y2 = (await this.getAggregatedTrustRelations(J2)).filter((G2) => G2.relation === "trustedBy");
|
|
13432
|
+
return g2(Y2);
|
|
13433
13433
|
}
|
|
13434
13434
|
async getTrusts($3) {
|
|
13435
|
-
let J2 =
|
|
13436
|
-
return
|
|
13435
|
+
let J2 = H5($3), Y2 = (await this.getAggregatedTrustRelations(J2)).filter((G2) => G2.relation === "trusts");
|
|
13436
|
+
return g2(Y2);
|
|
13437
13437
|
}
|
|
13438
13438
|
async getMutualTrusts($3) {
|
|
13439
|
-
let J2 =
|
|
13440
|
-
return
|
|
13439
|
+
let J2 = H5($3), Y2 = (await this.getAggregatedTrustRelations(J2)).filter((G2) => G2.relation === "mutuallyTrusts");
|
|
13440
|
+
return g2(Y2);
|
|
13441
13441
|
}
|
|
13442
13442
|
}
|
|
13443
13443
|
|
|
@@ -13560,16 +13560,16 @@ class A02 {
|
|
|
13560
13560
|
this.client = $3;
|
|
13561
13561
|
}
|
|
13562
13562
|
async getTotalBalance($3, J2 = true) {
|
|
13563
|
-
let Q3 = await this.client.call("circlesV2_getTotalBalance", [
|
|
13563
|
+
let Q3 = await this.client.call("circlesV2_getTotalBalance", [H5($3), J2]);
|
|
13564
13564
|
return i4.circlesToAttoCircles(Q3);
|
|
13565
13565
|
}
|
|
13566
13566
|
async getTokenBalances($3) {
|
|
13567
|
-
let Q3 = (await this.client.call("circles_getTokenBalances", [
|
|
13568
|
-
return
|
|
13567
|
+
let Q3 = (await this.client.call("circles_getTokenBalances", [H5($3)])).map((Y2) => j03(Y2));
|
|
13568
|
+
return g2(Q3);
|
|
13569
13569
|
}
|
|
13570
13570
|
}
|
|
13571
13571
|
|
|
13572
|
-
class
|
|
13572
|
+
class X$2 {
|
|
13573
13573
|
client;
|
|
13574
13574
|
constructor($3) {
|
|
13575
13575
|
this.client = $3;
|
|
@@ -13581,16 +13581,16 @@ class K$2 {
|
|
|
13581
13581
|
async getAvatarInfoBatch($3) {
|
|
13582
13582
|
if ($3.length === 0)
|
|
13583
13583
|
return [];
|
|
13584
|
-
let J2 = $3.map((Y2) =>
|
|
13585
|
-
return
|
|
13584
|
+
let J2 = $3.map((Y2) => H5(Y2)), Q3 = await this.client.call("circles_getAvatarInfoBatch", [J2]);
|
|
13585
|
+
return g2(Q3);
|
|
13586
13586
|
}
|
|
13587
13587
|
async getNetworkSnapshot() {
|
|
13588
13588
|
let $3 = await this.client.call("circles_getNetworkSnapshot", []);
|
|
13589
|
-
return
|
|
13589
|
+
return g2($3);
|
|
13590
13590
|
}
|
|
13591
13591
|
}
|
|
13592
13592
|
|
|
13593
|
-
class
|
|
13593
|
+
class q$ {
|
|
13594
13594
|
client;
|
|
13595
13595
|
constructor($3) {
|
|
13596
13596
|
this.client = $3;
|
|
@@ -13602,10 +13602,10 @@ class X$2 {
|
|
|
13602
13602
|
return this.client.call("circles_getProfileByCidBatch", [$3]);
|
|
13603
13603
|
}
|
|
13604
13604
|
async getProfileByAddress($3) {
|
|
13605
|
-
return this.client.call("circles_getProfileByAddress", [
|
|
13605
|
+
return this.client.call("circles_getProfileByAddress", [H5($3)]);
|
|
13606
13606
|
}
|
|
13607
13607
|
async getProfileByAddressBatch($3) {
|
|
13608
|
-
return this.client.call("circles_getProfileByAddressBatch", [$3.map((J2) => J2 === null ? null :
|
|
13608
|
+
return this.client.call("circles_getProfileByAddressBatch", [$3.map((J2) => J2 === null ? null : H5(J2))]);
|
|
13609
13609
|
}
|
|
13610
13610
|
async searchProfiles($3, J2 = 10, Q3 = 0, Y2) {
|
|
13611
13611
|
return this.client.call("circles_searchProfiles", [$3.toLowerCase(), J2, Q3, Y2]);
|
|
@@ -13637,7 +13637,7 @@ class X$2 {
|
|
|
13637
13637
|
}
|
|
13638
13638
|
}
|
|
13639
13639
|
|
|
13640
|
-
class
|
|
13640
|
+
class w03 {
|
|
13641
13641
|
client;
|
|
13642
13642
|
constructor($3) {
|
|
13643
13643
|
this.client = $3;
|
|
@@ -13649,11 +13649,11 @@ class q$ {
|
|
|
13649
13649
|
async getTokenInfoBatch($3) {
|
|
13650
13650
|
if ($3.length === 0)
|
|
13651
13651
|
return [];
|
|
13652
|
-
let J2 = $3.map((G2) =>
|
|
13653
|
-
return
|
|
13652
|
+
let J2 = $3.map((G2) => H5(G2)), Y2 = (await this.client.call("circles_getTokenInfoBatch", [J2])).map((G2) => j03(G2));
|
|
13653
|
+
return g2(Y2);
|
|
13654
13654
|
}
|
|
13655
13655
|
getTokenHolders($3, J2 = 100, Q3 = "DESC") {
|
|
13656
|
-
let Y2 =
|
|
13656
|
+
let Y2 = H5($3);
|
|
13657
13657
|
return new Y03(this.client, { namespace: "V_CrcV2", table: "BalancesByAccountAndToken", columns: ["account", "tokenAddress", "demurragedTotalBalance"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "tokenAddress", Value: Y2 }], cursorColumns: [{ name: "demurragedTotalBalance", sortOrder: Q3 }, { name: "account", sortOrder: "ASC" }], orderColumns: [{ Column: "demurragedTotalBalance", SortOrder: Q3 }, { Column: "account", SortOrder: "ASC" }], limit: J2, sortOrder: Q3 }, (G2) => ({ account: G2.account, tokenAddress: G2.tokenAddress, demurragedTotalBalance: G2.demurragedTotalBalance }));
|
|
13658
13658
|
}
|
|
13659
13659
|
}
|
|
@@ -13673,13 +13673,13 @@ class M$ {
|
|
|
13673
13673
|
});
|
|
13674
13674
|
}
|
|
13675
13675
|
async getInvitedBy($3) {
|
|
13676
|
-
let J2 =
|
|
13676
|
+
let J2 = H5($3), Q3 = await this.client.call("circles_query", [{ Namespace: "CrcV2", Table: "RegisterHuman", Columns: ["inviter"], Filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "avatar", Value: J2 }], Order: [{ Column: "blockNumber", SortOrder: "DESC" }], Limit: 1 }]);
|
|
13677
13677
|
if (Q3.length > 0)
|
|
13678
|
-
return
|
|
13678
|
+
return g2(Q3[0].inviter);
|
|
13679
13679
|
return;
|
|
13680
13680
|
}
|
|
13681
13681
|
async getInvitations($3) {
|
|
13682
|
-
let J2 =
|
|
13682
|
+
let J2 = H5($3), Q3 = 96, Y2 = await this.client.call("circles_getAvatarInfoBatch", [[J2]]);
|
|
13683
13683
|
if ((Y2.length > 0 ? Y2[0] : undefined)?.version === 2)
|
|
13684
13684
|
return [];
|
|
13685
13685
|
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: [] }]), X4 = this.transformQueryResponse(Z3).map((j3) => j3.truster);
|
|
@@ -13689,23 +13689,23 @@ class M$ {
|
|
|
13689
13689
|
for (let j3 of q3) {
|
|
13690
13690
|
if (!j3?.isHuman)
|
|
13691
13691
|
continue;
|
|
13692
|
-
let
|
|
13693
|
-
if (
|
|
13692
|
+
let D3 = (await this.client.call("circles_getTokenBalances", [j3.avatar])).find((O4) => H5(O4.tokenAddress) === H5(j3.avatar));
|
|
13693
|
+
if (D3 && D3.circles >= 96)
|
|
13694
13694
|
M2.push(j3);
|
|
13695
13695
|
}
|
|
13696
|
-
return
|
|
13696
|
+
return g2(M2);
|
|
13697
13697
|
}
|
|
13698
13698
|
async getInvitationsFrom($3, J2 = false) {
|
|
13699
|
-
let Q3 =
|
|
13699
|
+
let Q3 = H5($3);
|
|
13700
13700
|
if (J2) {
|
|
13701
13701
|
let Y2 = await this.client.call("circles_query", [{ Namespace: "CrcV2", Table: "RegisterHuman", Columns: ["avatar"], Filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "inviter", Value: Q3 }], Order: [{ Column: "blockNumber", SortOrder: "DESC" }] }]), Z3 = this.transformQueryResponse(Y2).map((K2) => K2.avatar);
|
|
13702
|
-
return
|
|
13702
|
+
return g2(Z3);
|
|
13703
13703
|
} else {
|
|
13704
13704
|
let Y2 = 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: Q3 }] }], Order: [] }]), Z3 = this.transformQueryResponse(Y2).map((M2) => M2.trustee);
|
|
13705
13705
|
if (Z3.length === 0)
|
|
13706
13706
|
return [];
|
|
13707
|
-
let K2 = await this.client.call("circles_getAvatarInfoBatch", [Z3]), X4 = new Set(K2.filter((M2) => M2 !== null).map((M2) =>
|
|
13708
|
-
return
|
|
13707
|
+
let K2 = await this.client.call("circles_getAvatarInfoBatch", [Z3]), X4 = new Set(K2.filter((M2) => M2 !== null).map((M2) => H5(M2.avatar))), q3 = Z3.filter((M2) => !X4.has(H5(M2)));
|
|
13708
|
+
return g2(q3);
|
|
13709
13709
|
}
|
|
13710
13710
|
}
|
|
13711
13711
|
}
|
|
@@ -13720,15 +13720,15 @@ class j$2 {
|
|
|
13720
13720
|
this.client = $3;
|
|
13721
13721
|
}
|
|
13722
13722
|
getTransactionHistory($3, J2 = 50, Q3 = "DESC") {
|
|
13723
|
-
let Y2 =
|
|
13723
|
+
let Y2 = H5($3), G2 = [{ 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: Y2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "to", Value: Y2 }] }] }];
|
|
13724
13724
|
return new Y03(this.client, { namespace: "V_Crc", table: "TransferSummary", sortOrder: Q3, columns: [], filter: G2, limit: J2 }, (Z3) => {
|
|
13725
13725
|
let K2 = MQ(Z3.value, Z3.timestamp), X4 = { ...Z3, ...K2 };
|
|
13726
|
-
return
|
|
13726
|
+
return g2(X4);
|
|
13727
13727
|
});
|
|
13728
13728
|
}
|
|
13729
13729
|
}
|
|
13730
13730
|
|
|
13731
|
-
class
|
|
13731
|
+
class y03 {
|
|
13732
13732
|
client;
|
|
13733
13733
|
constructor($3) {
|
|
13734
13734
|
this.client = $3;
|
|
@@ -13744,19 +13744,19 @@ class w03 {
|
|
|
13744
13744
|
return Y2.slice(0, $3);
|
|
13745
13745
|
}
|
|
13746
13746
|
getGroupMemberships($3, J2 = 50, Q3 = "DESC") {
|
|
13747
|
-
let Y2 =
|
|
13748
|
-
return new Y03(this.client, { namespace: "V_CrcV2", table: "GroupMemberships", sortOrder: Q3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "member", "expiryTime"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "member", Value: Y2 }], limit: J2 }, (G2) =>
|
|
13747
|
+
let Y2 = H5($3);
|
|
13748
|
+
return new Y03(this.client, { namespace: "V_CrcV2", table: "GroupMemberships", sortOrder: Q3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "member", "expiryTime"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "member", Value: Y2 }], limit: J2 }, (G2) => g2(G2));
|
|
13749
13749
|
}
|
|
13750
13750
|
getGroupHolders($3, J2 = 100) {
|
|
13751
|
-
let Q3 =
|
|
13751
|
+
let Q3 = H5($3);
|
|
13752
13752
|
return new Y03(this.client, { namespace: "V_CrcV2", table: "GroupTokenHoldersBalance", sortOrder: "DESC", columns: ["group", "holder", "totalBalance", "demurragedTotalBalance", "fractionOwnership"], cursorColumns: [{ name: "holder", sortOrder: "ASC" }], orderColumns: [{ Column: "totalBalance", SortOrder: "DESC" }, { Column: "holder", SortOrder: "ASC" }], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: Q3 }], limit: J2, rowTransformer: (Y2) => {
|
|
13753
13753
|
let G2 = { ...Y2, totalBalance: BigInt(Y2.totalBalance), demurragedTotalBalance: BigInt(Y2.demurragedTotalBalance) };
|
|
13754
|
-
return
|
|
13754
|
+
return g2(G2);
|
|
13755
13755
|
} });
|
|
13756
13756
|
}
|
|
13757
13757
|
getGroupMembers($3, J2 = 100, Q3 = "DESC") {
|
|
13758
|
-
let Y2 =
|
|
13759
|
-
return new Y03(this.client, { namespace: "V_CrcV2", table: "GroupMemberships", sortOrder: Q3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "member", "expiryTime"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: Y2 }], limit: J2 }, (G2) =>
|
|
13758
|
+
let Y2 = H5($3);
|
|
13759
|
+
return new Y03(this.client, { namespace: "V_CrcV2", table: "GroupMemberships", sortOrder: Q3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "member", "expiryTime"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: Y2 }], limit: J2 }, (G2) => g2(G2));
|
|
13760
13760
|
}
|
|
13761
13761
|
getGroups($3 = 50, J2, Q3 = "DESC") {
|
|
13762
13762
|
let Y2 = [];
|
|
@@ -13766,7 +13766,7 @@ class w03 {
|
|
|
13766
13766
|
if (J2.symbolStartsWith)
|
|
13767
13767
|
Y2.push({ Type: "FilterPredicate", FilterType: "Like", Column: "symbol", Value: J2.symbolStartsWith + "%" });
|
|
13768
13768
|
if (J2.groupAddressIn && J2.groupAddressIn.length > 0) {
|
|
13769
|
-
let Z3 = J2.groupAddressIn.map((K2) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value:
|
|
13769
|
+
let Z3 = J2.groupAddressIn.map((K2) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: H5(K2) }));
|
|
13770
13770
|
if (Z3.length === 1)
|
|
13771
13771
|
Y2.push(Z3[0]);
|
|
13772
13772
|
else
|
|
@@ -13780,19 +13780,19 @@ class w03 {
|
|
|
13780
13780
|
Y2.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: Z3 });
|
|
13781
13781
|
}
|
|
13782
13782
|
if (J2.ownerIn && J2.ownerIn.length > 0) {
|
|
13783
|
-
let Z3 = J2.ownerIn.map((K2) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "owner", Value:
|
|
13783
|
+
let Z3 = J2.ownerIn.map((K2) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "owner", Value: H5(K2) }));
|
|
13784
13784
|
if (Z3.length === 1)
|
|
13785
13785
|
Y2.push(Z3[0]);
|
|
13786
13786
|
else
|
|
13787
13787
|
Y2.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: Z3 });
|
|
13788
13788
|
}
|
|
13789
13789
|
if (J2.mintHandlerEquals)
|
|
13790
|
-
Y2.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "mintHandler", Value:
|
|
13790
|
+
Y2.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "mintHandler", Value: H5(J2.mintHandlerEquals) });
|
|
13791
13791
|
if (J2.treasuryEquals)
|
|
13792
|
-
Y2.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "treasury", Value:
|
|
13792
|
+
Y2.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "treasury", Value: H5(J2.treasuryEquals) });
|
|
13793
13793
|
}
|
|
13794
13794
|
let G2 = Y2.length > 1 ? [{ Type: "Conjunction", ConjunctionType: "And", Predicates: Y2 }] : Y2;
|
|
13795
|
-
return new Y03(this.client, { namespace: "V_CrcV2", table: "Groups", sortOrder: Q3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "type", "owner", "mintPolicy", "mintHandler", "treasury", "service", "feeCollection", "memberCount", "name", "symbol", "cidV0Digest", "erc20WrapperDemurraged", "erc20WrapperStatic"], filter: G2, limit: $3 }, (Z3) =>
|
|
13795
|
+
return new Y03(this.client, { namespace: "V_CrcV2", table: "Groups", sortOrder: Q3, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "type", "owner", "mintPolicy", "mintHandler", "treasury", "service", "feeCollection", "memberCount", "name", "symbol", "cidV0Digest", "erc20WrapperDemurraged", "erc20WrapperStatic"], filter: G2, limit: $3 }, (Z3) => g2(Z3));
|
|
13796
13796
|
}
|
|
13797
13797
|
}
|
|
13798
13798
|
|
|
@@ -13818,7 +13818,7 @@ class x$2 {
|
|
|
13818
13818
|
}
|
|
13819
13819
|
get query() {
|
|
13820
13820
|
if (!this._query)
|
|
13821
|
-
this._query = new
|
|
13821
|
+
this._query = new K$2(this.client);
|
|
13822
13822
|
return this._query;
|
|
13823
13823
|
}
|
|
13824
13824
|
get trust() {
|
|
@@ -13833,17 +13833,17 @@ class x$2 {
|
|
|
13833
13833
|
}
|
|
13834
13834
|
get avatar() {
|
|
13835
13835
|
if (!this._avatar)
|
|
13836
|
-
this._avatar = new
|
|
13836
|
+
this._avatar = new X$2(this.client);
|
|
13837
13837
|
return this._avatar;
|
|
13838
13838
|
}
|
|
13839
13839
|
get profile() {
|
|
13840
13840
|
if (!this._profile)
|
|
13841
|
-
this._profile = new
|
|
13841
|
+
this._profile = new q$(this.client);
|
|
13842
13842
|
return this._profile;
|
|
13843
13843
|
}
|
|
13844
13844
|
get token() {
|
|
13845
13845
|
if (!this._token)
|
|
13846
|
-
this._token = new
|
|
13846
|
+
this._token = new w03(this.client);
|
|
13847
13847
|
return this._token;
|
|
13848
13848
|
}
|
|
13849
13849
|
get invitation() {
|
|
@@ -13858,7 +13858,7 @@ class x$2 {
|
|
|
13858
13858
|
}
|
|
13859
13859
|
get group() {
|
|
13860
13860
|
if (!this._group)
|
|
13861
|
-
this._group = new
|
|
13861
|
+
this._group = new y03(this.client);
|
|
13862
13862
|
return this._group;
|
|
13863
13863
|
}
|
|
13864
13864
|
setRpcUrl($3) {
|
|
@@ -13937,7 +13937,7 @@ class E$2 extends n5 {
|
|
|
13937
13937
|
}
|
|
13938
13938
|
var o$2 = [{ type: "function", name: "unwrap", inputs: [{ name: "_amount", type: "uint256" }], outputs: [], stateMutability: "nonpayable" }];
|
|
13939
13939
|
|
|
13940
|
-
class
|
|
13940
|
+
class i03 extends n5 {
|
|
13941
13941
|
constructor($3) {
|
|
13942
13942
|
super({ address: $3.address, abi: o$2, rpcUrl: $3.rpcUrl });
|
|
13943
13943
|
}
|
|
@@ -13946,7 +13946,7 @@ class d03 extends n5 {
|
|
|
13946
13946
|
}
|
|
13947
13947
|
}
|
|
13948
13948
|
|
|
13949
|
-
class
|
|
13949
|
+
class n03 extends n5 {
|
|
13950
13950
|
constructor($3) {
|
|
13951
13951
|
super({ address: $3.address, abi: o$2, rpcUrl: $3.rpcUrl });
|
|
13952
13952
|
}
|
|
@@ -13959,7 +13959,7 @@ var a$2 = [{ type: "function", name: "claimInvite", inputs: [], outputs: [{ name
|
|
|
13959
13959
|
var s$2 = [{ 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" }];
|
|
13960
13960
|
var r$2 = [{ type: "function", name: "trustInviter", inputs: [{ name: "inviter", type: "address" }], outputs: [], stateMutability: "nonpayable" }];
|
|
13961
13961
|
|
|
13962
|
-
class
|
|
13962
|
+
class o03 extends n5 {
|
|
13963
13963
|
constructor($3) {
|
|
13964
13964
|
super({ address: $3.address, abi: t$2, rpcUrl: $3.rpcUrl });
|
|
13965
13965
|
}
|
|
@@ -13971,7 +13971,7 @@ class n03 extends n5 {
|
|
|
13971
13971
|
}
|
|
13972
13972
|
}
|
|
13973
13973
|
|
|
13974
|
-
class
|
|
13974
|
+
class t03 extends n5 {
|
|
13975
13975
|
constructor($3) {
|
|
13976
13976
|
super({ address: $3.address, abi: a$2, rpcUrl: $3.rpcUrl });
|
|
13977
13977
|
}
|
|
@@ -14053,7 +14053,7 @@ function J82($3, J2, Q3) {
|
|
|
14053
14053
|
class e$2 extends x03 {
|
|
14054
14054
|
constructor($3, J2, Q3, Y2) {
|
|
14055
14055
|
super();
|
|
14056
|
-
this.finished = false, this.length = 0, this.pos = 0, this.destroyed = false, this.blockLen = $3, this.outputLen = J2, this.padOffset = Q3, this.isLE = Y2, this.buffer = new Uint8Array($3), this.view =
|
|
14056
|
+
this.finished = false, this.length = 0, this.pos = 0, this.destroyed = false, this.blockLen = $3, this.outputLen = J2, this.padOffset = Q3, this.isLE = Y2, this.buffer = new Uint8Array($3), this.view = C$2(this.buffer);
|
|
14057
14057
|
}
|
|
14058
14058
|
update($3) {
|
|
14059
14059
|
M03(this), $3 = _03($3), K02($3);
|
|
@@ -14061,7 +14061,7 @@ class e$2 extends x03 {
|
|
|
14061
14061
|
for (let Z3 = 0;Z3 < G2; ) {
|
|
14062
14062
|
let K2 = Math.min(Y2 - this.pos, G2 - Z3);
|
|
14063
14063
|
if (K2 === Y2) {
|
|
14064
|
-
let X4 =
|
|
14064
|
+
let X4 = C$2($3);
|
|
14065
14065
|
for (;Y2 <= G2 - Z3; Z3 += Y2)
|
|
14066
14066
|
this.process(X4, Z3);
|
|
14067
14067
|
continue;
|
|
@@ -14072,14 +14072,14 @@ class e$2 extends x03 {
|
|
|
14072
14072
|
return this.length += $3.length, this.roundClean(), this;
|
|
14073
14073
|
}
|
|
14074
14074
|
digestInto($3) {
|
|
14075
|
-
M03(this),
|
|
14075
|
+
M03(this), B$2($3, this), this.finished = true;
|
|
14076
14076
|
let { buffer: J2, view: Q3, blockLen: Y2, isLE: G2 } = this, { pos: Z3 } = this;
|
|
14077
14077
|
if (J2[Z3++] = 128, X03(this.buffer.subarray(Z3)), this.padOffset > Y2 - Z3)
|
|
14078
14078
|
this.process(Q3, 0), Z3 = 0;
|
|
14079
14079
|
for (let j3 = Z3;j3 < Y2; j3++)
|
|
14080
14080
|
J2[j3] = 0;
|
|
14081
14081
|
jQ(Q3, Y2 - 8, BigInt(this.length * 8), G2), this.process(Q3, 0);
|
|
14082
|
-
let K2 =
|
|
14082
|
+
let K2 = C$2($3), X4 = this.outputLen;
|
|
14083
14083
|
if (X4 % 4)
|
|
14084
14084
|
throw Error("_sha2: outputLen should be aligned to 32bit");
|
|
14085
14085
|
let q3 = X4 / 4, M2 = this.get();
|
|
@@ -14125,13 +14125,13 @@ class Q82 extends e$2 {
|
|
|
14125
14125
|
for (let j3 = 0;j3 < 16; j3++, J2 += 4)
|
|
14126
14126
|
L03[j3] = $3.getUint32(J2, false);
|
|
14127
14127
|
for (let j3 = 16;j3 < 64; j3++) {
|
|
14128
|
-
let
|
|
14129
|
-
L03[j3] = P + L03[j3 - 7] +
|
|
14128
|
+
let N = L03[j3 - 15], D3 = L03[j3 - 2], O4 = Z03(N, 7) ^ Z03(N, 18) ^ N >>> 3, P = Z03(D3, 17) ^ Z03(D3, 19) ^ D3 >>> 10;
|
|
14129
|
+
L03[j3] = P + L03[j3 - 7] + O4 + L03[j3 - 16] | 0;
|
|
14130
14130
|
}
|
|
14131
14131
|
let { A: Q3, B: Y2, C: G2, D: Z3, E: K2, F: X4, G: q3, H: M2 } = this;
|
|
14132
14132
|
for (let j3 = 0;j3 < 64; j3++) {
|
|
14133
|
-
let
|
|
14134
|
-
M2 = q3, q3 = X4, X4 = K2, K2 = Z3 +
|
|
14133
|
+
let N = Z03(K2, 6) ^ Z03(K2, 11) ^ Z03(K2, 25), D3 = M2 + N + $82(K2, X4, q3) + WQ2[j3] + L03[j3] | 0, P = (Z03(Q3, 2) ^ Z03(Q3, 13) ^ Z03(Q3, 22)) + J82(Q3, Y2, G2) | 0;
|
|
14134
|
+
M2 = q3, q3 = X4, X4 = K2, K2 = Z3 + D3 | 0, Z3 = G2, G2 = Y2, Y2 = Q3, Q3 = D3 + P | 0;
|
|
14135
14135
|
}
|
|
14136
14136
|
Q3 = Q3 + this.A | 0, Y2 = Y2 + this.B | 0, G2 = G2 + this.C | 0, Z3 = Z3 + this.D | 0, K2 = K2 + this.E | 0, X4 = X4 + this.F | 0, q3 = q3 + this.G | 0, M2 = M2 + this.H | 0, this.set(Q3, Y2, G2, Z3, K2, X4, q3, M2);
|
|
14137
14137
|
}
|
|
@@ -14188,14 +14188,14 @@ JJ2.create = ($3, J2) => new $J3($3, J2);
|
|
|
14188
14188
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14189
14189
|
var ZJ3 = BigInt(0);
|
|
14190
14190
|
var GJ3 = BigInt(1);
|
|
14191
|
-
function
|
|
14191
|
+
function a03($3) {
|
|
14192
14192
|
return $3 instanceof Uint8Array || ArrayBuffer.isView($3) && $3.constructor.name === "Uint8Array";
|
|
14193
14193
|
}
|
|
14194
14194
|
function KJ3($3) {
|
|
14195
|
-
if (!
|
|
14195
|
+
if (!a03($3))
|
|
14196
14196
|
throw Error("Uint8Array expected");
|
|
14197
14197
|
}
|
|
14198
|
-
function
|
|
14198
|
+
function s03($3, J2) {
|
|
14199
14199
|
if (typeof J2 !== "boolean")
|
|
14200
14200
|
throw Error($3 + " boolean expected, got " + J2);
|
|
14201
14201
|
}
|
|
@@ -14210,7 +14210,7 @@ function K82($3) {
|
|
|
14210
14210
|
}
|
|
14211
14211
|
var X82 = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
|
|
14212
14212
|
var UQ = Array.from({ length: 256 }, ($3, J2) => J2.toString(16).padStart(2, "0"));
|
|
14213
|
-
function
|
|
14213
|
+
function r03($3) {
|
|
14214
14214
|
if (KJ3($3), X82)
|
|
14215
14215
|
return $3.toHex();
|
|
14216
14216
|
let J2 = "";
|
|
@@ -14248,16 +14248,16 @@ function U$($3) {
|
|
|
14248
14248
|
return Y2;
|
|
14249
14249
|
}
|
|
14250
14250
|
function N03($3) {
|
|
14251
|
-
return K82(
|
|
14251
|
+
return K82(r03($3));
|
|
14252
14252
|
}
|
|
14253
14253
|
function XJ3($3) {
|
|
14254
|
-
return KJ3($3), K82(
|
|
14254
|
+
return KJ3($3), K82(r03(Uint8Array.from($3).reverse()));
|
|
14255
14255
|
}
|
|
14256
|
-
function
|
|
14256
|
+
function b03($3, J2) {
|
|
14257
14257
|
return U$($3.toString(16).padStart(J2 * 2, "0"));
|
|
14258
14258
|
}
|
|
14259
14259
|
function qJ3($3, J2) {
|
|
14260
|
-
return
|
|
14260
|
+
return b03($3, J2).reverse();
|
|
14261
14261
|
}
|
|
14262
14262
|
function J03($3, J2, Q3) {
|
|
14263
14263
|
let Y2;
|
|
@@ -14267,7 +14267,7 @@ function J03($3, J2, Q3) {
|
|
|
14267
14267
|
} catch (Z3) {
|
|
14268
14268
|
throw Error($3 + " must be hex string or Uint8Array, cause: " + Z3);
|
|
14269
14269
|
}
|
|
14270
|
-
else if (
|
|
14270
|
+
else if (a03(J2))
|
|
14271
14271
|
Y2 = Uint8Array.from(J2);
|
|
14272
14272
|
else
|
|
14273
14273
|
throw Error($3 + " must be hex string or Uint8Array");
|
|
@@ -14293,7 +14293,7 @@ var QJ3 = ($3) => typeof $3 === "bigint" && ZJ3 <= $3;
|
|
|
14293
14293
|
function y$2($3, J2, Q3) {
|
|
14294
14294
|
return QJ3($3) && QJ3(J2) && QJ3(Q3) && J2 <= $3 && $3 < Q3;
|
|
14295
14295
|
}
|
|
14296
|
-
function
|
|
14296
|
+
function F03($3, J2, Q3, Y2) {
|
|
14297
14297
|
if (!y$2(J2, Q3, Y2))
|
|
14298
14298
|
throw Error("expected valid " + $3 + ": " + Q3 + " <= n < " + Y2 + ", got " + J2);
|
|
14299
14299
|
}
|
|
@@ -14303,7 +14303,7 @@ function q82($3) {
|
|
|
14303
14303
|
;
|
|
14304
14304
|
return J2;
|
|
14305
14305
|
}
|
|
14306
|
-
var
|
|
14306
|
+
var g03 = ($3) => (GJ3 << BigInt($3)) - GJ3;
|
|
14307
14307
|
var YJ3 = ($3) => new Uint8Array($3);
|
|
14308
14308
|
var Z82 = ($3) => Uint8Array.from($3);
|
|
14309
14309
|
function M82($3, J2, Q3) {
|
|
@@ -14315,31 +14315,31 @@ function M82($3, J2, Q3) {
|
|
|
14315
14315
|
throw Error("hmacFn must be a function");
|
|
14316
14316
|
let Y2 = YJ3($3), G2 = YJ3($3), Z3 = 0, K2 = () => {
|
|
14317
14317
|
Y2.fill(1), G2.fill(0), Z3 = 0;
|
|
14318
|
-
}, X4 = (...
|
|
14319
|
-
if (G2 = X4(Z82([0]),
|
|
14318
|
+
}, X4 = (...N) => Q3(G2, Y2, ...N), q3 = (N = YJ3(0)) => {
|
|
14319
|
+
if (G2 = X4(Z82([0]), N), Y2 = X4(), N.length === 0)
|
|
14320
14320
|
return;
|
|
14321
|
-
G2 = X4(Z82([1]),
|
|
14321
|
+
G2 = X4(Z82([1]), N), Y2 = X4();
|
|
14322
14322
|
}, M2 = () => {
|
|
14323
14323
|
if (Z3++ >= 1000)
|
|
14324
14324
|
throw Error("drbg: tried 1000 values");
|
|
14325
|
-
let
|
|
14326
|
-
while (
|
|
14325
|
+
let N = 0, D3 = [];
|
|
14326
|
+
while (N < J2) {
|
|
14327
14327
|
Y2 = X4();
|
|
14328
|
-
let
|
|
14329
|
-
|
|
14328
|
+
let O4 = Y2.slice();
|
|
14329
|
+
D3.push(O4), N += Y2.length;
|
|
14330
14330
|
}
|
|
14331
|
-
return z$2(...
|
|
14331
|
+
return z$2(...D3);
|
|
14332
14332
|
};
|
|
14333
|
-
return (
|
|
14334
|
-
K2(), q3(
|
|
14335
|
-
let
|
|
14336
|
-
while (!(
|
|
14333
|
+
return (N, D3) => {
|
|
14334
|
+
K2(), q3(N);
|
|
14335
|
+
let O4 = undefined;
|
|
14336
|
+
while (!(O4 = D3(M2())))
|
|
14337
14337
|
q3();
|
|
14338
|
-
return K2(),
|
|
14338
|
+
return K2(), O4;
|
|
14339
14339
|
};
|
|
14340
14340
|
}
|
|
14341
|
-
var zQ = { 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" ||
|
|
14342
|
-
function
|
|
14341
|
+
var zQ = { 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" || a03($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) };
|
|
14342
|
+
function f03($3, J2, Q3 = {}) {
|
|
14343
14343
|
let Y2 = (G2, Z3, K2) => {
|
|
14344
14344
|
let X4 = zQ[Z3];
|
|
14345
14345
|
if (typeof X4 !== "function")
|
|
@@ -14369,7 +14369,7 @@ function MJ2($3) {
|
|
|
14369
14369
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14370
14370
|
var r4 = BigInt(0);
|
|
14371
14371
|
var t4 = BigInt(1);
|
|
14372
|
-
var
|
|
14372
|
+
var v03 = BigInt(2);
|
|
14373
14373
|
var NQ2 = BigInt(3);
|
|
14374
14374
|
var W82 = BigInt(4);
|
|
14375
14375
|
var U82 = BigInt(5);
|
|
@@ -14391,8 +14391,8 @@ function b$2($3, J2) {
|
|
|
14391
14391
|
throw Error("invert: expected positive modulus, got " + J2);
|
|
14392
14392
|
let Q3 = o4($3, J2), Y2 = J2, G2 = r4, Z3 = t4, K2 = t4, X4 = r4;
|
|
14393
14393
|
while (Q3 !== r4) {
|
|
14394
|
-
let M2 = Y2 / Q3, j3 = Y2 % Q3,
|
|
14395
|
-
Y2 = Q3, Q3 = j3, G2 = K2, Z3 = X4, K2 =
|
|
14394
|
+
let M2 = Y2 / Q3, j3 = Y2 % Q3, N = G2 - K2 * M2, D3 = Z3 - X4 * M2;
|
|
14395
|
+
Y2 = Q3, Q3 = j3, G2 = K2, Z3 = X4, K2 = N, X4 = D3;
|
|
14396
14396
|
}
|
|
14397
14397
|
if (Y2 !== t4)
|
|
14398
14398
|
throw Error("invert: does not exist");
|
|
@@ -14405,7 +14405,7 @@ function N83($3, J2) {
|
|
|
14405
14405
|
return Y2;
|
|
14406
14406
|
}
|
|
14407
14407
|
function DQ($3, J2) {
|
|
14408
|
-
let Q3 = ($3.ORDER - U82) / z82, Y2 = $3.mul(J2,
|
|
14408
|
+
let Q3 = ($3.ORDER - U82) / z82, Y2 = $3.mul(J2, v03), G2 = $3.pow(Y2, Q3), Z3 = $3.mul(J2, G2), K2 = $3.mul($3.mul(Z3, v03), G2), X4 = $3.mul(Z3, $3.sub(K2, $3.ONE));
|
|
14409
14409
|
if (!$3.eql($3.sqr(X4), J2))
|
|
14410
14410
|
throw Error("Cannot find square root");
|
|
14411
14411
|
return X4;
|
|
@@ -14414,32 +14414,32 @@ function VQ($3) {
|
|
|
14414
14414
|
if ($3 < BigInt(3))
|
|
14415
14415
|
throw Error("sqrt is not defined for small field");
|
|
14416
14416
|
let J2 = $3 - t4, Q3 = 0;
|
|
14417
|
-
while (J2 %
|
|
14418
|
-
J2 /=
|
|
14419
|
-
let Y2 =
|
|
14417
|
+
while (J2 % v03 === r4)
|
|
14418
|
+
J2 /= v03, Q3++;
|
|
14419
|
+
let Y2 = v03, G2 = N$2($3);
|
|
14420
14420
|
while (j82(G2, Y2) === 1)
|
|
14421
14421
|
if (Y2++ > 1000)
|
|
14422
14422
|
throw Error("Cannot find square root: probably non-prime P");
|
|
14423
14423
|
if (Q3 === 1)
|
|
14424
14424
|
return N83;
|
|
14425
|
-
let Z3 = G2.pow(Y2, J2), K2 = (J2 + t4) /
|
|
14425
|
+
let Z3 = G2.pow(Y2, J2), K2 = (J2 + t4) / v03;
|
|
14426
14426
|
return function(q3, M2) {
|
|
14427
14427
|
if (q3.is0(M2))
|
|
14428
14428
|
return M2;
|
|
14429
14429
|
if (j82(q3, M2) !== 1)
|
|
14430
14430
|
throw Error("Cannot find square root");
|
|
14431
|
-
let j3 = Q3,
|
|
14432
|
-
while (!q3.eql(
|
|
14433
|
-
if (q3.is0(
|
|
14431
|
+
let j3 = Q3, N = q3.mul(q3.ONE, Z3), D3 = q3.pow(M2, J2), O4 = q3.pow(M2, K2);
|
|
14432
|
+
while (!q3.eql(D3, q3.ONE)) {
|
|
14433
|
+
if (q3.is0(D3))
|
|
14434
14434
|
return q3.ZERO;
|
|
14435
|
-
let P = 1, V3 = q3.sqr(
|
|
14435
|
+
let P = 1, V3 = q3.sqr(D3);
|
|
14436
14436
|
while (!q3.eql(V3, q3.ONE))
|
|
14437
14437
|
if (P++, V3 = q3.sqr(V3), P === j3)
|
|
14438
14438
|
throw Error("Cannot find square root");
|
|
14439
|
-
let k4 = t4 << BigInt(j3 - P - 1),
|
|
14440
|
-
j3 = P,
|
|
14439
|
+
let k4 = t4 << BigInt(j3 - P - 1), T4 = q3.pow(N, k4);
|
|
14440
|
+
j3 = P, N = q3.sqr(T4), D3 = q3.mul(D3, N), O4 = q3.mul(O4, T4);
|
|
14441
14441
|
}
|
|
14442
|
-
return
|
|
14442
|
+
return O4;
|
|
14443
14443
|
};
|
|
14444
14444
|
}
|
|
14445
14445
|
function OQ($3) {
|
|
@@ -14454,9 +14454,9 @@ function jJ3($3) {
|
|
|
14454
14454
|
let J2 = { ORDER: "bigint", MASK: "bigint", BYTES: "isSafeInteger", BITS: "isSafeInteger" }, Q3 = RQ.reduce((Y2, G2) => {
|
|
14455
14455
|
return Y2[G2] = "function", Y2;
|
|
14456
14456
|
}, J2);
|
|
14457
|
-
return
|
|
14457
|
+
return f03($3, Q3);
|
|
14458
14458
|
}
|
|
14459
|
-
function
|
|
14459
|
+
function BQ2($3, J2, Q3) {
|
|
14460
14460
|
if (Q3 < r4)
|
|
14461
14461
|
throw Error("invalid exponent, negatives unsupported");
|
|
14462
14462
|
if (Q3 === r4)
|
|
@@ -14484,7 +14484,7 @@ function WJ2($3, J2, Q3 = false) {
|
|
|
14484
14484
|
}, Z3), Y2;
|
|
14485
14485
|
}
|
|
14486
14486
|
function j82($3, J2) {
|
|
14487
|
-
let Q3 = ($3.ORDER - t4) /
|
|
14487
|
+
let Q3 = ($3.ORDER - t4) / v03, Y2 = $3.pow(J2, Q3), G2 = $3.eql(Y2, $3.ONE), Z3 = $3.eql(Y2, $3.ZERO), K2 = $3.eql(Y2, $3.neg($3.ONE));
|
|
14488
14488
|
if (!G2 && !Z3 && !K2)
|
|
14489
14489
|
throw Error("invalid Legendre symbol result");
|
|
14490
14490
|
return G2 ? 1 : Z3 ? 0 : -1;
|
|
@@ -14501,15 +14501,15 @@ function N$2($3, J2, Q3 = false, Y2 = {}) {
|
|
|
14501
14501
|
let { nBitLength: G2, nByteLength: Z3 } = UJ2($3, J2);
|
|
14502
14502
|
if (Z3 > 2048)
|
|
14503
14503
|
throw Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
14504
|
-
let K2, X4 = Object.freeze({ ORDER: $3, isLE: Q3, BITS: G2, BYTES: Z3, MASK:
|
|
14504
|
+
let K2, X4 = Object.freeze({ ORDER: $3, isLE: Q3, BITS: G2, BYTES: Z3, MASK: g03(G2), ZERO: r4, ONE: t4, create: (q3) => o4(q3, $3), isValid: (q3) => {
|
|
14505
14505
|
if (typeof q3 !== "bigint")
|
|
14506
14506
|
throw Error("invalid field element: expected bigint, got " + typeof q3);
|
|
14507
14507
|
return r4 <= q3 && q3 < $3;
|
|
14508
|
-
}, is0: (q3) => q3 === r4, isOdd: (q3) => (q3 & t4) === t4, neg: (q3) => o4(-q3, $3), eql: (q3, M2) => q3 === M2, sqr: (q3) => o4(q3 * q3, $3), add: (q3, M2) => o4(q3 + M2, $3), sub: (q3, M2) => o4(q3 - M2, $3), mul: (q3, M2) => o4(q3 * M2, $3), pow: (q3, M2) =>
|
|
14508
|
+
}, is0: (q3) => q3 === r4, isOdd: (q3) => (q3 & t4) === t4, neg: (q3) => o4(-q3, $3), eql: (q3, M2) => q3 === M2, sqr: (q3) => o4(q3 * q3, $3), add: (q3, M2) => o4(q3 + M2, $3), sub: (q3, M2) => o4(q3 - M2, $3), mul: (q3, M2) => o4(q3 * M2, $3), pow: (q3, M2) => BQ2(X4, q3, M2), div: (q3, M2) => o4(q3 * b$2(M2, $3), $3), sqrN: (q3) => q3 * q3, addN: (q3, M2) => q3 + M2, subN: (q3, M2) => q3 - M2, mulN: (q3, M2) => q3 * M2, inv: (q3) => b$2(q3, $3), sqrt: Y2.sqrt || ((q3) => {
|
|
14509
14509
|
if (!K2)
|
|
14510
14510
|
K2 = OQ($3);
|
|
14511
14511
|
return K2(X4, q3);
|
|
14512
|
-
}), toBytes: (q3) => Q3 ? qJ3(q3, Z3) :
|
|
14512
|
+
}), toBytes: (q3) => Q3 ? qJ3(q3, Z3) : b03(q3, Z3), fromBytes: (q3) => {
|
|
14513
14513
|
if (q3.length !== Z3)
|
|
14514
14514
|
throw Error("Field.fromBytes: expected " + Z3 + " bytes, got " + q3.length);
|
|
14515
14515
|
return Q3 ? XJ3(q3) : N03(q3);
|
|
@@ -14531,7 +14531,7 @@ function V82($3, J2, Q3 = false) {
|
|
|
14531
14531
|
if (Y2 < 16 || Y2 < Z3 || Y2 > 1024)
|
|
14532
14532
|
throw Error("expected " + Z3 + "-1024 bytes of input, got " + Y2);
|
|
14533
14533
|
let K2 = Q3 ? XJ3($3) : N03($3), X4 = o4(K2, J2 - t4) + t4;
|
|
14534
|
-
return Q3 ? qJ3(X4, G2) :
|
|
14534
|
+
return Q3 ? qJ3(X4, G2) : b03(X4, G2);
|
|
14535
14535
|
}
|
|
14536
14536
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14537
14537
|
var O82 = BigInt(0);
|
|
@@ -14540,23 +14540,23 @@ function NJ2($3, J2) {
|
|
|
14540
14540
|
let Q3 = J2.negate();
|
|
14541
14541
|
return $3 ? Q3 : J2;
|
|
14542
14542
|
}
|
|
14543
|
-
function
|
|
14543
|
+
function B8($3, J2) {
|
|
14544
14544
|
if (!Number.isSafeInteger($3) || $3 <= 0 || $3 > J2)
|
|
14545
14545
|
throw Error("invalid window size, expected [1.." + J2 + "], got W=" + $3);
|
|
14546
14546
|
}
|
|
14547
14547
|
function DJ3($3, J2) {
|
|
14548
|
-
|
|
14549
|
-
let Q3 = Math.ceil(J2 / $3) + 1, Y2 = 2 ** ($3 - 1), G2 = 2 ** $3, Z3 =
|
|
14548
|
+
B8($3, J2);
|
|
14549
|
+
let Q3 = Math.ceil(J2 / $3) + 1, Y2 = 2 ** ($3 - 1), G2 = 2 ** $3, Z3 = g03($3), K2 = BigInt($3);
|
|
14550
14550
|
return { windows: Q3, windowSize: Y2, mask: Z3, maxNumber: G2, shiftBy: K2 };
|
|
14551
14551
|
}
|
|
14552
14552
|
function R8($3, J2, Q3) {
|
|
14553
14553
|
let { windowSize: Y2, mask: G2, maxNumber: Z3, shiftBy: K2 } = Q3, X4 = Number($3 & G2), q3 = $3 >> K2;
|
|
14554
14554
|
if (X4 > Y2)
|
|
14555
14555
|
X4 -= Z3, q3 += RJ3;
|
|
14556
|
-
let M2 = J2 * Y2, j3 = M2 + Math.abs(X4) - 1,
|
|
14557
|
-
return { nextN: q3, offset: j3, isZero:
|
|
14556
|
+
let M2 = J2 * Y2, j3 = M2 + Math.abs(X4) - 1, N = X4 === 0, D3 = X4 < 0, O4 = J2 % 2 !== 0;
|
|
14557
|
+
return { nextN: q3, offset: j3, isZero: N, isNeg: D3, isNegF: O4, offsetF: M2 };
|
|
14558
14558
|
}
|
|
14559
|
-
function
|
|
14559
|
+
function CQ2($3, J2) {
|
|
14560
14560
|
if (!Array.isArray($3))
|
|
14561
14561
|
throw Error("array expected");
|
|
14562
14562
|
$3.forEach((Q3, Y2) => {
|
|
@@ -14573,9 +14573,9 @@ function PQ($3, J2) {
|
|
|
14573
14573
|
});
|
|
14574
14574
|
}
|
|
14575
14575
|
var VJ3 = new WeakMap;
|
|
14576
|
-
var
|
|
14576
|
+
var C8 = new WeakMap;
|
|
14577
14577
|
function OJ3($3) {
|
|
14578
|
-
return
|
|
14578
|
+
return C8.get($3) || 1;
|
|
14579
14579
|
}
|
|
14580
14580
|
function P8($3, J2) {
|
|
14581
14581
|
return { constTimeNegate: NJ2, hasPrecomputes(Q3) {
|
|
@@ -14600,11 +14600,11 @@ function P8($3, J2) {
|
|
|
14600
14600
|
}, wNAF(Q3, Y2, G2) {
|
|
14601
14601
|
let { ZERO: Z3, BASE: K2 } = $3, X4 = DJ3(Q3, J2);
|
|
14602
14602
|
for (let q3 = 0;q3 < X4.windows; q3++) {
|
|
14603
|
-
let { nextN: M2, offset: j3, isZero:
|
|
14604
|
-
if (G2 = M2,
|
|
14605
|
-
K2 = K2.add(NJ2(
|
|
14603
|
+
let { nextN: M2, offset: j3, isZero: N, isNeg: D3, isNegF: O4, offsetF: P } = R8(G2, q3, X4);
|
|
14604
|
+
if (G2 = M2, N)
|
|
14605
|
+
K2 = K2.add(NJ2(O4, Y2[P]));
|
|
14606
14606
|
else
|
|
14607
|
-
Z3 = Z3.add(NJ2(
|
|
14607
|
+
Z3 = Z3.add(NJ2(D3, Y2[j3]));
|
|
14608
14608
|
}
|
|
14609
14609
|
return { p: Z3, f: K2 };
|
|
14610
14610
|
}, wNAFUnsafe(Q3, Y2, G2, Z3 = $3.ZERO) {
|
|
@@ -14612,12 +14612,12 @@ function P8($3, J2) {
|
|
|
14612
14612
|
for (let X4 = 0;X4 < K2.windows; X4++) {
|
|
14613
14613
|
if (G2 === O82)
|
|
14614
14614
|
break;
|
|
14615
|
-
let { nextN: q3, offset: M2, isZero: j3, isNeg:
|
|
14615
|
+
let { nextN: q3, offset: M2, isZero: j3, isNeg: N } = R8(G2, X4, K2);
|
|
14616
14616
|
if (G2 = q3, j3)
|
|
14617
14617
|
continue;
|
|
14618
14618
|
else {
|
|
14619
|
-
let
|
|
14620
|
-
Z3 = Z3.add(
|
|
14619
|
+
let D3 = Y2[M2];
|
|
14620
|
+
Z3 = Z3.add(N ? D3.negate() : D3);
|
|
14621
14621
|
}
|
|
14622
14622
|
}
|
|
14623
14623
|
return Z3;
|
|
@@ -14637,11 +14637,11 @@ function P8($3, J2) {
|
|
|
14637
14637
|
return this.unsafeLadder(Q3, Y2, Z3);
|
|
14638
14638
|
return this.wNAFUnsafe(K2, this.getPrecomputes(K2, Q3, G2), Y2, Z3);
|
|
14639
14639
|
}, setWindowSize(Q3, Y2) {
|
|
14640
|
-
|
|
14640
|
+
B8(Y2, J2), C8.set(Q3, Y2), VJ3.delete(Q3);
|
|
14641
14641
|
} };
|
|
14642
14642
|
}
|
|
14643
14643
|
function L8($3, J2, Q3, Y2) {
|
|
14644
|
-
|
|
14644
|
+
CQ2(Q3, $3), PQ(Y2, J2);
|
|
14645
14645
|
let G2 = Q3.length, Z3 = Y2.length;
|
|
14646
14646
|
if (G2 !== Z3)
|
|
14647
14647
|
throw Error("arrays of points and scalars must have equal length");
|
|
@@ -14652,35 +14652,35 @@ function L8($3, J2, Q3, Y2) {
|
|
|
14652
14652
|
q3 = X4 - 2;
|
|
14653
14653
|
else if (X4 > 0)
|
|
14654
14654
|
q3 = 2;
|
|
14655
|
-
let M2 =
|
|
14656
|
-
for (let
|
|
14655
|
+
let M2 = g03(q3), j3 = Array(Number(M2) + 1).fill(K2), N = Math.floor((J2.BITS - 1) / q3) * q3, D3 = K2;
|
|
14656
|
+
for (let O4 = N;O4 >= 0; O4 -= q3) {
|
|
14657
14657
|
j3.fill(K2);
|
|
14658
14658
|
for (let V3 = 0;V3 < Z3; V3++) {
|
|
14659
|
-
let k4 = Y2[V3],
|
|
14660
|
-
j3[
|
|
14659
|
+
let k4 = Y2[V3], T4 = Number(k4 >> BigInt(O4) & M2);
|
|
14660
|
+
j3[T4] = j3[T4].add(Q3[V3]);
|
|
14661
14661
|
}
|
|
14662
14662
|
let P = K2;
|
|
14663
14663
|
for (let V3 = j3.length - 1, k4 = K2;V3 > 0; V3--)
|
|
14664
14664
|
k4 = k4.add(j3[V3]), P = P.add(k4);
|
|
14665
|
-
if (
|
|
14665
|
+
if (D3 = D3.add(P), O4 !== 0)
|
|
14666
14666
|
for (let V3 = 0;V3 < q3; V3++)
|
|
14667
|
-
|
|
14667
|
+
D3 = D3.double();
|
|
14668
14668
|
}
|
|
14669
|
-
return
|
|
14669
|
+
return D3;
|
|
14670
14670
|
}
|
|
14671
|
-
function
|
|
14672
|
-
return jJ3($3.Fp),
|
|
14671
|
+
function BJ2($3) {
|
|
14672
|
+
return jJ3($3.Fp), f03($3, { n: "bigint", h: "bigint", Gx: "field", Gy: "field" }, { nBitLength: "isSafeInteger", nByteLength: "isSafeInteger" }), Object.freeze({ ...UJ2($3.n, $3.nBitLength), ...$3, ...{ p: $3.Fp.ORDER } });
|
|
14673
14673
|
}
|
|
14674
14674
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14675
14675
|
function H8($3) {
|
|
14676
14676
|
if ($3.lowS !== undefined)
|
|
14677
|
-
|
|
14677
|
+
s03("lowS", $3.lowS);
|
|
14678
14678
|
if ($3.prehash !== undefined)
|
|
14679
|
-
|
|
14679
|
+
s03("prehash", $3.prehash);
|
|
14680
14680
|
}
|
|
14681
14681
|
function LQ($3) {
|
|
14682
|
-
let J2 =
|
|
14683
|
-
|
|
14682
|
+
let J2 = BJ2($3);
|
|
14683
|
+
f03(J2, { a: "field", b: "field" }, { allowInfinityPoint: "boolean", allowedPrivateKeyLengths: "array", clearCofactor: "function", fromBytes: "function", isTorsionFree: "function", toBytes: "function", wrapPrivateKey: "boolean" });
|
|
14684
14684
|
let { endo: Q3, Fp: Y2, a: G2 } = J2;
|
|
14685
14685
|
if (Q3) {
|
|
14686
14686
|
if (!Y2.eql(G2, Y2.ZERO))
|
|
@@ -14765,8 +14765,8 @@ var D03 = { Err: S8, _tlv: { encode: ($3, J2) => {
|
|
|
14765
14765
|
let { _tlv: J2, _int: Q3 } = D03, Y2 = J2.encode(2, Q3.encode($3.r)), G2 = J2.encode(2, Q3.encode($3.s)), Z3 = Y2 + G2;
|
|
14766
14766
|
return J2.encode(48, Z3);
|
|
14767
14767
|
} };
|
|
14768
|
-
function
|
|
14769
|
-
return
|
|
14768
|
+
function CJ2($3, J2) {
|
|
14769
|
+
return r03(b03($3, J2));
|
|
14770
14770
|
}
|
|
14771
14771
|
var V03 = BigInt(0);
|
|
14772
14772
|
var d4 = BigInt(1);
|
|
@@ -14774,20 +14774,20 @@ var IG = BigInt(2);
|
|
|
14774
14774
|
var PJ2 = BigInt(3);
|
|
14775
14775
|
var HQ2 = BigInt(4);
|
|
14776
14776
|
function SQ2($3) {
|
|
14777
|
-
let J2 = LQ($3), { Fp: Q3 } = J2, Y2 = N$2(J2.n, J2.nBitLength), G2 = J2.toBytes || ((W2,
|
|
14778
|
-
let
|
|
14779
|
-
return z$2(Uint8Array.from([4]), Q3.toBytes(
|
|
14777
|
+
let J2 = LQ($3), { Fp: Q3 } = J2, Y2 = N$2(J2.n, J2.nBitLength), G2 = J2.toBytes || ((W2, U3, C4) => {
|
|
14778
|
+
let L3 = U3.toAffine();
|
|
14779
|
+
return z$2(Uint8Array.from([4]), Q3.toBytes(L3.x), Q3.toBytes(L3.y));
|
|
14780
14780
|
}), Z3 = J2.fromBytes || ((W2) => {
|
|
14781
|
-
let
|
|
14782
|
-
return { x:
|
|
14781
|
+
let U3 = W2.subarray(1), C4 = Q3.fromBytes(U3.subarray(0, Q3.BYTES)), L3 = Q3.fromBytes(U3.subarray(Q3.BYTES, 2 * Q3.BYTES));
|
|
14782
|
+
return { x: C4, y: L3 };
|
|
14783
14783
|
});
|
|
14784
14784
|
function K2(W2) {
|
|
14785
|
-
let { a:
|
|
14786
|
-
return Q3.add(Q3.add(w3, Q3.mul(W2,
|
|
14785
|
+
let { a: U3, b: C4 } = J2, L3 = Q3.sqr(W2), w3 = Q3.mul(L3, W2);
|
|
14786
|
+
return Q3.add(Q3.add(w3, Q3.mul(W2, U3)), C4);
|
|
14787
14787
|
}
|
|
14788
|
-
function X4(W2,
|
|
14789
|
-
let
|
|
14790
|
-
return Q3.eql(
|
|
14788
|
+
function X4(W2, U3) {
|
|
14789
|
+
let C4 = Q3.sqr(U3), L3 = K2(W2);
|
|
14790
|
+
return Q3.eql(C4, L3);
|
|
14791
14791
|
}
|
|
14792
14792
|
if (!X4(J2.Gx, J2.Gy))
|
|
14793
14793
|
throw Error("bad curve params: generator point");
|
|
@@ -14797,37 +14797,37 @@ function SQ2($3) {
|
|
|
14797
14797
|
function j3(W2) {
|
|
14798
14798
|
return y$2(W2, d4, J2.n);
|
|
14799
14799
|
}
|
|
14800
|
-
function
|
|
14801
|
-
let { allowedPrivateKeyLengths:
|
|
14802
|
-
if (
|
|
14803
|
-
if (
|
|
14804
|
-
W2 =
|
|
14805
|
-
if (typeof W2 !== "string" || !
|
|
14800
|
+
function N(W2) {
|
|
14801
|
+
let { allowedPrivateKeyLengths: U3, nByteLength: C4, wrapPrivateKey: L3, n: w3 } = J2;
|
|
14802
|
+
if (U3 && typeof W2 !== "bigint") {
|
|
14803
|
+
if (a03(W2))
|
|
14804
|
+
W2 = r03(W2);
|
|
14805
|
+
if (typeof W2 !== "string" || !U3.includes(W2.length))
|
|
14806
14806
|
throw Error("invalid private key");
|
|
14807
|
-
W2 = W2.padStart(
|
|
14807
|
+
W2 = W2.padStart(C4 * 2, "0");
|
|
14808
14808
|
}
|
|
14809
14809
|
let x3;
|
|
14810
14810
|
try {
|
|
14811
|
-
x3 = typeof W2 === "bigint" ? W2 : N03(J03("private key", W2,
|
|
14811
|
+
x3 = typeof W2 === "bigint" ? W2 : N03(J03("private key", W2, C4));
|
|
14812
14812
|
} catch (y4) {
|
|
14813
|
-
throw Error("invalid private key, expected hex or " +
|
|
14813
|
+
throw Error("invalid private key, expected hex or " + C4 + " bytes, got " + typeof W2);
|
|
14814
14814
|
}
|
|
14815
|
-
if (
|
|
14815
|
+
if (L3)
|
|
14816
14816
|
x3 = o4(x3, w3);
|
|
14817
|
-
return
|
|
14817
|
+
return F03("private key", x3, d4, w3), x3;
|
|
14818
14818
|
}
|
|
14819
|
-
function
|
|
14819
|
+
function D3(W2) {
|
|
14820
14820
|
if (!(W2 instanceof V3))
|
|
14821
14821
|
throw Error("ProjectivePoint expected");
|
|
14822
14822
|
}
|
|
14823
|
-
let
|
|
14824
|
-
let { px:
|
|
14823
|
+
let O4 = MJ2((W2, U3) => {
|
|
14824
|
+
let { px: C4, py: L3, pz: w3 } = W2;
|
|
14825
14825
|
if (Q3.eql(w3, Q3.ONE))
|
|
14826
|
-
return { x:
|
|
14826
|
+
return { x: C4, y: L3 };
|
|
14827
14827
|
let x3 = W2.is0();
|
|
14828
|
-
if (
|
|
14829
|
-
|
|
14830
|
-
let y4 = Q3.mul(
|
|
14828
|
+
if (U3 == null)
|
|
14829
|
+
U3 = x3 ? Q3.ONE : Q3.inv(w3);
|
|
14830
|
+
let y4 = Q3.mul(C4, U3), _4 = Q3.mul(L3, U3), A4 = Q3.mul(w3, U3);
|
|
14831
14831
|
if (x3)
|
|
14832
14832
|
return { x: Q3.ZERO, y: Q3.ZERO };
|
|
14833
14833
|
if (!Q3.eql(A4, Q3.ONE))
|
|
@@ -14839,10 +14839,10 @@ function SQ2($3) {
|
|
|
14839
14839
|
return;
|
|
14840
14840
|
throw Error("bad point: ZERO");
|
|
14841
14841
|
}
|
|
14842
|
-
let { x:
|
|
14843
|
-
if (!Q3.isValid(
|
|
14842
|
+
let { x: U3, y: C4 } = W2.toAffine();
|
|
14843
|
+
if (!Q3.isValid(U3) || !Q3.isValid(C4))
|
|
14844
14844
|
throw Error("bad point: x or y not FE");
|
|
14845
|
-
if (!X4(
|
|
14845
|
+
if (!X4(U3, C4))
|
|
14846
14846
|
throw Error("bad point: equation left != right");
|
|
14847
14847
|
if (!W2.isTorsionFree())
|
|
14848
14848
|
throw Error("bad point: not in prime-order subgroup");
|
|
@@ -14850,25 +14850,25 @@ function SQ2($3) {
|
|
|
14850
14850
|
});
|
|
14851
14851
|
|
|
14852
14852
|
class V3 {
|
|
14853
|
-
constructor(W2,
|
|
14853
|
+
constructor(W2, U3, C4) {
|
|
14854
14854
|
if (W2 == null || !Q3.isValid(W2))
|
|
14855
14855
|
throw Error("x required");
|
|
14856
|
-
if (
|
|
14856
|
+
if (U3 == null || !Q3.isValid(U3) || Q3.is0(U3))
|
|
14857
14857
|
throw Error("y required");
|
|
14858
|
-
if (
|
|
14858
|
+
if (C4 == null || !Q3.isValid(C4))
|
|
14859
14859
|
throw Error("z required");
|
|
14860
|
-
this.px = W2, this.py =
|
|
14860
|
+
this.px = W2, this.py = U3, this.pz = C4, Object.freeze(this);
|
|
14861
14861
|
}
|
|
14862
14862
|
static fromAffine(W2) {
|
|
14863
|
-
let { x:
|
|
14864
|
-
if (!W2 || !Q3.isValid(
|
|
14863
|
+
let { x: U3, y: C4 } = W2 || {};
|
|
14864
|
+
if (!W2 || !Q3.isValid(U3) || !Q3.isValid(C4))
|
|
14865
14865
|
throw Error("invalid affine point");
|
|
14866
14866
|
if (W2 instanceof V3)
|
|
14867
14867
|
throw Error("projective point not allowed");
|
|
14868
|
-
let
|
|
14869
|
-
if (
|
|
14868
|
+
let L3 = (w3) => Q3.eql(w3, Q3.ZERO);
|
|
14869
|
+
if (L3(U3) && L3(C4))
|
|
14870
14870
|
return V3.ZERO;
|
|
14871
|
-
return new V3(
|
|
14871
|
+
return new V3(U3, C4, Q3.ONE);
|
|
14872
14872
|
}
|
|
14873
14873
|
get x() {
|
|
14874
14874
|
return this.toAffine().x;
|
|
@@ -14877,21 +14877,21 @@ function SQ2($3) {
|
|
|
14877
14877
|
return this.toAffine().y;
|
|
14878
14878
|
}
|
|
14879
14879
|
static normalizeZ(W2) {
|
|
14880
|
-
let
|
|
14881
|
-
return W2.map((
|
|
14880
|
+
let U3 = WJ2(Q3, W2.map((C4) => C4.pz));
|
|
14881
|
+
return W2.map((C4, L3) => C4.toAffine(U3[L3])).map(V3.fromAffine);
|
|
14882
14882
|
}
|
|
14883
14883
|
static fromHex(W2) {
|
|
14884
|
-
let
|
|
14885
|
-
return
|
|
14884
|
+
let U3 = V3.fromAffine(Z3(J03("pointHex", W2)));
|
|
14885
|
+
return U3.assertValidity(), U3;
|
|
14886
14886
|
}
|
|
14887
14887
|
static fromPrivateKey(W2) {
|
|
14888
|
-
return V3.BASE.multiply(
|
|
14888
|
+
return V3.BASE.multiply(N(W2));
|
|
14889
14889
|
}
|
|
14890
|
-
static msm(W2,
|
|
14891
|
-
return L8(V3, Y2, W2,
|
|
14890
|
+
static msm(W2, U3) {
|
|
14891
|
+
return L8(V3, Y2, W2, U3);
|
|
14892
14892
|
}
|
|
14893
14893
|
_setWindowSize(W2) {
|
|
14894
|
-
|
|
14894
|
+
v3.setWindowSize(this, W2);
|
|
14895
14895
|
}
|
|
14896
14896
|
assertValidity() {
|
|
14897
14897
|
P(this);
|
|
@@ -14903,23 +14903,23 @@ function SQ2($3) {
|
|
|
14903
14903
|
throw Error("Field doesn't support isOdd");
|
|
14904
14904
|
}
|
|
14905
14905
|
equals(W2) {
|
|
14906
|
-
|
|
14907
|
-
let { px:
|
|
14906
|
+
D3(W2);
|
|
14907
|
+
let { px: U3, py: C4, pz: L3 } = this, { px: w3, py: x3, pz: y4 } = W2, _4 = Q3.eql(Q3.mul(U3, y4), Q3.mul(w3, L3)), A4 = Q3.eql(Q3.mul(C4, y4), Q3.mul(x3, L3));
|
|
14908
14908
|
return _4 && A4;
|
|
14909
14909
|
}
|
|
14910
14910
|
negate() {
|
|
14911
14911
|
return new V3(this.px, Q3.neg(this.py), this.pz);
|
|
14912
14912
|
}
|
|
14913
14913
|
double() {
|
|
14914
|
-
let { a: W2, b:
|
|
14915
|
-
return
|
|
14914
|
+
let { a: W2, b: U3 } = J2, C4 = Q3.mul(U3, PJ2), { px: L3, py: w3, pz: x3 } = this, y4 = Q3.ZERO, _4 = Q3.ZERO, A4 = Q3.ZERO, E4 = Q3.mul(L3, L3), c4 = Q3.mul(w3, w3), h4 = Q3.mul(x3, x3), z2 = Q3.mul(L3, w3);
|
|
14915
|
+
return z2 = Q3.add(z2, z2), A4 = Q3.mul(L3, x3), A4 = Q3.add(A4, A4), y4 = Q3.mul(W2, A4), _4 = Q3.mul(C4, h4), _4 = Q3.add(y4, _4), y4 = Q3.sub(c4, _4), _4 = Q3.add(c4, _4), _4 = Q3.mul(y4, _4), y4 = Q3.mul(z2, y4), A4 = Q3.mul(C4, A4), h4 = Q3.mul(W2, h4), z2 = Q3.sub(E4, h4), z2 = Q3.mul(W2, z2), z2 = Q3.add(z2, A4), A4 = Q3.add(E4, E4), E4 = Q3.add(A4, E4), E4 = Q3.add(E4, h4), E4 = Q3.mul(E4, z2), _4 = Q3.add(_4, E4), h4 = Q3.mul(w3, x3), h4 = Q3.add(h4, h4), E4 = Q3.mul(h4, z2), y4 = Q3.sub(y4, E4), A4 = Q3.mul(h4, c4), A4 = Q3.add(A4, A4), A4 = Q3.add(A4, A4), new V3(y4, _4, A4);
|
|
14916
14916
|
}
|
|
14917
14917
|
add(W2) {
|
|
14918
|
-
|
|
14919
|
-
let { px:
|
|
14920
|
-
|
|
14921
|
-
let
|
|
14922
|
-
return
|
|
14918
|
+
D3(W2);
|
|
14919
|
+
let { px: U3, py: C4, pz: L3 } = this, { px: w3, py: x3, pz: y4 } = W2, _4 = Q3.ZERO, A4 = Q3.ZERO, E4 = Q3.ZERO, c4 = J2.a, h4 = Q3.mul(J2.b, PJ2), z2 = Q3.mul(U3, w3), B4 = Q3.mul(C4, x3), S3 = Q3.mul(L3, y4), b4 = Q3.add(U3, C4), I3 = Q3.add(w3, x3);
|
|
14920
|
+
b4 = Q3.mul(b4, I3), I3 = Q3.add(z2, B4), b4 = Q3.sub(b4, I3), I3 = Q3.add(U3, L3);
|
|
14921
|
+
let R4 = Q3.add(w3, y4);
|
|
14922
|
+
return I3 = Q3.mul(I3, R4), R4 = Q3.add(z2, S3), I3 = Q3.sub(I3, R4), R4 = Q3.add(C4, L3), _4 = Q3.add(x3, y4), R4 = Q3.mul(R4, _4), _4 = Q3.add(B4, S3), R4 = Q3.sub(R4, _4), E4 = Q3.mul(c4, I3), _4 = Q3.mul(h4, S3), E4 = Q3.add(_4, E4), _4 = Q3.sub(B4, E4), E4 = Q3.add(B4, E4), A4 = Q3.mul(_4, E4), B4 = Q3.add(z2, z2), B4 = Q3.add(B4, z2), S3 = Q3.mul(c4, S3), I3 = Q3.mul(h4, I3), B4 = Q3.add(B4, S3), S3 = Q3.sub(z2, S3), S3 = Q3.mul(c4, S3), I3 = Q3.add(I3, S3), z2 = Q3.mul(B4, I3), A4 = Q3.add(A4, z2), z2 = Q3.mul(R4, I3), _4 = Q3.mul(b4, _4), _4 = Q3.sub(_4, z2), z2 = Q3.mul(b4, B4), E4 = Q3.mul(R4, E4), E4 = Q3.add(E4, z2), new V3(_4, A4, E4);
|
|
14923
14923
|
}
|
|
14924
14924
|
subtract(W2) {
|
|
14925
14925
|
return this.add(W2.negate());
|
|
@@ -14928,19 +14928,19 @@ function SQ2($3) {
|
|
|
14928
14928
|
return this.equals(V3.ZERO);
|
|
14929
14929
|
}
|
|
14930
14930
|
wNAF(W2) {
|
|
14931
|
-
return
|
|
14931
|
+
return v3.wNAFCached(this, W2, V3.normalizeZ);
|
|
14932
14932
|
}
|
|
14933
14933
|
multiplyUnsafe(W2) {
|
|
14934
|
-
let { endo:
|
|
14935
|
-
|
|
14936
|
-
let
|
|
14934
|
+
let { endo: U3, n: C4 } = J2;
|
|
14935
|
+
F03("scalar", W2, V03, C4);
|
|
14936
|
+
let L3 = V3.ZERO;
|
|
14937
14937
|
if (W2 === V03)
|
|
14938
|
-
return
|
|
14938
|
+
return L3;
|
|
14939
14939
|
if (this.is0() || W2 === d4)
|
|
14940
14940
|
return this;
|
|
14941
|
-
if (!
|
|
14942
|
-
return
|
|
14943
|
-
let { k1neg: w3, k1: x3, k2neg: y4, k2: _4 } =
|
|
14941
|
+
if (!U3 || v3.hasPrecomputes(this))
|
|
14942
|
+
return v3.wNAFCachedUnsafe(this, W2, V3.normalizeZ);
|
|
14943
|
+
let { k1neg: w3, k1: x3, k2neg: y4, k2: _4 } = U3.splitScalar(W2), A4 = L3, E4 = L3, c4 = this;
|
|
14944
14944
|
while (x3 > V03 || _4 > V03) {
|
|
14945
14945
|
if (x3 & d4)
|
|
14946
14946
|
A4 = A4.add(c4);
|
|
@@ -14952,133 +14952,133 @@ function SQ2($3) {
|
|
|
14952
14952
|
A4 = A4.negate();
|
|
14953
14953
|
if (y4)
|
|
14954
14954
|
E4 = E4.negate();
|
|
14955
|
-
return E4 = new V3(Q3.mul(E4.px,
|
|
14955
|
+
return E4 = new V3(Q3.mul(E4.px, U3.beta), E4.py, E4.pz), A4.add(E4);
|
|
14956
14956
|
}
|
|
14957
14957
|
multiply(W2) {
|
|
14958
|
-
let { endo:
|
|
14959
|
-
|
|
14960
|
-
let
|
|
14961
|
-
if (
|
|
14962
|
-
let { k1neg: x3, k1: y4, k2neg: _4, k2: A4 } =
|
|
14963
|
-
E4 =
|
|
14958
|
+
let { endo: U3, n: C4 } = J2;
|
|
14959
|
+
F03("scalar", W2, d4, C4);
|
|
14960
|
+
let L3, w3;
|
|
14961
|
+
if (U3) {
|
|
14962
|
+
let { k1neg: x3, k1: y4, k2neg: _4, k2: A4 } = U3.splitScalar(W2), { p: E4, f: c4 } = this.wNAF(y4), { p: h4, f: z2 } = this.wNAF(A4);
|
|
14963
|
+
E4 = v3.constTimeNegate(x3, E4), h4 = v3.constTimeNegate(_4, h4), h4 = new V3(Q3.mul(h4.px, U3.beta), h4.py, h4.pz), L3 = E4.add(h4), w3 = c4.add(z2);
|
|
14964
14964
|
} else {
|
|
14965
14965
|
let { p: x3, f: y4 } = this.wNAF(W2);
|
|
14966
|
-
|
|
14966
|
+
L3 = x3, w3 = y4;
|
|
14967
14967
|
}
|
|
14968
|
-
return V3.normalizeZ([
|
|
14968
|
+
return V3.normalizeZ([L3, w3])[0];
|
|
14969
14969
|
}
|
|
14970
|
-
multiplyAndAddUnsafe(W2,
|
|
14971
|
-
let
|
|
14970
|
+
multiplyAndAddUnsafe(W2, U3, C4) {
|
|
14971
|
+
let L3 = V3.BASE, w3 = (y4, _4) => _4 === V03 || _4 === d4 || !y4.equals(L3) ? y4.multiplyUnsafe(_4) : y4.multiply(_4), x3 = w3(this, U3).add(w3(W2, C4));
|
|
14972
14972
|
return x3.is0() ? undefined : x3;
|
|
14973
14973
|
}
|
|
14974
14974
|
toAffine(W2) {
|
|
14975
|
-
return
|
|
14975
|
+
return O4(this, W2);
|
|
14976
14976
|
}
|
|
14977
14977
|
isTorsionFree() {
|
|
14978
|
-
let { h: W2, isTorsionFree:
|
|
14978
|
+
let { h: W2, isTorsionFree: U3 } = J2;
|
|
14979
14979
|
if (W2 === d4)
|
|
14980
14980
|
return true;
|
|
14981
|
-
if (
|
|
14982
|
-
return
|
|
14981
|
+
if (U3)
|
|
14982
|
+
return U3(V3, this);
|
|
14983
14983
|
throw Error("isTorsionFree() has not been declared for the elliptic curve");
|
|
14984
14984
|
}
|
|
14985
14985
|
clearCofactor() {
|
|
14986
|
-
let { h: W2, clearCofactor:
|
|
14986
|
+
let { h: W2, clearCofactor: U3 } = J2;
|
|
14987
14987
|
if (W2 === d4)
|
|
14988
14988
|
return this;
|
|
14989
|
-
if (
|
|
14990
|
-
return
|
|
14989
|
+
if (U3)
|
|
14990
|
+
return U3(V3, this);
|
|
14991
14991
|
return this.multiplyUnsafe(J2.h);
|
|
14992
14992
|
}
|
|
14993
14993
|
toRawBytes(W2 = true) {
|
|
14994
|
-
return
|
|
14994
|
+
return s03("isCompressed", W2), this.assertValidity(), G2(V3, this, W2);
|
|
14995
14995
|
}
|
|
14996
14996
|
toHex(W2 = true) {
|
|
14997
|
-
return
|
|
14997
|
+
return s03("isCompressed", W2), r03(this.toRawBytes(W2));
|
|
14998
14998
|
}
|
|
14999
14999
|
}
|
|
15000
15000
|
V3.BASE = new V3(J2.Gx, J2.Gy, Q3.ONE), V3.ZERO = new V3(Q3.ZERO, Q3.ONE, Q3.ZERO);
|
|
15001
|
-
let { endo: k4, nBitLength:
|
|
15002
|
-
return { CURVE: J2, ProjectivePoint: V3, normPrivateKeyToScalar:
|
|
15001
|
+
let { endo: k4, nBitLength: T4 } = J2, v3 = P8(V3, k4 ? Math.ceil(T4 / 2) : T4);
|
|
15002
|
+
return { CURVE: J2, ProjectivePoint: V3, normPrivateKeyToScalar: N, weierstrassEquation: K2, isWithinCurveOrder: j3 };
|
|
15003
15003
|
}
|
|
15004
15004
|
function IQ($3) {
|
|
15005
|
-
let J2 =
|
|
15006
|
-
return
|
|
15005
|
+
let J2 = BJ2($3);
|
|
15006
|
+
return f03(J2, { hash: "hash", hmac: "function", randomBytes: "function" }, { bits2int: "function", bits2int_modN: "function", lowS: "boolean" }), Object.freeze({ lowS: true, ...J2 });
|
|
15007
15007
|
}
|
|
15008
15008
|
function I82($3) {
|
|
15009
15009
|
let J2 = IQ($3), { Fp: Q3, n: Y2, nByteLength: G2, nBitLength: Z3 } = J2, K2 = Q3.BYTES + 1, X4 = 2 * Q3.BYTES + 1;
|
|
15010
|
-
function q3(
|
|
15011
|
-
return o4(
|
|
15010
|
+
function q3(z2) {
|
|
15011
|
+
return o4(z2, Y2);
|
|
15012
15012
|
}
|
|
15013
|
-
function M2(
|
|
15014
|
-
return b$2(
|
|
15013
|
+
function M2(z2) {
|
|
15014
|
+
return b$2(z2, Y2);
|
|
15015
15015
|
}
|
|
15016
|
-
let { ProjectivePoint: j3, normPrivateKeyToScalar:
|
|
15017
|
-
let
|
|
15018
|
-
if (
|
|
15019
|
-
return
|
|
15016
|
+
let { ProjectivePoint: j3, normPrivateKeyToScalar: N, weierstrassEquation: D3, isWithinCurveOrder: O4 } = SQ2({ ...J2, toBytes(z2, B4, S3) {
|
|
15017
|
+
let b4 = B4.toAffine(), I3 = Q3.toBytes(b4.x), R4 = z$2;
|
|
15018
|
+
if (s03("isCompressed", S3), S3)
|
|
15019
|
+
return R4(Uint8Array.from([B4.hasEvenY() ? 2 : 3]), I3);
|
|
15020
15020
|
else
|
|
15021
|
-
return
|
|
15022
|
-
}, fromBytes(
|
|
15023
|
-
let B4 =
|
|
15024
|
-
if (B4 === K2 && (
|
|
15025
|
-
let
|
|
15026
|
-
if (!y$2(
|
|
15021
|
+
return R4(Uint8Array.from([4]), I3, Q3.toBytes(b4.y));
|
|
15022
|
+
}, fromBytes(z2) {
|
|
15023
|
+
let B4 = z2.length, S3 = z2[0], b4 = z2.subarray(1);
|
|
15024
|
+
if (B4 === K2 && (S3 === 2 || S3 === 3)) {
|
|
15025
|
+
let I3 = N03(b4);
|
|
15026
|
+
if (!y$2(I3, d4, Q3.ORDER))
|
|
15027
15027
|
throw Error("Point is not on curve");
|
|
15028
|
-
let
|
|
15028
|
+
let R4 = D3(I3), F2;
|
|
15029
15029
|
try {
|
|
15030
|
-
|
|
15030
|
+
F2 = Q3.sqrt(R4);
|
|
15031
15031
|
} catch (e5) {
|
|
15032
15032
|
let $03 = e5 instanceof Error ? ": " + e5.message : "";
|
|
15033
15033
|
throw Error("Point is not on curve" + $03);
|
|
15034
15034
|
}
|
|
15035
|
-
let m3 = (
|
|
15036
|
-
if ((
|
|
15037
|
-
|
|
15038
|
-
return { x:
|
|
15039
|
-
} else if (B4 === X4 &&
|
|
15040
|
-
let
|
|
15041
|
-
return { x:
|
|
15035
|
+
let m3 = (F2 & d4) === d4;
|
|
15036
|
+
if ((S3 & 1) === 1 !== m3)
|
|
15037
|
+
F2 = Q3.neg(F2);
|
|
15038
|
+
return { x: I3, y: F2 };
|
|
15039
|
+
} else if (B4 === X4 && S3 === 4) {
|
|
15040
|
+
let I3 = Q3.fromBytes(b4.subarray(0, Q3.BYTES)), R4 = Q3.fromBytes(b4.subarray(Q3.BYTES, 2 * Q3.BYTES));
|
|
15041
|
+
return { x: I3, y: R4 };
|
|
15042
15042
|
} else {
|
|
15043
|
-
let
|
|
15044
|
-
throw Error("invalid Point, expected length of " +
|
|
15043
|
+
let I3 = K2, R4 = X4;
|
|
15044
|
+
throw Error("invalid Point, expected length of " + I3 + ", or uncompressed " + R4 + ", got " + B4);
|
|
15045
15045
|
}
|
|
15046
15046
|
} });
|
|
15047
|
-
function P(
|
|
15047
|
+
function P(z2) {
|
|
15048
15048
|
let B4 = Y2 >> d4;
|
|
15049
|
-
return
|
|
15049
|
+
return z2 > B4;
|
|
15050
15050
|
}
|
|
15051
|
-
function V3(
|
|
15052
|
-
return P(
|
|
15051
|
+
function V3(z2) {
|
|
15052
|
+
return P(z2) ? q3(-z2) : z2;
|
|
15053
15053
|
}
|
|
15054
|
-
let k4 = (
|
|
15054
|
+
let k4 = (z2, B4, S3) => N03(z2.slice(B4, S3));
|
|
15055
15055
|
|
|
15056
|
-
class
|
|
15057
|
-
constructor(
|
|
15058
|
-
if (
|
|
15059
|
-
this.recovery =
|
|
15056
|
+
class T4 {
|
|
15057
|
+
constructor(z2, B4, S3) {
|
|
15058
|
+
if (F03("r", z2, d4, Y2), F03("s", B4, d4, Y2), this.r = z2, this.s = B4, S3 != null)
|
|
15059
|
+
this.recovery = S3;
|
|
15060
15060
|
Object.freeze(this);
|
|
15061
15061
|
}
|
|
15062
|
-
static fromCompact(
|
|
15062
|
+
static fromCompact(z2) {
|
|
15063
15063
|
let B4 = G2;
|
|
15064
|
-
return
|
|
15064
|
+
return z2 = J03("compactSignature", z2, B4 * 2), new T4(k4(z2, 0, B4), k4(z2, B4, 2 * B4));
|
|
15065
15065
|
}
|
|
15066
|
-
static fromDER(
|
|
15067
|
-
let { r: B4, s:
|
|
15068
|
-
return new
|
|
15066
|
+
static fromDER(z2) {
|
|
15067
|
+
let { r: B4, s: S3 } = D03.toSig(J03("DER", z2));
|
|
15068
|
+
return new T4(B4, S3);
|
|
15069
15069
|
}
|
|
15070
15070
|
assertValidity() {}
|
|
15071
|
-
addRecoveryBit(
|
|
15072
|
-
return new
|
|
15071
|
+
addRecoveryBit(z2) {
|
|
15072
|
+
return new T4(this.r, this.s, z2);
|
|
15073
15073
|
}
|
|
15074
|
-
recoverPublicKey(
|
|
15075
|
-
let { r: B4, s:
|
|
15076
|
-
if (
|
|
15074
|
+
recoverPublicKey(z2) {
|
|
15075
|
+
let { r: B4, s: S3, recovery: b4 } = this, I3 = w3(J03("msgHash", z2));
|
|
15076
|
+
if (b4 == null || ![0, 1, 2, 3].includes(b4))
|
|
15077
15077
|
throw Error("recovery id invalid");
|
|
15078
|
-
let
|
|
15079
|
-
if (
|
|
15078
|
+
let R4 = b4 === 2 || b4 === 3 ? B4 + J2.n : B4;
|
|
15079
|
+
if (R4 >= Q3.ORDER)
|
|
15080
15080
|
throw Error("recovery id 2 or 3 invalid");
|
|
15081
|
-
let
|
|
15081
|
+
let F2 = (b4 & 1) === 0 ? "02" : "03", m3 = j3.fromHex(F2 + CJ2(R4, Q3.BYTES)), l4 = M2(R4), e5 = q3(-I3 * l4), $03 = q3(S3 * l4), O03 = j3.BASE.multiplyAndAddUnsafe(m3, e5, $03);
|
|
15082
15082
|
if (!O03)
|
|
15083
15083
|
throw Error("point at infinify");
|
|
15084
15084
|
return O03.assertValidity(), O03;
|
|
@@ -15087,7 +15087,7 @@ function I82($3) {
|
|
|
15087
15087
|
return P(this.s);
|
|
15088
15088
|
}
|
|
15089
15089
|
normalizeS() {
|
|
15090
|
-
return this.hasHighS() ? new
|
|
15090
|
+
return this.hasHighS() ? new T4(this.r, q3(-this.s), this.recovery) : this;
|
|
15091
15091
|
}
|
|
15092
15092
|
toDERRawBytes() {
|
|
15093
15093
|
return U$(this.toDERHex());
|
|
@@ -15099,133 +15099,133 @@ function I82($3) {
|
|
|
15099
15099
|
return U$(this.toCompactHex());
|
|
15100
15100
|
}
|
|
15101
15101
|
toCompactHex() {
|
|
15102
|
-
let
|
|
15103
|
-
return
|
|
15102
|
+
let z2 = G2;
|
|
15103
|
+
return CJ2(this.r, z2) + CJ2(this.s, z2);
|
|
15104
15104
|
}
|
|
15105
15105
|
}
|
|
15106
|
-
let
|
|
15106
|
+
let v3 = { isValidPrivateKey(z2) {
|
|
15107
15107
|
try {
|
|
15108
|
-
return z2
|
|
15108
|
+
return N(z2), true;
|
|
15109
15109
|
} catch (B4) {
|
|
15110
15110
|
return false;
|
|
15111
15111
|
}
|
|
15112
|
-
}, normPrivateKeyToScalar:
|
|
15113
|
-
let
|
|
15114
|
-
return V82(J2.randomBytes(
|
|
15115
|
-
}, precompute(
|
|
15116
|
-
return B4._setWindowSize(
|
|
15112
|
+
}, normPrivateKeyToScalar: N, randomPrivateKey: () => {
|
|
15113
|
+
let z2 = zJ3(J2.n);
|
|
15114
|
+
return V82(J2.randomBytes(z2), J2.n);
|
|
15115
|
+
}, precompute(z2 = 8, B4 = j3.BASE) {
|
|
15116
|
+
return B4._setWindowSize(z2), B4.multiply(BigInt(3)), B4;
|
|
15117
15117
|
} };
|
|
15118
|
-
function W2(
|
|
15119
|
-
return j3.fromPrivateKey(
|
|
15118
|
+
function W2(z2, B4 = true) {
|
|
15119
|
+
return j3.fromPrivateKey(z2).toRawBytes(B4);
|
|
15120
15120
|
}
|
|
15121
|
-
function
|
|
15122
|
-
if (typeof
|
|
15121
|
+
function U3(z2) {
|
|
15122
|
+
if (typeof z2 === "bigint")
|
|
15123
15123
|
return false;
|
|
15124
|
-
if (
|
|
15124
|
+
if (z2 instanceof j3)
|
|
15125
15125
|
return true;
|
|
15126
|
-
let
|
|
15127
|
-
if (J2.allowedPrivateKeyLengths || G2 ===
|
|
15126
|
+
let S3 = J03("key", z2).length, b4 = Q3.BYTES, I3 = b4 + 1, R4 = 2 * b4 + 1;
|
|
15127
|
+
if (J2.allowedPrivateKeyLengths || G2 === I3)
|
|
15128
15128
|
return;
|
|
15129
15129
|
else
|
|
15130
|
-
return
|
|
15130
|
+
return S3 === I3 || S3 === R4;
|
|
15131
15131
|
}
|
|
15132
|
-
function
|
|
15133
|
-
if (
|
|
15132
|
+
function C4(z2, B4, S3 = true) {
|
|
15133
|
+
if (U3(z2) === true)
|
|
15134
15134
|
throw Error("first arg must be private key");
|
|
15135
|
-
if (
|
|
15135
|
+
if (U3(B4) === false)
|
|
15136
15136
|
throw Error("second arg must be public key");
|
|
15137
|
-
return j3.fromHex(B4).multiply(z2
|
|
15137
|
+
return j3.fromHex(B4).multiply(N(z2)).toRawBytes(S3);
|
|
15138
15138
|
}
|
|
15139
|
-
let
|
|
15140
|
-
if (
|
|
15139
|
+
let L3 = J2.bits2int || function(z2) {
|
|
15140
|
+
if (z2.length > 8192)
|
|
15141
15141
|
throw Error("input is too large");
|
|
15142
|
-
let B4 = N03(
|
|
15143
|
-
return
|
|
15144
|
-
}, w3 = J2.bits2int_modN || function(
|
|
15145
|
-
return q3(
|
|
15146
|
-
}, x3 =
|
|
15147
|
-
function y4(
|
|
15148
|
-
return
|
|
15149
|
-
}
|
|
15150
|
-
function _4(
|
|
15151
|
-
if (["recovered", "canonical"].some((H03) => (H03 in
|
|
15142
|
+
let B4 = N03(z2), S3 = z2.length * 8 - Z3;
|
|
15143
|
+
return S3 > 0 ? B4 >> BigInt(S3) : B4;
|
|
15144
|
+
}, w3 = J2.bits2int_modN || function(z2) {
|
|
15145
|
+
return q3(L3(z2));
|
|
15146
|
+
}, x3 = g03(Z3);
|
|
15147
|
+
function y4(z2) {
|
|
15148
|
+
return F03("num < 2^" + Z3, z2, V03, x3), b03(z2, G2);
|
|
15149
|
+
}
|
|
15150
|
+
function _4(z2, B4, S3 = A4) {
|
|
15151
|
+
if (["recovered", "canonical"].some((H03) => (H03 in S3)))
|
|
15152
15152
|
throw Error("sign() legacy options not supported");
|
|
15153
|
-
let { hash:
|
|
15154
|
-
if (
|
|
15155
|
-
|
|
15156
|
-
if (
|
|
15157
|
-
|
|
15158
|
-
let l4 = w3(
|
|
15153
|
+
let { hash: b4, randomBytes: I3 } = J2, { lowS: R4, prehash: F2, extraEntropy: m3 } = S3;
|
|
15154
|
+
if (R4 == null)
|
|
15155
|
+
R4 = true;
|
|
15156
|
+
if (z2 = J03("msgHash", z2), H8(S3), F2)
|
|
15157
|
+
z2 = J03("prehashed msgHash", b4(z2));
|
|
15158
|
+
let l4 = w3(z2), e5 = N(B4), $03 = [y4(e5), y4(l4)];
|
|
15159
15159
|
if (m3 != null && m3 !== false) {
|
|
15160
|
-
let H03 = m3 === true ?
|
|
15160
|
+
let H03 = m3 === true ? I3(Q3.BYTES) : m3;
|
|
15161
15161
|
$03.push(J03("extraEntropy", H03));
|
|
15162
15162
|
}
|
|
15163
15163
|
let O03 = z$2(...$03), V$2 = l4;
|
|
15164
15164
|
function v$2(H03) {
|
|
15165
|
-
let
|
|
15166
|
-
if (!
|
|
15165
|
+
let m03 = L3(H03);
|
|
15166
|
+
if (!O4(m03))
|
|
15167
15167
|
return;
|
|
15168
|
-
let h$2 = M2(
|
|
15168
|
+
let h$2 = M2(m03), e03 = j3.BASE.multiply(m03).toAffine(), S03 = q3(e03.x);
|
|
15169
15169
|
if (S03 === V03)
|
|
15170
15170
|
return;
|
|
15171
|
-
let
|
|
15172
|
-
if (
|
|
15171
|
+
let $$ = q3(h$2 * q3(V$2 + S03 * e5));
|
|
15172
|
+
if ($$ === V03)
|
|
15173
15173
|
return;
|
|
15174
|
-
let
|
|
15175
|
-
if (
|
|
15176
|
-
AJ2 = V3(
|
|
15177
|
-
return new
|
|
15174
|
+
let u03 = (e03.x === S03 ? 0 : 2) | Number(e03.y & d4), AJ2 = $$;
|
|
15175
|
+
if (R4 && P($$))
|
|
15176
|
+
AJ2 = V3($$), u03 ^= 1;
|
|
15177
|
+
return new T4(S03, AJ2, u03);
|
|
15178
15178
|
}
|
|
15179
15179
|
return { seed: O03, k2sig: v$2 };
|
|
15180
15180
|
}
|
|
15181
15181
|
let A4 = { lowS: J2.lowS, prehash: false }, E4 = { lowS: J2.lowS, prehash: false };
|
|
15182
|
-
function c4(
|
|
15183
|
-
let { seed:
|
|
15184
|
-
return M82(
|
|
15182
|
+
function c4(z2, B4, S3 = A4) {
|
|
15183
|
+
let { seed: b4, k2sig: I3 } = _4(z2, B4, S3), R4 = J2;
|
|
15184
|
+
return M82(R4.hash.outputLen, R4.nByteLength, R4.hmac)(b4, I3);
|
|
15185
15185
|
}
|
|
15186
15186
|
j3.BASE._setWindowSize(8);
|
|
15187
|
-
function h4(
|
|
15188
|
-
let
|
|
15189
|
-
B4 = J03("msgHash", B4),
|
|
15190
|
-
let { lowS:
|
|
15191
|
-
if (H8(
|
|
15187
|
+
function h4(z2, B4, S3, b4 = E4) {
|
|
15188
|
+
let I3 = z2;
|
|
15189
|
+
B4 = J03("msgHash", B4), S3 = J03("publicKey", S3);
|
|
15190
|
+
let { lowS: R4, prehash: F2, format: m3 } = b4;
|
|
15191
|
+
if (H8(b4), "strict" in b4)
|
|
15192
15192
|
throw Error("options.strict was renamed to lowS");
|
|
15193
15193
|
if (m3 !== undefined && m3 !== "compact" && m3 !== "der")
|
|
15194
15194
|
throw Error("format must be compact or der");
|
|
15195
|
-
let l4 = typeof
|
|
15195
|
+
let l4 = typeof I3 === "string" || a03(I3), e5 = !l4 && !m3 && typeof I3 === "object" && I3 !== null && typeof I3.r === "bigint" && typeof I3.s === "bigint";
|
|
15196
15196
|
if (!l4 && !e5)
|
|
15197
15197
|
throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
|
15198
15198
|
let $03 = undefined, O03;
|
|
15199
15199
|
try {
|
|
15200
15200
|
if (e5)
|
|
15201
|
-
$03 = new
|
|
15201
|
+
$03 = new T4(I3.r, I3.s);
|
|
15202
15202
|
if (l4) {
|
|
15203
15203
|
try {
|
|
15204
15204
|
if (m3 !== "compact")
|
|
15205
|
-
$03 =
|
|
15206
|
-
} catch (
|
|
15207
|
-
if (!(
|
|
15208
|
-
throw
|
|
15205
|
+
$03 = T4.fromDER(I3);
|
|
15206
|
+
} catch (u03) {
|
|
15207
|
+
if (!(u03 instanceof D03.Err))
|
|
15208
|
+
throw u03;
|
|
15209
15209
|
}
|
|
15210
15210
|
if (!$03 && m3 !== "der")
|
|
15211
|
-
$03 =
|
|
15211
|
+
$03 = T4.fromCompact(I3);
|
|
15212
15212
|
}
|
|
15213
|
-
O03 = j3.fromHex(
|
|
15214
|
-
} catch (
|
|
15213
|
+
O03 = j3.fromHex(S3);
|
|
15214
|
+
} catch (u03) {
|
|
15215
15215
|
return false;
|
|
15216
15216
|
}
|
|
15217
15217
|
if (!$03)
|
|
15218
15218
|
return false;
|
|
15219
|
-
if (
|
|
15219
|
+
if (R4 && $03.hasHighS())
|
|
15220
15220
|
return false;
|
|
15221
|
-
if (
|
|
15221
|
+
if (F2)
|
|
15222
15222
|
B4 = J2.hash(B4);
|
|
15223
|
-
let { r: V$2, s: v$2 } = $03, H03 = w3(B4),
|
|
15223
|
+
let { r: V$2, s: v$2 } = $03, H03 = w3(B4), m03 = M2(v$2), h$2 = q3(H03 * m03), e03 = q3(V$2 * m03), S03 = j3.BASE.multiplyAndAddUnsafe(O03, h$2, e03)?.toAffine();
|
|
15224
15224
|
if (!S03)
|
|
15225
15225
|
return false;
|
|
15226
15226
|
return q3(S03.x) === V$2;
|
|
15227
15227
|
}
|
|
15228
|
-
return { CURVE: J2, getPublicKey: W2, getSharedSecret:
|
|
15228
|
+
return { CURVE: J2, getPublicKey: W2, getSharedSecret: C4, sign: c4, verify: h4, ProjectivePoint: j3, Signature: T4, utils: v3 };
|
|
15229
15229
|
}
|
|
15230
15230
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
15231
15231
|
function TQ($3) {
|
|
@@ -15243,29 +15243,29 @@ var xQ2 = BigInt(1);
|
|
|
15243
15243
|
var LJ3 = BigInt(2);
|
|
15244
15244
|
var x8 = ($3, J2) => ($3 + J2 / LJ3) / J2;
|
|
15245
15245
|
function EQ2($3) {
|
|
15246
|
-
let J2 = E8, Q3 = BigInt(3), Y2 = BigInt(6), G2 = BigInt(11), Z3 = BigInt(22), K2 = BigInt(23), X4 = BigInt(44), q3 = BigInt(88), M2 = $3 * $3 * $3 % J2, j3 = M2 * M2 * $3 % J2,
|
|
15247
|
-
if (!HJ3.eql(HJ3.sqr(
|
|
15246
|
+
let J2 = E8, Q3 = BigInt(3), Y2 = BigInt(6), G2 = BigInt(11), Z3 = BigInt(22), K2 = BigInt(23), X4 = BigInt(44), q3 = BigInt(88), M2 = $3 * $3 * $3 % J2, j3 = M2 * M2 * $3 % J2, N = G03(j3, Q3, J2) * j3 % J2, D3 = G03(N, Q3, J2) * j3 % J2, O4 = G03(D3, LJ3, J2) * M2 % J2, P = G03(O4, G2, J2) * O4 % J2, V3 = G03(P, Z3, J2) * P % J2, k4 = G03(V3, X4, J2) * V3 % J2, T4 = G03(k4, q3, J2) * k4 % J2, v3 = G03(T4, X4, J2) * V3 % J2, W2 = G03(v3, Q3, J2) * j3 % J2, U3 = G03(W2, K2, J2) * P % J2, C4 = G03(U3, Y2, J2) * M2 % J2, L3 = G03(C4, LJ3, J2);
|
|
15247
|
+
if (!HJ3.eql(HJ3.sqr(L3), $3))
|
|
15248
15248
|
throw Error("Cannot find square root");
|
|
15249
|
-
return
|
|
15249
|
+
return L3;
|
|
15250
15250
|
}
|
|
15251
15251
|
var HJ3 = N$2(E8, undefined, undefined, { sqrt: EQ2 });
|
|
15252
15252
|
var SJ3 = T82({ a: _Q2, b: BigInt(7), Fp: HJ3, n: _82, Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"), Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"), h: BigInt(1), lowS: true, endo: { beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"), splitScalar: ($3) => {
|
|
15253
|
-
let J2 = _82, Q3 = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), Y2 = -xQ2 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), G2 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), Z3 = Q3, K2 = BigInt("0x100000000000000000000000000000000"), X4 = x8(Z3 * $3, J2), q3 = x8(-Y2 * $3, J2), M2 = o4($3 - X4 * Q3 - q3 * G2, J2), j3 = o4(-X4 * Y2 - q3 * Z3, J2),
|
|
15254
|
-
if (z2)
|
|
15255
|
-
M2 = J2 - M2;
|
|
15253
|
+
let J2 = _82, Q3 = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), Y2 = -xQ2 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), G2 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), Z3 = Q3, K2 = BigInt("0x100000000000000000000000000000000"), X4 = x8(Z3 * $3, J2), q3 = x8(-Y2 * $3, J2), M2 = o4($3 - X4 * Q3 - q3 * G2, J2), j3 = o4(-X4 * Y2 - q3 * Z3, J2), N = M2 > K2, D3 = j3 > K2;
|
|
15256
15254
|
if (N)
|
|
15255
|
+
M2 = J2 - M2;
|
|
15256
|
+
if (D3)
|
|
15257
15257
|
j3 = J2 - j3;
|
|
15258
15258
|
if (M2 > K2 || j3 > K2)
|
|
15259
15259
|
throw Error("splitScalar: Endomorphism failed, k=" + $3);
|
|
15260
|
-
return { k1neg:
|
|
15260
|
+
return { k1neg: N, k1: M2, k2neg: D3, k2: j3 };
|
|
15261
15261
|
} } }, Y8);
|
|
15262
15262
|
function F$2() {
|
|
15263
15263
|
let $3 = SJ3.utils.randomPrivateKey();
|
|
15264
15264
|
return "0x" + Buffer.from($3).toString("hex");
|
|
15265
15265
|
}
|
|
15266
15266
|
function g$2($3) {
|
|
15267
|
-
let J2 = $3.startsWith("0x") ? $3.slice(2) : $3, Q3 = Buffer.from(J2, "hex"), Y2 = SJ3.getPublicKey(Q3, false), Z3 =
|
|
15268
|
-
return
|
|
15267
|
+
let J2 = $3.startsWith("0x") ? $3.slice(2) : $3, Q3 = Buffer.from(J2, "hex"), Y2 = SJ3.getPublicKey(Q3, false), Z3 = l03(Y2.slice(1)).slice(-20), K2 = "0x" + Buffer.from(Z3).toString("hex");
|
|
15268
|
+
return C03(K2);
|
|
15269
15269
|
}
|
|
15270
15270
|
function f$2($3) {
|
|
15271
15271
|
let J2;
|
|
@@ -15274,29 +15274,29 @@ function f$2($3) {
|
|
|
15274
15274
|
J2 = Buffer.from(Y2, "hex");
|
|
15275
15275
|
} else
|
|
15276
15276
|
J2 = $3;
|
|
15277
|
-
let Q3 =
|
|
15277
|
+
let Q3 = l03(J2);
|
|
15278
15278
|
return "0x" + Buffer.from(Q3).toString("hex");
|
|
15279
15279
|
}
|
|
15280
15280
|
|
|
15281
|
-
class
|
|
15281
|
+
class f2 extends w$2 {
|
|
15282
15282
|
constructor($3, J2) {
|
|
15283
15283
|
super("InvitationError", $3, { ...J2, source: J2?.source || "INVITATIONS" });
|
|
15284
15284
|
}
|
|
15285
15285
|
static noPathFound($3, J2, Q3) {
|
|
15286
|
-
return new
|
|
15286
|
+
return new f2(`No valid invitation path found from ${$3} to ${J2}. ${Q3 || "The inviter may not have enough balance of the proxy inviter's token or there's no trust connection."}`, { code: "INVITATION_NO_PATH", source: "PATHFINDING", context: { from: $3, to: J2, reason: Q3 } });
|
|
15287
15287
|
}
|
|
15288
15288
|
static noProxyInviters($3) {
|
|
15289
|
-
return new
|
|
15289
|
+
return new f2(`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 } });
|
|
15290
15290
|
}
|
|
15291
15291
|
static insufficientBalance($3, J2, Q3, Y2, G2, Z3) {
|
|
15292
15292
|
let K2 = Number(Q3) / 1000000000000000000, X4 = Number(Y2) / 1000000000000000000;
|
|
15293
|
-
return new
|
|
15293
|
+
return new f2(`Insufficient balance for ${$3} invitation(s). Can only afford ${J2} invitation(s). Requested: ${K2.toFixed(6)} CRC, Available: ${X4.toFixed(6)} CRC.`, { code: "INVITATION_INSUFFICIENT_BALANCE", source: "VALIDATION", context: { from: G2, to: Z3, requestedInvites: $3, availableInvites: J2, requested: Q3.toString(), available: Y2.toString(), requestedCrc: K2, availableCrc: X4 } });
|
|
15294
15294
|
}
|
|
15295
15295
|
static inviteeAlreadyRegistered($3, J2) {
|
|
15296
|
-
return new
|
|
15296
|
+
return new f2(`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 } });
|
|
15297
15297
|
}
|
|
15298
15298
|
static noAddressesProvided() {
|
|
15299
|
-
return new
|
|
15299
|
+
return new f2("At least one address must be provided for invitation.", { code: "INVITATION_NO_ADDRESSES_PROVIDED", source: "VALIDATION" });
|
|
15300
15300
|
}
|
|
15301
15301
|
}
|
|
15302
15302
|
var k8 = [];
|
|
@@ -15321,8 +15321,8 @@ function w8($3, J2, Q3) {
|
|
|
15321
15321
|
Y2.add(K2.from.toLowerCase()), Y2.add(K2.to.toLowerCase()), Y2.add(K2.tokenOwner.toLowerCase());
|
|
15322
15322
|
});
|
|
15323
15323
|
let G2 = [...Y2].sort((K2, X4) => {
|
|
15324
|
-
let q3 = BigInt(K2), M2 = BigInt(X4), j3 = q3 < M2,
|
|
15325
|
-
return j3 ? -1 :
|
|
15324
|
+
let q3 = BigInt(K2), M2 = BigInt(X4), j3 = q3 < M2, N = q3 > M2;
|
|
15325
|
+
return j3 ? -1 : N ? 1 : 0;
|
|
15326
15326
|
}), Z3 = {};
|
|
15327
15327
|
return G2.forEach((K2, X4) => {
|
|
15328
15328
|
Z3[K2] = X4;
|
|
@@ -15343,19 +15343,19 @@ function kQ($3, J2) {
|
|
|
15343
15343
|
return Q3;
|
|
15344
15344
|
}
|
|
15345
15345
|
function IJ3($3, J2, Q3, Y2) {
|
|
15346
|
-
let G2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), { sorted: K2, idx: X4 } = w8(Y2, G2, Z3), q3 = kQ(Y2, Z3), M2 = Y2.map((
|
|
15347
|
-
return { streamSinkId: q3.has(
|
|
15346
|
+
let G2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), { sorted: K2, idx: X4 } = w8(Y2, G2, Z3), q3 = kQ(Y2, Z3), M2 = Y2.map((T4, v3) => {
|
|
15347
|
+
return { streamSinkId: q3.has(v3) ? 1 : 0, amount: T4.value };
|
|
15348
15348
|
});
|
|
15349
15349
|
if (q3.size === 0)
|
|
15350
15350
|
throw Error(`No terminal edges detected. Flow must have at least one edge delivering to receiver ${Z3}`);
|
|
15351
|
-
let j3 = Array.from(q3),
|
|
15352
|
-
Y2.forEach((
|
|
15353
|
-
|
|
15351
|
+
let j3 = Array.from(q3), N = [{ sourceCoordinate: X4[G2], flowEdgeIds: j3, data: new Uint8Array(0) }], D3 = [];
|
|
15352
|
+
Y2.forEach((T4) => {
|
|
15353
|
+
D3.push(X4[T4.tokenOwner.toLowerCase()]), D3.push(X4[T4.from.toLowerCase()]), D3.push(X4[T4.to.toLowerCase()]);
|
|
15354
15354
|
});
|
|
15355
|
-
let
|
|
15355
|
+
let O4 = A8(D3), P = BigInt(Q3), V3 = M2.filter((T4) => T4.streamSinkId === 1).reduce((T4, v3) => T4 + BigInt(v3.amount.toString()), BigInt(0));
|
|
15356
15356
|
if (V3 !== P)
|
|
15357
15357
|
throw Error(`Terminal sum ${V3} does not equal expected ${P}`);
|
|
15358
|
-
return { flowVertices: K2, flowEdges: M2, streams:
|
|
15358
|
+
return { flowVertices: K2, flowEdges: M2, streams: N, packedCoordinates: O4, sourceCoordinate: X4[G2] };
|
|
15359
15359
|
}
|
|
15360
15360
|
function TJ3($3, J2) {
|
|
15361
15361
|
let Q3 = $3.streams.map((Y2) => ({ sourceCoordinate: Y2.sourceCoordinate, flowEdgeIds: Y2.flowEdgeIds, data: Y2.data instanceof Uint8Array ? D$2(Y2.data) : Y2.data }));
|
|
@@ -15395,7 +15395,7 @@ function EJ3($3, J2) {
|
|
|
15395
15395
|
return { ...$3, transfers: Q3 };
|
|
15396
15396
|
}
|
|
15397
15397
|
|
|
15398
|
-
class a4 extends
|
|
15398
|
+
class a4 extends Q$ {
|
|
15399
15399
|
constructor($3, J2) {
|
|
15400
15400
|
super("TransferError", $3, { ...J2, source: J2?.source || "TRANSFERS" });
|
|
15401
15401
|
}
|
|
@@ -15420,7 +15420,7 @@ class a4 extends J$2 {
|
|
|
15420
15420
|
}
|
|
15421
15421
|
}
|
|
15422
15422
|
|
|
15423
|
-
class
|
|
15423
|
+
class h03 {
|
|
15424
15424
|
config;
|
|
15425
15425
|
hubV2;
|
|
15426
15426
|
liftERC20;
|
|
@@ -15429,7 +15429,7 @@ class v03 {
|
|
|
15429
15429
|
balance;
|
|
15430
15430
|
group;
|
|
15431
15431
|
constructor($3) {
|
|
15432
|
-
this.config = $3, this.hubV2 = new P03({ address: $3.v2HubAddress, rpcUrl: $3.circlesRpcUrl }), this.liftERC20 = new E$2({ address: $3.liftERC20Address, rpcUrl: $3.circlesRpcUrl }), this.rpcClient = new R03($3.circlesRpcUrl), this.pathfinder = new W03(this.rpcClient), this.balance = new A02(this.rpcClient), this.group = new
|
|
15432
|
+
this.config = $3, this.hubV2 = new P03({ address: $3.v2HubAddress, rpcUrl: $3.circlesRpcUrl }), this.liftERC20 = new E$2({ address: $3.liftERC20Address, rpcUrl: $3.circlesRpcUrl }), this.rpcClient = new R03($3.circlesRpcUrl), this.pathfinder = new W03(this.rpcClient), this.balance = new A02(this.rpcClient), this.group = new y03(this.rpcClient);
|
|
15433
15433
|
}
|
|
15434
15434
|
async buildFlowMatrixTx($3, J2, Q3, Y2, G2 = false) {
|
|
15435
15435
|
let Z3 = $3.toLowerCase(), K2 = J2.toLowerCase();
|
|
@@ -15437,115 +15437,115 @@ class v03 {
|
|
|
15437
15437
|
throw a4.noPathFound(Z3, K2);
|
|
15438
15438
|
let X4 = { ...Q3 };
|
|
15439
15439
|
if (G2 && Y2?.toTokens?.length === 1) {
|
|
15440
|
-
let
|
|
15440
|
+
let v3 = Y2.toTokens[0].toLowerCase();
|
|
15441
15441
|
if (Q3.maxFlow > 0n)
|
|
15442
|
-
X4.transfers.push({ from: K2, to: K2, tokenOwner:
|
|
15442
|
+
X4.transfers.push({ from: K2, to: K2, tokenOwner: v3, value: Q3.maxFlow });
|
|
15443
15443
|
}
|
|
15444
15444
|
let q3 = await _J3(Z3, this.config.circlesRpcUrl, X4), M2 = xJ2(X4, q3), j3 = Object.keys(M2).length > 0;
|
|
15445
15445
|
if (j3 && !Y2?.useWrappedBalances)
|
|
15446
15446
|
throw a4.wrappedTokensRequired();
|
|
15447
|
-
let
|
|
15447
|
+
let N = [], D3 = [];
|
|
15448
15448
|
if (j3) {
|
|
15449
|
-
let
|
|
15450
|
-
|
|
15449
|
+
let v3 = await this._getTokenBalanceMap(Z3), W2 = this._createDemurragedUnwrapCalls(M2), { unwrapCalls: U3, wrapCalls: C4 } = this._createInflationaryUnwrapAndWrapCalls(M2, q3, v3);
|
|
15450
|
+
N = [...W2, ...U3], D3 = C4, X4 = EJ3(X4, q3);
|
|
15451
15451
|
}
|
|
15452
|
-
let
|
|
15452
|
+
let O4 = IJ3(Z3, K2, X4.maxFlow, X4.transfers), P = TJ3(O4, Y2?.txData), V3 = this.hubV2.operateFlowMatrix(O4.flowVertices, O4.flowEdges, P, O4.packedCoordinates), k4 = false;
|
|
15453
15453
|
try {
|
|
15454
15454
|
k4 = await this.hubV2.isApprovedForAll(Z3, Z3);
|
|
15455
|
-
} catch (
|
|
15456
|
-
console.warn("Failed to check approval status, including approval transaction:",
|
|
15455
|
+
} catch (v3) {
|
|
15456
|
+
console.warn("Failed to check approval status, including approval transaction:", v3);
|
|
15457
15457
|
}
|
|
15458
|
-
return [...k4 ? [] : [this.hubV2.setApprovalForAll(Z3, true)], ...
|
|
15458
|
+
return [...k4 ? [] : [this.hubV2.setApprovalForAll(Z3, true)], ...N, V3, ...D3];
|
|
15459
15459
|
}
|
|
15460
15460
|
async constructAdvancedTransfer($3, J2, Q3, Y2, G2 = false) {
|
|
15461
15461
|
let Z3 = $3.toLowerCase(), K2 = J2.toLowerCase(), X4 = BigInt(Q3);
|
|
15462
15462
|
if (Z3 === K2 && Y2?.fromTokens?.length === 1 && Y2?.toTokens?.length === 1) {
|
|
15463
|
-
let
|
|
15464
|
-
if (
|
|
15465
|
-
let
|
|
15466
|
-
return [{ to:
|
|
15463
|
+
let O4 = Y2.fromTokens[0], P = Y2.toTokens[0], [V3, k4] = await Promise.all([this.liftERC20.erc20Circles(0, P), this.liftERC20.erc20Circles(1, P)]);
|
|
15464
|
+
if (O4.toLowerCase() === V3.toLowerCase() && V3 !== _$2) {
|
|
15465
|
+
let v3 = new i03({ address: O4, rpcUrl: this.config.circlesRpcUrl }).unwrap(X4);
|
|
15466
|
+
return [{ to: v3.to, data: v3.data, value: v3.value ?? 0n }];
|
|
15467
15467
|
}
|
|
15468
|
-
if (
|
|
15469
|
-
let
|
|
15468
|
+
if (O4.toLowerCase() === k4.toLowerCase() && k4 !== _$2) {
|
|
15469
|
+
let T4 = new n03({ address: O4, rpcUrl: this.config.circlesRpcUrl }), v3 = i4.attoCirclesToAttoStaticCircles(X4), W2 = T4.unwrap(v3);
|
|
15470
15470
|
return [{ to: W2.to, data: W2.data, value: W2.value ?? 0n }];
|
|
15471
15471
|
}
|
|
15472
15472
|
}
|
|
15473
|
-
let q3 = this._truncateToSixDecimals(X4), M2 = await this._getDefaultTokenExcludeList(K2, Y2?.excludeFromTokens), { ...j3 } = Y2 || {},
|
|
15474
|
-
if (!
|
|
15473
|
+
let q3 = this._truncateToSixDecimals(X4), M2 = await this._getDefaultTokenExcludeList(K2, Y2?.excludeFromTokens), { ...j3 } = Y2 || {}, N = { ...j3, ...M2 ? { excludeFromTokens: M2 } : {} }, D3 = await this.pathfinder.findPath({ from: Z3, to: K2, targetFlow: q3, ...N });
|
|
15474
|
+
if (!D3.transfers || D3.transfers.length === 0)
|
|
15475
15475
|
throw a4.noPathFound(Z3, K2);
|
|
15476
|
-
if (
|
|
15477
|
-
throw a4.insufficientBalance(q3,
|
|
15478
|
-
return this.buildFlowMatrixTx(Z3, K2,
|
|
15476
|
+
if (D3.maxFlow < q3)
|
|
15477
|
+
throw a4.insufficientBalance(q3, D3.maxFlow, Z3, K2);
|
|
15478
|
+
return this.buildFlowMatrixTx(Z3, K2, D3, Y2, G2);
|
|
15479
15479
|
}
|
|
15480
15480
|
async constructReplenish($3, J2, Q3, Y2) {
|
|
15481
|
-
let G2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), K2 = (Y2 || $3).toLowerCase(), X4 = BigInt(Q3), M2 = (await this.balance.getTokenBalances(G2)).filter((
|
|
15482
|
-
for (let
|
|
15483
|
-
if (
|
|
15484
|
-
if (
|
|
15485
|
-
|
|
15481
|
+
let G2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), K2 = (Y2 || $3).toLowerCase(), X4 = BigInt(Q3), M2 = (await this.balance.getTokenBalances(G2)).filter((R4) => R4.tokenOwner.toLowerCase() === Z3), j3 = 0n, N = 0n, D3 = 0n, O4 = null, P = null;
|
|
15482
|
+
for (let R4 of M2)
|
|
15483
|
+
if (R4.isWrapped)
|
|
15484
|
+
if (R4.tokenType.includes("Demurrage"))
|
|
15485
|
+
N = BigInt(R4.attoCircles), O4 = R4.tokenAddress;
|
|
15486
15486
|
else
|
|
15487
|
-
|
|
15487
|
+
D3 = BigInt(R4.staticAttoCircles), P = R4.tokenAddress;
|
|
15488
15488
|
else
|
|
15489
|
-
j3 = BigInt(
|
|
15490
|
-
let V3 = j3 +
|
|
15489
|
+
j3 = BigInt(R4.attoCircles);
|
|
15490
|
+
let V3 = j3 + N + i4.attoStaticCirclesToAttoCircles(D3), k4 = [];
|
|
15491
15491
|
if (j3 >= X4) {
|
|
15492
15492
|
if (console.log(`✓ Already have ${Number(j3) / 1000000000000000000} CRC unwrapped (target: ${Number(X4) / 1000000000000000000} CRC). No replenish needed.`), K2 !== G2) {
|
|
15493
|
-
let
|
|
15494
|
-
k4.push({ to:
|
|
15493
|
+
let R4 = await this.hubV2.toTokenId(Z3), F2 = this.hubV2.safeTransferFrom(G2, K2, R4, X4);
|
|
15494
|
+
k4.push({ to: F2.to, data: F2.data, value: F2.value ?? 0n });
|
|
15495
15495
|
}
|
|
15496
15496
|
return k4;
|
|
15497
15497
|
}
|
|
15498
|
-
let
|
|
15499
|
-
if (console.log(`Current unwrapped: ${Number(j3) / 1000000000000000000} CRC`), console.log(`Target amount: ${Number(X4) / 1000000000000000000} CRC`), console.log(`Need to acquire: ${Number(
|
|
15500
|
-
let
|
|
15501
|
-
if (
|
|
15502
|
-
let
|
|
15503
|
-
k4.push({ to: l4.to, data: l4.data, value: l4.value ?? 0n }),
|
|
15498
|
+
let T4 = X4 - j3;
|
|
15499
|
+
if (console.log(`Current unwrapped: ${Number(j3) / 1000000000000000000} CRC`), console.log(`Target amount: ${Number(X4) / 1000000000000000000} CRC`), console.log(`Need to acquire: ${Number(T4) / 1000000000000000000} CRC`), V3 >= X4) {
|
|
15500
|
+
let R4 = T4;
|
|
15501
|
+
if (N > 0n && O4 && R4 > 0n) {
|
|
15502
|
+
let F2 = R4 > N ? N : R4, l4 = new i03({ address: O4, rpcUrl: this.config.circlesRpcUrl }).unwrap(F2);
|
|
15503
|
+
k4.push({ to: l4.to, data: l4.data, value: l4.value ?? 0n }), R4 -= F2;
|
|
15504
15504
|
}
|
|
15505
|
-
if (
|
|
15506
|
-
let
|
|
15505
|
+
if (D3 > 0n && P && R4 > 0n) {
|
|
15506
|
+
let F2 = i4.attoCirclesToAttoStaticCircles(R4), m3 = F2 > D3 ? D3 : F2, e5 = new n03({ address: P, rpcUrl: this.config.circlesRpcUrl }).unwrap(m3);
|
|
15507
15507
|
k4.push({ to: e5.to, data: e5.data, value: e5.value ?? 0n });
|
|
15508
15508
|
}
|
|
15509
15509
|
if (K2 !== G2) {
|
|
15510
|
-
let
|
|
15510
|
+
let F2 = await this.hubV2.toTokenId(Z3), m3 = this.hubV2.safeTransferFrom(G2, K2, F2, X4);
|
|
15511
15511
|
k4.push({ to: m3.to, data: m3.data, value: m3.value ?? 0n });
|
|
15512
15512
|
}
|
|
15513
15513
|
return k4;
|
|
15514
15514
|
}
|
|
15515
|
-
let W2 = !await this.hubV2.isTrusted(G2, Z3),
|
|
15515
|
+
let W2 = !await this.hubV2.isTrusted(G2, Z3), U3 = BigInt(Math.floor(Date.now() / 1000) + 31536000), C4 = i4.truncateToInt64(T4), L3 = T4 % i4.FACTOR_1E12 !== 0n, w3 = i4.blowUpToBigInt(L3 ? C4 + 1n : C4), x3;
|
|
15516
15516
|
try {
|
|
15517
15517
|
x3 = await this.pathfinder.findPath({ from: G2, to: K2, targetFlow: w3, toTokens: [Z3], useWrappedBalances: true, simulatedTrusts: W2 ? [{ truster: G2, trustee: Z3 }] : undefined });
|
|
15518
|
-
} catch (
|
|
15519
|
-
let
|
|
15520
|
-
throw new a4(`Insufficient tokens to replenish. Target: ${m3.toFixed(6)} CRC, Current unwrapped: ${Number(j3) / 1000000000000000000} CRC, Need: ${l4.toFixed(6)} CRC, Available (including all paths): ${
|
|
15518
|
+
} catch (R4) {
|
|
15519
|
+
let F2 = Number(V3) / 1000000000000000000, m3 = Number(X4) / 1000000000000000000, l4 = Number(T4) / 1000000000000000000;
|
|
15520
|
+
throw new a4(`Insufficient tokens to replenish. Target: ${m3.toFixed(6)} CRC, Current unwrapped: ${Number(j3) / 1000000000000000000} CRC, Need: ${l4.toFixed(6)} CRC, Available (including all paths): ${F2.toFixed(6)} CRC. Cannot acquire the remaining ${(Number(T4 - (V3 - j3)) / 1000000000000000000).toFixed(6)} CRC.`, { code: "REPLENISH_INSUFFICIENT_TOKENS", source: "VALIDATION", context: { from: G2, tokenId: Z3, target: X4.toString(), unwrapped: j3.toString(), deficit: T4.toString(), available: V3.toString(), targetCrc: m3, unwrappedCrc: Number(j3) / 1000000000000000000, deficitCrc: l4, availableCrc: F2 } });
|
|
15521
15521
|
}
|
|
15522
15522
|
if (!x3.transfers || x3.transfers.length === 0)
|
|
15523
15523
|
throw a4.noPathFound(G2, K2, `No path to acquire token ${Z3}`);
|
|
15524
15524
|
if (x3.maxFlow < w3) {
|
|
15525
|
-
let
|
|
15526
|
-
throw new a4(`Pathfinder can only provide ${
|
|
15525
|
+
let R4 = Number(x3.maxFlow) / 1000000000000000000, F2 = Number(w3) / 1000000000000000000;
|
|
15526
|
+
throw new a4(`Pathfinder can only provide ${R4.toFixed(6)} CRC of the ${F2.toFixed(6)} CRC deficit needed for token ${Z3}.`, { code: "REPLENISH_INSUFFICIENT_PATH_FLOW", source: "PATHFINDING", context: { from: G2, tokenId: Z3, deficit: w3.toString(), pathFlow: x3.maxFlow.toString(), deficitCrc: F2, pathFlowCrc: R4 } });
|
|
15527
15527
|
}
|
|
15528
15528
|
if (W2) {
|
|
15529
|
-
let
|
|
15530
|
-
k4.push({ to:
|
|
15529
|
+
let R4 = this.hubV2.trust(Z3, U3);
|
|
15530
|
+
k4.push({ to: R4.to, data: R4.data, value: R4.value ?? 0n });
|
|
15531
15531
|
}
|
|
15532
15532
|
let y4 = await _J3(G2, this.config.circlesRpcUrl, x3), _4 = xJ2(x3, y4), A4 = Object.keys(_4).length > 0, E4 = [], c4 = [];
|
|
15533
15533
|
if (A4) {
|
|
15534
|
-
let
|
|
15535
|
-
E4 = [...
|
|
15534
|
+
let R4 = await this._getTokenBalanceMap(G2), F2 = this._createDemurragedUnwrapCalls(_4), { unwrapCalls: m3, wrapCalls: l4 } = this._createInflationaryUnwrapAndWrapCalls(_4, y4, R4);
|
|
15535
|
+
E4 = [...F2, ...m3], c4 = l4, x3 = EJ3(x3, y4);
|
|
15536
15536
|
}
|
|
15537
|
-
let h4 = IJ3(G2, K2, x3.maxFlow, x3.transfers),
|
|
15537
|
+
let h4 = IJ3(G2, K2, x3.maxFlow, x3.transfers), z2 = TJ3(h4), B4 = this.hubV2.operateFlowMatrix(h4.flowVertices, h4.flowEdges, z2, h4.packedCoordinates), S3 = { to: B4.to, data: B4.data, value: B4.value ?? 0n }, b4 = false;
|
|
15538
15538
|
try {
|
|
15539
|
-
|
|
15540
|
-
} catch (
|
|
15541
|
-
console.warn("Failed to check approval status, including approval transaction:",
|
|
15539
|
+
b4 = await this.hubV2.isApprovedForAll(G2, G2);
|
|
15540
|
+
} catch (R4) {
|
|
15541
|
+
console.warn("Failed to check approval status, including approval transaction:", R4);
|
|
15542
15542
|
}
|
|
15543
15543
|
if (W2) {
|
|
15544
|
-
let
|
|
15545
|
-
c4.push({ to:
|
|
15544
|
+
let R4 = this.hubV2.trust(Z3, 0n);
|
|
15545
|
+
c4.push({ to: R4.to, data: R4.data, value: R4.value ?? 0n });
|
|
15546
15546
|
}
|
|
15547
|
-
let
|
|
15548
|
-
return k4.push(...
|
|
15547
|
+
let I3 = b4 ? [] : [{ to: this.hubV2.setApprovalForAll(G2, true).to, data: this.hubV2.setApprovalForAll(G2, true).data, value: 0n }];
|
|
15548
|
+
return k4.push(...I3, ...E4, S3, ...c4), k4;
|
|
15549
15549
|
}
|
|
15550
15550
|
async _getTokenBalanceMap($3) {
|
|
15551
15551
|
let J2 = await this.balance.getTokenBalances($3), Q3 = new Map;
|
|
@@ -15558,7 +15558,7 @@ class v03 {
|
|
|
15558
15558
|
for (let [Q3, [Y2, G2]] of Object.entries($3)) {
|
|
15559
15559
|
if (G2 !== "CrcV2_ERC20WrapperDeployed_Demurraged")
|
|
15560
15560
|
continue;
|
|
15561
|
-
let K2 = new
|
|
15561
|
+
let K2 = new i03({ address: Q3, rpcUrl: this.config.circlesRpcUrl }).unwrap(Y2);
|
|
15562
15562
|
J2.push({ to: K2.to, data: K2.data, value: K2.value ?? 0n });
|
|
15563
15563
|
}
|
|
15564
15564
|
return J2;
|
|
@@ -15571,11 +15571,11 @@ class v03 {
|
|
|
15571
15571
|
let q3 = J2.get(Z3.toLowerCase()), M2 = Q3.get(Z3.toLowerCase()) || 0n;
|
|
15572
15572
|
if (M2 === 0n)
|
|
15573
15573
|
continue;
|
|
15574
|
-
let
|
|
15575
|
-
Y2.push({ to:
|
|
15576
|
-
let
|
|
15577
|
-
if (
|
|
15578
|
-
let P = this.hubV2.wrap(
|
|
15574
|
+
let N = new n03({ address: Z3, rpcUrl: this.config.circlesRpcUrl }).unwrap(M2);
|
|
15575
|
+
Y2.push({ to: N.to, data: N.data, value: N.value ?? 0n });
|
|
15576
|
+
let D3 = q3?.tokenOwner, O4 = i4.attoStaticCirclesToAttoCircles(M2) - K2;
|
|
15577
|
+
if (O4 > 0n) {
|
|
15578
|
+
let P = this.hubV2.wrap(D3, O4, 1);
|
|
15579
15579
|
G2.push({ to: P.to, data: P.data, value: P.value ?? 0n });
|
|
15580
15580
|
}
|
|
15581
15581
|
}
|
|
@@ -15599,21 +15599,22 @@ class v03 {
|
|
|
15599
15599
|
return Array.from(Y2);
|
|
15600
15600
|
}
|
|
15601
15601
|
}
|
|
15602
|
-
var y82 =
|
|
15602
|
+
var y82 = d03;
|
|
15603
15603
|
|
|
15604
15604
|
class kJ3 {
|
|
15605
15605
|
config;
|
|
15606
15606
|
rpcClient;
|
|
15607
15607
|
pathfinder;
|
|
15608
15608
|
trust;
|
|
15609
|
+
token;
|
|
15609
15610
|
hubV2;
|
|
15610
15611
|
referralsModule;
|
|
15611
15612
|
invitationFarm;
|
|
15612
15613
|
invitationModuleContract;
|
|
15613
15614
|
constructor($3) {
|
|
15614
15615
|
if (!$3.referralsServiceUrl)
|
|
15615
|
-
throw new
|
|
15616
|
-
this.config = $3, this.rpcClient = new R03($3.circlesRpcUrl), this.pathfinder = new W03(this.rpcClient), this.trust = new k03(this.rpcClient), this.hubV2 = new P03({ address: $3.v2HubAddress, rpcUrl: $3.circlesRpcUrl }), this.referralsModule = new
|
|
15616
|
+
throw new f2("referralsServiceUrl is required in config", { code: "INVITATION_MISSING_CONFIG", source: "INVITATIONS", context: { missingField: "referralsServiceUrl" } });
|
|
15617
|
+
this.config = $3, this.rpcClient = new R03($3.circlesRpcUrl), this.pathfinder = new W03(this.rpcClient), this.trust = new k03(this.rpcClient), this.token = new w03(this.rpcClient), this.hubV2 = new P03({ address: $3.v2HubAddress, rpcUrl: $3.circlesRpcUrl }), this.referralsModule = new o03({ address: $3.referralsModuleAddress, rpcUrl: $3.circlesRpcUrl }), this.invitationFarm = new t03({ address: $3.invitationFarmAddress, rpcUrl: $3.circlesRpcUrl }), this.invitationModuleContract = new A$2({ address: $3.invitationModuleAddress, rpcUrl: $3.circlesRpcUrl });
|
|
15617
15618
|
}
|
|
15618
15619
|
async ensureInviterSetup($3) {
|
|
15619
15620
|
let J2 = $3.toLowerCase(), Q3 = this.config.invitationModuleAddress, Y2 = [], G2 = new k$2({ address: J2, rpcUrl: this.config.circlesRpcUrl });
|
|
@@ -15627,9 +15628,9 @@ class kJ3 {
|
|
|
15627
15628
|
try {
|
|
15628
15629
|
let Q3 = await fetch(`${this.config.referralsServiceUrl}/store`, { method: "POST", headers: { accept: "application/json", "Content-Type": "application/json" }, body: JSON.stringify({ privateKey: J2, inviter: $3 }) });
|
|
15629
15630
|
if (!Q3.ok)
|
|
15630
|
-
throw new
|
|
15631
|
+
throw new f2(`HTTP error! status: ${Q3.status}`, { code: "INVITATION_HTTP_ERROR", source: "INVITATIONS", context: { status: Q3.status, url: `${this.config.referralsServiceUrl}/store` } });
|
|
15631
15632
|
} catch (Q3) {
|
|
15632
|
-
throw new
|
|
15633
|
+
throw new f2(`Failed to save referral data: ${Q3 instanceof Error ? Q3.message : "Unknown error"}`, { code: "INVITATION_SAVE_REFERRAL_FAILED", source: "INVITATIONS", cause: Q3 });
|
|
15633
15634
|
}
|
|
15634
15635
|
}
|
|
15635
15636
|
async listReferrals($3, J2 = 10, Q3 = 0) {
|
|
@@ -15638,12 +15639,12 @@ class kJ3 {
|
|
|
15638
15639
|
Y2.searchParams.set("limit", String(J2)), Y2.searchParams.set("offset", String(Q3));
|
|
15639
15640
|
let G2 = await fetch(Y2.toString(), { method: "GET", headers: { accept: "application/json" } });
|
|
15640
15641
|
if (!G2.ok)
|
|
15641
|
-
throw new
|
|
15642
|
+
throw new f2(`HTTP error! status: ${G2.status}`, { code: "INVITATION_HTTP_ERROR", source: "INVITATIONS", context: { status: G2.status, url: Y2.toString() } });
|
|
15642
15643
|
return await G2.json();
|
|
15643
15644
|
} catch (Y2) {
|
|
15644
|
-
if (Y2 instanceof
|
|
15645
|
+
if (Y2 instanceof f2)
|
|
15645
15646
|
throw Y2;
|
|
15646
|
-
throw new
|
|
15647
|
+
throw new f2(`Failed to list referrals: ${Y2 instanceof Error ? Y2.message : "Unknown error"}`, { code: "INVITATION_LIST_REFERRALS_FAILED", source: "INVITATIONS", cause: Y2 });
|
|
15647
15648
|
}
|
|
15648
15649
|
}
|
|
15649
15650
|
orderRealInviters($3, J2) {
|
|
@@ -15660,19 +15661,19 @@ class kJ3 {
|
|
|
15660
15661
|
async generateInvite($3, J2) {
|
|
15661
15662
|
let Q3 = $3.toLowerCase(), Y2 = J2.toLowerCase();
|
|
15662
15663
|
if (await this.hubV2.isHuman(Y2))
|
|
15663
|
-
throw
|
|
15664
|
+
throw f2.inviteeAlreadyRegistered(Q3, Y2);
|
|
15664
15665
|
let Z3 = await this.ensureInviterSetup(Q3), K2 = await this.getRealInviters(Q3), X4 = [...Z3];
|
|
15665
15666
|
if (K2.length > 0) {
|
|
15666
15667
|
console.log("[generateInvite] Using STANDARD PATH (proxy inviters available)");
|
|
15667
|
-
let q3 = K2[0].address, M2 = await this.findInvitePath(Q3, q3), j3 = await this.generateInviteData([Y2], false),
|
|
15668
|
-
X4.push(...
|
|
15668
|
+
let q3 = K2[0].address, M2 = await this.findInvitePath(Q3, q3), j3 = await this.generateInviteData([Y2], false), D3 = await new h03(this.config).buildFlowMatrixTx(Q3, this.config.invitationModuleAddress, M2, { toTokens: [q3], useWrappedBalances: true, txData: H$2(j3) }, true);
|
|
15669
|
+
X4.push(...D3);
|
|
15669
15670
|
} else {
|
|
15670
15671
|
console.log("[generateInvite] Using FARM FALLBACK PATH (no proxy inviters available)");
|
|
15671
|
-
let q3 = new
|
|
15672
|
+
let q3 = new h03(this.config), M2 = await this.findFarmInvitePath(Q3), j3 = await q3.buildFlowMatrixTx(Q3, E03, M2, { toTokens: [d03], useWrappedBalances: true }, true);
|
|
15672
15673
|
X4.push(...j3);
|
|
15673
|
-
let
|
|
15674
|
-
X4.push(
|
|
15675
|
-
let P = await this.invitationFarm.invitationModule(), V3 = Q03(["address"], [Y2]), k4 = this.hubV2.safeTransferFrom(Q3, P,
|
|
15674
|
+
let N = "0x20EcD8bDeb2F48d8a7c94E542aA4feC5790D9676", D3 = await this.invitationFarm.read("claimInvite", [], { from: N }), O4 = this.invitationFarm.claimInvite();
|
|
15675
|
+
X4.push(O4);
|
|
15676
|
+
let P = await this.invitationFarm.invitationModule(), V3 = Q03(["address"], [Y2]), k4 = this.hubV2.safeTransferFrom(Q3, P, D3, p5, V3);
|
|
15676
15677
|
X4.push(k4);
|
|
15677
15678
|
}
|
|
15678
15679
|
return X4;
|
|
@@ -15684,85 +15685,74 @@ class kJ3 {
|
|
|
15684
15685
|
else {
|
|
15685
15686
|
let Z3 = await this.getRealInviters(Q3);
|
|
15686
15687
|
if (Z3.length === 0)
|
|
15687
|
-
throw
|
|
15688
|
+
throw f2.noPathFound(Q3, this.config.invitationModuleAddress);
|
|
15688
15689
|
Y2 = Z3[0].address;
|
|
15689
15690
|
}
|
|
15690
|
-
let G2 = await this.pathfinder.findPath({ from: Q3, to: this.config.invitationModuleAddress, targetFlow: p5, toTokens: [Y2], useWrappedBalances: true });
|
|
15691
|
+
let G2 = await this.pathfinder.findPath({ from: Q3, to: this.config.invitationModuleAddress, targetFlow: p5, toTokens: [Y2], useWrappedBalances: true, simulatedTrusts: [{ truster: this.config.invitationModuleAddress, trustee: Q3 }] });
|
|
15691
15692
|
if (!G2.transfers || G2.transfers.length === 0)
|
|
15692
|
-
throw
|
|
15693
|
+
throw f2.noPathFound(Q3, this.config.invitationModuleAddress);
|
|
15693
15694
|
if (G2.maxFlow < p5) {
|
|
15694
15695
|
let K2 = Number(G2.maxFlow / p5);
|
|
15695
|
-
throw
|
|
15696
|
+
throw f2.insufficientBalance(1, K2, p5, G2.maxFlow, Q3, this.config.invitationModuleAddress);
|
|
15696
15697
|
}
|
|
15697
15698
|
return G2;
|
|
15698
15699
|
}
|
|
15699
15700
|
async findFarmInvitePath($3) {
|
|
15700
15701
|
let J2 = $3.toLowerCase(), Q3 = await this.pathfinder.findPath({ from: J2, to: E03, targetFlow: p5, toTokens: [y82], useWrappedBalances: true });
|
|
15701
15702
|
if (!Q3.transfers || Q3.transfers.length === 0)
|
|
15702
|
-
throw
|
|
15703
|
+
throw f2.noPathFound(J2, E03);
|
|
15703
15704
|
if (Q3.maxFlow < p5) {
|
|
15704
15705
|
let G2 = Number(Q3.maxFlow / p5);
|
|
15705
|
-
throw
|
|
15706
|
+
throw f2.insufficientBalance(1, G2, p5, Q3.maxFlow, J2, E03);
|
|
15706
15707
|
}
|
|
15707
15708
|
return Q3;
|
|
15708
15709
|
}
|
|
15709
15710
|
async getRealInviters($3) {
|
|
15710
|
-
|
|
15711
|
-
|
|
15712
|
-
if (p03 !== "0x0000000000000000000000000000000000000000") {
|
|
15713
|
-
let C4 = await this.trust.getTrusts(p03);
|
|
15714
|
-
q3 = new Set([...C4.map((b4) => b4.objectAvatar.toLowerCase())]);
|
|
15715
|
-
}
|
|
15716
|
-
let M2 = [];
|
|
15717
|
-
for (let C4 of G2)
|
|
15718
|
-
if (X4.has(C4) && !q3.has(C4))
|
|
15719
|
-
M2.push(C4);
|
|
15720
|
-
let j3 = [...M2];
|
|
15721
|
-
if (!q3.has(J2))
|
|
15722
|
-
j3.push(J2);
|
|
15723
|
-
if (j3.length === 0)
|
|
15711
|
+
let J2 = $3.toLowerCase(), [Q3, Y2, G2, Z3, K2] = await Promise.all([d03 !== "0x0000000000000000000000000000000000000000" ? this.trust.getTrusts(d03) : Promise.resolve([]), this.trust.getTrustedBy(J2), this.trust.getMutualTrusts(J2), this.trust.getTrusts(this.config.invitationModuleAddress), this.trust.getMutualTrusts(this.config.invitationModuleAddress)]), X4 = new Set(Q3.map((U3) => U3.objectAvatar.toLowerCase())), q3 = new Set([...Y2.map((U3) => U3.objectAvatar.toLowerCase()), ...G2.map((U3) => U3.objectAvatar.toLowerCase())]), M2 = new Set([...Z3.map((U3) => U3.objectAvatar.toLowerCase()), ...K2.map((U3) => U3.objectAvatar.toLowerCase())]), N = [...[...q3].filter((U3) => M2.has(U3) && !X4.has(U3)), J2];
|
|
15712
|
+
if (N.length === 0)
|
|
15724
15713
|
return [];
|
|
15725
|
-
let
|
|
15726
|
-
if (!
|
|
15714
|
+
let D3 = await this.pathfinder.findPath({ from: J2, to: this.config.invitationModuleAddress, useWrappedBalances: true, targetFlow: Z$, toTokens: N, simulatedTrusts: [{ truster: this.config.invitationModuleAddress, trustee: J2 }] });
|
|
15715
|
+
if (!D3.transfers || D3.transfers.length === 0)
|
|
15727
15716
|
return [];
|
|
15728
|
-
let D3 = new
|
|
15729
|
-
for (let
|
|
15730
|
-
|
|
15731
|
-
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
let
|
|
15735
|
-
for (let
|
|
15736
|
-
let
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
|
|
15740
|
-
let
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
|
|
15744
|
-
|
|
15717
|
+
let O4 = this.config.invitationModuleAddress.toLowerCase(), P = D3.transfers.filter((U3) => U3.to.toLowerCase() === O4), V3 = [...new Set(P.map((U3) => U3.tokenOwner.toLowerCase()))], k4 = await this.token.getTokenInfoBatch(V3), T4 = new Map;
|
|
15718
|
+
for (let U3 of k4) {
|
|
15719
|
+
let C4 = U3.tokenAddress ?? U3.token;
|
|
15720
|
+
if (C4 && U3?.tokenOwner)
|
|
15721
|
+
T4.set(C4.toLowerCase(), U3.tokenOwner.toLowerCase());
|
|
15722
|
+
}
|
|
15723
|
+
let v3 = new Map;
|
|
15724
|
+
for (let U3 of P) {
|
|
15725
|
+
let C4 = U3.tokenOwner.toLowerCase(), L3 = T4.get(C4) ?? C4;
|
|
15726
|
+
v3.set(L3, (v3.get(L3) ?? 0n) + U3.value);
|
|
15727
|
+
}
|
|
15728
|
+
let W2 = [];
|
|
15729
|
+
for (let [U3, C4] of v3.entries()) {
|
|
15730
|
+
let L3 = Number(C4 / p5);
|
|
15731
|
+
if (L3 >= 1)
|
|
15732
|
+
W2.push({ address: U3, possibleInvites: L3 });
|
|
15733
|
+
}
|
|
15734
|
+
return this.orderRealInviters(W2, J2);
|
|
15745
15735
|
}
|
|
15746
15736
|
async generateReferral($3) {
|
|
15747
15737
|
let J2 = $3.toLowerCase(), Q3 = F$2(), Y2 = g$2(Q3), G2 = await this.ensureInviterSetup(J2), Z3 = await this.getRealInviters(J2), K2 = [...G2];
|
|
15748
15738
|
if (Z3.length > 0) {
|
|
15749
15739
|
console.log("[generateReferral] Using STANDARD PATH (proxy inviters available)");
|
|
15750
|
-
let X4 = new
|
|
15751
|
-
K2.push(...
|
|
15740
|
+
let X4 = new h03(this.config), q3 = await this.generateInviteData([Y2], true), M2 = Z3[0].address, j3 = await this.findInvitePath(J2, M2), N = await X4.buildFlowMatrixTx(J2, this.config.invitationModuleAddress, j3, { toTokens: [M2], useWrappedBalances: true, txData: H$2(q3) }, true);
|
|
15741
|
+
K2.push(...N);
|
|
15752
15742
|
} else {
|
|
15753
15743
|
console.log("[generateReferral] Using FARM FALLBACK PATH (no proxy inviters available)");
|
|
15754
|
-
let X4 = new
|
|
15744
|
+
let X4 = new h03(this.config), q3 = await this.findFarmInvitePath(J2), M2 = await X4.buildFlowMatrixTx(J2, E03, q3, { toTokens: [y82], useWrappedBalances: true }, true);
|
|
15755
15745
|
K2.push(...M2);
|
|
15756
|
-
let j3 = "0x20EcD8bDeb2F48d8a7c94E542aA4feC5790D9676",
|
|
15757
|
-
K2.push(
|
|
15758
|
-
let
|
|
15746
|
+
let j3 = "0x20EcD8bDeb2F48d8a7c94E542aA4feC5790D9676", N = await this.invitationFarm.read("claimInvite", [], { from: j3 }), D3 = this.invitationFarm.claimInvite();
|
|
15747
|
+
K2.push(D3);
|
|
15748
|
+
let O4 = await this.invitationFarm.invitationModule(), P = this.referralsModule.createAccount(Y2).data, V3 = Q03(["address", "bytes"], [this.config.referralsModuleAddress, P]), k4 = this.hubV2.safeTransferFrom(J2, O4, N, p5, V3);
|
|
15759
15749
|
K2.push(k4);
|
|
15760
15750
|
}
|
|
15761
15751
|
return { transactions: K2, privateKey: Q3 };
|
|
15762
15752
|
}
|
|
15763
15753
|
async generateInviteData($3, J2 = true) {
|
|
15764
15754
|
if ($3.length === 0)
|
|
15765
|
-
throw
|
|
15755
|
+
throw f2.noAddressesProvided();
|
|
15766
15756
|
if (!J2)
|
|
15767
15757
|
if ($3.length === 1)
|
|
15768
15758
|
return Q03(["address"], [$3[0]]);
|
|
@@ -15777,8 +15767,8 @@ class kJ3 {
|
|
|
15777
15767
|
}
|
|
15778
15768
|
}
|
|
15779
15769
|
computeAddress($3) {
|
|
15780
|
-
let Q3 = $3.toLowerCase().replace("0x", "").padStart(64, "0"), Y2 = i$2.replace("0x", "") + Q3, G2 = f$2("0x" + Y2), Z3 = "ff", K2 = d$2.toLowerCase().replace("0x", ""), X4 = G2.replace("0x", ""), q3 = n$2.replace("0x", ""), M2 = "ff" + K2 + X4 + q3,
|
|
15781
|
-
return
|
|
15770
|
+
let Q3 = $3.toLowerCase().replace("0x", "").padStart(64, "0"), Y2 = i$2.replace("0x", "") + Q3, G2 = f$2("0x" + Y2), Z3 = "ff", K2 = d$2.toLowerCase().replace("0x", ""), X4 = G2.replace("0x", ""), q3 = n$2.replace("0x", ""), M2 = "ff" + K2 + X4 + q3, N = "0x" + f$2("0x" + M2).slice(-40);
|
|
15771
|
+
return C03(N);
|
|
15782
15772
|
}
|
|
15783
15773
|
generateSecrets($3) {
|
|
15784
15774
|
return Array.from({ length: $3 }, () => {
|
|
@@ -15795,7 +15785,7 @@ class wQ {
|
|
|
15795
15785
|
referralsModule;
|
|
15796
15786
|
hubV2;
|
|
15797
15787
|
constructor($3) {
|
|
15798
|
-
this.referralsModuleAddress = $3.referralsModuleAddress, this.invitations = new kJ3($3), this.invitationFarm = new
|
|
15788
|
+
this.referralsModuleAddress = $3.referralsModuleAddress, this.invitations = new kJ3($3), this.invitationFarm = new t03({ address: $3.invitationFarmAddress, rpcUrl: $3.circlesRpcUrl }), this.referralsModule = new o03({ address: $3.referralsModuleAddress, rpcUrl: $3.circlesRpcUrl }), this.hubV2 = new P03({ address: $3.v2HubAddress, rpcUrl: $3.circlesRpcUrl });
|
|
15799
15789
|
}
|
|
15800
15790
|
async getQuota($3) {
|
|
15801
15791
|
return this.invitationFarm.inviterQuota($3);
|
|
@@ -15808,19 +15798,19 @@ class wQ {
|
|
|
15808
15798
|
}
|
|
15809
15799
|
async generateReferrals($3, J2) {
|
|
15810
15800
|
if (J2 <= 0)
|
|
15811
|
-
throw new
|
|
15801
|
+
throw new f2("Count must be greater than 0", { code: "INVITATION_INVALID_COUNT", source: "VALIDATION", context: { count: J2 } });
|
|
15812
15802
|
let Q3 = $3.toLowerCase(), Y2 = J2 === 1, G2 = await this.simulateClaim(Q3, J2);
|
|
15813
15803
|
if (!G2.length)
|
|
15814
|
-
throw new
|
|
15804
|
+
throw new f2("No invitation IDs returned from claim", { code: "INVITATION_NO_IDS", source: "INVITATIONS", context: { inviter: Q3, count: J2 } });
|
|
15815
15805
|
let Z3 = this.invitations.generateSecrets(J2), K2 = Z3.map((j3) => j3.signer), X4 = await this.invitationFarm.invitationModule(), q3 = Y2 ? this.invitationFarm.claimInvite() : this.invitationFarm.claimInvites(BigInt(J2)), M2 = Y2 ? this.buildReferralTransfer(Q3, X4, G2[0], K2[0]) : this.buildBatchReferralTransfer(Q3, X4, G2, K2);
|
|
15816
15806
|
return { referrals: Z3, transactions: [q3, M2] };
|
|
15817
15807
|
}
|
|
15818
15808
|
async generateInvites($3, J2) {
|
|
15819
15809
|
if (J2.length === 0)
|
|
15820
|
-
throw new
|
|
15810
|
+
throw new f2("At least one invitee address must be provided", { code: "INVITATION_INVALID_COUNT", source: "VALIDATION", context: { count: 0 } });
|
|
15821
15811
|
let Q3 = $3.toLowerCase(), Y2 = J2.map((j3) => j3.toLowerCase()), G2 = Y2.length, Z3 = G2 === 1, K2 = await this.simulateClaim(Q3, G2);
|
|
15822
15812
|
if (!K2.length)
|
|
15823
|
-
throw new
|
|
15813
|
+
throw new f2("No invitation IDs returned from claim", { code: "INVITATION_NO_IDS", source: "INVITATIONS", context: { inviter: Q3, count: G2 } });
|
|
15824
15814
|
let X4 = await this.invitationFarm.invitationModule(), q3 = Z3 ? this.invitationFarm.claimInvite() : this.invitationFarm.claimInvites(BigInt(G2)), M2 = Z3 ? this.buildInviteTransfer(Q3, X4, K2[0], Y2[0]) : this.buildBatchInviteTransfer(Q3, X4, K2, Y2);
|
|
15825
15815
|
return { invitees: Y2, transactions: [q3, M2] };
|
|
15826
15816
|
}
|