@aboutcircles/sdk 0.1.15 → 0.1.16
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/avatars/HumanAvatar.d.ts +11 -3
- package/dist/avatars/HumanAvatar.d.ts.map +1 -1
- package/dist/avatars/HumanAvatar.js +18 -6
- package/dist/index.js +315 -290
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12524,7 +12524,7 @@ function E8($3, J2) {
|
|
|
12524
12524
|
return false;
|
|
12525
12525
|
return J2;
|
|
12526
12526
|
}
|
|
12527
|
-
function
|
|
12527
|
+
function g$2($3) {
|
|
12528
12528
|
let { event: J2, values: Q4 } = $3, G2 = { $event: J2, blockNumber: Q4.blockNumber ? a03(Q4.blockNumber) : 0, timestamp: Q4.timestamp ? a03(Q4.timestamp) : undefined, transactionIndex: Q4.transactionIndex ? a03(Q4.transactionIndex) : 0, logIndex: Q4.logIndex ? a03(Q4.logIndex) : 0, transactionHash: Q4.transactionHash };
|
|
12529
12529
|
for (let [Y2, Z3] of Object.entries(Q4)) {
|
|
12530
12530
|
if (["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash"].includes(Y2))
|
|
@@ -12534,7 +12534,7 @@ function f$2($3) {
|
|
|
12534
12534
|
return G2;
|
|
12535
12535
|
}
|
|
12536
12536
|
function z$2($3) {
|
|
12537
|
-
return $3.map(
|
|
12537
|
+
return $3.map(g$2);
|
|
12538
12538
|
}
|
|
12539
12539
|
|
|
12540
12540
|
class h03 {
|
|
@@ -12733,7 +12733,7 @@ function T03($3) {
|
|
|
12733
12733
|
if (!Number.isSafeInteger($3) || $3 < 0)
|
|
12734
12734
|
throw Error("positive integer expected, got " + $3);
|
|
12735
12735
|
}
|
|
12736
|
-
function
|
|
12736
|
+
function K02($3, ...J2) {
|
|
12737
12737
|
if (!k8($3))
|
|
12738
12738
|
throw Error("Uint8Array expected");
|
|
12739
12739
|
if (J2.length > 0 && !J2.includes($3.length))
|
|
@@ -12744,14 +12744,14 @@ function yJ($3) {
|
|
|
12744
12744
|
throw Error("Hash should be wrapped by utils.createHasher");
|
|
12745
12745
|
T03($3.outputLen), T03($3.blockLen);
|
|
12746
12746
|
}
|
|
12747
|
-
function
|
|
12747
|
+
function M03($3, J2 = true) {
|
|
12748
12748
|
if ($3.destroyed)
|
|
12749
12749
|
throw Error("Hash instance has been destroyed");
|
|
12750
12750
|
if (J2 && $3.finished)
|
|
12751
12751
|
throw Error("Hash#digest() has already been called");
|
|
12752
12752
|
}
|
|
12753
12753
|
function V$2($3, J2) {
|
|
12754
|
-
|
|
12754
|
+
K02($3);
|
|
12755
12755
|
let Q4 = J2.outputLen;
|
|
12756
12756
|
if ($3.length < Q4)
|
|
12757
12757
|
throw Error("digestInto() expects output buffer of length at least " + Q4);
|
|
@@ -12759,14 +12759,14 @@ function V$2($3, J2) {
|
|
|
12759
12759
|
function FJ3($3) {
|
|
12760
12760
|
return new Uint32Array($3.buffer, $3.byteOffset, Math.floor($3.byteLength / 4));
|
|
12761
12761
|
}
|
|
12762
|
-
function
|
|
12762
|
+
function X03(...$3) {
|
|
12763
12763
|
for (let J2 = 0;J2 < $3.length; J2++)
|
|
12764
12764
|
$3[J2].fill(0);
|
|
12765
12765
|
}
|
|
12766
12766
|
function O$2($3) {
|
|
12767
12767
|
return new DataView($3.buffer, $3.byteOffset, $3.byteLength);
|
|
12768
12768
|
}
|
|
12769
|
-
function
|
|
12769
|
+
function Y03($3, J2) {
|
|
12770
12770
|
return $3 << 32 - J2 | $3 >>> J2;
|
|
12771
12771
|
}
|
|
12772
12772
|
var w8 = (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
@@ -12778,7 +12778,7 @@ function F82($3) {
|
|
|
12778
12778
|
$3[J2] = y83($3[J2]);
|
|
12779
12779
|
return $3;
|
|
12780
12780
|
}
|
|
12781
|
-
var
|
|
12781
|
+
var f$2 = w8 ? ($3) => $3 : F82;
|
|
12782
12782
|
function b82($3) {
|
|
12783
12783
|
if (typeof $3 !== "string")
|
|
12784
12784
|
throw Error("string expected");
|
|
@@ -12787,13 +12787,13 @@ function b82($3) {
|
|
|
12787
12787
|
function _03($3) {
|
|
12788
12788
|
if (typeof $3 === "string")
|
|
12789
12789
|
$3 = b82($3);
|
|
12790
|
-
return
|
|
12790
|
+
return K02($3), $3;
|
|
12791
12791
|
}
|
|
12792
12792
|
function bJ2(...$3) {
|
|
12793
12793
|
let J2 = 0;
|
|
12794
12794
|
for (let G2 = 0;G2 < $3.length; G2++) {
|
|
12795
12795
|
let Y2 = $3[G2];
|
|
12796
|
-
|
|
12796
|
+
K02(Y2), J2 += Y2.length;
|
|
12797
12797
|
}
|
|
12798
12798
|
let Q4 = new Uint8Array(J2);
|
|
12799
12799
|
for (let G2 = 0, Y2 = 0;G2 < $3.length; G2++) {
|
|
@@ -12809,16 +12809,16 @@ function R$2($3) {
|
|
|
12809
12809
|
let J2 = (G2) => $3().update(_03(G2)).digest(), Q4 = $3();
|
|
12810
12810
|
return J2.outputLen = Q4.outputLen, J2.blockLen = Q4.blockLen, J2.create = () => $3(), J2;
|
|
12811
12811
|
}
|
|
12812
|
-
function
|
|
12812
|
+
function gJ3($3 = 32) {
|
|
12813
12813
|
if (I02 && typeof I02.getRandomValues === "function")
|
|
12814
12814
|
return I02.getRandomValues(new Uint8Array($3));
|
|
12815
12815
|
if (I02 && typeof I02.randomBytes === "function")
|
|
12816
12816
|
return Uint8Array.from(I02.randomBytes($3));
|
|
12817
12817
|
throw Error("crypto.getRandomValues must be defined");
|
|
12818
12818
|
}
|
|
12819
|
-
var
|
|
12819
|
+
var g82 = BigInt(0);
|
|
12820
12820
|
var r02 = BigInt(1);
|
|
12821
|
-
var
|
|
12821
|
+
var f82 = BigInt(2);
|
|
12822
12822
|
var v83 = BigInt(7);
|
|
12823
12823
|
var h83 = BigInt(256);
|
|
12824
12824
|
var m82 = BigInt(113);
|
|
@@ -12827,16 +12827,16 @@ var mJ2 = [];
|
|
|
12827
12827
|
var uJ2 = [];
|
|
12828
12828
|
for (let $3 = 0, J2 = r02, Q4 = 1, G2 = 0;$3 < 24; $3++) {
|
|
12829
12829
|
[Q4, G2] = [G2, (2 * Q4 + 3 * G2) % 5], hJ.push(2 * (5 * G2 + Q4)), mJ2.push(($3 + 1) * ($3 + 2) / 2 % 64);
|
|
12830
|
-
let Y2 =
|
|
12830
|
+
let Y2 = g82;
|
|
12831
12831
|
for (let Z3 = 0;Z3 < 7; Z3++)
|
|
12832
|
-
if (J2 = (J2 << r02 ^ (J2 >> v83) * m82) % h83, J2 &
|
|
12832
|
+
if (J2 = (J2 << r02 ^ (J2 >> v83) * m82) % h83, J2 & f82)
|
|
12833
12833
|
Y2 ^= r02 << (r02 << BigInt(Z3)) - r02;
|
|
12834
12834
|
uJ2.push(Y2);
|
|
12835
12835
|
}
|
|
12836
12836
|
var cJ2 = EJ3(uJ2, true);
|
|
12837
12837
|
var u83 = cJ2[0];
|
|
12838
12838
|
var c82 = cJ2[1];
|
|
12839
|
-
var
|
|
12839
|
+
var fJ2 = ($3, J2, Q4) => Q4 > 32 ? kJ3($3, J2, Q4) : xJ2($3, J2, Q4);
|
|
12840
12840
|
var vJ3 = ($3, J2, Q4) => Q4 > 32 ? wJ3($3, J2, Q4) : AJ2($3, J2, Q4);
|
|
12841
12841
|
function l82($3, J2 = 24) {
|
|
12842
12842
|
let Q4 = new Uint32Array(10);
|
|
@@ -12844,13 +12844,13 @@ function l82($3, J2 = 24) {
|
|
|
12844
12844
|
for (let K3 = 0;K3 < 10; K3++)
|
|
12845
12845
|
Q4[K3] = $3[K3] ^ $3[K3 + 10] ^ $3[K3 + 20] ^ $3[K3 + 30] ^ $3[K3 + 40];
|
|
12846
12846
|
for (let K3 = 0;K3 < 10; K3 += 2) {
|
|
12847
|
-
let X4 = (K3 + 8) % 10, q3 = (K3 + 2) % 10, M2 = Q4[q3], j4 = Q4[q3 + 1], N =
|
|
12847
|
+
let X4 = (K3 + 8) % 10, q3 = (K3 + 2) % 10, M2 = Q4[q3], j4 = Q4[q3 + 1], N = fJ2(M2, j4, 1) ^ Q4[X4], z2 = vJ3(M2, j4, 1) ^ Q4[X4 + 1];
|
|
12848
12848
|
for (let D3 = 0;D3 < 50; D3 += 10)
|
|
12849
12849
|
$3[K3 + D3] ^= N, $3[K3 + D3 + 1] ^= z2;
|
|
12850
12850
|
}
|
|
12851
12851
|
let Y2 = $3[2], Z3 = $3[3];
|
|
12852
12852
|
for (let K3 = 0;K3 < 24; K3++) {
|
|
12853
|
-
let X4 = mJ2[K3], q3 =
|
|
12853
|
+
let X4 = mJ2[K3], q3 = fJ2(Y2, Z3, X4), M2 = vJ3(Y2, Z3, X4), j4 = hJ[K3];
|
|
12854
12854
|
Y2 = $3[j4], Z3 = $3[j4 + 1], $3[j4] = q3, $3[j4 + 1] = M2;
|
|
12855
12855
|
}
|
|
12856
12856
|
for (let K3 = 0;K3 < 50; K3 += 10) {
|
|
@@ -12861,7 +12861,7 @@ function l82($3, J2 = 24) {
|
|
|
12861
12861
|
}
|
|
12862
12862
|
$3[0] ^= u83[G2], $3[1] ^= c82[G2];
|
|
12863
12863
|
}
|
|
12864
|
-
|
|
12864
|
+
X03(Q4);
|
|
12865
12865
|
}
|
|
12866
12866
|
|
|
12867
12867
|
class v$2 extends E03 {
|
|
@@ -12875,10 +12875,10 @@ class v$2 extends E03 {
|
|
|
12875
12875
|
return this._cloneInto();
|
|
12876
12876
|
}
|
|
12877
12877
|
keccak() {
|
|
12878
|
-
|
|
12878
|
+
f$2(this.state32), l82(this.state32, this.rounds), f$2(this.state32), this.posOut = 0, this.pos = 0;
|
|
12879
12879
|
}
|
|
12880
12880
|
update($3) {
|
|
12881
|
-
|
|
12881
|
+
M03(this), $3 = _03($3), K02($3);
|
|
12882
12882
|
let { blockLen: J2, state: Q4 } = this, G2 = $3.length;
|
|
12883
12883
|
for (let Y2 = 0;Y2 < G2; ) {
|
|
12884
12884
|
let Z3 = Math.min(J2 - this.pos, G2 - Y2);
|
|
@@ -12899,7 +12899,7 @@ class v$2 extends E03 {
|
|
|
12899
12899
|
$3[G2 - 1] ^= 128, this.keccak();
|
|
12900
12900
|
}
|
|
12901
12901
|
writeInto($3) {
|
|
12902
|
-
|
|
12902
|
+
M03(this, false), K02($3), this.finish();
|
|
12903
12903
|
let J2 = this.state, { blockLen: Q4 } = this;
|
|
12904
12904
|
for (let G2 = 0, Y2 = $3.length;G2 < Y2; ) {
|
|
12905
12905
|
if (this.posOut >= Q4)
|
|
@@ -12926,7 +12926,7 @@ class v$2 extends E03 {
|
|
|
12926
12926
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
12927
12927
|
}
|
|
12928
12928
|
destroy() {
|
|
12929
|
-
this.destroyed = true,
|
|
12929
|
+
this.destroyed = true, X03(this.state);
|
|
12930
12930
|
}
|
|
12931
12931
|
_cloneInto($3) {
|
|
12932
12932
|
let { blockLen: J2, suffix: Q4, outputLen: G2, rounds: Y2, enableXOF: Z3 } = this;
|
|
@@ -12944,17 +12944,17 @@ function C$2($3) {
|
|
|
12944
12944
|
J2 += lJ2[$3[Q4]];
|
|
12945
12945
|
return J2;
|
|
12946
12946
|
}
|
|
12947
|
-
function
|
|
12947
|
+
function P$2($3) {
|
|
12948
12948
|
let J2 = $3.startsWith("0x") ? $3.slice(2) : $3, Q4 = new Uint8Array(J2.length / 2);
|
|
12949
12949
|
for (let G2 = 0;G2 < J2.length; G2 += 2)
|
|
12950
12950
|
Q4[G2 / 2] = parseInt(J2.slice(G2, G2 + 2), 16);
|
|
12951
12951
|
return Q4;
|
|
12952
12952
|
}
|
|
12953
12953
|
var u4 = 64;
|
|
12954
|
-
var
|
|
12955
|
-
var
|
|
12956
|
-
var
|
|
12957
|
-
function
|
|
12954
|
+
var L$2 = 32;
|
|
12955
|
+
var B$2 = ($3) => $3.startsWith("0x") ? $3.slice(2) : $3;
|
|
12956
|
+
var q02 = ($3) => $3.toString(16).padStart(u4, "0");
|
|
12957
|
+
function P03($3) {
|
|
12958
12958
|
let J2 = $3.toLowerCase().replace("0x", ""), Q4 = C$2(m03(new TextEncoder().encode(J2))).slice(2), G2 = "0x";
|
|
12959
12959
|
for (let Y2 = 0;Y2 < J2.length; Y2++)
|
|
12960
12960
|
G2 += parseInt(Q4[Y2], 16) >= 8 ? J2[Y2].toUpperCase() : J2[Y2];
|
|
@@ -13004,14 +13004,14 @@ function C03($3, J2, Q4) {
|
|
|
13004
13004
|
function n82($3, J2, Q4) {
|
|
13005
13005
|
let G2 = $3.slice(0, $3.indexOf("[")), Y2 = $3.endsWith("[]"), Z3 = u03(G2, Q4), K3;
|
|
13006
13006
|
if (Z3) {
|
|
13007
|
-
let X4 = J2.map((j4) => C03(G2, j4, Q4)), q3 = J2.length *
|
|
13007
|
+
let X4 = J2.map((j4) => C03(G2, j4, Q4)), q3 = J2.length * L$2;
|
|
13008
13008
|
K3 = X4.map((j4) => {
|
|
13009
13009
|
let N = q3;
|
|
13010
|
-
return q3 += j4.length / 2,
|
|
13010
|
+
return q3 += j4.length / 2, q02(N);
|
|
13011
13011
|
}).join("") + X4.join("");
|
|
13012
13012
|
} else
|
|
13013
13013
|
K3 = J2.map((X4) => C03(G2, X4, Q4)).join("");
|
|
13014
|
-
return Y2 ?
|
|
13014
|
+
return Y2 ? q02(J2.length) + K3 : K3;
|
|
13015
13015
|
}
|
|
13016
13016
|
function o82($3, J2) {
|
|
13017
13017
|
let Q4 = Array.isArray(J2), G2 = [], Y2 = [], Z3 = [];
|
|
@@ -13023,10 +13023,10 @@ function o82($3, J2) {
|
|
|
13023
13023
|
G2.push(C03(X4.type, q3, X4.components));
|
|
13024
13024
|
}
|
|
13025
13025
|
if (Y2.length > 0) {
|
|
13026
|
-
let K3 = G2.reduce((M2, j4, N) => M2 + (Z3[N] ?
|
|
13026
|
+
let K3 = G2.reduce((M2, j4, N) => M2 + (Z3[N] ? L$2 : j4.length / 2), 0), X4 = "", q3 = 0;
|
|
13027
13027
|
for (let M2 = 0;M2 < $3.length; M2++)
|
|
13028
13028
|
if (Z3[M2])
|
|
13029
|
-
X4 +=
|
|
13029
|
+
X4 += q02(K3), K3 += Y2[q3].length / 2, q3++;
|
|
13030
13030
|
else
|
|
13031
13031
|
X4 += G2[M2];
|
|
13032
13032
|
return X4 + Y2.join("");
|
|
@@ -13035,12 +13035,12 @@ function o82($3, J2) {
|
|
|
13035
13035
|
}
|
|
13036
13036
|
function t83($3, J2) {
|
|
13037
13037
|
if ($3 === "address")
|
|
13038
|
-
return
|
|
13038
|
+
return B$2(J2).toLowerCase().padStart(u4, "0");
|
|
13039
13039
|
if ($3 === "bool")
|
|
13040
|
-
return
|
|
13040
|
+
return q02(J2 ? 1 : 0);
|
|
13041
13041
|
if ($3.startsWith("uint")) {
|
|
13042
13042
|
let Q4 = typeof J2 === "bigint" ? J2 : BigInt(J2);
|
|
13043
|
-
return
|
|
13043
|
+
return q02(Q4);
|
|
13044
13044
|
}
|
|
13045
13045
|
if ($3.startsWith("int")) {
|
|
13046
13046
|
let Q4 = typeof J2 === "bigint" ? J2 : BigInt(J2);
|
|
@@ -13048,16 +13048,16 @@ function t83($3, J2) {
|
|
|
13048
13048
|
let G2 = $3 === "int" ? 256 : parseInt($3.slice(3));
|
|
13049
13049
|
Q4 = (1n << BigInt(G2)) + Q4;
|
|
13050
13050
|
}
|
|
13051
|
-
return
|
|
13051
|
+
return q02(Q4);
|
|
13052
13052
|
}
|
|
13053
13053
|
if ($3.startsWith("bytes") && $3 !== "bytes")
|
|
13054
|
-
return
|
|
13054
|
+
return B$2(J2).padEnd(u4, "0");
|
|
13055
13055
|
if ($3 === "bytes") {
|
|
13056
|
-
let Q4 =
|
|
13056
|
+
let Q4 = B$2(J2), G2 = q02(Q4.length / 2), Y2 = Q4.padEnd(Math.ceil(Q4.length / u4) * u4, "0");
|
|
13057
13057
|
return G2 + Y2;
|
|
13058
13058
|
}
|
|
13059
13059
|
if ($3 === "string") {
|
|
13060
|
-
let Q4 = Array.from(new TextEncoder().encode(J2)).map((Z3) => Z3.toString(16).padStart(2, "0")).join(""), G2 =
|
|
13060
|
+
let Q4 = Array.from(new TextEncoder().encode(J2)).map((Z3) => Z3.toString(16).padStart(2, "0")).join(""), G2 = q02(Q4.length / 2), Y2 = Q4.padEnd(Math.ceil(Q4.length / u4) * u4, "0");
|
|
13061
13061
|
return G2 + Y2;
|
|
13062
13062
|
}
|
|
13063
13063
|
throw Error(`Unsupported type: ${$3}`);
|
|
@@ -13101,7 +13101,7 @@ function s82($3, J2, Q4) {
|
|
|
13101
13101
|
function r82($3, J2, Q4) {
|
|
13102
13102
|
let G2 = J2.slice(Q4, Q4 + u4);
|
|
13103
13103
|
if ($3 === "address")
|
|
13104
|
-
return { value:
|
|
13104
|
+
return { value: P03("0x" + G2.slice(24)), consumed: u4 };
|
|
13105
13105
|
if ($3 === "bool")
|
|
13106
13106
|
return { value: parseInt(G2, 16) !== 0, consumed: u4 };
|
|
13107
13107
|
if ($3.startsWith("uint"))
|
|
@@ -13135,18 +13135,18 @@ function H$2($3) {
|
|
|
13135
13135
|
throw Error(`Expected ${K3.length} arguments, got ${G2.length}`);
|
|
13136
13136
|
let X4 = [], q3 = [], M2 = [];
|
|
13137
13137
|
for (let D3 = 0;D3 < K3.length; D3++) {
|
|
13138
|
-
let H4 = K3[D3], V2 = H4.components,
|
|
13139
|
-
if (M2.push(
|
|
13138
|
+
let H4 = K3[D3], V2 = H4.components, B4 = u03(H4.type, V2);
|
|
13139
|
+
if (M2.push(B4), B4)
|
|
13140
13140
|
X4.push(""), q3.push(C03(H4.type, G2[D3], V2));
|
|
13141
13141
|
else
|
|
13142
13142
|
X4.push(C03(H4.type, G2[D3], V2));
|
|
13143
13143
|
}
|
|
13144
13144
|
if (q3.length === 0)
|
|
13145
13145
|
return Z3 + X4.join("");
|
|
13146
|
-
let j4 = X4.reduce((D3, H4, V2) => D3 + (M2[V2] ?
|
|
13146
|
+
let j4 = X4.reduce((D3, H4, V2) => D3 + (M2[V2] ? L$2 : H4.length / 2), 0), N = "", z2 = 0;
|
|
13147
13147
|
for (let D3 = 0;D3 < K3.length; D3++)
|
|
13148
13148
|
if (M2[D3])
|
|
13149
|
-
N +=
|
|
13149
|
+
N += q02(j4), j4 += q3[z2].length / 2, z2++;
|
|
13150
13150
|
else
|
|
13151
13151
|
N += X4[D3];
|
|
13152
13152
|
return Z3 + N + q3.join("");
|
|
@@ -13158,7 +13158,7 @@ function m$2($3) {
|
|
|
13158
13158
|
let Z3 = Y2.outputs || [];
|
|
13159
13159
|
if (Z3.length === 0)
|
|
13160
13160
|
return;
|
|
13161
|
-
let K3 =
|
|
13161
|
+
let K3 = B$2(G2);
|
|
13162
13162
|
if (Z3.length === 1)
|
|
13163
13163
|
return e03(Z3[0].type, K3, 0, Z3[0].components).value;
|
|
13164
13164
|
let X4 = [], q3 = 0;
|
|
@@ -13168,7 +13168,7 @@ function m$2($3) {
|
|
|
13168
13168
|
}
|
|
13169
13169
|
return X4;
|
|
13170
13170
|
}
|
|
13171
|
-
function
|
|
13171
|
+
function Z03($3, J2) {
|
|
13172
13172
|
if ($3.length !== J2.length)
|
|
13173
13173
|
throw Error(`Type/value length mismatch: ${$3.length} types, ${J2.length} values`);
|
|
13174
13174
|
let Q4 = [], G2 = [], Y2 = [];
|
|
@@ -13181,19 +13181,19 @@ function M03($3, J2) {
|
|
|
13181
13181
|
}
|
|
13182
13182
|
if (G2.length === 0)
|
|
13183
13183
|
return "0x" + Q4.join("");
|
|
13184
|
-
let Z3 = Q4.reduce((q3, M2, j4) => q3 + (Y2[j4] ?
|
|
13184
|
+
let Z3 = Q4.reduce((q3, M2, j4) => q3 + (Y2[j4] ? L$2 : M2.length / 2), 0), K3 = "", X4 = 0;
|
|
13185
13185
|
for (let q3 = 0;q3 < $3.length; q3++)
|
|
13186
13186
|
if (Y2[q3])
|
|
13187
|
-
K3 +=
|
|
13187
|
+
K3 += q02(Z3), Z3 += G2[X4].length / 2, X4++;
|
|
13188
13188
|
else
|
|
13189
13189
|
K3 += Q4[q3];
|
|
13190
13190
|
return "0x" + K3 + G2.join("");
|
|
13191
13191
|
}
|
|
13192
|
-
function
|
|
13192
|
+
function P($3) {
|
|
13193
13193
|
return $3.toLowerCase();
|
|
13194
13194
|
}
|
|
13195
13195
|
function e82($3) {
|
|
13196
|
-
return
|
|
13196
|
+
return P03($3);
|
|
13197
13197
|
}
|
|
13198
13198
|
function $Q2($3) {
|
|
13199
13199
|
if (typeof $3 !== "string")
|
|
@@ -13218,7 +13218,7 @@ function f2($3) {
|
|
|
13218
13218
|
return $3;
|
|
13219
13219
|
}
|
|
13220
13220
|
function dJ2($3) {
|
|
13221
|
-
return { Source:
|
|
13221
|
+
return { Source: P($3.from), Sink: P($3.to), TargetFlow: $3.targetFlow.toString(), WithWrap: $3.useWrappedBalances, FromTokens: $3.fromTokens?.map(P), ToTokens: $3.toTokens?.map(P), ExcludedFromTokens: $3.excludeFromTokens?.map(P), ExcludedToTokens: $3.excludeToTokens?.map(P), SimulatedBalances: $3.simulatedBalances?.map((J2) => ({ Holder: P(J2.holder), Token: P(J2.token), Amount: J2.amount.toString(), IsWrapped: J2.isWrapped, IsStatic: J2.isStatic })), SimulatedTrusts: $3.simulatedTrusts?.map((J2) => ({ Truster: P(J2.truster), Trustee: P(J2.trustee) })), MaxTransfers: $3.maxTransfers };
|
|
13222
13222
|
}
|
|
13223
13223
|
function j03($3) {
|
|
13224
13224
|
let J2 = {};
|
|
@@ -13238,7 +13238,7 @@ function j03($3) {
|
|
|
13238
13238
|
return J2;
|
|
13239
13239
|
}
|
|
13240
13240
|
var S$2 = "0x0000000000000000000000000000000000000000";
|
|
13241
|
-
var
|
|
13241
|
+
var Q03 = BigInt(96) * BigInt(1000000000000000000);
|
|
13242
13242
|
var $$ = BigInt("9999999999999999999999999999999999999");
|
|
13243
13243
|
var u$2 = "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67";
|
|
13244
13244
|
var c$2 = "0x89867a67674bd4bf33165a653cde826b696ab7d050166b71066dfa0b9b6f90f4";
|
|
@@ -13392,32 +13392,32 @@ class x03 {
|
|
|
13392
13392
|
});
|
|
13393
13393
|
}
|
|
13394
13394
|
async getCommonTrust($3, J2) {
|
|
13395
|
-
let Q4 = await this.client.call("circles_getCommonTrust", [
|
|
13395
|
+
let Q4 = await this.client.call("circles_getCommonTrust", [P($3), P(J2)]);
|
|
13396
13396
|
return f2(Q4);
|
|
13397
13397
|
}
|
|
13398
13398
|
getTrustRelations($3, J2 = 100, Q4 = "DESC") {
|
|
13399
|
-
let G2 =
|
|
13399
|
+
let G2 = P($3), Y2 = [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "Conjunction", ConjunctionType: "Or", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "trustee", Value: G2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "truster", Value: G2 }] }] }];
|
|
13400
13400
|
return new $03(this.client, { namespace: "V_Crc", table: "TrustRelations", sortOrder: Q4, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "version", "trustee", "truster", "expiryTime"], filter: Y2, limit: J2 }, (Z3) => f2(Z3));
|
|
13401
13401
|
}
|
|
13402
13402
|
async getAggregatedTrustRelations($3) {
|
|
13403
|
-
let J2 =
|
|
13403
|
+
let J2 = P($3), Q4 = this.getTrustRelations(J2, 1000), G2 = [];
|
|
13404
13404
|
while (await Q4.queryNextPage())
|
|
13405
13405
|
if (G2.push(...Q4.currentPage.results), !Q4.currentPage.hasMore)
|
|
13406
13406
|
break;
|
|
13407
13407
|
let Y2 = {};
|
|
13408
13408
|
G2.forEach((K3) => {
|
|
13409
|
-
let X4 =
|
|
13409
|
+
let X4 = P(K3.truster), q3 = P(K3.trustee), M2 = X4 !== J2 ? K3.truster : K3.trustee;
|
|
13410
13410
|
if (!Y2[M2])
|
|
13411
13411
|
Y2[M2] = [];
|
|
13412
13412
|
Y2[M2].push(K3);
|
|
13413
13413
|
});
|
|
13414
|
-
let Z3 = Object.entries(Y2).filter(([K3]) =>
|
|
13414
|
+
let Z3 = Object.entries(Y2).filter(([K3]) => P(K3) !== J2).map(([K3, X4]) => {
|
|
13415
13415
|
let q3 = Math.max(...X4.map((j4) => j4.timestamp)), M2;
|
|
13416
13416
|
if (X4.length === 2)
|
|
13417
13417
|
M2 = "mutuallyTrusts";
|
|
13418
|
-
else if (
|
|
13418
|
+
else if (P(X4[0]?.trustee) === J2)
|
|
13419
13419
|
M2 = "trustedBy";
|
|
13420
|
-
else if (
|
|
13420
|
+
else if (P(X4[0]?.truster) === J2)
|
|
13421
13421
|
M2 = "trusts";
|
|
13422
13422
|
else
|
|
13423
13423
|
throw Error("Unexpected trust list row. Couldn't determine trust relation.");
|
|
@@ -13426,15 +13426,15 @@ class x03 {
|
|
|
13426
13426
|
return f2(Z3);
|
|
13427
13427
|
}
|
|
13428
13428
|
async getTrustedBy($3) {
|
|
13429
|
-
let J2 =
|
|
13429
|
+
let J2 = P($3), G2 = (await this.getAggregatedTrustRelations(J2)).filter((Y2) => Y2.relation === "trustedBy");
|
|
13430
13430
|
return f2(G2);
|
|
13431
13431
|
}
|
|
13432
13432
|
async getTrusts($3) {
|
|
13433
|
-
let J2 =
|
|
13433
|
+
let J2 = P($3), G2 = (await this.getAggregatedTrustRelations(J2)).filter((Y2) => Y2.relation === "trusts");
|
|
13434
13434
|
return f2(G2);
|
|
13435
13435
|
}
|
|
13436
13436
|
async getMutualTrusts($3) {
|
|
13437
|
-
let J2 =
|
|
13437
|
+
let J2 = P($3), G2 = (await this.getAggregatedTrustRelations(J2)).filter((Y2) => Y2.relation === "mutuallyTrusts");
|
|
13438
13438
|
return f2(G2);
|
|
13439
13439
|
}
|
|
13440
13440
|
}
|
|
@@ -13558,11 +13558,11 @@ class A02 {
|
|
|
13558
13558
|
this.client = $3;
|
|
13559
13559
|
}
|
|
13560
13560
|
async getTotalBalance($3, J2 = true) {
|
|
13561
|
-
let Q4 = await this.client.call("circlesV2_getTotalBalance", [
|
|
13561
|
+
let Q4 = await this.client.call("circlesV2_getTotalBalance", [P($3), J2]);
|
|
13562
13562
|
return d4.circlesToAttoCircles(Q4);
|
|
13563
13563
|
}
|
|
13564
13564
|
async getTokenBalances($3) {
|
|
13565
|
-
let Q4 = (await this.client.call("circles_getTokenBalances", [
|
|
13565
|
+
let Q4 = (await this.client.call("circles_getTokenBalances", [P($3)])).map((G2) => j03(G2));
|
|
13566
13566
|
return f2(Q4);
|
|
13567
13567
|
}
|
|
13568
13568
|
}
|
|
@@ -13579,7 +13579,7 @@ class Q$ {
|
|
|
13579
13579
|
async getAvatarInfoBatch($3) {
|
|
13580
13580
|
if ($3.length === 0)
|
|
13581
13581
|
return [];
|
|
13582
|
-
let J2 = $3.map((G2) =>
|
|
13582
|
+
let J2 = $3.map((G2) => P(G2)), Q4 = await this.client.call("circles_getAvatarInfoBatch", [J2]);
|
|
13583
13583
|
return f2(Q4);
|
|
13584
13584
|
}
|
|
13585
13585
|
async getNetworkSnapshot() {
|
|
@@ -13600,10 +13600,10 @@ class G$ {
|
|
|
13600
13600
|
return this.client.call("circles_getProfileByCidBatch", [$3]);
|
|
13601
13601
|
}
|
|
13602
13602
|
async getProfileByAddress($3) {
|
|
13603
|
-
return this.client.call("circles_getProfileByAddress", [
|
|
13603
|
+
return this.client.call("circles_getProfileByAddress", [P($3)]);
|
|
13604
13604
|
}
|
|
13605
13605
|
async getProfileByAddressBatch($3) {
|
|
13606
|
-
return this.client.call("circles_getProfileByAddressBatch", [$3.map((J2) => J2 === null ? null :
|
|
13606
|
+
return this.client.call("circles_getProfileByAddressBatch", [$3.map((J2) => J2 === null ? null : P(J2))]);
|
|
13607
13607
|
}
|
|
13608
13608
|
async searchProfiles($3, J2 = 10, Q4 = 0, G2) {
|
|
13609
13609
|
return this.client.call("circles_searchProfiles", [$3.toLowerCase(), J2, Q4, G2]);
|
|
@@ -13647,11 +13647,11 @@ class Y$2 {
|
|
|
13647
13647
|
async getTokenInfoBatch($3) {
|
|
13648
13648
|
if ($3.length === 0)
|
|
13649
13649
|
return [];
|
|
13650
|
-
let J2 = $3.map((Y2) =>
|
|
13650
|
+
let J2 = $3.map((Y2) => P(Y2)), G2 = (await this.client.call("circles_getTokenInfoBatch", [J2])).map((Y2) => j03(Y2));
|
|
13651
13651
|
return f2(G2);
|
|
13652
13652
|
}
|
|
13653
13653
|
getTokenHolders($3, J2 = 100, Q4 = "DESC") {
|
|
13654
|
-
let G2 =
|
|
13654
|
+
let G2 = P($3);
|
|
13655
13655
|
return new $03(this.client, { namespace: "V_CrcV2", table: "BalancesByAccountAndToken", columns: ["account", "tokenAddress", "demurragedTotalBalance"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "tokenAddress", Value: G2 }], cursorColumns: [{ name: "demurragedTotalBalance", sortOrder: Q4 }, { name: "account", sortOrder: "ASC" }], orderColumns: [{ Column: "demurragedTotalBalance", SortOrder: Q4 }, { Column: "account", SortOrder: "ASC" }], limit: J2, sortOrder: Q4 }, (Y2) => ({ account: Y2.account, tokenAddress: Y2.tokenAddress, demurragedTotalBalance: Y2.demurragedTotalBalance }));
|
|
13656
13656
|
}
|
|
13657
13657
|
}
|
|
@@ -13671,13 +13671,13 @@ class Z$ {
|
|
|
13671
13671
|
});
|
|
13672
13672
|
}
|
|
13673
13673
|
async getInvitedBy($3) {
|
|
13674
|
-
let J2 =
|
|
13674
|
+
let J2 = P($3), Q4 = 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 }]);
|
|
13675
13675
|
if (Q4.length > 0)
|
|
13676
13676
|
return f2(Q4[0].inviter);
|
|
13677
13677
|
return;
|
|
13678
13678
|
}
|
|
13679
13679
|
async getInvitations($3) {
|
|
13680
|
-
let J2 =
|
|
13680
|
+
let J2 = P($3), Q4 = 96, G2 = await this.client.call("circles_getAvatarInfoBatch", [[J2]]);
|
|
13681
13681
|
if ((G2.length > 0 ? G2[0] : undefined)?.version === 2)
|
|
13682
13682
|
return [];
|
|
13683
13683
|
let Z3 = await this.client.call("circles_query", [{ Namespace: "V_Crc", Table: "TrustRelations", Columns: ["truster", "trustee"], Filter: [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "trustee", Value: J2 }] }], Order: [] }]), X4 = this.transformQueryResponse(Z3).map((j4) => j4.truster);
|
|
@@ -13687,14 +13687,14 @@ class Z$ {
|
|
|
13687
13687
|
for (let j4 of q3) {
|
|
13688
13688
|
if (!j4?.isHuman)
|
|
13689
13689
|
continue;
|
|
13690
|
-
let z2 = (await this.client.call("circles_getTokenBalances", [j4.avatar])).find((D3) =>
|
|
13690
|
+
let z2 = (await this.client.call("circles_getTokenBalances", [j4.avatar])).find((D3) => P(D3.tokenAddress) === P(j4.avatar));
|
|
13691
13691
|
if (z2 && z2.circles >= 96)
|
|
13692
13692
|
M2.push(j4);
|
|
13693
13693
|
}
|
|
13694
13694
|
return f2(M2);
|
|
13695
13695
|
}
|
|
13696
13696
|
async getInvitationsFrom($3, J2 = false) {
|
|
13697
|
-
let Q4 =
|
|
13697
|
+
let Q4 = P($3);
|
|
13698
13698
|
if (J2) {
|
|
13699
13699
|
let G2 = await this.client.call("circles_query", [{ Namespace: "CrcV2", Table: "RegisterHuman", Columns: ["avatar"], Filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "inviter", Value: Q4 }], Order: [{ Column: "blockNumber", SortOrder: "DESC" }] }]), Z3 = this.transformQueryResponse(G2).map((K3) => K3.avatar);
|
|
13700
13700
|
return f2(Z3);
|
|
@@ -13702,7 +13702,7 @@ class Z$ {
|
|
|
13702
13702
|
let G2 = await this.client.call("circles_query", [{ Namespace: "V_Crc", Table: "TrustRelations", Columns: ["trustee", "truster"], Filter: [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "truster", Value: Q4 }] }], Order: [] }]), Z3 = this.transformQueryResponse(G2).map((M2) => M2.trustee);
|
|
13703
13703
|
if (Z3.length === 0)
|
|
13704
13704
|
return [];
|
|
13705
|
-
let K3 = await this.client.call("circles_getAvatarInfoBatch", [Z3]), X4 = new Set(K3.filter((M2) => M2 !== null).map((M2) =>
|
|
13705
|
+
let K3 = await this.client.call("circles_getAvatarInfoBatch", [Z3]), X4 = new Set(K3.filter((M2) => M2 !== null).map((M2) => P(M2.avatar))), q3 = Z3.filter((M2) => !X4.has(P(M2)));
|
|
13706
13706
|
return f2(q3);
|
|
13707
13707
|
}
|
|
13708
13708
|
}
|
|
@@ -13718,7 +13718,7 @@ class K$2 {
|
|
|
13718
13718
|
this.client = $3;
|
|
13719
13719
|
}
|
|
13720
13720
|
getTransactionHistory($3, J2 = 50, Q4 = "DESC") {
|
|
13721
|
-
let G2 =
|
|
13721
|
+
let G2 = P($3), Y2 = [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "Conjunction", ConjunctionType: "Or", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "from", Value: G2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "to", Value: G2 }] }] }];
|
|
13722
13722
|
return new $03(this.client, { namespace: "V_Crc", table: "TransferSummary", sortOrder: Q4, columns: [], filter: Y2, limit: J2 }, (Z3) => {
|
|
13723
13723
|
let K3 = QQ(Z3.value, Z3.timestamp), X4 = { ...Z3, ...K3 };
|
|
13724
13724
|
return f2(X4);
|
|
@@ -13742,18 +13742,18 @@ class k03 {
|
|
|
13742
13742
|
return G2.slice(0, $3);
|
|
13743
13743
|
}
|
|
13744
13744
|
getGroupMemberships($3, J2 = 50, Q4 = "DESC") {
|
|
13745
|
-
let G2 =
|
|
13745
|
+
let G2 = P($3);
|
|
13746
13746
|
return new $03(this.client, { namespace: "V_CrcV2", table: "GroupMemberships", sortOrder: Q4, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "member", "expiryTime"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "member", Value: G2 }], limit: J2 }, (Y2) => f2(Y2));
|
|
13747
13747
|
}
|
|
13748
13748
|
getGroupHolders($3, J2 = 100) {
|
|
13749
|
-
let Q4 =
|
|
13749
|
+
let Q4 = P($3);
|
|
13750
13750
|
return new $03(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: Q4 }], limit: J2, rowTransformer: (G2) => {
|
|
13751
13751
|
let Y2 = { ...G2, totalBalance: BigInt(G2.totalBalance), demurragedTotalBalance: BigInt(G2.demurragedTotalBalance) };
|
|
13752
13752
|
return f2(Y2);
|
|
13753
13753
|
} });
|
|
13754
13754
|
}
|
|
13755
13755
|
getGroupMembers($3, J2 = 100, Q4 = "DESC") {
|
|
13756
|
-
let G2 =
|
|
13756
|
+
let G2 = P($3);
|
|
13757
13757
|
return new $03(this.client, { namespace: "V_CrcV2", table: "GroupMemberships", sortOrder: Q4, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "member", "expiryTime"], filter: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: G2 }], limit: J2 }, (Y2) => f2(Y2));
|
|
13758
13758
|
}
|
|
13759
13759
|
getGroups($3 = 50, J2, Q4 = "DESC") {
|
|
@@ -13764,7 +13764,7 @@ class k03 {
|
|
|
13764
13764
|
if (J2.symbolStartsWith)
|
|
13765
13765
|
G2.push({ Type: "FilterPredicate", FilterType: "Like", Column: "symbol", Value: J2.symbolStartsWith + "%" });
|
|
13766
13766
|
if (J2.groupAddressIn && J2.groupAddressIn.length > 0) {
|
|
13767
|
-
let Z3 = J2.groupAddressIn.map((K3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value:
|
|
13767
|
+
let Z3 = J2.groupAddressIn.map((K3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "group", Value: P(K3) }));
|
|
13768
13768
|
if (Z3.length === 1)
|
|
13769
13769
|
G2.push(Z3[0]);
|
|
13770
13770
|
else
|
|
@@ -13778,16 +13778,16 @@ class k03 {
|
|
|
13778
13778
|
G2.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: Z3 });
|
|
13779
13779
|
}
|
|
13780
13780
|
if (J2.ownerIn && J2.ownerIn.length > 0) {
|
|
13781
|
-
let Z3 = J2.ownerIn.map((K3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "owner", Value:
|
|
13781
|
+
let Z3 = J2.ownerIn.map((K3) => ({ Type: "FilterPredicate", FilterType: "Equals", Column: "owner", Value: P(K3) }));
|
|
13782
13782
|
if (Z3.length === 1)
|
|
13783
13783
|
G2.push(Z3[0]);
|
|
13784
13784
|
else
|
|
13785
13785
|
G2.push({ Type: "Conjunction", ConjunctionType: "Or", Predicates: Z3 });
|
|
13786
13786
|
}
|
|
13787
13787
|
if (J2.mintHandlerEquals)
|
|
13788
|
-
G2.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "mintHandler", Value:
|
|
13788
|
+
G2.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "mintHandler", Value: P(J2.mintHandlerEquals) });
|
|
13789
13789
|
if (J2.treasuryEquals)
|
|
13790
|
-
G2.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "treasury", Value:
|
|
13790
|
+
G2.push({ Type: "FilterPredicate", FilterType: "Equals", Column: "treasury", Value: P(J2.treasuryEquals) });
|
|
13791
13791
|
}
|
|
13792
13792
|
let Y2 = G2.length > 1 ? [{ Type: "Conjunction", ConjunctionType: "And", Predicates: G2 }] : G2;
|
|
13793
13793
|
return new $03(this.client, { namespace: "V_CrcV2", table: "Groups", sortOrder: Q4, columns: ["blockNumber", "timestamp", "transactionIndex", "logIndex", "transactionHash", "group", "type", "owner", "mintPolicy", "mintHandler", "treasury", "service", "feeCollection", "memberCount", "name", "symbol", "cidV0Digest", "erc20WrapperDemurraged", "erc20WrapperStatic"], filter: Y2, limit: $3 }, (Z3) => f2(Z3));
|
|
@@ -13867,7 +13867,7 @@ class I$2 {
|
|
|
13867
13867
|
}
|
|
13868
13868
|
}
|
|
13869
13869
|
|
|
13870
|
-
class
|
|
13870
|
+
class G03 {
|
|
13871
13871
|
address;
|
|
13872
13872
|
abi;
|
|
13873
13873
|
rpcUrl;
|
|
@@ -13888,7 +13888,7 @@ class Q03 {
|
|
|
13888
13888
|
}
|
|
13889
13889
|
var iJ2 = [{ type: "function", name: "operateFlowMatrix", inputs: [{ name: "_flowVertices", type: "address[]" }, { name: "_flow", type: "tuple[]", components: [{ name: "streamSinkId", type: "uint16" }, { name: "amount", type: "uint192" }] }, { name: "_streams", type: "tuple[]", components: [{ name: "sourceCoordinate", type: "uint16" }, { name: "flowEdgeIds", type: "uint16[]" }, { name: "data", type: "bytes" }] }, { name: "_packedCoordinates", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isApprovedForAll", inputs: [{ name: "_account", type: "address" }, { name: "_operator", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "setApprovalForAll", inputs: [{ name: "_operator", type: "address" }, { name: "_approved", type: "bool" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "wrap", inputs: [{ name: "_avatar", type: "address" }, { name: "_amount", type: "uint256" }, { name: "_type", type: "uint8" }], outputs: [{ type: "address" }], stateMutability: "nonpayable" }, { type: "function", name: "trust", inputs: [{ name: "_trustReceiver", type: "address" }, { name: "_expiry", type: "uint96" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isTrusted", inputs: [{ name: "_truster", type: "address" }, { name: "_trustee", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "toTokenId", inputs: [{ name: "_avatar", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "pure" }, { type: "function", name: "safeTransferFrom", inputs: [{ name: "_from", type: "address" }, { name: "_to", type: "address" }, { name: "_id", type: "uint256" }, { name: "_value", type: "uint256" }, { name: "_data", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "isHuman", inputs: [{ name: "_human", type: "address" }], outputs: [{ type: "bool" }], stateMutability: "view" }, { type: "function", name: "safeBatchTransferFrom", inputs: [{ name: "_from", type: "address" }, { name: "_to", type: "address" }, { name: "_ids", type: "uint256[]" }, { name: "_values", type: "uint256[]" }, { name: "_data", type: "bytes" }], outputs: [], stateMutability: "nonpayable" }];
|
|
13890
13890
|
|
|
13891
|
-
class
|
|
13891
|
+
class B0 extends G03 {
|
|
13892
13892
|
constructor($3) {
|
|
13893
13893
|
super({ address: $3.address, abi: iJ2, rpcUrl: $3.rpcUrl });
|
|
13894
13894
|
}
|
|
@@ -13925,7 +13925,7 @@ class P03 extends Q03 {
|
|
|
13925
13925
|
}
|
|
13926
13926
|
var nJ2 = [{ type: "function", name: "erc20Circles", inputs: [{ name: "_circlesType", type: "uint8" }, { name: "_avatar", type: "address" }], outputs: [{ type: "address" }], stateMutability: "view" }];
|
|
13927
13927
|
|
|
13928
|
-
class T$2 extends
|
|
13928
|
+
class T$2 extends G03 {
|
|
13929
13929
|
constructor($3) {
|
|
13930
13930
|
super({ address: $3.address, abi: nJ2, rpcUrl: $3.rpcUrl });
|
|
13931
13931
|
}
|
|
@@ -13935,7 +13935,7 @@ class T$2 extends Q03 {
|
|
|
13935
13935
|
}
|
|
13936
13936
|
var p$2 = [{ type: "function", name: "unwrap", inputs: [{ name: "_amount", type: "uint256" }], outputs: [], stateMutability: "nonpayable" }];
|
|
13937
13937
|
|
|
13938
|
-
class c03 extends
|
|
13938
|
+
class c03 extends G03 {
|
|
13939
13939
|
constructor($3) {
|
|
13940
13940
|
super({ address: $3.address, abi: p$2, rpcUrl: $3.rpcUrl });
|
|
13941
13941
|
}
|
|
@@ -13944,7 +13944,7 @@ class c03 extends Q03 {
|
|
|
13944
13944
|
}
|
|
13945
13945
|
}
|
|
13946
13946
|
|
|
13947
|
-
class l03 extends
|
|
13947
|
+
class l03 extends G03 {
|
|
13948
13948
|
constructor($3) {
|
|
13949
13949
|
super({ address: $3.address, abi: p$2, rpcUrl: $3.rpcUrl });
|
|
13950
13950
|
}
|
|
@@ -13955,7 +13955,7 @@ class l03 extends Q03 {
|
|
|
13955
13955
|
var d$2 = [{ type: "function", name: "createAccount", inputs: [{ name: "signer", type: "address" }], outputs: [{ name: "account", type: "address" }], stateMutability: "nonpayable" }, { type: "function", name: "createAccounts", inputs: [{ name: "signers", type: "address[]" }], outputs: [{ name: "_accounts", type: "address[]" }], stateMutability: "nonpayable" }];
|
|
13956
13956
|
var i$2 = [{ type: "function", name: "claimInvite", inputs: [], outputs: [{ name: "id", type: "uint256" }], stateMutability: "nonpayable" }, { type: "function", name: "claimInvites", inputs: [{ name: "numberOfInvites", type: "uint256" }], outputs: [{ name: "ids", type: "uint256[]" }], stateMutability: "nonpayable" }, { type: "function", name: "inviterQuota", inputs: [{ name: "", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "view" }, { type: "function", name: "INVITATION_FEE", inputs: [], outputs: [{ type: "uint256" }], stateMutability: "view" }, { type: "function", name: "invitationModule", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" }];
|
|
13957
13957
|
|
|
13958
|
-
class p03 extends
|
|
13958
|
+
class p03 extends G03 {
|
|
13959
13959
|
constructor($3) {
|
|
13960
13960
|
super({ address: $3.address, abi: d$2, rpcUrl: $3.rpcUrl });
|
|
13961
13961
|
}
|
|
@@ -13967,7 +13967,7 @@ class p03 extends Q03 {
|
|
|
13967
13967
|
}
|
|
13968
13968
|
}
|
|
13969
13969
|
|
|
13970
|
-
class _$2 extends
|
|
13970
|
+
class _$2 extends G03 {
|
|
13971
13971
|
constructor($3) {
|
|
13972
13972
|
super({ address: $3.address, abi: i$2, rpcUrl: $3.rpcUrl });
|
|
13973
13973
|
}
|
|
@@ -14031,7 +14031,7 @@ class n$2 extends E03 {
|
|
|
14031
14031
|
this.finished = false, this.length = 0, this.pos = 0, this.destroyed = false, this.blockLen = $3, this.outputLen = J2, this.padOffset = Q4, this.isLE = G2, this.buffer = new Uint8Array($3), this.view = O$2(this.buffer);
|
|
14032
14032
|
}
|
|
14033
14033
|
update($3) {
|
|
14034
|
-
|
|
14034
|
+
M03(this), $3 = _03($3), K02($3);
|
|
14035
14035
|
let { view: J2, buffer: Q4, blockLen: G2 } = this, Y2 = $3.length;
|
|
14036
14036
|
for (let Z3 = 0;Z3 < Y2; ) {
|
|
14037
14037
|
let K3 = Math.min(G2 - this.pos, Y2 - Z3);
|
|
@@ -14047,9 +14047,9 @@ class n$2 extends E03 {
|
|
|
14047
14047
|
return this.length += $3.length, this.roundClean(), this;
|
|
14048
14048
|
}
|
|
14049
14049
|
digestInto($3) {
|
|
14050
|
-
|
|
14050
|
+
M03(this), V$2($3, this), this.finished = true;
|
|
14051
14051
|
let { buffer: J2, view: Q4, blockLen: G2, isLE: Y2 } = this, { pos: Z3 } = this;
|
|
14052
|
-
if (J2[Z3++] = 128,
|
|
14052
|
+
if (J2[Z3++] = 128, X03(this.buffer.subarray(Z3)), this.padOffset > G2 - Z3)
|
|
14053
14053
|
this.process(Q4, 0), Z3 = 0;
|
|
14054
14054
|
for (let j4 = Z3;j4 < G2; j4++)
|
|
14055
14055
|
J2[j4] = 0;
|
|
@@ -14082,7 +14082,7 @@ class n$2 extends E03 {
|
|
|
14082
14082
|
}
|
|
14083
14083
|
var W03 = Uint32Array.from([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
|
|
14084
14084
|
var YQ2 = Uint32Array.from([1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298]);
|
|
14085
|
-
var
|
|
14085
|
+
var L03 = new Uint32Array(64);
|
|
14086
14086
|
|
|
14087
14087
|
class aJ extends n$2 {
|
|
14088
14088
|
constructor($3 = 32) {
|
|
@@ -14098,23 +14098,23 @@ class aJ extends n$2 {
|
|
|
14098
14098
|
}
|
|
14099
14099
|
process($3, J2) {
|
|
14100
14100
|
for (let j4 = 0;j4 < 16; j4++, J2 += 4)
|
|
14101
|
-
|
|
14101
|
+
L03[j4] = $3.getUint32(J2, false);
|
|
14102
14102
|
for (let j4 = 16;j4 < 64; j4++) {
|
|
14103
|
-
let N =
|
|
14104
|
-
|
|
14103
|
+
let N = L03[j4 - 15], z2 = L03[j4 - 2], D3 = Y03(N, 7) ^ Y03(N, 18) ^ N >>> 3, H4 = Y03(z2, 17) ^ Y03(z2, 19) ^ z2 >>> 10;
|
|
14104
|
+
L03[j4] = H4 + L03[j4 - 7] + D3 + L03[j4 - 16] | 0;
|
|
14105
14105
|
}
|
|
14106
14106
|
let { A: Q4, B: G2, C: Y2, D: Z3, E: K3, F: X4, G: q3, H: M2 } = this;
|
|
14107
14107
|
for (let j4 = 0;j4 < 64; j4++) {
|
|
14108
|
-
let N =
|
|
14108
|
+
let N = Y03(K3, 6) ^ Y03(K3, 11) ^ Y03(K3, 25), z2 = M2 + N + oJ2(K3, X4, q3) + YQ2[j4] + L03[j4] | 0, H4 = (Y03(Q4, 2) ^ Y03(Q4, 13) ^ Y03(Q4, 22)) + tJ2(Q4, G2, Y2) | 0;
|
|
14109
14109
|
M2 = q3, q3 = X4, X4 = K3, K3 = Z3 + z2 | 0, Z3 = Y2, Y2 = G2, G2 = Q4, Q4 = z2 + H4 | 0;
|
|
14110
14110
|
}
|
|
14111
14111
|
Q4 = Q4 + this.A | 0, G2 = G2 + this.B | 0, Y2 = Y2 + this.C | 0, Z3 = Z3 + this.D | 0, K3 = K3 + this.E | 0, X4 = X4 + this.F | 0, q3 = q3 + this.G | 0, M2 = M2 + this.H | 0, this.set(Q4, G2, Y2, Z3, K3, X4, q3, M2);
|
|
14112
14112
|
}
|
|
14113
14113
|
roundClean() {
|
|
14114
|
-
|
|
14114
|
+
X03(L03);
|
|
14115
14115
|
}
|
|
14116
14116
|
destroy() {
|
|
14117
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0),
|
|
14117
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), X03(this.buffer);
|
|
14118
14118
|
}
|
|
14119
14119
|
}
|
|
14120
14120
|
var sJ2 = R$2(() => new aJ);
|
|
@@ -14134,13 +14134,13 @@ class o$2 extends E03 {
|
|
|
14134
14134
|
this.iHash.update(Y2), this.oHash = $3.create();
|
|
14135
14135
|
for (let Z3 = 0;Z3 < Y2.length; Z3++)
|
|
14136
14136
|
Y2[Z3] ^= 106;
|
|
14137
|
-
this.oHash.update(Y2),
|
|
14137
|
+
this.oHash.update(Y2), X03(Y2);
|
|
14138
14138
|
}
|
|
14139
14139
|
update($3) {
|
|
14140
|
-
return
|
|
14140
|
+
return M03(this), this.iHash.update($3), this;
|
|
14141
14141
|
}
|
|
14142
14142
|
digestInto($3) {
|
|
14143
|
-
|
|
14143
|
+
M03(this), K02($3, this.outputLen), this.finished = true, this.iHash.digestInto($3), this.oHash.update($3), this.oHash.digestInto($3), this.destroy();
|
|
14144
14144
|
}
|
|
14145
14145
|
digest() {
|
|
14146
14146
|
let $3 = new Uint8Array(this.oHash.outputLen);
|
|
@@ -14344,7 +14344,7 @@ function GJ3($3) {
|
|
|
14344
14344
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14345
14345
|
var a4 = BigInt(0);
|
|
14346
14346
|
var n4 = BigInt(1);
|
|
14347
|
-
var
|
|
14347
|
+
var g03 = BigInt(2);
|
|
14348
14348
|
var XQ2 = BigInt(3);
|
|
14349
14349
|
var Z82 = BigInt(4);
|
|
14350
14350
|
var K82 = BigInt(5);
|
|
@@ -14380,7 +14380,7 @@ function q82($3, J2) {
|
|
|
14380
14380
|
return G2;
|
|
14381
14381
|
}
|
|
14382
14382
|
function qQ2($3, J2) {
|
|
14383
|
-
let Q4 = ($3.ORDER - K82) / X82, G2 = $3.mul(J2,
|
|
14383
|
+
let Q4 = ($3.ORDER - K82) / X82, G2 = $3.mul(J2, g03), Y2 = $3.pow(G2, Q4), Z3 = $3.mul(J2, Y2), K3 = $3.mul($3.mul(Z3, g03), Y2), X4 = $3.mul(Z3, $3.sub(K3, $3.ONE));
|
|
14384
14384
|
if (!$3.eql($3.sqr(X4), J2))
|
|
14385
14385
|
throw Error("Cannot find square root");
|
|
14386
14386
|
return X4;
|
|
@@ -14389,15 +14389,15 @@ function MQ($3) {
|
|
|
14389
14389
|
if ($3 < BigInt(3))
|
|
14390
14390
|
throw Error("sqrt is not defined for small field");
|
|
14391
14391
|
let J2 = $3 - n4, Q4 = 0;
|
|
14392
|
-
while (J2 %
|
|
14393
|
-
J2 /=
|
|
14394
|
-
let G2 =
|
|
14392
|
+
while (J2 % g03 === a4)
|
|
14393
|
+
J2 /= g03, Q4++;
|
|
14394
|
+
let G2 = g03, Y2 = j$2($3);
|
|
14395
14395
|
while (Y8(Y2, G2) === 1)
|
|
14396
14396
|
if (G2++ > 1000)
|
|
14397
14397
|
throw Error("Cannot find square root: probably non-prime P");
|
|
14398
14398
|
if (Q4 === 1)
|
|
14399
14399
|
return q82;
|
|
14400
|
-
let Z3 = Y2.pow(G2, J2), K3 = (J2 + n4) /
|
|
14400
|
+
let Z3 = Y2.pow(G2, J2), K3 = (J2 + n4) / g03;
|
|
14401
14401
|
return function(q3, M2) {
|
|
14402
14402
|
if (q3.is0(M2))
|
|
14403
14403
|
return M2;
|
|
@@ -14411,7 +14411,7 @@ function MQ($3) {
|
|
|
14411
14411
|
while (!q3.eql(V2, q3.ONE))
|
|
14412
14412
|
if (H4++, V2 = q3.sqr(V2), H4 === j4)
|
|
14413
14413
|
throw Error("Cannot find square root");
|
|
14414
|
-
let
|
|
14414
|
+
let B4 = n4 << BigInt(j4 - H4 - 1), S3 = q3.pow(N, B4);
|
|
14415
14415
|
j4 = H4, N = q3.sqr(S3), z2 = q3.mul(z2, N), D3 = q3.mul(D3, S3);
|
|
14416
14416
|
}
|
|
14417
14417
|
return D3;
|
|
@@ -14459,7 +14459,7 @@ function ZJ3($3, J2, Q4 = false) {
|
|
|
14459
14459
|
}, Z3), G2;
|
|
14460
14460
|
}
|
|
14461
14461
|
function Y8($3, J2) {
|
|
14462
|
-
let Q4 = ($3.ORDER - n4) /
|
|
14462
|
+
let Q4 = ($3.ORDER - n4) / g03, G2 = $3.pow(J2, Q4), Y2 = $3.eql(G2, $3.ONE), Z3 = $3.eql(G2, $3.ZERO), K3 = $3.eql(G2, $3.neg($3.ONE));
|
|
14463
14463
|
if (!Y2 && !Z3 && !K3)
|
|
14464
14464
|
throw Error("invalid Legendre symbol result");
|
|
14465
14465
|
return Y2 ? 1 : Z3 ? 0 : -1;
|
|
@@ -14631,12 +14631,12 @@ function V82($3, J2, Q4, G2) {
|
|
|
14631
14631
|
for (let D3 = N;D3 >= 0; D3 -= q3) {
|
|
14632
14632
|
j4.fill(K3);
|
|
14633
14633
|
for (let V2 = 0;V2 < Z3; V2++) {
|
|
14634
|
-
let
|
|
14634
|
+
let B4 = G2[V2], S3 = Number(B4 >> BigInt(D3) & M2);
|
|
14635
14635
|
j4[S3] = j4[S3].add(Q4[V2]);
|
|
14636
14636
|
}
|
|
14637
14637
|
let H4 = K3;
|
|
14638
|
-
for (let V2 = j4.length - 1,
|
|
14639
|
-
|
|
14638
|
+
for (let V2 = j4.length - 1, B4 = K3;V2 > 0; V2--)
|
|
14639
|
+
B4 = B4.add(j4[V2]), H4 = H4.add(B4);
|
|
14640
14640
|
if (z2 = z2.add(H4), D3 !== 0)
|
|
14641
14641
|
for (let V2 = 0;V2 < q3; V2++)
|
|
14642
14642
|
z2 = z2.double();
|
|
@@ -14749,20 +14749,20 @@ var KY = BigInt(2);
|
|
|
14749
14749
|
var DJ3 = BigInt(3);
|
|
14750
14750
|
var VQ = BigInt(4);
|
|
14751
14751
|
function OQ($3) {
|
|
14752
|
-
let J2 = DQ($3), { Fp: Q4 } = J2, G2 = j$2(J2.n, J2.nBitLength), Y2 = J2.toBytes || ((U2, R4,
|
|
14752
|
+
let J2 = DQ($3), { Fp: Q4 } = J2, G2 = j$2(J2.n, J2.nBitLength), Y2 = J2.toBytes || ((U2, R4, L3) => {
|
|
14753
14753
|
let I4 = R4.toAffine();
|
|
14754
14754
|
return M$(Uint8Array.from([4]), Q4.toBytes(I4.x), Q4.toBytes(I4.y));
|
|
14755
14755
|
}), Z3 = J2.fromBytes || ((U2) => {
|
|
14756
|
-
let R4 = U2.subarray(1),
|
|
14757
|
-
return { x:
|
|
14756
|
+
let R4 = U2.subarray(1), L3 = Q4.fromBytes(R4.subarray(0, Q4.BYTES)), I4 = Q4.fromBytes(R4.subarray(Q4.BYTES, 2 * Q4.BYTES));
|
|
14757
|
+
return { x: L3, y: I4 };
|
|
14758
14758
|
});
|
|
14759
14759
|
function K3(U2) {
|
|
14760
|
-
let { a: R4, b:
|
|
14761
|
-
return Q4.add(Q4.add(w3, Q4.mul(U2, R4)),
|
|
14760
|
+
let { a: R4, b: L3 } = J2, I4 = Q4.sqr(U2), w3 = Q4.mul(I4, U2);
|
|
14761
|
+
return Q4.add(Q4.add(w3, Q4.mul(U2, R4)), L3);
|
|
14762
14762
|
}
|
|
14763
14763
|
function X4(U2, R4) {
|
|
14764
|
-
let
|
|
14765
|
-
return Q4.eql(
|
|
14764
|
+
let L3 = Q4.sqr(R4), I4 = K3(U2);
|
|
14765
|
+
return Q4.eql(L3, I4);
|
|
14766
14766
|
}
|
|
14767
14767
|
if (!X4(J2.Gx, J2.Gy))
|
|
14768
14768
|
throw Error("bad curve params: generator point");
|
|
@@ -14773,19 +14773,19 @@ function OQ($3) {
|
|
|
14773
14773
|
return x$2(U2, p5, J2.n);
|
|
14774
14774
|
}
|
|
14775
14775
|
function N(U2) {
|
|
14776
|
-
let { allowedPrivateKeyLengths: R4, nByteLength:
|
|
14776
|
+
let { allowedPrivateKeyLengths: R4, nByteLength: L3, wrapPrivateKey: I4, n: w3 } = J2;
|
|
14777
14777
|
if (R4 && typeof U2 !== "bigint") {
|
|
14778
14778
|
if (d03(U2))
|
|
14779
14779
|
U2 = n03(U2);
|
|
14780
14780
|
if (typeof U2 !== "string" || !R4.includes(U2.length))
|
|
14781
14781
|
throw Error("invalid private key");
|
|
14782
|
-
U2 = U2.padStart(
|
|
14782
|
+
U2 = U2.padStart(L3 * 2, "0");
|
|
14783
14783
|
}
|
|
14784
14784
|
let x3;
|
|
14785
14785
|
try {
|
|
14786
|
-
x3 = typeof U2 === "bigint" ? U2 : z02(e5("private key", U2,
|
|
14786
|
+
x3 = typeof U2 === "bigint" ? U2 : z02(e5("private key", U2, L3));
|
|
14787
14787
|
} catch (y4) {
|
|
14788
|
-
throw Error("invalid private key, expected hex or " +
|
|
14788
|
+
throw Error("invalid private key, expected hex or " + L3 + " bytes, got " + typeof U2);
|
|
14789
14789
|
}
|
|
14790
14790
|
if (I4)
|
|
14791
14791
|
x3 = i4(x3, w3);
|
|
@@ -14796,13 +14796,13 @@ function OQ($3) {
|
|
|
14796
14796
|
throw Error("ProjectivePoint expected");
|
|
14797
14797
|
}
|
|
14798
14798
|
let D3 = GJ3((U2, R4) => {
|
|
14799
|
-
let { px:
|
|
14799
|
+
let { px: L3, py: I4, pz: w3 } = U2;
|
|
14800
14800
|
if (Q4.eql(w3, Q4.ONE))
|
|
14801
|
-
return { x:
|
|
14801
|
+
return { x: L3, y: I4 };
|
|
14802
14802
|
let x3 = U2.is0();
|
|
14803
14803
|
if (R4 == null)
|
|
14804
14804
|
R4 = x3 ? Q4.ONE : Q4.inv(w3);
|
|
14805
|
-
let y4 = Q4.mul(
|
|
14805
|
+
let y4 = Q4.mul(L3, R4), E4 = Q4.mul(I4, R4), k4 = Q4.mul(w3, R4);
|
|
14806
14806
|
if (x3)
|
|
14807
14807
|
return { x: Q4.ZERO, y: Q4.ZERO };
|
|
14808
14808
|
if (!Q4.eql(k4, Q4.ONE))
|
|
@@ -14814,10 +14814,10 @@ function OQ($3) {
|
|
|
14814
14814
|
return;
|
|
14815
14815
|
throw Error("bad point: ZERO");
|
|
14816
14816
|
}
|
|
14817
|
-
let { x: R4, y:
|
|
14818
|
-
if (!Q4.isValid(R4) || !Q4.isValid(
|
|
14817
|
+
let { x: R4, y: L3 } = U2.toAffine();
|
|
14818
|
+
if (!Q4.isValid(R4) || !Q4.isValid(L3))
|
|
14819
14819
|
throw Error("bad point: x or y not FE");
|
|
14820
|
-
if (!X4(R4,
|
|
14820
|
+
if (!X4(R4, L3))
|
|
14821
14821
|
throw Error("bad point: equation left != right");
|
|
14822
14822
|
if (!U2.isTorsionFree())
|
|
14823
14823
|
throw Error("bad point: not in prime-order subgroup");
|
|
@@ -14825,25 +14825,25 @@ function OQ($3) {
|
|
|
14825
14825
|
});
|
|
14826
14826
|
|
|
14827
14827
|
class V2 {
|
|
14828
|
-
constructor(U2, R4,
|
|
14828
|
+
constructor(U2, R4, L3) {
|
|
14829
14829
|
if (U2 == null || !Q4.isValid(U2))
|
|
14830
14830
|
throw Error("x required");
|
|
14831
14831
|
if (R4 == null || !Q4.isValid(R4) || Q4.is0(R4))
|
|
14832
14832
|
throw Error("y required");
|
|
14833
|
-
if (
|
|
14833
|
+
if (L3 == null || !Q4.isValid(L3))
|
|
14834
14834
|
throw Error("z required");
|
|
14835
|
-
this.px = U2, this.py = R4, this.pz =
|
|
14835
|
+
this.px = U2, this.py = R4, this.pz = L3, Object.freeze(this);
|
|
14836
14836
|
}
|
|
14837
14837
|
static fromAffine(U2) {
|
|
14838
|
-
let { x: R4, y:
|
|
14839
|
-
if (!U2 || !Q4.isValid(R4) || !Q4.isValid(
|
|
14838
|
+
let { x: R4, y: L3 } = U2 || {};
|
|
14839
|
+
if (!U2 || !Q4.isValid(R4) || !Q4.isValid(L3))
|
|
14840
14840
|
throw Error("invalid affine point");
|
|
14841
14841
|
if (U2 instanceof V2)
|
|
14842
14842
|
throw Error("projective point not allowed");
|
|
14843
14843
|
let I4 = (w3) => Q4.eql(w3, Q4.ZERO);
|
|
14844
|
-
if (I4(R4) && I4(
|
|
14844
|
+
if (I4(R4) && I4(L3))
|
|
14845
14845
|
return V2.ZERO;
|
|
14846
|
-
return new V2(R4,
|
|
14846
|
+
return new V2(R4, L3, Q4.ONE);
|
|
14847
14847
|
}
|
|
14848
14848
|
get x() {
|
|
14849
14849
|
return this.toAffine().x;
|
|
@@ -14852,8 +14852,8 @@ function OQ($3) {
|
|
|
14852
14852
|
return this.toAffine().y;
|
|
14853
14853
|
}
|
|
14854
14854
|
static normalizeZ(U2) {
|
|
14855
|
-
let R4 = ZJ3(Q4, U2.map((
|
|
14856
|
-
return U2.map((
|
|
14855
|
+
let R4 = ZJ3(Q4, U2.map((L3) => L3.pz));
|
|
14856
|
+
return U2.map((L3, I4) => L3.toAffine(R4[I4])).map(V2.fromAffine);
|
|
14857
14857
|
}
|
|
14858
14858
|
static fromHex(U2) {
|
|
14859
14859
|
let R4 = V2.fromAffine(Z3(e5("pointHex", U2)));
|
|
@@ -14866,7 +14866,7 @@ function OQ($3) {
|
|
|
14866
14866
|
return V82(V2, G2, U2, R4);
|
|
14867
14867
|
}
|
|
14868
14868
|
_setWindowSize(U2) {
|
|
14869
|
-
|
|
14869
|
+
v3.setWindowSize(this, U2);
|
|
14870
14870
|
}
|
|
14871
14871
|
assertValidity() {
|
|
14872
14872
|
H4(this);
|
|
@@ -14879,22 +14879,22 @@ function OQ($3) {
|
|
|
14879
14879
|
}
|
|
14880
14880
|
equals(U2) {
|
|
14881
14881
|
z2(U2);
|
|
14882
|
-
let { px: R4, py:
|
|
14882
|
+
let { px: R4, py: L3, pz: I4 } = this, { px: w3, py: x3, pz: y4 } = U2, E4 = Q4.eql(Q4.mul(R4, y4), Q4.mul(w3, I4)), k4 = Q4.eql(Q4.mul(L3, y4), Q4.mul(x3, I4));
|
|
14883
14883
|
return E4 && k4;
|
|
14884
14884
|
}
|
|
14885
14885
|
negate() {
|
|
14886
14886
|
return new V2(this.px, Q4.neg(this.py), this.pz);
|
|
14887
14887
|
}
|
|
14888
14888
|
double() {
|
|
14889
|
-
let { a: U2, b: R4 } = J2,
|
|
14890
|
-
return W3 = Q4.add(W3, W3), k4 = Q4.mul(I4, x3), k4 = Q4.add(k4, k4), y4 = Q4.mul(U2, k4), E4 = Q4.mul(
|
|
14889
|
+
let { a: U2, b: R4 } = J2, L3 = Q4.mul(R4, DJ3), { px: I4, py: w3, pz: x3 } = this, y4 = Q4.ZERO, E4 = Q4.ZERO, k4 = Q4.ZERO, A3 = Q4.mul(I4, I4), c4 = Q4.mul(w3, w3), h4 = Q4.mul(x3, x3), W3 = Q4.mul(I4, w3);
|
|
14890
|
+
return W3 = Q4.add(W3, W3), k4 = Q4.mul(I4, x3), k4 = Q4.add(k4, k4), y4 = Q4.mul(U2, k4), E4 = Q4.mul(L3, h4), E4 = Q4.add(y4, E4), y4 = Q4.sub(c4, E4), E4 = Q4.add(c4, E4), E4 = Q4.mul(y4, E4), y4 = Q4.mul(W3, y4), k4 = Q4.mul(L3, k4), h4 = Q4.mul(U2, h4), W3 = Q4.sub(A3, h4), W3 = Q4.mul(U2, W3), W3 = Q4.add(W3, k4), k4 = Q4.add(A3, A3), A3 = Q4.add(k4, A3), A3 = Q4.add(A3, h4), A3 = Q4.mul(A3, W3), E4 = Q4.add(E4, A3), h4 = Q4.mul(w3, x3), h4 = Q4.add(h4, h4), A3 = Q4.mul(h4, W3), y4 = Q4.sub(y4, A3), k4 = Q4.mul(h4, c4), k4 = Q4.add(k4, k4), k4 = Q4.add(k4, k4), new V2(y4, E4, k4);
|
|
14891
14891
|
}
|
|
14892
14892
|
add(U2) {
|
|
14893
14893
|
z2(U2);
|
|
14894
|
-
let { px: R4, py:
|
|
14894
|
+
let { px: R4, py: L3, pz: I4 } = this, { px: w3, py: x3, pz: y4 } = U2, E4 = Q4.ZERO, k4 = Q4.ZERO, A3 = Q4.ZERO, c4 = J2.a, h4 = Q4.mul(J2.b, DJ3), W3 = Q4.mul(R4, w3), C3 = Q4.mul(L3, x3), T3 = Q4.mul(I4, y4), F2 = Q4.add(R4, L3), _4 = Q4.add(w3, x3);
|
|
14895
14895
|
F2 = Q4.mul(F2, _4), _4 = Q4.add(W3, C3), F2 = Q4.sub(F2, _4), _4 = Q4.add(R4, I4);
|
|
14896
14896
|
let O4 = Q4.add(w3, y4);
|
|
14897
|
-
return _4 = Q4.mul(_4, O4), O4 = Q4.add(W3, T3), _4 = Q4.sub(_4, O4), O4 = Q4.add(
|
|
14897
|
+
return _4 = Q4.mul(_4, O4), O4 = Q4.add(W3, T3), _4 = Q4.sub(_4, O4), O4 = Q4.add(L3, I4), E4 = Q4.add(x3, y4), O4 = Q4.mul(O4, E4), E4 = Q4.add(C3, T3), O4 = Q4.sub(O4, E4), A3 = Q4.mul(c4, _4), E4 = Q4.mul(h4, T3), A3 = Q4.add(E4, A3), E4 = Q4.sub(C3, A3), A3 = Q4.add(C3, A3), k4 = Q4.mul(E4, A3), C3 = Q4.add(W3, W3), C3 = Q4.add(C3, W3), T3 = Q4.mul(c4, T3), _4 = Q4.mul(h4, _4), C3 = Q4.add(C3, T3), T3 = Q4.sub(W3, T3), T3 = Q4.mul(c4, T3), _4 = Q4.add(_4, T3), W3 = Q4.mul(C3, _4), k4 = Q4.add(k4, W3), W3 = Q4.mul(O4, _4), E4 = Q4.mul(F2, E4), E4 = Q4.sub(E4, W3), W3 = Q4.mul(F2, C3), A3 = Q4.mul(O4, A3), A3 = Q4.add(A3, W3), new V2(E4, k4, A3);
|
|
14898
14898
|
}
|
|
14899
14899
|
subtract(U2) {
|
|
14900
14900
|
return this.add(U2.negate());
|
|
@@ -14903,18 +14903,18 @@ function OQ($3) {
|
|
|
14903
14903
|
return this.equals(V2.ZERO);
|
|
14904
14904
|
}
|
|
14905
14905
|
wNAF(U2) {
|
|
14906
|
-
return
|
|
14906
|
+
return v3.wNAFCached(this, U2, V2.normalizeZ);
|
|
14907
14907
|
}
|
|
14908
14908
|
multiplyUnsafe(U2) {
|
|
14909
|
-
let { endo: R4, n:
|
|
14910
|
-
y03("scalar", U2, V03,
|
|
14909
|
+
let { endo: R4, n: L3 } = J2;
|
|
14910
|
+
y03("scalar", U2, V03, L3);
|
|
14911
14911
|
let I4 = V2.ZERO;
|
|
14912
14912
|
if (U2 === V03)
|
|
14913
14913
|
return I4;
|
|
14914
14914
|
if (this.is0() || U2 === p5)
|
|
14915
14915
|
return this;
|
|
14916
|
-
if (!R4 ||
|
|
14917
|
-
return
|
|
14916
|
+
if (!R4 || v3.hasPrecomputes(this))
|
|
14917
|
+
return v3.wNAFCachedUnsafe(this, U2, V2.normalizeZ);
|
|
14918
14918
|
let { k1neg: w3, k1: x3, k2neg: y4, k2: E4 } = R4.splitScalar(U2), k4 = I4, A3 = I4, c4 = this;
|
|
14919
14919
|
while (x3 > V03 || E4 > V03) {
|
|
14920
14920
|
if (x3 & p5)
|
|
@@ -14930,20 +14930,20 @@ function OQ($3) {
|
|
|
14930
14930
|
return A3 = new V2(Q4.mul(A3.px, R4.beta), A3.py, A3.pz), k4.add(A3);
|
|
14931
14931
|
}
|
|
14932
14932
|
multiply(U2) {
|
|
14933
|
-
let { endo: R4, n:
|
|
14934
|
-
y03("scalar", U2, p5,
|
|
14933
|
+
let { endo: R4, n: L3 } = J2;
|
|
14934
|
+
y03("scalar", U2, p5, L3);
|
|
14935
14935
|
let I4, w3;
|
|
14936
14936
|
if (R4) {
|
|
14937
14937
|
let { k1neg: x3, k1: y4, k2neg: E4, k2: k4 } = R4.splitScalar(U2), { p: A3, f: c4 } = this.wNAF(y4), { p: h4, f: W3 } = this.wNAF(k4);
|
|
14938
|
-
A3 =
|
|
14938
|
+
A3 = v3.constTimeNegate(x3, A3), h4 = v3.constTimeNegate(E4, h4), h4 = new V2(Q4.mul(h4.px, R4.beta), h4.py, h4.pz), I4 = A3.add(h4), w3 = c4.add(W3);
|
|
14939
14939
|
} else {
|
|
14940
14940
|
let { p: x3, f: y4 } = this.wNAF(U2);
|
|
14941
14941
|
I4 = x3, w3 = y4;
|
|
14942
14942
|
}
|
|
14943
14943
|
return V2.normalizeZ([I4, w3])[0];
|
|
14944
14944
|
}
|
|
14945
|
-
multiplyAndAddUnsafe(U2, R4,
|
|
14946
|
-
let I4 = V2.BASE, w3 = (y4, E4) => E4 === V03 || E4 === p5 || !y4.equals(I4) ? y4.multiplyUnsafe(E4) : y4.multiply(E4), x3 = w3(this, R4).add(w3(U2,
|
|
14945
|
+
multiplyAndAddUnsafe(U2, R4, L3) {
|
|
14946
|
+
let I4 = V2.BASE, w3 = (y4, E4) => E4 === V03 || E4 === p5 || !y4.equals(I4) ? y4.multiplyUnsafe(E4) : y4.multiply(E4), x3 = w3(this, R4).add(w3(U2, L3));
|
|
14947
14947
|
return x3.is0() ? undefined : x3;
|
|
14948
14948
|
}
|
|
14949
14949
|
toAffine(U2) {
|
|
@@ -14973,7 +14973,7 @@ function OQ($3) {
|
|
|
14973
14973
|
}
|
|
14974
14974
|
}
|
|
14975
14975
|
V2.BASE = new V2(J2.Gx, J2.Gy, Q4.ONE), V2.ZERO = new V2(Q4.ZERO, Q4.ONE, Q4.ZERO);
|
|
14976
|
-
let { endo:
|
|
14976
|
+
let { endo: B4, nBitLength: S3 } = J2, v3 = D82(V2, B4 ? Math.ceil(S3 / 2) : S3);
|
|
14977
14977
|
return { CURVE: J2, ProjectivePoint: V2, normPrivateKeyToScalar: N, weierstrassEquation: K3, isWithinCurveOrder: j4 };
|
|
14978
14978
|
}
|
|
14979
14979
|
function RQ($3) {
|
|
@@ -15000,17 +15000,17 @@ function C8($3) {
|
|
|
15000
15000
|
let _4 = z02(F2);
|
|
15001
15001
|
if (!x$2(_4, p5, Q4.ORDER))
|
|
15002
15002
|
throw Error("Point is not on curve");
|
|
15003
|
-
let O4 = z2(_4),
|
|
15003
|
+
let O4 = z2(_4), g3;
|
|
15004
15004
|
try {
|
|
15005
|
-
|
|
15005
|
+
g3 = Q4.sqrt(O4);
|
|
15006
15006
|
} catch (s3) {
|
|
15007
15007
|
let r4 = s3 instanceof Error ? ": " + s3.message : "";
|
|
15008
15008
|
throw Error("Point is not on curve" + r4);
|
|
15009
15009
|
}
|
|
15010
|
-
let m3 = (
|
|
15010
|
+
let m3 = (g3 & p5) === p5;
|
|
15011
15011
|
if ((T3 & 1) === 1 !== m3)
|
|
15012
|
-
|
|
15013
|
-
return { x: _4, y:
|
|
15012
|
+
g3 = Q4.neg(g3);
|
|
15013
|
+
return { x: _4, y: g3 };
|
|
15014
15014
|
} else if (C3 === X4 && T3 === 4) {
|
|
15015
15015
|
let _4 = Q4.fromBytes(F2.subarray(0, Q4.BYTES)), O4 = Q4.fromBytes(F2.subarray(Q4.BYTES, 2 * Q4.BYTES));
|
|
15016
15016
|
return { x: _4, y: O4 };
|
|
@@ -15026,7 +15026,7 @@ function C8($3) {
|
|
|
15026
15026
|
function V2(W3) {
|
|
15027
15027
|
return H4(W3) ? q3(-W3) : W3;
|
|
15028
15028
|
}
|
|
15029
|
-
let
|
|
15029
|
+
let B4 = (W3, C3, T3) => z02(W3.slice(C3, T3));
|
|
15030
15030
|
|
|
15031
15031
|
class S3 {
|
|
15032
15032
|
constructor(W3, C3, T3) {
|
|
@@ -15036,7 +15036,7 @@ function C8($3) {
|
|
|
15036
15036
|
}
|
|
15037
15037
|
static fromCompact(W3) {
|
|
15038
15038
|
let C3 = Y2;
|
|
15039
|
-
return W3 = e5("compactSignature", W3, C3 * 2), new S3(
|
|
15039
|
+
return W3 = e5("compactSignature", W3, C3 * 2), new S3(B4(W3, 0, C3), B4(W3, C3, 2 * C3));
|
|
15040
15040
|
}
|
|
15041
15041
|
static fromDER(W3) {
|
|
15042
15042
|
let { r: C3, s: T3 } = D03.toSig(e5("DER", W3));
|
|
@@ -15053,7 +15053,7 @@ function C8($3) {
|
|
|
15053
15053
|
let O4 = F2 === 2 || F2 === 3 ? C3 + J2.n : C3;
|
|
15054
15054
|
if (O4 >= Q4.ORDER)
|
|
15055
15055
|
throw Error("recovery id 2 or 3 invalid");
|
|
15056
|
-
let
|
|
15056
|
+
let g3 = (F2 & 1) === 0 ? "02" : "03", m3 = j4.fromHex(g3 + zJ3(O4, Q4.BYTES)), l4 = M2(O4), s3 = q3(-_4 * l4), r4 = q3(T3 * l4), O03 = j4.BASE.multiplyAndAddUnsafe(m3, s3, r4);
|
|
15057
15057
|
if (!O03)
|
|
15058
15058
|
throw Error("point at infinify");
|
|
15059
15059
|
return O03.assertValidity(), O03;
|
|
@@ -15078,7 +15078,7 @@ function C8($3) {
|
|
|
15078
15078
|
return zJ3(this.r, W3) + zJ3(this.s, W3);
|
|
15079
15079
|
}
|
|
15080
15080
|
}
|
|
15081
|
-
let
|
|
15081
|
+
let v3 = { isValidPrivateKey(W3) {
|
|
15082
15082
|
try {
|
|
15083
15083
|
return N(W3), true;
|
|
15084
15084
|
} catch (C3) {
|
|
@@ -15104,7 +15104,7 @@ function C8($3) {
|
|
|
15104
15104
|
else
|
|
15105
15105
|
return T3 === _4 || T3 === O4;
|
|
15106
15106
|
}
|
|
15107
|
-
function
|
|
15107
|
+
function L3(W3, C3, T3 = true) {
|
|
15108
15108
|
if (R4(W3) === true)
|
|
15109
15109
|
throw Error("first arg must be private key");
|
|
15110
15110
|
if (R4(C3) === false)
|
|
@@ -15125,10 +15125,10 @@ function C8($3) {
|
|
|
15125
15125
|
function E4(W3, C3, T3 = k4) {
|
|
15126
15126
|
if (["recovered", "canonical"].some((H03) => (H03 in T3)))
|
|
15127
15127
|
throw Error("sign() legacy options not supported");
|
|
15128
|
-
let { hash: F2, randomBytes: _4 } = J2, { lowS: O4, prehash:
|
|
15128
|
+
let { hash: F2, randomBytes: _4 } = J2, { lowS: O4, prehash: g3, extraEntropy: m3 } = T3;
|
|
15129
15129
|
if (O4 == null)
|
|
15130
15130
|
O4 = true;
|
|
15131
|
-
if (W3 = e5("msgHash", W3), O82(T3),
|
|
15131
|
+
if (W3 = e5("msgHash", W3), O82(T3), g3)
|
|
15132
15132
|
W3 = e5("prehashed msgHash", F2(W3));
|
|
15133
15133
|
let l4 = w3(W3), s3 = N(C3), r4 = [y4(s3), y4(l4)];
|
|
15134
15134
|
if (m3 != null && m3 !== false) {
|
|
@@ -15137,10 +15137,10 @@ function C8($3) {
|
|
|
15137
15137
|
}
|
|
15138
15138
|
let O03 = M$(...r4), N$2 = l4;
|
|
15139
15139
|
function F$2(H03) {
|
|
15140
|
-
let
|
|
15141
|
-
if (!D3(
|
|
15140
|
+
let f03 = I4(H03);
|
|
15141
|
+
if (!D3(f03))
|
|
15142
15142
|
return;
|
|
15143
|
-
let b$2 = M2(
|
|
15143
|
+
let b$2 = M2(f03), o03 = j4.BASE.multiply(f03).toAffine(), S03 = q3(o03.x);
|
|
15144
15144
|
if (S03 === V03)
|
|
15145
15145
|
return;
|
|
15146
15146
|
let t03 = q3(b$2 * q3(N$2 + S03 * s3));
|
|
@@ -15162,7 +15162,7 @@ function C8($3) {
|
|
|
15162
15162
|
function h4(W3, C3, T3, F2 = A3) {
|
|
15163
15163
|
let _4 = W3;
|
|
15164
15164
|
C3 = e5("msgHash", C3), T3 = e5("publicKey", T3);
|
|
15165
|
-
let { lowS: O4, prehash:
|
|
15165
|
+
let { lowS: O4, prehash: g3, format: m3 } = F2;
|
|
15166
15166
|
if (O82(F2), "strict" in F2)
|
|
15167
15167
|
throw Error("options.strict was renamed to lowS");
|
|
15168
15168
|
if (m3 !== undefined && m3 !== "compact" && m3 !== "der")
|
|
@@ -15193,39 +15193,39 @@ function C8($3) {
|
|
|
15193
15193
|
return false;
|
|
15194
15194
|
if (O4 && r4.hasHighS())
|
|
15195
15195
|
return false;
|
|
15196
|
-
if (
|
|
15196
|
+
if (g3)
|
|
15197
15197
|
C3 = J2.hash(C3);
|
|
15198
|
-
let { r: N$2, s: F$2 } = r4, H03 = w3(C3),
|
|
15198
|
+
let { r: N$2, s: F$2 } = r4, H03 = w3(C3), f03 = M2(F$2), b$2 = q3(H03 * f03), o03 = q3(N$2 * f03), S03 = j4.BASE.multiplyAndAddUnsafe(O03, b$2, o03)?.toAffine();
|
|
15199
15199
|
if (!S03)
|
|
15200
15200
|
return false;
|
|
15201
15201
|
return q3(S03.x) === N$2;
|
|
15202
15202
|
}
|
|
15203
|
-
return { CURVE: J2, getPublicKey: U2, getSharedSecret:
|
|
15203
|
+
return { CURVE: J2, getPublicKey: U2, getSharedSecret: L3, sign: c4, verify: h4, ProjectivePoint: j4, Signature: S3, utils: v3 };
|
|
15204
15204
|
}
|
|
15205
15205
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
15206
15206
|
function CQ2($3) {
|
|
15207
|
-
return { hash: $3, hmac: (J2, ...Q4) => t$2($3, J2, bJ2(...Q4)), randomBytes:
|
|
15207
|
+
return { hash: $3, hmac: (J2, ...Q4) => t$2($3, J2, bJ2(...Q4)), randomBytes: gJ3 };
|
|
15208
15208
|
}
|
|
15209
|
-
function
|
|
15209
|
+
function P8($3, J2) {
|
|
15210
15210
|
let Q4 = (G2) => C8({ ...$3, ...CQ2(G2) });
|
|
15211
15211
|
return { ...Q4(J2), create: Q4 };
|
|
15212
15212
|
}
|
|
15213
15213
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
15214
15214
|
var H8 = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
|
|
15215
|
-
var
|
|
15216
|
-
var
|
|
15217
|
-
var
|
|
15215
|
+
var B8 = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
|
|
15216
|
+
var PQ2 = BigInt(0);
|
|
15217
|
+
var BQ2 = BigInt(1);
|
|
15218
15218
|
var VJ3 = BigInt(2);
|
|
15219
|
-
var
|
|
15220
|
-
function
|
|
15221
|
-
let J2 = H8, Q4 = BigInt(3), G2 = BigInt(6), Y2 = BigInt(11), Z3 = BigInt(22), K3 = BigInt(23), X4 = BigInt(44), q3 = BigInt(88), M2 = $3 * $3 * $3 % J2, j4 = M2 * M2 * $3 % J2, N = J02(j4, Q4, J2) * j4 % J2, z2 = J02(N, Q4, J2) * j4 % J2, D3 = J02(z2, VJ3, J2) * M2 % J2, H4 = J02(D3, Y2, J2) * D3 % J2, V2 = J02(H4, Z3, J2) * H4 % J2,
|
|
15219
|
+
var L8 = ($3, J2) => ($3 + J2 / VJ3) / J2;
|
|
15220
|
+
function LQ($3) {
|
|
15221
|
+
let J2 = H8, Q4 = BigInt(3), G2 = BigInt(6), Y2 = BigInt(11), Z3 = BigInt(22), K3 = BigInt(23), X4 = BigInt(44), q3 = BigInt(88), M2 = $3 * $3 * $3 % J2, j4 = M2 * M2 * $3 % J2, N = J02(j4, Q4, J2) * j4 % J2, z2 = J02(N, Q4, J2) * j4 % J2, D3 = J02(z2, VJ3, J2) * M2 % J2, H4 = J02(D3, Y2, J2) * D3 % J2, V2 = J02(H4, Z3, J2) * H4 % J2, B4 = J02(V2, X4, J2) * V2 % J2, S3 = J02(B4, q3, J2) * B4 % J2, v3 = J02(S3, X4, J2) * V2 % J2, U2 = J02(v3, Q4, J2) * j4 % J2, R4 = J02(U2, K3, J2) * H4 % J2, L3 = J02(R4, G2, J2) * M2 % J2, I4 = J02(L3, VJ3, J2);
|
|
15222
15222
|
if (!OJ3.eql(OJ3.sqr(I4), $3))
|
|
15223
15223
|
throw Error("Cannot find square root");
|
|
15224
15224
|
return I4;
|
|
15225
15225
|
}
|
|
15226
|
-
var OJ3 = j$2(H8, undefined, undefined, { sqrt:
|
|
15227
|
-
var RJ3 =
|
|
15228
|
-
let J2 =
|
|
15226
|
+
var OJ3 = j$2(H8, undefined, undefined, { sqrt: LQ });
|
|
15227
|
+
var RJ3 = P8({ a: PQ2, b: BigInt(7), Fp: OJ3, n: B8, Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"), Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"), h: BigInt(1), lowS: true, endo: { beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"), splitScalar: ($3) => {
|
|
15228
|
+
let J2 = B8, Q4 = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), G2 = -BQ2 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), Y2 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), Z3 = Q4, K3 = BigInt("0x100000000000000000000000000000000"), X4 = L8(Z3 * $3, J2), q3 = L8(-G2 * $3, J2), M2 = i4($3 - X4 * Q4 - q3 * Y2, J2), j4 = i4(-X4 * G2 - q3 * Z3, J2), N = M2 > K3, z2 = j4 > K3;
|
|
15229
15229
|
if (N)
|
|
15230
15230
|
M2 = J2 - M2;
|
|
15231
15231
|
if (z2)
|
|
@@ -15240,7 +15240,7 @@ function k$2() {
|
|
|
15240
15240
|
}
|
|
15241
15241
|
function w$2($3) {
|
|
15242
15242
|
let J2 = $3.startsWith("0x") ? $3.slice(2) : $3, Q4 = Buffer.from(J2, "hex"), G2 = RJ3.getPublicKey(Q4, false), Z3 = m03(G2.slice(1)).slice(-20), K3 = "0x" + Buffer.from(Z3).toString("hex");
|
|
15243
|
-
return
|
|
15243
|
+
return P03(K3);
|
|
15244
15244
|
}
|
|
15245
15245
|
function y$2($3) {
|
|
15246
15246
|
let J2;
|
|
@@ -15253,25 +15253,25 @@ function y$2($3) {
|
|
|
15253
15253
|
return "0x" + Buffer.from(Q4).toString("hex");
|
|
15254
15254
|
}
|
|
15255
15255
|
|
|
15256
|
-
class
|
|
15256
|
+
class b4 extends E$2 {
|
|
15257
15257
|
constructor($3, J2) {
|
|
15258
15258
|
super("InvitationError", $3, { ...J2, source: J2?.source || "INVITATIONS" });
|
|
15259
15259
|
}
|
|
15260
15260
|
static noPathFound($3, J2, Q4) {
|
|
15261
|
-
return new
|
|
15261
|
+
return new b4(`No valid invitation path found from ${$3} to ${J2}. ${Q4 || "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: Q4 } });
|
|
15262
15262
|
}
|
|
15263
15263
|
static noProxyInviters($3) {
|
|
15264
|
-
return new
|
|
15264
|
+
return new b4(`No proxy inviters found for ${$3}. The inviter must have mutual trust connections with users who are also trusted by the invitation module, and these users must have sufficient balance.`, { code: "INVITATION_NO_PROXY_INVITERS", source: "VALIDATION", context: { inviter: $3 } });
|
|
15265
15265
|
}
|
|
15266
15266
|
static insufficientBalance($3, J2, Q4, G2, Y2, Z3) {
|
|
15267
15267
|
let K3 = Number(Q4) / 1000000000000000000, X4 = Number(G2) / 1000000000000000000;
|
|
15268
|
-
return new
|
|
15268
|
+
return new b4(`Insufficient balance for ${$3} invitation(s). Can only afford ${J2} invitation(s). Requested: ${K3.toFixed(6)} CRC, Available: ${X4.toFixed(6)} CRC.`, { code: "INVITATION_INSUFFICIENT_BALANCE", source: "VALIDATION", context: { from: Y2, to: Z3, requestedInvites: $3, availableInvites: J2, requested: Q4.toString(), available: G2.toString(), requestedCrc: K3, availableCrc: X4 } });
|
|
15269
15269
|
}
|
|
15270
15270
|
static inviteeAlreadyRegistered($3, J2) {
|
|
15271
|
-
return new
|
|
15271
|
+
return new b4(`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 } });
|
|
15272
15272
|
}
|
|
15273
15273
|
static noAddressesProvided() {
|
|
15274
|
-
return new
|
|
15274
|
+
return new b4("At least one address must be provided for invitation.", { code: "INVITATION_NO_ADDRESSES_PROVIDED", source: "VALIDATION" });
|
|
15275
15275
|
}
|
|
15276
15276
|
}
|
|
15277
15277
|
var S82 = [];
|
|
@@ -15318,8 +15318,8 @@ function HQ2($3, J2) {
|
|
|
15318
15318
|
return Q4;
|
|
15319
15319
|
}
|
|
15320
15320
|
function CJ2($3, J2, Q4, G2) {
|
|
15321
|
-
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), { sorted: K3, idx: X4 } = T82(G2, Y2, Z3), q3 = HQ2(G2, Z3), M2 = G2.map((S3,
|
|
15322
|
-
return { streamSinkId: q3.has(
|
|
15321
|
+
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), { sorted: K3, idx: X4 } = T82(G2, Y2, Z3), q3 = HQ2(G2, Z3), M2 = G2.map((S3, v3) => {
|
|
15322
|
+
return { streamSinkId: q3.has(v3) ? 1 : 0, amount: S3.value };
|
|
15323
15323
|
});
|
|
15324
15324
|
if (q3.size === 0)
|
|
15325
15325
|
throw Error(`No terminal edges detected. Flow must have at least one edge delivering to receiver ${Z3}`);
|
|
@@ -15327,18 +15327,18 @@ function CJ2($3, J2, Q4, G2) {
|
|
|
15327
15327
|
G2.forEach((S3) => {
|
|
15328
15328
|
z2.push(X4[S3.tokenOwner.toLowerCase()]), z2.push(X4[S3.from.toLowerCase()]), z2.push(X4[S3.to.toLowerCase()]);
|
|
15329
15329
|
});
|
|
15330
|
-
let D3 = I82(z2), H4 = BigInt(Q4), V2 = M2.filter((S3) => S3.streamSinkId === 1).reduce((S3,
|
|
15330
|
+
let D3 = I82(z2), H4 = BigInt(Q4), V2 = M2.filter((S3) => S3.streamSinkId === 1).reduce((S3, v3) => S3 + BigInt(v3.amount.toString()), BigInt(0));
|
|
15331
15331
|
if (V2 !== H4)
|
|
15332
15332
|
throw Error(`Terminal sum ${V2} does not equal expected ${H4}`);
|
|
15333
15333
|
return { flowVertices: K3, flowEdges: M2, streams: N, packedCoordinates: D3, sourceCoordinate: X4[Y2] };
|
|
15334
15334
|
}
|
|
15335
|
-
function
|
|
15335
|
+
function PJ2($3, J2) {
|
|
15336
15336
|
let Q4 = $3.streams.map((G2) => ({ sourceCoordinate: G2.sourceCoordinate, flowEdgeIds: G2.flowEdgeIds, data: G2.data instanceof Uint8Array ? U$(G2.data) : G2.data }));
|
|
15337
15337
|
if (J2 && Q4.length > 0)
|
|
15338
15338
|
Q4[0].data = J2 instanceof Uint8Array ? U$(J2) : J2;
|
|
15339
15339
|
return Q4;
|
|
15340
15340
|
}
|
|
15341
|
-
async function
|
|
15341
|
+
async function BJ2($3, J2, Q4) {
|
|
15342
15342
|
let G2 = new Map, Y2 = new Set;
|
|
15343
15343
|
return Q4.transfers.forEach((X4) => {
|
|
15344
15344
|
if ($3.toLowerCase() === X4.from.toLowerCase())
|
|
@@ -15349,7 +15349,7 @@ async function PJ2($3, J2, Q4) {
|
|
|
15349
15349
|
G2.set(X4.tokenAddress.toLowerCase(), X4);
|
|
15350
15350
|
}), G2;
|
|
15351
15351
|
}
|
|
15352
|
-
function
|
|
15352
|
+
function LJ3($3, J2) {
|
|
15353
15353
|
let Q4 = {};
|
|
15354
15354
|
return $3.transfers.forEach((G2) => {
|
|
15355
15355
|
let Y2 = J2.get(G2.tokenOwner.toLowerCase());
|
|
@@ -15404,7 +15404,7 @@ class W$ {
|
|
|
15404
15404
|
balance;
|
|
15405
15405
|
group;
|
|
15406
15406
|
constructor($3) {
|
|
15407
|
-
this.config = $3, this.hubV2 = new
|
|
15407
|
+
this.config = $3, this.hubV2 = new B0({ address: $3.v2HubAddress, rpcUrl: $3.circlesRpcUrl }), this.liftERC20 = new T$2({ address: $3.liftERC20Address, rpcUrl: $3.circlesRpcUrl }), this.rpcClient = new R03($3.circlesRpcUrl), this.pathfinder = new U03(this.rpcClient), this.balance = new A02(this.rpcClient), this.group = new k03(this.rpcClient);
|
|
15408
15408
|
}
|
|
15409
15409
|
async buildFlowMatrixTx($3, J2, Q4, G2, Y2 = false) {
|
|
15410
15410
|
let Z3 = $3.toLowerCase(), K3 = J2.toLowerCase();
|
|
@@ -15412,36 +15412,36 @@ class W$ {
|
|
|
15412
15412
|
throw o5.noPathFound(Z3, K3);
|
|
15413
15413
|
let X4 = { ...Q4 };
|
|
15414
15414
|
if (Y2 && G2?.toTokens?.length === 1) {
|
|
15415
|
-
let
|
|
15415
|
+
let v3 = G2.toTokens[0].toLowerCase();
|
|
15416
15416
|
if (Q4.maxFlow > 0n)
|
|
15417
|
-
X4.transfers.push({ from: K3, to: K3, tokenOwner:
|
|
15417
|
+
X4.transfers.push({ from: K3, to: K3, tokenOwner: v3, value: Q4.maxFlow });
|
|
15418
15418
|
}
|
|
15419
|
-
let q3 = await
|
|
15419
|
+
let q3 = await BJ2(Z3, this.config.circlesRpcUrl, X4), M2 = LJ3(X4, q3), j4 = Object.keys(M2).length > 0;
|
|
15420
15420
|
if (j4 && !G2?.useWrappedBalances)
|
|
15421
15421
|
throw o5.wrappedTokensRequired();
|
|
15422
15422
|
let N = [], z2 = [];
|
|
15423
15423
|
if (j4) {
|
|
15424
|
-
let
|
|
15425
|
-
N = [...U2, ...R4], z2 =
|
|
15424
|
+
let v3 = await this._getTokenBalanceMap(Z3), U2 = this._createDemurragedUnwrapCalls(M2), { unwrapCalls: R4, wrapCalls: L3 } = this._createInflationaryUnwrapAndWrapCalls(M2, q3, v3);
|
|
15425
|
+
N = [...U2, ...R4], z2 = L3, X4 = HJ3(X4, q3);
|
|
15426
15426
|
}
|
|
15427
|
-
let D3 = CJ2(Z3, K3, X4.maxFlow, X4.transfers), H4 =
|
|
15427
|
+
let D3 = CJ2(Z3, K3, X4.maxFlow, X4.transfers), H4 = PJ2(D3, G2?.txData), V2 = this.hubV2.operateFlowMatrix(D3.flowVertices, D3.flowEdges, H4, D3.packedCoordinates), B4 = false;
|
|
15428
15428
|
try {
|
|
15429
|
-
|
|
15430
|
-
} catch (
|
|
15431
|
-
console.warn("Failed to check approval status, including approval transaction:",
|
|
15429
|
+
B4 = await this.hubV2.isApprovedForAll(Z3, Z3);
|
|
15430
|
+
} catch (v3) {
|
|
15431
|
+
console.warn("Failed to check approval status, including approval transaction:", v3);
|
|
15432
15432
|
}
|
|
15433
|
-
return [...
|
|
15433
|
+
return [...B4 ? [] : [this.hubV2.setApprovalForAll(Z3, true)], ...N, V2, ...z2];
|
|
15434
15434
|
}
|
|
15435
15435
|
async constructAdvancedTransfer($3, J2, Q4, G2, Y2 = false) {
|
|
15436
15436
|
let Z3 = $3.toLowerCase(), K3 = J2.toLowerCase(), X4 = BigInt(Q4);
|
|
15437
15437
|
if (Z3 === K3 && G2?.fromTokens?.length === 1 && G2?.toTokens?.length === 1) {
|
|
15438
|
-
let D3 = G2.fromTokens[0], H4 = G2.toTokens[0], [V2,
|
|
15438
|
+
let D3 = G2.fromTokens[0], H4 = G2.toTokens[0], [V2, B4] = await Promise.all([this.liftERC20.erc20Circles(0, H4), this.liftERC20.erc20Circles(1, H4)]);
|
|
15439
15439
|
if (D3.toLowerCase() === V2.toLowerCase() && V2 !== S$2) {
|
|
15440
|
-
let
|
|
15441
|
-
return [{ to:
|
|
15440
|
+
let v3 = new c03({ address: D3, rpcUrl: this.config.circlesRpcUrl }).unwrap(X4);
|
|
15441
|
+
return [{ to: v3.to, data: v3.data, value: v3.value ?? 0n }];
|
|
15442
15442
|
}
|
|
15443
|
-
if (D3.toLowerCase() ===
|
|
15444
|
-
let S3 = new l03({ address: D3, rpcUrl: this.config.circlesRpcUrl }),
|
|
15443
|
+
if (D3.toLowerCase() === B4.toLowerCase() && B4 !== S$2) {
|
|
15444
|
+
let S3 = new l03({ address: D3, rpcUrl: this.config.circlesRpcUrl }), v3 = d4.attoCirclesToAttoStaticCircles(X4), U2 = S3.unwrap(v3);
|
|
15445
15445
|
return [{ to: U2.to, data: U2.data, value: U2.value ?? 0n }];
|
|
15446
15446
|
}
|
|
15447
15447
|
}
|
|
@@ -15462,54 +15462,54 @@ class W$ {
|
|
|
15462
15462
|
z2 = BigInt(O4.staticAttoCircles), H4 = O4.tokenAddress;
|
|
15463
15463
|
else
|
|
15464
15464
|
j4 = BigInt(O4.attoCircles);
|
|
15465
|
-
let V2 = j4 + N + d4.attoStaticCirclesToAttoCircles(z2),
|
|
15465
|
+
let V2 = j4 + N + d4.attoStaticCirclesToAttoCircles(z2), B4 = [];
|
|
15466
15466
|
if (j4 >= X4) {
|
|
15467
15467
|
if (console.log(`✓ Already have ${Number(j4) / 1000000000000000000} CRC unwrapped (target: ${Number(X4) / 1000000000000000000} CRC). No replenish needed.`), K3 !== Y2) {
|
|
15468
|
-
let O4 = await this.hubV2.toTokenId(Z3),
|
|
15469
|
-
|
|
15468
|
+
let O4 = await this.hubV2.toTokenId(Z3), g3 = this.hubV2.safeTransferFrom(Y2, K3, O4, X4);
|
|
15469
|
+
B4.push({ to: g3.to, data: g3.data, value: g3.value ?? 0n });
|
|
15470
15470
|
}
|
|
15471
|
-
return
|
|
15471
|
+
return B4;
|
|
15472
15472
|
}
|
|
15473
15473
|
let S3 = X4 - j4;
|
|
15474
15474
|
if (console.log(`Current unwrapped: ${Number(j4) / 1000000000000000000} CRC`), console.log(`Target amount: ${Number(X4) / 1000000000000000000} CRC`), console.log(`Need to acquire: ${Number(S3) / 1000000000000000000} CRC`), V2 >= X4) {
|
|
15475
15475
|
let O4 = S3;
|
|
15476
15476
|
if (N > 0n && D3 && O4 > 0n) {
|
|
15477
|
-
let
|
|
15478
|
-
|
|
15477
|
+
let g3 = O4 > N ? N : O4, l4 = new c03({ address: D3, rpcUrl: this.config.circlesRpcUrl }).unwrap(g3);
|
|
15478
|
+
B4.push({ to: l4.to, data: l4.data, value: l4.value ?? 0n }), O4 -= g3;
|
|
15479
15479
|
}
|
|
15480
15480
|
if (z2 > 0n && H4 && O4 > 0n) {
|
|
15481
|
-
let
|
|
15482
|
-
|
|
15481
|
+
let g3 = d4.attoCirclesToAttoStaticCircles(O4), m3 = g3 > z2 ? z2 : g3, s3 = new l03({ address: H4, rpcUrl: this.config.circlesRpcUrl }).unwrap(m3);
|
|
15482
|
+
B4.push({ to: s3.to, data: s3.data, value: s3.value ?? 0n });
|
|
15483
15483
|
}
|
|
15484
15484
|
if (K3 !== Y2) {
|
|
15485
|
-
let
|
|
15486
|
-
|
|
15485
|
+
let g3 = await this.hubV2.toTokenId(Z3), m3 = this.hubV2.safeTransferFrom(Y2, K3, g3, X4);
|
|
15486
|
+
B4.push({ to: m3.to, data: m3.data, value: m3.value ?? 0n });
|
|
15487
15487
|
}
|
|
15488
|
-
return
|
|
15488
|
+
return B4;
|
|
15489
15489
|
}
|
|
15490
|
-
let U2 = !await this.hubV2.isTrusted(Y2, Z3), R4 = BigInt(Math.floor(Date.now() / 1000) + 31536000),
|
|
15490
|
+
let U2 = !await this.hubV2.isTrusted(Y2, Z3), R4 = BigInt(Math.floor(Date.now() / 1000) + 31536000), L3 = d4.truncateToInt64(S3), I4 = S3 % d4.FACTOR_1E12 !== 0n, w3 = d4.blowUpToBigInt(I4 ? L3 + 1n : L3), x3;
|
|
15491
15491
|
try {
|
|
15492
15492
|
x3 = await this.pathfinder.findPath({ from: Y2, to: K3, targetFlow: w3, toTokens: [Z3], useWrappedBalances: true, simulatedTrusts: U2 ? [{ truster: Y2, trustee: Z3 }] : undefined });
|
|
15493
15493
|
} catch (O4) {
|
|
15494
|
-
let
|
|
15495
|
-
throw new o5(`Insufficient tokens to replenish. Target: ${m3.toFixed(6)} CRC, Current unwrapped: ${Number(j4) / 1000000000000000000} CRC, Need: ${l4.toFixed(6)} CRC, Available (including all paths): ${
|
|
15494
|
+
let g3 = Number(V2) / 1000000000000000000, m3 = Number(X4) / 1000000000000000000, l4 = Number(S3) / 1000000000000000000;
|
|
15495
|
+
throw new o5(`Insufficient tokens to replenish. Target: ${m3.toFixed(6)} CRC, Current unwrapped: ${Number(j4) / 1000000000000000000} CRC, Need: ${l4.toFixed(6)} CRC, Available (including all paths): ${g3.toFixed(6)} CRC. Cannot acquire the remaining ${(Number(S3 - (V2 - j4)) / 1000000000000000000).toFixed(6)} CRC.`, { code: "REPLENISH_INSUFFICIENT_TOKENS", source: "VALIDATION", context: { from: Y2, tokenId: Z3, target: X4.toString(), unwrapped: j4.toString(), deficit: S3.toString(), available: V2.toString(), targetCrc: m3, unwrappedCrc: Number(j4) / 1000000000000000000, deficitCrc: l4, availableCrc: g3 } });
|
|
15496
15496
|
}
|
|
15497
15497
|
if (!x3.transfers || x3.transfers.length === 0)
|
|
15498
15498
|
throw o5.noPathFound(Y2, K3, `No path to acquire token ${Z3}`);
|
|
15499
15499
|
if (x3.maxFlow < w3) {
|
|
15500
|
-
let O4 = Number(x3.maxFlow) / 1000000000000000000,
|
|
15501
|
-
throw new o5(`Pathfinder can only provide ${O4.toFixed(6)} CRC of the ${
|
|
15500
|
+
let O4 = Number(x3.maxFlow) / 1000000000000000000, g3 = Number(w3) / 1000000000000000000;
|
|
15501
|
+
throw new o5(`Pathfinder can only provide ${O4.toFixed(6)} CRC of the ${g3.toFixed(6)} CRC deficit needed for token ${Z3}.`, { code: "REPLENISH_INSUFFICIENT_PATH_FLOW", source: "PATHFINDING", context: { from: Y2, tokenId: Z3, deficit: w3.toString(), pathFlow: x3.maxFlow.toString(), deficitCrc: g3, pathFlowCrc: O4 } });
|
|
15502
15502
|
}
|
|
15503
15503
|
if (U2) {
|
|
15504
15504
|
let O4 = this.hubV2.trust(Z3, R4);
|
|
15505
|
-
|
|
15505
|
+
B4.push({ to: O4.to, data: O4.data, value: O4.value ?? 0n });
|
|
15506
15506
|
}
|
|
15507
|
-
let y4 = await
|
|
15507
|
+
let y4 = await BJ2(Y2, this.config.circlesRpcUrl, x3), E4 = LJ3(x3, y4), k4 = Object.keys(E4).length > 0, A3 = [], c4 = [];
|
|
15508
15508
|
if (k4) {
|
|
15509
|
-
let O4 = await this._getTokenBalanceMap(Y2),
|
|
15510
|
-
A3 = [...
|
|
15509
|
+
let O4 = await this._getTokenBalanceMap(Y2), g3 = this._createDemurragedUnwrapCalls(E4), { unwrapCalls: m3, wrapCalls: l4 } = this._createInflationaryUnwrapAndWrapCalls(E4, y4, O4);
|
|
15510
|
+
A3 = [...g3, ...m3], c4 = l4, x3 = HJ3(x3, y4);
|
|
15511
15511
|
}
|
|
15512
|
-
let h4 = CJ2(Y2, K3, x3.maxFlow, x3.transfers), W3 =
|
|
15512
|
+
let h4 = CJ2(Y2, K3, x3.maxFlow, x3.transfers), W3 = PJ2(h4), C3 = this.hubV2.operateFlowMatrix(h4.flowVertices, h4.flowEdges, W3, h4.packedCoordinates), T3 = { to: C3.to, data: C3.data, value: C3.value ?? 0n }, F2 = false;
|
|
15513
15513
|
try {
|
|
15514
15514
|
F2 = await this.hubV2.isApprovedForAll(Y2, Y2);
|
|
15515
15515
|
} catch (O4) {
|
|
@@ -15520,7 +15520,7 @@ class W$ {
|
|
|
15520
15520
|
c4.push({ to: O4.to, data: O4.data, value: O4.value ?? 0n });
|
|
15521
15521
|
}
|
|
15522
15522
|
let _4 = F2 ? [] : [{ to: this.hubV2.setApprovalForAll(Y2, true).to, data: this.hubV2.setApprovalForAll(Y2, true).data, value: 0n }];
|
|
15523
|
-
return
|
|
15523
|
+
return B4.push(..._4, ...A3, T3, ...c4), B4;
|
|
15524
15524
|
}
|
|
15525
15525
|
async _getTokenBalanceMap($3) {
|
|
15526
15526
|
let J2 = await this.balance.getTokenBalances($3), Q4 = new Map;
|
|
@@ -15584,16 +15584,16 @@ class SJ3 {
|
|
|
15584
15584
|
referralsModule;
|
|
15585
15585
|
constructor($3) {
|
|
15586
15586
|
if (!$3.referralsServiceUrl)
|
|
15587
|
-
throw new
|
|
15588
|
-
this.config = $3, this.rpcClient = new R03($3.circlesRpcUrl), this.pathfinder = new U03(this.rpcClient), this.trust = new x03(this.rpcClient), this.hubV2 = new
|
|
15587
|
+
throw new b4("referralsServiceUrl is required in config", { code: "INVITATION_MISSING_CONFIG", source: "INVITATIONS", context: { missingField: "referralsServiceUrl" } });
|
|
15588
|
+
this.config = $3, this.rpcClient = new R03($3.circlesRpcUrl), this.pathfinder = new U03(this.rpcClient), this.trust = new x03(this.rpcClient), this.hubV2 = new B0({ address: $3.v2HubAddress, rpcUrl: $3.circlesRpcUrl }), this.referralsModule = new p03({ address: $3.referralsModuleAddress, rpcUrl: $3.circlesRpcUrl });
|
|
15589
15589
|
}
|
|
15590
15590
|
async saveReferralData($3, J2) {
|
|
15591
15591
|
try {
|
|
15592
15592
|
let Q4 = await fetch(`${this.config.referralsServiceUrl}/store`, { method: "POST", headers: { accept: "application/json", "Content-Type": "application/json" }, body: JSON.stringify({ privateKey: J2, inviter: $3 }) });
|
|
15593
15593
|
if (!Q4.ok)
|
|
15594
|
-
throw new
|
|
15594
|
+
throw new b4(`HTTP error! status: ${Q4.status}`, { code: "INVITATION_HTTP_ERROR", source: "INVITATIONS", context: { status: Q4.status, url: `${this.config.referralsServiceUrl}/store` } });
|
|
15595
15595
|
} catch (Q4) {
|
|
15596
|
-
throw console.error("Failed to save referral data:", Q4), new
|
|
15596
|
+
throw console.error("Failed to save referral data:", Q4), new b4(`Failed to save referral data: ${Q4 instanceof Error ? Q4.message : "Unknown error"}`, { code: "INVITATION_SAVE_REFERRAL_FAILED", source: "INVITATIONS", cause: Q4 });
|
|
15597
15597
|
}
|
|
15598
15598
|
}
|
|
15599
15599
|
async listReferrals($3, J2 = 10, Q4 = 0) {
|
|
@@ -15602,12 +15602,12 @@ class SJ3 {
|
|
|
15602
15602
|
G2.searchParams.set("limit", String(J2)), G2.searchParams.set("offset", String(Q4));
|
|
15603
15603
|
let Y2 = await fetch(G2.toString(), { method: "GET", headers: { accept: "application/json" } });
|
|
15604
15604
|
if (!Y2.ok)
|
|
15605
|
-
throw new
|
|
15605
|
+
throw new b4(`HTTP error! status: ${Y2.status}`, { code: "INVITATION_HTTP_ERROR", source: "INVITATIONS", context: { status: Y2.status, url: G2.toString() } });
|
|
15606
15606
|
return await Y2.json();
|
|
15607
15607
|
} catch (G2) {
|
|
15608
|
-
if (G2 instanceof
|
|
15608
|
+
if (G2 instanceof b4)
|
|
15609
15609
|
throw G2;
|
|
15610
|
-
throw new
|
|
15610
|
+
throw new b4(`Failed to list referrals: ${G2 instanceof Error ? G2.message : "Unknown error"}`, { code: "INVITATION_LIST_REFERRALS_FAILED", source: "INVITATIONS", cause: G2 });
|
|
15611
15611
|
}
|
|
15612
15612
|
}
|
|
15613
15613
|
orderRealInviters($3, J2) {
|
|
@@ -15624,12 +15624,12 @@ class SJ3 {
|
|
|
15624
15624
|
async generateInvite($3, J2) {
|
|
15625
15625
|
let Q4 = $3.toLowerCase(), G2 = J2.toLowerCase();
|
|
15626
15626
|
if (await this.hubV2.isHuman(G2))
|
|
15627
|
-
throw
|
|
15627
|
+
throw b4.inviteeAlreadyRegistered(Q4, G2);
|
|
15628
15628
|
let Z3 = await this.findInvitePath(Q4), K3 = await this.generateInviteData([G2], false), X4 = new W$(this.config), q3 = await this.getRealInviters(Q4);
|
|
15629
15629
|
if (q3.length === 0)
|
|
15630
|
-
throw
|
|
15630
|
+
throw b4.noPathFound(Q4, this.config.invitationModuleAddress);
|
|
15631
15631
|
let M2 = q3[0].address;
|
|
15632
|
-
return await X4.buildFlowMatrixTx(Q4, this.config.invitationModuleAddress, Z3, { toTokens: [M2], useWrappedBalances: true, txData:
|
|
15632
|
+
return await X4.buildFlowMatrixTx(Q4, this.config.invitationModuleAddress, Z3, { toTokens: [M2], useWrappedBalances: true, txData: P$2(K3) }, true);
|
|
15633
15633
|
}
|
|
15634
15634
|
async findInvitePath($3, J2) {
|
|
15635
15635
|
let Q4 = $3.toLowerCase(), G2;
|
|
@@ -15638,26 +15638,26 @@ class SJ3 {
|
|
|
15638
15638
|
else {
|
|
15639
15639
|
let Z3 = await this.getRealInviters(Q4);
|
|
15640
15640
|
if (Z3.length === 0)
|
|
15641
|
-
throw
|
|
15641
|
+
throw b4.noPathFound(Q4, this.config.invitationModuleAddress);
|
|
15642
15642
|
G2 = Z3[0].address;
|
|
15643
15643
|
}
|
|
15644
|
-
let Y2 = await this.pathfinder.findPath({ from: Q4, to: this.config.invitationModuleAddress, targetFlow:
|
|
15644
|
+
let Y2 = await this.pathfinder.findPath({ from: Q4, to: this.config.invitationModuleAddress, targetFlow: Q03, toTokens: [G2], useWrappedBalances: true });
|
|
15645
15645
|
if (!Y2.transfers || Y2.transfers.length === 0)
|
|
15646
|
-
throw
|
|
15647
|
-
if (Y2.maxFlow <
|
|
15648
|
-
let K3 = Number(Y2.maxFlow /
|
|
15649
|
-
throw
|
|
15646
|
+
throw b4.noPathFound(Q4, this.config.invitationModuleAddress);
|
|
15647
|
+
if (Y2.maxFlow < Q03) {
|
|
15648
|
+
let K3 = Number(Y2.maxFlow / Q03);
|
|
15649
|
+
throw b4.insufficientBalance(1, K3, Q03, Y2.maxFlow, Q4, this.config.invitationModuleAddress);
|
|
15650
15650
|
}
|
|
15651
15651
|
return Y2;
|
|
15652
15652
|
}
|
|
15653
15653
|
async getRealInviters($3) {
|
|
15654
|
-
let J2 = $3.toLowerCase(), Q4 = await this.trust.getTrustedBy(J2), G2 = await this.trust.getMutualTrusts(J2), Y2 = new Set([...Q4.map((
|
|
15654
|
+
let J2 = $3.toLowerCase(), Q4 = await this.trust.getTrustedBy(J2), G2 = await this.trust.getMutualTrusts(J2), Y2 = new Set([...Q4.map((B4) => B4.objectAvatar.toLowerCase()), ...G2.map((B4) => B4.objectAvatar.toLowerCase())]), [Z3, K3] = await Promise.all([this.trust.getTrusts(this.config.invitationModuleAddress), this.trust.getMutualTrusts(this.config.invitationModuleAddress)]), X4 = new Set([...Z3.map((B4) => B4.objectAvatar.toLowerCase()), ...K3.map((B4) => B4.objectAvatar.toLowerCase())]);
|
|
15655
15655
|
if (!X4.has(J2))
|
|
15656
|
-
throw new
|
|
15656
|
+
throw new b4("Inviter must enable the invitation module before creating invitations", { code: "INVITATION_MODULE_NOT_ENABLED", source: "INVITATIONS", context: { inviter: J2, invitationModule: this.config.invitationModuleAddress } });
|
|
15657
15657
|
let M2 = [];
|
|
15658
|
-
for (let
|
|
15659
|
-
if (X4.has(
|
|
15660
|
-
M2.push(
|
|
15658
|
+
for (let B4 of Y2)
|
|
15659
|
+
if (X4.has(B4))
|
|
15660
|
+
M2.push(B4);
|
|
15661
15661
|
let j4 = [...M2, J2];
|
|
15662
15662
|
if (j4.length === 0)
|
|
15663
15663
|
return [];
|
|
@@ -15665,47 +15665,47 @@ class SJ3 {
|
|
|
15665
15665
|
if (!N.transfers || N.transfers.length === 0)
|
|
15666
15666
|
return [];
|
|
15667
15667
|
let z2 = new Map, D3 = this.config.invitationModuleAddress.toLowerCase();
|
|
15668
|
-
for (let
|
|
15669
|
-
if (
|
|
15670
|
-
let S3 =
|
|
15671
|
-
z2.set(S3,
|
|
15668
|
+
for (let B4 of N.transfers)
|
|
15669
|
+
if (B4.to.toLowerCase() === D3) {
|
|
15670
|
+
let S3 = B4.tokenOwner.toLowerCase(), v3 = z2.get(S3) || BigInt(0);
|
|
15671
|
+
z2.set(S3, v3 + B4.value);
|
|
15672
15672
|
}
|
|
15673
15673
|
let H4 = [];
|
|
15674
|
-
for (let [
|
|
15675
|
-
let
|
|
15676
|
-
if (
|
|
15677
|
-
H4.push({ address:
|
|
15674
|
+
for (let [B4, S3] of z2.entries()) {
|
|
15675
|
+
let v3 = Number(S3 / Q03);
|
|
15676
|
+
if (v3 >= 1)
|
|
15677
|
+
H4.push({ address: B4, possibleInvites: v3 });
|
|
15678
15678
|
}
|
|
15679
15679
|
return this.orderRealInviters(H4, J2);
|
|
15680
15680
|
}
|
|
15681
15681
|
async generateReferral($3) {
|
|
15682
15682
|
let J2 = $3.toLowerCase(), Q4 = k$2(), G2 = w$2(Q4), Y2 = await this.getRealInviters(J2);
|
|
15683
15683
|
if (Y2.length === 0)
|
|
15684
|
-
throw
|
|
15685
|
-
let K3 = Y2[0].address, X4 = await this.findInvitePath(J2, K3), q3 = new W$(this.config), M2 = await this.generateInviteData([G2], true), j4 = await q3.buildFlowMatrixTx(J2, this.config.invitationModuleAddress, X4, { toTokens: [K3], useWrappedBalances: true, txData:
|
|
15684
|
+
throw b4.noProxyInviters(J2);
|
|
15685
|
+
let K3 = Y2[0].address, X4 = await this.findInvitePath(J2, K3), q3 = new W$(this.config), M2 = await this.generateInviteData([G2], true), j4 = await q3.buildFlowMatrixTx(J2, this.config.invitationModuleAddress, X4, { toTokens: [K3], useWrappedBalances: true, txData: P$2(M2) }, true);
|
|
15686
15686
|
await this.saveReferralData(J2, Q4);
|
|
15687
15687
|
let N = [];
|
|
15688
15688
|
return N.push(...j4), { transactions: N, privateKey: Q4 };
|
|
15689
15689
|
}
|
|
15690
15690
|
async generateInviteData($3, J2 = true) {
|
|
15691
15691
|
if ($3.length === 0)
|
|
15692
|
-
throw
|
|
15692
|
+
throw b4.noAddressesProvided();
|
|
15693
15693
|
if (!J2)
|
|
15694
15694
|
if ($3.length === 1)
|
|
15695
|
-
return
|
|
15695
|
+
return Z03(["address"], [$3[0]]);
|
|
15696
15696
|
else
|
|
15697
|
-
return
|
|
15697
|
+
return Z03(["address[]"], [$3]);
|
|
15698
15698
|
if ($3.length === 1) {
|
|
15699
15699
|
let G2 = this.referralsModule.createAccount($3[0]).data;
|
|
15700
|
-
return
|
|
15700
|
+
return Z03(["address", "bytes"], [this.config.referralsModuleAddress, G2]);
|
|
15701
15701
|
} else {
|
|
15702
15702
|
let G2 = this.referralsModule.createAccounts($3).data;
|
|
15703
|
-
return
|
|
15703
|
+
return Z03(["address", "bytes"], [this.config.referralsModuleAddress, G2]);
|
|
15704
15704
|
}
|
|
15705
15705
|
}
|
|
15706
15706
|
computeAddress($3) {
|
|
15707
15707
|
let Q4 = $3.toLowerCase().replace("0x", "").padStart(64, "0"), G2 = c$2.replace("0x", "") + Q4, Y2 = y$2("0x" + G2), Z3 = "ff", K3 = u$2.toLowerCase().replace("0x", ""), X4 = Y2.replace("0x", ""), q3 = l$.replace("0x", ""), M2 = "ff" + K3 + X4 + q3, N = "0x" + y$2("0x" + M2).slice(-40);
|
|
15708
|
-
return
|
|
15708
|
+
return P03(N);
|
|
15709
15709
|
}
|
|
15710
15710
|
generateSecrets($3) {
|
|
15711
15711
|
return Array.from({ length: $3 }, () => {
|
|
@@ -15722,7 +15722,7 @@ class IQ {
|
|
|
15722
15722
|
referralsModule;
|
|
15723
15723
|
hubV2;
|
|
15724
15724
|
constructor($3) {
|
|
15725
|
-
this.referralsModuleAddress = $3.referralsModuleAddress, this.invitations = new SJ3($3), this.invitationFarm = new _$2({ address: $3.invitationFarmAddress, rpcUrl: $3.circlesRpcUrl }), this.referralsModule = new p03({ address: $3.referralsModuleAddress, rpcUrl: $3.circlesRpcUrl }), this.hubV2 = new
|
|
15725
|
+
this.referralsModuleAddress = $3.referralsModuleAddress, this.invitations = new SJ3($3), this.invitationFarm = new _$2({ address: $3.invitationFarmAddress, rpcUrl: $3.circlesRpcUrl }), this.referralsModule = new p03({ address: $3.referralsModuleAddress, rpcUrl: $3.circlesRpcUrl }), this.hubV2 = new B0({ address: $3.v2HubAddress, rpcUrl: $3.circlesRpcUrl });
|
|
15726
15726
|
}
|
|
15727
15727
|
async getQuota($3) {
|
|
15728
15728
|
return this.invitationFarm.inviterQuota($3);
|
|
@@ -15733,14 +15733,23 @@ class IQ {
|
|
|
15733
15733
|
async getInvitationModule() {
|
|
15734
15734
|
return this.invitationFarm.invitationModule();
|
|
15735
15735
|
}
|
|
15736
|
-
async
|
|
15736
|
+
async generateReferrals($3, J2) {
|
|
15737
15737
|
if (J2 <= 0)
|
|
15738
|
-
throw new
|
|
15738
|
+
throw new b4("Count must be greater than 0", { code: "INVITATION_INVALID_COUNT", source: "VALIDATION", context: { count: J2 } });
|
|
15739
15739
|
let Q4 = $3.toLowerCase(), G2 = J2 === 1, Y2 = await this.simulateClaim(Q4, J2);
|
|
15740
15740
|
if (!Y2.length)
|
|
15741
|
-
throw new
|
|
15742
|
-
let Z3 = this.invitations.generateSecrets(J2), K3 = Z3.map((j4) => j4.signer), X4 = await this.invitationFarm.invitationModule(), q3 = G2 ? this.invitationFarm.claimInvite() : this.invitationFarm.claimInvites(BigInt(J2)), M2 = G2 ? this.
|
|
15743
|
-
return await Promise.all(Z3.map((j4) => this.invitations.saveReferralData(Q4, j4.secret))), {
|
|
15741
|
+
throw new b4("No invitation IDs returned from claim", { code: "INVITATION_NO_IDS", source: "INVITATIONS", context: { inviter: Q4, count: J2 } });
|
|
15742
|
+
let Z3 = this.invitations.generateSecrets(J2), K3 = Z3.map((j4) => j4.signer), X4 = await this.invitationFarm.invitationModule(), q3 = G2 ? this.invitationFarm.claimInvite() : this.invitationFarm.claimInvites(BigInt(J2)), M2 = G2 ? this.buildReferralTransfer(Q4, X4, Y2[0], K3[0]) : this.buildBatchReferralTransfer(Q4, X4, Y2, K3);
|
|
15743
|
+
return await Promise.all(Z3.map((j4) => this.invitations.saveReferralData(Q4, j4.secret))), { referrals: Z3, transactions: [q3, M2] };
|
|
15744
|
+
}
|
|
15745
|
+
async generateInvites($3, J2) {
|
|
15746
|
+
if (J2.length === 0)
|
|
15747
|
+
throw new b4("At least one invitee address must be provided", { code: "INVITATION_INVALID_COUNT", source: "VALIDATION", context: { count: 0 } });
|
|
15748
|
+
let Q4 = $3.toLowerCase(), G2 = J2.map((j4) => j4.toLowerCase()), Y2 = G2.length, Z3 = Y2 === 1, K3 = await this.simulateClaim(Q4, Y2);
|
|
15749
|
+
if (!K3.length)
|
|
15750
|
+
throw new b4("No invitation IDs returned from claim", { code: "INVITATION_NO_IDS", source: "INVITATIONS", context: { inviter: Q4, count: Y2 } });
|
|
15751
|
+
let X4 = await this.invitationFarm.invitationModule(), q3 = Z3 ? this.invitationFarm.claimInvite() : this.invitationFarm.claimInvites(BigInt(Y2)), M2 = Z3 ? this.buildInviteTransfer(Q4, X4, K3[0], G2[0]) : this.buildBatchInviteTransfer(Q4, X4, K3, G2);
|
|
15752
|
+
return { invitees: G2, transactions: [q3, M2] };
|
|
15744
15753
|
}
|
|
15745
15754
|
async listReferrals($3, J2 = 10, Q4 = 0) {
|
|
15746
15755
|
return this.invitations.listReferrals($3, J2, Q4);
|
|
@@ -15750,14 +15759,22 @@ class IQ {
|
|
|
15750
15759
|
return [await this.invitationFarm.read("claimInvite", [], { from: $3 })];
|
|
15751
15760
|
return this.invitationFarm.read("claimInvites", [BigInt(J2)], { from: $3 });
|
|
15752
15761
|
}
|
|
15753
|
-
|
|
15754
|
-
let Y2 = this.referralsModule.createAccount(G2).data, Z3 =
|
|
15755
|
-
return this.hubV2.safeTransferFrom($3, J2, Q4,
|
|
15762
|
+
buildReferralTransfer($3, J2, Q4, G2) {
|
|
15763
|
+
let Y2 = this.referralsModule.createAccount(G2).data, Z3 = Z03(["address", "bytes"], [this.referralsModuleAddress, Y2]);
|
|
15764
|
+
return this.hubV2.safeTransferFrom($3, J2, Q4, Q03, Z3);
|
|
15756
15765
|
}
|
|
15757
|
-
|
|
15758
|
-
let Y2 = this.referralsModule.createAccounts(G2).data, Z3 =
|
|
15766
|
+
buildBatchReferralTransfer($3, J2, Q4, G2) {
|
|
15767
|
+
let Y2 = this.referralsModule.createAccounts(G2).data, Z3 = Z03(["address", "bytes"], [this.referralsModuleAddress, Y2]), K3 = Q4.map(() => Q03);
|
|
15759
15768
|
return this.hubV2.safeBatchTransferFrom($3, J2, Q4, K3, Z3);
|
|
15760
15769
|
}
|
|
15770
|
+
buildInviteTransfer($3, J2, Q4, G2) {
|
|
15771
|
+
let Y2 = Z03(["address"], [G2]);
|
|
15772
|
+
return this.hubV2.safeTransferFrom($3, J2, Q4, Q03, Y2);
|
|
15773
|
+
}
|
|
15774
|
+
buildBatchInviteTransfer($3, J2, Q4, G2) {
|
|
15775
|
+
let Y2 = Z03(["address[]"], [G2]), Z3 = Q4.map(() => Q03);
|
|
15776
|
+
return this.hubV2.safeBatchTransferFrom($3, J2, Q4, Z3, Y2);
|
|
15777
|
+
}
|
|
15761
15778
|
}
|
|
15762
15779
|
|
|
15763
15780
|
// src/avatars/HumanAvatar.ts
|
|
@@ -15813,12 +15830,20 @@ class HumanAvatar extends CommonAvatar {
|
|
|
15813
15830
|
computeAddress: (signer) => {
|
|
15814
15831
|
return this._invitations.computeAddress(signer);
|
|
15815
15832
|
},
|
|
15816
|
-
|
|
15817
|
-
const result = await this._inviteFarm.
|
|
15833
|
+
generateReferrals: async (count) => {
|
|
15834
|
+
const result = await this._inviteFarm.generateReferrals(this.address, count);
|
|
15835
|
+
const receipt = await this.runner.sendTransaction(result.transactions);
|
|
15836
|
+
return {
|
|
15837
|
+
secrets: result.referrals.map((r4) => r4.secret),
|
|
15838
|
+
signers: result.referrals.map((r4) => r4.signer),
|
|
15839
|
+
transactionReceipt: receipt
|
|
15840
|
+
};
|
|
15841
|
+
},
|
|
15842
|
+
generateInvites: async (invitees) => {
|
|
15843
|
+
const result = await this._inviteFarm.generateInvites(this.address, invitees);
|
|
15818
15844
|
const receipt = await this.runner.sendTransaction(result.transactions);
|
|
15819
15845
|
return {
|
|
15820
|
-
|
|
15821
|
-
signers: result.invites.map((inv) => inv.signer),
|
|
15846
|
+
invitees: result.invitees,
|
|
15822
15847
|
transactionReceipt: receipt
|
|
15823
15848
|
};
|
|
15824
15849
|
},
|