@hinkal/common 0.1.6 → 0.1.7

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/coingecko.constants.cjs +1 -1
  2. package/constants/coingecko.constants.mjs +14 -13
  3. package/constants/vite.constants.cjs +1 -1
  4. package/constants/vite.constants.mjs +22 -21
  5. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  6. package/data-structures/Hinkal/Hinkal.mjs +71 -70
  7. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  8. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +8 -7
  9. package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
  10. package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +35 -34
  11. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  12. package/data-structures/transactions-manager/TransactionsManager.mjs +28 -27
  13. package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
  14. package/functions/pre-transaction/outputUtxoProcessing.mjs +3 -2
  15. package/functions/pre-transaction/processAmountChanges.cjs +1 -1
  16. package/functions/pre-transaction/processAmountChanges.mjs +3 -2
  17. package/functions/protocols/pendle.helpers.cjs +1 -1
  18. package/functions/protocols/pendle.helpers.mjs +11 -10
  19. package/functions/snarkjs/common.snarkjs.cjs +1 -1
  20. package/functions/snarkjs/common.snarkjs.mjs +28 -27
  21. package/functions/staking/index.cjs +1 -1
  22. package/functions/staking/index.mjs +25 -24
  23. package/functions/utils/process.utils.cjs +1 -1
  24. package/functions/utils/process.utils.mjs +3 -2
  25. package/functions/utils/requireEnv.cjs +1 -1
  26. package/functions/utils/requireEnv.mjs +5 -4
  27. package/functions/web3/events/balanceChangedHandler.cjs +1 -1
  28. package/functions/web3/events/balanceChangedHandler.mjs +4 -3
  29. package/functions/web3/odosAPI.cjs +1 -1
  30. package/functions/web3/odosAPI.mjs +9 -8
  31. package/functions/web3/oneInchAPI.cjs +1 -1
  32. package/functions/web3/oneInchAPI.mjs +3 -2
  33. package/functions/web3/runContractFunction.cjs +1 -1
  34. package/functions/web3/runContractFunction.mjs +3 -2
  35. package/functions/web3/uniswapAPI.cjs +1 -1
  36. package/functions/web3/uniswapAPI.mjs +3 -2
  37. package/package.json +1 -1
  38. package/providers/prepareEthersHinkal.cjs +1 -1
  39. package/providers/prepareEthersHinkal.mjs +4 -2
  40. package/providers/prepareWagmiv1Hinkal.cjs +1 -1
  41. package/providers/prepareWagmiv1Hinkal.mjs +4 -2
  42. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  43. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  44. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  45. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +11 -10
  46. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  47. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +2 -2
  48. package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
  49. package/webworker/utxoWorker/utxoWorkerLogic.mjs +29 -28
  50. package/webworker/workerProxy.cjs +1 -1
  51. package/webworker/workerProxy.mjs +4 -3
  52. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  53. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
@@ -1,5 +1,5 @@
1
- import { callOdosAPI as i } from "../../API/callOdosAPI.mjs";
2
- import { localhostNetwork as a, networkRegistry as p } from "../../constants/chains.constants.mjs";
1
+ import { callOdosAPI as d } from "../../API/callOdosAPI.mjs";
2
+ import { localhostNetwork as p, networkRegistry as a } 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";
@@ -11,15 +11,16 @@ import "../../constants/reorg-depths.constants.mjs";
11
11
  import { transactionErrorCodes as c } from "../../error-handling/error-codes.constants.mjs";
12
12
  import { getAmountInWei as u } from "./etherFunctions.mjs";
13
13
  import "axios";
14
+ import "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
14
15
  import "../../types/circom-data.types.mjs";
15
16
  import "../../types/transactions.types.mjs";
16
17
  import "../../types/curve.types.mjs";
17
18
  import "circomlibjs";
18
19
  import "ethers";
