@hinkal/common 0.1.7 → 0.1.9

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