@hinkal/common 0.1.33 → 0.1.35

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 (56) hide show
  1. package/constants/chains.constants.cjs +1 -1
  2. package/constants/chains.constants.mjs +29 -29
  3. package/constants/fees.constants.cjs +1 -1
  4. package/constants/fees.constants.mjs +22 -22
  5. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  6. package/data-structures/Hinkal/Hinkal.d.ts +1 -0
  7. package/data-structures/Hinkal/Hinkal.mjs +13 -10
  8. package/data-structures/Hinkal/IHinkal.d.ts +2 -1
  9. package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
  10. package/data-structures/Hinkal/hinkalActionBeefy.mjs +18 -20
  11. package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
  12. package/data-structures/Hinkal/hinkalActionConvex.mjs +18 -21
  13. package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
  14. package/data-structures/Hinkal/hinkalActionLidoEth.mjs +31 -31
  15. package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
  16. package/data-structures/Hinkal/hinkalActionPendle.mjs +77 -80
  17. package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
  18. package/data-structures/Hinkal/hinkalActionPendleLP.mjs +34 -34
  19. package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
  20. package/data-structures/Hinkal/hinkalActionStake.mjs +48 -52
  21. package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
  22. package/data-structures/Hinkal/hinkalActionVolatile.mjs +38 -44
  23. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  24. package/data-structures/Hinkal/hinkalDeposit.mjs +27 -28
  25. package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -4
  26. package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +11 -16
  27. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  28. package/data-structures/transactions-manager/TransactionsManager.mjs +66 -74
  29. package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
  30. package/data-structures/transactions-manager/history/getVolatileData.mjs +13 -13
  31. package/data-structures/volatile-helper/VolatileHelper.cjs +1 -1
  32. package/data-structures/volatile-helper/VolatileHelper.mjs +60 -60
  33. package/functions/pre-transaction/getFlatFees.cjs +1 -1
  34. package/functions/pre-transaction/getFlatFees.mjs +42 -42
  35. package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
  36. package/functions/pre-transaction/process-gas-estimates.mjs +17 -26
  37. package/functions/protocols/pendle.helpers.cjs +1 -1
  38. package/functions/protocols/pendle.helpers.mjs +27 -27
  39. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  40. package/functions/snarkjs/constructGeneralZkProof.mjs +35 -37
  41. package/functions/utils/cacheFunctions.cjs +1 -1
  42. package/functions/utils/cacheFunctions.mjs +27 -30
  43. package/functions/web3/events/getShieldedBalance.cjs +2 -2
  44. package/functions/web3/events/getShieldedBalance.mjs +25 -25
  45. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  46. package/functions/web3/functionCalls/transactCallDirect.mjs +15 -15
  47. package/functions/web3/runContractFunction.cjs +1 -1
  48. package/functions/web3/runContractFunction.mjs +37 -37
  49. package/functions/web3/uniswapAPI.cjs +1 -1
  50. package/functions/web3/uniswapAPI.mjs +28 -28
  51. package/package.json +1 -1
  52. package/types/relayer.types.d.ts +22 -0
  53. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  54. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  55. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  56. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +16 -17
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("async-mutex"),q=require("../../../constants/token-data/ERC20Registry.cjs"),I=require("../../utils/erc20tokenFunctions.cjs"),p=require("../../utils/caseInsensitive.utils.cjs"),k=require("../../utils/volatile-patcher.utils.cjs"),U=require("../../../data-structures/utxo/Utxo.cjs"),w=require("../../../data-structures/custom-token-registry/CustomTokenRegistry.cjs"),x=require("../../../data-structures/volatile-helper/VolatileHelper.cjs"),P=require("../etherFunctions.cjs"),S=require("../../../error-handling/customErrors/ErrorWithAmount.cjs"),y=require("./getInputUtxoAndBalance.cjs"),b=new A.Mutex,v=async a=>{const r=await b.acquire(),{inputUtxos:c}=await y.getInputUtxoAndBalance({hinkal:a,sliceIfMore6:!1}),n=a.getCurrentChainId(),u=[...q.getERC20Registry(n),...w.customTokenRegistry.getCustomTokens(n)];await k.patchRegistry(n);const h=u.map(e=>({token:e,balance:c.reduce((t,i)=>{const s=e.isVolatile?e.sharedAddress:e.erc20TokenAddress;return p.caseInsensitiveEqual(s,i.erc20TokenAddress)?t+i.amount:t},0n),timestamp:c.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress))[0]?.timeStamp,nfts:c.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress)&&t.tokenId!==0).map(t=>({tokenId:t.tokenId,timestamp:t.timeStamp}))})),m=await Promise.all(h.map(async e=>{if(!e.token.isVolatile)return e;e.token?.sharedAddress||console.log("VolatileToken must have a corresponding sharedAddress");let t=0n;return e.balance>0n&&(t=await x.VolatileHelper.getVolatileTokenBalance(n,e.token.sharedAddress,e.balance)),{...e,balance:BigInt(t)}}));return r(),m},E=async(a,r,c,n=6,u=r.map(()=>0),h=!1)=>{const{userKeys:m}=a,e=[],t=[];let i=0;for(let s=0;s<r.length;s+=1)if(h===!1){const{inputUtxos:o}=await y.getInputUtxoAndBalance({hinkal:a,erc20TokenAddress:r[s],tokenId:u[s],sliceIfMore6:!1});i=Math.max(o.length,i),t.push(o)}else t.push([]);return console.log({maxUtxoNum:i}),i===2?t:(t.forEach((s,o)=>{if(s.length>n){const l=s.slice(0,n),d=l.reduce((g,f)=>g+f.amount,0n);if(c[o]<0n&&d<-c[o]){const g=I.getERC20Token(r[o],a.getCurrentChainId()),f=Number(P.getAmountWithPrecision(d,g,2)),T=`Unfortunately your transaction did not go through due to UTXOs limitations.
2
- Please try again with ${g.symbol}`;throw new S.ErrorWithAmount(f,T)}e.push(l)}else if(s.length<=n){const l=[...s];let d=n-s.length;for(;d>0;)d-=1,l.push(new U.Utxo({amount:0n,erc20TokenAddress:r[o],shieldedPrivateKey:m.getShieldedPrivateKey(),tokenId:u[o]}));e.push(l)}}),e)};exports.addPaddingToUtxos=E;exports.getShieldedBalance=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("async-mutex"),q=require("../../../constants/token-data/ERC20Registry.cjs"),I=require("../../utils/erc20tokenFunctions.cjs"),p=require("../../utils/caseInsensitive.utils.cjs"),k=require("../../utils/volatile-patcher.utils.cjs"),U=require("../../../data-structures/utxo/Utxo.cjs"),w=require("../../../data-structures/custom-token-registry/CustomTokenRegistry.cjs"),x=require("../../../data-structures/volatile-helper/VolatileHelper.cjs"),P=require("../etherFunctions.cjs"),S=require("../../../error-handling/customErrors/ErrorWithAmount.cjs"),y=require("./getInputUtxoAndBalance.cjs"),b=new A.Mutex,v=async i=>{const r=await b.acquire(),{inputUtxos:a}=await y.getInputUtxoAndBalance({hinkal:i,sliceIfMore6:!1}),n=i.getCurrentChainId(),u=[...q.getERC20Registry(n),...w.customTokenRegistry.getCustomTokens(n)];await k.patchRegistry(n);const h=u.map(e=>({token:e,balance:a.reduce((t,c)=>{const s=e.isVolatile?e.sharedAddress:e.erc20TokenAddress;return p.caseInsensitiveEqual(s,c.erc20TokenAddress)?t+c.amount:t},0n),timestamp:a.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress))[0]?.timeStamp,nfts:a.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress)&&t.tokenId!==0).map(t=>({tokenId:t.tokenId,timestamp:t.timeStamp}))})),m=await Promise.all(h.map(async e=>{if(!e.token.isVolatile)return e;e.token?.sharedAddress||console.log("VolatileToken must have a corresponding sharedAddress");let t=0n;return e.balance>0n&&(t=await x.VolatileHelper.getVolatileTokenBalance(n,e.token.sharedAddress,e.balance)),{...e,balance:BigInt(t)}}));return r(),m},E=async(i,r,a,n=6,u=r.map(()=>0),h=!1)=>{const{userKeys:m}=i,e=[],t=[];let c=0;for(let s=0;s<r.length;s+=1)if(h===!1){const{inputUtxos:o}=await y.getInputUtxoAndBalance({hinkal:i,erc20TokenAddress:r[s],tokenId:u[s],sliceIfMore6:!1});c=Math.max(o.length,c),t.push(o)}else t.push([]);return c===2?t:(t.forEach((s,o)=>{if(s.length>n){const d=s.slice(0,n),l=d.reduce((g,f)=>g+f.amount,0n);if(a[o]<0n&&l<-a[o]){const g=I.getERC20Token(r[o],i.getCurrentChainId()),f=Number(P.getAmountWithPrecision(l,g,2)),T=`Unfortunately your transaction did not go through due to UTXOs limitations.
2
+ Please try again with ${g.symbol}`;throw new S.ErrorWithAmount(f,T)}e.push(d)}else if(s.length<=n){const d=[...s];let l=n-s.length;for(;l>0;)l-=1,d.push(new U.Utxo({amount:0n,erc20TokenAddress:r[o],shieldedPrivateKey:m.getShieldedPrivateKey(),tokenId:u[o]}));e.push(d)}}),e)};exports.addPaddingToUtxos=E;exports.getShieldedBalance=v;
@@ -1,7 +1,7 @@
1
1
  import { Mutex as A } from "async-mutex";
