@hinkal/common 0.1.33 → 0.1.34

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.
Files changed (53) hide show
  1. package/constants/fees.constants.cjs +1 -1
  2. package/constants/fees.constants.mjs +22 -22
  3. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  4. package/data-structures/Hinkal/Hinkal.d.ts +1 -0
  5. package/data-structures/Hinkal/Hinkal.mjs +13 -10
  6. package/data-structures/Hinkal/IHinkal.d.ts +2 -1
  7. package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
  8. package/data-structures/Hinkal/hinkalActionBeefy.mjs +18 -20
  9. package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
  10. package/data-structures/Hinkal/hinkalActionConvex.mjs +18 -21
  11. package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
  12. package/data-structures/Hinkal/hinkalActionLidoEth.mjs +31 -31
  13. package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
  14. package/data-structures/Hinkal/hinkalActionPendle.mjs +77 -80
  15. package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
  16. package/data-structures/Hinkal/hinkalActionPendleLP.mjs +34 -34
  17. package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
  18. package/data-structures/Hinkal/hinkalActionStake.mjs +48 -52
  19. package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
  20. package/data-structures/Hinkal/hinkalActionVolatile.mjs +38 -44
  21. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  22. package/data-structures/Hinkal/hinkalDeposit.mjs +27 -28
  23. package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -4
  24. package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +11 -16
  25. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  26. package/data-structures/transactions-manager/TransactionsManager.mjs +66 -74
  27. package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
  28. package/data-structures/transactions-manager/history/getVolatileData.mjs +13 -13
  29. package/data-structures/volatile-helper/VolatileHelper.cjs +1 -1
  30. package/data-structures/volatile-helper/VolatileHelper.mjs +60 -60
  31. package/functions/pre-transaction/getFlatFees.cjs +1 -1
  32. package/functions/pre-transaction/getFlatFees.mjs +42 -42
  33. package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
  34. package/functions/pre-transaction/process-gas-estimates.mjs +17 -26
  35. package/functions/protocols/pendle.helpers.cjs +1 -1
  36. package/functions/protocols/pendle.helpers.mjs +27 -27
  37. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  38. package/functions/snarkjs/constructGeneralZkProof.mjs +35 -37
  39. package/functions/utils/cacheFunctions.cjs +1 -1
  40. package/functions/utils/cacheFunctions.mjs +27 -30
  41. package/functions/web3/events/getShieldedBalance.cjs +2 -2
  42. package/functions/web3/events/getShieldedBalance.mjs +25 -25
  43. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  44. package/functions/web3/functionCalls/transactCallDirect.mjs +15 -15
  45. package/functions/web3/runContractFunction.cjs +1 -1
  46. package/functions/web3/runContractFunction.mjs +37 -37
  47. package/functions/web3/uniswapAPI.cjs +1 -1
  48. package/functions/web3/uniswapAPI.mjs +28 -28
  49. package/package.json +1 -1
  50. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  51. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  52. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  53. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +16 -17
@@ -1,6 +1,6 @@
1
- import { UserFriendlyErrorCodes as l, transactionErrorCodes as g } from "../../error-handling/error-codes.constants.mjs";
1
+ import { UserFriendlyErrorCodes as g, transactionErrorCodes as T } from "../../error-handling/error-codes.constants.mjs";
2
2
  import "ethers";
3
- import { getErrorMessage as T } from "../../error-handling/get-error.message.mjs";
3
+ import { getErrorMessage as p } from "../../error-handling/get-error.message.mjs";
4
4
  import "axios";
5
5
  import "../../constants/chains.constants.mjs";
6
6
  import "../../constants/vite.constants.mjs";
@@ -9,70 +9,70 @@ import "../../types/transactions.types.mjs";
9
9
  import "../../types/curve.types.mjs";
10
10
  import "circomlibjs";
11
11
  import "../../constants/reorg-depths.constants.mjs";
