@hinkal/common 0.2.13 → 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 (656) hide show
  1. package/API/API.cjs +1 -1
  2. package/API/API.d.ts +10 -3
  3. package/API/API.mjs +42 -31
  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 +7 -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/rewardsPointsCalls.cjs +1 -1
  27. package/API/rewardsPointsCalls.d.ts +3 -3
  28. package/API/rewardsPointsCalls.mjs +1 -3
  29. package/API/tenderly.api.cjs +1 -0
  30. package/API/tenderly.api.d.ts +12 -0
  31. package/API/tenderly.api.mjs +47 -0
  32. package/API/token-calls.cjs +1 -0
  33. package/API/token-calls.d.ts +2 -0
  34. package/API/token-calls.mjs +9 -0
  35. package/API/userVerifyTransactions.cjs +1 -1
  36. package/API/userVerifyTransactions.d.ts +6 -7
  37. package/API/userVerifyTransactions.mjs +13 -14
  38. package/constants/addresses.constants.cjs +1 -0
  39. package/constants/addresses.constants.d.ts +16 -0
  40. package/constants/addresses.constants.mjs +50 -0
  41. package/constants/assets.constants.cjs +1 -1
  42. package/constants/assets.constants.mjs +13 -13
  43. package/constants/axelar.constants.cjs +1 -1
  44. package/constants/axelar.constants.mjs +5 -5
  45. package/constants/balance.constants.cjs +1 -0
  46. package/constants/balance.constants.d.ts +1 -0
  47. package/constants/balance.constants.mjs +4 -0
  48. package/constants/chains.constants.cjs +1 -1
  49. package/constants/chains.constants.d.ts +0 -2
  50. package/constants/chains.constants.mjs +28 -40
  51. package/constants/contracts.constants.cjs +1 -1
  52. package/constants/contracts.constants.mjs +144 -140
  53. package/constants/conversion.constants.cjs +1 -0
  54. package/constants/conversion.constants.d.ts +1 -0
  55. package/constants/conversion.constants.mjs +4 -0
  56. package/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
  57. package/constants/deploy-data/deploy-data-arbMainnet.json.mjs +846 -11
  58. package/constants/deploy-data/deploy-data-avalanche.json.cjs +1 -1
  59. package/constants/deploy-data/deploy-data-avalanche.json.mjs +848 -13
  60. package/constants/deploy-data/deploy-data-base.json.cjs +1 -1
  61. package/constants/deploy-data/deploy-data-base.json.mjs +852 -17
  62. package/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
  63. package/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +855 -20
  64. package/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
  65. package/constants/deploy-data/deploy-data-ethMainnet.json.mjs +850 -15
  66. package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
  67. package/constants/deploy-data/deploy-data-localhost.json.mjs +3208 -1550
  68. package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
  69. package/constants/deploy-data/deploy-data-optimism.json.mjs +10010 -3429
  70. package/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
  71. package/constants/deploy-data/deploy-data-polygon.json.mjs +844 -9
  72. package/constants/fees.constants.cjs +1 -1
  73. package/constants/fees.constants.d.ts +5 -3
  74. package/constants/fees.constants.mjs +22 -19
  75. package/constants/index.d.ts +6 -0
  76. package/constants/kyc.constants.cjs +1 -1
  77. package/constants/kyc.constants.mjs +30 -18
  78. package/constants/mediaUrls.constants.cjs +1 -0
  79. package/constants/mediaUrls.constants.d.ts +23 -0
  80. package/constants/mediaUrls.constants.mjs +26 -0
  81. package/constants/permit2.constants.cjs +1 -0
  82. package/constants/permit2.constants.d.ts +2 -0
  83. package/constants/permit2.constants.mjs +5 -0
  84. package/constants/protocol.constants.cjs +1 -1
  85. package/constants/protocol.constants.d.ts +6 -0
  86. package/constants/protocol.constants.mjs +27 -15
  87. package/constants/rewards.constants.cjs +1 -1
  88. package/constants/rewards.constants.mjs +14 -12
  89. package/constants/server.constants.cjs +1 -1
  90. package/constants/server.constants.d.ts +14 -6
  91. package/constants/server.constants.mjs +24 -16
  92. package/constants/token-data/ERC20Registry.cjs +1 -1
  93. package/constants/token-data/ERC20Registry.mjs +49 -48
  94. package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
  95. package/constants/token-data/arbMainnetRegistry.json.mjs +89 -86
  96. package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
  97. package/constants/token-data/arbMainnetRegistryFixed.json.mjs +79 -76
  98. package/constants/token-data/avalancheRegistry.json.cjs +1 -1
  99. package/constants/token-data/avalancheRegistry.json.mjs +51 -48
  100. package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
  101. package/constants/token-data/avalancheRegistryFixed.json.mjs +51 -48
  102. package/constants/token-data/baseRegistry.json.cjs +1 -1
  103. package/constants/token-data/baseRegistry.json.mjs +34 -31
  104. package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
  105. package/constants/token-data/baseRegistryFixed.json.mjs +31 -28
  106. package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
  107. package/constants/token-data/bnbMainnetRegistry.json.mjs +67 -64
  108. package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
  109. package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +67 -64
  110. package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
  111. package/constants/token-data/ethMainnetRegistry.json.mjs +229 -226
  112. package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
  113. package/constants/token-data/ethMainnetRegistryFixed.json.mjs +193 -190
  114. package/constants/token-data/index.cjs +1 -0
  115. package/constants/token-data/index.d.ts +1063 -15
  116. package/constants/token-data/index.mjs +34 -0
  117. package/constants/token-data/localhostRegistry.json.cjs +1 -1
  118. package/constants/token-data/localhostRegistry.json.mjs +296 -276
  119. package/constants/token-data/optimismRegistry.json.cjs +1 -1
  120. package/constants/token-data/optimismRegistry.json.mjs +703 -180
  121. package/constants/token-data/optimismRegistryFixed.json.cjs +1 -1
  122. package/constants/token-data/optimismRegistryFixed.json.mjs +679 -173
  123. package/constants/token-data/polygonRegistry.json.cjs +1 -1
  124. package/constants/token-data/polygonRegistry.json.mjs +110 -107
  125. package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
  126. package/constants/token-data/polygonRegistryFixed.json.mjs +102 -99
  127. package/constants/token.limits.constants.cjs +1 -0
  128. package/constants/token.limits.constants.d.ts +5 -0
  129. package/constants/token.limits.constants.mjs +30 -0
  130. package/constants/vite.constants.cjs +1 -1
  131. package/constants/vite.constants.d.ts +5 -0
  132. package/constants/vite.constants.mjs +26 -22
  133. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  134. package/data-structures/Hinkal/Hinkal.d.ts +48 -20
  135. package/data-structures/Hinkal/Hinkal.mjs +263 -85
  136. package/data-structures/Hinkal/IHinkal.d.ts +37 -10
  137. package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
  138. package/data-structures/Hinkal/hinkalActionBeefy.mjs +25 -23
  139. package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
  140. package/data-structures/Hinkal/hinkalActionConvex.mjs +11 -9
  141. package/data-structures/Hinkal/hinkalActionCurve.cjs +1 -1
  142. package/data-structures/Hinkal/hinkalActionCurve.mjs +18 -16
  143. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +1 -0
  144. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +3 -0
  145. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +61 -0
  146. package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
  147. package/data-structures/Hinkal/hinkalActionLidoEth.mjs +24 -22
  148. package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
  149. package/data-structures/Hinkal/hinkalActionPendle.d.ts +1 -1
  150. package/data-structures/Hinkal/hinkalActionPendle.mjs +17 -15
  151. package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
  152. package/data-structures/Hinkal/hinkalActionPendleLP.mjs +29 -26
  153. package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -0
  154. package/data-structures/Hinkal/hinkalActionReceive.d.ts +4 -0
  155. package/data-structures/Hinkal/hinkalActionReceive.mjs +39 -0
  156. package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
  157. package/data-structures/Hinkal/hinkalActionStake.d.ts +1 -1
  158. package/data-structures/Hinkal/hinkalActionStake.mjs +15 -11
  159. package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
  160. package/data-structures/Hinkal/hinkalActionVolatile.d.ts +1 -1
  161. package/data-structures/Hinkal/hinkalActionVolatile.mjs +31 -26
  162. package/data-structures/Hinkal/hinkalApprove.cjs +1 -0
  163. package/data-structures/Hinkal/hinkalApprove.d.ts +2 -0
  164. package/data-structures/Hinkal/hinkalApprove.mjs +120 -0
  165. package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -0
  166. package/data-structures/Hinkal/hinkalCheckTokenRegistry.d.ts +3 -0
  167. package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -0
  168. package/data-structures/Hinkal/hinkalDeploySubAccount.cjs +1 -0
  169. package/data-structures/Hinkal/hinkalDeploySubAccount.d.ts +3 -0
  170. package/data-structures/Hinkal/hinkalDeploySubAccount.mjs +15 -0
  171. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  172. package/data-structures/Hinkal/hinkalDeposit.d.ts +3 -2
  173. package/data-structures/Hinkal/hinkalDeposit.mjs +116 -52
  174. package/data-structures/Hinkal/hinkalGetRecipientInfo.cjs +1 -0
  175. package/data-structures/Hinkal/hinkalGetRecipientInfo.d.ts +2 -0
  176. package/data-structures/Hinkal/hinkalGetRecipientInfo.mjs +10 -0
  177. package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
  178. package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +6 -17
  179. package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -0
  180. package/data-structures/Hinkal/hinkalInsideTransact.d.ts +2 -0
  181. package/data-structures/Hinkal/hinkalInsideTransact.mjs +111 -0
  182. package/data-structures/Hinkal/hinkalMultiSend.cjs +1 -0
  183. package/data-structures/Hinkal/hinkalMultiSend.d.ts +3 -0
  184. package/data-structures/Hinkal/hinkalMultiSend.mjs +13 -0
  185. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  186. package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -1
  187. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +83 -37
  188. package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -0
  189. package/data-structures/Hinkal/hinkalProoflessDeposit.d.ts +4 -0
  190. package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +46 -0
  191. package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -0
  192. package/data-structures/Hinkal/hinkalProxySwap.d.ts +5 -0
  193. package/data-structures/Hinkal/hinkalProxySwap.mjs +36 -0
  194. package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -0
  195. package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +3 -0
  196. package/data-structures/Hinkal/hinkalSignSubAccount.mjs +20 -0
  197. package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
  198. package/data-structures/Hinkal/hinkalSwap.d.ts +2 -1
  199. package/data-structures/Hinkal/hinkalSwap.mjs +69 -60
  200. package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
  201. package/data-structures/Hinkal/hinkalWithdraw.d.ts +3 -1
  202. package/data-structures/Hinkal/hinkalWithdraw.mjs +77 -50
  203. package/data-structures/Hinkal/index.d.ts +1 -0
  204. package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
  205. package/data-structures/Hinkal/resetMerkleTrees.mjs +18 -11
  206. package/data-structures/IndexedDB/activity-db.cjs +1 -0
  207. package/data-structures/IndexedDB/activity-db.d.ts +16 -0
  208. package/data-structures/IndexedDB/activity-db.mjs +124 -0
  209. package/data-structures/IndexedDB/balances-db.cjs +1 -0
  210. package/data-structures/IndexedDB/balances-db.d.ts +13 -0
  211. package/data-structures/IndexedDB/balances-db.mjs +75 -0
  212. package/data-structures/IndexedDB/contact-db.cjs +1 -0
  213. package/data-structures/IndexedDB/contact-db.d.ts +11 -0
  214. package/data-structures/IndexedDB/contact-db.mjs +44 -0
  215. package/data-structures/IndexedDB/index.d.ts +5 -0
  216. package/data-structures/IndexedDB/prices-db.cjs +1 -0
  217. package/data-structures/IndexedDB/prices-db.d.ts +9 -0
  218. package/data-structures/IndexedDB/prices-db.mjs +62 -0
  219. package/data-structures/IndexedDB/private-balances-db.cjs +1 -0
  220. package/data-structures/IndexedDB/private-balances-db.d.ts +9 -0
  221. package/data-structures/IndexedDB/private-balances-db.mjs +28 -0
  222. package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs +1 -1
  223. package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs +47 -44
  224. package/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -0
  225. package/data-structures/TokenDBs/PrivateTokensDB.d.ts +11 -0
  226. package/data-structures/TokenDBs/PrivateTokensDB.mjs +53 -0
  227. package/data-structures/TokenDBs/PublicTokensDB.cjs +1 -0
  228. package/data-structures/TokenDBs/PublicTokensDB.d.ts +13 -0
  229. package/data-structures/TokenDBs/PublicTokensDB.mjs +81 -0
  230. package/data-structures/TokenDBs/index.d.ts +2 -0
  231. package/data-structures/cacheDevices/AttachableMemoryCacheDevice.cjs +1 -0
  232. package/data-structures/cacheDevices/AttachableMemoryCacheDevice.d.ts +8 -0
  233. package/data-structures/cacheDevices/AttachableMemoryCacheDevice.mjs +28 -0
  234. package/data-structures/cacheDevices/BaseCacheDevice.cjs +1 -1
  235. package/data-structures/cacheDevices/BaseCacheDevice.d.ts +9 -6
  236. package/data-structures/cacheDevices/BaseCacheDevice.mjs +13 -4
  237. package/data-structures/cacheDevices/FileCacheDevice.cjs +1 -1
  238. package/data-structures/cacheDevices/FileCacheDevice.d.ts +1 -0
  239. package/data-structures/cacheDevices/FileCacheDevice.mjs +7 -3
  240. package/data-structures/cacheDevices/LocalStorageCacheDevice.cjs +1 -1
  241. package/data-structures/cacheDevices/LocalStorageCacheDevice.d.ts +2 -1
  242. package/data-structures/cacheDevices/LocalStorageCacheDevice.mjs +10 -5
  243. package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
  244. package/data-structures/crypto-keys/decodeUTXO.mjs +13 -12
  245. package/data-structures/crypto-keys/keys.cjs +1 -1
  246. package/data-structures/crypto-keys/keys.d.ts +13 -3
  247. package/data-structures/crypto-keys/keys.mjs +45 -34
  248. package/data-structures/custom-token-registry/CustomTokenRegistry.cjs +1 -1
  249. package/data-structures/custom-token-registry/CustomTokenRegistry.d.ts +2 -3
  250. package/data-structures/custom-token-registry/CustomTokenRegistry.mjs +17 -21
  251. package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
  252. package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +15 -29
  253. package/data-structures/event-service/AbstractApprovalsSnapshotService.cjs +1 -0
  254. package/data-structures/event-service/AbstractApprovalsSnapshotService.d.ts +30 -0
  255. package/data-structures/event-service/AbstractApprovalsSnapshotService.mjs +104 -0
  256. package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -1
  257. package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +24 -37
  258. package/data-structures/event-service/AbstractEventService.cjs +1 -1
  259. package/data-structures/event-service/AbstractEventService.d.ts +1 -1
  260. package/data-structures/event-service/AbstractEventService.mjs +15 -15
  261. package/data-structures/event-service/index.d.ts +1 -0
  262. package/data-structures/index.d.ts +2 -0
  263. package/data-structures/merkle-tree/MerkleTree.cjs +1 -1
  264. package/data-structures/merkle-tree/MerkleTree.d.ts +6 -1
  265. package/data-structures/merkle-tree/MerkleTree.mjs +79 -65
  266. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +1 -0
  267. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +3 -0
  268. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +13 -0
  269. package/data-structures/merkle-tree/index.d.ts +1 -0
  270. package/data-structures/provider-adapter/IProviderAdapter.d.ts +2 -0
  271. package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
  272. package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +3 -2
  273. package/data-structures/snapshot/ClientApprovalsSnapshotService.cjs +1 -0
  274. package/data-structures/snapshot/ClientApprovalsSnapshotService.d.ts +8 -0
  275. package/data-structures/snapshot/ClientApprovalsSnapshotService.mjs +23 -0
  276. package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
  277. package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +3 -2
  278. package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
  279. package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +6 -5
  280. package/data-structures/token-price-fetcher/TokenChecker.cjs +1 -1
  281. package/data-structures/token-price-fetcher/TokenChecker.d.ts +1 -0
  282. package/data-structures/token-price-fetcher/TokenChecker.mjs +4 -2
  283. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  284. package/data-structures/transactions-manager/TransactionsManager.d.ts +8 -6
  285. package/data-structures/transactions-manager/TransactionsManager.mjs +124 -122
  286. package/data-structures/transactions-manager/history/getBeefyData.cjs +1 -1
  287. package/data-structures/transactions-manager/history/getBeefyData.mjs +3 -2
  288. package/data-structures/transactions-manager/history/getConvexData.cjs +1 -1
  289. package/data-structures/transactions-manager/history/getConvexData.mjs +3 -2
  290. package/data-structures/transactions-manager/history/getCurveData.cjs +1 -1
  291. package/data-structures/transactions-manager/history/getCurveData.mjs +3 -2
  292. package/data-structures/transactions-manager/history/getLidoData.cjs +1 -1
  293. package/data-structures/transactions-manager/history/getLidoData.mjs +3 -2
  294. package/data-structures/transactions-manager/history/getPendleData.cjs +1 -1
  295. package/data-structures/transactions-manager/history/getPendleData.mjs +13 -12
  296. package/data-structures/transactions-manager/history/getTxDetails.cjs +1 -1
  297. package/data-structures/transactions-manager/history/getTxDetails.mjs +22 -20
  298. package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
  299. package/data-structures/transactions-manager/history/getVolatileData.mjs +11 -10
  300. package/data-structures/transactions-manager/history/history.types.cjs +1 -1
  301. package/data-structures/transactions-manager/history/history.types.mjs +4 -2
  302. package/data-structures/utxo/Utxo.cjs +1 -1
  303. package/data-structures/utxo/Utxo.d.ts +3 -3
  304. package/data-structures/utxo/Utxo.mjs +8 -7
  305. package/error-handling/error-codes.constants.cjs +2 -2
  306. package/error-handling/error-codes.constants.d.ts +22 -1
  307. package/error-handling/error-codes.constants.mjs +129 -112
  308. package/error-handling/get-error.message.cjs +1 -1
  309. package/error-handling/get-error.message.mjs +29 -25
  310. package/error-handling/index.d.ts +1 -0
  311. package/error-handling/logger.cjs +1 -0
  312. package/error-handling/logger.d.ts +5 -0
  313. package/error-handling/logger.mjs +16 -0
  314. package/error-handling/types.cjs +1 -1
  315. package/error-handling/types.d.ts +3 -1
  316. package/error-handling/types.mjs +2 -2
  317. package/externalABIs/BabPassport.json.cjs +1 -1
  318. package/externalABIs/BabPassport.json.mjs +8 -3
  319. package/externalABIs/BeefyRouterAbi.json.cjs +1 -1
  320. package/externalABIs/BeefyRouterAbi.json.mjs +5 -2
  321. package/externalABIs/BeefyStrategyAbi.json.cjs +1 -1
  322. package/externalABIs/BeefyStrategyAbi.json.mjs +5 -2
  323. package/externalABIs/BeefyVaultAbi.json.cjs +1 -1
  324. package/externalABIs/BeefyVaultAbi.json.mjs +5 -2
  325. package/externalABIs/BeefyZapAbi.json.cjs +1 -1
  326. package/externalABIs/BeefyZapAbi.json.mjs +5 -2
  327. package/externalABIs/BeefyZapOneInchAbi.json.cjs +1 -1
  328. package/externalABIs/BeefyZapOneInchAbi.json.mjs +5 -2
  329. package/externalABIs/ConvexBoosterAbi.json.cjs +1 -1
  330. package/externalABIs/ConvexBoosterAbi.json.mjs +5 -2
  331. package/externalABIs/ConvexBoosterAbiMainnet.json.cjs +1 -1
  332. package/externalABIs/ConvexBoosterAbiMainnet.json.mjs +5 -2
  333. package/externalABIs/ConvexRewardPoolAbi.json.cjs +1 -1
  334. package/externalABIs/ConvexRewardPoolAbi.json.mjs +5 -2
  335. package/externalABIs/CurveReadingWrapperAbi.json.cjs +1 -1
  336. package/externalABIs/CurveReadingWrapperAbi.json.mjs +5 -2
  337. package/externalABIs/CurveWrappedMainPool.json.cjs +1 -1
  338. package/externalABIs/CurveWrappedMainPool.json.mjs +5 -2
  339. package/externalABIs/CurveZap.json.cjs +1 -1
  340. package/externalABIs/CurveZap.json.mjs +5 -2
  341. package/externalABIs/CvxCrvUtilities.json.cjs +1 -1
  342. package/externalABIs/CvxCrvUtilities.json.mjs +5 -2
  343. package/externalABIs/ERC20.json.cjs +1 -1
  344. package/externalABIs/ERC20.json.mjs +20 -3
  345. package/externalABIs/GalxePassport.json.cjs +1 -1
  346. package/externalABIs/GalxePassport.json.mjs +8 -3
  347. package/externalABIs/IQuoterV2.json.cjs +1 -1
  348. package/externalABIs/IQuoterV2.json.mjs +20 -3
  349. package/externalABIs/ISwapRouter.json.cjs +1 -1
  350. package/externalABIs/ISwapRouter.json.mjs +5 -2
  351. package/externalABIs/IUniswapV3Factory.json.cjs +1 -1
  352. package/externalABIs/IUniswapV3Factory.json.mjs +20 -3
  353. package/externalABIs/IUniswapV3Pool.json.cjs +1 -1
  354. package/externalABIs/IUniswapV3Pool.json.mjs +20 -3
  355. package/externalABIs/PendleRouterAbi.json.cjs +1 -1
  356. package/externalABIs/PendleRouterAbi.json.mjs +5 -2
  357. package/externalABIs/UniswapV2PoolAbi.json.cjs +1 -1
  358. package/externalABIs/UniswapV2PoolAbi.json.mjs +16 -3
  359. package/externalABIs/index.cjs +1 -0
  360. package/externalABIs/index.d.ts +307 -11
  361. package/externalABIs/index.mjs +23 -0
  362. package/externalABIs/transactionsProver.json.cjs +1 -1
  363. package/externalABIs/transactionsProver.json.mjs +20 -3
  364. package/functions/kyc/zkMeHelper.cjs +1 -1
  365. package/functions/kyc/zkMeHelper.d.ts +0 -1
  366. package/functions/kyc/zkMeHelper.mjs +8 -11
  367. package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -0
  368. package/functions/pre-transaction/getExternalSwapAddress.d.ts +3 -0
  369. package/functions/pre-transaction/getExternalSwapAddress.mjs +26 -0
  370. package/functions/pre-transaction/getFeeStructure.cjs +1 -0
  371. package/functions/pre-transaction/getFeeStructure.d.ts +4 -0
  372. package/functions/pre-transaction/getFeeStructure.mjs +30 -0
  373. package/functions/pre-transaction/getFlatFees.cjs +1 -1
  374. package/functions/pre-transaction/getFlatFees.d.ts +3 -7
  375. package/functions/pre-transaction/getFlatFees.mjs +52 -46
  376. package/functions/pre-transaction/getSignatureDataForTransact.cjs +1 -0
  377. package/functions/pre-transaction/getSignatureDataForTransact.d.ts +3 -0
  378. package/functions/pre-transaction/getSignatureDataForTransact.mjs +6 -0
  379. package/functions/pre-transaction/index.d.ts +1 -0
  380. package/functions/pre-transaction/interaction-to-action.cjs +1 -1
  381. package/functions/pre-transaction/interaction-to-action.mjs +3 -2
  382. package/functions/pre-transaction/merge-with-fee-structure.cjs +1 -0
  383. package/functions/pre-transaction/merge-with-fee-structure.d.ts +2 -0
  384. package/functions/pre-transaction/merge-with-fee-structure.mjs +25 -0
  385. package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -0
  386. package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +16 -0
  387. package/functions/pre-transaction/outputApprovalDataProcessing.mjs +42 -0
  388. package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
  389. package/functions/pre-transaction/outputUtxoProcessing.d.ts +1 -1
  390. package/functions/pre-transaction/outputUtxoProcessing.mjs +19 -30
  391. package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
  392. package/functions/pre-transaction/process-gas-estimates.d.ts +2 -2
  393. package/functions/pre-transaction/process-gas-estimates.mjs +17 -27
  394. package/functions/pre-transaction/processAmountChanges.cjs +1 -1
  395. package/functions/pre-transaction/processAmountChanges.mjs +34 -23
  396. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -0
  397. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +6 -0
  398. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +7 -0
  399. package/functions/private-wallet/emporium.helpers.cjs +1 -1
  400. package/functions/private-wallet/emporium.helpers.d.ts +9 -1
  401. package/functions/private-wallet/emporium.helpers.mjs +117 -22
  402. package/functions/private-wallet/emporium.swap.helpers.cjs +1 -0
  403. package/functions/private-wallet/emporium.swap.helpers.d.ts +5 -0
  404. package/functions/private-wallet/emporium.swap.helpers.mjs +92 -0
  405. package/functions/private-wallet/index.d.ts +1 -0
  406. package/functions/private-wallet/opProducer.cjs +1 -1
  407. package/functions/private-wallet/opProducer.mjs +9 -10
  408. package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -1
  409. package/functions/private-wallet/smartContractWalletCalculator.d.ts +5 -1
  410. package/functions/private-wallet/smartContractWalletCalculator.mjs +22 -17
  411. package/functions/protocols/convex.protocols.cjs +1 -1
  412. package/functions/protocols/convex.protocols.mjs +11 -8
  413. package/functions/protocols/pendle.helpers.cjs +1 -1
  414. package/functions/protocols/pendle.helpers.mjs +20 -15
  415. package/functions/snarkjs/common.snarkjs.cjs +1 -1
  416. package/functions/snarkjs/common.snarkjs.d.ts +8 -5
  417. package/functions/snarkjs/common.snarkjs.mjs +177 -87
  418. package/functions/snarkjs/constant.cjs +1 -1
  419. package/functions/snarkjs/constant.d.ts +223 -1
  420. package/functions/snarkjs/constant.mjs +315 -94
  421. package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
  422. package/functions/snarkjs/constructEmporiumProof.d.ts +6 -3
  423. package/functions/snarkjs/constructEmporiumProof.mjs +148 -84
  424. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  425. package/functions/snarkjs/constructGeneralZkProof.d.ts +5 -3
  426. package/functions/snarkjs/constructGeneralZkProof.mjs +142 -86
  427. package/functions/snarkjs/generateCircomData.cjs +1 -1
  428. package/functions/snarkjs/generateCircomData.d.ts +3 -2
  429. package/functions/snarkjs/generateCircomData.mjs +33 -35
  430. package/functions/snarkjs/generateZkProof.cjs +1 -1
  431. package/functions/snarkjs/generateZkProof.d.ts +2 -2
  432. package/functions/snarkjs/generateZkProof.mjs +4 -15
  433. package/functions/snarkjs/generateZkProofEnclave.cjs +1 -0
  434. package/functions/snarkjs/generateZkProofEnclave.d.ts +6 -0
  435. package/functions/snarkjs/generateZkProofEnclave.mjs +26 -0
  436. package/functions/snarkjs/generateZkProofSelf.cjs +1 -0
  437. package/functions/snarkjs/generateZkProofSelf.d.ts +5 -0
  438. package/functions/snarkjs/generateZkProofSelf.mjs +17 -0
  439. package/functions/snarkjs/getOriginalSender.cjs +1 -0
  440. package/functions/snarkjs/getOriginalSender.d.ts +1 -0
  441. package/functions/snarkjs/getOriginalSender.mjs +5 -0
  442. package/functions/snarkjs/getZKFiles.cjs +1 -1
  443. package/functions/snarkjs/getZKFiles.d.ts +3 -2
  444. package/functions/snarkjs/getZKFiles.mjs +14 -5
  445. package/functions/utils/addresses.cjs +1 -0
  446. package/functions/utils/addresses.d.ts +4 -0
  447. package/functions/utils/addresses.mjs +20 -0
  448. package/functions/utils/amounts.utils.cjs +1 -1
  449. package/functions/utils/amounts.utils.d.ts +4 -1
  450. package/functions/utils/amounts.utils.mjs +29 -27
  451. package/functions/utils/arraysMatch.cjs +1 -0
  452. package/functions/utils/arraysMatch.d.ts +1 -0
  453. package/functions/utils/arraysMatch.mjs +4 -0
  454. package/functions/utils/axelar.utils.cjs +1 -1
  455. package/functions/utils/axelar.utils.d.ts +1 -0
  456. package/functions/utils/axelar.utils.mjs +32 -9
  457. package/functions/utils/cacheDevice.utils.cjs +1 -1
  458. package/functions/utils/cacheDevice.utils.mjs +11 -8
  459. package/functions/utils/cacheFunctions.cjs +1 -1
  460. package/functions/utils/cacheFunctions.d.ts +10 -7
  461. package/functions/utils/cacheFunctions.mjs +62 -39
  462. package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -0
  463. package/functions/utils/convertEmporiumOpToCallInfo.d.ts +2 -0
  464. package/functions/utils/convertEmporiumOpToCallInfo.mjs +10 -0
  465. package/functions/utils/convertIntegrationProviderToExternalActionId.cjs +1 -1
  466. package/functions/utils/convertIntegrationProviderToExternalActionId.d.ts +2 -1
  467. package/functions/utils/convertIntegrationProviderToExternalActionId.mjs +7 -10
  468. package/functions/utils/encodeTokenWithId.cjs +1 -0
  469. package/functions/utils/encodeTokenWithId.d.ts +2 -0
  470. package/functions/utils/encodeTokenWithId.mjs +4 -0
  471. package/functions/utils/encryptInputForEnclave.cjs +1 -0
  472. package/functions/utils/encryptInputForEnclave.d.ts +8 -0
  473. package/functions/utils/encryptInputForEnclave.mjs +43 -0
  474. package/functions/utils/erc20tokenFunctions.cjs +1 -1
  475. package/functions/utils/erc20tokenFunctions.d.ts +8 -2
  476. package/functions/utils/erc20tokenFunctions.mjs +23 -14
  477. package/functions/utils/evmNetworkFunctions.cjs +1 -1
  478. package/functions/utils/evmNetworkFunctions.mjs +7 -4
  479. package/functions/utils/external-action.utils.d.ts +2 -2
  480. package/functions/utils/fees.utils.cjs +1 -0
  481. package/functions/utils/fees.utils.d.ts +2 -0
  482. package/functions/utils/fees.utils.mjs +14 -0
  483. package/functions/utils/getBlockExplorerUrl.cjs +1 -0
  484. package/functions/utils/getBlockExplorerUrl.d.ts +1 -0
  485. package/functions/utils/getBlockExplorerUrl.mjs +6 -0
  486. package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -0
  487. package/functions/utils/getRecipientInfoFromUserKeys.d.ts +3 -0
  488. package/functions/utils/getRecipientInfoFromUserKeys.mjs +18 -0
  489. package/functions/utils/index.d.ts +12 -0
  490. package/functions/utils/involves-permit2-op.cjs +1 -0
  491. package/functions/utils/involves-permit2-op.d.ts +1 -0
  492. package/functions/utils/involves-permit2-op.mjs +5 -0
  493. package/functions/utils/merkleTree.utils.cjs +1 -0
  494. package/functions/utils/merkleTree.utils.d.ts +2 -0
  495. package/functions/utils/merkleTree.utils.mjs +19 -0
  496. package/functions/utils/prepareHinkal.d.ts +6 -0
  497. package/functions/utils/processUseApprovalUtxoData.cjs +1 -0
  498. package/functions/utils/processUseApprovalUtxoData.d.ts +3 -0
  499. package/functions/utils/processUseApprovalUtxoData.mjs +19 -0
  500. package/functions/utils/publicBalance.utils.cjs +1 -0
  501. package/functions/utils/publicBalance.utils.d.ts +5 -0
  502. package/functions/utils/publicBalance.utils.mjs +25 -0
  503. package/functions/utils/replaceAddressInCalldata.cjs +1 -0
  504. package/functions/utils/replaceAddressInCalldata.d.ts +1 -0
  505. package/functions/utils/replaceAddressInCalldata.mjs +7 -0
  506. package/functions/utils/rpc-int-encode.cjs +1 -0
  507. package/functions/utils/rpc-int-encode.d.ts +2 -0
  508. package/functions/utils/rpc-int-encode.mjs +8 -0
  509. package/functions/utils/serialize.utils.cjs +1 -1
  510. package/functions/utils/serialize.utils.d.ts +1 -0
  511. package/functions/utils/serialize.utils.mjs +3 -2
  512. package/functions/utils/string.utils.cjs +1 -1
  513. package/functions/utils/string.utils.d.ts +2 -0
  514. package/functions/utils/string.utils.mjs +28 -14
  515. package/functions/utils/time.utils.cjs +1 -1
  516. package/functions/utils/time.utils.d.ts +1 -0
  517. package/functions/utils/time.utils.mjs +4 -3
  518. package/functions/utils/token-check.utils.cjs +1 -0
  519. package/functions/utils/token-check.utils.d.ts +1 -0
  520. package/functions/utils/token-check.utils.mjs +10 -0
  521. package/functions/utils/upToDateState.cjs +1 -0
  522. package/functions/utils/upToDateState.d.ts +2 -0
  523. package/functions/utils/upToDateState.mjs +11 -0
  524. package/functions/utils/userAgent.cjs +1 -1
  525. package/functions/utils/userAgent.mjs +8 -8
  526. package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -0
  527. package/functions/web3/events/balanceChangedCustomHandler.d.ts +2 -0
  528. package/functions/web3/events/balanceChangedCustomHandler.mjs +14 -0
  529. package/functions/web3/events/balanceChangedHandler.cjs +1 -1
  530. package/functions/web3/events/balanceChangedHandler.mjs +5 -4
  531. package/functions/web3/events/getApprovedBalance.cjs +1 -0
  532. package/functions/web3/events/getApprovedBalance.d.ts +7 -0
  533. package/functions/web3/events/getApprovedBalance.mjs +80 -0
  534. package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
  535. package/functions/web3/events/getInputUtxoAndBalance.d.ts +16 -3
  536. package/functions/web3/events/getInputUtxoAndBalance.mjs +128 -46
  537. package/functions/web3/events/getShieldedBalance.cjs +2 -2
  538. package/functions/web3/events/getShieldedBalance.d.ts +1 -1
  539. package/functions/web3/events/getShieldedBalance.mjs +70 -65
  540. package/functions/web3/events/index.d.ts +2 -0
  541. package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
  542. package/functions/web3/functionCalls/accessTokenCalls.d.ts +2 -2
  543. package/functions/web3/functionCalls/accessTokenCalls.mjs +20 -18
  544. package/functions/web3/functionCalls/approveToken.cjs +1 -1
  545. package/functions/web3/functionCalls/approveToken.mjs +8 -7
  546. package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -0
  547. package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +4 -0
  548. package/functions/web3/functionCalls/approveTokensToHinkal.mjs +11 -0
  549. package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
  550. package/functions/web3/functionCalls/estimateGasRelayer.d.ts +2 -2
  551. package/functions/web3/functionCalls/estimateGasRelayer.mjs +14 -8
  552. package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -0
  553. package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +5 -0
  554. package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +32 -0
  555. package/functions/web3/functionCalls/relayFunctions.d.ts +1 -15
  556. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  557. package/functions/web3/functionCalls/transactCallDirect.d.ts +2 -2
  558. package/functions/web3/functionCalls/transactCallDirect.mjs +31 -30
  559. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  560. package/functions/web3/functionCalls/transactCallRelayer.d.ts +2 -2
  561. package/functions/web3/functionCalls/transactCallRelayer.mjs +32 -9
  562. package/functions/web3/getContractMetadata.cjs +1 -0
  563. package/functions/web3/getContractMetadata.d.ts +5 -0
  564. package/functions/web3/getContractMetadata.mjs +30 -0
  565. package/functions/web3/odosAPI.cjs +1 -1
  566. package/functions/web3/odosAPI.d.ts +1 -2
  567. package/functions/web3/odosAPI.mjs +23 -19
  568. package/functions/web3/oneInchAPI.cjs +1 -1
  569. package/functions/web3/oneInchAPI.d.ts +1 -2
  570. package/functions/web3/oneInchAPI.mjs +20 -15
  571. package/functions/web3/runContractFunction.cjs +1 -1
  572. package/functions/web3/runContractFunction.mjs +3 -2
  573. package/functions/web3/uniswapAPI.cjs +1 -1
  574. package/functions/web3/uniswapAPI.d.ts +4 -4
  575. package/functions/web3/uniswapAPI.mjs +57 -43
  576. package/index.cjs +1 -1
  577. package/index.mjs +761 -639
  578. package/package.json +19 -8
  579. package/providers/EthersProviderAdapter.cjs +1 -1
  580. package/providers/EthersProviderAdapter.d.ts +8 -3
  581. package/providers/EthersProviderAdapter.mjs +52 -43
  582. package/providers/WagmiProviderAdapter.cjs +1 -1
  583. package/providers/WagmiProviderAdapter.d.ts +4 -1
  584. package/providers/WagmiProviderAdapter.mjs +53 -56
  585. package/providers/prepareEthersHinkal.cjs +1 -1
  586. package/providers/prepareEthersHinkal.mjs +18 -10
  587. package/providers/prepareWagmiHinkal.cjs +1 -1
  588. package/providers/prepareWagmiHinkal.mjs +18 -10
  589. package/types/API.types.d.ts +21 -0
  590. package/types/ICacheDevice.d.ts +4 -3
  591. package/types/TransactionSimulator.types.d.ts +9 -0
  592. package/types/activities.types.cjs +1 -0
  593. package/types/activities.types.d.ts +45 -0
  594. package/types/activities.types.mjs +13 -0
  595. package/types/balances.types.cjs +1 -0
  596. package/types/balances.types.d.ts +17 -0
  597. package/types/balances.types.mjs +4 -0
  598. package/types/cache.types.cjs +1 -0
  599. package/types/cache.types.d.ts +27 -0
  600. package/types/cache.types.mjs +4 -0
  601. package/types/circom-data.types.d.ts +29 -9
  602. package/types/commitments.types.d.ts +6 -0
  603. package/types/contacts.types.d.ts +5 -0
  604. package/types/crypto.types.d.ts +1 -0
  605. package/types/earlyAccessCode.types.d.ts +4 -0
  606. package/types/ethereum-network.types.cjs +1 -1
  607. package/types/ethereum-network.types.d.ts +8 -3
  608. package/types/ethereum-network.types.mjs +1 -1
  609. package/types/external-action.types.cjs +1 -1
  610. package/types/external-action.types.d.ts +2 -1
  611. package/types/external-action.types.mjs +1 -1
  612. package/types/fee.types.d.ts +9 -0
  613. package/types/hinkal.types.cjs +1 -1
  614. package/types/hinkal.types.d.ts +48 -0
  615. package/types/hinkal.types.mjs +38 -13
  616. package/types/index.d.ts +9 -0
  617. package/types/kyc.types.cjs +1 -1
  618. package/types/kyc.types.d.ts +1 -1
  619. package/types/kyc.types.mjs +1 -1
  620. package/types/remote-proof.types.d.ts +15 -0
  621. package/types/rewards.types.d.ts +9 -0
  622. package/types/sandbox.types.cjs +1 -0
  623. package/types/sandbox.types.d.ts +157 -0
  624. package/types/sandbox.types.mjs +4 -0
  625. package/types/tenderly.api.types.d.ts +180 -0
  626. package/types/time.types.cjs +1 -1
  627. package/types/time.types.mjs +1 -1
  628. package/types/token-with-id.types.d.ts +4 -0
  629. package/types/token.types.d.ts +23 -0
  630. package/types/transactions.types.cjs +1 -1
  631. package/types/transactions.types.d.ts +31 -0
  632. package/types/transactions.types.mjs +8 -5
  633. package/types/wc.types.d.ts +89 -0
  634. package/types/with-id.types.d.ts +3 -0
  635. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  636. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  637. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  638. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +26 -26
  639. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  640. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  641. package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
  642. package/webworker/utxoWorker/utxoWorkerLogic.mjs +58 -50
  643. package/webworker/viteWorkerURL.constant.cjs +3 -3
  644. package/webworker/viteWorkerURL.constant.mjs +3 -3
  645. package/webworker/workerFactory.cjs +1 -1
  646. package/webworker/workerFactory.mjs +2 -2
  647. package/webworker/workerProxy.cjs +1 -1
  648. package/webworker/workerProxy.d.ts +11 -11
  649. package/webworker/workerProxy.mjs +24 -26
  650. package/webworker/zkProofWorker/zkProofWorker.types.d.ts +2 -0
  651. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  652. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
  653. package/webworker/zkProofWorker/zkProofWorkerLogic.cjs +1 -1
  654. package/webworker/zkProofWorker/zkProofWorkerLogic.mjs +47 -61
  655. package/functions/utils/memoize.utils.cjs +0 -1
  656. package/functions/utils/memoize.utils.mjs +0 -14
