h_test_1 0.0.24 → 0.0.25

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("../../data-structures/merkle-tree/MerkleTree.cjs"),A=require("../../data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs"),S=require("../../webworker/performTaskWithWorker.cjs"),m=require("../../webworker/worker.registry.cjs"),h=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),u=require("./fetchMerkleTreeSiblings.cjs"),H=require("../utils/amounts.utils.cjs"),R=require("../../crypto/poseidon.cjs"),C=require("../../constants/vite.constants.cjs"),_=require("./fetchOnChainRootHashes.cjs"),p=async(e,r)=>{const o=e.getRootHash();if(console.log("pre calculate access token siblings and root hash",{rootHash:o,patchedMerkleTree:e}),o===void 0)throw new Error("Root hash not available from patched merkle tree");const s=await S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,data:{accessKey:r,merkleTreeAccessTokenSerialized:e.toJSON()}}});return{accessTokenSiblings:s.accessTokenSiblings,accessTokenSiblingSides:s.accessTokenSiblingSides,rootHashAccessToken:o}},N=async(e,r,o,s,i,n)=>{console.log("hinkalDeposit sa5");const t=o.getAccessKey();console.log("hinkalDeposit sa6",{accessKey:t});const a=A.getPatchedAccessTokenMerkleTree(r,t,i,n),k=e.getRootHash();if(k===void 0)throw new Error("Root hash not available from hinkal merkle tree");let l,c;return C.isNode?(l=await p(a,t),c=await S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:s,merkleTreeSerialized:e.toJSON()}}})):[l,c]=await Promise.all([p(a,t),S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:s,merkleTreeSerialized:e.toJSON()}}})]),{inCommitmentSiblings:c.inCommitmentSiblings,inCommitmentSiblingSides:c.inCommitmentSiblingSides,accessTokenSiblings:l.accessTokenSiblings,accessTokenSiblingSides:l.accessTokenSiblingSides,rootHashHinkal:k,rootHashAccessToken:l.rootHashAccessToken}},P=async(e,r,o,s,i)=>{console.log("hinkalDeposit sa3");const n=r.getAccessKey();console.log("hinkalDeposit sa4",{accessKey:n});const t=!i||s;if(console.log("ba4",{needsPatching:t}),t){console.log("ba5");const k=W.MerkleTree.create(R.poseidonFunction,0n);console.log("ba6",{emptyMerkleTreeAccessToken:k});const l=A.getPatchedAccessTokenMerkleTree(k,n,s,i);console.log("pre calculating access token siblings and root hash",{accessKey:n});const[c,g]=await Promise.all([p(l,n),u.fetchMerkleTreeSiblings(e,o,n)]);return console.log("post calculating access token siblings and root hash",{accessTokenResult:c,siblingsResponse:g}),{inCommitmentSiblings:g.inCommitmentSiblings,inCommitmentSiblingSides:g.inCommitmentSiblingSides,accessTokenSiblings:c.accessTokenSiblings,accessTokenSiblingSides:c.accessTokenSiblingSides,rootHashHinkal:H.toBigInt(g.rootHashHinkal),rootHashAccessToken:c.rootHashAccessToken}}console.log("kaksk",{chainId:e,inputUtxosSerialized:o,accessKey:n});const a=await u.fetchMerkleTreeSiblings(e,o,n);return{inCommitmentSiblings:a.inCommitmentSiblings,inCommitmentSiblingSides:a.inCommitmentSiblingSides,accessTokenSiblings:a.accessTokenSiblings,accessTokenSiblingSides:a.accessTokenSiblingSides,rootHashHinkal:H.toBigInt(a.rootHashHinkal),rootHashAccessToken:H.toBigInt(a.rootHashAccessToken)}},I=async(e,r,o)=>{if(!r||!o)return!1;try{const s=r.getRootHash(),i=o.getRootHash();if(!s||!i)return!1;const{hinkalRootHash:n,accessTokenRootHash:t}=await _.fetchOnChainRootHashes(e);return s===n&&i===t}catch{return!1}},y=async(e,r,o,s,i,n,t)=>{const a=await I(e,n,t);return console.log("hinkalDeposit sa2",{isLocalFresh:a}),a?N(n,t,r,o,s,i):P(e,r,o,s,i)},M=async(e,r,o,s,i,n,t,a,k)=>{if(C.isNode){const{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:g,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d}=await y(e,s,i,n,t,r,o),f=await S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:i,onChainCreation:a,proverVersion:k}}});return{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:g,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d,inNullifiers:f}}else{const[{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:g,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d},f]=await Promise.all([y(e,s,i,n,t,r,o),S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:i,onChainCreation:a,proverVersion:k}}})]);return{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:g,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d,inNullifiers:f}}};exports.getDataFromWorkers=M;exports.getMerkleTreeSiblingsAndRootHashes=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("../../data-structures/merkle-tree/MerkleTree.cjs"),A=require("../../data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs"),S=require("../../webworker/performTaskWithWorker.cjs"),m=require("../../webworker/worker.registry.cjs"),h=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),u=require("./fetchMerkleTreeSiblings.cjs"),H=require("../utils/amounts.utils.cjs"),N=require("../../crypto/poseidon.cjs"),C=require("../../constants/vite.constants.cjs"),R=require("./fetchOnChainRootHashes.cjs"),p=async(o,i)=>{const e=o.getRootHash();if(console.log("sss pre calculate access token siblings and root hash",{accessKey:i,rootHash:e,patchedMerkleTree:o,tjson:o.toJSON()}),e===void 0)throw new Error("Root hash not available from patched merkle tree");const s=await S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,data:{accessKey:i,merkleTreeAccessTokenSerialized:o.toJSON()}}});return console.log({resultFromWorker:s}),{accessTokenSiblings:s.accessTokenSiblings,accessTokenSiblingSides:s.accessTokenSiblingSides,rootHashAccessToken:e}},_=async(o,i,e,s,t,n)=>{console.log("hinkalDeposit sa5");const a=e.getAccessKey();console.log("hinkalDeposit sa6",{accessKey:a});const r=A.getPatchedAccessTokenMerkleTree(i,a,t,n),k=o.getRootHash();if(k===void 0)throw new Error("Root hash not available from hinkal merkle tree");let l,c;return C.isNode?(l=await p(r,a),c=await S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:s,merkleTreeSerialized:o.toJSON()}}})):[l,c]=await Promise.all([p(r,a),S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:s,merkleTreeSerialized:o.toJSON()}}})]),{inCommitmentSiblings:c.inCommitmentSiblings,inCommitmentSiblingSides:c.inCommitmentSiblingSides,accessTokenSiblings:l.accessTokenSiblings,accessTokenSiblingSides:l.accessTokenSiblingSides,rootHashHinkal:k,rootHashAccessToken:l.rootHashAccessToken}},P=async(o,i,e,s,t)=>{console.log("hinkalDeposit sa3");const n=i.getAccessKey();console.log("hinkalDeposit sa4",{accessKey:n});const a=!t||s;if(console.log("ba4",{needsPatching:a}),a){console.log("ba5");const k=W.MerkleTree.create(N.poseidonFunction,0n);console.log("ba6",{emptyMerkleTreeAccessToken:k});const l=A.getPatchedAccessTokenMerkleTree(k,n,s,t);console.log("pre calculating access token siblings and root hash",{accessKey:n});const[c,g]=await Promise.all([p(l,n),u.fetchMerkleTreeSiblings(o,e,n)]);return console.log("post calculating access token siblings and root hash",{accessTokenResult:c,siblingsResponse:g}),{inCommitmentSiblings:g.inCommitmentSiblings,inCommitmentSiblingSides:g.inCommitmentSiblingSides,accessTokenSiblings:c.accessTokenSiblings,accessTokenSiblingSides:c.accessTokenSiblingSides,rootHashHinkal:H.toBigInt(g.rootHashHinkal),rootHashAccessToken:c.rootHashAccessToken}}console.log("kaksk",{chainId:o,inputUtxosSerialized:e,accessKey:n});const r=await u.fetchMerkleTreeSiblings(o,e,n);return{inCommitmentSiblings:r.inCommitmentSiblings,inCommitmentSiblingSides:r.inCommitmentSiblingSides,accessTokenSiblings:r.accessTokenSiblings,accessTokenSiblingSides:r.accessTokenSiblingSides,rootHashHinkal:H.toBigInt(r.rootHashHinkal),rootHashAccessToken:H.toBigInt(r.rootHashAccessToken)}},I=async(o,i,e)=>{if(!i||!e)return!1;try{const s=i.getRootHash(),t=e.getRootHash();if(!s||!t)return!1;const{hinkalRootHash:n,accessTokenRootHash:a}=await R.fetchOnChainRootHashes(o);return s===n&&t===a}catch{return!1}},y=async(o,i,e,s,t,n,a)=>{const r=await I(o,n,a);return console.log("hinkalDeposit sa2",{isLocalFresh:r}),r?_(n,a,i,e,s,t):P(o,i,e,s,t)},w=async(o,i,e,s,t,n,a,r,k)=>{if(C.isNode){const{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:g,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:f}=await y(o,s,t,n,a,i,e),d=await S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:t,onChainCreation:r,proverVersion:k}}});return{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:g,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:f,inNullifiers:d}}else{const[{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:g,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:f},d]=await Promise.all([y(o,s,t,n,a,i,e),S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:t,onChainCreation:r,proverVersion:k}}})]);return{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:g,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:f,inNullifiers:d}}};exports.getDataFromWorkers=w;exports.getMerkleTreeSiblingsAndRootHashes=y;
@@ -1,53 +1,58 @@
1
1
  import { MerkleTree as R } from "../../data-structures/merkle-tree/MerkleTree.mjs";