19
- const N = async (r, t, e, n) => {
20
+ const V = async (r, t, e, n) => {
20
21
  try {
21
22
  const o = {
22
- chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : a,
23
+ chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : p,
23
24
  inputTokens: [
24
25
  {
25
26
  tokenAddress: t?.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
@@ -32,15 +33,15 @@ const N = async (r, t, e, n) => {
32
33
  proportion: 1
33
34
  }
34
35
  ],
35
- userAddr: p[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress || m,
36
+ userAddr: a[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress || m,
36
37
  slippageLimitPercent: 10,
37
38
  disableRFQs: !0
38
39
  // sometimes swap fails because of RFQs
39
- }, { odosResponse: s, status: d } = await i(
40
+ }, { odosResponse: s, status: i } = await d(
40
41
  r.getCurrentChainId(),
41
42
  o
42
43
  );
43
- if (d !== "success")
44
+ if (i !== "success")
44
45
  throw Error("Odos API Fetch Error");
45
46
  return {
46
47
  outSwapAmountValue: BigInt(s.outputTokens[0].amount),
@@ -51,5 +52,5 @@ const N = async (r, t, e, n) => {
51
52
  }
52
53
  };
53
54
  export {
54
- N as getOdosPrice
55
+ V as getOdosPrice
55
56
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=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 d=require("../../error-handling/error-codes.constants.cjs"),u=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");const l=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:u.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(d.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=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 d=require("../../error-handling/error-codes.constants.cjs"),u=require("./etherFunctions.cjs");require("axios");require("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");const q=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:u.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(d.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=q;
@@ -11,13 +11,14 @@ import "../../constants/reorg-depths.constants.mjs";
11
11
  import { transactionErrorCodes as c } from "../../error-handling/error-codes.constants.mjs";
12
12
  import { getAmountInWei as d } from "./etherFunctions.mjs";
13
13
  import "axios";
14
+ import "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
14
15
  import "../../types/circom-data.types.mjs";
15
16
  import { ContractType as p } from "../../types/ethereum-network.types.mjs";
16
17
  import "../../types/transactions.types.mjs";
17
18
  import "../../types/curve.types.mjs";
18
19
  import "circomlibjs";
19
20
  import "ethers";
20
- const _ = async (s, t, n, m) => {
21
+ const b = async (s, t, n, m) => {
21
22
  try {
22
23
  const o = {
23
24
  fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : i,
@@ -47,5 +48,5 @@ const _ = async (s, t, n, m) => {
47
48
  }
48
49
  };
49
50
  export {
50
- _ as getOneInchPrice
51
+ b as getOneInchPrice
51
52
  };
@@ -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 T=require("../../error-handling/get-error.message.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.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,q=11,w=15,g=async(s,o)=>{try{const r=await s.getFeeData(),n=o===0?q:w,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;
@@ -4,6 +4,7 @@ import { getErrorMessage as T } 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";
7
+ import "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
7
8
  import "../../types/circom-data.types.mjs";
8
9
  import "../../types/transactions.types.mjs";
9
10
  import "../../types/curve.types.mjs";
@@ -46,7 +47,7 @@ const p = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
46
47
  n ?? w,
47
48
  o ?? p
48
49
  );
49
- }, N = async ({
50
+ }, F = async ({
50
51
  provider: a,
51
52
  contractFunction: e,
52
53
  args: t,
@@ -76,5 +77,5 @@ const p = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
76
77
  }
77
78
  };
78
79
  export {
79
- N as runContractFunction
80
+ F as runContractFunction
80
81
  };
@@ -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 A=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("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs");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}},q=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 q(t,r,o),s=A.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=q;exports.getUniswapPrice=P;exports.getUniswapPriceHelper=g;exports.searchPoolAndFee=w;
@@ -11,6 +11,7 @@ import "../../constants/reorg-depths.constants.mjs";
11
11
  import { transactionErrorCodes as u } from "../../error-handling/error-codes.constants.mjs";
12
12
  import { getAmountInWei as A } from "./etherFunctions.mjs";
13
13
  import "axios";
14
+ import "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
14
15
  import "../../types/circom-data.types.mjs";
15
16
  import { ContractType as p } from "../../types/ethereum-network.types.mjs";
16
17
  import "../../types/transactions.types.mjs";
@@ -68,7 +69,7 @@ const g = async (e, c, t, o) => {
68
69
  } catch (o) {
69
70
  throw console.log("Error in getUniswapFee", o), o;
70
71
  }
71
- }, L = async (e, c, t, o) => {
72
+ }, S = async (e, c, t, o) => {
72
73
  try {
73
74
  const n = await I(e, t, o), s = l.defaultAbiCoder.encode(["uint24"], [n]), a = A(t, c);
74
75
  return { tokenPrice: await f(e, t, o, n, a), poolFee: s };
@@ -78,7 +79,7 @@ const g = async (e, c, t, o) => {
78
79
  };
79
80
  export {
80
81
  I as getUniswapFee,
81
- L as getUniswapPrice,
82
+ S as getUniswapPrice,
82
83
  f as getUniswapPriceHelper,
83
84
  g as searchPoolAndFee
84
85
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hinkal/common",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "homepage": "hinkal.pro",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs");require("../data-structures/crypto-keys/keys.cjs");require("../data-structures/crypto-keys/encryptDecryptUtxo.cjs");const t=require("../data-structures/Hinkal/Hinkal.cjs");require("../constants/chains.constants.cjs");require("../types/circom-data.types.cjs");require("../types/transactions.types.cjs");require("../types/curve.types.cjs");require("../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../constants/vite.constants.cjs");require("axios");require("../constants/coingecko.constants.cjs");require("../constants/contracts.constants.cjs");require("../constants/kyc.constants.cjs");require("../constants/axelar.constants.cjs");require("../constants/rewards.constants.cjs");require("../constants/reorg-depths.constants.cjs");const u=require("../crypto/preProcessing.cjs");require("../functions/utils/external-action.utils.cjs");require("../functions/web3/events/getShieldedBalance.cjs");require("../data-structures/volatile-helper/VolatileHelper.cjs");require("idb-keyval");const r=require("./EthersProviderAdapter.cjs"),q=async i=>{await u.preProcessing();const e=new t.Hinkal;return r.ethersProvierAdapter.initSigner?.(i),await e.initProviderAdapter(void 0,r.ethersProvierAdapter),await e.initUserKeys(),await e.resetMerkle(),e};exports.prepareEthersHinkal=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs");require("../data-structures/crypto-keys/keys.cjs");require("../data-structures/crypto-keys/encryptDecryptUtxo.cjs");const u=require("../data-structures/Hinkal/Hinkal.cjs");require("../constants/chains.constants.cjs");require("../types/circom-data.types.cjs");require("../types/transactions.types.cjs");require("../types/curve.types.cjs");require("../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../constants/vite.constants.cjs");require("axios");require("../constants/coingecko.constants.cjs");require("../constants/contracts.constants.cjs");require("../constants/kyc.constants.cjs");require("../constants/axelar.constants.cjs");require("../constants/rewards.constants.cjs");require("../constants/reorg-depths.constants.cjs");require("../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs");const t=require("../crypto/preProcessing.cjs");require("../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.cjs");require("../functions/utils/external-action.utils.cjs");require("../functions/web3/events/getShieldedBalance.cjs");require("../data-structures/volatile-helper/VolatileHelper.cjs");require("idb-keyval");const r=require("./EthersProviderAdapter.cjs"),q=async i=>{await t.preProcessing();const e=new u.Hinkal;return r.ethersProvierAdapter.initSigner?.(i),await e.initProviderAdapter(void 0,r.ethersProvierAdapter),await e.initUserKeys(),await e.resetMerkle(),e};exports.prepareEthersHinkal=q;
@@ -16,17 +16,19 @@ import "../constants/kyc.constants.mjs";
16
16
  import "../constants/axelar.constants.mjs";
17
17
  import "../constants/rewards.constants.mjs";
18
18
  import "../constants/reorg-depths.constants.mjs";
19
+ import "../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
19
20
  import { preProcessing as p } from "../crypto/preProcessing.mjs";
21
+ import "../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.mjs";
20
22
  import "../functions/utils/external-action.utils.mjs";
21
23
  import "../functions/web3/events/getShieldedBalance.mjs";
22
24
  import "../data-structures/volatile-helper/VolatileHelper.mjs";
23
25
  import "idb-keyval";
24
26
  import { ethersProvierAdapter as i } from "./EthersProviderAdapter.mjs";
25
- const U = async (t) => {
27
+ const j = async (t) => {
26
28
  await p();
27
29
  const r = new o();
28
30
  return i.initSigner?.(t), await r.initProviderAdapter(void 0, i), await r.initUserKeys(), await r.resetMerkle(), r;
29
31
  };
30
32
  export {
31
- U as prepareEthersHinkal
33
+ j as prepareEthersHinkal
32
34
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs");require("../data-structures/crypto-keys/keys.cjs");require("../data-structures/crypto-keys/encryptDecryptUtxo.cjs");const i=require("../data-structures/Hinkal/Hinkal.cjs");require("../constants/chains.constants.cjs");require("../types/circom-data.types.cjs");require("../types/transactions.types.cjs");require("../types/curve.types.cjs");require("../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../constants/vite.constants.cjs");require("axios");require("../constants/coingecko.constants.cjs");require("../constants/contracts.constants.cjs");require("../constants/kyc.constants.cjs");require("../constants/axelar.constants.cjs");require("../constants/rewards.constants.cjs");require("../constants/reorg-depths.constants.cjs");const u=require("../crypto/preProcessing.cjs");require("../functions/utils/external-action.utils.cjs");require("../functions/web3/events/getShieldedBalance.cjs");require("../data-structures/volatile-helper/VolatileHelper.cjs");require("idb-keyval");const a=require("./Wagmiv1ProviderAdapter.cjs"),q=async r=>{await u.preProcessing();const e=new i.Hinkal;return await e.initProviderAdapter(r,a.wagmiv1ProvierAdapter),await e.initUserKeys(),await e.resetMerkle(),e};exports.prepareWagmiv1Hinkal=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs");require("../data-structures/crypto-keys/keys.cjs");require("../data-structures/crypto-keys/encryptDecryptUtxo.cjs");const i=require("../data-structures/Hinkal/Hinkal.cjs");require("../constants/chains.constants.cjs");require("../types/circom-data.types.cjs");require("../types/transactions.types.cjs");require("../types/curve.types.cjs");require("../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../constants/vite.constants.cjs");require("axios");require("../constants/coingecko.constants.cjs");require("../constants/contracts.constants.cjs");require("../constants/kyc.constants.cjs");require("../constants/axelar.constants.cjs");require("../constants/rewards.constants.cjs");require("../constants/reorg-depths.constants.cjs");require("../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs");const u=require("../crypto/preProcessing.cjs");require("../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.cjs");require("../functions/utils/external-action.utils.cjs");require("../functions/web3/events/getShieldedBalance.cjs");require("../data-structures/volatile-helper/VolatileHelper.cjs");require("idb-keyval");const q=require("./Wagmiv1ProviderAdapter.cjs"),a=async r=>{await u.preProcessing();const e=new i.Hinkal;return await e.initProviderAdapter(r,q.wagmiv1ProvierAdapter),await e.initUserKeys(),await e.resetMerkle(),e};exports.prepareWagmiv1Hinkal=a;
@@ -16,17 +16,19 @@ import "../constants/kyc.constants.mjs";
16
16
  import "../constants/axelar.constants.mjs";
17
17
  import "../constants/rewards.constants.mjs";
18
18
  import "../constants/reorg-depths.constants.mjs";
19
+ import "../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
19
20
  import { preProcessing as o } from "../crypto/preProcessing.mjs";
21
+ import "../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.mjs";
20
22
  import "../functions/utils/external-action.utils.mjs";
21
23
  import "../functions/web3/events/getShieldedBalance.mjs";
22
24
  import "../data-structures/volatile-helper/VolatileHelper.mjs";
23
25
  import "idb-keyval";
24
26
  import { wagmiv1ProvierAdapter as p } from "./Wagmiv1ProviderAdapter.mjs";
25
- const b = async (i) => {
27
+ const q = async (i) => {
26
28
  await o();
27
29
  const r = new t();
28
30
  return await r.initProviderAdapter(i, p), await r.initUserKeys(), await r.resetMerkle(), r;
29
31
  };
30
32
  export {
31
- b as prepareWagmiv1Hinkal
33
+ q as prepareWagmiv1Hinkal
32
34
  };
@@ -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-DiZX10-t.js").href:new URL("../../assets/snarkjsWorkerLauncher-DiZX10-t.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-DiZX10-t.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("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs"),m=require("../workerProxy.cjs"),r=require("../../constants/vite.constants.cjs"),w=require("snarkjs");function $(t){const n=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(n,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const f=$(w),l=new m.WorkerProxy,p=async t=>{const{input:n,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 c=s.startsWith("https://");if(r.isNode&&!c){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&&c?P.default.browser=!0:h===b.localhost&&!r.isNode&&(s=`${u}/${e}`,i=`${u}/${o}`);try{console.log({isNode:r.isNode,isWebpack:r.isWebpack,isOnline:c,message:"file before actual proof",wasmFullFilePath:s});const{proof:a,publicSignals:d}=await f.groth16.fullProve(n,s,i),k=await f.groth16.exportSolidityCallData(a,d),y=JSON.parse(`[${k}]`);l.postMessageToMainThread({zkCallData:y,proof:a,publicSignals:d})}catch(a){console.log(a)}};l.attachWorkerSideOnMessage(p);exports.default=l;exports.onWorkerMessage=p;
@@ -1,32 +1,33 @@
1
- import { WorkerProxy as w } from "../workerProxy.mjs";
1
+ import w from "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
2
+ import { WorkerProxy as y } from "../workerProxy.mjs";
2
3
  import { isNode as r, isWebpack as l } from "../../constants/vite.constants.mjs";
3
4
  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, {
5
+ const f = new y(), P = async (c) => {
6
+ const { input: m, wasmFilePath: o, zKeyFilePath: a, chainId: u } = c.payload.data, {
6
7
  hostLocation: { origin: n },
7
8
  constants: {
8
- isDevelopment: m,
9
+ isDevelopment: d,
9
10
  chains: { chainIds: g }
10
11
  }
11
12
  } = c.metadata;
12
- let t = a, e = o;
13
+ let t = o, e = a;
13
14
  const i = t.startsWith("https://");
14
15
  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}`);
16
+ l ? (t = `libs/hardhat/test/circuits/${o}`, e = `libs/hardhat/test/circuits/${a}`) : !l && d && (t = `test/circuits/${o}`, e = `test/circuits/${a}`);
16
17
  const s = require("path");
17
18
  t = s.resolve(t), e = s.resolve(e);
18
19
  }
19
- r && i ? process.browser = !0 : d === g.localhost && !r && (t = `${n}/${a}`, e = `${n}/${o}`);
20
+ r && i ? w.browser = !0 : u === g.localhost && !r && (t = `${n}/${o}`, e = `${n}/${a}`);
20
21
  try {
21
22
  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
+ const { proof: s, publicSignals: h } = await p.groth16.fullProve(m, t, e), $ = await p.groth16.exportSolidityCallData(s, h), k = JSON.parse(`[${$}]`);
23
24
  f.postMessageToMainThread({ zkCallData: k, proof: s, publicSignals: h });
24
25
  } catch (s) {
25
26
  console.log(s);
26
27
  }
27
28
  };
28
- f.attachWorkerSideOnMessage(y);
29
+ f.attachWorkerSideOnMessage(P);
29
30
  export {
30
31
  f as default,
31
- y as onWorkerMessage
32
+ P as onWorkerMessage
32
33
  };
@@ -1 +1 @@
1
- "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-Bu-W3EAj.js").href:new URL("../../assets/utxoWorkerLauncher-Bu-W3EAj.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/utxoWorkerLauncher-DU_iWrt8.js").href:new URL("../../assets/utxoWorkerLauncher-DU_iWrt8.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
@@ -1,4 +1,4 @@
1
- const e = "" + new URL("../../assets/utxoWorkerLauncher-Bu-W3EAj.js", import.meta.url).href;
1
+ const r = "" + new URL("../../assets/utxoWorkerLauncher-DU_iWrt8.js", import.meta.url).href;
2
2
  export {
3
- e as default
3
+ r as default
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("../../crypto/preProcessing.cjs"),d=require("../../data-structures/crypto-keys/keys.cjs"),T=require("../../data-structures/utxo/Utxo.cjs"),y=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),h=require("../../data-structures/crypto-keys/decodeUTXO.cjs"),k=require("../workerProxy.cjs"),l=require("./utxoWorker.types.cjs"),c=new k.WorkerProxy,p=async({data:e})=>{const{utxos:t,nullifiers:s}=e,o=t.filter(r=>{const i=new T.Utxo(r);return!s.has(i.getNullifier())});c.postMessageToMainThread(o)},U=async({data:e})=>{const t=new d.UserKeys(e.signature),s=t.getShieldedPrivateKey(),o=e.encryptedOutputs.map((r,i)=>{try{return r.isPositive?y.decryptUtxoConstructorArgs(Buffer.from(r.value.slice(2),"hex"),t):h.decodeUtxoConstructorArgs(r.value,s)}catch{return}}).filter(r=>r!==void 0);c.postMessageToMainThread(o)},x=async({data:e})=>{const t=new d.UserKeys(e.signature),s=[],{encryptedOutputs:o}=e;let{lastOutput:r}=e;const i=t.getShieldedPrivateKey();for(let u=0;u<o.length;u+=1){const a=o[u];if(r=a.value,a.isPositive)try{const n=y.decryptUtxo(Buffer.from(r.slice(2),"hex"),t);if(!n.erc20TokenAddress||!n.amount||!n.stealthAddress)throw Error("bruh");s.push(a)}catch{}else try{h.checkUtxoSignature(r,i)&&s.push(a)}catch{}}c.postMessageToMainThread({additionalEncryptedOutputs:s,lastOutput:r})},g=async e=>{await f.preProcessing();const{type:t}=e.payload;switch(t){case l.UtxoWorkerActionType.BATCH_FILTER_UTXOS_WITH_NULLIFIER:p(e.payload);return;case l.UtxoWorkerActionType.BUILD_UTXOS:U(e.payload);return;case l.UtxoWorkerActionType.DECIPHER_OUTPUTS:x(e.payload);return;default:throw Error(`Unknown worker message type ${t}`)}};c.attachWorkerSideOnMessage(g);exports.default=c;exports.handleBuildUtxosMessage=U;exports.handleDecipherMessage=x;exports.handleFilterUtxosWithNullifier=p;exports.onWorkerMessage=g;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.cjs"),f=require("../../crypto/preProcessing.cjs"),y=require("../../data-structures/crypto-keys/keys.cjs"),k=require("../../data-structures/utxo/Utxo.cjs"),h=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),p=require("../../data-structures/crypto-keys/decodeUTXO.cjs"),M=require("../workerProxy.cjs"),l=require("./utxoWorker.types.cjs"),i=new M.WorkerProxy,x=async({data:e})=>{const{utxos:t,nullifiers:s}=e,o=t.filter(r=>{const c=new k.Utxo(r);return!s.has(c.getNullifier())});i.postMessageToMainThread(o)},U=async({data:e})=>{const t=new y.UserKeys(e.signature),s=t.getShieldedPrivateKey(),o=e.encryptedOutputs.map((r,c)=>{try{return r.isPositive?h.decryptUtxoConstructorArgs(d.from(r.value.slice(2),"hex"),t):p.decodeUtxoConstructorArgs(r.value,s)}catch{return}}).filter(r=>r!==void 0);i.postMessageToMainThread(o)},g=async({data:e})=>{const t=new y.UserKeys(e.signature),s=[],{encryptedOutputs:o}=e;let{lastOutput:r}=e;const c=t.getShieldedPrivateKey();for(let u=0;u<o.length;u+=1){const a=o[u];if(r=a.value,a.isPositive)try{const n=h.decryptUtxo(d.from(r.slice(2),"hex"),t);if(!n.erc20TokenAddress||!n.amount||!n.stealthAddress)throw Error("bruh");s.push(a)}catch{}else try{p.checkUtxoSignature(r,c)&&s.push(a)}catch{}}i.postMessageToMainThread({additionalEncryptedOutputs:s,lastOutput:r})},T=async e=>{await f.preProcessing();const{type:t}=e.payload;switch(t){case l.UtxoWorkerActionType.BATCH_FILTER_UTXOS_WITH_NULLIFIER:x(e.payload);return;case l.UtxoWorkerActionType.BUILD_UTXOS:U(e.payload);return;case l.UtxoWorkerActionType.DECIPHER_OUTPUTS:g(e.payload);return;default:throw Error(`Unknown worker message type ${t}`)}};i.attachWorkerSideOnMessage(T);exports.default=i;exports.handleBuildUtxosMessage=U;exports.handleDecipherMessage=g;exports.handleFilterUtxosWithNullifier=x;exports.onWorkerMessage=T;
@@ -1,34 +1,35 @@
1
- import { preProcessing as p } from "../../crypto/preProcessing.mjs";
2
- import { UserKeys as l } from "../../data-structures/crypto-keys/keys.mjs";
3
- import { Utxo as h } from "../../data-structures/utxo/Utxo.mjs";
4
- import { decryptUtxoConstructorArgs as y, decryptUtxo as f } from "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
5
- import { decodeUtxoConstructorArgs as m, checkUtxoSignature as g } from "../../data-structures/crypto-keys/decodeUTXO.mjs";
6
- import { WorkerProxy as x } from "../workerProxy.mjs";
7
- import { UtxoWorkerActionType as u } from "./utxoWorker.types.mjs";
8
- const a = new x(), U = async ({ data: e }) => {
1
+ import u from "../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.mjs";
2
+ import { preProcessing as h } from "../../crypto/preProcessing.mjs";
3
+ import { UserKeys as p } from "../../data-structures/crypto-keys/keys.mjs";
4
+ import { Utxo as y } from "../../data-structures/utxo/Utxo.mjs";
5
+ import { decryptUtxoConstructorArgs as f, decryptUtxo as m } from "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
6
+ import { decodeUtxoConstructorArgs as g, checkUtxoSignature as x } from "../../data-structures/crypto-keys/decodeUTXO.mjs";
7
+ import { WorkerProxy as U } from "../workerProxy.mjs";
8
+ import { UtxoWorkerActionType as l } from "./utxoWorker.types.mjs";
9
+ const a = new U(), T = async ({ data: e }) => {
9
10
  const { utxos: t, nullifiers: o } = e, s = t.filter((r) => {
10
- const i = new h(r);
11
+ const i = new y(r);
11
12
  return !o.has(i.getNullifier());
12
13
  });
13
14
  a.postMessageToMainThread(s);
14
- }, T = async ({ data: e }) => {
15
- const t = new l(e.signature), o = t.getShieldedPrivateKey(), s = e.encryptedOutputs.map((r, i) => {
15
+ }, k = async ({ data: e }) => {
16
+ const t = new p(e.signature), o = t.getShieldedPrivateKey(), s = e.encryptedOutputs.map((r, i) => {
16
17
  try {
17
- return r.isPositive ? y(Buffer.from(r.value.slice(2), "hex"), t) : m(r.value, o);
18
+ return r.isPositive ? f(u.from(r.value.slice(2), "hex"), t) : g(r.value, o);
18
19
  } catch {
19
20
  return;
20
21
  }
21
22
  }).filter((r) => r !== void 0);
22
23
  a.postMessageToMainThread(s);
23
- }, k = async ({ data: e }) => {
24
- const t = new l(e.signature), o = [], { encryptedOutputs: s } = e;
24
+ }, v = async ({ data: e }) => {
25
+ const t = new p(e.signature), o = [], { encryptedOutputs: s } = e;
25
26
  let { lastOutput: r } = e;
26
27
  const i = t.getShieldedPrivateKey();
27
28
  for (let d = 0; d < s.length; d += 1) {
28
29
  const c = s[d];
29
30
  if (r = c.value, c.isPositive)
30
31
  try {
31
- const n = f(Buffer.from(r.slice(2), "hex"), t);
32
+ const n = m(u.from(r.slice(2), "hex"), t);
32
33
  if (!n.erc20TokenAddress || !n.amount || !n.stealthAddress)
33
34
  throw Error("bruh");
34
35
  o.push(c);
@@ -36,33 +37,33 @@ const a = new x(), U = async ({ data: e }) => {
36
37
  }
37
38
  else
38
39
  try {
39
- g(r, i) && o.push(c);
40
+ x(r, i) && o.push(c);
40
41
  } catch {
41
42
  }
42
43
  }
43
44
  a.postMessageToMainThread({ additionalEncryptedOutputs: o, lastOutput: r });
44
- }, v = async (e) => {
45
- await p();
45
+ }, w = async (e) => {
46
+ await h();
46
47
  const { type: t } = e.payload;
47
48
  switch (t) {
48
- case u.BATCH_FILTER_UTXOS_WITH_NULLIFIER:
49
- U(e.payload);
50
- return;
51
- case u.BUILD_UTXOS:
49
+ case l.BATCH_FILTER_UTXOS_WITH_NULLIFIER:
52
50
  T(e.payload);
53
51
  return;
54
- case u.DECIPHER_OUTPUTS:
52
+ case l.BUILD_UTXOS:
55
53
  k(e.payload);
56
54
  return;
55
+ case l.DECIPHER_OUTPUTS:
56
+ v(e.payload);
57
+ return;
57
58
  default:
58
59
  throw Error(`Unknown worker message type ${t}`);
59
60
  }
60
61
  };
61
- a.attachWorkerSideOnMessage(v);
62
+ a.attachWorkerSideOnMessage(w);
62
63
  export {
63
64
  a as default,
64
- T as handleBuildUtxosMessage,
65
- k as handleDecipherMessage,
66
- U as handleFilterUtxosWithNullifier,
67
- v as onWorkerMessage
65
+ k as handleBuildUtxosMessage,
66
+ v as handleDecipherMessage,
67
+ T as handleFilterUtxosWithNullifier,
68
+ w as onWorkerMessage
68
69
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class s{isNode=!1;onmessage=null;_eventEmitter;get eventEmitter(){if(this._eventEmitter)return this._eventEmitter;const e=require("events");return this._eventEmitter=new e,this._eventEmitter}constructor(){this.isNode=typeof process<"u"&&process.versions!=null&&process.versions.node!=null}terminate(){}postMessage(e){if(this.isNode){this.eventEmitter.emit("message",e);return}else postMessage(e)}postMessageToMainThread(e){if(this.isNode){const t={data:e};this.onmessage&&this.onmessage(t)}else postMessage(e)}attachWorkerSideOnMessage(e){this.isNode&&this.eventEmitter.on("message",t=>{e(t)})}}exports.WorkerProxy=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs");class i{isNode=!1;onmessage=null;_eventEmitter;get eventEmitter(){if(this._eventEmitter)return this._eventEmitter;const e=require("events");return this._eventEmitter=new e,this._eventEmitter}constructor(){this.isNode=typeof s.default<"u"&&s.default.versions!=null&&s.default.versions.node!=null}terminate(){}postMessage(e){if(this.isNode){this.eventEmitter.emit("message",e);return}else postMessage(e)}postMessageToMainThread(e){if(this.isNode){const t={data:e};this.onmessage&&this.onmessage(t)}else postMessage(e)}attachWorkerSideOnMessage(e){this.isNode&&this.eventEmitter.on("message",t=>{e(t)})}}exports.WorkerProxy=i;
@@ -1,4 +1,5 @@
1
- class i {
1
+ import s from "../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
2
+ class r {
2
3
  isNode = !1;
3
4
  /**
4
5
  * This allow browser or main thread to listen for worker response message
@@ -18,7 +19,7 @@ class i {
18
19
  return this._eventEmitter = new e(), this._eventEmitter;
19
20
  }
20
21
  constructor() {
21
- this.isNode = typeof process < "u" && process.versions != null && process.versions.node != null;
22
+ this.isNode = typeof s < "u" && s.versions != null && s.versions.node != null;
22
23
  }
23
24
  terminate() {
24
25
  }
@@ -52,5 +53,5 @@ class i {
52
53
  }
53
54
  }
54
55
  export {
55
- i as WorkerProxy
56
+ r as WorkerProxy
56
57
  };
@@ -1 +1 @@
1
- "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-BwaZD8dV.js").href:new URL("../../assets/zkProofWorkerLauncher-BwaZD8dV.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/zkProofWorkerLauncher-D1YLF2Yw.js").href:new URL("../../assets/zkProofWorkerLauncher-D1YLF2Yw.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
@@ -1,4 +1,4 @@
1
- const r = "" + new URL("../../assets/zkProofWorkerLauncher-BwaZD8dV.js", import.meta.url).href;
1
+ const r = "" + new URL("../../assets/zkProofWorkerLauncher-D1YLF2Yw.js", import.meta.url).href;
2
2
  export {
3
3
  r as default
4
4
  };