12
- const p = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
12
+ const w = 5e4, l = 1, P = 11, d = 15, m = async (o, e) => {
13
13
  try {
14
- const t = await a.getFeeData(), s = e === 0 ? P : d, r = t.gasPrice?.mul(s).div(10) ?? void 0;
15
- return console.log("getGasPrice , ", r?.toBigInt(), { gasPremiumType: e }), r;
14
+ const t = await o.getFeeData(), a = e === 0 ? P : d;
15
+ return t.gasPrice?.mul(a).div(10) ?? void 0;
16
16
  } catch (t) {
17
17
  console.log("getGasPrice error: ", { err: t });
18
18
  return;
19
19
  }
20
- }, E = (a, e, t) => new Promise((s, r) => {
21
- const n = setTimeout(() => {
22
- r(new Error(g.TRANSACTION_TIMEOUT));
20
+ }, E = (o, e, t) => new Promise((a, s) => {
21
+ const i = setTimeout(() => {
22
+ s(new Error(T.TRANSACTION_TIMEOUT));
23
23
  }, t);
24
- a.wait(e).then((o) => {
25
- clearTimeout(n), s(o);
26
- }).catch((o) => {
27
- clearTimeout(n), r(o);
24
+ o.wait(e).then((r) => {
25
+ clearTimeout(i), a(r);
26
+ }).catch((r) => {
27
+ clearTimeout(i), s(r);
28
28
  });
29
29
  }), u = async ({
30
- contractFunction: a,
30
+ contractFunction: o,
31
31
  args: e,
32
32
  gasPrice: t,
33
- gasLimit: s,
34
- nonce: r,
35
- confirmations: n,
36
- waitTime: o
33
+ gasLimit: a,
34
+ nonce: s,
35
+ confirmations: i,
36
+ waitTime: r
37
37
  }) => {
38
- const i = await a(...e, {
38
+ const n = await o(...e, {
39
39
  type: 0,
40
- gasLimit: s,
40
+ gasLimit: a,
41
41
  gasPrice: t,
42
- nonce: r
42
+ nonce: s
43
43
  });
44
- return console.log("runTransaction: ", i?.hash), await E(
45
- i,
46
- n ?? w,
47
- o ?? p
44
+ return await E(
45
+ n,
46
+ i ?? l,
47
+ r ?? w
48
48
  );
49
49
  }, N = async ({
50
- provider: a,
50
+ provider: o,
51
51
  contractFunction: e,
52
52
  args: t,
53
- gasLimit: s,
54
- nonce: r,
55
- confirmations: n
53
+ gasLimit: a,
54
+ nonce: s,
55
+ confirmations: i
56
56
  }) => {
57
57
  try {
58
- const o = await m(
59
- a,
58
+ const r = await m(
59
+ o,
60
60
  0
61
61
  /* Initial */
62
62
  );
63
- return await u({ contractFunction: e, args: t, gasPrice: o, gasLimit: s, nonce: r, confirmations: n });
64
- } catch (o) {
65
- const i = T(o);
66
- if (i === l.MAX_FEE_GAS_ERROR || i === g.TRANSACTION_TIMEOUT) {
63
+ return await u({ contractFunction: e, args: t, gasPrice: r, gasLimit: a, nonce: s, confirmations: i });
64
+ } catch (r) {
65
+ const n = p(r);
66
+ if (n === g.MAX_FEE_GAS_ERROR || n === T.TRANSACTION_TIMEOUT) {
67
67
  console.log("Timeout Hit: Increase gas");
68
68
  const c = await m(
69
- a,
69
+ o,
70
70
  1
71
71
  /* Secondary */
72
72
  );
73
- return await u({ contractFunction: e, args: t, gasPrice: c, gasLimit: s, nonce: r, confirmations: n });
73
+ return await u({ contractFunction: e, args: t, gasPrice: c, gasLimit: a, nonce: s, confirmations: i });
74
74
  }
75
- throw o;
75
+ throw r;
76
76
  }
77
77
  };
78
78
  export {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");const h=require("../../error-handling/logError.cjs"),w=async(t,c,r,o)=>{const n=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await c.getPool(r,o,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),s=await Promise.all(n.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await t.balanceOf(e.poolAddress)).toBigInt()}))),i=s.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return s.find(e=>e.token1Balance===i)},g=async(t,c,r,o,n)=>{try{if(!d.networkRegistry[t.getCurrentChainId()].quoterV2Address)throw Error("No Quoter Contract Provided");return(await t.getContractWithFetcher(u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t.getCurrentChainId()].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:c.wrappedErc20TokenAddress??c.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:n,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(s){throw h.logError(s),s}},A=async(t,c,r)=>{try{const o=t.getCurrentChainId(),n=t.getContractWithFetcher(u.ContractType.UniswapV3FactoryContract,d.networkRegistry[o].uniswapV3FactoryAddress),s=t.getContractWithFetcher(u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(s,n,c.wrappedErc20TokenAddress??c.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},P=async(t,c,r,o)=>{try{const n=await A(t,r,o),s=q.utils.defaultAbiCoder.encode(["uint24"],[n]),a=y.getAmountInWei(r,c);return{tokenPrice:await g(t,r,o,n,a),poolFee:s}}catch(n){throw console.log({error:n}),Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=A;exports.getUniswapPrice=P;exports.getUniswapPriceHelper=g;exports.searchPoolAndFee=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");const h=require("../../error-handling/logError.cjs"),w=async(t,s,r,o)=>{const c=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await s.getPool(r,o,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),n=await Promise.all(c.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await t.balanceOf(e.poolAddress)).toBigInt()}))),i=n.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return n.find(e=>e.token1Balance===i)},g=async(t,s,r,o,c)=>{try{if(!d.networkRegistry[t.getCurrentChainId()].quoterV2Address)throw Error("No Quoter Contract Provided");return(await t.getContractWithFetcher(u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t.getCurrentChainId()].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:s.wrappedErc20TokenAddress??s.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:c,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(n){throw h.logError(n),n}},A=async(t,s,r)=>{try{const o=t.getCurrentChainId(),c=t.getContractWithFetcher(u.ContractType.UniswapV3FactoryContract,d.networkRegistry[o].uniswapV3FactoryAddress),n=t.getContractWithFetcher(u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(n,c,s.wrappedErc20TokenAddress??s.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},P=async(t,s,r,o)=>{try{const c=await A(t,r,o),n=q.utils.defaultAbiCoder.encode(["uint24"],[c]),a=y.getAmountInWei(r,s);return{tokenPrice:await g(t,r,o,c,a),poolFee:n}}catch{throw Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=A;exports.getUniswapPrice=P;exports.getUniswapPriceHelper=g;exports.searchPoolAndFee=w;
@@ -1,15 +1,15 @@
1
- import { utils as l } from "ethers";
1
+ import { utils as w } from "ethers";
2
2
  import { networkRegistry as d } from "../../constants/chains.constants.mjs";
3
3
  import "../../constants/vite.constants.mjs";
4
4
  import "../../constants/contracts.constants.mjs";
5
5
  import "../../constants/kyc.constants.mjs";
6
- import { zeroAddress as w } from "../../constants/protocol.constants.mjs";
6
+ import { zeroAddress as A } from "../../constants/protocol.constants.mjs";
7
7
  import "../../constants/coingecko.constants.mjs";
8
8
  import "../../constants/axelar.constants.mjs";
9
9
  import "../../constants/rewards.constants.mjs";
10
10
  import "../../constants/reorg-depths.constants.mjs";
11
11
  import { transactionErrorCodes as u } from "../../error-handling/error-codes.constants.mjs";
12
- import { getAmountInWei as A } from "./etherFunctions.mjs";
12
+ import { getAmountInWei as l } from "./etherFunctions.mjs";
13
13
  import "axios";
14
14
  import "../../types/circom-data.types.mjs";
15
15
  import { ContractType as p } from "../../types/ethereum-network.types.mjs";
@@ -17,23 +17,23 @@ import "../../types/transactions.types.mjs";
17
17
  import "../../types/curve.types.mjs";
18
18
  import "circomlibjs";
19
19
  import { logError as C } from "../../error-handling/logError.mjs";
20
- const g = async (e, c, t, o) => {
21
- const n = (await Promise.all(
20
+ const f = async (e, s, t, o) => {
21
+ const c = (await Promise.all(
22
22
  [100, 500, 3e3, 1e4].map(async (r) => ({
23
- poolAddress: await c.getPool(t, o, r),
23
+ poolAddress: await s.getPool(t, o, r),
24
24
  fee: r
25
25
  }))
26
- )).filter(({ poolAddress: r }) => r !== w), s = await Promise.all(
27
- n.map(async (r) => ({
26
+ )).filter(({ poolAddress: r }) => r !== A), n = await Promise.all(
27
+ c.map(async (r) => ({
28
28
  poolAddress: r.poolAddress,
29
29
  fee: r.fee,
30
30
  token1Balance: (await e.balanceOf(r.poolAddress)).toBigInt()
31
31
  }))
32
- ), i = s.map((r) => r.token1Balance).reduce((r, m) => m >= r ? m : r, 0n);
32
+ ), i = n.map((r) => r.token1Balance).reduce((r, m) => m >= r ? m : r, 0n);
33
33
  if (i === 0n)
34
34
  throw new Error(u.UNISWAP_NOT_ENOUGH_LIQUIDITY);
35
- return s.find((r) => r.token1Balance === i);
36
- }, f = async (e, c, t, o, n) => {
35
+ return n.find((r) => r.token1Balance === i);
36
+ }, g = async (e, s, t, o, c) => {
37
37
  try {
38
38
  if (!d[e.getCurrentChainId()].quoterV2Address)
39
39
  throw Error("No Quoter Contract Provided");
@@ -41,44 +41,44 @@ const g = async (e, c, t, o) => {
41
41
  p.UniswapV3QuoterContract,
42
42
  d[e.getCurrentChainId()].quoterV2Address
43
43
  ).callStatic.quoteExactInputSingle({
44
- tokenIn: c.wrappedErc20TokenAddress ?? c.erc20TokenAddress,
44
+ tokenIn: s.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
45
45
  tokenOut: t.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
46
46
  fee: o,
47
- amountIn: n,
47
+ amountIn: c,
48
48
  sqrtPriceLimitX96: 0
49
49
  })).amountOut.toBigInt();
50
- } catch (s) {
51
- throw C(s), s;
50
+ } catch (n) {
51
+ throw C(n), n;
52
52
  }
53
- }, I = async (e, c, t) => {
53
+ }, I = async (e, s, t) => {
54
54
  try {
55
- const o = e.getCurrentChainId(), n = e.getContractWithFetcher(
55
+ const o = e.getCurrentChainId(), c = e.getContractWithFetcher(
56
56
  p.UniswapV3FactoryContract,
57
57
  d[o].uniswapV3FactoryAddress
58
- ), s = e.getContractWithFetcher(
58
+ ), n = e.getContractWithFetcher(
59
59
  p.ERC20Contract,
60
60
  t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
61
- ), { fee: a } = await g(
62
- s,
61
+ ), { fee: a } = await f(
63
62
  n,
64
- c.wrappedErc20TokenAddress ?? c.erc20TokenAddress,
63
+ c,
64
+ s.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
65
65
  t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
66
66
  );
67
67
  return a;
68
68
  } catch (o) {
69
69
  throw console.log("Error in getUniswapFee", o), o;
70
70
  }
71
- }, L = async (e, c, t, o) => {
71
+ }, L = async (e, s, t, o) => {
72
72
  try {
73
- const n = await I(e, t, o), s = l.defaultAbiCoder.encode(["uint24"], [n]), a = A(t, c);
74
- return { tokenPrice: await f(e, t, o, n, a), poolFee: s };
75
- } catch (n) {
76
- throw console.log({ error: n }), Error(u.NO_UNISWAP_PRICE);
73
+ const c = await I(e, t, o), n = w.defaultAbiCoder.encode(["uint24"], [c]), a = l(t, s);
74
+ return { tokenPrice: await g(e, t, o, c, a), poolFee: n };
75
+ } catch {
76
+ throw Error(u.NO_UNISWAP_PRICE);
77
77
  }
78
78
  };
79
79
  export {
80
80
  I as getUniswapFee,
81
81
  L as getUniswapPrice,
82
- f as getUniswapPriceHelper,
83
- g as searchPoolAndFee
82
+ g as getUniswapPriceHelper,
83
+ f as searchPoolAndFee
84
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hinkal/common",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "homepage": "hinkal.pro",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"
@@ -1 +1 @@
1
- "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-T9sCESzH.js").href:new URL("../../assets/snarkjsWorkerLauncher-T9sCESzH.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
1
+ "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-D2n9Ry7V.js").href:new URL("../../assets/snarkjsWorkerLauncher-D2n9Ry7V.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
@@ -1,4 +1,4 @@
1
- const r = "" + new URL("../../assets/snarkjsWorkerLauncher-T9sCESzH.js", import.meta.url).href;
1
+ const r = "" + new URL("../../assets/snarkjsWorkerLauncher-D2n9Ry7V.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 P=require("../workerProxy.cjs"),r=require("../../constants/vite.constants.cjs"),m=require("snarkjs");function w(t){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(c,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return c.default=t,Object.freeze(c)}const p=w(m),l=new P.WorkerProxy,f=async t=>{const{input:c,wasmFilePath:e,zKeyFilePath:o,chainId:h}=t.payload.data,{hostLocation:{origin:u},constants:{isDevelopment:g,chains:{chainIds:b}}}=t.metadata;let s=e,i=o;const n=s.startsWith("https://");if(r.isNode&&!n){r.isWebpack?(s=`libs/hardhat/test/circuits/${e}`,i=`libs/hardhat/test/circuits/${o}`):!r.isWebpack&&g&&(s=`test/circuits/${e}`,i=`test/circuits/${o}`);const a=require("path");s=a.resolve(s),i=a.resolve(i)}r.isNode&&n?process.browser=!0:h===b.localhost&&!r.isNode&&(s=`${u}/${e}`,i=`${u}/${o}`);try{console.log({isNode:r.isNode,isWebpack:r.isWebpack,isOnline:n,message:"file before actual proof",wasmFullFilePath:s});const{proof:a,publicSignals:d}=await p.groth16.fullProve(c,s,i),k=await p.groth16.exportSolidityCallData(a,d),y=JSON.parse(`[${k}]`);l.postMessageToMainThread({zkCallData:y,proof:a,publicSignals:d})}catch(a){console.log(a)}};l.attachWorkerSideOnMessage(f);exports.default=l;exports.onWorkerMessage=f;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("../workerProxy.cjs"),n=require("../../constants/vite.constants.cjs"),w=require("snarkjs");function $(t){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,s.get?s:{enumerable:!0,get:()=>t[e]})}}return i.default=t,Object.freeze(i)}const h=$(w),c=new P.WorkerProxy,p=async t=>{const{input:i,wasmFilePath:e,zKeyFilePath:s,chainId:f}=t.payload.data,{hostLocation:{origin:l},constants:{isDevelopment:g,chains:{chainIds:b}}}=t.metadata;let o=e,r=s;const u=o.startsWith("https://");if(n.isNode&&!u){n.isWebpack?(o=`libs/hardhat/test/circuits/${e}`,r=`libs/hardhat/test/circuits/${s}`):!n.isWebpack&&g&&(o=`test/circuits/${e}`,r=`test/circuits/${s}`);const a=require("path");o=a.resolve(o),r=a.resolve(r)}n.isNode&&u?process.browser=!0:f===b.localhost&&!n.isNode&&(o=`${l}/${e}`,r=`${l}/${s}`);try{const{proof:a,publicSignals:d}=await h.groth16.fullProve(i,o,r),k=await h.groth16.exportSolidityCallData(a,d),y=JSON.parse(`[${k}]`);c.postMessageToMainThread({zkCallData:y,proof:a,publicSignals:d})}catch(a){console.log(a)}};c.attachWorkerSideOnMessage(p);exports.default=c;exports.onWorkerMessage=p;
@@ -1,32 +1,31 @@
1
1
  import { WorkerProxy as w } from "../workerProxy.mjs";
2
- import { isNode as r, isWebpack as l } from "../../constants/vite.constants.mjs";
2
+ import { isNode as i, isWebpack as h } from "../../constants/vite.constants.mjs";
3
3
  import * as p from "snarkjs";
4
- const f = new w(), y = async (c) => {
5
- const { input: u, wasmFilePath: a, zKeyFilePath: o, chainId: d } = c.payload.data, {
6
- hostLocation: { origin: n },
4
+ const u = new w(), y = async (r) => {
5
+ const { input: d, wasmFilePath: e, zKeyFilePath: o, chainId: f } = r.payload.data, {
6
+ hostLocation: { origin: l },
7
7
  constants: {
8
8
  isDevelopment: m,
9
- chains: { chainIds: g }
9
+ chains: { chainIds: $ }
10
10
  }
11
- } = c.metadata;
12
- let t = a, e = o;
13
- const i = t.startsWith("https://");
14
- if (r && !i) {
15
- l ? (t = `libs/hardhat/test/circuits/${a}`, e = `libs/hardhat/test/circuits/${o}`) : !l && m && (t = `test/circuits/${a}`, e = `test/circuits/${o}`);
11
+ } = r.metadata;
12
+ let t = e, a = o;
13
+ const c = t.startsWith("https://");
14
+ if (i && !c) {
15
+ h ? (t = `libs/hardhat/test/circuits/${e}`, a = `libs/hardhat/test/circuits/${o}`) : !h && m && (t = `test/circuits/${e}`, a = `test/circuits/${o}`);
16
16
  const s = require("path");
17
- t = s.resolve(t), e = s.resolve(e);
17
+ t = s.resolve(t), a = s.resolve(a);
18
18
  }
19
- r && i ? process.browser = !0 : d === g.localhost && !r && (t = `${n}/${a}`, e = `${n}/${o}`);
19
+ i && c ? process.browser = !0 : f === $.localhost && !i && (t = `${l}/${e}`, a = `${l}/${o}`);
20
20
  try {
21
- console.log({ isNode: r, isWebpack: l, isOnline: i, message: "file before actual proof", wasmFullFilePath: t });
22
- const { proof: s, publicSignals: h } = await p.groth16.fullProve(u, t, e), $ = await p.groth16.exportSolidityCallData(s, h), k = JSON.parse(`[${$}]`);
23
- f.postMessageToMainThread({ zkCallData: k, proof: s, publicSignals: h });
21
+ const { proof: s, publicSignals: n } = await p.groth16.fullProve(d, t, a), g = await p.groth16.exportSolidityCallData(s, n), k = JSON.parse(`[${g}]`);
22
+ u.postMessageToMainThread({ zkCallData: k, proof: s, publicSignals: n });
24
23
  } catch (s) {
25
24
  console.log(s);
26
25
  }
27
26
  };
28
- f.attachWorkerSideOnMessage(y);
27
+ u.attachWorkerSideOnMessage(y);
29
28
  export {
30
- f as default,
29
+ u as default,
31
30
  y as onWorkerMessage
32
31
  };