@@ -1,13 +1,16 @@
1
- import { zeroAddress as o } from "../../constants/protocol.constants.mjs";
2
- import { poseidonFunction as m } from "../../crypto/poseidon.mjs";
1
+ import { zeroAddress as m } from "../../constants/protocol.constants.mjs";
2
+ import { poseidonFunction as o } from "../../crypto/poseidon.mjs";
3
3
  import "circomlibjs-hinkal-fork";
4
4
  import "libsodium-wrappers";
5
5
  import "process";
6
6
  import "buffer";
7
- import { toBigInt as n } from "../../functions/utils/amounts.utils.mjs";
8
- import { MerkleTree as c } from "../merkle-tree/MerkleTree.mjs";
9
- import { AbstractSnapshotService as l } from "./AbstractSnapshotService.mjs";
10
- class I extends l {
7
+ import { toBigInt as t } from "../../functions/utils/amounts.utils.mjs";
8
+ import { MerkleTree as a } from "../merkle-tree/MerkleTree.mjs";
9
+ import "ethers";
10
+ import "../../error-handling/error-codes.constants.mjs";
11
+ import { AbstractSnapshotService as c } from "./AbstractSnapshotService.mjs";
12
+ import { contructMerkleTreeFromSerialized as l } from "../../functions/utils/merkleTree.utils.mjs";
13
+ class f extends c {
11
14
  constructor(e, s, r, d) {
12
15
  super(
13
16
  e,
@@ -46,25 +49,8 @@ class I extends l {
46
49
  }
47
50
  deserializeSnapshot(e) {
48
51
  let s, r;
49
- if (e.latestBlockNumber && e.merkleTree) {
50
- const d = new Map(
51
- Object.entries(e.merkleTree.tree).map(([t, a]) => [
52
- BigInt(t),
53
- BigInt(a)
54
- ])
55
- );
56
- s = c.createWithData(
57
- d,
58
- n(e.merkleTree.index),
59
- n(e.merkleTree.count),
60
- m,
61
- 25n,
62
- 0n
63
- );
64
- } else
65
- s = c.create(m, 25n, 0n);
66
- return e.latestBlockNumber && e.senderAddressIndexMap ? r = new Map(
67
- e.senderAddressIndexMap.map(({ address: d, index: t }) => [d, t])
52
+ return e.latestBlockNumber && e.merkleTree ? s = l(e.merkleTree) : s = a.create(o, 25n, 0n), e.latestBlockNumber && e.senderAddressIndexMap ? r = new Map(
53
+ e.senderAddressIndexMap.map(({ address: d, index: n }) => [d, n])
68
54
  ) : r = /* @__PURE__ */ new Map(), {
69
55
  latestBlockNumber: e.latestBlockNumber ?? 0,
70
56
  reserveBlockNumber: e.reserveBlockNumber ?? 0,
@@ -80,7 +66,7 @@ class I extends l {
80
66
  return this._merkleTree.insert(e.accessKey, e.index), this._senderAddressIndexMap.set(
81
67
  e.senderAddress,
82
68
  Math.max(Number(e.index), this._senderAddressIndexMap.get(e.senderAddress) ?? 0)
83
- ), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress === o && this._merkleTree.remove(e.index), !0;
69
+ ), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress === m && this._merkleTree.remove(e.index), !0;
84
70
  } catch (r) {
85
71
  return console.error(r), !1;
86
72
  }
@@ -88,8 +74,8 @@ class I extends l {
88
74
  mapEvent(e) {
89
75
  const { accessKey: s, index: r, senderAddress: d } = e;
90
76
  return {
91
- accessKey: n(s),
92
- index: n(r),
77
+ accessKey: t(s),
78
+ index: t(r),
93
79
  senderAddress: d
94
80
  };
95
81
  }
@@ -107,5 +93,5 @@ class I extends l {
107
93
  }
108
94
  }
109
95
  export {
110
- I as AbstractAccessTokenSnapshotService
96
+ f as AbstractAccessTokenSnapshotService
111
97
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./AbstractSnapshotService.cjs"),d=require("../../functions/utils/amounts.utils.cjs"),u=require("../../functions/utils/caseInsensitive.utils.cjs");class A extends c.AbstractSnapshotService{constructor(e,t,r,s){super(e,{name:"NewApprovedUtxo",args:["approveTo","tokenAddress","amount","inHinkalAddress"]},t,r,s)}_approvals=new Map;events=new Set;get approvals(){return this._approvals}getEventKey(e,t){return typeof e!="bigint"||typeof t!="string"?null:`${t}-${e}`}serializeSnapshot(e){const t=Object.fromEntries(e.payload.approvals),r=Object.entries(t).map(([p,l])=>{const i=l.map(n=>({amount:n.amount.toString(),tokenAddress:n.tokenAddress,inHinkalAddress:n.inHinkalAddress.toString()}));return[p,i]}),s=Object.fromEntries(r);return{latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,approvals:s,events:[...this.events]}}deserializeSnapshot(e){console.log({serializedSnapshot:e});const t=e.approvals,r=Object.entries(t).map(([p,l])=>{const i=l.map(n=>({amount:BigInt(n.amount),tokenAddress:n.tokenAddress,inHinkalAddress:BigInt(n.inHinkalAddress)}));return[p,i]}),s=new Map(r);return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{approvals:s,events:new Set(e.events)}}}getSnapshotPayload(){return{approvals:this._approvals,events:this.events}}populateSnapshot({payload:{approvals:e,events:t}}){this._approvals=e,this.events=t}mapEvent(e){const{approveTo:t,tokenAddress:r,amount:s,inHinkalAddress:p}=e;return{approveTo:t,tokenAddress:r,amount:d.toBigInt(s),inHinkalAddress:d.toBigInt(p)}}acceptEvent(e,t,r){const s=this.getEventKey(e.inHinkalAddress,r);if(s&&!this.events.has(s)){const{amount:p,tokenAddress:l,inHinkalAddress:i}=e,n={amount:p,tokenAddress:l,inHinkalAddress:i};let a=this.approvals.get(e.approveTo)||[],v=!1;for(let o=0;o<a.length;o+=1)u.caseInsensitiveEqual(l,a[o].tokenAddress)&&i===a[o].inHinkalAddress&&(a[o].amount+=p,v=!0);if(a=a.filter(o=>o.amount!==0n),v&&a.length===0)this.approvals.delete(e.approveTo);else{const o=v?a:[...a,n];this.approvals.set(e.approveTo,o)}return r&&this.events.add(s),!0}return!1}}exports.AbstractApprovalsSnapshotService=A;
@@ -0,0 +1,30 @@
1
+ import { ethers } from 'ethers';
2
+ import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
3
+ import { NewApprovedUtxoEvent } from '../../types/commitments.types';
4
+ import { ApprovedUtxo } from '../../types/hinkal.types';
5
+ export type ApprovalsSnapshotPayload = {
6
+ readonly approvals: Map<string, ApprovedUtxo[]>;
7
+ readonly events: Set<string>;
8
+ };
9
+ export type ApprovalsSerializedSnapshot = {
10
+ latestBlockNumber?: number;
11
+ reserveBlockNumber?: number;
12
+ approvals: Record<string, ApprovedUtxo<string>[]>;
13
+ events: string[];
14
+ };
15
+ export declare abstract class AbstractApprovalsSnapshotService extends AbstractSnapshotService<NewApprovedUtxoEvent, NewApprovedUtxoEvent<string>, ApprovalsSnapshotPayload, ApprovalsSerializedSnapshot> {
16
+ constructor(contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, maxPageSize?: number);
17
+ private _approvals;
18
+ events: Set<string>;
19
+ get approvals(): Map<string, ApprovedUtxo[]>;
20
+ private getEventKey;
21
+ protected serializeSnapshot(snapshot: Snapshot<ApprovalsSnapshotPayload>): ApprovalsSerializedSnapshot;
22
+ protected deserializeSnapshot(serializedSnapshot: ApprovalsSerializedSnapshot): Snapshot<ApprovalsSnapshotPayload>;
23
+ protected getSnapshotPayload(): {
24
+ approvals: Map<string, ApprovedUtxo[]>;
25
+ events: Set<string>;
26
+ };
27
+ protected populateSnapshot({ payload: { approvals, events } }: Snapshot<ApprovalsSnapshotPayload>): void;
28
+ protected mapEvent(event: NewApprovedUtxoEvent<string>): NewApprovedUtxoEvent;
29
+ protected acceptEvent(event: NewApprovedUtxoEvent, _blockNumber: number, txHash: string): boolean;
30
+ }
@@ -0,0 +1,104 @@
1
+ import { AbstractSnapshotService as c } from "./AbstractSnapshotService.mjs";
2
+ import { toBigInt as v } from "../../functions/utils/amounts.utils.mjs";
3
+ import { caseInsensitiveEqual as u } from "../../functions/utils/caseInsensitive.utils.mjs";
4
+ class f extends c {
5
+ constructor(e, t, r, s) {
6
+ super(
7
+ e,
8
+ {
9
+ name: "NewApprovedUtxo",
10
+ args: ["approveTo", "tokenAddress", "amount", "inHinkalAddress"]
11
+ },
12
+ t,
13
+ r,
14
+ s
15
+ );
16
+ }
17
+ _approvals = /* @__PURE__ */ new Map();
18
+ events = /* @__PURE__ */ new Set();
19
+ get approvals() {
20
+ return this._approvals;
21
+ }
22
+ getEventKey(e, t) {
23
+ return typeof e != "bigint" || typeof t != "string" ? null : `${t}-${e}`;
24
+ }
25
+ serializeSnapshot(e) {
26
+ const t = Object.fromEntries(e.payload.approvals), r = Object.entries(t).map(([p, l]) => {
27
+ const i = l.map((n) => ({
28
+ amount: n.amount.toString(),
29
+ tokenAddress: n.tokenAddress,
30
+ inHinkalAddress: n.inHinkalAddress.toString()
31
+ }));
32
+ return [p, i];
33
+ }), s = Object.fromEntries(r);
34
+ return {
35
+ latestBlockNumber: e.latestBlockNumber,
36
+ reserveBlockNumber: e.reserveBlockNumber,
37
+ approvals: s,
38
+ events: [...this.events]
39
+ };
40
+ }
41
+ deserializeSnapshot(e) {
42
+ console.log({ serializedSnapshot: e });
43
+ const t = e.approvals, r = Object.entries(t).map(
44
+ ([p, l]) => {
45
+ const i = l.map((n) => ({
46
+ amount: BigInt(n.amount),
47
+ tokenAddress: n.tokenAddress,
48
+ inHinkalAddress: BigInt(n.inHinkalAddress)
49
+ }));
50
+ return [p, i];
51
+ }
52
+ ), s = new Map(r);
53
+ return {
54
+ latestBlockNumber: e.latestBlockNumber ?? 0,
55
+ reserveBlockNumber: e.reserveBlockNumber ?? 0,
56
+ payload: {
57
+ approvals: s,
58
+ events: new Set(e.events)
59
+ }
60
+ };
61
+ }
62
+ getSnapshotPayload() {
63
+ return {
64
+ approvals: this._approvals,
65
+ events: this.events
66
+ };
67
+ }
68
+ populateSnapshot({ payload: { approvals: e, events: t } }) {
69
+ this._approvals = e, this.events = t;
70
+ }
71
+ mapEvent(e) {
72
+ const { approveTo: t, tokenAddress: r, amount: s, inHinkalAddress: p } = e;
73
+ return {
74
+ approveTo: t,
75
+ tokenAddress: r,
76
+ amount: v(s),
77
+ inHinkalAddress: v(p)
78
+ };
79
+ }
80
+ acceptEvent(e, t, r) {
81
+ const s = this.getEventKey(e.inHinkalAddress, r);
82
+ if (s && !this.events.has(s)) {
83
+ const { amount: p, tokenAddress: l, inHinkalAddress: i } = e, n = {
84
+ amount: p,
85
+ tokenAddress: l,
86
+ inHinkalAddress: i
87
+ };
88
+ let o = this.approvals.get(e.approveTo) || [], d = !1;
89
+ for (let a = 0; a < o.length; a += 1)
90
+ u(l, o[a].tokenAddress) && i === o[a].inHinkalAddress && (o[a].amount += p, d = !0);
91
+ if (o = o.filter((a) => a.amount !== 0n), d && o.length === 0)
92
+ this.approvals.delete(e.approveTo);
93
+ else {
94
+ const a = d ? o : [...o, n];
95
+ this.approvals.set(e.approveTo, a);
96
+ }
97
+ return r && this.events.add(s), !0;
98
+ }
99
+ return !1;
100
+ }
101
+ }
102
+ export {
103
+ f as AbstractApprovalsSnapshotService
104
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const i=require("../merkle-tree/MerkleTree.cjs"),n=require("../../functions/utils/amounts.utils.cjs"),m=require("./AbstractSnapshotService.cjs");class p extends m.AbstractSnapshotService{constructor(e,t,u,r){super(e,{name:"NewCommitment",args:["commitment","index","encryptedOutput"]},t,u,r)}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive)}))}}deserializeSnapshot(e){let t;if(e.latestBlockNumber&&e.merkleTree){const r=new Map(Object.entries(e.merkleTree.tree).map(([c,o])=>[BigInt(c),BigInt(o)]));t=i.MerkleTree.createWithData(r,n.toBigInt(e.merkleTree.index),n.toBigInt(e.merkleTree.count),s.poseidonFunction,25n,0n)}else t=i.MerkleTree.create(s.poseidonFunction,25n,0n);const u=e.encryptedOutputs?.map(r=>({value:r.value,isPositive:JSON.parse(r.isPositive)}));return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:u||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:u,encryptedOutput:r}=e;return{commitment:n.toBigInt(t),index:n.toBigInt(u),encryptedOutput:r}}acceptEvent(e,t){if(!this.encryptedOutputs.map(u=>u.value).includes(e.encryptedOutput)){if(!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return!1;const r={value:e.encryptedOutput,isPositive:e.index>=0n};return this._encryptedOutputs.push(r),!0}return!1}}exports.AbstractCommitmentsSnapshotService=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const n=require("../merkle-tree/MerkleTree.cjs");require("ethers");require("../../error-handling/error-codes.constants.cjs");const s=require("../../functions/utils/amounts.utils.cjs"),c=require("./AbstractSnapshotService.cjs"),l=require("../../functions/utils/merkleTree.utils.cjs");class m extends c.AbstractSnapshotService{constructor(e,t,r,u){super(e,{name:"NewCommitment",args:["commitment","index","encryptedOutput"]},t,r,u)}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive)}))}}deserializeSnapshot(e){let t;e.latestBlockNumber&&e.merkleTree?t=l.contructMerkleTreeFromSerialized(e.merkleTree):t=n.MerkleTree.create(i.poseidonFunction,25n,0n);const r=e.encryptedOutputs?.map(u=>({value:u.value,isPositive:JSON.parse(u.isPositive)}));return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:r||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:r,encryptedOutput:u}=e;return{commitment:s.toBigInt(t),index:s.toBigInt(r),encryptedOutput:u}}acceptEvent(e,t){if(!this.encryptedOutputs.map(r=>r.value).includes(e.encryptedOutput)){if(!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return!1;const u={value:e.encryptedOutput,isPositive:e.index>=0n};return this._encryptedOutputs.push(u),!0}return!1}}exports.AbstractCommitmentsSnapshotService=m;
@@ -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 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,n){this.contract=e,this.eventConfig=t,this._latestBlockNumber=s,this.maxPageSize=n,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: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{return this.inProgress=!1,!1}}async processEventsPage(e){const t=[];return await o.resolveSync(e.map(s=>async()=>{const{args:r,blockNumber:n}=s;if(!r)throw new Error("Wrong event structure");const i=this.mapEvent(r);await this.acceptEvent(i,n)&&t.push(i)})),t}handleEvent=async(...e)=>{const{args:t}=this.eventConfig,{blockNumber:s}=e[e.length-1],r=e.slice(0,t.length),n=t.reduce((a,l,h)=>(a[l]=r[h],a),{});if(!s)throw new Error("Wrong event structure");const i=this.mapEvent(n);if(!await this.acceptEvent(i,s))throw new Error("Failed to retrieve events");this._latestBlockNumber=s,await this.afterEventsAccepted(),this.emitNewEvent(i)}}exports.AbstractEventService=u;
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
  }