2
- import { getPatchedAccessTokenMerkleTree as A } from "../../data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs";
2
+ import { getPatchedAccessTokenMerkleTree as N } from "../../data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs";
3
3
  import { performTaskWithWorker as g } from "../../webworker/performTaskWithWorker.mjs";
4
4
  import { WorkerVariant as k } from "../../webworker/worker.registry.mjs";
5
5
  import { ZKProofWorkerActionType as b } from "../../webworker/zkProofWorker/zkProofWorker.types.mjs";
6
6
  import { fetchMerkleTreeSiblings as C } from "./fetchMerkleTreeSiblings.mjs";
7
7
  import { toBigInt as p } from "../utils/amounts.utils.mjs";
8
8
  import { poseidonFunction as _ } from "../../crypto/poseidon.mjs";
9
- import { isNode as N } from "../../constants/vite.constants.mjs";
9
+ import { isNode as A } from "../../constants/vite.constants.mjs";
10
10
  import { fetchOnChainRootHashes as I } from "./fetchOnChainRootHashes.mjs";
11
- const d = async (o, c) => {
11
+ const d = async (o, i) => {
12
12
  const s = o.getRootHash();
13
- if (console.log("pre calculate access token siblings and root hash", { rootHash: s, patchedMerkleTree: o }), s === void 0)
13
+ if (console.log("sss pre calculate access token siblings and root hash", {
14
+ accessKey: i,
15
+ rootHash: s,
16
+ patchedMerkleTree: o,
17
+ tjson: o.toJSON()
18
+ }), s === void 0)
14
19
  throw new Error("Root hash not available from patched merkle tree");
15
20
  const e = await g({
16
21
  type: k.ZKProof,
17
22
  payload: {
18
23
  type: b.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,
19
24
  data: {
20
- accessKey: c,
25
+ accessKey: i,
21
26
  merkleTreeAccessTokenSerialized: o.toJSON()
22
27
  }
23
28
  }
24
29
  });
25
- return {
30
+ return console.log({ resultFromWorker: e }), {
26
31
  accessTokenSiblings: e.accessTokenSiblings,
27
32
  accessTokenSiblingSides: e.accessTokenSiblingSides,
28
33
  rootHashAccessToken: s
29
34
  };
30
- }, w = async (o, c, s, e, i, n) => {
35
+ }, w = async (o, i, s, e, t, n) => {
31
36
  console.log("hinkalDeposit sa5");
32
- const t = s.getAccessKey();
33
- console.log("hinkalDeposit sa6", { accessKey: t });
34
- const a = A(
35
- c,
36
- t,
37
+ const a = s.getAccessKey();
38
+ console.log("hinkalDeposit sa6", { accessKey: a });
39
+ const c = N(
37
40
  i,
41
+ a,
42
+ t,
38
43
  n
39
44
  ), m = o.getRootHash();
40
45
  if (m === void 0)
41
46
  throw new Error("Root hash not available from hinkal merkle tree");
42
47
  let r, l;
43
- return N ? (r = await d(a, t), l = await g({
48
+ return A ? (r = await d(c, a), l = await g({
44
49
  type: k.ZKProof,
45
50
  payload: {
46
51
  type: b.CALC_COMMITMENTS_SIBLING_AND_SIDES,
47
52
  data: { inputUtxosSerialized: e, merkleTreeSerialized: o.toJSON() }
48
53
  }
49
54
  })) : [r, l] = await Promise.all([
50
- d(a, t),
55
+ d(c, a),
51
56
  g({
52
57
  type: k.ZKProof,
53
58
  payload: {
@@ -63,20 +68,20 @@ const d = async (o, c) => {
63
68
  rootHashHinkal: m,
64
69
  rootHashAccessToken: r.rootHashAccessToken
65
70
  };
66
- }, D = async (o, c, s, e, i) => {
71
+ }, D = async (o, i, s, e, t) => {
67
72
  console.log("hinkalDeposit sa3");
68
- const n = c.getAccessKey();
73
+ const n = i.getAccessKey();
69
74
  console.log("hinkalDeposit sa4", { accessKey: n });
70
- const t = !i || e;
71
- if (console.log("ba4", { needsPatching: t }), t) {
75
+ const a = !t || e;
76
+ if (console.log("ba4", { needsPatching: a }), a) {
72
77
  console.log("ba5");
73
78
  const m = R.create(_, 0n);
74
79
  console.log("ba6", { emptyMerkleTreeAccessToken: m });
75
- const r = A(
80
+ const r = N(
76
81
  m,
77
82
  n,
78
83
  e,
79
- i
84
+ t
80
85
  );
81
86
  console.log("pre calculating access token siblings and root hash", { accessKey: n });
82
87
  const [l, S] = await Promise.all([
@@ -93,39 +98,39 @@ const d = async (o, c) => {
93
98
  };
94
99
  }
95
100
  console.log("kaksk", { chainId: o, inputUtxosSerialized: s, accessKey: n });
96
- const a = await C(o, s, n);
101
+ const c = await C(o, s, n);
97
102
  return {
98
- inCommitmentSiblings: a.inCommitmentSiblings,
99
- inCommitmentSiblingSides: a.inCommitmentSiblingSides,
100
- accessTokenSiblings: a.accessTokenSiblings,
101
- accessTokenSiblingSides: a.accessTokenSiblingSides,
102
- rootHashHinkal: p(a.rootHashHinkal),
103
- rootHashAccessToken: p(a.rootHashAccessToken)
103
+ inCommitmentSiblings: c.inCommitmentSiblings,
104
+ inCommitmentSiblingSides: c.inCommitmentSiblingSides,
105
+ accessTokenSiblings: c.accessTokenSiblings,
106
+ accessTokenSiblingSides: c.accessTokenSiblingSides,
107
+ rootHashHinkal: p(c.rootHashHinkal),
108
+ rootHashAccessToken: p(c.rootHashAccessToken)
104
109
  };
105
- }, L = async (o, c, s) => {
106
- if (!c || !s)
110
+ }, L = async (o, i, s) => {
111
+ if (!i || !s)
107
112
  return !1;
108
113
  try {
109
- const e = c.getRootHash(), i = s.getRootHash();
110
- if (!e || !i)
114
+ const e = i.getRootHash(), t = s.getRootHash();
115
+ if (!e || !t)
111
116
  return !1;
112
- const { hinkalRootHash: n, accessTokenRootHash: t } = await I(o);
113
- return e === n && i === t;
117
+ const { hinkalRootHash: n, accessTokenRootHash: a } = await I(o);
118
+ return e === n && t === a;
114
119
  } catch {
115
120
  return !1;
116
121
  }
117
- }, y = async (o, c, s, e, i, n, t) => {
118
- const a = await L(o, n, t);
119
- return console.log("hinkalDeposit sa2", { isLocalFresh: a }), a ? w(
122
+ }, y = async (o, i, s, e, t, n, a) => {
123
+ const c = await L(o, n, a);
124
+ return console.log("hinkalDeposit sa2", { isLocalFresh: c }), c ? w(
120
125
  n,
121
- t,
122
- c,
126
+ a,
127
+ i,
123
128
  s,
124
129
  e,
125
- i
126
- ) : D(o, c, s, e, i);
127
- }, v = async (o, c, s, e, i, n, t, a, m) => {
128
- if (N) {
130
+ t
131
+ ) : D(o, i, s, e, t);
132
+ }, J = async (o, i, s, e, t, n, a, c, m) => {
133
+ if (A) {
129
134
  const {
130
135
  inCommitmentSiblings: r,
131
136
  inCommitmentSiblingSides: l,
@@ -136,16 +141,16 @@ const d = async (o, c) => {
136
141
  } = await y(
137
142
  o,
138
143
  e,
139
- i,
140
- n,
141
144
  t,
142
- c,
145
+ n,
146
+ a,
147
+ i,
143
148
  s
144
149
  ), H = await g({
145
150
  type: k.ZKProof,
146
151
  payload: {
147
152
  type: b.BUILD_IN_NULLIFIERS,
148
- data: { inputUtxosSerialized: i, onChainCreation: a, proverVersion: m }
153
+ data: { inputUtxosSerialized: t, onChainCreation: c, proverVersion: m }
149
154
  }
150
155
  });
151
156
  return {
@@ -172,17 +177,17 @@ const d = async (o, c) => {
172
177
  y(
173
178
  o,
174
179
  e,
175
- i,
176
- n,
177
180
  t,
178
- c,
181
+ n,
182
+ a,
183
+ i,
179
184
  s
180
185
  ),
181
186
  g({
182
187
  type: k.ZKProof,
183
188
  payload: {
184
189
  type: b.BUILD_IN_NULLIFIERS,
185
- data: { inputUtxosSerialized: i, onChainCreation: a, proverVersion: m }
190
+ data: { inputUtxosSerialized: t, onChainCreation: c, proverVersion: m }
186
191
  }
187
192
  })
188
193
  ]);
@@ -198,6 +203,6 @@ const d = async (o, c) => {
198
203
  }
199
204
  };
200
205
  export {
201
- v as getDataFromWorkers,
206
+ J as getDataFromWorkers,
202
207
  y as getMerkleTreeSiblingsAndRootHashes
203
208
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h_test_1",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "homepage": "hinkal.io",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../constants/chains.constants.cjs"),h=require("../constants/vite.constants.cjs"),w=require("./workerFactory.cjs"),y=async t=>{const e=await w.WorkerFactory.getWebWorker(t.type);return new Promise((r,s)=>{let n={};if(typeof window<"u"&&window.location){const{origin:o,protocol:i,host:c,port:d,hostname:m,href:p}=window.location;n={origin:o,protocol:i,host:c,port:d,hostname:m,href:p}}e.onmessage=o=>{r(o.data),e.terminate()},e.onerror=o=>{s(o),e.terminate()};const a={payload:t.payload,metadata:{hostLocation:n,constants:{chains:{chainIds:l.chainIds},isDevelopment:h.isDevelopment}}};e.postMessage(a)})};exports.performTaskWithWorker=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("../constants/chains.constants.cjs"),h=require("../constants/vite.constants.cjs"),k=require("./workerFactory.cjs"),d=async r=>{const e=await k.WorkerFactory.getWebWorker(r.type);return console.log("performTaskWithWorker a1",{worker:e,workerData:r}),new Promise((s,a)=>{let t={};if(typeof window<"u"&&window.location){const{origin:o,protocol:i,host:c,port:l,hostname:m,href:p}=window.location;t={origin:o,protocol:i,host:c,port:l,hostname:m,href:p}}e.onmessage=o=>{console.log("performTaskWithWorker a3",{result:o}),s(o.data),e.terminate()},e.onerror=o=>{console.error("performTaskWithWorker a2",{err:o}),a(o),e.terminate()};const n={payload:r.payload,metadata:{hostLocation:t,constants:{chains:{chainIds:W.chainIds},isDevelopment:h.isDevelopment}}};console.log("performTaskWithWorker a4",{message:n}),e.postMessage(n)})};exports.performTaskWithWorker=d;
@@ -1,41 +1,41 @@
1
- import { chainIds as f } from "../constants/chains.constants.mjs";
2
- import { isDevelopment as w } from "../constants/vite.constants.mjs";
1
+ import { chainIds as W } from "../constants/chains.constants.mjs";
2
+ import { isDevelopment as f } from "../constants/vite.constants.mjs";
3
3
  import { WorkerFactory as h } from "./workerFactory.mjs";
4
- const W = async (e) => {
5
- const o = await h.getWebWorker(e.type);
6
- return new Promise((n, a) => {
7
- let r = {};
4
+ const w = async (r) => {
5
+ const e = await h.getWebWorker(r.type);
6
+ return console.log("performTaskWithWorker a1", { worker: e, workerData: r }), new Promise((n, s) => {
7
+ let t = {};
8
8
  if (typeof window < "u" && window.location) {
9
- const { origin: t, protocol: i, host: m, port: c, hostname: p, href: d } = window.location;
10
- r = {
11
- origin: t,
9
+ const { origin: o, protocol: i, host: m, port: c, hostname: p, href: l } = window.location;
10
+ t = {
11
+ origin: o,
12
12
  protocol: i,
13
13
  host: m,
14
14
  port: c,
15
15
  hostname: p,
16
- href: d
16
+ href: l
17
17
  };
18
18
  }
19
- o.onmessage = (t) => {
20
- n(t.data), o.terminate();
21
- }, o.onerror = (t) => {
22
- a(t), o.terminate();
19
+ e.onmessage = (o) => {
20
+ console.log("performTaskWithWorker a3", { result: o }), n(o.data), e.terminate();
21
+ }, e.onerror = (o) => {
22
+ console.error("performTaskWithWorker a2", { err: o }), s(o), e.terminate();
23
23
  };
24
- const s = {
25
- payload: e.payload,
24
+ const a = {
25
+ payload: r.payload,
26
26
  metadata: {
27
- hostLocation: r,
27
+ hostLocation: t,
28
28
  constants: {
29
29
  chains: {
30
- chainIds: f
30
+ chainIds: W
31
31
  },
32
- isDevelopment: w
32
+ isDevelopment: f
33
33
  }
34
34
  }
35
35
  };
36
- o.postMessage(s);
36
+ console.log("performTaskWithWorker a4", { message: a }), e.postMessage(a);
37
37
  });
38
38
  };
39
39
  export {
40
- W as performTaskWithWorker
40
+ w as performTaskWithWorker
41
41
  };
@@ -1 +1 @@
1
- "use strict";const r=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-2a1CGTor.js").href:new URL("../../assets/zkProofWorkerLauncher-2a1CGTor.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=r;
1
+ "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-DQUaX0hI.js").href:new URL("../../assets/zkProofWorkerLauncher-DQUaX0hI.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
@@ -1,4 +1,4 @@
1
- const r = "" + new URL("../../assets/zkProofWorkerLauncher-2a1CGTor.js", import.meta.url).href;
1
+ const r = "" + new URL("../../assets/zkProofWorkerLauncher-DQUaX0hI.js", import.meta.url).href;
2
2
  export {
3
3
  r as default
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("../../crypto/preProcessing.cjs"),S=require("../../data-structures/utxo/Utxo.cjs"),m=require("../../functions/snarkjs/common.snarkjs.cjs"),C=require("../workerProxy.cjs"),d=require("./zkProofWorker.types.cjs"),u=require("../../functions/utils/merkleTree.utils.cjs"),c=new C.WorkerProxy,k=o=>{const{inputUtxosSerialized:e,merkleTreeSerialized:t}=o.data,a=u.contructMerkleTreeFromSerialized(t),s=e.map(n=>n.map(l=>new S.Utxo(l))),{inCommitmentSiblings:r,inCommitmentSiblingSides:i}=m.calcCommitmentsSiblingAndSides(s,a);c.postMessageToMainThread({inCommitmentSiblings:r,inCommitmentSiblingSides:i})},p=o=>{const{accessKey:e,merkleTreeAccessTokenSerialized:t}=o.data;console.log("worker code a1",{accessKey:e,merkleTreeAccessTokenSerialized:t});const a=u.contructMerkleTreeFromSerialized(t);console.log("worker code a2",{merkleTree:a});const{accessTokenSiblings:s,accessTokenSiblingSides:r}=m.calcAccessTokenSiblingsAndSides(e,a);console.log("worker code a3",{accessTokenSiblings:s,accessTokenSiblingSides:r}),c.postMessageToMainThread({accessTokenSiblings:s,accessTokenSiblingSides:r})},T=o=>{const{inputUtxosSerialized:e,onChainCreation:t,proverVersion:a}=o.data,s=e.map(i=>i.map(n=>new S.Utxo(n)));let r=[];a==="v1x0"?r=s.map((i,n)=>i.map(l=>t[n]?"0":l.getNullifier())):r=s.map(i=>i.map(n=>n.amount===0n?"0":n.getNullifier())),c.postMessageToMainThread(r)},g=async o=>{try{await A.preProcessing();const{type:e}=o.payload;switch(e){case d.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES:k(o.payload);return;case d.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES:p(o.payload);return;case d.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS:T(o.payload);return;default:throw Error(`Unknown worker message type ${e}`)}}catch(e){console.error(e),c.postErrorToMainThread(e)}};c.attachWorkerSideOnMessage(g);exports.default=c;exports.handleBuildInNullifiers=T;exports.handleCalcAccessTokenSiblingAndSides=p;exports.handleCalcCommitmentsSiblingAndSides=k;exports.onWorkerMessage=g;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("../../crypto/preProcessing.cjs"),S=require("../../data-structures/utxo/Utxo.cjs"),m=require("../../functions/snarkjs/common.snarkjs.cjs"),C=require("../workerProxy.cjs"),d=require("./zkProofWorker.types.cjs"),k=require("../../functions/utils/merkleTree.utils.cjs"),c=new C.WorkerProxy,u=o=>{const{inputUtxosSerialized:e,merkleTreeSerialized:t}=o.data,a=k.contructMerkleTreeFromSerialized(t),s=e.map(n=>n.map(l=>new S.Utxo(l))),{inCommitmentSiblings:r,inCommitmentSiblingSides:i}=m.calcCommitmentsSiblingAndSides(s,a);c.postMessageToMainThread({inCommitmentSiblings:r,inCommitmentSiblingSides:i})},p=o=>{const{accessKey:e,merkleTreeAccessTokenSerialized:t}=o.data;console.log("worker code a1",{accessKey:e,merkleTreeAccessTokenSerialized:t});const a=k.contructMerkleTreeFromSerialized(t);console.log("worker code a2",{merkleTree:a});const{accessTokenSiblings:s,accessTokenSiblingSides:r}=m.calcAccessTokenSiblingsAndSides(e,a);console.log("worker code a3",{accessTokenSiblings:s,accessTokenSiblingSides:r}),c.postMessageToMainThread({accessTokenSiblings:s,accessTokenSiblingSides:r})},g=o=>{const{inputUtxosSerialized:e,onChainCreation:t,proverVersion:a}=o.data,s=e.map(i=>i.map(n=>new S.Utxo(n)));let r=[];a==="v1x0"?r=s.map((i,n)=>i.map(l=>t[n]?"0":l.getNullifier())):r=s.map(i=>i.map(n=>n.amount===0n?"0":n.getNullifier())),c.postMessageToMainThread(r)},T=async o=>{console.log("worker code onWorkerMessage",{data:o});try{await A.preProcessing();const{type:e}=o.payload;switch(e){case d.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES:u(o.payload);return;case d.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES:p(o.payload);return;case d.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS:g(o.payload);return;default:throw Error(`Unknown worker message type ${e}`)}}catch(e){console.error(e),c.postErrorToMainThread(e)}};c.attachWorkerSideOnMessage(T);exports.default=c;exports.handleBuildInNullifiers=g;exports.handleCalcAccessTokenSiblingAndSides=p;exports.handleCalcCommitmentsSiblingAndSides=u;exports.onWorkerMessage=T;
@@ -1,22 +1,22 @@
1
1
  import { preProcessing as S } from "../../crypto/preProcessing.mjs";
2
2
  import { Utxo as d } from "../../data-structures/utxo/Utxo.mjs";
3
- import { calcCommitmentsSiblingAndSides as T, calcAccessTokenSiblingsAndSides as g } from "../../functions/snarkjs/common.snarkjs.mjs";
4
- import { WorkerProxy as k } from "../workerProxy.mjs";
3
+ import { calcCommitmentsSiblingAndSides as g, calcAccessTokenSiblingsAndSides as k } from "../../functions/snarkjs/common.snarkjs.mjs";
4
+ import { WorkerProxy as T } from "../workerProxy.mjs";
5
5
  import { ZKProofWorkerActionType as m } from "./zkProofWorker.types.mjs";
6
6
  import { contructMerkleTreeFromSerialized as p } from "../../functions/utils/merkleTree.utils.mjs";
7
- const c = new k(), u = (o) => {
7
+ const c = new T(), u = (o) => {
8
8
  const { inputUtxosSerialized: e, merkleTreeSerialized: t } = o.data, a = p(t), s = e.map(
9
9
  (n) => n.map((l) => new d(l))
10
- ), { inCommitmentSiblings: r, inCommitmentSiblingSides: i } = T(s, a);
10
+ ), { inCommitmentSiblings: r, inCommitmentSiblingSides: i } = g(s, a);
11
11
  c.postMessageToMainThread({ inCommitmentSiblings: r, inCommitmentSiblingSides: i });
12
12
  }, C = (o) => {
13
13
  const { accessKey: e, merkleTreeAccessTokenSerialized: t } = o.data;
14
14
  console.log("worker code a1", { accessKey: e, merkleTreeAccessTokenSerialized: t });
15
15
  const a = p(t);
16
16
  console.log("worker code a2", { merkleTree: a });
17
- const { accessTokenSiblings: s, accessTokenSiblingSides: r } = g(e, a);
17
+ const { accessTokenSiblings: s, accessTokenSiblingSides: r } = k(e, a);
18
18
  console.log("worker code a3", { accessTokenSiblings: s, accessTokenSiblingSides: r }), c.postMessageToMainThread({ accessTokenSiblings: s, accessTokenSiblingSides: r });
19
- }, f = (o) => {
19
+ }, M = (o) => {
20
20
  const { inputUtxosSerialized: e, onChainCreation: t, proverVersion: a } = o.data, s = e.map(
21
21
  (i) => i.map((n) => new d(n))
22
22
  );
@@ -24,7 +24,8 @@ const c = new k(), u = (o) => {
24
24
  a === "v1x0" ? r = s.map(
25
25
  (i, n) => i.map((l) => t[n] ? "0" : l.getNullifier())
26
26
  ) : r = s.map((i) => i.map((n) => n.amount === 0n ? "0" : n.getNullifier())), c.postMessageToMainThread(r);
27
- }, A = async (o) => {
27
+ }, f = async (o) => {
28
+ console.log("worker code onWorkerMessage", { data: o });
28
29
  try {
29
30
  await S();
30
31
  const { type: e } = o.payload;
@@ -36,7 +37,7 @@ const c = new k(), u = (o) => {
36
37
  C(o.payload);
37
38
  return;
38
39
  case m.BUILD_IN_NULLIFIERS:
39
- f(o.payload);
40
+ M(o.payload);
40
41
  return;
41
42
  default:
42
43
  throw Error(`Unknown worker message type ${e}`);
@@ -45,11 +46,11 @@ const c = new k(), u = (o) => {
45
46
  console.error(e), c.postErrorToMainThread(e);
46
47
  }
47
48
  };
48
- c.attachWorkerSideOnMessage(A);
49
+ c.attachWorkerSideOnMessage(f);
49
50
  export {
50
51
  c as default,
51
- f as handleBuildInNullifiers,
52
+ M as handleBuildInNullifiers,
52
53
  C as handleCalcAccessTokenSiblingAndSides,
53
54
  u as handleCalcCommitmentsSiblingAndSides,
54
- A as onWorkerMessage
55
+ f as onWorkerMessage
55
56
  };