@hinkal/common 0.0.104 → 0.0.106

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 (272) hide show
  1. package/API/API.js +58 -0
  2. package/API/HinkalPointsCalls.js +38 -0
  3. package/API/callBeefyGraphAPI.js +37 -0
  4. package/API/callCurveAPI.js +156 -0
  5. package/API/callMonitor.js +30 -0
  6. package/API/callOdosAPI.js +44 -0
  7. package/API/callOneInchAPI.js +37 -0
  8. package/API/callRelayer.js +32 -0
  9. package/API/checkRisk.js +30 -0
  10. package/API/dataServerCalls.js +32 -0
  11. package/API/fetchCommitmentsCache.js +31 -0
  12. package/API/fetchNullifiers.js +30 -0
  13. package/API/getAxelarGasEstimate.js +37 -0
  14. package/API/getCoingeckoPrice.js +27 -0
  15. package/API/getConnextReceiveFee.js +30 -0
  16. package/API/getGasEstimates.js +38 -0
  17. package/API/getRelayerURL.js +32 -0
  18. package/API/getServerURL.js +67 -0
  19. package/API/getTokenPrice.js +41 -0
  20. package/API/kycCalls.js +32 -0
  21. package/API/passwordCalls.js +36 -0
  22. package/API/referralProgramCalls.js +58 -0
  23. package/API/relayCalls.js +30 -0
  24. package/API/restoreSnapshots.js +32 -0
  25. package/API/rewardsPointsCalls.js +40 -0
  26. package/API/userVerifyTransactions.js +45 -0
  27. package/README.md +116 -1
  28. package/assets/{snarkjsWorkerLogic-CatB8Hso.js → snarkjsWorkerLogic-Fv0M38Mc.js} +2 -2
  29. package/assets/{utxoWorkerLogic-DDqTe7hT.js → utxoWorkerLogic-CtFLQiAX.js} +2 -2
  30. package/assets/{zkProofWorkerLauncher-C-pvCm0b.js → zkProofWorkerLauncher-J3Ts5_Ba.js} +1 -1
  31. package/assets/{zkProofWorkerLogic-CLpRqNRx.js → zkProofWorkerLogic-CPNuu61R.js} +18 -19
  32. package/constants/assets.constants.js +16 -0
  33. package/constants/axelar.constants.js +55 -0
  34. package/constants/backend.constants.js +18 -0
  35. package/constants/beefy.registry.js +24 -0
  36. package/constants/chains.constants.js +204 -0
  37. package/constants/coingecko.constants.js +53 -0
  38. package/constants/contracts.constants.js +276 -0
  39. package/constants/crvCvx.registry.js +636 -0
  40. package/constants/crvDynamic.registry.js +24 -0
  41. package/constants/deploy-data/deploy-data-arbMainnet.json.js +7415 -0
  42. package/constants/deploy-data/deploy-data-avalanche.json.js +7411 -0
  43. package/constants/deploy-data/deploy-data-axelar1.json.js +4329 -0
  44. package/constants/deploy-data/deploy-data-axelar2.json.js +4329 -0
  45. package/constants/deploy-data/deploy-data-base.json.js +8425 -0
  46. package/constants/deploy-data/deploy-data-blast.json.js +9600 -0
  47. package/constants/deploy-data/deploy-data-bnbMainnet.json.js +6877 -0
  48. package/constants/deploy-data/deploy-data-ethMainnet.json.js +11427 -0
  49. package/constants/deploy-data/deploy-data-localhost.json.js +13283 -0
  50. package/constants/deploy-data/deploy-data-optimism.json.js +7417 -0
  51. package/constants/deploy-data/deploy-data-polygon.json.js +7439 -0
  52. package/constants/fees.constants.js +57 -0
  53. package/constants/kyc.constants.js +118 -0
  54. package/constants/lido.constants.js +13 -0
  55. package/constants/pendle.registry.js +253 -0
  56. package/constants/protocol.constants.js +26 -0
  57. package/constants/reorg-depths.constants.js +15 -0
  58. package/constants/rewards.constants.js +27 -0
  59. package/constants/server.constants.js +157 -0
  60. package/constants/token-data/ERC20Registry.js +85 -0
  61. package/constants/token-data/arbMainnetRegistry.json.js +946 -0
  62. package/constants/token-data/arbMainnetRegistryFixed.json.js +856 -0
  63. package/constants/token-data/avalancheRegistry.json.js +591 -0
  64. package/constants/token-data/avalancheRegistryFixed.json.js +591 -0
  65. package/constants/token-data/baseRegistry.json.js +490 -0
  66. package/constants/token-data/baseRegistryFixed.json.js +463 -0
  67. package/constants/token-data/blastRegistry.json.js +137 -0
  68. package/constants/token-data/blastRegistryFixed.json.js +137 -0
  69. package/constants/token-data/bnbMainnetRegistry.json.js +973 -0
  70. package/constants/token-data/bnbMainnetRegistryFixed.json.js +973 -0
  71. package/constants/token-data/coingeckoRegistry.json.js +115623 -0
  72. package/constants/token-data/ethMainnetRegistry.json.js +2700 -0
  73. package/constants/token-data/ethMainnetRegistryFixed.json.js +2251 -0
  74. package/constants/token-data/index.js +6 -0
  75. package/constants/token-data/localhostRegistry.json.js +2768 -0
  76. package/constants/token-data/optimismRegistry.json.js +1455 -0
  77. package/constants/token-data/optimismRegistryFixed.json.js +1392 -0
  78. package/constants/token-data/polygonRegistry.json.js +1327 -0
  79. package/constants/token-data/polygonRegistryFixed.json.js +1255 -0
  80. package/constants/token-data/popularTokens.constants.js +14 -0
  81. package/constants/token-data/tokenPricing.consts.js +8 -0
  82. package/constants/vite.constants.js +29 -0
  83. package/crypto/babyJub.js +15 -0
  84. package/crypto/poseidon.js +26 -0
  85. package/crypto/preProcessing.js +9 -0
  86. package/data-structures/Hinkal/Hinkal.js +299 -0
  87. package/data-structures/Hinkal/hinkalActionBeefy.js +101 -0
  88. package/data-structures/Hinkal/hinkalActionConvex.js +83 -0
  89. package/data-structures/Hinkal/hinkalActionCurve.js +112 -0
  90. package/data-structures/Hinkal/hinkalActionLidoEth.js +91 -0
  91. package/data-structures/Hinkal/hinkalActionPendle.js +140 -0
  92. package/data-structures/Hinkal/hinkalActionPendleLP.js +96 -0
  93. package/data-structures/Hinkal/hinkalActionStake.js +138 -0
  94. package/data-structures/Hinkal/hinkalActionVolatile.js +112 -0
  95. package/data-structures/Hinkal/hinkalDeposit.js +95 -0
  96. package/data-structures/Hinkal/hinkalGetZkMeProvider.js +47 -0
  97. package/data-structures/Hinkal/hinkalPrivateWallet.js +66 -0
  98. package/data-structures/Hinkal/hinkalSwap.js +98 -0
  99. package/data-structures/Hinkal/hinkalTransfer.js +5 -0
  100. package/data-structures/Hinkal/hinkalWithdraw.js +91 -0
  101. package/data-structures/Hinkal/resetMerkleTrees.js +49 -0
  102. package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.js +83 -0
  103. package/data-structures/ValueCache/ValueCache.js +25 -0
  104. package/data-structures/crypto-keys/decodeUTXO.js +40 -0
  105. package/data-structures/crypto-keys/encryptDecryptUtxo.js +41 -0
  106. package/data-structures/crypto-keys/keyUtils.js +10 -0
  107. package/data-structures/crypto-keys/keys.js +90 -0
  108. package/data-structures/custom-token-registry/CustomTokenRegistry.js +33 -0
  109. package/data-structures/event-service/AbstractAccessTokenSnapshotService.js +131 -0
  110. package/data-structures/event-service/AbstractCommitmentsSnapshotService.js +132 -0
  111. package/data-structures/event-service/AbstractEventService.js +118 -0
  112. package/data-structures/event-service/AbstractNullifierSnapshotService.js +59 -0
  113. package/data-structures/event-service/AbstractSnapshotService.js +35 -0
  114. package/data-structures/merkle-tree/MerkleTree.js +177 -0
  115. package/data-structures/merkle-tree/MerkleTreeIncompleteError.js +8 -0
  116. package/data-structures/snapshot/ClientAccessTokenSnapshotService.js +48 -0
  117. package/data-structures/snapshot/ClientCommitmentsSnapshotService.js +47 -0
  118. package/data-structures/snapshot/ClientNullifierSnapshotService.js +44 -0
  119. package/data-structures/token-price-fetcher/TokenChecker.js +29 -0
  120. package/data-structures/token-price-fetcher/TokenPriceFetcher.js +218 -0
  121. package/data-structures/transactions-manager/TransactionsManager.js +194 -0
  122. package/data-structures/transactions-manager/history/getBeefyData.js +68 -0
  123. package/data-structures/transactions-manager/history/getConvexData.js +57 -0
  124. package/data-structures/transactions-manager/history/getCurveData.js +97 -0
  125. package/data-structures/transactions-manager/history/getDepositData.js +36 -0
  126. package/data-structures/transactions-manager/history/getLidoData.js +44 -0
  127. package/data-structures/transactions-manager/history/getPendleData.js +59 -0
  128. package/data-structures/transactions-manager/history/getSwapData.js +43 -0
  129. package/data-structures/transactions-manager/history/getTxDetails.js +74 -0
  130. package/data-structures/transactions-manager/history/getVolatileData.js +75 -0
  131. package/data-structures/transactions-manager/history/history.types.js +62 -0
  132. package/data-structures/transactions-manager/history/history.utils.js +8 -0
  133. package/data-structures/utxo/Utxo.js +134 -0
  134. package/data-structures/volatile-helper/VolatileHelper.js +181 -0
  135. package/error-handling/customErrors/ErrorWithAmount.js +9 -0
  136. package/error-handling/customErrors/FeeOverTransactionValueError.js +9 -0
  137. package/error-handling/customErrors/customErrors.helpers.js +21 -0
  138. package/error-handling/error-codes.constants.js +184 -0
  139. package/error-handling/get-error.message.js +53 -0
  140. package/error-handling/handleErrorRestore.js +35 -0
  141. package/error-handling/logError.js +7 -0
  142. package/error-handling/types.js +4 -0
  143. package/externalABIs/BUSD.js +519 -0
  144. package/externalABIs/BabPassport.json.js +24 -0
  145. package/externalABIs/BeefyRouterAbi.json.js +1022 -0
  146. package/externalABIs/BeefyStrategyAbi.json.js +1423 -0
  147. package/externalABIs/BeefyVaultAbi.json.js +570 -0
  148. package/externalABIs/BeefyZapAbi.json.js +208 -0
  149. package/externalABIs/BeefyZapOneInchAbi.json.js +340 -0
  150. package/externalABIs/ConvexBoosterAbi.json.js +674 -0
  151. package/externalABIs/ConvexBoosterAbiMainnet.json.js +1002 -0
  152. package/externalABIs/ConvexRewardPoolAbi.json.js +883 -0
  153. package/externalABIs/CurveReadingWrapperAbi.json.js +1422 -0
  154. package/externalABIs/CurveWrappedMainPool.json.js +1136 -0
  155. package/externalABIs/CurveZap.json.js +262 -0
  156. package/externalABIs/CvxCrvUtilities.json.js +264 -0
  157. package/externalABIs/DAI.js +334 -0
  158. package/externalABIs/ERC20.json.js +291 -0
  159. package/externalABIs/GalxePassport.json.js +41 -0
  160. package/externalABIs/IQuoterV2.json.js +205 -0
  161. package/externalABIs/ISwapRouter.json.js +568 -0
  162. package/externalABIs/IUniswapV3Factory.json.js +201 -0
  163. package/externalABIs/IUniswapV3Pool.json.js +999 -0
  164. package/externalABIs/LidoStEthAbi.json.js +1603 -0
  165. package/externalABIs/LidoStMaticAbi.json.js +1764 -0
  166. package/externalABIs/LidoStakeManagerAbi.json.js +2082 -0
  167. package/externalABIs/LidoWithdrawalQueueERC721Abi.json.js +2030 -0
  168. package/externalABIs/LidoWstEthAbi.json.js +480 -0
  169. package/externalABIs/OptimismGasPriceOracle.json.js +206 -0
  170. package/externalABIs/PendleRouterAbi.json.js +173 -0
  171. package/externalABIs/PoLidoNftAbi.json.js +701 -0
  172. package/externalABIs/SanctionsList.js +89 -0
  173. package/externalABIs/USDC.js +721 -0
  174. package/externalABIs/USDR.js +346 -0
  175. package/externalABIs/USDR3CRV.js +542 -0
  176. package/externalABIs/USDT.js +393 -0
  177. package/externalABIs/UniswapV2PoolAbi.json.js +80 -0
  178. package/externalABIs/WETH.js +156 -0
  179. package/externalABIs/amToken.js +350 -0
  180. package/externalABIs/transactionsProver.json.js +39 -0
  181. package/functions/kyc/authentoHelper.js +42 -0
  182. package/functions/kyc/passportHelper.js +39 -0
  183. package/functions/kyc/zkMeHelper.js +56 -0
  184. package/functions/pre-transaction/getFlatFees.js +203 -0
  185. package/functions/pre-transaction/interaction-to-action.js +57 -0
  186. package/functions/pre-transaction/outputUtxoProcessing.js +45 -0
  187. package/functions/pre-transaction/process-gas-estimates.js +57 -0
  188. package/functions/pre-transaction/processAmountChanges.js +229 -0
  189. package/functions/private-wallet/emporium.helpers.js +19 -0
  190. package/functions/private-wallet/opProducer.js +24 -0
  191. package/functions/protocols/convex.protocols.js +41 -0
  192. package/functions/protocols/curve.protocols.js +45 -0
  193. package/functions/protocols/pendle.helpers.js +108 -0
  194. package/functions/snarkjs/common.snarkjs.js +96 -0
  195. package/functions/snarkjs/constant.js +211 -0
  196. package/functions/snarkjs/constructEmporiumProof.js +105 -0
  197. package/functions/snarkjs/constructGeneralZkProof.js +129 -0
  198. package/functions/snarkjs/generateCircomData.js +60 -0
  199. package/functions/snarkjs/generateZkProof.js +18 -0
  200. package/functions/snarkjs/getZKFiles.js +30 -0
  201. package/functions/staking/index.js +40 -0
  202. package/functions/utils/amounts.utils.js +70 -0
  203. package/functions/utils/axelar.utils.js +38 -0
  204. package/functions/utils/cacheFunctions.js +67 -0
  205. package/functions/utils/caseInsensitive.utils.js +6 -0
  206. package/functions/utils/convertIntegrationProviderToExternalActionId.js +16 -0
  207. package/functions/utils/create-provider.js +5 -0
  208. package/functions/utils/enum.utils.js +14 -0
  209. package/functions/utils/erc20tokenFunctions.js +20 -0
  210. package/functions/utils/evmNetworkFunctions.js +29 -0
  211. package/functions/utils/external-action.utils.js +61 -0
  212. package/functions/utils/getDataFromTransaction.js +105 -0
  213. package/functions/utils/memoize.utils.js +14 -0
  214. package/functions/utils/nickname.utils.js +7 -0
  215. package/functions/utils/process.utils.js +4 -0
  216. package/functions/utils/reloadPage.js +4 -0
  217. package/functions/utils/requireEnv.js +7 -0
  218. package/functions/utils/resolve-sync.utils.js +22 -0
  219. package/functions/utils/serialize.utils.js +4 -0
  220. package/functions/utils/string.utils.js +14 -0
  221. package/functions/utils/time.utils.js +8 -0
  222. package/functions/utils/userAgent.js +15 -0
  223. package/functions/utils/volatile-patcher.utils.js +40 -0
  224. package/functions/web3/etherFunctions.js +41 -0
  225. package/functions/web3/events/balanceChangedHandler.js +10 -0
  226. package/functions/web3/events/getInputUtxoAndBalance.js +72 -0
  227. package/functions/web3/events/getShieldedBalance.js +107 -0
  228. package/functions/web3/events/web3RetrieveEvents.js +9 -0
  229. package/functions/web3/functionCalls/accessTokenCalls.js +48 -0
  230. package/functions/web3/functionCalls/approveToken.js +153 -0
  231. package/functions/web3/functionCalls/estimateGasRelayer.js +18 -0
  232. package/functions/web3/functionCalls/transactCallDirect.js +60 -0
  233. package/functions/web3/functionCalls/transactCallRelayer.js +42 -0
  234. package/functions/web3/odosAPI.js +65 -0
  235. package/functions/web3/oneInchAPI.js +61 -0
  236. package/functions/web3/runContractFunction.js +95 -0
  237. package/functions/web3/uniswapAPI.js +97 -0
  238. package/index.js +644 -0
  239. package/package.json +5 -4
  240. package/types/beefy.types.js +21 -0
  241. package/types/circom-data.types.js +22 -0
  242. package/types/curve.types.js +25 -0
  243. package/types/ethereum-network.types.js +4 -0
  244. package/types/external-action.types.js +4 -0
  245. package/types/hinkal.stake.types.js +4 -0
  246. package/types/hinkal.types.js +15 -0
  247. package/types/kyc.types.js +13 -0
  248. package/types/pendle.types.js +15 -0
  249. package/types/rewards.types.js +27 -0
  250. package/types/slippage.types.js +15 -0
  251. package/types/time.types.js +58 -0
  252. package/types/token.types.js +4 -0
  253. package/types/transactions.types.js +36 -0
  254. package/webworker/performTaskWithWorker.js +62 -0
  255. package/webworker/snarkjsWorker/snarkjsWorker.types.js +4 -0
  256. package/webworker/snarkjsWorker/snarkjsWorkerLogic.js +32 -0
  257. package/webworker/utxoWorker/utxoWorker.types.js +4 -0
  258. package/webworker/utxoWorker/utxoWorkerLogic.js +70 -0
  259. package/webworker/viteWorkerURL.constant.d.ts +3 -3
  260. package/webworker/worker.registry.js +4 -0
  261. package/webworker/workerFactory.d.ts +0 -1
  262. package/webworker/workerFactory.js +42 -0
  263. package/{workerProxy-BDj498Ht.mjs → webworker/workerProxy.js} +1 -1
  264. package/webworker/zkProofWorker/zkProofWorker.types.js +4 -0
  265. package/webworker/zkProofWorker/zkProofWorkerLogic.js +66 -0
  266. package/assets/viteWorkerURL.constant-DrIQXA2B.js +0 -11
  267. package/index-DbehuQxV.mjs +0 -398145
  268. package/index.mjs +0 -457
  269. package/snarkjsWorkerLogic-BpNWzeoy.mjs +0 -12086
  270. package/utxoWorkerLogic-D7NuHk_K.mjs +0 -64
  271. package/viteWorkerURL.constant-Bc7ufzqC.mjs +0 -9
  272. package/zkProofWorkerLogic-Bnalmuka.mjs +0 -60
