@hinkal/common 0.0.17 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ import { U as y, l as h, m as f, B as p, n as U, o as g, q as d, s as x, k as T, t as u } from "./index-CRZ_sTGy.js";
2
+ import { W as v } from "./workerProxy-DTKGeJe4.js";
3
+ const i = new v(), k = async ({ data: e }) => {
4
+ const { utxos: t, nullifiers: r } = e, o = t.filter((s) => {
5
+ const c = new y(s);
6
+ return !r.has(c.getNullifier());
7
+ });
8
+ i.postMessageToMainThread(o);
9
+ }, m = async ({ data: e }) => {
10
+ const t = new h(e.signature), r = t.getShieldedPrivateKey(), o = e.encryptedOutputs.map((s) => {
11
+ try {
12
+ return s.isPositive ? f(p.from(s.value.slice(2), "hex"), t) : U(s.value, r);
13
+ } catch {
14
+ return;
15
+ }
16
+ }).filter((s) => s !== void 0);
17
+ i.postMessageToMainThread(o);
18
+ }, w = async ({ data: e }) => {
19
+ const t = new h(e.signature), r = [], { encryptedOutputs: o } = e;
20
+ let { lastOutput: s } = e;
21
+ for (let c = 0; c < o.length; c += 1) {
22
+ const a = o[c];
23
+ if (s = a.value, a.isPositive)
24
+ try {
25
+ const n = g(p.from(s.slice(2), "hex"), t);
26
+ if (!n.erc20TokenAddress || !n.amount || !n.stealthAddress)
27
+ throw Error("bruh");
28
+ r.map((l) => l.value).includes(a.value) || r.push(a);
29
+ } catch {
30
+ d("Utxo not decrypted");
31
+ }
32
+ else
33
+ try {
34
+ x(s, t.getShieldedPrivateKey()) && (r.map((l) => l.value).includes(a.value) || r.push(a));
35
+ } catch {
36
+ d("Utxo not decoded");
37
+ }
38
+ }
39
+ i.postMessageToMainThread({ additionalEncryptedOutputs: r, lastOutput: s });
40
+ }, M = async (e) => {
41
+ await T();
42
+ const { type: t } = e.payload;
43
+ switch (t) {
44
+ case u.BATCH_FILTER_UTXOS_WITH_NULLIFIER:
45
+ k(e.payload);
46
+ return;
47
+ case u.BUILD_UTXOS:
48
+ m(e.payload);
49
+ return;
50
+ case u.DECIPHER_OUTPUTS:
51
+ w(e.payload);
52
+ return;
53
+ default:
54
+ throw Error(`Unknown worker message type ${t}`);
55
+ }
56
+ };
57
+ i.attachWorkerSideOnMessage(M);
58
+ export {
59
+ i as default,
60
+ m as handleBuildUtxosMessage,
61
+ w as handleDecipherMessage,
62
+ k as handleFilterUtxosWithNullifier,
63
+ M as onWorkerMessage
64
+ };
@@ -0,0 +1,9 @@
1
+ import { W as r } from "./index-CRZ_sTGy.js";
2
+ const o = "" + new URL("assets/zkProofWorkerLauncher-B54jpyIs.js", import.meta.url).href, e = "" + new URL("assets/snarkjsWorkerLauncher-Cxayz-rO.js", import.meta.url).href, s = "" + new URL("assets/utxoWorkerLauncher-949gA7j-.js", import.meta.url).href, a = {
3
+ [r.ZKProof]: o,
4
+ [r.SnarkJS]: e,
5
+ [r.UTXO]: s
6
+ };
7
+ export {
8
+ a as workerViteURL
9
+ };
@@ -1,4 +1,5 @@
1
- class i {
1
+ import { p as s } from "./index-CRZ_sTGy.js";
2
+ class r {
2
3
  isNode = !1;
3
4
  /**
4
5
  * This allow browser or main thread to listen for worker response message
@@ -18,7 +19,7 @@ class i {
18
19
  return this._eventEmitter = new e(), this._eventEmitter;
19
20
  }
20
21
  constructor() {
21
- this.isNode = typeof process < "u" && process.versions != null && process.versions.node != null;
22
+ this.isNode = typeof s < "u" && s.versions != null && s.versions.node != null;
22
23
  }
23
24
  terminate() {
24
25
  }
@@ -50,5 +51,5 @@ class i {
50
51
  }
51
52
  }
52
53
  export {
53
- i as W
54
+ r as W
54
55
  };
@@ -1,6 +1,6 @@
1
- import { M as p, p as g, U as T, a as u, b as I, d as k, Z as m, g as C } from "./index-DVX9ShLf.js";
2
- import { W as M } from "./workerProxy-BDj498Ht.js";
3
- const d = new M(), A = (e) => {
1
+ import { M as p, h as g, U as T, i as k, j as u, k as I, Z as m, l as C } from "./index-CRZ_sTGy.js";
2
+ import { W as M } from "./workerProxy-DTKGeJe4.js";
3
+ const d = new M(), h = (e) => {
4
4
  const { inputUtxosSerialized: s, merkleTreeSerialized: n } = e.data, l = n.tree, a = new Map(
5
5
  Object.entries(l).map(([r, c]) => [BigInt(r), BigInt(c)])
6
6
  ), t = p.createWithData(
@@ -12,9 +12,9 @@ const d = new M(), A = (e) => {
12
12
  0n
13
13
  ), i = s.map(
14
14
  (r) => r.map((c) => new T(c))
15
- ), { inCommitmentSiblings: o, inCommitmentSiblingSides: S } = u(i, t);
15
+ ), { inCommitmentSiblings: o, inCommitmentSiblingSides: S } = k(i, t);
16
16
  d.postMessageToMainThread({ inCommitmentSiblings: o, inCommitmentSiblingSides: S });
17
- }, h = (e) => {
17
+ }, A = (e) => {
18
18
  const { userSignature: s, merkleTreeAccessTokenSerialized: n } = e.data, l = new C(s), a = n.tree, t = new Map(
19
19
  Object.entries(a).map(([r, c]) => [BigInt(r), BigInt(c)])
20
20
  ), i = p.createWithData(
@@ -24,7 +24,7 @@ const d = new M(), A = (e) => {
24
24
  g,
25
25
  25n,
26
26
  0n
27
- ), { accessTokenSiblings: o, accessTokenSiblingSides: S } = I(l, i);
27
+ ), { accessTokenSiblings: o, accessTokenSiblingSides: S } = u(l, i);
28
28
  d.postMessageToMainThread({ accessTokenSiblings: o, accessTokenSiblingSides: S });
29
29
  }, w = (e) => {
30
30
  const { inputUtxosSerialized: s, onChainCreation: n } = e.data, a = s.map(
@@ -34,14 +34,14 @@ const d = new M(), A = (e) => {
34
34
  );
35
35
  d.postMessageToMainThread(a);
36
36
  }, y = async (e) => {
37
- await k();
37
+ await I();
38
38
  const { type: s } = e.payload;
39
39
  switch (s) {
40
40
  case m.CALC_COMMITMENTS_SIBLING_AND_SIDES:
41
- A(e.payload);
41
+ h(e.payload);
42
42
  return;
43
43
  case m.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES:
44
- h(e.payload);
44
+ A(e.payload);
45
45
  return;
46
46
  case m.BUILD_IN_NULLIFIERS:
47
47
  w(e.payload);
@@ -54,7 +54,7 @@ d.attachWorkerSideOnMessage(y);
54
54
  export {
55
55
  d as default,
56
56
  w as handleBuildInNullifiers,
57
- h as handleCalcAccessTokenSiblingAndSides,
58
- A as handleCalcCommitmentsSiblingAndSides,
57
+ A as handleCalcAccessTokenSiblingAndSides,
58
+ h as handleCalcCommitmentsSiblingAndSides,
59
59
  y as onWorkerMessage
60
60
  };