@hinkal/common 0.2.12 → 0.2.14

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 (574) hide show
  1. package/API/API.cjs +1 -1
  2. package/API/API.d.ts +9 -3
  3. package/API/API.mjs +44 -34
  4. package/API/ai-calls.cjs +1 -0
  5. package/API/ai-calls.d.ts +9 -0
  6. package/API/ai-calls.mjs +13 -0
  7. package/API/callCurveAPI.cjs +1 -1
  8. package/API/callCurveAPI.mjs +28 -22
  9. package/API/callRelayer.d.ts +3 -2
  10. package/API/dataServerCalls.cjs +1 -1
  11. package/API/dataServerCalls.d.ts +4 -0
  12. package/API/dataServerCalls.mjs +11 -7
  13. package/API/duneAPI.cjs +1 -1
  14. package/API/duneAPI.mjs +6 -4
  15. package/API/fetchCommitmentsCache.cjs +1 -1
  16. package/API/fetchCommitmentsCache.d.ts +9 -1
  17. package/API/fetchCommitmentsCache.mjs +6 -5
  18. package/API/getGasEstimates.cjs +1 -1
  19. package/API/getGasEstimates.d.ts +2 -1
  20. package/API/getGasEstimates.mjs +10 -9
  21. package/API/getServerURL.d.ts +1 -1
  22. package/API/index.d.ts +2 -0
  23. package/API/is-tx-stateless.cjs +1 -0
  24. package/API/is-tx-stateless.d.ts +3 -0
  25. package/API/is-tx-stateless.mjs +9 -0
  26. package/API/kycCalls.cjs +1 -1
  27. package/API/kycCalls.d.ts +0 -4
  28. package/API/kycCalls.mjs +11 -15
  29. package/API/rewardsPointsCalls.d.ts +0 -3
  30. package/API/tenderly.api.cjs +1 -0
  31. package/API/tenderly.api.d.ts +12 -0
  32. package/API/tenderly.api.mjs +47 -0
  33. package/API/token-calls.cjs +1 -0
  34. package/API/token-calls.d.ts +2 -0
  35. package/API/token-calls.mjs +9 -0
  36. package/README.md +0 -61
  37. package/constants/addresses.constants.cjs +1 -0
  38. package/constants/addresses.constants.d.ts +16 -0
  39. package/constants/addresses.constants.mjs +50 -0
  40. package/constants/assets.constants.cjs +1 -1
  41. package/constants/assets.constants.mjs +13 -13
  42. package/constants/axelar.constants.cjs +1 -1
  43. package/constants/axelar.constants.mjs +5 -5
  44. package/constants/balance.constants.cjs +1 -0
  45. package/constants/balance.constants.d.ts +1 -0
  46. package/constants/balance.constants.mjs +4 -0
  47. package/constants/chains.constants.cjs +1 -1
  48. package/constants/chains.constants.d.ts +0 -2
  49. package/constants/chains.constants.mjs +26 -38
  50. package/constants/contracts.constants.cjs +1 -1
  51. package/constants/contracts.constants.mjs +108 -108
  52. package/constants/conversion.constants.cjs +1 -0
  53. package/constants/conversion.constants.d.ts +1 -0
  54. package/constants/conversion.constants.mjs +4 -0
  55. package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
  56. package/constants/deploy-data/deploy-data-localhost.json.mjs +1652 -829
  57. package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
  58. package/constants/deploy-data/deploy-data-optimism.json.mjs +9707 -3957
  59. package/constants/fees.constants.cjs +1 -1
  60. package/constants/fees.constants.d.ts +5 -3
  61. package/constants/fees.constants.mjs +22 -19
  62. package/constants/index.d.ts +6 -0
  63. package/constants/mediaUrls.constants.cjs +1 -0
  64. package/constants/mediaUrls.constants.d.ts +23 -0
  65. package/constants/mediaUrls.constants.mjs +26 -0
  66. package/constants/permit2.constants.cjs +1 -0
  67. package/constants/permit2.constants.d.ts +2 -0
  68. package/constants/permit2.constants.mjs +5 -0
  69. package/constants/protocol.constants.cjs +1 -1
  70. package/constants/protocol.constants.d.ts +6 -0
  71. package/constants/protocol.constants.mjs +27 -15
  72. package/constants/rewards.constants.cjs +1 -1
  73. package/constants/rewards.constants.d.ts +0 -1
  74. package/constants/rewards.constants.mjs +14 -13
  75. package/constants/server.constants.cjs +1 -1
  76. package/constants/server.constants.d.ts +8 -3
  77. package/constants/server.constants.mjs +16 -11
  78. package/constants/token-data/ERC20Registry.cjs +1 -1
  79. package/constants/token-data/ERC20Registry.mjs +10 -9
  80. package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
  81. package/constants/token-data/arbMainnetRegistry.json.mjs +88 -88
  82. package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
  83. package/constants/token-data/arbMainnetRegistryFixed.json.mjs +78 -78
  84. package/constants/token-data/avalancheRegistry.json.cjs +1 -1
  85. package/constants/token-data/avalancheRegistry.json.mjs +49 -49
  86. package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
  87. package/constants/token-data/avalancheRegistryFixed.json.mjs +49 -49
  88. package/constants/token-data/baseRegistry.json.cjs +1 -1
  89. package/constants/token-data/baseRegistry.json.mjs +32 -32
  90. package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
  91. package/constants/token-data/baseRegistryFixed.json.mjs +29 -29
  92. package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
  93. package/constants/token-data/bnbMainnetRegistry.json.mjs +65 -65
  94. package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
  95. package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +65 -65
  96. package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
  97. package/constants/token-data/ethMainnetRegistry.json.mjs +227 -227
  98. package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
  99. package/constants/token-data/ethMainnetRegistryFixed.json.mjs +191 -191
  100. package/constants/token-data/index.d.ts +91 -0
  101. package/constants/token-data/localhostRegistry.json.cjs +1 -1
  102. package/constants/token-data/localhostRegistry.json.mjs +294 -277
  103. package/constants/token-data/optimismRegistry.json.cjs +1 -1
  104. package/constants/token-data/optimismRegistry.json.mjs +702 -182
  105. package/constants/token-data/optimismRegistryFixed.json.cjs +1 -1
  106. package/constants/token-data/optimismRegistryFixed.json.mjs +678 -175
  107. package/constants/token-data/polygonRegistry.json.cjs +1 -1
  108. package/constants/token-data/polygonRegistry.json.mjs +109 -109
  109. package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
  110. package/constants/token-data/polygonRegistryFixed.json.mjs +101 -101
  111. package/constants/token.limits.constants.cjs +1 -0
  112. package/constants/token.limits.constants.d.ts +5 -0
  113. package/constants/token.limits.constants.mjs +30 -0
  114. package/constants/vite.constants.cjs +1 -1
  115. package/constants/vite.constants.d.ts +5 -0
  116. package/constants/vite.constants.mjs +26 -22
  117. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  118. package/data-structures/Hinkal/Hinkal.d.ts +46 -21
  119. package/data-structures/Hinkal/Hinkal.mjs +260 -92
  120. package/data-structures/Hinkal/IHinkal.d.ts +35 -11
  121. package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
  122. package/data-structures/Hinkal/hinkalActionBeefy.mjs +5 -4
  123. package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
  124. package/data-structures/Hinkal/hinkalActionConvex.mjs +4 -3
  125. package/data-structures/Hinkal/hinkalActionCurve.cjs +1 -1
  126. package/data-structures/Hinkal/hinkalActionCurve.mjs +5 -4
  127. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +1 -0
  128. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +3 -0
  129. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +61 -0
  130. package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
  131. package/data-structures/Hinkal/hinkalActionLidoEth.mjs +9 -8
  132. package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
  133. package/data-structures/Hinkal/hinkalActionPendle.mjs +17 -16
  134. package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
  135. package/data-structures/Hinkal/hinkalActionPendleLP.mjs +14 -12
  136. package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -0
  137. package/data-structures/Hinkal/hinkalActionReceive.d.ts +4 -0
  138. package/data-structures/Hinkal/hinkalActionReceive.mjs +39 -0
  139. package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
  140. package/data-structures/Hinkal/hinkalActionStake.mjs +12 -9
  141. package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
  142. package/data-structures/Hinkal/hinkalActionVolatile.mjs +25 -21
  143. package/data-structures/Hinkal/hinkalApprove.cjs +1 -0
  144. package/data-structures/Hinkal/hinkalApprove.d.ts +2 -0
  145. package/data-structures/Hinkal/hinkalApprove.mjs +120 -0
  146. package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -0
  147. package/data-structures/Hinkal/hinkalCheckTokenRegistry.d.ts +3 -0
  148. package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -0
  149. package/data-structures/Hinkal/hinkalDeploySubAccount.cjs +1 -0
  150. package/data-structures/Hinkal/hinkalDeploySubAccount.d.ts +3 -0
  151. package/data-structures/Hinkal/hinkalDeploySubAccount.mjs +15 -0
  152. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  153. package/data-structures/Hinkal/hinkalDeposit.d.ts +3 -2
  154. package/data-structures/Hinkal/hinkalDeposit.mjs +96 -71
  155. package/data-structures/Hinkal/hinkalGetRecipientInfo.cjs +1 -1
  156. package/data-structures/Hinkal/hinkalGetRecipientInfo.d.ts +1 -1
  157. package/data-structures/Hinkal/hinkalGetRecipientInfo.mjs +5 -11
  158. package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
  159. package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +6 -18
  160. package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -0
  161. package/data-structures/Hinkal/hinkalInsideTransact.d.ts +2 -0
  162. package/data-structures/Hinkal/hinkalInsideTransact.mjs +111 -0
  163. package/data-structures/Hinkal/hinkalMultiSend.cjs +1 -0
  164. package/data-structures/Hinkal/hinkalMultiSend.d.ts +3 -0
  165. package/data-structures/Hinkal/hinkalMultiSend.mjs +13 -0
  166. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  167. package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -1
  168. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +83 -38
  169. package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -0
  170. package/data-structures/Hinkal/hinkalProoflessDeposit.d.ts +4 -0
  171. package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +46 -0
  172. package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -0
  173. package/data-structures/Hinkal/hinkalProxySwap.d.ts +5 -0
  174. package/data-structures/Hinkal/hinkalProxySwap.mjs +36 -0
  175. package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -0
  176. package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +3 -0
  177. package/data-structures/Hinkal/hinkalSignSubAccount.mjs +20 -0
  178. package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
  179. package/data-structures/Hinkal/hinkalSwap.d.ts +2 -1
  180. package/data-structures/Hinkal/hinkalSwap.mjs +68 -60
  181. package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
  182. package/data-structures/Hinkal/hinkalWithdraw.d.ts +3 -1
  183. package/data-structures/Hinkal/hinkalWithdraw.mjs +76 -50
  184. package/data-structures/Hinkal/index.d.ts +1 -0
  185. package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
  186. package/data-structures/Hinkal/resetMerkleTrees.mjs +18 -11
  187. package/data-structures/IndexedDB/activity-db.cjs +1 -0
  188. package/data-structures/IndexedDB/activity-db.d.ts +16 -0
  189. package/data-structures/IndexedDB/activity-db.mjs +124 -0
  190. package/data-structures/IndexedDB/balances-db.cjs +1 -0
  191. package/data-structures/IndexedDB/balances-db.d.ts +13 -0
  192. package/data-structures/IndexedDB/balances-db.mjs +75 -0
  193. package/data-structures/IndexedDB/contact-db.cjs +1 -0
  194. package/data-structures/IndexedDB/contact-db.d.ts +11 -0
  195. package/data-structures/IndexedDB/contact-db.mjs +44 -0
  196. package/data-structures/IndexedDB/index.d.ts +5 -0
  197. package/data-structures/IndexedDB/prices-db.cjs +1 -0
  198. package/data-structures/IndexedDB/prices-db.d.ts +9 -0
  199. package/data-structures/IndexedDB/prices-db.mjs +62 -0
  200. package/data-structures/IndexedDB/private-balances-db.cjs +1 -0
  201. package/data-structures/IndexedDB/private-balances-db.d.ts +9 -0
  202. package/data-structures/IndexedDB/private-balances-db.mjs +28 -0
  203. package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs +1 -1
  204. package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs +47 -44
  205. package/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -0
  206. package/data-structures/TokenDBs/PrivateTokensDB.d.ts +11 -0
  207. package/data-structures/TokenDBs/PrivateTokensDB.mjs +53 -0
  208. package/data-structures/TokenDBs/PublicTokensDB.cjs +1 -0
  209. package/data-structures/TokenDBs/PublicTokensDB.d.ts +13 -0
  210. package/data-structures/TokenDBs/PublicTokensDB.mjs +81 -0
  211. package/data-structures/TokenDBs/index.d.ts +2 -0
  212. package/data-structures/cacheDevices/AttachableMemoryCacheDevice.cjs +1 -0
  213. package/data-structures/cacheDevices/AttachableMemoryCacheDevice.d.ts +8 -0
  214. package/data-structures/cacheDevices/AttachableMemoryCacheDevice.mjs +28 -0
  215. package/data-structures/cacheDevices/BaseCacheDevice.cjs +1 -1
  216. package/data-structures/cacheDevices/BaseCacheDevice.d.ts +9 -6
  217. package/data-structures/cacheDevices/BaseCacheDevice.mjs +13 -4
  218. package/data-structures/cacheDevices/FileCacheDevice.cjs +1 -1
  219. package/data-structures/cacheDevices/FileCacheDevice.d.ts +1 -0
  220. package/data-structures/cacheDevices/FileCacheDevice.mjs +7 -3
  221. package/data-structures/cacheDevices/LocalStorageCacheDevice.cjs +1 -1
  222. package/data-structures/cacheDevices/LocalStorageCacheDevice.d.ts +2 -1
  223. package/data-structures/cacheDevices/LocalStorageCacheDevice.mjs +10 -5
  224. package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
  225. package/data-structures/crypto-keys/decodeUTXO.mjs +13 -12
  226. package/data-structures/crypto-keys/keys.cjs +1 -1
  227. package/data-structures/crypto-keys/keys.d.ts +13 -3
  228. package/data-structures/crypto-keys/keys.mjs +45 -34
  229. package/data-structures/custom-token-registry/CustomTokenRegistry.cjs +1 -1
  230. package/data-structures/custom-token-registry/CustomTokenRegistry.d.ts +2 -3
  231. package/data-structures/custom-token-registry/CustomTokenRegistry.mjs +17 -21
  232. package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
  233. package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +15 -29
  234. package/data-structures/event-service/AbstractApprovalsSnapshotService.cjs +1 -0
  235. package/data-structures/event-service/AbstractApprovalsSnapshotService.d.ts +30 -0
  236. package/data-structures/event-service/AbstractApprovalsSnapshotService.mjs +104 -0
  237. package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -1
  238. package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +24 -37
  239. package/data-structures/event-service/AbstractEventService.cjs +1 -1
  240. package/data-structures/event-service/AbstractEventService.d.ts +1 -1
  241. package/data-structures/event-service/AbstractEventService.mjs +34 -46
  242. package/data-structures/event-service/index.d.ts +1 -0
  243. package/data-structures/index.d.ts +2 -0
  244. package/data-structures/merkle-tree/MerkleTree.cjs +1 -1
  245. package/data-structures/merkle-tree/MerkleTree.d.ts +4 -1
  246. package/data-structures/merkle-tree/MerkleTree.mjs +66 -65
  247. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +1 -1
  248. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +1 -1
  249. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +10 -6
  250. package/data-structures/provider-adapter/IProviderAdapter.d.ts +2 -0
  251. package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
  252. package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +6 -10
  253. package/data-structures/snapshot/ClientApprovalsSnapshotService.cjs +1 -0
  254. package/data-structures/snapshot/ClientApprovalsSnapshotService.d.ts +8 -0
  255. package/data-structures/snapshot/ClientApprovalsSnapshotService.mjs +23 -0
  256. package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
  257. package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +6 -10
  258. package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
  259. package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +6 -10
  260. package/data-structures/token-price-fetcher/TokenChecker.cjs +1 -1
  261. package/data-structures/token-price-fetcher/TokenChecker.d.ts +1 -0
  262. package/data-structures/token-price-fetcher/TokenChecker.mjs +4 -2
  263. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  264. package/data-structures/transactions-manager/TransactionsManager.d.ts +6 -5
  265. package/data-structures/transactions-manager/TransactionsManager.mjs +95 -100
  266. package/data-structures/transactions-manager/history/getBeefyData.cjs +1 -1
  267. package/data-structures/transactions-manager/history/getBeefyData.mjs +3 -2
  268. package/data-structures/transactions-manager/history/getConvexData.cjs +1 -1
  269. package/data-structures/transactions-manager/history/getConvexData.mjs +3 -2
  270. package/data-structures/transactions-manager/history/getCurveData.cjs +1 -1
  271. package/data-structures/transactions-manager/history/getCurveData.mjs +3 -2
  272. package/data-structures/transactions-manager/history/getLidoData.cjs +1 -1
  273. package/data-structures/transactions-manager/history/getLidoData.mjs +3 -2
  274. package/data-structures/transactions-manager/history/getPendleData.cjs +1 -1
  275. package/data-structures/transactions-manager/history/getPendleData.mjs +13 -12
  276. package/data-structures/transactions-manager/history/getTxDetails.cjs +1 -1
  277. package/data-structures/transactions-manager/history/getTxDetails.mjs +22 -20
  278. package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
  279. package/data-structures/transactions-manager/history/getVolatileData.mjs +11 -10
  280. package/data-structures/transactions-manager/history/history.types.cjs +1 -1
  281. package/data-structures/transactions-manager/history/history.types.mjs +4 -2
  282. package/data-structures/utxo/Utxo.cjs +1 -1
  283. package/data-structures/utxo/Utxo.d.ts +3 -3
  284. package/data-structures/utxo/Utxo.mjs +8 -7
  285. package/error-handling/error-codes.constants.cjs +2 -2
  286. package/error-handling/error-codes.constants.d.ts +20 -3
  287. package/error-handling/error-codes.constants.mjs +139 -126
  288. package/error-handling/get-error.message.cjs +1 -1
  289. package/error-handling/get-error.message.mjs +29 -25
  290. package/error-handling/index.d.ts +1 -0
  291. package/error-handling/logger.cjs +1 -0
  292. package/error-handling/logger.d.ts +5 -0
  293. package/error-handling/logger.mjs +16 -0
  294. package/error-handling/types.cjs +1 -1
  295. package/error-handling/types.d.ts +3 -1
  296. package/error-handling/types.mjs +2 -2
  297. package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -0
  298. package/functions/pre-transaction/getExternalSwapAddress.d.ts +3 -0
  299. package/functions/pre-transaction/getExternalSwapAddress.mjs +26 -0
  300. package/functions/pre-transaction/getFeeStructure.cjs +1 -0
  301. package/functions/pre-transaction/getFeeStructure.d.ts +4 -0
  302. package/functions/pre-transaction/getFeeStructure.mjs +30 -0
  303. package/functions/pre-transaction/getFlatFees.cjs +1 -1
  304. package/functions/pre-transaction/getFlatFees.d.ts +3 -7
  305. package/functions/pre-transaction/getFlatFees.mjs +52 -46
  306. package/functions/pre-transaction/getSignatureDataForTransact.cjs +1 -0
  307. package/functions/pre-transaction/getSignatureDataForTransact.d.ts +3 -0
  308. package/functions/pre-transaction/getSignatureDataForTransact.mjs +6 -0
  309. package/functions/pre-transaction/index.d.ts +1 -0
  310. package/functions/pre-transaction/interaction-to-action.cjs +1 -1
  311. package/functions/pre-transaction/interaction-to-action.mjs +3 -2
  312. package/functions/pre-transaction/merge-with-fee-structure.cjs +1 -0
  313. package/functions/pre-transaction/merge-with-fee-structure.d.ts +2 -0
  314. package/functions/pre-transaction/merge-with-fee-structure.mjs +25 -0
  315. package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -0
  316. package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +16 -0
  317. package/functions/pre-transaction/outputApprovalDataProcessing.mjs +42 -0
  318. package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
  319. package/functions/pre-transaction/outputUtxoProcessing.d.ts +1 -1
  320. package/functions/pre-transaction/outputUtxoProcessing.mjs +19 -30
  321. package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
  322. package/functions/pre-transaction/process-gas-estimates.d.ts +2 -2
  323. package/functions/pre-transaction/process-gas-estimates.mjs +17 -28
  324. package/functions/pre-transaction/processAmountChanges.cjs +1 -1
  325. package/functions/pre-transaction/processAmountChanges.mjs +34 -23
  326. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -0
  327. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +6 -0
  328. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +7 -0
  329. package/functions/private-wallet/emporium.helpers.cjs +1 -1
  330. package/functions/private-wallet/emporium.helpers.d.ts +17 -4
  331. package/functions/private-wallet/emporium.helpers.mjs +119 -12
  332. package/functions/private-wallet/emporium.swap.helpers.cjs +1 -0
  333. package/functions/private-wallet/emporium.swap.helpers.d.ts +5 -0
  334. package/functions/private-wallet/emporium.swap.helpers.mjs +92 -0
  335. package/functions/private-wallet/index.d.ts +2 -0
  336. package/functions/private-wallet/opProducer.cjs +1 -1
  337. package/functions/private-wallet/opProducer.mjs +1 -1
  338. package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -0
  339. package/functions/private-wallet/smartContractWalletCalculator.d.ts +5 -0
  340. package/functions/private-wallet/smartContractWalletCalculator.mjs +25 -0
  341. package/functions/protocols/convex.protocols.cjs +1 -1
  342. package/functions/protocols/convex.protocols.mjs +10 -8
  343. package/functions/protocols/pendle.helpers.cjs +1 -1
  344. package/functions/protocols/pendle.helpers.mjs +16 -12
  345. package/functions/snarkjs/common.snarkjs.cjs +1 -1
  346. package/functions/snarkjs/common.snarkjs.d.ts +8 -5
  347. package/functions/snarkjs/common.snarkjs.mjs +177 -87
  348. package/functions/snarkjs/constant.cjs +1 -1
  349. package/functions/snarkjs/constant.d.ts +223 -2
  350. package/functions/snarkjs/constant.mjs +313 -93
  351. package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
  352. package/functions/snarkjs/constructEmporiumProof.d.ts +6 -3
  353. package/functions/snarkjs/constructEmporiumProof.mjs +148 -84
  354. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  355. package/functions/snarkjs/constructGeneralZkProof.d.ts +5 -3
  356. package/functions/snarkjs/constructGeneralZkProof.mjs +141 -86
  357. package/functions/snarkjs/generateCircomData.cjs +1 -1
  358. package/functions/snarkjs/generateCircomData.d.ts +3 -2
  359. package/functions/snarkjs/generateCircomData.mjs +33 -35
  360. package/functions/snarkjs/generateZkProof.cjs +1 -1
  361. package/functions/snarkjs/generateZkProof.d.ts +2 -2
  362. package/functions/snarkjs/generateZkProof.mjs +4 -4
  363. package/functions/snarkjs/generateZkProofEnclave.cjs +1 -1
  364. package/functions/snarkjs/generateZkProofEnclave.d.ts +2 -1
  365. package/functions/snarkjs/generateZkProofEnclave.mjs +22 -29
  366. package/functions/snarkjs/generateZkProofSelf.cjs +1 -1
  367. package/functions/snarkjs/generateZkProofSelf.d.ts +2 -2
  368. package/functions/snarkjs/generateZkProofSelf.mjs +10 -10
  369. package/functions/snarkjs/getOriginalSender.cjs +1 -0
  370. package/functions/snarkjs/getOriginalSender.d.ts +1 -0
  371. package/functions/snarkjs/getOriginalSender.mjs +5 -0
  372. package/functions/snarkjs/getZKFiles.cjs +1 -1
  373. package/functions/snarkjs/getZKFiles.d.ts +3 -2
  374. package/functions/snarkjs/getZKFiles.mjs +14 -5
  375. package/functions/utils/addresses.cjs +1 -0
  376. package/functions/utils/addresses.d.ts +4 -0
  377. package/functions/utils/addresses.mjs +20 -0
  378. package/functions/utils/amounts.utils.cjs +1 -1
  379. package/functions/utils/amounts.utils.d.ts +4 -1
  380. package/functions/utils/amounts.utils.mjs +29 -27
  381. package/functions/utils/arraysMatch.cjs +1 -0
  382. package/functions/utils/arraysMatch.d.ts +1 -0
  383. package/functions/utils/arraysMatch.mjs +4 -0
  384. package/functions/utils/axelar.utils.cjs +1 -1
  385. package/functions/utils/axelar.utils.d.ts +1 -0
  386. package/functions/utils/axelar.utils.mjs +31 -9
  387. package/functions/utils/cacheDevice.utils.cjs +1 -1
  388. package/functions/utils/cacheDevice.utils.mjs +5 -3
  389. package/functions/utils/cacheFunctions.cjs +1 -1
  390. package/functions/utils/cacheFunctions.d.ts +10 -7
  391. package/functions/utils/cacheFunctions.mjs +62 -39
  392. package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -0
  393. package/functions/utils/convertEmporiumOpToCallInfo.d.ts +2 -0
  394. package/functions/utils/convertEmporiumOpToCallInfo.mjs +10 -0
  395. package/functions/utils/convertIntegrationProviderToExternalActionId.cjs +1 -1
  396. package/functions/utils/convertIntegrationProviderToExternalActionId.d.ts +2 -1
  397. package/functions/utils/convertIntegrationProviderToExternalActionId.mjs +7 -10
  398. package/functions/utils/encodeTokenWithId.cjs +1 -0
  399. package/functions/utils/encodeTokenWithId.d.ts +2 -0
  400. package/functions/utils/encodeTokenWithId.mjs +4 -0
  401. package/functions/utils/encryptInputForEnclave.cjs +1 -0
  402. package/functions/utils/encryptInputForEnclave.d.ts +8 -0
  403. package/functions/utils/encryptInputForEnclave.mjs +43 -0
  404. package/functions/utils/erc20tokenFunctions.cjs +1 -1
  405. package/functions/utils/erc20tokenFunctions.d.ts +8 -2
  406. package/functions/utils/erc20tokenFunctions.mjs +22 -14
  407. package/functions/utils/evmNetworkFunctions.cjs +1 -1
  408. package/functions/utils/evmNetworkFunctions.mjs +6 -4
  409. package/functions/utils/external-action.utils.d.ts +2 -2
  410. package/functions/utils/fees.utils.cjs +1 -0
  411. package/functions/utils/fees.utils.d.ts +2 -0
  412. package/functions/utils/fees.utils.mjs +14 -0
  413. package/functions/utils/getBlockExplorerUrl.cjs +1 -0
  414. package/functions/utils/getBlockExplorerUrl.d.ts +1 -0
  415. package/functions/utils/getBlockExplorerUrl.mjs +6 -0
  416. package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -0
  417. package/functions/utils/getRecipientInfoFromUserKeys.d.ts +3 -0
  418. package/functions/utils/getRecipientInfoFromUserKeys.mjs +18 -0
  419. package/functions/utils/index.d.ts +12 -0
  420. package/functions/utils/involves-permit2-op.cjs +1 -0
  421. package/functions/utils/involves-permit2-op.d.ts +1 -0
  422. package/functions/utils/involves-permit2-op.mjs +5 -0
  423. package/functions/utils/merkleTree.utils.cjs +1 -0
  424. package/functions/utils/merkleTree.utils.d.ts +2 -0
  425. package/functions/utils/merkleTree.utils.mjs +19 -0
  426. package/functions/utils/prepareHinkal.d.ts +6 -0
  427. package/functions/utils/processUseApprovalUtxoData.cjs +1 -0
  428. package/functions/utils/processUseApprovalUtxoData.d.ts +3 -0
  429. package/functions/utils/processUseApprovalUtxoData.mjs +19 -0
  430. package/functions/utils/publicBalance.utils.cjs +1 -0
  431. package/functions/utils/publicBalance.utils.d.ts +5 -0
  432. package/functions/utils/publicBalance.utils.mjs +25 -0
  433. package/functions/utils/replaceAddressInCalldata.cjs +1 -0
  434. package/functions/utils/replaceAddressInCalldata.d.ts +1 -0
  435. package/functions/utils/replaceAddressInCalldata.mjs +7 -0
  436. package/functions/utils/rpc-int-encode.cjs +1 -0
  437. package/functions/utils/rpc-int-encode.d.ts +2 -0
  438. package/functions/utils/rpc-int-encode.mjs +8 -0
  439. package/functions/utils/serialize.utils.cjs +1 -1
  440. package/functions/utils/serialize.utils.d.ts +1 -0
  441. package/functions/utils/serialize.utils.mjs +3 -2
  442. package/functions/utils/string.utils.cjs +1 -1
  443. package/functions/utils/string.utils.d.ts +3 -0
  444. package/functions/utils/string.utils.mjs +31 -7
  445. package/functions/utils/time.utils.cjs +1 -1
  446. package/functions/utils/time.utils.d.ts +1 -0
  447. package/functions/utils/time.utils.mjs +4 -3
  448. package/functions/utils/token-check.utils.cjs +1 -0
  449. package/functions/utils/token-check.utils.d.ts +1 -0
  450. package/functions/utils/token-check.utils.mjs +10 -0
  451. package/functions/utils/upToDateState.cjs +1 -0
  452. package/functions/utils/upToDateState.d.ts +2 -0
  453. package/functions/utils/upToDateState.mjs +11 -0
  454. package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -0
  455. package/functions/web3/events/balanceChangedCustomHandler.d.ts +2 -0
  456. package/functions/web3/events/balanceChangedCustomHandler.mjs +14 -0
  457. package/functions/web3/events/balanceChangedHandler.cjs +1 -1
  458. package/functions/web3/events/balanceChangedHandler.mjs +5 -4
  459. package/functions/web3/events/getApprovedBalance.cjs +1 -0
  460. package/functions/web3/events/getApprovedBalance.d.ts +7 -0
  461. package/functions/web3/events/getApprovedBalance.mjs +80 -0
  462. package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
  463. package/functions/web3/events/getInputUtxoAndBalance.d.ts +16 -3
  464. package/functions/web3/events/getInputUtxoAndBalance.mjs +128 -46
  465. package/functions/web3/events/getShieldedBalance.cjs +2 -2
  466. package/functions/web3/events/getShieldedBalance.d.ts +1 -1
  467. package/functions/web3/events/getShieldedBalance.mjs +79 -82
  468. package/functions/web3/events/index.d.ts +2 -0
  469. package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
  470. package/functions/web3/functionCalls/accessTokenCalls.d.ts +2 -2
  471. package/functions/web3/functionCalls/accessTokenCalls.mjs +19 -17
  472. package/functions/web3/functionCalls/approveToken.cjs +1 -1
  473. package/functions/web3/functionCalls/approveToken.mjs +8 -7
  474. package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -0
  475. package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +4 -0
  476. package/functions/web3/functionCalls/approveTokensToHinkal.mjs +11 -0
  477. package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
  478. package/functions/web3/functionCalls/estimateGasRelayer.d.ts +2 -2
  479. package/functions/web3/functionCalls/estimateGasRelayer.mjs +14 -8
  480. package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -0
  481. package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +5 -0
  482. package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +32 -0
  483. package/functions/web3/functionCalls/relayFunctions.d.ts +1 -15
  484. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  485. package/functions/web3/functionCalls/transactCallDirect.d.ts +2 -2
  486. package/functions/web3/functionCalls/transactCallDirect.mjs +29 -42
  487. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  488. package/functions/web3/functionCalls/transactCallRelayer.d.ts +2 -2
  489. package/functions/web3/functionCalls/transactCallRelayer.mjs +26 -5
  490. package/functions/web3/odosAPI.cjs +1 -1
  491. package/functions/web3/odosAPI.mjs +6 -3
  492. package/functions/web3/oneInchAPI.cjs +1 -1
  493. package/functions/web3/oneInchAPI.mjs +6 -3
  494. package/functions/web3/runContractFunction.cjs +1 -1
  495. package/functions/web3/runContractFunction.mjs +3 -2
  496. package/functions/web3/uniswapAPI.cjs +1 -1
  497. package/functions/web3/uniswapAPI.mjs +6 -3
  498. package/index.cjs +1 -1
  499. package/index.mjs +756 -612
  500. package/package.json +6 -2
  501. package/providers/EthersProviderAdapter.cjs +1 -1
  502. package/providers/EthersProviderAdapter.d.ts +7 -3
  503. package/providers/EthersProviderAdapter.mjs +31 -11
  504. package/providers/WagmiProviderAdapter.cjs +1 -1
  505. package/providers/WagmiProviderAdapter.d.ts +3 -1
  506. package/providers/WagmiProviderAdapter.mjs +12 -4
  507. package/providers/prepareEthersHinkal.cjs +1 -1
  508. package/providers/prepareEthersHinkal.mjs +17 -11
  509. package/providers/prepareWagmiHinkal.cjs +1 -1
  510. package/providers/prepareWagmiHinkal.mjs +17 -11
  511. package/types/API.types.d.ts +21 -0
  512. package/types/ICacheDevice.d.ts +4 -3
  513. package/types/TransactionSimulator.types.d.ts +9 -0
  514. package/types/activities.types.cjs +1 -0
  515. package/types/activities.types.d.ts +45 -0
  516. package/types/activities.types.mjs +13 -0
  517. package/types/balances.types.cjs +1 -0
  518. package/types/balances.types.d.ts +17 -0
  519. package/types/balances.types.mjs +4 -0
  520. package/types/cache.types.cjs +1 -0
  521. package/types/cache.types.d.ts +27 -0
  522. package/types/cache.types.mjs +4 -0
  523. package/types/circom-data.types.d.ts +29 -9
  524. package/types/commitments.types.d.ts +6 -0
  525. package/types/contacts.types.d.ts +5 -0
  526. package/types/crypto.types.d.ts +1 -0
  527. package/types/earlyAccessCode.types.d.ts +4 -0
  528. package/types/ethereum-network.types.cjs +1 -1
  529. package/types/ethereum-network.types.d.ts +66 -62
  530. package/types/ethereum-network.types.mjs +1 -1
  531. package/types/external-action.types.cjs +1 -1
  532. package/types/external-action.types.d.ts +2 -1
  533. package/types/external-action.types.mjs +1 -1
  534. package/types/fee.types.d.ts +9 -0
  535. package/types/hinkal.types.cjs +1 -1
  536. package/types/hinkal.types.d.ts +43 -5
  537. package/types/hinkal.types.mjs +37 -13
  538. package/types/index.d.ts +9 -0
  539. package/types/rewards.types.cjs +1 -1
  540. package/types/rewards.types.d.ts +3 -4
  541. package/types/rewards.types.mjs +12 -12
  542. package/types/sandbox.types.cjs +1 -0
  543. package/types/sandbox.types.d.ts +157 -0
  544. package/types/sandbox.types.mjs +4 -0
  545. package/types/tenderly.api.types.d.ts +180 -0
  546. package/types/token-with-id.types.d.ts +4 -0
  547. package/types/token.types.d.ts +23 -0
  548. package/types/transactions.types.cjs +1 -1
  549. package/types/transactions.types.d.ts +31 -0
  550. package/types/transactions.types.mjs +8 -5
  551. package/types/wc.types.d.ts +89 -0
  552. package/types/with-id.types.d.ts +3 -0
  553. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  554. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  555. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  556. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +26 -31
  557. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  558. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  559. package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
  560. package/webworker/utxoWorker/utxoWorkerLogic.mjs +58 -50
  561. package/webworker/viteWorkerURL.constant.cjs +3 -3
  562. package/webworker/viteWorkerURL.constant.mjs +3 -3
  563. package/webworker/workerFactory.cjs +1 -1
  564. package/webworker/workerFactory.mjs +2 -2
  565. package/webworker/workerProxy.cjs +1 -1
  566. package/webworker/workerProxy.d.ts +11 -11
  567. package/webworker/workerProxy.mjs +24 -26
  568. package/webworker/zkProofWorker/zkProofWorker.types.d.ts +2 -0
  569. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  570. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
  571. package/webworker/zkProofWorker/zkProofWorkerLogic.cjs +1 -1
  572. package/webworker/zkProofWorker/zkProofWorkerLogic.mjs +47 -61
  573. package/functions/utils/memoize.utils.cjs +0 -1
  574. package/functions/utils/memoize.utils.mjs +0 -14