@@ -0,0 +1,45 @@
1
+ import { getNonLocalhostChainId as o, chainIds as t } from "../../constants/chains.constants.js";
2
+ import "../../types/circom-data.types.js";
3
+ import "../../types/transactions.types.js";
4
+ import "../../types/curve.types.js";
5
+ import "ethers";
6
+ import "circomlibjs";
7
+ import "../../data-structures/crypto-keys/keys.js";
8
+ import "axios";
9
+ import "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
10
+ import "../web3/events/getShieldedBalance.js";
11
+ import "../../webworker/workerFactory.js";
12
+ import "../utils/external-action.utils.js";
13
+ import "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
14
+ import "../utils/convertIntegrationProviderToExternalActionId.js";
15
+ import "../../constants/coingecko.constants.js";
16
+ import "../../constants/vite.constants.js";
17
+ import "../utils/userAgent.js";
18
+ import "../../constants/reorg-depths.constants.js";
19
+ import "../../constants/kyc.constants.js";
20
+ import "../../data-structures/volatile-helper/VolatileHelper.js";
21
+ import "libsodium-wrappers";
22
+ import "../../constants/contracts.constants.js";
23
+ import "../../constants/axelar.constants.js";
24
+ import "../../constants/rewards.constants.js";
25
+ const v = (r) => {
26
+ switch (o(r)) {
27
+ case t.polygon:
28
+ return "0x172370d5Cd63279eFa6d502DAB29171933a610AF";
29
+ case t.arbMainnet:
30
+ return "0x11cdb42b0eb46d95f990bedd4695a6e3fa034978";
31
+ case t.ethMainnet:
32
+ return "0xD533a949740bb3306d119CC777fa900bA034cd52";
33
+ case t.avalanche:
34
+ return "0x47536F17F4fF30e64A96a7555826b8f9e66ec468";
35
+ case t.optimism:
36
+ return "0x0994206dfe8de6ec6920ff4d779b0d950605fb53";
37
+ case t.base:
38
+ return "0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415";
39
+ default:
40
+ return "0xD533a949740bb3306d119CC777fa900bA034cd52";
41
+ }
42
+ };
43
+ export {
44
+ v as getCRV
45
+ };
@@ -0,0 +1,108 @@
1
+ import "../../constants/chains.constants.js";
2
+ import "../../types/circom-data.types.js";
3
+ import { PendleAction as n } from "../../types/hinkal.types.js";
4
+ import "../../types/transactions.types.js";
5
+ import { PendleAssetType as i, PendleSwapType as t } from "../../types/pendle.types.js";
6
+ import "../../types/curve.types.js";
7
+ import "ethers";
8
+ import "circomlibjs";
9
+ import "../../data-structures/crypto-keys/keys.js";
10
+ import "axios";
11
+ import "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
12
+ import "../web3/events/getShieldedBalance.js";
13
+ import "../../webworker/workerFactory.js";
14
+ import "../utils/external-action.utils.js";
15
+ import { getERC20Token as T } from "../utils/erc20tokenFunctions.js";
16
+ import "../utils/convertIntegrationProviderToExternalActionId.js";
17
+ import "../../constants/coingecko.constants.js";
18
+ import { API_CONFIG as p } from "../../constants/server.constants.js";
19
+ import "../../constants/vite.constants.js";
20
+ import { caseInsensitiveEqual as d } from "../utils/caseInsensitive.utils.js";
21
+ import "../utils/userAgent.js";
22
+ import "../../constants/reorg-depths.constants.js";
23
+ import "../../constants/kyc.constants.js";
24
+ import { isInEnum as w } from "../utils/enum.utils.js";
25
+ import "../../data-structures/volatile-helper/VolatileHelper.js";
26
+ import "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
27
+ import "libsodium-wrappers";
28
+ import "../../constants/contracts.constants.js";
29
+ import "../../constants/axelar.constants.js";
30
+ import "../../constants/rewards.constants.js";
31
+ function H(e) {
32
+ if (!e)
33
+ return;
34
+ const r = T(e.address, e.chainId);
35
+ if (!r?.isVolatile)
36
+ return r?.symbol.toLowerCase() === "weth" && console.log("token:", r), r;
37
+ }
38
+ function J(e, r) {
39
+ if (!e || !r)
40
+ return;
41
+ let o;
42
+ switch (r) {
43
+ case i.YT:
44
+ o = e?.yt;
45
+ break;
46
+ case i.PT:
47
+ o = e?.pt;
48
+ break;
49
+ case i.PENDLE_LP:
50
+ o = e?.lp;
51
+ break;
52
+ case i.SY:
53
+ o = e?.sy;
54
+ break;
55
+ default:
56
+ o = void 0;
57
+ break;
58
+ }
59
+ return o;
60
+ }
61
+ const K = (e, r, o) => {
62
+ if (d(e.yt.address, o.erc20TokenAddress))
63
+ return t.SwapExactTokenForYt;
64
+ if (d(e.pt.address, o.erc20TokenAddress))
65
+ return t.SwapExactTokenForPt;
66
+ if (d(e.yt.address, r.erc20TokenAddress))
67
+ return t.SwapExactYtForToken;
68
+ if (d(e.pt.address, r.erc20TokenAddress))
69
+ return t.SwapExactPtForToken;
70
+ }, Q = (e) => {
71
+ let r;
72
+ switch (e) {
73
+ case t.SwapExactTokenForYt:
74
+ r = p.ROUTES.pendleSwapExactTokenForYT;
75
+ break;
76
+ case t.SwapExactTokenForPt:
77
+ r = p.ROUTES.pendleSwapExactTokenForPt;
78
+ break;
79
+ case t.SwapExactYtForToken:
80
+ r = p.ROUTES.pendleSwapExactYtForToken;
81
+ break;
82
+ case t.SwapExactPtForToken:
83
+ r = p.ROUTES.pendleSwapExactPtForToken;
84
+ break;
85
+ default:
86
+ throw new Error("Cant determine Pendle Swap Type Api Route");
87
+ }
88
+ return r;
89
+ }, W = (e, r, o, s) => {
90
+ if (!w(n, e))
91
+ throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");
92
+ if (s)
93
+ return o.findIndex(
94
+ (a) => a.toLowerCase() === s?.toLowerCase()
95
+ );
96
+ const l = r.findIndex((a) => a > 0n), c = r.length - 1;
97
+ if (r[c] <= 0n)
98
+ throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");
99
+ let m = l;
100
+ return (e === n.Mint || e === n.Redeem || e === n.PoolRemove) && (m = l), m;
101
+ };
102
+ export {
103
+ K as determinePendleSwapType,
104
+ Q as determinePendleSwapTypeApiRoute,
105
+ H as erc20TokenFromPendleAsset,
106
+ J as getAssetTypeFromPendleMarket,
107
+ W as getTokenIndexForPendleFlatFee
108
+ };
@@ -0,0 +1,96 @@
1
+ import { ethers as i } from "ethers";
2
+ import { CIRCOM_P as u } from "../../constants/protocol.constants.js";
3
+ import { UserKeys as g } from "../../data-structures/crypto-keys/keys.js";
4
+ import { encryptUtxo as h } from "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
5
+ import { defaultHookData as S } from "../../types/circom-data.types.js";
6
+ import { getExternalActionIdHash as m } from "../utils/external-action.utils.js";
7
+ const k = (t, e) => t.map((r, n) => r.map((s) => e[n] ? "0" : s.getNullifier())), B = (t, e) => t.map((r, n) => r.map((s) => e[n] ? "0" : s.getCommitment())), y = (t, e, r = !1) => {
8
+ const n = [];
9
+ for (let s = 0; s < t.length; s += 1) {
10
+ let o = 0n, l = 0n;
11
+ for (let a = 0; a < t[s].length; a += 1)
12
+ o += t[s][a].amount;
13
+ for (let a = 0; a < e[s].length; a += 1)
14
+ l += e[s][a].amount;
15
+ l - o < 0 ? r ? n.push(l - o) : n.push(u + (l - o)) : n.push(l - o);
16
+ }
17
+ return n;
18
+ }, O = (t, e) => {
19
+ const r = [[""]];
20
+ for (let n = 0; n < t.length; n += 1)
21
+ n > 0 && r.push([""]), t[n].forEach((s, o) => {
22
+ r[n][o] = `0x${Buffer.from(h(s, e)).toString("hex")}`;
23
+ });
24
+ return r;
25
+ }, T = (t, e) => {
26
+ const r = [];
27
+ for (let s = 0; s < t.length; s += 1) {
28
+ r.push([]);
29
+ for (let o = 0; o < t[s].length; o += 1)
30
+ r[s][o] = e.getSiblingHashesForVerification(BigInt(t[s][o].getCommitment())).map((l) => l.toString());
31
+ }
32
+ const n = [];
33
+ for (let s = 0; s < t.length; s += 1) {
34
+ n.push([]);
35
+ for (let o = 0; o < t[s].length; o += 1)
36
+ n[s][o] = e.getSiblingSides(BigInt(t[s][o].getCommitment())).map((l) => l.toString());
37
+ }
38
+ return { inCommitmentSiblings: r, inCommitmentSiblingSides: n };
39
+ }, j = (t, e) => {
40
+ const r = e.getSiblingHashesForVerification(BigInt(t.getAccessKey())).map((s) => s.toString()), n = e.getSiblingSides(BigInt(t.getAccessKey())).map((s) => s.toString());
41
+ return { accessTokenSiblings: r, accessTokenSiblingSides: n };
42
+ }, E = (t) => {
43
+ const e = { ...t };
44
+ return e.amountChanges = t.amountChanges.map((r) => r.toString()), e.calldataHash = t.calldataHash.toString(), e.rootHashAccessToken = t.rootHashAccessToken?.toString(), e.stealthAddressStructure.extraRandomization = t.stealthAddressStructure.extraRandomization.toString(), e.stealthAddressStructure.stealthAddress = t.stealthAddressStructure.stealthAddress.toString(), e.stealthAddressStructure.H0 = t.stealthAddressStructure.H0.toString(), e.stealthAddressStructure.H1 = t.stealthAddressStructure.H1.toString(), e.rootHashHinkal = t.rootHashHinkal?.toString(), e.externalActionId = t.externalActionId?.toString(), e.flatFees = t.flatFees.map((r) => r.toString()), e;
45
+ }, F = (t) => {
46
+ const e = { ...t };
47
+ return e.amountChanges = t.amountChanges.map((r) => BigInt(r)), e.calldataHash = BigInt(t.calldataHash), e.rootHashAccessToken = BigInt(t.rootHashAccessToken), e.rootHashHinkal = BigInt(t.rootHashHinkal), e.externalActionId = BigInt(t.externalActionId), e;
48
+ }, M = (t, e, r, n, s, o, l, a) => {
49
+ const d = Object.values(a || S), c = i.utils.defaultAbiCoder.encode(
50
+ [
51
+ "uint16",
52
+ "address",
53
+ "address",
54
+ "uint256",
55
+ "bytes",
56
+ "tuple(address, address, bytes, bytes)",
57
+ "bytes[][]",
58
+ "uint256[]"
59
+ ],
60
+ [
61
+ t,
62
+ e,
63
+ r,
64
+ typeof n == "bigint" ? n : m(n),
65
+ s,
66
+ d,
67
+ o,
68
+ l
69
+ ]
70
+ );
71
+ return BigInt(i.utils.keccak256(c)) % u;
72
+ }, f = (t) => t.startsWith("swapperMO") || t.startsWith("swapperME") ? 2 : t.startsWith("swapperMW") ? 1 : 0, W = (t, e, r, n, s, o) => {
73
+ const l = f(t);
74
+ return 9 + e.length + r.length + n.flat().length + s.length + l + o;
75
+ }, w = (t, e) => {
76
+ const { h0: r, h1: n } = g.getStealthAddressCompressedPoints(t, e), s = BigInt(g.getStealthAddress(t, e));
77
+ return {
78
+ extraRandomization: t,
79
+ H0: r,
80
+ H1: n,
81
+ stealthAddress: s
82
+ };
83
+ };
84
+ export {
85
+ k as buildInNullifiers,
86
+ B as buildOutCommitments,
87
+ j as calcAccessTokenSiblingsAndSides,
88
+ y as calcAmountChanges,
89
+ T as calcCommitmentsSiblingAndSides,
90
+ O as calcEncryptedOutputs,
91
+ W as calcPublicSignalCount,
92
+ w as calcStealthAddressStructure,
93
+ M as createCallDataHash,
94
+ F as deserializeCircomData,
95
+ E as serializeCircomData
96
+ };
@@ -0,0 +1,211 @@
1
+ import { chainIds as e } from "../../constants/chains.constants.js";
2
+ import "../../types/circom-data.types.js";
3
+ import "../../types/transactions.types.js";
4
+ import "../../types/curve.types.js";
5
+ import "ethers";
6
+ import "circomlibjs";
7
+ import "../../data-structures/crypto-keys/keys.js";
8
+ import "axios";
9
+ import "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
10
+ import "../web3/events/getShieldedBalance.js";
11
+ import "../../webworker/workerFactory.js";
12
+ import "../utils/external-action.utils.js";
13
+ import "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
14
+ import "../utils/convertIntegrationProviderToExternalActionId.js";
15
+ import "../../constants/coingecko.constants.js";
16
+ import { logError as x } from "../../error-handling/logError.js";
17
+ import "../utils/userAgent.js";
18
+ import "../../constants/reorg-depths.constants.js";
19
+ import "../../constants/kyc.constants.js";
20
+ import "../../data-structures/volatile-helper/VolatileHelper.js";
21
+ import "libsodium-wrappers";
22
+ import "../../constants/vite.constants.js";
23
+ import "../../constants/contracts.constants.js";
24
+ import "../../constants/axelar.constants.js";
25
+ import "../../constants/rewards.constants.js";
26
+ const p = {
27
+ ethMainnet: "https://hinkal-zk-verifiers-may-2024.s3.us-west-1.amazonaws.com/",
28
+ polygon: "https://hinkal-zk-new-verifiers.s3.us-west-1.amazonaws.com/",
29
+ bnb: "https://hinkal-zk-verifiers-may-2024.s3.us-west-1.amazonaws.com/",
30
+ arbitrum: "https://hinkal-zk-verifiers-may-2024.s3.us-west-1.amazonaws.com/",
31
+ optimism: "https://hinkal-zk-new-verifiers.s3.us-west-1.amazonaws.com/",
32
+ avalanche: "https://hinkal-zk-new-verifiers.s3.us-west-1.amazonaws.com/",
33
+ base: "https://hinkal-zk-verifiers-may-2024.s3.us-west-1.amazonaws.com/",
34
+ blast: "https://hinkal-zk-verifiers-may-2024.s3.us-west-1.amazonaws.com/"
35
+ }, r = (s) => {
36
+ switch (s) {
37
+ case e.ethMainnet:
38
+ return p.ethMainnet;
39
+ case e.polygon:
40
+ return p.polygon;
41
+ case e.bnbMainnet:
42
+ return p.bnb;
43
+ case e.arbMainnet:
44
+ return p.arbitrum;
45
+ case e.optimism:
46
+ return p.optimism;
47
+ case e.avalanche:
48
+ return p.avalanche;
49
+ case e.base:
50
+ return p.base;
51
+ case e.blast:
52
+ return p.blast;
53
+ default:
54
+ return x("Warning: no S3 bucket specified for selected chainid: ", s), p.polygon;
55
+ }
56
+ }, E = (s) => {
57
+ const a = r(s);
58
+ return {
59
+ swapperM1x2x1Zkey: `${a}swapperM1x2x1_final-31337.zkey`,
60
+ swapperM1x2x1Wasm: `${a}swapperM1x2x1-31337.wasm`,
61
+ swapperM1x6x1Zkey: `${a}swapperM1x6x1_final-31337.zkey`,
62
+ swapperM1x6x1Wasm: `${a}swapperM1x6x1-31337.wasm`,
63
+ swapperME1x2x1Zkey: `${a}swapperME1x2x1_final-31337.zkey`,
64
+ swapperME1x2x1Wasm: `${a}swapperME1x2x1-31337.wasm`,
65
+ swapperM2x2x1Zkey: `${a}swapperM2x2x1_final-31337.zkey`,
66
+ swapperM2x2x1Wasm: `${a}swapperM2x2x1-31337.wasm`,
67
+ swapperM2x6x1Zkey: `${a}swapperM2x6x1_final-31337.zkey`,
68
+ swapperM2x6x1Wasm: `${a}swapperM2x6x1-31337.wasm`,
69
+ swapperMO2x2x1Zkey: `${a}swapperMO2x2x1_final-31337.zkey`,
70
+ swapperMO2x2x1Wasm: `${a}swapperMO2x2x1-31337.wasm`,
71
+ swapperMO2x6x1Zkey: `${a}swapperMO2x6x1_final-31337.zkey`,
72
+ swapperMO2x6x1Wasm: `${a}swapperMO2x6x1-31337.wasm`,
73
+ swapperToken2x2x1Zkey: `${a}swapperToken2x2x1_final-31337.zkey`,
74
+ swapperToken2x2x1Wasm: `${a}swapperToken2x2x1-31337.wasm`,
75
+ swapperToken2x6x1Zkey: `${a}swapperToken2x6x1_final-31337.zkey`,
76
+ swapperToken2x6x1Wasm: `${a}swapperToken2x6x1-31337.wasm`,
77
+ swapperM3x2x1Zkey: `${a}swapperM3x2x1_final-31337.zkey`,
78
+ swapperM3x2x1Wasm: `${a}swapperM3x2x1-31337.wasm`,
79
+ swapperM3x6x1Zkey: `${a}swapperM3x6x1_final-31337.zkey`,
80
+ swapperM3x6x1Wasm: `${a}swapperM3x6x1-31337.wasm`,
81
+ swapperMO3x2x1Zkey: `${a}swapperMO3x2x1_final-31337.zkey`,
82
+ swapperMO3x2x1Wasm: `${a}swapperMO3x2x1-31337.wasm`,
83
+ swapperMO3x6x1Zkey: `${a}swapperMO3x6x1_final-31337.zkey`,
84
+ swapperMO3x6x1Wasm: `${a}swapperMO3x6x1-31337.wasm`,
85
+ swapperM4x2x1Zkey: `${a}swapperM4x2x1_final-31337.zkey`,
86
+ swapperM4x2x1Wasm: `${a}swapperM4x2x1-31337.wasm`,
87
+ swapperM4x6x1Zkey: `${a}swapperM4x6x1_final-31337.zkey`,
88
+ swapperM4x6x1Wasm: `${a}swapperM4x6x1-31337.wasm`,
89
+ swapperMO4x2x1Zkey: `${a}swapperMO4x2x1_final-31337.zkey`,
90
+ swapperMO4x2x1Wasm: `${a}swapperMO4x2x1-31337.wasm`,
91
+ swapperMO4x6x1Zkey: `${a}swapperMO4x6x1_final-31337.zkey`,
92
+ swapperMO4x6x1Wasm: `${a}swapperMO4x6x1-31337.wasm`,
93
+ swapperM5x2x1Zkey: `${a}swapperM5x2x1_final-31337.zkey`,
94
+ swapperM5x2x1Wasm: `${a}swapperM5x2x1-31337.wasm`,
95
+ swapperM5x6x1Zkey: `${a}swapperM5x6x1_final-31337.zkey`,
96
+ swapperM5x6x1Wasm: `${a}swapperM5x6x1-31337.wasm`,
97
+ swapperMO5x2x1Zkey: `${a}swapperMO5x2x1_final-31337.zkey`,
98
+ swapperMO5x2x1Wasm: `${a}swapperMO5x2x1-31337.wasm`,
99
+ swapperMO5x6x1Zkey: `${a}swapperMO5x6x1_final-31337.zkey`,
100
+ swapperMO5x6x1Wasm: `${a}swapperMO5x6x1-31337.wasm`,
101
+ swapperMTS2x2x1Zkey: "swapperMTS2x2x1_final-31337.zkey",
102
+ swapperMTS2x2x1Wasm: "swapperMTS2x2x1-31337.wasm",
103
+ transactionsProverZkey: `${a}transactionsProver.zkey`,
104
+ transactionsProverWasm: `${a}transactionsProver.wasm`,
105
+ stakeProverZkey: `${a}StakeProver_final-31337.zkey`,
106
+ stakeProverWasm: `${a}StakeProver-31337.wasm`,
107
+ stakeProverPermissionlessZkey: `${a}StakeProverPermissionless_final-31337.zkey`,
108
+ stakeProverPermissionlessWasm: `${a}StakeProverPermissionless-31337.wasm`,
109
+ swapperMW1x2Wasm: `${a}swapperMW1x2-31337.wasm`,
110
+ swapperMW1x2Zkey: `${a}swapperMW1x2_final-31337.zkey`,
111
+ swapperMW1x6Wasm: `${a}swapperMW1x6-31337.wasm`,
112
+ swapperMW1x6Zkey: `${a}swapperMW1x6_final-31337.zkey`,
113
+ swapperMW2x2Wasm: `${a}swapperMW2x2-31337.wasm`,
114
+ swapperMW2x2Zkey: `${a}swapperMW2x2_final-31337.zkey`,
115
+ swapperMW2x6Wasm: `${a}swapperMW2x6-31337.wasm`,
116
+ swapperMW2x6Zkey: `${a}swapperMW2x6_final-31337.zkey`,
117
+ swapperMW3x2Wasm: `${a}swapperMW3x2-31337.wasm`,
118
+ swapperMW3x2Zkey: `${a}swapperMW3x2_final-31337.zkey`,
119
+ swapperMW3x6Wasm: `${a}swapperMW3x6-31337.wasm`,
120
+ swapperMW3x6Zkey: `${a}swapperMW3x6_final-31337.zkey`,
121
+ swapperMW4x2Wasm: `${a}swapperMW4x2-31337.wasm`,
122
+ swapperMW4x2Zkey: `${a}swapperMW4x2_final-31337.zkey`,
123
+ swapperMW4x6Wasm: `${a}swapperMW4x6-31337.wasm`,
124
+ swapperMW4x6Zkey: `${a}swapperMW4x6_final-31337.zkey`,
125
+ swapperMW5x2Wasm: `${a}swapperMW5x2-31337.wasm`,
126
+ swapperMW5x2Zkey: `${a}swapperMW5x2_final-31337.zkey`,
127
+ swapperMW5x6Wasm: `${a}swapperMW5x6-31337.wasm`,
128
+ swapperMW5x6Zkey: `${a}swapperMW5x6_final-31337.zkey`
129
+ };
130
+ }, g = {
131
+ swapperM1x2x1Zkey: "swapperM1x2x1_final-31337.zkey",
132
+ swapperM1x2x1Wasm: "swapperM1x2x1-31337.wasm",
133
+ swapperM1x6x1Zkey: "swapperM1x6x1_final-31337.zkey",
134
+ swapperM1x6x1Wasm: "swapperM1x6x1-31337.wasm",
135
+ swapperMO1x2x1Zkey: "swapperMO1x2x1_final-31337.zkey",
136
+ swapperMO1x2x1Wasm: "swapperMO1x2x1-31337.wasm",
137
+ swapperMO1x6x1Zkey: "swapperMO1x6x1_final-31337.zkey",
138
+ swapperMO1x6x1Wasm: "swapperMO1x6x1-31337.wasm",
139
+ swapperME1x2x1Zkey: "swapperME1x2x1_final-31337.zkey",
140
+ swapperME1x2x1Wasm: "swapperME1x2x1-31337.wasm",
141
+ swapperM2x2x1Zkey: "swapperM2x2x1_final-31337.zkey",
142
+ swapperM2x2x1Wasm: "swapperM2x2x1-31337.wasm",
143
+ swapperM2x6x1Zkey: "swapperM2x6x1_final-31337.zkey",
144
+ swapperM2x6x1Wasm: "swapperM2x6x1-31337.wasm",
145
+ swapperMO2x2x1Zkey: "swapperMO2x2x1_final-31337.zkey",
146
+ swapperMO2x2x1Wasm: "swapperMO2x2x1-31337.wasm",
147
+ swapperMO2x6x1Zkey: "swapperMO2x6x1_final-31337.zkey",
148
+ swapperMO2x6x1Wasm: "swapperMO2x6x1-31337.wasm",
149
+ swapperToken2x2x1Zkey: "swapperToken2x2x1_final-31337.zkey",
150
+ swapperToken2x2x1Wasm: "swapperToken2x2x1-31337.wasm",
151
+ swapperToken2x6x1Zkey: "swapperToken2x6x1_final-31337.zkey",
152
+ swapperToken2x6x1Wasm: "swapperToken2x6x1-31337.wasm",
153
+ swapperM3x2x1Zkey: "swapperM3x2x1_final-31337.zkey",
154
+ swapperM3x2x1Wasm: "swapperM3x2x1-31337.wasm",
155
+ swapperM3x6x1Zkey: "swapperM3x6x1_final-31337.zkey",
156
+ swapperM3x6x1Wasm: "swapperM3x6x1-31337.wasm",
157
+ swapperMO3x2x1Zkey: "swapperMO3x2x1_final-31337.zkey",
158
+ swapperMO3x2x1Wasm: "swapperMO3x2x1-31337.wasm",
159
+ swapperMO3x6x1Zkey: "swapperMO3x6x1_final-31337.zkey",
160
+ swapperMO3x6x1Wasm: "swapperMO3x6x1-31337.wasm",
161
+ swapperM4x2x1Zkey: "swapperM4x2x1_final-31337.zkey",
162
+ swapperM4x2x1Wasm: "swapperM4x2x1-31337.wasm",
163
+ swapperM4x6x1Zkey: "swapperM4x6x1_final-31337.zkey",
164
+ swapperM4x6x1Wasm: "swapperM4x6x1-31337.wasm",
165
+ swapperMO4x2x1Zkey: "swapperMO4x2x1_final-31337.zkey",
166
+ swapperMO4x2x1Wasm: "swapperMO4x2x1-31337.wasm",
167
+ swapperMO4x6x1Zkey: "swapperMO4x6x1_final-31337.zkey",
168
+ swapperMO4x6x1Wasm: "swapperMO4x6x1-31337.wasm",
169
+ swapperM5x2x1Zkey: "swapperM5x2x1_final-31337.zkey",
170
+ swapperM5x2x1Wasm: "swapperM5x2x1-31337.wasm",
171
+ swapperM5x6x1Zkey: "swapperM5x6x1_final-31337.zkey",
172
+ swapperM5x6x1Wasm: "swapperM5x6x1-31337.wasm",
173
+ swapperMO5x2x1Zkey: "swapperMO5x2x1_final-31337.zkey",
174
+ swapperMO5x2x1Wasm: "swapperMO5x2x1-31337.wasm",
175
+ swapperMO5x6x1Zkey: "swapperMO5x6x1_final-31337.zkey",
176
+ swapperMO5x6x1Wasm: "swapperMO5x6x1-31337.wasm",
177
+ swapperMTS2x2x1Zkey: "swapperMTS2x2x1_final-31337.zkey",
178
+ swapperMTS2x2x1Wasm: "swapperMTS2x2x1-31337.wasm",
179
+ transactionsProverZkey: "transactionsProver.zkey",
180
+ transactionsProverWasm: "transactionsProver.wasm",
181
+ stakeProverZkey: "StakeProver_final-31337.zkey",
182
+ stakeProverWasm: "StakeProver-31337.wasm",
183
+ stakeProverPermissionlessZkey: "StakeProverPermissionless_final-31337.zkey",
184
+ stakeProverPermissionlessWasm: "StakeProverPermissionless-31337.wasm",
185
+ receiverZkey: "receiver_final-31337.zkey",
186
+ receiverWasm: "receiver-31337.wasm",
187
+ swapperMW1x2Wasm: "swapperMW1x2-31337.wasm",
188
+ swapperMW1x2Zkey: "swapperMW1x2_final-31337.zkey",
189
+ swapperMW1x6Wasm: "swapperMW1x6-31337.wasm",
190
+ swapperMW1x6Zkey: "swapperMW1x6_final-31337.zkey",
191
+ swapperMW2x2Wasm: "swapperMW2x2-31337.wasm",
192
+ swapperMW2x2Zkey: "swapperMW2x2_final-31337.zkey",
193
+ swapperMW2x6Wasm: "swapperMW2x6-31337.wasm",
194
+ swapperMW2x6Zkey: "swapperMW2x6_final-31337.zkey",
195
+ swapperMW3x2Wasm: "swapperMW3x2-31337.wasm",
196
+ swapperMW3x2Zkey: "swapperMW3x2_final-31337.zkey",
197
+ swapperMW3x6Wasm: "swapperMW3x6-31337.wasm",
198
+ swapperMW3x6Zkey: "swapperMW3x6_final-31337.zkey",
199
+ swapperMW4x2Wasm: "swapperMW4x2-31337.wasm",
200
+ swapperMW4x2Zkey: "swapperMW4x2_final-31337.zkey",
201
+ swapperMW4x6Wasm: "swapperMW4x6-31337.wasm",
202
+ swapperMW4x6Zkey: "swapperMW4x6_final-31337.zkey",
203
+ swapperMW5x2Wasm: "swapperMW5x2-31337.wasm",
204
+ swapperMW5x2Zkey: "swapperMW5x2_final-31337.zkey",
205
+ swapperMW5x6Wasm: "swapperMW5x6-31337.wasm",
206
+ swapperMW5x6Zkey: "swapperMW5x6_final-31337.zkey"
207
+ };
208
+ export {
209
+ g as localVerifiers,
210
+ E as prodVerifiers
211
+ };
@@ -0,0 +1,105 @@
1
+ import { Utxo as $ } from "../../data-structures/utxo/Utxo.js";
2
+ import { zeroAddress as V } from "../../constants/protocol.constants.js";
3
+ import { chainIds as j } from "../../constants/chains.constants.js";
4
+ import { ZKProofWorkerActionType as d } from "../../webworker/zkProofWorker/zkProofWorker.types.js";
5
+ import { performTaskWithWorker as p } from "../../webworker/performTaskWithWorker.js";
6
+ import { WorkerVariant as S } from "../../webworker/worker.registry.js";
7
+ import { calcAmountChanges as q, calcEncryptedOutputs as F, buildOutCommitments as Q, calcPublicSignalCount as X, createCallDataHash as Y, calcStealthAddressStructure as x } from "./common.snarkjs.js";
8
+ import { randomBigInt as U } from "../web3/etherFunctions.js";
9
+ import { encodeEmporiumMetadata as tt } from "../private-wallet/emporium.helpers.js";
10
+ import { ExternalActionId as at } from "../../types/external-action.types.js";
11
+ import { defaultHookData as et } from "../../types/circom-data.types.js";
12
+ import { generateCircomData as ot } from "./generateCircomData.js";
13
+ import { generateZkProof as rt } from "./generateZkProof.js";
14
+ const It = async (f, g, a, e, n, _, b, H, z, A = V, v = j.localhost, m = a.map(() => !1), h = a.map(() => 0n), i, mt, nt) => {
15
+ const u = f.getRootHash(), k = g.getRootHash(), I = a.map((t) => t.map((r) => r.getConstructableParams())), C = n.getSignature(), { accessTokenSiblings: L, accessTokenSiblingSides: O } = await p({
16
+ type: S.ZKProof,
17
+ payload: {
18
+ type: d.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,
19
+ data: {
20
+ userSignature: C,
21
+ merkleTreeAccessTokenSerialized: g.toJSON()
22
+ }
23
+ }
24
+ }), { inCommitmentSiblings: W, inCommitmentSiblingSides: K } = await p({
25
+ type: S.ZKProof,
26
+ payload: {
27
+ type: d.CALC_COMMITMENTS_SIBLING_AND_SIDES,
28
+ data: { inputUtxosSerialized: I, userSignature: C, merkleTreeSerialized: f.toJSON() }
29
+ }
30
+ }), M = q(a, e), l = F(e, !1), s = n.getShieldedPrivateKey(), y = $.findCorrectRandomization(U(31), s), R = await p({
31
+ type: S.ZKProof,
32
+ payload: {
33
+ type: d.BUILD_IN_NULLIFIERS,
34
+ data: { inputUtxosSerialized: I, onChainCreation: m }
35
+ }
36
+ }), c = a.map((t) => t[0].tokenId ?? 0), o = {
37
+ rootHashHinkal: u,
38
+ erc20TokenAddresses: a.map((t) => t[0].erc20TokenAddress),
39
+ tokenIds: c,
40
+ inNullifiers: R,
41
+ outTimeStamp: BigInt(e[0][0].timeStamp),
42
+ extraRandomization: y,
43
+ amountChanges: M,
44
+ outCommitments: Q(e, m).map((t) => t[0]),
45
+ rootHashAccessToken: k,
46
+ calldataHash: 0n,
47
+ shieldedPrivateKey: s,
48
+ hinkalWalletNonce: i ?? 0n,
49
+ accessTokenSiblings: L,
50
+ accessTokenSiblingSides: O,
51
+ onChainCreation: m,
52
+ outAmounts: e.map((t) => t[0].amount),
53
+ outPublicKeys: e.map((t) => t[0].getStealthAddress()),
54
+ inAmounts: a.map((t) => t.map((r) => r.amount.toString())),
55
+ inTimeStamps: a.map((t) => t.map((r) => r.timeStamp)),
56
+ inRandomizations: a.map((t) => t.map((r) => r.randomization)),
57
+ inCommitmentSiblings: W,
58
+ inCommitmentSiblingSides: K
59
+ }, w = i ? n.getWalletSalt(i) : void 0;
60
+ let N = H, T = at.Emporium, D = tt(z, w);
61
+ const E = `swapperMW${_}x${b}`, P = X(
62
+ E,
63
+ o.erc20TokenAddresses,
64
+ o.amountChanges,
65
+ o.inNullifiers,
66
+ o.outCommitments,
67
+ c.length
68
+ );
69
+ o.calldataHash = Y(
70
+ P,
71
+ A,
72
+ N,
73
+ T,
74
+ D,
75
+ l,
76
+ h,
77
+ void 0
78
+ );
79
+ const { zkCallData: B } = await rt(v, E, o), Z = x(y, s), G = await ot(
80
+ u,
81
+ k,
82
+ a,
83
+ e,
84
+ l,
85
+ h,
86
+ P,
87
+ T,
88
+ N,
89
+ D,
90
+ A,
91
+ o.calldataHash,
92
+ c,
93
+ Z,
94
+ m,
95
+ et
96
+ ), J = {
97
+ tokenNumber: a.length,
98
+ nullifierAmount: a[0].length,
99
+ outputAmount: e[0].length
100
+ };
101
+ return { zkCallData: B, circomData: G, dimData: J, encryptedOutputs: l };
102
+ };
103
+ export {
104
+ It as constructEmporiumProof
105
+ };