@aboutcircles/sdk 0.1.14 → 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 +701 -676
- 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 {
|
|
@@ -12656,9 +12656,9 @@ class R03 {
|
|
|
12656
12656
|
if (Y2 !== undefined && this.pendingResponses[Y2])
|
|
12657
12657
|
this.pendingResponses[Y2].resolve(G2), delete this.pendingResponses[Y2];
|
|
12658
12658
|
if (Z3 === "eth_subscription" && K3) {
|
|
12659
|
-
let { subscription:
|
|
12660
|
-
if (this.subscriptionListeners[
|
|
12661
|
-
this.subscriptionListeners[
|
|
12659
|
+
let { subscription: X4, result: q3 } = K3;
|
|
12660
|
+
if (this.subscriptionListeners[X4])
|
|
12661
|
+
this.subscriptionListeners[X4].forEach((M2) => M2(q3));
|
|
12662
12662
|
}
|
|
12663
12663
|
}, this.websocket.onclose = () => {
|
|
12664
12664
|
console.warn("WebSocket closed"), this.websocketConnected = false;
|
|
@@ -12701,7 +12701,7 @@ class R03 {
|
|
|
12701
12701
|
if (!this.subscriptionListeners[Z3])
|
|
12702
12702
|
this.subscriptionListeners[Z3] = [];
|
|
12703
12703
|
return this.subscriptionListeners[Z3].push((K3) => {
|
|
12704
|
-
z$2(K3).forEach((
|
|
12704
|
+
z$2(K3).forEach((X4) => Q4.emit(X4));
|
|
12705
12705
|
}), Q4.property;
|
|
12706
12706
|
}
|
|
12707
12707
|
}
|
|
@@ -12715,8 +12715,8 @@ function A8($3, J2 = false) {
|
|
|
12715
12715
|
function EJ3($3, J2 = false) {
|
|
12716
12716
|
let Q4 = $3.length, G2 = new Uint32Array(Q4), Y2 = new Uint32Array(Q4);
|
|
12717
12717
|
for (let Z3 = 0;Z3 < Q4; Z3++) {
|
|
12718
|
-
let { h: K3, l:
|
|
12719
|
-
[G2[Z3], Y2[Z3]] = [K3,
|
|
12718
|
+
let { h: K3, l: X4 } = A8($3[Z3], J2);
|
|
12719
|
+
[G2[Z3], Y2[Z3]] = [K3, X4];
|
|
12720
12720
|
}
|
|
12721
12721
|
return [G2, Y2];
|
|
12722
12722
|
}
|
|
@@ -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,24 +12844,24 @@ 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
|
|
12848
|
-
for (let
|
|
12849
|
-
$3[K3 +
|
|
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
|
+
for (let D3 = 0;D3 < 50; D3 += 10)
|
|
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
|
|
12854
|
-
Y2 = $3[j4], Z3 = $3[j4 + 1], $3[j4] =
|
|
12853
|
+
let X4 = mJ2[K3], q3 = fJ2(Y2, Z3, X4), M2 = vJ3(Y2, Z3, X4), j4 = hJ[K3];
|
|
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) {
|
|
12857
|
-
for (let
|
|
12858
|
-
Q4[
|
|
12859
|
-
for (let
|
|
12860
|
-
$3[K3 +
|
|
12857
|
+
for (let X4 = 0;X4 < 10; X4++)
|
|
12858
|
+
Q4[X4] = $3[K3 + X4];
|
|
12859
|
+
for (let X4 = 0;X4 < 10; X4++)
|
|
12860
|
+
$3[K3 + X4] ^= ~Q4[(X4 + 2) % 10] & Q4[(X4 + 4) % 10];
|
|
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,43 +13004,43 @@ function C03($3, J2, Q4) {
|
|
|
13004
13004
|
function n82($3, J2, Q4) {
|
|
13005
13005
|
let G2 = $3.slice(0, $3.indexOf("[")), Y2 = $3.endsWith("[]"), Z3 = u03(G2, Q4), K3;
|
|
13006
13006
|
if (Z3) {
|
|
13007
|
-
let
|
|
13008
|
-
K3 =
|
|
13009
|
-
let N =
|
|
13010
|
-
return
|
|
13011
|
-
}).join("") +
|
|
13007
|
+
let X4 = J2.map((j4) => C03(G2, j4, Q4)), q3 = J2.length * L$2;
|
|
13008
|
+
K3 = X4.map((j4) => {
|
|
13009
|
+
let N = q3;
|
|
13010
|
+
return q3 += j4.length / 2, q02(N);
|
|
13011
|
+
}).join("") + X4.join("");
|
|
13012
13012
|
} else
|
|
13013
|
-
K3 = J2.map((
|
|
13014
|
-
return Y2 ?
|
|
13013
|
+
K3 = J2.map((X4) => C03(G2, X4, Q4)).join("");
|
|
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 = [];
|
|
13018
13018
|
for (let K3 = 0;K3 < $3.length; K3++) {
|
|
13019
|
-
let
|
|
13019
|
+
let X4 = $3[K3], q3 = Q4 ? J2[K3] : J2[X4.name || ""], M2 = u03(X4.type, X4.components);
|
|
13020
13020
|
if (Z3.push(M2), M2)
|
|
13021
|
-
G2.push(""), Y2.push(C03(
|
|
13021
|
+
G2.push(""), Y2.push(C03(X4.type, q3, X4.components));
|
|
13022
13022
|
else
|
|
13023
|
-
G2.push(C03(
|
|
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
|
-
|
|
13029
|
+
X4 += q02(K3), K3 += Y2[q3].length / 2, q3++;
|
|
13030
13030
|
else
|
|
13031
|
-
|
|
13032
|
-
return
|
|
13031
|
+
X4 += G2[M2];
|
|
13032
|
+
return X4 + Y2.join("");
|
|
13033
13033
|
}
|
|
13034
13034
|
return G2.join("");
|
|
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}`);
|
|
@@ -13072,21 +13072,21 @@ function e03($3, J2, Q4 = 0, G2) {
|
|
|
13072
13072
|
function a82($3, J2, Q4, G2) {
|
|
13073
13073
|
let Y2 = $3.slice(0, $3.indexOf("[")), Z3 = J2.slice(Q4, Q4 + u4);
|
|
13074
13074
|
if ($3.endsWith("[]")) {
|
|
13075
|
-
let
|
|
13076
|
-
for (let N = 0;N <
|
|
13077
|
-
let
|
|
13078
|
-
M2.push(
|
|
13075
|
+
let X4 = parseInt(Z3, 16) * 2, q3 = parseInt(J2.slice(X4, X4 + u4), 16), M2 = [], j4 = X4 + u4;
|
|
13076
|
+
for (let N = 0;N < q3; N++) {
|
|
13077
|
+
let z2 = e03(Y2, J2, j4, G2);
|
|
13078
|
+
M2.push(z2.value), j4 += z2.consumed;
|
|
13079
13079
|
}
|
|
13080
13080
|
return { value: M2, consumed: u4 };
|
|
13081
13081
|
}
|
|
13082
13082
|
let K3 = $3.match(/\[(\d+)\]$/);
|
|
13083
13083
|
if (K3) {
|
|
13084
|
-
let
|
|
13085
|
-
for (let j4 = 0;j4 <
|
|
13084
|
+
let X4 = parseInt(K3[1]), q3 = [], M2 = 0;
|
|
13085
|
+
for (let j4 = 0;j4 < X4; j4++) {
|
|
13086
13086
|
let N = e03(Y2, J2, Q4 + M2, G2);
|
|
13087
|
-
|
|
13087
|
+
q3.push(N.value), M2 += N.consumed;
|
|
13088
13088
|
}
|
|
13089
|
-
return { value:
|
|
13089
|
+
return { value: q3, consumed: M2 };
|
|
13090
13090
|
}
|
|
13091
13091
|
throw Error(`Invalid array type: ${$3}`);
|
|
13092
13092
|
}
|
|
@@ -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"))
|
|
@@ -13119,13 +13119,13 @@ function r82($3, J2, Q4) {
|
|
|
13119
13119
|
return { value: "0x" + J2.slice(Y2 + u4, Y2 + u4 + Z3), consumed: u4 };
|
|
13120
13120
|
}
|
|
13121
13121
|
if ($3 === "string") {
|
|
13122
|
-
let Y2 = parseInt(G2, 16) * 2, Z3 = parseInt(J2.slice(Y2, Y2 + u4), 16) * 2, K3 = J2.slice(Y2 + u4, Y2 + u4 + Z3),
|
|
13123
|
-
return { value: new TextDecoder().decode(
|
|
13122
|
+
let Y2 = parseInt(G2, 16) * 2, Z3 = parseInt(J2.slice(Y2, Y2 + u4), 16) * 2, K3 = J2.slice(Y2 + u4, Y2 + u4 + Z3), X4 = new Uint8Array(K3.match(/.{2}/g)?.map((q3) => parseInt(q3, 16)) || []);
|
|
13123
|
+
return { value: new TextDecoder().decode(X4), consumed: u4 };
|
|
13124
13124
|
}
|
|
13125
13125
|
throw Error(`Unsupported type: ${$3}`);
|
|
13126
13126
|
}
|
|
13127
13127
|
function H$2($3) {
|
|
13128
|
-
let { abi: J2, functionName: Q4, args: G2 = [] } = $3, Y2 = J2.find((
|
|
13128
|
+
let { abi: J2, functionName: Q4, args: G2 = [] } = $3, Y2 = J2.find((D3) => D3.type === "function" && D3.name === Q4);
|
|
13129
13129
|
if (!Y2)
|
|
13130
13130
|
throw Error(`Function "${Q4}" not found in ABI`);
|
|
13131
13131
|
let Z3 = i82(Y2), K3 = Y2.inputs || [];
|
|
@@ -13133,23 +13133,23 @@ function H$2($3) {
|
|
|
13133
13133
|
return Z3;
|
|
13134
13134
|
if (G2.length !== K3.length)
|
|
13135
13135
|
throw Error(`Expected ${K3.length} arguments, got ${G2.length}`);
|
|
13136
|
-
let
|
|
13137
|
-
for (let
|
|
13138
|
-
let
|
|
13139
|
-
if (M2.push(
|
|
13140
|
-
|
|
13136
|
+
let X4 = [], q3 = [], M2 = [];
|
|
13137
|
+
for (let D3 = 0;D3 < K3.length; D3++) {
|
|
13138
|
+
let H4 = K3[D3], V2 = H4.components, B4 = u03(H4.type, V2);
|
|
13139
|
+
if (M2.push(B4), B4)
|
|
13140
|
+
X4.push(""), q3.push(C03(H4.type, G2[D3], V2));
|
|
13141
13141
|
else
|
|
13142
|
-
|
|
13143
|
-
}
|
|
13144
|
-
if (
|
|
13145
|
-
return Z3 +
|
|
13146
|
-
let j4 =
|
|
13147
|
-
for (let
|
|
13148
|
-
if (M2[
|
|
13149
|
-
N +=
|
|
13142
|
+
X4.push(C03(H4.type, G2[D3], V2));
|
|
13143
|
+
}
|
|
13144
|
+
if (q3.length === 0)
|
|
13145
|
+
return Z3 + X4.join("");
|
|
13146
|
+
let j4 = X4.reduce((D3, H4, V2) => D3 + (M2[V2] ? L$2 : H4.length / 2), 0), N = "", z2 = 0;
|
|
13147
|
+
for (let D3 = 0;D3 < K3.length; D3++)
|
|
13148
|
+
if (M2[D3])
|
|
13149
|
+
N += q02(j4), j4 += q3[z2].length / 2, z2++;
|
|
13150
13150
|
else
|
|
13151
|
-
N +=
|
|
13152
|
-
return Z3 + N +
|
|
13151
|
+
N += X4[D3];
|
|
13152
|
+
return Z3 + N + q3.join("");
|
|
13153
13153
|
}
|
|
13154
13154
|
function m$2($3) {
|
|
13155
13155
|
let { abi: J2, functionName: Q4, data: G2 } = $3, Y2 = J2.find((M2) => M2.type === "function" && M2.name === Q4);
|
|
@@ -13158,42 +13158,42 @@ 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
|
-
let
|
|
13164
|
+
let X4 = [], q3 = 0;
|
|
13165
13165
|
for (let M2 of Z3) {
|
|
13166
|
-
let j4 = e03(M2.type, K3,
|
|
13167
|
-
|
|
13166
|
+
let j4 = e03(M2.type, K3, q3, M2.components);
|
|
13167
|
+
X4.push(j4.value), q3 += j4.consumed;
|
|
13168
13168
|
}
|
|
13169
|
-
return
|
|
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 = [];
|
|
13175
|
-
for (let
|
|
13176
|
-
let M2 = $3[
|
|
13175
|
+
for (let q3 = 0;q3 < $3.length; q3++) {
|
|
13176
|
+
let M2 = $3[q3], j4 = u03(M2);
|
|
13177
13177
|
if (Y2.push(j4), j4)
|
|
13178
|
-
Q4.push(""), G2.push(C03(M2, J2[
|
|
13178
|
+
Q4.push(""), G2.push(C03(M2, J2[q3]));
|
|
13179
13179
|
else
|
|
13180
|
-
Q4.push(C03(M2, J2[
|
|
13180
|
+
Q4.push(C03(M2, J2[q3]));
|
|
13181
13181
|
}
|
|
13182
13182
|
if (G2.length === 0)
|
|
13183
13183
|
return "0x" + Q4.join("");
|
|
13184
|
-
let Z3 = Q4.reduce((
|
|
13185
|
-
for (let
|
|
13186
|
-
if (Y2[
|
|
13187
|
-
K3 +=
|
|
13184
|
+
let Z3 = Q4.reduce((q3, M2, j4) => q3 + (Y2[j4] ? L$2 : M2.length / 2), 0), K3 = "", X4 = 0;
|
|
13185
|
+
for (let q3 = 0;q3 < $3.length; q3++)
|
|
13186
|
+
if (Y2[q3])
|
|
13187
|
+
K3 += q02(Z3), Z3 += G2[X4].length / 2, X4++;
|
|
13188
13188
|
else
|
|
13189
|
-
K3 += Q4[
|
|
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";
|
|
@@ -13323,9 +13323,9 @@ class $03 {
|
|
|
13323
13323
|
else {
|
|
13324
13324
|
let Z3 = [];
|
|
13325
13325
|
for (let K3 = 0;K3 < Q4; K3++) {
|
|
13326
|
-
let
|
|
13327
|
-
if (
|
|
13328
|
-
Z3.push(this.createEqualityPredicate(
|
|
13326
|
+
let X4 = this.cursorColumns[K3], q3 = $3[X4.name];
|
|
13327
|
+
if (q3 !== undefined)
|
|
13328
|
+
Z3.push(this.createEqualityPredicate(X4, q3));
|
|
13329
13329
|
}
|
|
13330
13330
|
Z3.push(this.createComparisonPredicate(G2, Y2)), J2.push({ Type: "Conjunction", ConjunctionType: "And", Predicates: Z3 });
|
|
13331
13331
|
}
|
|
@@ -13392,49 +13392,49 @@ 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
|
|
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]) =>
|
|
13415
|
-
let
|
|
13416
|
-
if (
|
|
13414
|
+
let Z3 = Object.entries(Y2).filter(([K3]) => P(K3) !== J2).map(([K3, X4]) => {
|
|
13415
|
+
let q3 = Math.max(...X4.map((j4) => j4.timestamp)), M2;
|
|
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.");
|
|
13424
|
-
return { subjectAvatar: J2, relation: M2, objectAvatar: K3, timestamp:
|
|
13424
|
+
return { subjectAvatar: J2, relation: M2, objectAvatar: K3, timestamp: q3 };
|
|
13425
13425
|
});
|
|
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
|
}
|
|
@@ -13543,8 +13543,8 @@ class d4 {
|
|
|
13543
13543
|
return this.v1ToDemurrage($3, Z3, K3, Y2, this.PERIOD_SEC);
|
|
13544
13544
|
}
|
|
13545
13545
|
static attoCirclesToAttoCrc($3, J2) {
|
|
13546
|
-
let Q4 = J2 - this.INFLATION_DAY_ZERO_UNIX, G2 = Q4 / this.PERIOD_SEC, Y2 = Q4 % this.PERIOD_SEC, Z3 = this.v1InflateFactor(G2), K3 = this.v1InflateFactor(G2 + 1n),
|
|
13547
|
-
return $3 * 3n * this.V1_ACCURACY * this.PERIOD_SEC /
|
|
13546
|
+
let Q4 = J2 - this.INFLATION_DAY_ZERO_UNIX, G2 = Q4 / this.PERIOD_SEC, Y2 = Q4 % this.PERIOD_SEC, Z3 = this.v1InflateFactor(G2), K3 = this.v1InflateFactor(G2 + 1n), X4 = Z3 * (this.PERIOD_SEC - Y2) + K3 * Y2;
|
|
13547
|
+
return $3 * 3n * this.V1_ACCURACY * this.PERIOD_SEC / X4;
|
|
13548
13548
|
}
|
|
13549
13549
|
static v1ToDemurrage($3, J2, Q4, G2, Y2) {
|
|
13550
13550
|
let Z3 = J2 * (Y2 - G2) + Q4 * G2;
|
|
@@ -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]);
|
|
@@ -13614,9 +13614,9 @@ class G$ {
|
|
|
13614
13614
|
try {
|
|
13615
13615
|
let K3 = await this.getProfileByAddress($3);
|
|
13616
13616
|
if (K3) {
|
|
13617
|
-
let
|
|
13618
|
-
if (!G2 || !
|
|
13619
|
-
Y2.push(
|
|
13617
|
+
let X4 = { ...K3, address: $3 };
|
|
13618
|
+
if (!G2 || !X4.avatarType || G2.includes(X4.avatarType))
|
|
13619
|
+
Y2.push(X4);
|
|
13620
13620
|
}
|
|
13621
13621
|
} catch (K3) {
|
|
13622
13622
|
console.warn("Failed to get profile by address:", K3);
|
|
@@ -13624,8 +13624,8 @@ class G$ {
|
|
|
13624
13624
|
try {
|
|
13625
13625
|
let K3 = await this.searchProfiles($3, J2, Q4, G2);
|
|
13626
13626
|
if (Z3 && Y2.length > 0) {
|
|
13627
|
-
let
|
|
13628
|
-
Y2.push(...
|
|
13627
|
+
let X4 = $3.toLowerCase(), q3 = K3.filter((M2) => M2.address?.toLowerCase() !== X4);
|
|
13628
|
+
Y2.push(...q3);
|
|
13629
13629
|
} else
|
|
13630
13630
|
Y2.push(...K3);
|
|
13631
13631
|
} catch (K3) {
|
|
@@ -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,30 +13671,30 @@ 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
|
-
let Z3 = await this.client.call("circles_query", [{ Namespace: "V_Crc", Table: "TrustRelations", Columns: ["truster", "trustee"], Filter: [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "trustee", Value: J2 }] }], Order: [] }]),
|
|
13684
|
-
if (
|
|
13683
|
+
let Z3 = await this.client.call("circles_query", [{ Namespace: "V_Crc", Table: "TrustRelations", Columns: ["truster", "trustee"], Filter: [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "trustee", Value: J2 }] }], Order: [] }]), X4 = this.transformQueryResponse(Z3).map((j4) => j4.truster);
|
|
13684
|
+
if (X4.length === 0)
|
|
13685
13685
|
return [];
|
|
13686
|
-
let
|
|
13687
|
-
for (let j4 of
|
|
13686
|
+
let q3 = await this.client.call("circles_getAvatarInfoBatch", [X4]), M2 = [];
|
|
13687
|
+
for (let j4 of q3) {
|
|
13688
13688
|
if (!j4?.isHuman)
|
|
13689
13689
|
continue;
|
|
13690
|
-
let
|
|
13691
|
-
if (
|
|
13690
|
+
let z2 = (await this.client.call("circles_getTokenBalances", [j4.avatar])).find((D3) => P(D3.tokenAddress) === P(j4.avatar));
|
|
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,14 +13702,14 @@ class Z$ {
|
|
|
13702
13702
|
let G2 = await this.client.call("circles_query", [{ Namespace: "V_Crc", Table: "TrustRelations", Columns: ["trustee", "truster"], Filter: [{ Type: "Conjunction", ConjunctionType: "And", Predicates: [{ Type: "FilterPredicate", FilterType: "Equals", Column: "version", Value: 2 }, { Type: "FilterPredicate", FilterType: "Equals", Column: "truster", Value: Q4 }] }], Order: [] }]), Z3 = this.transformQueryResponse(G2).map((M2) => M2.trustee);
|
|
13703
13703
|
if (Z3.length === 0)
|
|
13704
13704
|
return [];
|
|
13705
|
-
let K3 = await this.client.call("circles_getAvatarInfoBatch", [Z3]),
|
|
13706
|
-
return f2(
|
|
13705
|
+
let K3 = await this.client.call("circles_getAvatarInfoBatch", [Z3]), X4 = new Set(K3.filter((M2) => M2 !== null).map((M2) => P(M2.avatar))), q3 = Z3.filter((M2) => !X4.has(P(M2)));
|
|
13706
|
+
return f2(q3);
|
|
13707
13707
|
}
|
|
13708
13708
|
}
|
|
13709
13709
|
}
|
|
13710
13710
|
function QQ($3, J2) {
|
|
13711
|
-
let Q4 = BigInt($3), G2 = d4.attoCirclesToCircles(Q4), Y2 = d4.attoCirclesToAttoCrc(Q4, BigInt(J2)), Z3 = d4.attoCirclesToCircles(Y2), K3 = d4.attoCirclesToAttoStaticCircles(Q4, BigInt(J2)),
|
|
13712
|
-
return { attoCircles: Q4, circles: G2, staticAttoCircles: K3, staticCircles:
|
|
13711
|
+
let Q4 = BigInt($3), G2 = d4.attoCirclesToCircles(Q4), Y2 = d4.attoCirclesToAttoCrc(Q4, BigInt(J2)), Z3 = d4.attoCirclesToCircles(Y2), K3 = d4.attoCirclesToAttoStaticCircles(Q4, BigInt(J2)), X4 = d4.attoCirclesToCircles(K3);
|
|
13712
|
+
return { attoCircles: Q4, circles: G2, staticAttoCircles: K3, staticCircles: X4, attoCrc: Y2, crc: Z3 };
|
|
13713
13713
|
}
|
|
13714
13714
|
|
|
13715
13715
|
class K$2 {
|
|
@@ -13718,10 +13718,10 @@ 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
|
-
let K3 = QQ(Z3.value, Z3.timestamp),
|
|
13724
|
-
return f2(
|
|
13723
|
+
let K3 = QQ(Z3.value, Z3.timestamp), X4 = { ...Z3, ...K3 };
|
|
13724
|
+
return f2(X4);
|
|
13725
13725
|
});
|
|
13726
13726
|
}
|
|
13727
13727
|
}
|
|
@@ -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
|
}
|
|
@@ -14015,8 +14015,8 @@ Context: ${JSON.stringify(this.context, null, 2)}`;
|
|
|
14015
14015
|
function GQ2($3, J2, Q4, G2) {
|
|
14016
14016
|
if (typeof $3.setBigUint64 === "function")
|
|
14017
14017
|
return $3.setBigUint64(J2, Q4, G2);
|
|
14018
|
-
let Y2 = BigInt(32), Z3 = BigInt(4294967295), K3 = Number(Q4 >> Y2 & Z3),
|
|
14019
|
-
$3.setUint32(J2 +
|
|
14018
|
+
let Y2 = BigInt(32), Z3 = BigInt(4294967295), K3 = Number(Q4 >> Y2 & Z3), X4 = Number(Q4 & Z3), q3 = G2 ? 4 : 0, M2 = G2 ? 0 : 4;
|
|
14019
|
+
$3.setUint32(J2 + q3, K3, G2), $3.setUint32(J2 + M2, X4, G2);
|
|
14020
14020
|
}
|
|
14021
14021
|
function oJ2($3, J2, Q4) {
|
|
14022
14022
|
return $3 & J2 ^ ~$3 & Q4;
|
|
@@ -14031,14 +14031,14 @@ 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);
|
|
14038
14038
|
if (K3 === G2) {
|
|
14039
|
-
let
|
|
14039
|
+
let X4 = O$2($3);
|
|
14040
14040
|
for (;G2 <= Y2 - Z3; Z3 += G2)
|
|
14041
|
-
this.process(
|
|
14041
|
+
this.process(X4, Z3);
|
|
14042
14042
|
continue;
|
|
14043
14043
|
}
|
|
14044
14044
|
if (Q4.set($3.subarray(Z3, Z3 + K3), this.pos), this.pos += K3, Z3 += K3, this.pos === G2)
|
|
@@ -14047,20 +14047,20 @@ 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;
|
|
14056
14056
|
GQ2(Q4, G2 - 8, BigInt(this.length * 8), Y2), this.process(Q4, 0);
|
|
14057
|
-
let K3 = O$2($3),
|
|
14058
|
-
if (
|
|
14057
|
+
let K3 = O$2($3), X4 = this.outputLen;
|
|
14058
|
+
if (X4 % 4)
|
|
14059
14059
|
throw Error("_sha2: outputLen should be aligned to 32bit");
|
|
14060
|
-
let
|
|
14061
|
-
if (
|
|
14060
|
+
let q3 = X4 / 4, M2 = this.get();
|
|
14061
|
+
if (q3 > M2.length)
|
|
14062
14062
|
throw Error("_sha2: outputLen bigger than state");
|
|
14063
|
-
for (let j4 = 0;j4 <
|
|
14063
|
+
for (let j4 = 0;j4 < q3; j4++)
|
|
14064
14064
|
K3.setUint32(4 * j4, M2[j4], Y2);
|
|
14065
14065
|
}
|
|
14066
14066
|
digest() {
|
|
@@ -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) {
|
|
@@ -14090,31 +14090,31 @@ class aJ extends n$2 {
|
|
|
14090
14090
|
this.A = W03[0] | 0, this.B = W03[1] | 0, this.C = W03[2] | 0, this.D = W03[3] | 0, this.E = W03[4] | 0, this.F = W03[5] | 0, this.G = W03[6] | 0, this.H = W03[7] | 0;
|
|
14091
14091
|
}
|
|
14092
14092
|
get() {
|
|
14093
|
-
let { A: $3, B: J2, C: Q4, D: G2, E: Y2, F: Z3, G: K3, H:
|
|
14094
|
-
return [$3, J2, Q4, G2, Y2, Z3, K3,
|
|
14093
|
+
let { A: $3, B: J2, C: Q4, D: G2, E: Y2, F: Z3, G: K3, H: X4 } = this;
|
|
14094
|
+
return [$3, J2, Q4, G2, Y2, Z3, K3, X4];
|
|
14095
14095
|
}
|
|
14096
|
-
set($3, J2, Q4, G2, Y2, Z3, K3,
|
|
14097
|
-
this.A = $3 | 0, this.B = J2 | 0, this.C = Q4 | 0, this.D = G2 | 0, this.E = Y2 | 0, this.F = Z3 | 0, this.G = K3 | 0, this.H =
|
|
14096
|
+
set($3, J2, Q4, G2, Y2, Z3, K3, X4) {
|
|
14097
|
+
this.A = $3 | 0, this.B = J2 | 0, this.C = Q4 | 0, this.D = G2 | 0, this.E = Y2 | 0, this.F = Z3 | 0, this.G = K3 | 0, this.H = X4 | 0;
|
|
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
|
-
let { A: Q4, B: G2, C: Y2, D: Z3, E: K3, F:
|
|
14106
|
+
let { A: Q4, B: G2, C: Y2, D: Z3, E: K3, F: X4, G: q3, H: M2 } = this;
|
|
14107
14107
|
for (let j4 = 0;j4 < 64; j4++) {
|
|
14108
|
-
let N =
|
|
14109
|
-
M2 =
|
|
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
|
+
M2 = q3, q3 = X4, X4 = K3, K3 = Z3 + z2 | 0, Z3 = Y2, Y2 = G2, G2 = Q4, Q4 = z2 + H4 | 0;
|
|
14110
14110
|
}
|
|
14111
|
-
Q4 = Q4 + this.A | 0, G2 = G2 + this.B | 0, Y2 = Y2 + this.C | 0, Z3 = Z3 + this.D | 0, K3 = K3 + this.E | 0,
|
|
14111
|
+
Q4 = Q4 + this.A | 0, G2 = G2 + this.B | 0, Y2 = Y2 + this.C | 0, Z3 = Z3 + this.D | 0, K3 = K3 + this.E | 0, 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);
|
|
@@ -14213,12 +14213,12 @@ function q$($3) {
|
|
|
14213
14213
|
throw Error("hex string expected, got unpadded hex of length " + J2);
|
|
14214
14214
|
let G2 = new Uint8Array(Q4);
|
|
14215
14215
|
for (let Y2 = 0, Z3 = 0;Y2 < Q4; Y2++, Z3 += 2) {
|
|
14216
|
-
let K3 = rJ2($3.charCodeAt(Z3)),
|
|
14217
|
-
if (K3 === undefined ||
|
|
14218
|
-
let
|
|
14219
|
-
throw Error('hex string expected, got non-hex character "' +
|
|
14216
|
+
let K3 = rJ2($3.charCodeAt(Z3)), X4 = rJ2($3.charCodeAt(Z3 + 1));
|
|
14217
|
+
if (K3 === undefined || X4 === undefined) {
|
|
14218
|
+
let q3 = $3[Z3] + $3[Z3 + 1];
|
|
14219
|
+
throw Error('hex string expected, got non-hex character "' + q3 + '" at index ' + Z3);
|
|
14220
14220
|
}
|
|
14221
|
-
G2[Y2] = K3 * 16 +
|
|
14221
|
+
G2[Y2] = K3 * 16 + X4;
|
|
14222
14222
|
}
|
|
14223
14223
|
return G2;
|
|
14224
14224
|
}
|
|
@@ -14290,40 +14290,40 @@ function G82($3, J2, Q4) {
|
|
|
14290
14290
|
throw Error("hmacFn must be a function");
|
|
14291
14291
|
let G2 = s$2($3), Y2 = s$2($3), Z3 = 0, K3 = () => {
|
|
14292
14292
|
G2.fill(1), Y2.fill(0), Z3 = 0;
|
|
14293
|
-
},
|
|
14294
|
-
if (Y2 =
|
|
14293
|
+
}, X4 = (...N) => Q4(Y2, G2, ...N), q3 = (N = s$2(0)) => {
|
|
14294
|
+
if (Y2 = X4(eJ2([0]), N), G2 = X4(), N.length === 0)
|
|
14295
14295
|
return;
|
|
14296
|
-
Y2 =
|
|
14296
|
+
Y2 = X4(eJ2([1]), N), G2 = X4();
|
|
14297
14297
|
}, M2 = () => {
|
|
14298
14298
|
if (Z3++ >= 1000)
|
|
14299
14299
|
throw Error("drbg: tried 1000 values");
|
|
14300
|
-
let N = 0,
|
|
14300
|
+
let N = 0, z2 = [];
|
|
14301
14301
|
while (N < J2) {
|
|
14302
|
-
G2 =
|
|
14303
|
-
let
|
|
14304
|
-
|
|
14302
|
+
G2 = X4();
|
|
14303
|
+
let D3 = G2.slice();
|
|
14304
|
+
z2.push(D3), N += G2.length;
|
|
14305
14305
|
}
|
|
14306
|
-
return M$(...
|
|
14306
|
+
return M$(...z2);
|
|
14307
14307
|
};
|
|
14308
|
-
return (N,
|
|
14309
|
-
K3(),
|
|
14310
|
-
let
|
|
14311
|
-
while (!(
|
|
14312
|
-
|
|
14313
|
-
return K3(),
|
|
14308
|
+
return (N, z2) => {
|
|
14309
|
+
K3(), q3(N);
|
|
14310
|
+
let D3 = undefined;
|
|
14311
|
+
while (!(D3 = z2(M2())))
|
|
14312
|
+
q3();
|
|
14313
|
+
return K3(), D3;
|
|
14314
14314
|
};
|
|
14315
14315
|
}
|
|
14316
14316
|
var KQ2 = { bigint: ($3) => typeof $3 === "bigint", function: ($3) => typeof $3 === "function", boolean: ($3) => typeof $3 === "boolean", string: ($3) => typeof $3 === "string", stringOrUint8Array: ($3) => typeof $3 === "string" || d03($3), isSafeInteger: ($3) => Number.isSafeInteger($3), array: ($3) => Array.isArray($3), field: ($3, J2) => J2.Fp.isValid($3), hash: ($3) => typeof $3 === "function" && Number.isSafeInteger($3.outputLen) };
|
|
14317
14317
|
function b03($3, J2, Q4 = {}) {
|
|
14318
14318
|
let G2 = (Y2, Z3, K3) => {
|
|
14319
|
-
let
|
|
14320
|
-
if (typeof
|
|
14319
|
+
let X4 = KQ2[Z3];
|
|
14320
|
+
if (typeof X4 !== "function")
|
|
14321
14321
|
throw Error("invalid validator function");
|
|
14322
|
-
let
|
|
14323
|
-
if (K3 &&
|
|
14322
|
+
let q3 = $3[Y2];
|
|
14323
|
+
if (K3 && q3 === undefined)
|
|
14324
14324
|
return;
|
|
14325
|
-
if (!q3
|
|
14326
|
-
throw Error("param " + String(Y2) + " is invalid. Expected " + Z3 + ", got " +
|
|
14325
|
+
if (!X4(q3, $3))
|
|
14326
|
+
throw Error("param " + String(Y2) + " is invalid. Expected " + Z3 + ", got " + q3);
|
|
14327
14327
|
};
|
|
14328
14328
|
for (let [Y2, Z3] of Object.entries(J2))
|
|
14329
14329
|
G2(Y2, Z3, false);
|
|
@@ -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);
|
|
@@ -14364,10 +14364,10 @@ function A$2($3, J2) {
|
|
|
14364
14364
|
throw Error("invert: expected non-zero number");
|
|
14365
14365
|
if (J2 <= a4)
|
|
14366
14366
|
throw Error("invert: expected positive modulus, got " + J2);
|
|
14367
|
-
let Q4 = i4($3, J2), G2 = J2, Y2 = a4, Z3 = n4, K3 = n4,
|
|
14367
|
+
let Q4 = i4($3, J2), G2 = J2, Y2 = a4, Z3 = n4, K3 = n4, X4 = a4;
|
|
14368
14368
|
while (Q4 !== a4) {
|
|
14369
|
-
let M2 = G2 / Q4, j4 = G2 % Q4, N = Y2 - K3 * M2,
|
|
14370
|
-
G2 = Q4, Q4 = j4, Y2 = K3, Z3 =
|
|
14369
|
+
let M2 = G2 / Q4, j4 = G2 % Q4, N = Y2 - K3 * M2, z2 = Z3 - X4 * M2;
|
|
14370
|
+
G2 = Q4, Q4 = j4, Y2 = K3, Z3 = X4, K3 = N, X4 = z2;
|
|
14371
14371
|
}
|
|
14372
14372
|
if (G2 !== n4)
|
|
14373
14373
|
throw Error("invert: does not exist");
|
|
@@ -14380,41 +14380,41 @@ 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,
|
|
14384
|
-
if (!$3.eql($3.sqr(
|
|
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
|
+
if (!$3.eql($3.sqr(X4), J2))
|
|
14385
14385
|
throw Error("Cannot find square root");
|
|
14386
|
-
return
|
|
14386
|
+
return X4;
|
|
14387
14387
|
}
|
|
14388
14388
|
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) /
|
|
14401
|
-
return function(
|
|
14402
|
-
if (
|
|
14400
|
+
let Z3 = Y2.pow(G2, J2), K3 = (J2 + n4) / g03;
|
|
14401
|
+
return function(q3, M2) {
|
|
14402
|
+
if (q3.is0(M2))
|
|
14403
14403
|
return M2;
|
|
14404
|
-
if (Y8(
|
|
14404
|
+
if (Y8(q3, M2) !== 1)
|
|
14405
14405
|
throw Error("Cannot find square root");
|
|
14406
|
-
let j4 = Q4, N =
|
|
14407
|
-
while (!
|
|
14408
|
-
if (
|
|
14409
|
-
return
|
|
14410
|
-
let
|
|
14411
|
-
while (!
|
|
14412
|
-
if (
|
|
14406
|
+
let j4 = Q4, N = q3.mul(q3.ONE, Z3), z2 = q3.pow(M2, J2), D3 = q3.pow(M2, K3);
|
|
14407
|
+
while (!q3.eql(z2, q3.ONE)) {
|
|
14408
|
+
if (q3.is0(z2))
|
|
14409
|
+
return q3.ZERO;
|
|
14410
|
+
let H4 = 1, V2 = q3.sqr(z2);
|
|
14411
|
+
while (!q3.eql(V2, q3.ONE))
|
|
14412
|
+
if (H4++, V2 = q3.sqr(V2), H4 === j4)
|
|
14413
14413
|
throw Error("Cannot find square root");
|
|
14414
|
-
let
|
|
14415
|
-
j4 =
|
|
14414
|
+
let B4 = n4 << BigInt(j4 - H4 - 1), S3 = q3.pow(N, B4);
|
|
14415
|
+
j4 = H4, N = q3.sqr(S3), z2 = q3.mul(z2, N), D3 = q3.mul(D3, S3);
|
|
14416
14416
|
}
|
|
14417
|
-
return
|
|
14417
|
+
return D3;
|
|
14418
14418
|
};
|
|
14419
14419
|
}
|
|
14420
14420
|
function jQ($3) {
|
|
@@ -14447,19 +14447,19 @@ function WQ2($3, J2, Q4) {
|
|
|
14447
14447
|
return G2;
|
|
14448
14448
|
}
|
|
14449
14449
|
function ZJ3($3, J2, Q4 = false) {
|
|
14450
|
-
let G2 = Array(J2.length).fill(Q4 ? $3.ZERO : undefined), Y2 = J2.reduce((K3,
|
|
14451
|
-
if ($3.is0(
|
|
14450
|
+
let G2 = Array(J2.length).fill(Q4 ? $3.ZERO : undefined), Y2 = J2.reduce((K3, X4, q3) => {
|
|
14451
|
+
if ($3.is0(X4))
|
|
14452
14452
|
return K3;
|
|
14453
|
-
return G2[
|
|
14453
|
+
return G2[q3] = K3, $3.mul(K3, X4);
|
|
14454
14454
|
}, $3.ONE), Z3 = $3.inv(Y2);
|
|
14455
|
-
return J2.reduceRight((K3,
|
|
14456
|
-
if ($3.is0(
|
|
14455
|
+
return J2.reduceRight((K3, X4, q3) => {
|
|
14456
|
+
if ($3.is0(X4))
|
|
14457
14457
|
return K3;
|
|
14458
|
-
return G2[
|
|
14458
|
+
return G2[q3] = $3.mul(K3, G2[q3]), $3.mul(K3, X4);
|
|
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;
|
|
@@ -14476,20 +14476,20 @@ function j$2($3, J2, Q4 = false, G2 = {}) {
|
|
|
14476
14476
|
let { nBitLength: Y2, nByteLength: Z3 } = KJ3($3, J2);
|
|
14477
14477
|
if (Z3 > 2048)
|
|
14478
14478
|
throw Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
14479
|
-
let K3,
|
|
14480
|
-
if (typeof
|
|
14481
|
-
throw Error("invalid field element: expected bigint, got " + typeof
|
|
14482
|
-
return a4 <=
|
|
14483
|
-
}, is0: (
|
|
14479
|
+
let K3, X4 = Object.freeze({ ORDER: $3, isLE: Q4, BITS: Y2, BYTES: Z3, MASK: F03(Y2), ZERO: a4, ONE: n4, create: (q3) => i4(q3, $3), isValid: (q3) => {
|
|
14480
|
+
if (typeof q3 !== "bigint")
|
|
14481
|
+
throw Error("invalid field element: expected bigint, got " + typeof q3);
|
|
14482
|
+
return a4 <= q3 && q3 < $3;
|
|
14483
|
+
}, is0: (q3) => q3 === a4, isOdd: (q3) => (q3 & n4) === n4, neg: (q3) => i4(-q3, $3), eql: (q3, M2) => q3 === M2, sqr: (q3) => i4(q3 * q3, $3), add: (q3, M2) => i4(q3 + M2, $3), sub: (q3, M2) => i4(q3 - M2, $3), mul: (q3, M2) => i4(q3 * M2, $3), pow: (q3, M2) => WQ2(X4, q3, M2), div: (q3, M2) => i4(q3 * A$2(M2, $3), $3), sqrN: (q3) => q3 * q3, addN: (q3, M2) => q3 + M2, subN: (q3, M2) => q3 - M2, mulN: (q3, M2) => q3 * M2, inv: (q3) => A$2(q3, $3), sqrt: G2.sqrt || ((q3) => {
|
|
14484
14484
|
if (!K3)
|
|
14485
14485
|
K3 = jQ($3);
|
|
14486
|
-
return K3(
|
|
14487
|
-
}), toBytes: (
|
|
14488
|
-
if (
|
|
14489
|
-
throw Error("Field.fromBytes: expected " + Z3 + " bytes, got " +
|
|
14490
|
-
return Q4 ? JJ2(
|
|
14491
|
-
}, invertBatch: (
|
|
14492
|
-
return Object.freeze(
|
|
14486
|
+
return K3(X4, q3);
|
|
14487
|
+
}), toBytes: (q3) => Q4 ? QJ3(q3, Z3) : w03(q3, Z3), fromBytes: (q3) => {
|
|
14488
|
+
if (q3.length !== Z3)
|
|
14489
|
+
throw Error("Field.fromBytes: expected " + Z3 + " bytes, got " + q3.length);
|
|
14490
|
+
return Q4 ? JJ2(q3) : z02(q3);
|
|
14491
|
+
}, invertBatch: (q3) => ZJ3(X4, q3), cmov: (q3, M2, j4) => j4 ? M2 : q3 });
|
|
14492
|
+
return Object.freeze(X4);
|
|
14493
14493
|
}
|
|
14494
14494
|
function M82($3) {
|
|
14495
14495
|
if (typeof $3 !== "bigint")
|
|
@@ -14505,8 +14505,8 @@ function j82($3, J2, Q4 = false) {
|
|
|
14505
14505
|
let G2 = $3.length, Y2 = M82(J2), Z3 = XJ3(J2);
|
|
14506
14506
|
if (G2 < 16 || G2 < Z3 || G2 > 1024)
|
|
14507
14507
|
throw Error("expected " + Z3 + "-1024 bytes of input, got " + G2);
|
|
14508
|
-
let K3 = Q4 ? JJ2($3) : z02($3),
|
|
14509
|
-
return Q4 ? QJ3(
|
|
14508
|
+
let K3 = Q4 ? JJ2($3) : z02($3), X4 = i4(K3, J2 - n4) + n4;
|
|
14509
|
+
return Q4 ? QJ3(X4, Y2) : w03(X4, Y2);
|
|
14510
14510
|
}
|
|
14511
14511
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14512
14512
|
var U82 = BigInt(0);
|
|
@@ -14525,11 +14525,11 @@ function MJ2($3, J2) {
|
|
|
14525
14525
|
return { windows: Q4, windowSize: G2, mask: Z3, maxNumber: Y2, shiftBy: K3 };
|
|
14526
14526
|
}
|
|
14527
14527
|
function W82($3, J2, Q4) {
|
|
14528
|
-
let { windowSize: G2, mask: Y2, maxNumber: Z3, shiftBy: K3 } = Q4,
|
|
14529
|
-
if (
|
|
14530
|
-
|
|
14531
|
-
let M2 = J2 * G2, j4 = M2 + Math.abs(
|
|
14532
|
-
return { nextN:
|
|
14528
|
+
let { windowSize: G2, mask: Y2, maxNumber: Z3, shiftBy: K3 } = Q4, X4 = Number($3 & Y2), q3 = $3 >> K3;
|
|
14529
|
+
if (X4 > G2)
|
|
14530
|
+
X4 -= Z3, q3 += WJ2;
|
|
14531
|
+
let M2 = J2 * G2, j4 = M2 + Math.abs(X4) - 1, N = X4 === 0, z2 = X4 < 0, D3 = J2 % 2 !== 0;
|
|
14532
|
+
return { nextN: q3, offset: j4, isZero: N, isNeg: z2, isNegF: D3, offsetF: M2 };
|
|
14533
14533
|
}
|
|
14534
14534
|
function NQ2($3, J2) {
|
|
14535
14535
|
if (!Array.isArray($3))
|
|
@@ -14564,35 +14564,35 @@ function D82($3, J2) {
|
|
|
14564
14564
|
}
|
|
14565
14565
|
return Y2;
|
|
14566
14566
|
}, precomputeWindow(Q4, G2) {
|
|
14567
|
-
let { windows: Y2, windowSize: Z3 } = MJ2(G2, J2), K3 = [],
|
|
14567
|
+
let { windows: Y2, windowSize: Z3 } = MJ2(G2, J2), K3 = [], X4 = Q4, q3 = X4;
|
|
14568
14568
|
for (let M2 = 0;M2 < Y2; M2++) {
|
|
14569
|
-
|
|
14569
|
+
q3 = X4, K3.push(q3);
|
|
14570
14570
|
for (let j4 = 1;j4 < Z3; j4++)
|
|
14571
|
-
|
|
14572
|
-
|
|
14571
|
+
q3 = q3.add(X4), K3.push(q3);
|
|
14572
|
+
X4 = q3.double();
|
|
14573
14573
|
}
|
|
14574
14574
|
return K3;
|
|
14575
14575
|
}, wNAF(Q4, G2, Y2) {
|
|
14576
|
-
let { ZERO: Z3, BASE: K3 } = $3,
|
|
14577
|
-
for (let
|
|
14578
|
-
let { nextN: M2, offset: j4, isZero: N, isNeg:
|
|
14576
|
+
let { ZERO: Z3, BASE: K3 } = $3, X4 = MJ2(Q4, J2);
|
|
14577
|
+
for (let q3 = 0;q3 < X4.windows; q3++) {
|
|
14578
|
+
let { nextN: M2, offset: j4, isZero: N, isNeg: z2, isNegF: D3, offsetF: H4 } = W82(Y2, q3, X4);
|
|
14579
14579
|
if (Y2 = M2, N)
|
|
14580
|
-
K3 = K3.add(qJ3(
|
|
14580
|
+
K3 = K3.add(qJ3(D3, G2[H4]));
|
|
14581
14581
|
else
|
|
14582
|
-
Z3 = Z3.add(qJ3(
|
|
14582
|
+
Z3 = Z3.add(qJ3(z2, G2[j4]));
|
|
14583
14583
|
}
|
|
14584
14584
|
return { p: Z3, f: K3 };
|
|
14585
14585
|
}, wNAFUnsafe(Q4, G2, Y2, Z3 = $3.ZERO) {
|
|
14586
14586
|
let K3 = MJ2(Q4, J2);
|
|
14587
|
-
for (let
|
|
14587
|
+
for (let X4 = 0;X4 < K3.windows; X4++) {
|
|
14588
14588
|
if (Y2 === U82)
|
|
14589
14589
|
break;
|
|
14590
|
-
let { nextN:
|
|
14591
|
-
if (Y2 =
|
|
14590
|
+
let { nextN: q3, offset: M2, isZero: j4, isNeg: N } = W82(Y2, X4, K3);
|
|
14591
|
+
if (Y2 = q3, j4)
|
|
14592
14592
|
continue;
|
|
14593
14593
|
else {
|
|
14594
|
-
let
|
|
14595
|
-
Z3 = Z3.add(N ?
|
|
14594
|
+
let z2 = G2[M2];
|
|
14595
|
+
Z3 = Z3.add(N ? z2.negate() : z2);
|
|
14596
14596
|
}
|
|
14597
14597
|
}
|
|
14598
14598
|
return Z3;
|
|
@@ -14620,28 +14620,28 @@ function V82($3, J2, Q4, G2) {
|
|
|
14620
14620
|
let Y2 = Q4.length, Z3 = G2.length;
|
|
14621
14621
|
if (Y2 !== Z3)
|
|
14622
14622
|
throw Error("arrays of points and scalars must have equal length");
|
|
14623
|
-
let K3 = $3.ZERO,
|
|
14624
|
-
if (
|
|
14625
|
-
|
|
14626
|
-
else if (
|
|
14627
|
-
|
|
14628
|
-
else if (
|
|
14629
|
-
|
|
14630
|
-
let M2 = F03(
|
|
14631
|
-
for (let
|
|
14623
|
+
let K3 = $3.ZERO, X4 = Q82(BigInt(Y2)), q3 = 1;
|
|
14624
|
+
if (X4 > 12)
|
|
14625
|
+
q3 = X4 - 3;
|
|
14626
|
+
else if (X4 > 4)
|
|
14627
|
+
q3 = X4 - 2;
|
|
14628
|
+
else if (X4 > 0)
|
|
14629
|
+
q3 = 2;
|
|
14630
|
+
let M2 = F03(q3), j4 = Array(Number(M2) + 1).fill(K3), N = Math.floor((J2.BITS - 1) / q3) * q3, z2 = K3;
|
|
14631
|
+
for (let D3 = N;D3 >= 0; D3 -= q3) {
|
|
14632
14632
|
j4.fill(K3);
|
|
14633
|
-
for (let
|
|
14634
|
-
let
|
|
14635
|
-
j4[
|
|
14633
|
+
for (let V2 = 0;V2 < Z3; V2++) {
|
|
14634
|
+
let B4 = G2[V2], S3 = Number(B4 >> BigInt(D3) & M2);
|
|
14635
|
+
j4[S3] = j4[S3].add(Q4[V2]);
|
|
14636
14636
|
}
|
|
14637
|
-
let
|
|
14638
|
-
for (let
|
|
14639
|
-
|
|
14640
|
-
if (
|
|
14641
|
-
for (let
|
|
14642
|
-
|
|
14637
|
+
let H4 = K3;
|
|
14638
|
+
for (let V2 = j4.length - 1, B4 = K3;V2 > 0; V2--)
|
|
14639
|
+
B4 = B4.add(j4[V2]), H4 = H4.add(B4);
|
|
14640
|
+
if (z2 = z2.add(H4), D3 !== 0)
|
|
14641
|
+
for (let V2 = 0;V2 < q3; V2++)
|
|
14642
|
+
z2 = z2.double();
|
|
14643
14643
|
}
|
|
14644
|
-
return
|
|
14644
|
+
return z2;
|
|
14645
14645
|
}
|
|
14646
14646
|
function NJ2($3) {
|
|
14647
14647
|
return YJ3($3.Fp), b03($3, { n: "bigint", h: "bigint", Gx: "field", Gy: "field" }, { nBitLength: "isSafeInteger", nByteLength: "isSafeInteger" }), Object.freeze({ ...KJ3($3.n, $3.nBitLength), ...$3, ...{ p: $3.Fp.ORDER } });
|
|
@@ -14692,25 +14692,25 @@ var D03 = { Err: R8, _tlv: { encode: ($3, J2) => {
|
|
|
14692
14692
|
if (!Z3)
|
|
14693
14693
|
K3 = Y2;
|
|
14694
14694
|
else {
|
|
14695
|
-
let
|
|
14696
|
-
if (!
|
|
14695
|
+
let q3 = Y2 & 127;
|
|
14696
|
+
if (!q3)
|
|
14697
14697
|
throw new Q4("tlv.decode(long): indefinite length not supported");
|
|
14698
|
-
if (
|
|
14698
|
+
if (q3 > 4)
|
|
14699
14699
|
throw new Q4("tlv.decode(long): byte length is too big");
|
|
14700
|
-
let M2 = J2.subarray(G2, G2 +
|
|
14701
|
-
if (M2.length !==
|
|
14700
|
+
let M2 = J2.subarray(G2, G2 + q3);
|
|
14701
|
+
if (M2.length !== q3)
|
|
14702
14702
|
throw new Q4("tlv.decode: length bytes not complete");
|
|
14703
14703
|
if (M2[0] === 0)
|
|
14704
14704
|
throw new Q4("tlv.decode(long): zero leftmost byte");
|
|
14705
14705
|
for (let j4 of M2)
|
|
14706
14706
|
K3 = K3 << 8 | j4;
|
|
14707
|
-
if (G2 +=
|
|
14707
|
+
if (G2 += q3, K3 < 128)
|
|
14708
14708
|
throw new Q4("tlv.decode(long): not minimal encoding");
|
|
14709
14709
|
}
|
|
14710
|
-
let
|
|
14711
|
-
if (
|
|
14710
|
+
let X4 = J2.subarray(G2, G2 + K3);
|
|
14711
|
+
if (X4.length !== K3)
|
|
14712
14712
|
throw new Q4("tlv.decode: wrong value length");
|
|
14713
|
-
return { v:
|
|
14713
|
+
return { v: X4, l: J2.subarray(G2 + K3) };
|
|
14714
14714
|
} }, _int: { encode($3) {
|
|
14715
14715
|
let { Err: J2 } = D03;
|
|
14716
14716
|
if ($3 < V03)
|
|
@@ -14732,10 +14732,10 @@ var D03 = { Err: R8, _tlv: { encode: ($3, J2) => {
|
|
|
14732
14732
|
let { Err: J2, _int: Q4, _tlv: G2 } = D03, Y2 = e5("signature", $3), { v: Z3, l: K3 } = G2.decode(48, Y2);
|
|
14733
14733
|
if (K3.length)
|
|
14734
14734
|
throw new J2("invalid signature: left bytes after parsing");
|
|
14735
|
-
let { v:
|
|
14735
|
+
let { v: X4, l: q3 } = G2.decode(2, Z3), { v: M2, l: j4 } = G2.decode(2, q3);
|
|
14736
14736
|
if (j4.length)
|
|
14737
14737
|
throw new J2("invalid signature: left bytes after parsing");
|
|
14738
|
-
return { r: Q4.decode(
|
|
14738
|
+
return { r: Q4.decode(X4), s: Q4.decode(M2) };
|
|
14739
14739
|
}, hexFromSig($3) {
|
|
14740
14740
|
let { _tlv: J2, _int: Q4 } = D03, G2 = J2.encode(2, Q4.encode($3.r)), Y2 = J2.encode(2, Q4.encode($3.s)), Z3 = G2 + Y2;
|
|
14741
14741
|
return J2.encode(48, Z3);
|
|
@@ -14749,101 +14749,101 @@ 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,
|
|
14753
|
-
let
|
|
14754
|
-
return M$(Uint8Array.from([4]), Q4.toBytes(
|
|
14752
|
+
let J2 = DQ($3), { Fp: Q4 } = J2, G2 = j$2(J2.n, J2.nBitLength), Y2 = J2.toBytes || ((U2, R4, L3) => {
|
|
14753
|
+
let I4 = R4.toAffine();
|
|
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
|
-
function
|
|
14764
|
-
let
|
|
14765
|
-
return Q4.eql(
|
|
14763
|
+
function X4(U2, R4) {
|
|
14764
|
+
let L3 = Q4.sqr(R4), I4 = K3(U2);
|
|
14765
|
+
return Q4.eql(L3, I4);
|
|
14766
14766
|
}
|
|
14767
|
-
if (!
|
|
14767
|
+
if (!X4(J2.Gx, J2.Gy))
|
|
14768
14768
|
throw Error("bad curve params: generator point");
|
|
14769
|
-
let
|
|
14770
|
-
if (Q4.is0(Q4.add(
|
|
14769
|
+
let q3 = Q4.mul(Q4.pow(J2.a, DJ3), VQ), M2 = Q4.mul(Q4.sqr(J2.b), BigInt(27));
|
|
14770
|
+
if (Q4.is0(Q4.add(q3, M2)))
|
|
14771
14771
|
throw Error("bad curve params: a or b");
|
|
14772
14772
|
function j4(U2) {
|
|
14773
14773
|
return x$2(U2, p5, J2.n);
|
|
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
|
-
let
|
|
14784
|
+
let x3;
|
|
14785
14785
|
try {
|
|
14786
|
-
|
|
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
|
-
if (
|
|
14791
|
-
|
|
14792
|
-
return y03("private key",
|
|
14790
|
+
if (I4)
|
|
14791
|
+
x3 = i4(x3, w3);
|
|
14792
|
+
return y03("private key", x3, p5, w3), x3;
|
|
14793
14793
|
}
|
|
14794
|
-
function
|
|
14795
|
-
if (!(U2 instanceof
|
|
14794
|
+
function z2(U2) {
|
|
14795
|
+
if (!(U2 instanceof V2))
|
|
14796
14796
|
throw Error("ProjectivePoint expected");
|
|
14797
14797
|
}
|
|
14798
|
-
let
|
|
14799
|
-
let { px:
|
|
14798
|
+
let D3 = GJ3((U2, R4) => {
|
|
14799
|
+
let { px: L3, py: I4, pz: w3 } = U2;
|
|
14800
14800
|
if (Q4.eql(w3, Q4.ONE))
|
|
14801
|
-
return { x:
|
|
14802
|
-
let
|
|
14801
|
+
return { x: L3, y: I4 };
|
|
14802
|
+
let x3 = U2.is0();
|
|
14803
14803
|
if (R4 == null)
|
|
14804
|
-
R4 =
|
|
14805
|
-
let y4 = Q4.mul(
|
|
14806
|
-
if (
|
|
14804
|
+
R4 = x3 ? Q4.ONE : Q4.inv(w3);
|
|
14805
|
+
let y4 = Q4.mul(L3, R4), E4 = Q4.mul(I4, R4), k4 = Q4.mul(w3, R4);
|
|
14806
|
+
if (x3)
|
|
14807
14807
|
return { x: Q4.ZERO, y: Q4.ZERO };
|
|
14808
14808
|
if (!Q4.eql(k4, Q4.ONE))
|
|
14809
14809
|
throw Error("invZ was invalid");
|
|
14810
|
-
return { x: y4, y:
|
|
14811
|
-
}),
|
|
14810
|
+
return { x: y4, y: E4 };
|
|
14811
|
+
}), H4 = GJ3((U2) => {
|
|
14812
14812
|
if (U2.is0()) {
|
|
14813
14813
|
if (J2.allowInfinityPoint && !Q4.is0(U2.py))
|
|
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 (!
|
|
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");
|
|
14824
14824
|
return true;
|
|
14825
14825
|
});
|
|
14826
14826
|
|
|
14827
|
-
class
|
|
14828
|
-
constructor(U2, R4,
|
|
14827
|
+
class V2 {
|
|
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
|
-
if (U2 instanceof
|
|
14841
|
+
if (U2 instanceof V2)
|
|
14842
14842
|
throw Error("projective point not allowed");
|
|
14843
|
-
let
|
|
14844
|
-
if (
|
|
14845
|
-
return
|
|
14846
|
-
return new
|
|
14843
|
+
let I4 = (w3) => Q4.eql(w3, Q4.ZERO);
|
|
14844
|
+
if (I4(R4) && I4(L3))
|
|
14845
|
+
return V2.ZERO;
|
|
14846
|
+
return new V2(R4, L3, Q4.ONE);
|
|
14847
14847
|
}
|
|
14848
14848
|
get x() {
|
|
14849
14849
|
return this.toAffine().x;
|
|
@@ -14852,24 +14852,24 @@ 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
|
-
let R4 =
|
|
14859
|
+
let R4 = V2.fromAffine(Z3(e5("pointHex", U2)));
|
|
14860
14860
|
return R4.assertValidity(), R4;
|
|
14861
14861
|
}
|
|
14862
14862
|
static fromPrivateKey(U2) {
|
|
14863
|
-
return
|
|
14863
|
+
return V2.BASE.multiply(N(U2));
|
|
14864
14864
|
}
|
|
14865
14865
|
static msm(U2, R4) {
|
|
14866
|
-
return V82(
|
|
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);
|
|
14873
14873
|
}
|
|
14874
14874
|
hasEvenY() {
|
|
14875
14875
|
let { y: U2 } = this.toAffine();
|
|
@@ -14878,83 +14878,83 @@ function OQ($3) {
|
|
|
14878
14878
|
throw Error("Field doesn't support isOdd");
|
|
14879
14879
|
}
|
|
14880
14880
|
equals(U2) {
|
|
14881
|
-
|
|
14882
|
-
let { px: R4, py:
|
|
14883
|
-
return
|
|
14881
|
+
z2(U2);
|
|
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
|
+
return E4 && k4;
|
|
14884
14884
|
}
|
|
14885
14885
|
negate() {
|
|
14886
|
-
return new
|
|
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(
|
|
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
|
-
|
|
14894
|
-
let { px: R4, py:
|
|
14895
|
-
F2 = Q4.mul(F2,
|
|
14893
|
+
z2(U2);
|
|
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
|
+
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
|
|
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());
|
|
14901
14901
|
}
|
|
14902
14902
|
is0() {
|
|
14903
|
-
return this.equals(
|
|
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,
|
|
14911
|
-
let
|
|
14909
|
+
let { endo: R4, n: L3 } = J2;
|
|
14910
|
+
y03("scalar", U2, V03, L3);
|
|
14911
|
+
let I4 = V2.ZERO;
|
|
14912
14912
|
if (U2 === V03)
|
|
14913
|
-
return
|
|
14913
|
+
return I4;
|
|
14914
14914
|
if (this.is0() || U2 === p5)
|
|
14915
14915
|
return this;
|
|
14916
|
-
if (!R4 ||
|
|
14917
|
-
return
|
|
14918
|
-
let { k1neg: w3, k1:
|
|
14919
|
-
while (
|
|
14920
|
-
if (
|
|
14916
|
+
if (!R4 || v3.hasPrecomputes(this))
|
|
14917
|
+
return v3.wNAFCachedUnsafe(this, U2, V2.normalizeZ);
|
|
14918
|
+
let { k1neg: w3, k1: x3, k2neg: y4, k2: E4 } = R4.splitScalar(U2), k4 = I4, A3 = I4, c4 = this;
|
|
14919
|
+
while (x3 > V03 || E4 > V03) {
|
|
14920
|
+
if (x3 & p5)
|
|
14921
14921
|
k4 = k4.add(c4);
|
|
14922
|
-
if (
|
|
14923
|
-
|
|
14924
|
-
c4 = c4.double(),
|
|
14922
|
+
if (E4 & p5)
|
|
14923
|
+
A3 = A3.add(c4);
|
|
14924
|
+
c4 = c4.double(), x3 >>= p5, E4 >>= p5;
|
|
14925
14925
|
}
|
|
14926
14926
|
if (w3)
|
|
14927
14927
|
k4 = k4.negate();
|
|
14928
14928
|
if (y4)
|
|
14929
|
-
|
|
14930
|
-
return
|
|
14929
|
+
A3 = A3.negate();
|
|
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,
|
|
14935
|
-
let
|
|
14933
|
+
let { endo: R4, n: L3 } = J2;
|
|
14934
|
+
y03("scalar", U2, p5, L3);
|
|
14935
|
+
let I4, w3;
|
|
14936
14936
|
if (R4) {
|
|
14937
|
-
let { k1neg:
|
|
14938
|
-
|
|
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 = 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
|
-
let { p:
|
|
14941
|
-
|
|
14940
|
+
let { p: x3, f: y4 } = this.wNAF(U2);
|
|
14941
|
+
I4 = x3, w3 = y4;
|
|
14942
14942
|
}
|
|
14943
|
-
return
|
|
14943
|
+
return V2.normalizeZ([I4, w3])[0];
|
|
14944
14944
|
}
|
|
14945
|
-
multiplyAndAddUnsafe(U2, R4,
|
|
14946
|
-
let
|
|
14947
|
-
return
|
|
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
|
+
return x3.is0() ? undefined : x3;
|
|
14948
14948
|
}
|
|
14949
14949
|
toAffine(U2) {
|
|
14950
|
-
return
|
|
14950
|
+
return D3(this, U2);
|
|
14951
14951
|
}
|
|
14952
14952
|
isTorsionFree() {
|
|
14953
14953
|
let { h: U2, isTorsionFree: R4 } = J2;
|
|
14954
14954
|
if (U2 === p5)
|
|
14955
14955
|
return true;
|
|
14956
14956
|
if (R4)
|
|
14957
|
-
return R4(
|
|
14957
|
+
return R4(V2, this);
|
|
14958
14958
|
throw Error("isTorsionFree() has not been declared for the elliptic curve");
|
|
14959
14959
|
}
|
|
14960
14960
|
clearCofactor() {
|
|
@@ -14962,107 +14962,107 @@ function OQ($3) {
|
|
|
14962
14962
|
if (U2 === p5)
|
|
14963
14963
|
return this;
|
|
14964
14964
|
if (R4)
|
|
14965
|
-
return R4(
|
|
14965
|
+
return R4(V2, this);
|
|
14966
14966
|
return this.multiplyUnsafe(J2.h);
|
|
14967
14967
|
}
|
|
14968
14968
|
toRawBytes(U2 = true) {
|
|
14969
|
-
return i03("isCompressed", U2), this.assertValidity(), Y2(
|
|
14969
|
+
return i03("isCompressed", U2), this.assertValidity(), Y2(V2, this, U2);
|
|
14970
14970
|
}
|
|
14971
14971
|
toHex(U2 = true) {
|
|
14972
14972
|
return i03("isCompressed", U2), n03(this.toRawBytes(U2));
|
|
14973
14973
|
}
|
|
14974
14974
|
}
|
|
14975
|
-
|
|
14976
|
-
let { endo:
|
|
14977
|
-
return { CURVE: J2, ProjectivePoint:
|
|
14975
|
+
V2.BASE = new V2(J2.Gx, J2.Gy, Q4.ONE), V2.ZERO = new V2(Q4.ZERO, Q4.ONE, Q4.ZERO);
|
|
14976
|
+
let { endo: B4, nBitLength: S3 } = J2, v3 = D82(V2, B4 ? Math.ceil(S3 / 2) : S3);
|
|
14977
|
+
return { CURVE: J2, ProjectivePoint: V2, normPrivateKeyToScalar: N, weierstrassEquation: K3, isWithinCurveOrder: j4 };
|
|
14978
14978
|
}
|
|
14979
14979
|
function RQ($3) {
|
|
14980
14980
|
let J2 = NJ2($3);
|
|
14981
14981
|
return b03(J2, { hash: "hash", hmac: "function", randomBytes: "function" }, { bits2int: "function", bits2int_modN: "function", lowS: "boolean" }), Object.freeze({ lowS: true, ...J2 });
|
|
14982
14982
|
}
|
|
14983
14983
|
function C8($3) {
|
|
14984
|
-
let J2 = RQ($3), { Fp: Q4, n: G2, nByteLength: Y2, nBitLength: Z3 } = J2, K3 = Q4.BYTES + 1,
|
|
14985
|
-
function
|
|
14984
|
+
let J2 = RQ($3), { Fp: Q4, n: G2, nByteLength: Y2, nBitLength: Z3 } = J2, K3 = Q4.BYTES + 1, X4 = 2 * Q4.BYTES + 1;
|
|
14985
|
+
function q3(W3) {
|
|
14986
14986
|
return i4(W3, G2);
|
|
14987
14987
|
}
|
|
14988
14988
|
function M2(W3) {
|
|
14989
14989
|
return A$2(W3, G2);
|
|
14990
14990
|
}
|
|
14991
|
-
let { ProjectivePoint: j4, normPrivateKeyToScalar: N, weierstrassEquation:
|
|
14992
|
-
let F2 = C3.toAffine(),
|
|
14993
|
-
if (i03("isCompressed",
|
|
14994
|
-
return O4(Uint8Array.from([C3.hasEvenY() ? 2 : 3]),
|
|
14991
|
+
let { ProjectivePoint: j4, normPrivateKeyToScalar: N, weierstrassEquation: z2, isWithinCurveOrder: D3 } = OQ({ ...J2, toBytes(W3, C3, T3) {
|
|
14992
|
+
let F2 = C3.toAffine(), _4 = Q4.toBytes(F2.x), O4 = M$;
|
|
14993
|
+
if (i03("isCompressed", T3), T3)
|
|
14994
|
+
return O4(Uint8Array.from([C3.hasEvenY() ? 2 : 3]), _4);
|
|
14995
14995
|
else
|
|
14996
|
-
return O4(Uint8Array.from([4]),
|
|
14996
|
+
return O4(Uint8Array.from([4]), _4, Q4.toBytes(F2.y));
|
|
14997
14997
|
}, fromBytes(W3) {
|
|
14998
|
-
let C3 = W3.length,
|
|
14999
|
-
if (C3 === K3 && (
|
|
15000
|
-
let
|
|
15001
|
-
if (!x$2(
|
|
14998
|
+
let C3 = W3.length, T3 = W3[0], F2 = W3.subarray(1);
|
|
14999
|
+
if (C3 === K3 && (T3 === 2 || T3 === 3)) {
|
|
15000
|
+
let _4 = z02(F2);
|
|
15001
|
+
if (!x$2(_4, p5, Q4.ORDER))
|
|
15002
15002
|
throw Error("Point is not on curve");
|
|
15003
|
-
let O4 =
|
|
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 = (
|
|
15011
|
-
if ((
|
|
15012
|
-
|
|
15013
|
-
return { x:
|
|
15014
|
-
} else if (C3 ===
|
|
15015
|
-
let
|
|
15016
|
-
return { x:
|
|
15010
|
+
let m3 = (g3 & p5) === p5;
|
|
15011
|
+
if ((T3 & 1) === 1 !== m3)
|
|
15012
|
+
g3 = Q4.neg(g3);
|
|
15013
|
+
return { x: _4, y: g3 };
|
|
15014
|
+
} else if (C3 === X4 && T3 === 4) {
|
|
15015
|
+
let _4 = Q4.fromBytes(F2.subarray(0, Q4.BYTES)), O4 = Q4.fromBytes(F2.subarray(Q4.BYTES, 2 * Q4.BYTES));
|
|
15016
|
+
return { x: _4, y: O4 };
|
|
15017
15017
|
} else {
|
|
15018
|
-
let
|
|
15019
|
-
throw Error("invalid Point, expected length of " +
|
|
15018
|
+
let _4 = K3, O4 = X4;
|
|
15019
|
+
throw Error("invalid Point, expected length of " + _4 + ", or uncompressed " + O4 + ", got " + C3);
|
|
15020
15020
|
}
|
|
15021
15021
|
} });
|
|
15022
|
-
function
|
|
15022
|
+
function H4(W3) {
|
|
15023
15023
|
let C3 = G2 >> p5;
|
|
15024
15024
|
return W3 > C3;
|
|
15025
15025
|
}
|
|
15026
|
-
function
|
|
15027
|
-
return
|
|
15026
|
+
function V2(W3) {
|
|
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
|
-
class
|
|
15032
|
-
constructor(W3, C3,
|
|
15033
|
-
if (y03("r", W3, p5, G2), y03("s", C3, p5, G2), this.r = W3, this.s = C3,
|
|
15034
|
-
this.recovery =
|
|
15031
|
+
class S3 {
|
|
15032
|
+
constructor(W3, C3, T3) {
|
|
15033
|
+
if (y03("r", W3, p5, G2), y03("s", C3, p5, G2), this.r = W3, this.s = C3, T3 != null)
|
|
15034
|
+
this.recovery = T3;
|
|
15035
15035
|
Object.freeze(this);
|
|
15036
15036
|
}
|
|
15037
15037
|
static fromCompact(W3) {
|
|
15038
15038
|
let C3 = Y2;
|
|
15039
|
-
return W3 = e5("compactSignature", W3, C3 * 2), new
|
|
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
|
-
let { r: C3, s:
|
|
15043
|
-
return new
|
|
15042
|
+
let { r: C3, s: T3 } = D03.toSig(e5("DER", W3));
|
|
15043
|
+
return new S3(C3, T3);
|
|
15044
15044
|
}
|
|
15045
15045
|
assertValidity() {}
|
|
15046
15046
|
addRecoveryBit(W3) {
|
|
15047
|
-
return new
|
|
15047
|
+
return new S3(this.r, this.s, W3);
|
|
15048
15048
|
}
|
|
15049
15049
|
recoverPublicKey(W3) {
|
|
15050
|
-
let { r: C3, s:
|
|
15050
|
+
let { r: C3, s: T3, recovery: F2 } = this, _4 = w3(e5("msgHash", W3));
|
|
15051
15051
|
if (F2 == null || ![0, 1, 2, 3].includes(F2))
|
|
15052
15052
|
throw Error("recovery id invalid");
|
|
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;
|
|
15060
15060
|
}
|
|
15061
15061
|
hasHighS() {
|
|
15062
|
-
return
|
|
15062
|
+
return H4(this.s);
|
|
15063
15063
|
}
|
|
15064
15064
|
normalizeS() {
|
|
15065
|
-
return this.hasHighS() ? new
|
|
15065
|
+
return this.hasHighS() ? new S3(this.r, q3(-this.s), this.recovery) : this;
|
|
15066
15066
|
}
|
|
15067
15067
|
toDERRawBytes() {
|
|
15068
15068
|
return q$(this.toDERHex());
|
|
@@ -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) {
|
|
@@ -15098,94 +15098,94 @@ function C8($3) {
|
|
|
15098
15098
|
return false;
|
|
15099
15099
|
if (W3 instanceof j4)
|
|
15100
15100
|
return true;
|
|
15101
|
-
let
|
|
15102
|
-
if (J2.allowedPrivateKeyLengths || Y2 ===
|
|
15101
|
+
let T3 = e5("key", W3).length, F2 = Q4.BYTES, _4 = F2 + 1, O4 = 2 * F2 + 1;
|
|
15102
|
+
if (J2.allowedPrivateKeyLengths || Y2 === _4)
|
|
15103
15103
|
return;
|
|
15104
15104
|
else
|
|
15105
|
-
return
|
|
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)
|
|
15111
15111
|
throw Error("second arg must be public key");
|
|
15112
|
-
return j4.fromHex(C3).multiply(N(W3)).toRawBytes(
|
|
15112
|
+
return j4.fromHex(C3).multiply(N(W3)).toRawBytes(T3);
|
|
15113
15113
|
}
|
|
15114
|
-
let
|
|
15114
|
+
let I4 = J2.bits2int || function(W3) {
|
|
15115
15115
|
if (W3.length > 8192)
|
|
15116
15116
|
throw Error("input is too large");
|
|
15117
|
-
let C3 = z02(W3),
|
|
15118
|
-
return
|
|
15117
|
+
let C3 = z02(W3), T3 = W3.length * 8 - Z3;
|
|
15118
|
+
return T3 > 0 ? C3 >> BigInt(T3) : C3;
|
|
15119
15119
|
}, w3 = J2.bits2int_modN || function(W3) {
|
|
15120
|
-
return
|
|
15121
|
-
},
|
|
15120
|
+
return q3(I4(W3));
|
|
15121
|
+
}, x3 = F03(Z3);
|
|
15122
15122
|
function y4(W3) {
|
|
15123
|
-
return y03("num < 2^" + Z3, W3, V03,
|
|
15123
|
+
return y03("num < 2^" + Z3, W3, V03, x3), w03(W3, Y2);
|
|
15124
15124
|
}
|
|
15125
|
-
function
|
|
15126
|
-
if (["recovered", "canonical"].some((H03) => (H03 in
|
|
15125
|
+
function E4(W3, C3, T3 = k4) {
|
|
15126
|
+
if (["recovered", "canonical"].some((H03) => (H03 in T3)))
|
|
15127
15127
|
throw Error("sign() legacy options not supported");
|
|
15128
|
-
let { hash: F2, randomBytes:
|
|
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(
|
|
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) {
|
|
15135
|
-
let H03 = m3 === true ?
|
|
15135
|
+
let H03 = m3 === true ? _4(Q4.BYTES) : m3;
|
|
15136
15136
|
r4.push(e5("extraEntropy", H03));
|
|
15137
15137
|
}
|
|
15138
15138
|
let O03 = M$(...r4), N$2 = l4;
|
|
15139
15139
|
function F$2(H03) {
|
|
15140
|
-
let
|
|
15141
|
-
if (!
|
|
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
|
-
let t03 =
|
|
15146
|
+
let t03 = q3(b$2 * q3(N$2 + S03 * s3));
|
|
15147
15147
|
if (t03 === V03)
|
|
15148
15148
|
return;
|
|
15149
15149
|
let v03 = (o03.x === S03 ? 0 : 2) | Number(o03.y & p5), IJ3 = t03;
|
|
15150
|
-
if (O4 &&
|
|
15151
|
-
IJ3 =
|
|
15152
|
-
return new
|
|
15150
|
+
if (O4 && H4(t03))
|
|
15151
|
+
IJ3 = V2(t03), v03 ^= 1;
|
|
15152
|
+
return new S3(S03, IJ3, v03);
|
|
15153
15153
|
}
|
|
15154
15154
|
return { seed: O03, k2sig: F$2 };
|
|
15155
15155
|
}
|
|
15156
|
-
let k4 = { lowS: J2.lowS, prehash: false },
|
|
15157
|
-
function c4(W3, C3,
|
|
15158
|
-
let { seed: F2, k2sig:
|
|
15159
|
-
return G82(O4.hash.outputLen, O4.nByteLength, O4.hmac)(F2,
|
|
15156
|
+
let k4 = { lowS: J2.lowS, prehash: false }, A3 = { lowS: J2.lowS, prehash: false };
|
|
15157
|
+
function c4(W3, C3, T3 = k4) {
|
|
15158
|
+
let { seed: F2, k2sig: _4 } = E4(W3, C3, T3), O4 = J2;
|
|
15159
|
+
return G82(O4.hash.outputLen, O4.nByteLength, O4.hmac)(F2, _4);
|
|
15160
15160
|
}
|
|
15161
15161
|
j4.BASE._setWindowSize(8);
|
|
15162
|
-
function
|
|
15163
|
-
let
|
|
15164
|
-
C3 = e5("msgHash", C3),
|
|
15165
|
-
let { lowS: O4, prehash:
|
|
15162
|
+
function h4(W3, C3, T3, F2 = A3) {
|
|
15163
|
+
let _4 = W3;
|
|
15164
|
+
C3 = e5("msgHash", C3), T3 = e5("publicKey", T3);
|
|
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")
|
|
15169
15169
|
throw Error("format must be compact or der");
|
|
15170
|
-
let l4 = typeof
|
|
15170
|
+
let l4 = typeof _4 === "string" || d03(_4), s3 = !l4 && !m3 && typeof _4 === "object" && _4 !== null && typeof _4.r === "bigint" && typeof _4.s === "bigint";
|
|
15171
15171
|
if (!l4 && !s3)
|
|
15172
15172
|
throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
|
15173
15173
|
let r4 = undefined, O03;
|
|
15174
15174
|
try {
|
|
15175
15175
|
if (s3)
|
|
15176
|
-
r4 = new
|
|
15176
|
+
r4 = new S3(_4.r, _4.s);
|
|
15177
15177
|
if (l4) {
|
|
15178
15178
|
try {
|
|
15179
15179
|
if (m3 !== "compact")
|
|
15180
|
-
r4 =
|
|
15180
|
+
r4 = S3.fromDER(_4);
|
|
15181
15181
|
} catch (v03) {
|
|
15182
15182
|
if (!(v03 instanceof D03.Err))
|
|
15183
15183
|
throw v03;
|
|
15184
15184
|
}
|
|
15185
15185
|
if (!r4 && m3 !== "der")
|
|
15186
|
-
r4 =
|
|
15186
|
+
r4 = S3.fromCompact(_4);
|
|
15187
15187
|
}
|
|
15188
|
-
O03 = j4.fromHex(
|
|
15188
|
+
O03 = j4.fromHex(T3);
|
|
15189
15189
|
} catch (v03) {
|
|
15190
15190
|
return false;
|
|
15191
15191
|
}
|
|
@@ -15193,46 +15193,46 @@ 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
|
-
return
|
|
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),
|
|
15222
|
-
if (!OJ3.eql(OJ3.sqr(
|
|
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
|
+
if (!OJ3.eql(OJ3.sqr(I4), $3))
|
|
15223
15223
|
throw Error("Cannot find square root");
|
|
15224
|
-
return
|
|
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
|
-
if (
|
|
15231
|
+
if (z2)
|
|
15232
15232
|
j4 = J2 - j4;
|
|
15233
15233
|
if (M2 > K3 || j4 > K3)
|
|
15234
15234
|
throw Error("splitScalar: Endomorphism failed, k=" + $3);
|
|
15235
|
-
return { k1neg: N, k1: M2, k2neg:
|
|
15235
|
+
return { k1neg: N, k1: M2, k2neg: z2, k2: j4 };
|
|
15236
15236
|
} } }, sJ2);
|
|
15237
15237
|
function k$2() {
|
|
15238
15238
|
let $3 = RJ3.utils.randomPrivateKey();
|
|
@@ -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
|
-
let K3 = Number(Q4) / 1000000000000000000,
|
|
15268
|
-
return new
|
|
15267
|
+
let K3 = Number(Q4) / 1000000000000000000, X4 = Number(G2) / 1000000000000000000;
|
|
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 = [];
|
|
@@ -15295,21 +15295,21 @@ function T82($3, J2, Q4) {
|
|
|
15295
15295
|
$3.forEach((K3) => {
|
|
15296
15296
|
G2.add(K3.from.toLowerCase()), G2.add(K3.to.toLowerCase()), G2.add(K3.tokenOwner.toLowerCase());
|
|
15297
15297
|
});
|
|
15298
|
-
let Y2 = [...G2].sort((K3,
|
|
15299
|
-
let
|
|
15298
|
+
let Y2 = [...G2].sort((K3, X4) => {
|
|
15299
|
+
let q3 = BigInt(K3), M2 = BigInt(X4), j4 = q3 < M2, N = q3 > M2;
|
|
15300
15300
|
return j4 ? -1 : N ? 1 : 0;
|
|
15301
15301
|
}), Z3 = {};
|
|
15302
|
-
return Y2.forEach((K3,
|
|
15303
|
-
Z3[K3] =
|
|
15302
|
+
return Y2.forEach((K3, X4) => {
|
|
15303
|
+
Z3[K3] = X4;
|
|
15304
15304
|
}), { sorted: Y2, idx: Z3 };
|
|
15305
15305
|
}
|
|
15306
15306
|
function HQ2($3, J2) {
|
|
15307
15307
|
let Q4 = new Set, G2 = [], Y2 = null;
|
|
15308
15308
|
if ($3.forEach((Z3, K3) => {
|
|
15309
|
-
let
|
|
15310
|
-
if (
|
|
15309
|
+
let X4 = Z3.from.toLowerCase(), q3 = Z3.to.toLowerCase();
|
|
15310
|
+
if (X4 === J2 && q3 === J2)
|
|
15311
15311
|
Y2 = K3;
|
|
15312
|
-
else if (
|
|
15312
|
+
else if (q3 === J2)
|
|
15313
15313
|
G2.push(K3);
|
|
15314
15314
|
}), Y2 !== null)
|
|
15315
15315
|
Q4.add(Y2);
|
|
@@ -15318,38 +15318,38 @@ function HQ2($3, J2) {
|
|
|
15318
15318
|
return Q4;
|
|
15319
15319
|
}
|
|
15320
15320
|
function CJ2($3, J2, Q4, G2) {
|
|
15321
|
-
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), { sorted: K3, idx:
|
|
15322
|
-
return { streamSinkId:
|
|
15321
|
+
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), { sorted: K3, idx: 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
|
-
if (
|
|
15324
|
+
if (q3.size === 0)
|
|
15325
15325
|
throw Error(`No terminal edges detected. Flow must have at least one edge delivering to receiver ${Z3}`);
|
|
15326
|
-
let j4 = Array.from(
|
|
15327
|
-
G2.forEach((
|
|
15328
|
-
|
|
15326
|
+
let j4 = Array.from(q3), N = [{ sourceCoordinate: X4[Y2], flowEdgeIds: j4, data: new Uint8Array(0) }], z2 = [];
|
|
15327
|
+
G2.forEach((S3) => {
|
|
15328
|
+
z2.push(X4[S3.tokenOwner.toLowerCase()]), z2.push(X4[S3.from.toLowerCase()]), z2.push(X4[S3.to.toLowerCase()]);
|
|
15329
15329
|
});
|
|
15330
|
-
let
|
|
15331
|
-
if (
|
|
15332
|
-
throw Error(`Terminal sum ${
|
|
15333
|
-
return { flowVertices: K3, flowEdges: M2, streams: N, packedCoordinates:
|
|
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
|
+
if (V2 !== H4)
|
|
15332
|
+
throw Error(`Terminal sum ${V2} does not equal expected ${H4}`);
|
|
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
|
-
return Q4.transfers.forEach((
|
|
15344
|
-
if ($3.toLowerCase() ===
|
|
15345
|
-
Y2.add(
|
|
15346
|
-
}), (await new I$2(J2).token.getTokenInfoBatch(Array.from(Y2))).forEach((
|
|
15347
|
-
if (
|
|
15348
|
-
|
|
15349
|
-
G2.set(
|
|
15343
|
+
return Q4.transfers.forEach((X4) => {
|
|
15344
|
+
if ($3.toLowerCase() === X4.from.toLowerCase())
|
|
15345
|
+
Y2.add(X4.tokenOwner.toLowerCase());
|
|
15346
|
+
}), (await new I$2(J2).token.getTokenInfoBatch(Array.from(Y2))).forEach((X4) => {
|
|
15347
|
+
if (X4.isWrapped && !X4.isInflationary)
|
|
15348
|
+
X4.tokenType = "CrcV2_ERC20WrapperDeployed_Demurraged";
|
|
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,112 +15404,112 @@ 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();
|
|
15411
15411
|
if (!Q4.transfers || Q4.transfers.length === 0)
|
|
15412
15412
|
throw o5.noPathFound(Z3, K3);
|
|
15413
|
-
let
|
|
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
|
-
|
|
15417
|
+
X4.transfers.push({ from: K3, to: K3, tokenOwner: v3, value: Q4.maxFlow });
|
|
15418
15418
|
}
|
|
15419
|
-
let
|
|
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
|
-
let N = [],
|
|
15422
|
+
let N = [], z2 = [];
|
|
15423
15423
|
if (j4) {
|
|
15424
|
-
let
|
|
15425
|
-
N = [...U2, ...R4],
|
|
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
|
|
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
|
-
let Z3 = $3.toLowerCase(), K3 = J2.toLowerCase(),
|
|
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
|
|
15439
|
-
if (
|
|
15440
|
-
let
|
|
15441
|
-
return [{ to:
|
|
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
|
+
if (D3.toLowerCase() === V2.toLowerCase() && V2 !== S$2) {
|
|
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 (
|
|
15444
|
-
let
|
|
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
|
}
|
|
15448
|
-
let
|
|
15449
|
-
if (!
|
|
15448
|
+
let q3 = this._truncateToSixDecimals(X4), M2 = await this._getDefaultTokenExcludeList(K3, G2?.excludeFromTokens), { ...j4 } = G2 || {}, N = { ...j4, ...M2 ? { excludeFromTokens: M2 } : {} }, z2 = await this.pathfinder.findPath({ from: Z3, to: K3, targetFlow: q3, ...N });
|
|
15449
|
+
if (!z2.transfers || z2.transfers.length === 0)
|
|
15450
15450
|
throw o5.noPathFound(Z3, K3);
|
|
15451
|
-
if (
|
|
15452
|
-
throw o5.insufficientBalance(
|
|
15453
|
-
return this.buildFlowMatrixTx(Z3, K3,
|
|
15451
|
+
if (z2.maxFlow < q3)
|
|
15452
|
+
throw o5.insufficientBalance(q3, z2.maxFlow, Z3, K3);
|
|
15453
|
+
return this.buildFlowMatrixTx(Z3, K3, z2, G2, Y2);
|
|
15454
15454
|
}
|
|
15455
15455
|
async constructReplenish($3, J2, Q4, G2) {
|
|
15456
|
-
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), K3 = (G2 || $3).toLowerCase(),
|
|
15456
|
+
let Y2 = $3.toLowerCase(), Z3 = J2.toLowerCase(), K3 = (G2 || $3).toLowerCase(), X4 = BigInt(Q4), M2 = (await this.balance.getTokenBalances(Y2)).filter((O4) => O4.tokenOwner.toLowerCase() === Z3), j4 = 0n, N = 0n, z2 = 0n, D3 = null, H4 = null;
|
|
15457
15457
|
for (let O4 of M2)
|
|
15458
15458
|
if (O4.isWrapped)
|
|
15459
15459
|
if (O4.tokenType.includes("Demurrage"))
|
|
15460
|
-
N = BigInt(O4.attoCircles),
|
|
15460
|
+
N = BigInt(O4.attoCircles), D3 = O4.tokenAddress;
|
|
15461
15461
|
else
|
|
15462
|
-
|
|
15462
|
+
z2 = BigInt(O4.staticAttoCircles), H4 = O4.tokenAddress;
|
|
15463
15463
|
else
|
|
15464
15464
|
j4 = BigInt(O4.attoCircles);
|
|
15465
|
-
let
|
|
15466
|
-
if (j4 >=
|
|
15467
|
-
if (console.log(`✓ Already have ${Number(j4) / 1000000000000000000} CRC unwrapped (target: ${Number(
|
|
15468
|
-
let O4 = await this.hubV2.toTokenId(Z3),
|
|
15469
|
-
|
|
15465
|
+
let V2 = j4 + N + d4.attoStaticCirclesToAttoCircles(z2), B4 = [];
|
|
15466
|
+
if (j4 >= X4) {
|
|
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), 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
|
|
15472
|
-
}
|
|
15473
|
-
let
|
|
15474
|
-
if (console.log(`Current unwrapped: ${Number(j4) / 1000000000000000000} CRC`), console.log(`Target amount: ${Number(
|
|
15475
|
-
let O4 =
|
|
15476
|
-
if (N > 0n &&
|
|
15477
|
-
let
|
|
15478
|
-
|
|
15471
|
+
return B4;
|
|
15472
|
+
}
|
|
15473
|
+
let S3 = X4 - j4;
|
|
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
|
+
let O4 = S3;
|
|
15476
|
+
if (N > 0n && D3 && O4 > 0n) {
|
|
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
|
-
if (
|
|
15481
|
-
let
|
|
15482
|
-
|
|
15480
|
+
if (z2 > 0n && H4 && O4 > 0n) {
|
|
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
|
-
if (!
|
|
15497
|
+
if (!x3.transfers || x3.transfers.length === 0)
|
|
15498
15498
|
throw o5.noPathFound(Y2, K3, `No path to acquire token ${Z3}`);
|
|
15499
|
-
if (
|
|
15500
|
-
let O4 = Number(
|
|
15501
|
-
throw new o5(`Pathfinder can only provide ${O4.toFixed(6)} CRC of the ${
|
|
15499
|
+
if (x3.maxFlow < w3) {
|
|
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
|
-
|
|
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
|
|
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) {
|
|
@@ -15519,8 +15519,8 @@ class W$ {
|
|
|
15519
15519
|
let O4 = this.hubV2.trust(Z3, 0n);
|
|
15520
15520
|
c4.push({ to: O4.to, data: O4.data, value: O4.value ?? 0n });
|
|
15521
15521
|
}
|
|
15522
|
-
let
|
|
15523
|
-
return
|
|
15522
|
+
let _4 = F2 ? [] : [{ to: this.hubV2.setApprovalForAll(Y2, true).to, data: this.hubV2.setApprovalForAll(Y2, true).data, value: 0n }];
|
|
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;
|
|
@@ -15540,18 +15540,18 @@ class W$ {
|
|
|
15540
15540
|
}
|
|
15541
15541
|
_createInflationaryUnwrapAndWrapCalls($3, J2, Q4) {
|
|
15542
15542
|
let G2 = [], Y2 = [];
|
|
15543
|
-
for (let [Z3, [K3,
|
|
15544
|
-
if (
|
|
15543
|
+
for (let [Z3, [K3, X4]] of Object.entries($3)) {
|
|
15544
|
+
if (X4 !== "CrcV2_ERC20WrapperDeployed_Inflationary")
|
|
15545
15545
|
continue;
|
|
15546
|
-
let
|
|
15546
|
+
let q3 = J2.get(Z3.toLowerCase()), M2 = Q4.get(Z3.toLowerCase()) || 0n;
|
|
15547
15547
|
if (M2 === 0n)
|
|
15548
15548
|
continue;
|
|
15549
15549
|
let N = new l03({ address: Z3, rpcUrl: this.config.circlesRpcUrl }).unwrap(M2);
|
|
15550
15550
|
G2.push({ to: N.to, data: N.data, value: N.value ?? 0n });
|
|
15551
|
-
let
|
|
15552
|
-
if (
|
|
15553
|
-
let
|
|
15554
|
-
Y2.push({ to:
|
|
15551
|
+
let z2 = q3?.tokenOwner, D3 = d4.attoStaticCirclesToAttoCircles(M2) - K3;
|
|
15552
|
+
if (D3 > 0n) {
|
|
15553
|
+
let H4 = this.hubV2.wrap(z2, D3, 1);
|
|
15554
|
+
Y2.push({ to: H4.to, data: H4.data, value: H4.value ?? 0n });
|
|
15555
15555
|
}
|
|
15556
15556
|
}
|
|
15557
15557
|
return { unwrapCalls: G2, wrapCalls: Y2 };
|
|
@@ -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
|
|
15628
|
-
let Z3 = await this.findInvitePath(Q4), K3 = await this.generateInviteData([G2], false),
|
|
15629
|
-
if (
|
|
15630
|
-
throw
|
|
15631
|
-
let M2 =
|
|
15632
|
-
return await
|
|
15627
|
+
throw b4.inviteeAlreadyRegistered(Q4, G2);
|
|
15628
|
+
let Z3 = await this.findInvitePath(Q4), K3 = await this.generateInviteData([G2], false), X4 = new W$(this.config), q3 = await this.getRealInviters(Q4);
|
|
15629
|
+
if (q3.length === 0)
|
|
15630
|
+
throw b4.noPathFound(Q4, this.config.invitationModuleAddress);
|
|
15631
|
+
let M2 = q3[0].address;
|
|
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,74 +15638,74 @@ 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((
|
|
15655
|
-
if (!
|
|
15656
|
-
throw new
|
|
15657
|
-
let
|
|
15658
|
-
for (let
|
|
15659
|
-
if (
|
|
15660
|
-
|
|
15661
|
-
let
|
|
15662
|
-
if (
|
|
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
|
+
if (!X4.has(J2))
|
|
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
|
+
let M2 = [];
|
|
15658
|
+
for (let B4 of Y2)
|
|
15659
|
+
if (X4.has(B4))
|
|
15660
|
+
M2.push(B4);
|
|
15661
|
+
let j4 = [...M2, J2];
|
|
15662
|
+
if (j4.length === 0)
|
|
15663
15663
|
return [];
|
|
15664
|
-
let
|
|
15665
|
-
if (!
|
|
15664
|
+
let N = await this.pathfinder.findPath({ from: J2, to: this.config.invitationModuleAddress, useWrappedBalances: true, targetFlow: $$, toTokens: j4 });
|
|
15665
|
+
if (!N.transfers || N.transfers.length === 0)
|
|
15666
15666
|
return [];
|
|
15667
|
-
let
|
|
15668
|
-
for (let
|
|
15669
|
-
if (
|
|
15670
|
-
let
|
|
15671
|
-
|
|
15667
|
+
let z2 = new Map, D3 = this.config.invitationModuleAddress.toLowerCase();
|
|
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
|
-
let
|
|
15674
|
-
for (let [
|
|
15675
|
-
let
|
|
15676
|
-
if (
|
|
15677
|
-
|
|
15673
|
+
let H4 = [];
|
|
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
|
-
return this.orderRealInviters(
|
|
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,
|
|
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
|
-
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", ""),
|
|
15708
|
-
return
|
|
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 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),
|
|
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
|
},
|