2
2
  import { getERC20Registry as w } from "../../../constants/token-data/ERC20Registry.mjs";
3
3
  import { getERC20Token as k } from "../../utils/erc20tokenFunctions.mjs";
4
- import { caseInsensitiveEqual as h } from "../../utils/caseInsensitive.utils.mjs";
4
+ import { caseInsensitiveEqual as g } from "../../utils/caseInsensitive.utils.mjs";
5
5
  import { patchRegistry as I } from "../../utils/volatile-patcher.utils.mjs";
6
6
  import { Utxo as U } from "../../../data-structures/utxo/Utxo.mjs";
7
7
  import { customTokenRegistry as P } from "../../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
@@ -9,20 +9,20 @@ import { VolatileHelper as b } from "../../../data-structures/volatile-helper/Vo
9
9
  import { getAmountWithPrecision as x } from "../etherFunctions.mjs";
10
10
  import { ErrorWithAmount as S } from "../../../error-handling/customErrors/ErrorWithAmount.mjs";
11
11
  import { getInputUtxoAndBalance as T } from "./getInputUtxoAndBalance.mjs";
12
- const C = new A(), O = async (a) => {
13
- const n = await C.acquire(), { inputUtxos: d } = await T({ hinkal: a, sliceIfMore6: !1 }), s = a.getCurrentChainId(), c = [...w(s), ...P.getCustomTokens(s)];
12
+ const C = new A(), O = async (i) => {
13
+ const n = await C.acquire(), { inputUtxos: a } = await T({ hinkal: i, sliceIfMore6: !1 }), s = i.getCurrentChainId(), c = [...w(s), ...P.getCustomTokens(s)];
14
14
  await I(s);
15
15
  const p = c.map((e) => ({
16
16
  token: e,
17
- balance: d.reduce((t, i) => {
17
+ balance: a.reduce((t, d) => {
18
18
  const o = e.isVolatile ? e.sharedAddress : e.erc20TokenAddress;
19
- return h(o, i.erc20TokenAddress) ? t + i.amount : t;
19
+ return g(o, d.erc20TokenAddress) ? t + d.amount : t;
20
20
  }, 0n),
21
- timestamp: d.filter(
22
- (t) => h(t.erc20TokenAddress, e.erc20TokenAddress)
21
+ timestamp: a.filter(
22
+ (t) => g(t.erc20TokenAddress, e.erc20TokenAddress)
23
23
  )[0]?.timeStamp,
24
- nfts: d.filter(
25
- (t) => h(t.erc20TokenAddress, e.erc20TokenAddress) && t.tokenId !== 0
24
+ nfts: a.filter(
25
+ (t) => g(t.erc20TokenAddress, e.erc20TokenAddress) && t.tokenId !== 0
26
26
  ).map((t) => ({ tokenId: t.tokenId, timestamp: t.timeStamp }))
27
27
  })), u = await Promise.all(
28
28
  p.map(async (e) => {
@@ -41,34 +41,34 @@ const C = new A(), O = async (a) => {
41
41
  })
42
42
  );
43
43
  return n(), u;
44
- }, X = async (a, n, d, s = 6, c = n.map(() => 0), p = !1) => {
45
- const { userKeys: u } = a, e = [], t = [];
46
- let i = 0;
44
+ }, X = async (i, n, a, s = 6, c = n.map(() => 0), p = !1) => {
45
+ const { userKeys: u } = i, e = [], t = [];
46
+ let d = 0;
47
47
  for (let o = 0; o < n.length; o += 1)
48
48
  if (p === !1) {
49
49
  const { inputUtxos: r } = await T({
50
- hinkal: a,
50
+ hinkal: i,
51
51
  erc20TokenAddress: n[o],
52
52
  tokenId: c[o],
53
53
  sliceIfMore6: !1
54
54
  });
55
- i = Math.max(r.length, i), t.push(r);
55
+ d = Math.max(r.length, d), t.push(r);
56
56
  } else
57
57
  t.push([]);
58
- return console.log({ maxUtxoNum: i }), i === 2 ? t : (t.forEach((o, r) => {
58
+ return d === 2 ? t : (t.forEach((o, r) => {
59
59
  if (o.length > s) {
60
- const l = o.slice(0, s), m = l.reduce((f, g) => f + g.amount, 0n);
61
- if (d[r] < 0n && m < -d[r]) {
62
- const f = k(n[r], a.getCurrentChainId()), g = Number(x(m, f, 2)), y = `Unfortunately your transaction did not go through due to UTXOs limitations.
60
+ const m = o.slice(0, s), l = m.reduce((f, h) => f + h.amount, 0n);
61
+ if (a[r] < 0n && l < -a[r]) {
62
+ const f = k(n[r], i.getCurrentChainId()), h = Number(x(l, f, 2)), y = `Unfortunately your transaction did not go through due to UTXOs limitations.
63
63
  Please try again with ${f.symbol}`;
64
- throw new S(g, y);
64
+ throw new S(h, y);
65
65
  }
66
- e.push(l);
66
+ e.push(m);
67
67
  } else if (o.length <= s) {
68
- const l = [...o];
69
- let m = s - o.length;
70
- for (; m > 0; )
71
- m -= 1, l.push(
68
+ const m = [...o];
69
+ let l = s - o.length;
70
+ for (; l > 0; )
71
+ l -= 1, m.push(
72
72
  new U({
73
73
  amount: 0n,
74
74
  erc20TokenAddress: n[r],
@@ -76,7 +76,7 @@ const C = new A(), O = async (a) => {
76
76
  tokenId: c[r]
77
77
  })
78
78
  );
79
- e.push(l);
79
+ e.push(m);
80
80
  }
81
81
  }), e);
82
82
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../../constants/protocol.constants.cjs"),T=require("../../../types/ethereum-network.types.cjs"),f=require("./approveToken.cjs"),A=require("../../utils/time.utils.cjs"),b=async(r,o,s,t,i,n,u,h)=>{const a=r.getContractWithSigner(T.ContractType.HinkalContract),p=await r.getEthereumAddress(),v=u??a,d=h??a,g="transact";console.log("before the direct transaction"),o>0n&&s.erc20TokenAddress!==l.zeroAddress&&await f.approveTokenToHinkal(r,v,o,s);const c={value:o>0n&&s.erc20TokenAddress===l.zeroAddress?BigInt(o).toString():void 0};let e;try{e=(await d.estimateGas[g](t[0],t[1],t[2],n,i,{...c,from:p})).toNumber(),console.log({"gas costs of deposit":e})}catch(y){console.log("hinkalDeposit: gas estimation error: ",{err:y})}const m=e&&e>=0?Math.ceil(e*12/10):void 0;return c.gasLimit=m,await A.waitLittle(),await d[g](t[0],t[1],t[2],n,i,c)};exports.transactCallDirect=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../../constants/protocol.constants.cjs"),T=require("../../../types/ethereum-network.types.cjs"),A=require("./approveToken.cjs"),q=require("../../utils/time.utils.cjs"),S=async(s,e,o,t,i,n,l,h)=>{const a=s.getContractWithSigner(T.ContractType.HinkalContract),p=await s.getEthereumAddress(),v=l??a,d=h??a,g="transact";e>0n&&o.erc20TokenAddress!==u.zeroAddress&&await A.approveTokenToHinkal(s,v,e,o);const c={value:e>0n&&o.erc20TokenAddress===u.zeroAddress?BigInt(e).toString():void 0};let r;try{r=(await d.estimateGas[g](t[0],t[1],t[2],n,i,{...c,from:p})).toNumber()}catch(y){console.log("hinkalDeposit: gas estimation error: ",{err:y})}const m=r&&r>=0?Math.ceil(r*12/10):void 0;return c.gasLimit=m,await q.waitLittle(),await d[g](t[0],t[1],t[2],n,i,c)};exports.transactCallDirect=S;
@@ -1,28 +1,28 @@
1
- import { zeroAddress as m } from "../../../constants/protocol.constants.mjs";
2
- import { ContractType as A } from "../../../types/ethereum-network.types.mjs";
3
- import { approveTokenToHinkal as T } from "./approveToken.mjs";
4
- import { waitLittle as y } from "../../utils/time.utils.mjs";
5
- const H = async (s, r, e, t, c, n, f, p) => {
6
- const a = s.getContractWithSigner(A.HinkalContract), h = await s.getEthereumAddress(), l = f ?? a, d = p ?? a, g = "transact";
7
- console.log("before the direct transaction"), r > 0n && e.erc20TokenAddress !== m && await T(s, l, r, e);
1
+ import { zeroAddress as g } from "../../../constants/protocol.constants.mjs";
2
+ import { ContractType as T } from "../../../types/ethereum-network.types.mjs";
3
+ import { approveTokenToHinkal as y } from "./approveToken.mjs";
4
+ import { waitLittle as u } from "../../utils/time.utils.mjs";
5
+ const S = async (s, r, e, t, c, n, p, f) => {
6
+ const a = s.getContractWithSigner(T.HinkalContract), h = await s.getEthereumAddress(), v = p ?? a, d = f ?? a, m = "transact";
7
+ r > 0n && e.erc20TokenAddress !== g && await y(s, v, r, e);
8
8
  const i = {
9
- value: r > 0n && e.erc20TokenAddress === m ? BigInt(r).toString() : void 0
9
+ value: r > 0n && e.erc20TokenAddress === g ? BigInt(r).toString() : void 0
10
10
  };
11
11
  let o;
12
12
  try {
13
- o = (await d.estimateGas[g](
13
+ o = (await d.estimateGas[m](
14
14
  t[0],
15
15
  t[1],
16
16
  t[2],
17
17
  n,
18
18
  c,
19
19
  { ...i, from: h }
20
- )).toNumber(), console.log({ "gas costs of deposit": o });
21
- } catch (x) {
22
- console.log("hinkalDeposit: gas estimation error: ", { err: x });
20
+ )).toNumber();
21
+ } catch (A) {
22
+ console.log("hinkalDeposit: gas estimation error: ", { err: A });
23
23
  }
24
- const v = o && o >= 0 ? Math.ceil(o * 12 / 10) : void 0;
25
- return i.gasLimit = v, await y(), await d[g](
24
+ const x = o && o >= 0 ? Math.ceil(o * 12 / 10) : void 0;
25
+ return i.gasLimit = x, await u(), await d[m](
26
26
  t[0],
27
27
  t[1],
28
28
  t[2],
@@ -32,5 +32,5 @@ const H = async (s, r, e, t, c, n, f, p) => {
32
32
  );
33
33
  };
34
34
  export {
35
- H as transactCallDirect
35
+ S as transactCallDirect
36
36
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../error-handling/error-codes.constants.cjs");require("ethers");const T=require("../../error-handling/get-error.message.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("../../constants/reorg-depths.constants.cjs");const d=5e4,m=1,w=11,q=15,g=async(s,o)=>{try{const r=await s.getFeeData(),n=o===0?w:q,e=r.gasPrice?.mul(n).div(10)??void 0;return console.log("getGasPrice , ",e?.toBigInt(),{gasPremiumType:o}),e}catch(r){console.log("getGasPrice error: ",{err:r});return}},E=(s,o,r)=>new Promise((n,e)=>{const a=setTimeout(()=>{e(new Error(c.transactionErrorCodes.TRANSACTION_TIMEOUT))},r);s.wait(o).then(t=>{clearTimeout(a),n(t)}).catch(t=>{clearTimeout(a),e(t)})}),l=async({contractFunction:s,args:o,gasPrice:r,gasLimit:n,nonce:e,confirmations:a,waitTime:t})=>{const i=await s(...o,{type:0,gasLimit:n,gasPrice:r,nonce:e});return console.log("runTransaction: ",i?.hash),await E(i,a??m,t??d)},P=async({provider:s,contractFunction:o,args:r,gasLimit:n,nonce:e,confirmations:a})=>{try{const t=await g(s,0);return await l({contractFunction:o,args:r,gasPrice:t,gasLimit:n,nonce:e,confirmations:a})}catch(t){const i=T.getErrorMessage(t);if(i===c.UserFriendlyErrorCodes.MAX_FEE_GAS_ERROR||i===c.transactionErrorCodes.TRANSACTION_TIMEOUT){console.log("Timeout Hit: Increase gas");const u=await g(s,1);return await l({contractFunction:o,args:r,gasPrice:u,gasLimit:n,nonce:e,confirmations:a})}throw t}};exports.runContractFunction=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../error-handling/error-codes.constants.cjs");require("ethers");const m=require("../../error-handling/get-error.message.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("../../constants/reorg-depths.constants.cjs");const l=5e4,d=1,w=11,P=15,g=async(t,s)=>{try{const r=await t.getFeeData(),a=s===0?w:P;return r.gasPrice?.mul(a).div(10)??void 0}catch(r){console.log("getGasPrice error: ",{err:r});return}},q=(t,s,r)=>new Promise((a,o)=>{const n=setTimeout(()=>{o(new Error(c.transactionErrorCodes.TRANSACTION_TIMEOUT))},r);t.wait(s).then(e=>{clearTimeout(n),a(e)}).catch(e=>{clearTimeout(n),o(e)})}),T=async({contractFunction:t,args:s,gasPrice:r,gasLimit:a,nonce:o,confirmations:n,waitTime:e})=>{const i=await t(...s,{type:0,gasLimit:a,gasPrice:r,nonce:o});return await q(i,n??d,e??l)},E=async({provider:t,contractFunction:s,args:r,gasLimit:a,nonce:o,confirmations:n})=>{try{const e=await g(t,0);return await T({contractFunction:s,args:r,gasPrice:e,gasLimit:a,nonce:o,confirmations:n})}catch(e){const i=m.getErrorMessage(e);if(i===c.UserFriendlyErrorCodes.MAX_FEE_GAS_ERROR||i===c.transactionErrorCodes.TRANSACTION_TIMEOUT){console.log("Timeout Hit: Increase gas");const u=await g(t,1);return await T({contractFunction:s,args:r,gasPrice:u,gasLimit:a,nonce:o,confirmations:n})}throw e}};exports.runContractFunction=E;
@@ -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.35",
4
4
  "homepage": "hinkal.pro",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"
@@ -1,3 +1,25 @@
1
1
  export interface RelayerTransaction {
2
+ to: string;
3
+ from: string;
4
+ contractAddress: string | null;
5
+ gasUsed: {
6
+ type: string;
7
+ hex: string;
8
+ };
9
+ logsBloom: string;
10
+ blockHash: string;
2
11
  transactionHash: string;
12
+ blockNumber: number;
13
+ confirmations: number;
14
+ cumulativeGasUsed: {
15
+ type: string;
16
+ hex: string;
17
+ };
18
+ effectiveGasPrice: {
19
+ type: string;
20
+ hex: string;
21
+ };
22
+ status: number;
23
+ type: number;
24
+ byzantium: boolean;
3
25
  }
@@ -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
  };