@@ -1,13 +1,16 @@
1
- import { poseidonFunction as m } from "../../crypto/poseidon.mjs";
1
+ import { poseidonFunction as s } from "../../crypto/poseidon.mjs";
2
2
  import "circomlibjs-hinkal-fork";
3
3
  import "libsodium-wrappers";
4
4
  import "process";
5
5
  import "buffer";
6
- import { MerkleTree as s } from "../merkle-tree/MerkleTree.mjs";
7
- import { toBigInt as n } from "../../functions/utils/amounts.utils.mjs";
8
- import { AbstractSnapshotService as i } from "./AbstractSnapshotService.mjs";
9
- class v extends i {
10
- constructor(e, t, u, r) {
6
+ import { MerkleTree as i } from "../merkle-tree/MerkleTree.mjs";
7
+ import "ethers";
8
+ import "../../error-handling/error-codes.constants.mjs";
9
+ import { toBigInt as m } from "../../functions/utils/amounts.utils.mjs";
10
+ import { AbstractSnapshotService as p } from "./AbstractSnapshotService.mjs";
11
+ import { contructMerkleTreeFromSerialized as n } from "../../functions/utils/merkleTree.utils.mjs";
12
+ class _ extends p {
13
+ constructor(e, t, r, u) {
11
14
  super(
12
15
  e,
13
16
  {
@@ -15,8 +18,8 @@ class v extends i {
15
18
  args: ["commitment", "index", "encryptedOutput"]
16
19
  },
17
20
  t,
18
- u,
19
- r
21
+ r,
22
+ u
20
23
  );
21
24
  }
22
25
  _merkleTree;
@@ -40,33 +43,17 @@ class v extends i {
40
43
  }
41
44
  deserializeSnapshot(e) {
42
45
  let t;
43
- if (e.latestBlockNumber && e.merkleTree) {
44
- const r = new Map(
45
- Object.entries(e.merkleTree.tree).map(([c, p]) => [
46
- BigInt(c),
47
- BigInt(p)
48
- ])
49
- );
50
- t = s.createWithData(
51
- r,
52
- n(e.merkleTree.index),
53
- n(e.merkleTree.count),
54
- m,
55
- 25n,
56
- 0n
57
- );
58
- } else
59
- t = s.create(m, 25n, 0n);
60
- const u = e.encryptedOutputs?.map((r) => ({
61
- value: r.value,
62
- isPositive: JSON.parse(r.isPositive)
46
+ e.latestBlockNumber && e.merkleTree ? t = n(e.merkleTree) : t = i.create(s, 25n, 0n);
47
+ const r = e.encryptedOutputs?.map((u) => ({
48
+ value: u.value,
49
+ isPositive: JSON.parse(u.isPositive)
63
50
  }));
64
51
  return {
65
52
  latestBlockNumber: e.latestBlockNumber ?? 0,
66
53
  reserveBlockNumber: e.reserveBlockNumber ?? 0,
67
54
  payload: {
68
55
  merkleTree: t,
69
- encryptedOutputs: u || []
56
+ encryptedOutputs: r || []
70
57
  }
71
58
  };
72
59
  }
@@ -82,26 +69,26 @@ class v extends i {
82
69
  this._merkleTree = e, this._encryptedOutputs = t;
83
70
  }
84
71
  mapEvent(e) {
85
- const { commitment: t, index: u, encryptedOutput: r } = e;
72
+ const { commitment: t, index: r, encryptedOutput: u } = e;
86
73
  return {
87
- commitment: n(t),
88
- index: n(u),
89
- encryptedOutput: r
74
+ commitment: m(t),
75
+ index: m(r),
76
+ encryptedOutput: u
90
77
  };
91
78
  }
92
79
  acceptEvent(e, t) {
93
- if (!this.encryptedOutputs.map((u) => u.value).includes(e.encryptedOutput)) {
80
+ if (!this.encryptedOutputs.map((r) => r.value).includes(e.encryptedOutput)) {
94
81
  if (!this._merkleTree.insert(e.commitment, e.index >= 0 ? e.index : -1n * e.index))
95
82
  return !1;
96
- const r = {
83
+ const u = {
97
84
  value: e.encryptedOutput,
98
85
  isPositive: e.index >= 0n
99
86
  };
100
- return this._encryptedOutputs.push(r), !0;
87
+ return this._encryptedOutputs.push(u), !0;
101
88
  }
102
89
  return !1;
103
90
  }
104
91
  }
105
92
  export {
106
- v as AbstractCommitmentsSnapshotService
93
+ _ as AbstractCommitmentsSnapshotService
107
94
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../constants/reorg-depths.constants.cjs"),o=require("../../functions/utils/resolve-sync.utils.cjs");require("ethers");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-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const v=require("../../error-handling/logError.cjs");class g{contract;eventConfig;_latestBlockNumber;maxPageSize;isReady=!1;_onNewEvent;isServer;intervalId;inProgress;constructor(e,r,t,s,n){this.contract=e,this.eventConfig=r,this._latestBlockNumber=t,this.maxPageSize=n,this.isServer=s,this.inProgress=!1}get latestBlockNumber(){return this._latestBlockNumber}set onNewEvent(e){this._onNewEvent=e}intervalClear(){this.isReady=!1,this._onNewEvent=void 0,clearInterval(this.intervalId)}async init(){if(this.isReady)throw new Error("Already initialized");this.isReady=!0,await this.retrieveEvents(this._latestBlockNumber+1),this.intervalId=setInterval(async()=>{await this.retrieveEvents(this.latestBlockNumber)},3500)}requireReady(){if(!this.isReady)throw new Error("Not ready")}emitNewEvent(e){this._onNewEvent?.(e)}getLastBlockNumberForEventRequest=async()=>{const e=await this.contract.provider.getBlockNumber();if(!this.isServer)return e;const{chainId:r}=await this.contract.provider.getNetwork();return Math.max(this.latestBlockNumber,e-u.blockReorgDepth[r]+1)};async retrieveEvents(e,r=!1){try{if(this.requireReady(),this.inProgress&&!r)return!1;this.inProgress=!0;const t=await this.getLastBlockNumberForEventRequest();if(t<e)return this.inProgress=!1,!1;const s=o.getSequence(e,t,this.maxPageSize);return await o.resolveSync(s.map(({from:n,to:i})=>async()=>{const c=await this.contract.queryFilter(this.contract.filters[this.eventConfig.name](),n,i);let a=[];c.length>0&&(a=await this.processEventsPage(c)),this._latestBlockNumber=i,await this.afterEventsAccepted(),a.length>0&&this.emitNewEvent()})),this.inProgress=!1,!0}catch(t){return v.logError("retrieveEvents error:",{err:t}),this.inProgress=!1,!1}}async processEventsPage(e){const r=[];return await o.resolveSync(e.map(t=>async()=>{const{args:s,blockNumber:n}=t;if(!s)throw new Error("Wrong event structure");const i=this.mapEvent(s);await this.acceptEvent(i,n)&&r.push(i)})),r}handleEvent=async(...e)=>{const{args:r}=this.eventConfig,{blockNumber:t}=e[e.length-1],s=e.slice(0,r.length),n=r.reduce((a,l,h)=>(a[l]=s[h],a),{});if(!t)throw new Error("Wrong event structure");const i=this.mapEvent(n);if(!await this.acceptEvent(i,t))throw new Error("Failed to retrieve events");this._latestBlockNumber=t,await this.afterEventsAccepted(),this.emitNewEvent(i)}}exports.AbstractEventService=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../constants/reorg-depths.constants.cjs"),o=require("../../functions/utils/resolve-sync.utils.cjs");class u{contract;eventConfig;_latestBlockNumber;maxPageSize;isReady=!1;_onNewEvent;isServer;intervalId;inProgress;constructor(e,t,s,r,i){this.contract=e,this.eventConfig=t,this._latestBlockNumber=s,this.maxPageSize=i,this.isServer=r,this.inProgress=!1}get latestBlockNumber(){return this._latestBlockNumber}set onNewEvent(e){this._onNewEvent=e}intervalClear(){this.isReady=!1,this._onNewEvent=void 0,clearInterval(this.intervalId)}async init(){if(this.isReady)throw new Error("Already initialized");this.isReady=!0,await this.retrieveEvents(this._latestBlockNumber+1),this.intervalId=setInterval(async()=>{await this.retrieveEvents(this.latestBlockNumber)},3500)}requireReady(){if(!this.isReady)throw new Error("Not ready")}emitNewEvent(e){this._onNewEvent?.(e)}getLastBlockNumberForEventRequest=async()=>{const e=await this.contract.provider.getBlockNumber();if(!this.isServer)return e;const{chainId:t}=await this.contract.provider.getNetwork();return Math.max(this.latestBlockNumber,e-v.blockReorgDepth[t]+1)};async retrieveEvents(e,t=!1){try{if(this.requireReady(),this.inProgress&&!t)return!1;this.inProgress=!0;const s=await this.getLastBlockNumberForEventRequest();if(s<e)return this.inProgress=!1,!1;const r=o.getSequence(e,s,this.maxPageSize);return await o.resolveSync(r.map(({from:i,to:n})=>async()=>{const a=await this.contract.queryFilter(this.contract.filters[this.eventConfig.name](),i,n);let c=[];a.length>0&&(c=await this.processEventsPage(a)),this._latestBlockNumber=n,await this.afterEventsAccepted(),c.length>0&&this.emitNewEvent()})),this.inProgress=!1,!0}catch{return this.inProgress=!1,!1}}async processEventsPage(e){const t=[];return await o.resolveSync(e.map(s=>async()=>{const{args:r,blockNumber:i,transactionHash:n}=s;if(!r)throw new Error("Wrong event structure");const a=this.mapEvent(r);await this.acceptEvent(a,i,n)&&t.push(a)})),t}handleEvent=async(...e)=>{const{args:t}=this.eventConfig,{blockNumber:s}=e[e.length-1],r=e.slice(0,t.length),i=t.reduce((c,l,h)=>(c[l]=r[h],c),{});if(!s)throw new Error("Wrong event structure");const n=this.mapEvent(i);if(!await this.acceptEvent(n,s))throw new Error("Failed to retrieve events");this._latestBlockNumber=s,await this.afterEventsAccepted(),this.emitNewEvent(n)}}exports.AbstractEventService=u;
@@ -25,7 +25,7 @@ export declare abstract class AbstractEventService<EventType, SerializedEventTyp
25
25
  protected retrieveEvents(fromBlockNumber: number, useForce?: boolean): Promise<boolean>;
26
26
  private processEventsPage;
27
27
  protected handleEvent: (...args: unknown[]) => Promise<void>;
28
- protected abstract acceptEvent(event: EventType, blockNumber: number): boolean | Promise<boolean>;
28
+ protected abstract acceptEvent(event: EventType, blockNumber: number, txHash?: string): boolean | Promise<boolean>;
29
29
  protected abstract mapEvent(event: SerializedEventType): EventType;
30
30
  protected abstract afterEventsAccepted(): Promise<unknown>;
31
31
  }
@@ -1,18 +1,6 @@
1
1
  import { blockReorgDepth as v } from "../../constants/reorg-depths.constants.mjs";
2
- import { getSequence as m, resolveSync as c } from "../../functions/utils/resolve-sync.utils.mjs";
3
- import "ethers";
4
- import "axios";
5
- import "../../constants/chains.constants.mjs";
6
- import "../../constants/vite.constants.mjs";
7
- import "../../types/circom-data.types.mjs";
8
- import "../../types/transactions.types.mjs";
9
- import "../../types/curve.types.mjs";
10
- import "circomlibjs-hinkal-fork";
11
- import "libsodium-wrappers";
12
- import "process";
13
- import "buffer";
14
- import { logError as u } from "../../error-handling/logError.mjs";
15
- class q {
2
+ import { getSequence as u, resolveSync as o } from "../../functions/utils/resolve-sync.utils.mjs";
3
+ class g {
16
4
  contract;
17
5
  eventConfig;
18
6
  _latestBlockNumber;
@@ -23,8 +11,8 @@ class q {
23
11
  intervalId;
24
12
  inProgress;
25
13
  // to remove race conditions
26
- constructor(e, r, t, s, n) {
27
- this.contract = e, this.eventConfig = r, this._latestBlockNumber = t, this.maxPageSize = n, this.isServer = s, this.inProgress = !1;
14
+ constructor(e, t, s, r, i) {
15
+ this.contract = e, this.eventConfig = t, this._latestBlockNumber = s, this.maxPageSize = i, this.isServer = r, this.inProgress = !1;
28
16
  }
29
17
  get latestBlockNumber() {
30
18
  return this._latestBlockNumber;
@@ -53,55 +41,55 @@ class q {
53
41
  const e = await this.contract.provider.getBlockNumber();
54
42
  if (!this.isServer)
55
43
  return e;
56
- const { chainId: r } = await this.contract.provider.getNetwork();
57
- return Math.max(this.latestBlockNumber, e - v[r] + 1);
44
+ const { chainId: t } = await this.contract.provider.getNetwork();
45
+ return Math.max(this.latestBlockNumber, e - v[t] + 1);
58
46
  };
59
- async retrieveEvents(e, r = !1) {
47
+ async retrieveEvents(e, t = !1) {
60
48
  try {
61
- if (this.requireReady(), this.inProgress && !r)
49
+ if (this.requireReady(), this.inProgress && !t)
62
50
  return !1;
63
51
  this.inProgress = !0;
64
- const t = await this.getLastBlockNumberForEventRequest();
65
- if (t < e)
52
+ const s = await this.getLastBlockNumberForEventRequest();
53
+ if (s < e)
66
54
  return this.inProgress = !1, !1;
67
- const s = m(e, t, this.maxPageSize);
68
- return await c(
69
- s.map(({ from: n, to: i }) => async () => {
70
- const o = await this.contract.queryFilter(
55
+ const r = u(e, s, this.maxPageSize);
56
+ return await o(
57
+ r.map(({ from: i, to: n }) => async () => {
58
+ const a = await this.contract.queryFilter(
71
59
  this.contract.filters[this.eventConfig.name](),
72
- n,
73
- i
60
+ i,
61
+ n
74
62
  );
75
- let a = [];
76
- o.length > 0 && (a = await this.processEventsPage(o)), this._latestBlockNumber = i, await this.afterEventsAccepted(), a.length > 0 && this.emitNewEvent();
63
+ let c = [];
64
+ a.length > 0 && (c = await this.processEventsPage(a)), this._latestBlockNumber = n, await this.afterEventsAccepted(), c.length > 0 && this.emitNewEvent();
77
65
  })
78
66
  ), this.inProgress = !1, !0;
79
- } catch (t) {
80
- return u("retrieveEvents error:", { err: t }), this.inProgress = !1, !1;
67
+ } catch {
68
+ return this.inProgress = !1, !1;
81
69
  }
82
70
  }
83
71
  async processEventsPage(e) {
84
- const r = [];
85
- return await c(
86
- e.map((t) => async () => {
87
- const { args: s, blockNumber: n } = t;
88
- if (!s)
72
+ const t = [];
73
+ return await o(
74
+ e.map((s) => async () => {
75
+ const { args: r, blockNumber: i, transactionHash: n } = s;
76
+ if (!r)
89
77
  throw new Error("Wrong event structure");
90
- const i = this.mapEvent(s);
91
- await this.acceptEvent(i, n) && r.push(i);
78
+ const a = this.mapEvent(r);
79
+ await this.acceptEvent(a, i, n) && t.push(a);
92
80
  })
93
- ), r;
81
+ ), t;
94
82
  }
95
83
  handleEvent = async (...e) => {
96
- const { args: r } = this.eventConfig, { blockNumber: t } = e[e.length - 1], s = e.slice(0, r.length), n = r.reduce((a, h, l) => (a[h] = s[l], a), {});
97
- if (!t)
84
+ const { args: t } = this.eventConfig, { blockNumber: s } = e[e.length - 1], r = e.slice(0, t.length), i = t.reduce((c, h, l) => (c[h] = r[l], c), {});
85
+ if (!s)
98
86
  throw new Error("Wrong event structure");
99
- const i = this.mapEvent(n);
100
- if (!await this.acceptEvent(i, t))
87
+ const n = this.mapEvent(i);
88
+ if (!await this.acceptEvent(n, s))
101
89
  throw new Error("Failed to retrieve events");
102
- this._latestBlockNumber = t, await this.afterEventsAccepted(), this.emitNewEvent(i);
90
+ this._latestBlockNumber = s, await this.afterEventsAccepted(), this.emitNewEvent(n);
103
91
  };
104
92
  }
105
93
  export {
106
- q as AbstractEventService
94
+ g as AbstractEventService
107
95
  };
@@ -1,5 +1,6 @@
1
1
  export * from './AbstractAccessTokenSnapshotService';
2
2
  export * from './AbstractCommitmentsSnapshotService';
3
+ export * from './AbstractApprovalsSnapshotService';
3
4
  export * from './AbstractNullifierSnapshotService';
4
5
  export * from './AbstractSnapshotService';
5
6
  export * from './AbstractEventService';
@@ -11,3 +11,5 @@ export * from './transactions-manager';
11
11
  export * from './volatile-helper';
12
12
  export * from './MultiThreadedUtxoUtils/MultiThreadedUtxoUtils';
13
13
  export * from './cacheDevices';
14
+ export * from './IndexedDB';
15
+ export * from './TokenDBs';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../error-handling/logError.cjs"),u=require("./MerkleTreeIncompleteError.cjs");class h{constructor(t,e,n,i,r,s){this.hashFunction=t,this.levels=e,this.defaultNodeValue=n,this.tree=i??new Map,this.count=s??0n,this.index=r??2n**(e-1n)}tree;count;index;static createWithData(t,e,n,i,r,s){return new h(i,r,s,t,e,n)}static create(t,e,n){return new h(t,e,n)}getStartIndex(){return 2n**(this.levels-1n)}logarithm2(t){let e=0n;for(;2n**e<t;)e+=1n;return e}bigIntMax(t,e){return t>e?t:e}forceInsert(t,e){if(e<this.getStartIndex())throw new RangeError;this.tree.set(e,t);const n=this.index-this.getStartIndex(),i=this.logarithm2(n);let r=e;for(let s=1n;s<=i;s+=1n){r/=2n;const l=this.hashFunction(this.tree.get(r*2n)||this.defaultNodeValue,this.tree.get(r*2n+1n)||this.defaultNodeValue);this.tree.set(r,l)}}insert(t,e){let n=!1;return this.tree.has(e)&&(n=!0,o.logError(`Editing commitment index: ${e} `)),n||(this.count+=1n),this.index=this.bigIntMax(this.index,e+1n),this.forceInsert(t,e),!0}remove(t){this.forceInsert(this.defaultNodeValue,t)}completenessCheck(){if(this.count!==this.index-this.getStartIndex())throw new u.MerkleTreeIncompleteError}getRootHash(){this.completenessCheck();for(let t=1n;t<2n**this.levels;t*=2n)if(this.tree.get(t))return this.tree.get(t);return this.defaultNodeValue}getMerkleData(){return this.completenessCheck(),new Map(this.tree)}getSiblingIndex(t){return t===1n?1n:t%2n===1n?t-1n:t+1n}getSiblingHashesForVerification(t){this.completenessCheck();let e;for(let i=this.getStartIndex();i<this.getStartIndex()+this.index;i+=1n)if(this.tree.get(i)===t){e=i;break}if(e===void 0)return new Array(Number(this.levels)).fill(0n);const n=[];for(;e!==0n;)n.push(this.tree.get(this.getSiblingIndex(e))||this.defaultNodeValue),e/=2n;return n}getSiblingSides(t){this.completenessCheck();let e;for(let i=this.getStartIndex();i<this.getStartIndex()+this.index;i+=1n)if(this.tree.get(i)===t){e=i;break}if(e===void 0)return new Array(Number(this.levels)).fill(0n);const n=[];for(;e!==0n;){const i=e%2n===0n?0n:1n;n.push(i),e/=2n}return n}toJSON(){const{tree:t,count:e,index:n}=this;return{tree:Object.fromEntries(t),count:e.toString(),index:n.toString()}}clone(){return h.createWithData(new Map(this.tree),this.index,this.count,this.hashFunction,this.levels,this.defaultNodeValue)}getIndex(){return this.index}}exports.MerkleTree=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../error-handling/logError.cjs"),u=require("./MerkleTreeIncompleteError.cjs");class o{constructor(t,e,r,s,i,n,h){this.hashFunction=t,this.levels=e,this.defaultNodeValue=r,this.tree=s??new Map,this.count=h??0n,this.index=n??2n**(e-1n),i?this.reverseTree=i:this.reverseTree=this.createReverseTree()}tree;count;index;reverseTree;static createWithData(t,e,r,s,i,n,h){return new o(i,n,h,t,e,r,s)}static create(t,e,r){return new o(t,e,r)}createReverseTree(){const t=new Map;for(let e=this.getStartIndex();e<this.getStartIndex()+this.count;e+=1n){const r=this.tree.get(e);r!==void 0&&t.set(r,e)}return t}getStartIndex(){return 2n**(this.levels-1n)}logarithm2(t){let e=0n;for(;2n**e<t;)e+=1n;return e}bigIntMax(t,e){return t>e?t:e}forceInsert(t,e){if(e<this.getStartIndex())throw new RangeError;this.tree.set(e,t),this.reverseTree.set(t,e);const r=this.index-this.getStartIndex(),s=this.logarithm2(r);let i=e;for(let n=1n;n<=s;n+=1n){i/=2n;const h=this.hashFunction(this.tree.get(i*2n)||this.defaultNodeValue,this.tree.get(i*2n+1n)||this.defaultNodeValue);this.tree.set(i,h)}}insert(t,e){let r=!1;return this.tree.has(e)&&(r=!0,l.logError(`Editing commitment index: ${e} `)),r||(this.count+=1n),this.index=this.bigIntMax(this.index,e+1n),this.forceInsert(t,e),!0}remove(t){this.forceInsert(this.defaultNodeValue,t)}completenessCheck(){if(this.count!==this.index-this.getStartIndex())throw new u.MerkleTreeIncompleteError}getRootHash(){this.completenessCheck();for(let t=1n;t<2n**this.levels;t*=2n)if(this.tree.get(t))return this.tree.get(t);return this.defaultNodeValue}getMerkleData(){return this.completenessCheck(),new Map(this.tree)}getSiblingIndex(t){return t===1n?1n:t%2n===1n?t-1n:t+1n}getSiblingHashesForVerification(t){this.completenessCheck();let e=this.reverseTree.get(t);if(e===void 0)return new Array(Number(this.levels)).fill(0n);const r=[];for(;e!==0n;)r.push(this.tree.get(this.getSiblingIndex(e))||this.defaultNodeValue),e/=2n;return r}getSiblingSides(t){this.completenessCheck();let e=this.reverseTree.get(t);if(e===void 0)return new Array(Number(this.levels)).fill(0n);const r=[];for(;e!==0n;){const s=e%2n===0n?0n:1n;r.push(s),e/=2n}return r}toJSON(){const{tree:t,reverseTree:e,count:r,index:s}=this;return{tree:Object.fromEntries(t),reverseTree:Object.fromEntries(e),count:r.toString(),index:s.toString()}}clone(){return o.createWithData(new Map(this.tree),new Map(this.reverseTree),this.index,this.count,this.hashFunction,this.levels,this.defaultNodeValue)}getIndex(){return this.index}}exports.MerkleTree=o;
@@ -1,5 +1,6 @@
1
1
  export type MerkleTreeJson = {
2
2
  tree: Record<string, string>;
3
+ reverseTree?: Record<string, string>;
3
4
  count: string;
4
5
  index: string;
5
6
  };
@@ -25,13 +26,15 @@ export declare class MerkleTree<T> {
25
26
  * meaning that there aren't any missing elements between getStartIndex() and index
26
27
  */
27
28
  private index;
28
- static createWithData<T>(tree: Map<bigint, T>, index: bigint, count: bigint, hashFunction: (a: T, b: T) => T, levels: bigint, defaultNodeValue: T): MerkleTree<T>;
29
+ private reverseTree;
30
+ static createWithData<T>(tree: Map<bigint, T>, reverseTree: Map<T, bigint> | undefined, index: bigint, count: bigint, hashFunction: (a: T, b: T) => T, levels: bigint, defaultNodeValue: T): MerkleTree<T>;
29
31
  /**
30
32
  * @param hashFunction the hashFunction used to fill the upper layers of the merkle tree
31
33
  * @param levels the amount of layers in the merkle tree
32
34
  * @param defaultNodeValue the default value of an empty node in the merkle tree
33
35
  */
34
36
  static create<T>(hashFunction: (a: T, b: T) => T, levels: bigint, defaultNodeValue: T): MerkleTree<T>;
37
+ private createReverseTree;
35
38
  private constructor();
36
39
  /**
37
40
  * get starting nodeIndex from which inserts are allowed
@@ -1,8 +1,8 @@
1
1
  import { logError as l } from "../../error-handling/logError.mjs";
2
2
  import { MerkleTreeIncompleteError as a } from "./MerkleTreeIncompleteError.mjs";
3
- class h {
4
- constructor(e, t, i, n, r, s) {
5
- this.hashFunction = e, this.levels = t, this.defaultNodeValue = i, this.tree = n ?? /* @__PURE__ */ new Map(), this.count = s ?? 0n, this.index = r ?? 2n ** (t - 1n);
3
+ class o {
4
+ constructor(t, e, r, i, s, n, h) {
5
+ this.hashFunction = t, this.levels = e, this.defaultNodeValue = r, this.tree = i ?? /* @__PURE__ */ new Map(), this.count = h ?? 0n, this.index = n ?? 2n ** (e - 1n), s ? this.reverseTree = s : this.reverseTree = this.createReverseTree();
6
6
  }
7
7
  /**
8
8
  * the map where the items are stored
@@ -18,16 +18,25 @@ class h {
18
18
  * meaning that there aren't any missing elements between getStartIndex() and index
19
19
  */
20
20
  index;
21
- static createWithData(e, t, i, n, r, s) {
22
- return new h(n, r, s, e, t, i);
21
+ reverseTree;
22
+ static createWithData(t, e, r, i, s, n, h) {
23
+ return new o(s, n, h, t, e, r, i);
23
24
  }
24
25
  /**
25
26
  * @param hashFunction the hashFunction used to fill the upper layers of the merkle tree
26
27
  * @param levels the amount of layers in the merkle tree
27
28
  * @param defaultNodeValue the default value of an empty node in the merkle tree
28
29
  */
29
- static create(e, t, i) {
30
- return new h(e, t, i);
30
+ static create(t, e, r) {
31
+ return new o(t, e, r);
32
+ }
33
+ createReverseTree() {
34
+ const t = /* @__PURE__ */ new Map();
35
+ for (let e = this.getStartIndex(); e < this.getStartIndex() + this.count; e += 1n) {
36
+ const r = this.tree.get(e);
37
+ r !== void 0 && t.set(r, e);
38
+ }
39
+ return t;
31
40
  }
32
41
  /**
33
42
  * get starting nodeIndex from which inserts are allowed
@@ -38,28 +47,28 @@ class h {
38
47
  /**
39
48
  * implementation of logarithm2 function from merkle contract
40
49
  */
41
- logarithm2(e) {
42
- let t = 0n;
43
- for (; 2n ** t < e; )
44
- t += 1n;
45
- return t;
50
+ logarithm2(t) {
51
+ let e = 0n;
52
+ for (; 2n ** e < t; )
53
+ e += 1n;
54
+ return e;
46
55
  }
47
- bigIntMax(e, t) {
48
- return e > t ? e : t;
56
+ bigIntMax(t, e) {
57
+ return t > e ? t : e;
49
58
  }
50
- forceInsert(e, t) {
51
- if (t < this.getStartIndex())
59
+ forceInsert(t, e) {
60
+ if (e < this.getStartIndex())
52
61
  throw new RangeError();
53
- this.tree.set(t, e);
54
- const i = this.index - this.getStartIndex(), n = this.logarithm2(i);
55
- let r = t;
56
- for (let s = 1n; s <= n; s += 1n) {
57
- r /= 2n;
58
- const o = this.hashFunction(
59
- this.tree.get(r * 2n) || this.defaultNodeValue,
60
- this.tree.get(r * 2n + 1n) || this.defaultNodeValue
62
+ this.tree.set(e, t), this.reverseTree.set(t, e);
63
+ const r = this.index - this.getStartIndex(), i = this.logarithm2(r);
64
+ let s = e;
65
+ for (let n = 1n; n <= i; n += 1n) {
66
+ s /= 2n;
67
+ const h = this.hashFunction(
68
+ this.tree.get(s * 2n) || this.defaultNodeValue,
69
+ this.tree.get(s * 2n + 1n) || this.defaultNodeValue
61
70
  );
62
- this.tree.set(r, o);
71
+ this.tree.set(s, h);
63
72
  }
64
73
  }
65
74
  /**
@@ -69,12 +78,12 @@ class h {
69
78
  * @return true - if added, false - if already exists
70
79
  * @throws will throw RangeError if nodeIndex is less than getStartIndex()
71
80
  */
72
- insert(e, t) {
73
- let i = !1;
74
- return this.tree.has(t) && (i = !0, l(`Editing commitment index: ${t} `)), i || (this.count += 1n), this.index = this.bigIntMax(this.index, t + 1n), this.forceInsert(e, t), !0;
81
+ insert(t, e) {
82
+ let r = !1;
83
+ return this.tree.has(e) && (r = !0, l(`Editing commitment index: ${e} `)), r || (this.count += 1n), this.index = this.bigIntMax(this.index, e + 1n), this.forceInsert(t, e), !0;
75
84
  }
76
- remove(e) {
77
- this.forceInsert(this.defaultNodeValue, e);
85
+ remove(t) {
86
+ this.forceInsert(this.defaultNodeValue, t);
78
87
  }
79
88
  completenessCheck() {
80
89
  if (this.count !== this.index - this.getStartIndex())
@@ -87,69 +96,61 @@ class h {
87
96
  */
88
97
  getRootHash() {
89
98
  this.completenessCheck();
90
- for (let e = 1n; e < 2n ** this.levels; e *= 2n)
91
- if (this.tree.get(e))
92
- return this.tree.get(e);
99
+ for (let t = 1n; t < 2n ** this.levels; t *= 2n)
100
+ if (this.tree.get(t))
101
+ return this.tree.get(t);
93
102
  return this.defaultNodeValue;
94
103
  }
95
104
  getMerkleData() {
96
105
  return this.completenessCheck(), new Map(this.tree);
97
106
  }
98
- getSiblingIndex(e) {
99
- return e === 1n ? 1n : e % 2n === 1n ? e - 1n : e + 1n;
107
+ getSiblingIndex(t) {
108
+ return t === 1n ? 1n : t % 2n === 1n ? t - 1n : t + 1n;
100
109
  }
101
110
  /**
102
111
  * get sibling hashes needed by main.circom
103
112
  * @throws will throw MerkleTreeIncompleteError if there are missing elements in the tree
104
113
  */
105
- getSiblingHashesForVerification(e) {
114
+ getSiblingHashesForVerification(t) {
106
115
  this.completenessCheck();
107
- let t;
108
- for (let n = this.getStartIndex(); n < this.getStartIndex() + this.index; n += 1n)
109
- if (this.tree.get(n) === e) {
110
- t = n;
111
- break;
112
- }
113
- if (t === void 0)
116
+ let e = this.reverseTree.get(t);
117
+ if (e === void 0)
114
118
  return new Array(Number(this.levels)).fill(0n);
115
- const i = [];
116
- for (; t !== 0n; )
117
- i.push(this.tree.get(this.getSiblingIndex(t)) || this.defaultNodeValue), t /= 2n;
118
- return i;
119
+ const r = [];
120
+ for (; e !== 0n; )
121
+ r.push(this.tree.get(this.getSiblingIndex(e)) || this.defaultNodeValue), e /= 2n;
122
+ return r;
119
123
  }
120
124
  /**
121
125
  * get item's sibling hashes side
122
126
  * @returns sibling's indexes
123
127
  * @throws will throw MerkleTreeIncompleteError if there are missing elements in the tree
124
128
  */
125
- getSiblingSides(e) {
129
+ getSiblingSides(t) {
126
130
  this.completenessCheck();
127
- let t;
128
- for (let n = this.getStartIndex(); n < this.getStartIndex() + this.index; n += 1n)
129
- if (this.tree.get(n) === e) {
130
- t = n;
131
- break;
132
- }
133
- if (t === void 0)
131
+ let e = this.reverseTree.get(t);
132
+ if (e === void 0)
134
133
  return new Array(Number(this.levels)).fill(0n);
135
- const i = [];
136
- for (; t !== 0n; ) {
137
- const n = t % 2n === 0n ? 0n : 1n;
138
- i.push(n), t /= 2n;
134
+ const r = [];
135
+ for (; e !== 0n; ) {
136
+ const i = e % 2n === 0n ? 0n : 1n;
137
+ r.push(i), e /= 2n;
139
138
  }
140
- return i;
139
+ return r;
141
140
  }
142
141
  toJSON() {
143
- const { tree: e, count: t, index: i } = this;
142
+ const { tree: t, reverseTree: e, count: r, index: i } = this;
144
143
  return {
145
- tree: Object.fromEntries(e),
146
- count: t.toString(),
144
+ tree: Object.fromEntries(t),
145
+ reverseTree: Object.fromEntries(e),
146
+ count: r.toString(),
147
147
  index: i.toString()
148
148
  };
149
149
  }
150
150
  clone() {
151
- return h.createWithData(
151
+ return o.createWithData(
152
152
  new Map(this.tree),
153
+ new Map(this.reverseTree),
153
154
  this.index,
154
155
  this.count,
155
156
  this.hashFunction,
@@ -162,5 +163,5 @@ class h {
162
163
  }
163
164
  }
164
165
  export {
165
- h as MerkleTree
166
+ o as MerkleTree
166
167
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(t,c,n)=>{if(n)return t;const e=t.clone(),s=e.getIndex(),r=BigInt(c.getAccessKey());return e.insert(r,s),e};exports.getPatchedAccessTokenMerkleTree=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../functions/web3/etherFunctions.cjs"),c=require("../../crypto/poseidon.cjs"),i=require("./MerkleTree.cjs"),g=(r,n,o,t)=>{if(!t||o){const e=i.MerkleTree.create(c.poseidonFunction,25n,0n);return e.insert(BigInt(n.getAccessKey()),e.getStartIndex()),t||e.insert(s.randomBigInt(31),e.getStartIndex()+1n),e}return r};exports.getPatchedAccessTokenMerkleTree=g;
@@ -1,3 +1,3 @@
1
1
  import { UserKeys } from '../crypto-keys/keys';
2
2
  import { MerkleTree } from './MerkleTree';
3
- export declare const getPatchedAccessTokenMerkleTree: (merkleTreeAccessToken: MerkleTree<bigint>, userKeys: UserKeys, hasAccessToken: boolean) => MerkleTree<bigint>;
3
+ export declare const getPatchedAccessTokenMerkleTree: (merkleTreeAccessToken: MerkleTree<bigint>, userKeys: UserKeys, patchAccessTokenMerkleTree: boolean, kycRequired: boolean) => MerkleTree<bigint>;
@@ -1,9 +1,13 @@
1
- const o = (n, t, c) => {
2
- if (c)
3
- return n;
4
- const e = n.clone(), s = e.getIndex(), r = BigInt(t.getAccessKey());
5
- return e.insert(r, s), e;
1
+ import { randomBigInt as i } from "../../functions/web3/etherFunctions.mjs";
2
+ import { poseidonFunction as s } from "../../crypto/poseidon.mjs";
3
+ import { MerkleTree as c } from "./MerkleTree.mjs";
4
+ const f = (r, n, o, t) => {
5
+ if (!t || o) {
6
+ const e = c.create(s, 25n, 0n);
7
+ return e.insert(BigInt(n.getAccessKey()), e.getStartIndex()), t || e.insert(i(31), e.getStartIndex() + 1n), e;
8
+ }
9
+ return r;
6
10
  };
7
11
  export {
8
- o as getPatchedAccessTokenMerkleTree
12
+ f as getPatchedAccessTokenMerkleTree
9
13
  };
@@ -8,6 +8,7 @@ export interface ChainEventListener {
8
8
  export interface IProviderAdapter<ConnectorType = unknown> {
9
9
  chainId: number | undefined;
10
10
  initConnector(connector: ConnectorType): void;
11
+ getSigner(): Signer;
11
12
  initSigner?(signer: Signer): void;
12
13
  init(chainId?: number): Promise<void>;
13
14
  initConfig?(config?: any): Promise<void> | void;
@@ -27,6 +28,7 @@ export interface IProviderAdapter<ConnectorType = unknown> {
27
28
  getContractWithFetcherForEthereum(contract: ContractType, contractAddress?: string): Contract;
28
29
  sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
29
30
  switchNetwork(network: EthereumNetwork): Promise<unknown>;
31
+ switchAccount(signer: ethers.Signer): Promise<void>;
30
32
  onAccountChanged(): Promise<unknown>;
31
33
  onChainChanged(chainId?: number): Promise<unknown>;
32
34
  isPermitterAvailable(): boolean;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const t=require("../../API/fetchCommitmentsCache.cjs");class c extends s.AbstractAccessTokenSnapshotService{constructor(r,e){super(r,0,!1,e)}async fetchSnapshot(){const{chainId:r}=await this.contract.provider.getNetwork(),e=await t.fetchAccessTokenSnapshot(r);if(e.accessTokenContractAddress!==this.contract.address||e.chainId!==r)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,senderAddresses:e.senderAddresses,senderAddressIndexMap:e.senderAddressIndexMap}}persistSnapshot(r){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../error-handling/error-codes.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const t=require("../../API/fetchCommitmentsCache.cjs");class c extends s.AbstractAccessTokenSnapshotService{constructor(r,e){super(r,0,!1,e)}async fetchSnapshot(){const{chainId:r}=await this.contract.provider.getNetwork(),e=await t.fetchAccessTokenSnapshot(r);if(e.accessTokenContractAddress!==this.contract.address||e.chainId!==r)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,senderAddresses:e.senderAddresses,senderAddressIndexMap:e.senderAddressIndexMap}}persistSnapshot(r){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=c;
@@ -1,23 +1,19 @@
1
- import { AbstractAccessTokenSnapshotService as t } from "../event-service/AbstractAccessTokenSnapshotService.mjs";
1
+ import { AbstractAccessTokenSnapshotService as s } from "../event-service/AbstractAccessTokenSnapshotService.mjs";
2
2
  import "ethers";
3
3
  import "circomlibjs-hinkal-fork";
4
4
  import "libsodium-wrappers";
5
5
  import "process";
6
6
  import "buffer";
7
7
  import "../../constants/vite.constants.mjs";
8
+ import "../../error-handling/error-codes.constants.mjs";
8
9
  import "../../constants/reorg-depths.constants.mjs";
9
- import "axios";
10
- import "../../constants/chains.constants.mjs";
11
- import "../../types/circom-data.types.mjs";
12
- import "../../types/transactions.types.mjs";
13
- import "../../types/curve.types.mjs";
14
- import { fetchAccessTokenSnapshot as s } from "../../API/fetchCommitmentsCache.mjs";
15
- class u extends t {
10
+ import { fetchAccessTokenSnapshot as t } from "../../API/fetchCommitmentsCache.mjs";
11
+ class S extends s {
16
12
  constructor(r, e) {
17
13
  super(r, 0, !1, e);
18
14
  }
19
15
  async fetchSnapshot() {
20
- const { chainId: r } = await this.contract.provider.getNetwork(), e = await s(r);
16
+ const { chainId: r } = await this.contract.provider.getNetwork(), e = await t(r);
21
17
  if (e.accessTokenContractAddress !== this.contract.address || e.chainId !== r)
22
18
  throw Error("Commitment Snapshot: incorrect contract or chain id");
23
19
  return {
@@ -32,5 +28,5 @@ class u extends t {
32
28
  }
33
29
  }
34
30
  export {
35
- u as ClientAccessTokenSnapshotService
31
+ S as ClientAccessTokenSnapshotService
36
32
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../event-service/AbstractApprovalsSnapshotService.cjs"),r=require("../../API/fetchCommitmentsCache.cjs");class s extends a.AbstractApprovalsSnapshotService{constructor(e,t){super(e,0,!1,t)}async fetchSnapshot(){const{chainId:e}=await this.contract.provider.getNetwork(),t=await r.fetchApprovalsSnapshot(e);if(t.hinkalAddress!==this.contract.address||t.chainId!==e)throw Error("approvalsSnapshotData Snapshot: incorrect contract or chain id");return{latestBlockNumber:t.latestBlockNumber,approvals:t.approvals,events:t.events}}persistSnapshot(e){return Promise.resolve()}}exports.ClientApprovalsSnapshotService=s;
@@ -0,0 +1,8 @@
1
+ import { Contract } from 'ethers';
2
+ import { AbstractApprovalsSnapshotService, ApprovalsSerializedSnapshot } from '../event-service/AbstractApprovalsSnapshotService';
3
+ import { CommitmentsSerializedSnapshot } from '../event-service';
4
+ export declare class ClientApprovalsSnapshotService extends AbstractApprovalsSnapshotService {
5
+ constructor(contract: Contract, maxPageSize?: number);
6
+ protected fetchSnapshot(): Promise<ApprovalsSerializedSnapshot>;
7
+ protected persistSnapshot(_serializedSnapshot: CommitmentsSerializedSnapshot): Promise<unknown>;
8
+ }