@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.
@@ -1,22 +1,22 @@
1
- import { U as l, d as p, a as T, b as f, c as I, g as y, l as h, p as m } from "./zkProofWorkerLogic-BwAAGTST.js";
2
- import "./zkProofWorkerLauncher-D1ef-Gxp.js";
3
- const U = (e) => {
4
- const t = p.decode(
1
+ import { B as U } from "./zkProofWorkerLauncher-B54jpyIs.js";
2
+ import { U as l, i as T, h as I, j as f, k as y, l as m, m as h, p as S } from "./zkProofWorkerLogic-g413cUJh.js";
3
+ const g = (e) => {
4
+ const t = T.decode(
5
5
  ["uint256", "address", "tuple(uint256, uint256, uint256, uint256)", "uint256", "uint256"],
6
6
  e
7
- ), o = t[0].toBigInt(), r = t[1], s = t[2][0].toBigInt(), n = t[2][1].toHexString(), a = t[2][2].toBigInt(), c = t[2][3].toBigInt(), i = t[3].toString(), g = t[4].toNumber();
7
+ ), o = t[0].toBigInt(), r = t[1], s = t[2][0].toBigInt(), n = t[2][1].toHexString(), a = t[2][2].toBigInt(), i = t[2][3].toBigInt(), c = t[3].toString(), p = t[4].toNumber();
8
8
  return {
9
9
  amount: o,
10
10
  erc20TokenAddress: r,
11
11
  randomization: s,
12
12
  stealthAddress: n,
13
13
  H0: a,
14
- H1: c,
15
- timeStamp: i,
16
- tokenId: g
14
+ H1: i,
15
+ timeStamp: c,
16
+ tokenId: p
17
17
  };
18
- }, S = (e, t) => {
19
- const { amount: o, erc20TokenAddress: r, timeStamp: s, tokenId: n, randomization: a } = U(e);
18
+ }, _ = (e, t) => {
19
+ const { amount: o, erc20TokenAddress: r, timeStamp: s, tokenId: n, randomization: a } = g(e);
20
20
  return {
21
21
  amount: o,
22
22
  erc20TokenAddress: r,
@@ -25,72 +25,72 @@ const U = (e) => {
25
25
  randomization: a,
26
26
  shieldedPrivateKey: t
27
27
  };
28
- }, _ = (e, t) => {
29
- const { randomization: o, H0: r, H1: s } = U(e), n = l.checkSignature(o, r, s, t);
28
+ }, x = (e, t) => {
29
+ const { randomization: o, H0: r, H1: s } = g(e), n = l.checkSignature(o, r, s, t);
30
30
  if (!n)
31
31
  throw new Error("UTXO doesn't belong to user");
32
32
  return n;
33
33
  };
34
34
  var d = /* @__PURE__ */ ((e) => (e[e.BATCH_FILTER_UTXOS_WITH_NULLIFIER = 0] = "BATCH_FILTER_UTXOS_WITH_NULLIFIER", e[e.BUILD_UTXOS = 1] = "BUILD_UTXOS", e[e.DECIPHER_OUTPUTS = 2] = "DECIPHER_OUTPUTS", e))(d || {});
35
- const u = new T(), x = async ({ data: e }) => {
35
+ const u = new I(), E = async ({ data: e }) => {
36
36
  const { utxos: t, nullifiers: o } = e, r = t.filter((s) => {
37
37
  const n = new f(s);
38
38
  return !o.has(n.getNullifier());
39
39
  });
40
40
  u.postMessageToMainThread(r);
41
- }, E = async ({ data: e }) => {
41
+ }, v = async ({ data: e }) => {
42
42
  const t = new l(e.signature), o = t.getShieldedPrivateKey(), r = e.encryptedOutputs.map((s) => {
43
43
  try {
44
- return s.isPositive ? I(Buffer.from(s.value.slice(2), "hex"), t) : S(s.value, o);
44
+ return s.isPositive ? y(U.from(s.value.slice(2), "hex"), t) : _(s.value, o);
45
45
  } catch {
46
46
  return;
47
47
  }
48
48
  }).filter((s) => s !== void 0);
49
49
  u.postMessageToMainThread(r);
50
- }, v = async ({ data: e }) => {
50
+ }, P = async ({ data: e }) => {
51
51
  const t = new l(e.signature), o = [], { encryptedOutputs: r } = e;
52
52
  let { lastOutput: s } = e;
53
53
  for (let n = 0; n < r.length; n += 1) {
54
54
  const a = r[n];
55
55
  if (s = a.value, a.isPositive)
56
56
  try {
57
- const c = y(Buffer.from(s.slice(2), "hex"), t);
58
- if (!c.erc20TokenAddress || !c.amount || !c.stealthAddress)
57
+ const i = m(U.from(s.slice(2), "hex"), t);
58
+ if (!i.erc20TokenAddress || !i.amount || !i.stealthAddress)
59
59
  throw Error("bruh");
60
- o.map((i) => i.value).includes(a.value) || o.push(a);
60
+ o.map((c) => c.value).includes(a.value) || o.push(a);
61
61
  } catch {
62
62
  h("Utxo not decrypted");
63
63
  }
64
64
  else
65
65
  try {
66
- _(s, t.getShieldedPrivateKey()) && (o.map((i) => i.value).includes(a.value) || o.push(a));
66
+ x(s, t.getShieldedPrivateKey()) && (o.map((c) => c.value).includes(a.value) || o.push(a));
67
67
  } catch {
68
68
  h("Utxo not decoded");
69
69
  }
70
70
  }
71
71
  u.postMessageToMainThread({ additionalEncryptedOutputs: o, lastOutput: s });
72
- }, P = async (e) => {
73
- await m();
72
+ }, B = async (e) => {
73
+ await S();
74
74
  const { type: t } = e.payload;
75
75
  switch (t) {
76
76
  case d.BATCH_FILTER_UTXOS_WITH_NULLIFIER:
77
- x(e.payload);
77
+ E(e.payload);
78
78
  return;
79
79
  case d.BUILD_UTXOS:
80
- E(e.payload);
80
+ v(e.payload);
81
81
  return;
82
82
  case d.DECIPHER_OUTPUTS:
83
- v(e.payload);
83
+ P(e.payload);
84
84
  return;
85
85
  default:
86
86
  throw Error(`Unknown worker message type ${t}`);
87
87
  }
88
88
  };
89
- u.attachWorkerSideOnMessage(P);
89
+ u.attachWorkerSideOnMessage(B);
90
90
  export {
91
91
  u as default,
92
- E as handleBuildUtxosMessage,
93
- v as handleDecipherMessage,
94
- x as handleFilterUtxosWithNullifier,
95
- P as onWorkerMessage
92
+ v as handleBuildUtxosMessage,
93
+ P as handleDecipherMessage,
94
+ E as handleFilterUtxosWithNullifier,
95
+ B as onWorkerMessage
96
96
  };