@@ -11,8 +11,8 @@ class g {
11
11
  intervalId;
12
12
  inProgress;
13
13
  // to remove race conditions
14
- constructor(e, t, s, r, n) {
15
- this.contract = e, this.eventConfig = t, this._latestBlockNumber = s, this.maxPageSize = n, this.isServer = r, 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;
16
16
  }
17
17
  get latestBlockNumber() {
18
18
  return this._latestBlockNumber;
@@ -54,14 +54,14 @@ class g {
54
54
  return this.inProgress = !1, !1;
55
55
  const r = u(e, s, this.maxPageSize);
56
56
  return await o(
57
- r.map(({ from: n, to: i }) => async () => {
58
- const c = await this.contract.queryFilter(
57
+ r.map(({ from: i, to: n }) => async () => {
58
+ const a = await this.contract.queryFilter(
59
59
  this.contract.filters[this.eventConfig.name](),
60
- n,
61
- i
60
+ i,
61
+ n
62
62
  );
63
- let a = [];
64
- c.length > 0 && (a = await this.processEventsPage(c)), 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();
65
65
  })
66
66
  ), this.inProgress = !1, !0;
67
67
  } catch {
@@ -72,22 +72,22 @@ class g {
72
72
  const t = [];
73
73
  return await o(
74
74
  e.map((s) => async () => {
75
- const { args: r, blockNumber: n } = s;
75
+ const { args: r, blockNumber: i, transactionHash: n } = s;
76
76
  if (!r)
77
77
  throw new Error("Wrong event structure");
78
- const i = this.mapEvent(r);
79
- await this.acceptEvent(i, n) && t.push(i);
78
+ const a = this.mapEvent(r);
79
+ await this.acceptEvent(a, i, n) && t.push(a);
80
80
  })
81
81
  ), t;
82
82
  }
83
83
  handleEvent = async (...e) => {
84
- const { args: t } = this.eventConfig, { blockNumber: s } = e[e.length - 1], r = e.slice(0, t.length), n = t.reduce((a, h, l) => (a[h] = r[l], a), {});
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
85
  if (!s)
86
86
  throw new Error("Wrong event structure");
87
- const i = this.mapEvent(n);
88
- if (!await this.acceptEvent(i, s))
87
+ const n = this.mapEvent(i);
88
+ if (!await this.acceptEvent(n, s))
89
89
  throw new Error("Failed to retrieve events");
90
- this._latestBlockNumber = s, await this.afterEventsAccepted(), this.emitNewEvent(i);
90
+ this._latestBlockNumber = s, await this.afterEventsAccepted(), this.emitNewEvent(n);
91
91
  };
92
92
  }
93
93
  export {
@@ -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,r,n,i,s){this.hashFunction=t,this.levels=e,this.defaultNodeValue=r,this.tree=n??new Map,this.count=s??0n,this.index=i??2n**(e-1n)}tree;count;index;static createWithData(t,e,r,n,i,s){return new h(n,i,s,t,e,r)}static create(t,e,r){return new h(t,e,r)}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 r=this.index-this.getStartIndex(),n=this.logarithm2(r);let i=e;for(let s=1n;s<=n;s+=1n){i/=2n;const l=this.hashFunction(this.tree.get(i*2n)||this.defaultNodeValue,this.tree.get(i*2n+1n)||this.defaultNodeValue);this.tree.set(i,l)}}insert(t,e){let r=!1;return this.tree.has(e)&&(r=!0,o.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;for(let n=this.getStartIndex();n<this.getStartIndex()+this.index;n+=1n)if(this.tree.get(n)===t){e=n;break}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;for(let n=this.getStartIndex();n<this.getStartIndex()+this.index;n+=1n)if(this.tree.get(n)===t){e=n;break}if(e===void 0)return new Array(Number(this.levels)).fill(0n);const r=[];for(;e!==0n;){const n=e%2n===0n?0n:1n;r.push(n),e/=2n}return r}toJSON(){const{tree:t,count:e,index:r}=this;return{tree:Object.fromEntries(t),count:e.toString(),index:r.toString()}}}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
@@ -73,4 +76,6 @@ export declare class MerkleTree<T> {
73
76
  */
74
77
  getSiblingSides(item: T): bigint[];
75
78
  toJSON(): MerkleTreeJson;
79
+ clone(): MerkleTree<T>;
80
+ getIndex(): bigint;
76
81
  }