@hinkal/common 0.2.26 → 0.2.28

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 (846) hide show
  1. package/API/API.cjs +1 -1
  2. package/API/API.d.ts +35 -17
  3. package/API/API.mjs +100 -80
  4. package/API/admin-calls.cjs +1 -1
  5. package/API/admin-calls.d.ts +8 -1
  6. package/API/admin-calls.mjs +6 -5
  7. package/API/callLifiAPI.cjs +1 -1
  8. package/API/callLifiAPI.d.ts +1 -1
  9. package/API/callLifiAPI.mjs +5 -5
  10. package/API/callMonitor.cjs +1 -1
  11. package/API/callMonitor.d.ts +1 -1
  12. package/API/callMonitor.mjs +7 -7
  13. package/API/callOdosAPI.cjs +1 -1
  14. package/API/callOdosAPI.mjs +11 -11
  15. package/API/callOkxAPI.cjs +1 -1
  16. package/API/callOkxAPI.d.ts +1 -1
  17. package/API/callOkxAPI.mjs +5 -5
  18. package/API/callOneInchAPI.cjs +1 -1
  19. package/API/callOneInchAPI.mjs +10 -11
  20. package/API/callRelayer.cjs +1 -1
  21. package/API/callRelayer.d.ts +14 -6
  22. package/API/callRelayer.mjs +11 -11
  23. package/API/checkRisk.cjs +1 -1
  24. package/API/checkRisk.d.ts +1 -1
  25. package/API/checkRisk.mjs +4 -4
  26. package/API/deposit-and-withdraw-status-calls.cjs +1 -1
  27. package/API/deposit-and-withdraw-status-calls.d.ts +3 -2
  28. package/API/deposit-and-withdraw-status-calls.mjs +8 -8
  29. package/API/enclaveSignatureCalls.cjs +1 -0
  30. package/API/enclaveSignatureCalls.d.ts +10 -0
  31. package/API/enclaveSignatureCalls.mjs +16 -0
  32. package/API/enclaveUtxoCalls.cjs +1 -0
  33. package/API/enclaveUtxoCalls.d.ts +40 -0
  34. package/API/enclaveUtxoCalls.mjs +24 -0
  35. package/API/fetchCommitmentsCache.cjs +1 -1
  36. package/API/fetchCommitmentsCache.d.ts +2 -1
  37. package/API/fetchCommitmentsCache.mjs +9 -9
  38. package/API/get-token-data.cjs +1 -1
  39. package/API/get-token-data.d.ts +1 -1
  40. package/API/get-token-data.mjs +5 -5
  41. package/API/get-token-price-chart-data.cjs +1 -0
  42. package/API/get-token-price-chart-data.d.ts +16 -0
  43. package/API/get-token-price-chart-data.mjs +13 -0
  44. package/API/getCoingeckoPrice.cjs +1 -1
  45. package/API/getCoingeckoPrice.d.ts +0 -1
  46. package/API/getCoingeckoPrice.mjs +15 -16
  47. package/API/getGasEstimates.cjs +1 -1
  48. package/API/getGasEstimates.mjs +9 -9
  49. package/API/getServerURL.cjs +1 -1
  50. package/API/getServerURL.d.ts +3 -3
  51. package/API/getServerURL.mjs +51 -67
  52. package/API/getTokenPrice.cjs +1 -1
  53. package/API/getTokenPrice.d.ts +5 -0
  54. package/API/getTokenPrice.mjs +14 -7
  55. package/API/getWebsiteURL.cjs +1 -1
  56. package/API/getWebsiteURL.d.ts +1 -0
  57. package/API/getWebsiteURL.mjs +25 -10
  58. package/API/index.d.ts +3 -3
  59. package/API/kycCalls.cjs +1 -1
  60. package/API/kycCalls.d.ts +4 -8
  61. package/API/kycCalls.mjs +23 -26
  62. package/API/onrampCalls.cjs +1 -0
  63. package/API/onrampCalls.d.ts +20 -0
  64. package/API/onrampCalls.mjs +15 -0
  65. package/API/privacy-score-calls.cjs +1 -0
  66. package/API/privacy-score-calls.d.ts +17 -0
  67. package/API/privacy-score-calls.mjs +29 -0
  68. package/API/privateSendEmailNotificationsCalls.cjs +1 -0
  69. package/API/privateSendEmailNotificationsCalls.d.ts +8 -0
  70. package/API/privateSendEmailNotificationsCalls.mjs +11 -0
  71. package/API/privateSendNonceCalls.cjs +1 -0
  72. package/API/privateSendNonceCalls.d.ts +13 -0
  73. package/API/privateSendNonceCalls.mjs +15 -0
  74. package/API/privateSendRecipientInfoCalls.cjs +1 -0
  75. package/API/privateSendRecipientInfoCalls.d.ts +21 -0
  76. package/API/privateSendRecipientInfoCalls.mjs +15 -0
  77. package/API/proxyAccountsCalls.cjs +1 -1
  78. package/API/proxyAccountsCalls.d.ts +4 -2
  79. package/API/proxyAccountsCalls.mjs +18 -20
  80. package/API/relayCalls.cjs +1 -1
  81. package/API/relayCalls.mjs +4 -4
  82. package/API/rewardsUserCalls.cjs +1 -1
  83. package/API/rewardsUserCalls.d.ts +9 -0
  84. package/API/rewardsUserCalls.mjs +28 -22
  85. package/API/scheduled-transactions-calls.cjs +1 -1
  86. package/API/scheduled-transactions-calls.d.ts +2 -2
  87. package/API/scheduled-transactions-calls.mjs +9 -8
  88. package/API/simulate-batch-tx.cjs +1 -1
  89. package/API/simulate-batch-tx.d.ts +2 -2
  90. package/API/simulate-batch-tx.mjs +7 -6
  91. package/API/simulate-transaction.cjs +1 -0
  92. package/API/{is-tx-stateless.d.ts → simulate-transaction.d.ts} +1 -1
  93. package/API/simulate-transaction.mjs +18 -0
  94. package/API/snapshot-event-calls.cjs +1 -0
  95. package/API/snapshot-event-calls.d.ts +7 -0
  96. package/API/snapshot-event-calls.mjs +13 -0
  97. package/API/solana-calls.cjs +1 -1
  98. package/API/solana-calls.d.ts +8 -4
  99. package/API/solana-calls.mjs +15 -15
  100. package/API/temporaryWalletCalls.cjs +1 -1
  101. package/API/temporaryWalletCalls.mjs +13 -19
  102. package/API/token-calls.cjs +1 -1
  103. package/API/token-calls.mjs +6 -5
  104. package/API/tronSubsidyCalls.cjs +1 -0
  105. package/API/tronSubsidyCalls.d.ts +13 -0
  106. package/API/tronSubsidyCalls.mjs +11 -0
  107. package/README.md +20 -13
  108. package/constants/activity.constants.cjs +1 -1
  109. package/constants/activity.constants.mjs +4 -2
  110. package/constants/addresses.constants.cjs +1 -1
  111. package/constants/addresses.constants.mjs +1 -1
  112. package/constants/bridging.constants.cjs +1 -1
  113. package/constants/bridging.constants.d.ts +4 -0
  114. package/constants/bridging.constants.mjs +6 -2
  115. package/constants/chains.constants.cjs +1 -1
  116. package/constants/chains.constants.d.ts +6 -6
  117. package/constants/chains.constants.mjs +112 -69
  118. package/constants/coingecko.constants.cjs +1 -1
  119. package/constants/coingecko.constants.d.ts +2 -1
  120. package/constants/coingecko.constants.mjs +49 -38
  121. package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
  122. package/constants/deploy-data/deploy-data-solana.json.mjs +390 -9
  123. package/constants/deploy-data/deploy-data-tronMainnet.json.cjs +1 -0
  124. package/constants/deploy-data/deploy-data-tronMainnet.json.mjs +4638 -0
  125. package/constants/deploy-data/deploy-data-tronNile.json.cjs +1 -0
  126. package/constants/deploy-data/deploy-data-tronNile.json.mjs +4638 -0
  127. package/constants/deploy-data/index.d.ts +3 -1
  128. package/constants/fees.constants.cjs +1 -1
  129. package/constants/fees.constants.d.ts +4 -1
  130. package/constants/fees.constants.mjs +8 -4
  131. package/constants/function-signatures.constants.cjs +1 -1
  132. package/constants/function-signatures.constants.d.ts +0 -1
  133. package/constants/function-signatures.constants.mjs +3 -4
  134. package/constants/images.constants.cjs +1 -0
  135. package/constants/images.constants.d.ts +1 -0
  136. package/constants/images.constants.mjs +4 -0
  137. package/constants/index.d.ts +6 -0
  138. package/constants/kyc.constants.cjs +1 -1
  139. package/constants/kyc.constants.mjs +39 -40
  140. package/constants/mediaUrls.constants.cjs +1 -1
  141. package/constants/mediaUrls.constants.d.ts +5 -1
  142. package/constants/mediaUrls.constants.mjs +6 -2
  143. package/constants/non-circular-tokens.constants.cjs +1 -0
  144. package/constants/non-circular-tokens.constants.d.ts +1 -0
  145. package/constants/non-circular-tokens.constants.mjs +4 -0
  146. package/constants/pay.constants.cjs +1 -0
  147. package/constants/pay.constants.d.ts +1 -0
  148. package/constants/pay.constants.mjs +4 -0
  149. package/constants/permit2.constants.cjs +1 -1
  150. package/constants/permit2.constants.d.ts +0 -1
  151. package/constants/permit2.constants.mjs +10 -11
  152. package/constants/protocol.constants.cjs +1 -1
  153. package/constants/protocol.constants.d.ts +6 -1
  154. package/constants/protocol.constants.mjs +38 -33
  155. package/constants/reorg-depths.constants.cjs +1 -1
  156. package/constants/reorg-depths.constants.mjs +3 -0
  157. package/constants/save-depths.cjs +1 -1
  158. package/constants/save-depths.mjs +6 -3
  159. package/constants/schedule.constants.cjs +1 -0
  160. package/constants/schedule.constants.d.ts +2 -0
  161. package/constants/schedule.constants.mjs +14 -0
  162. package/constants/server.constants.cjs +1 -1
  163. package/constants/server.constants.d.ts +31 -123
  164. package/constants/server.constants.mjs +65 -156
  165. package/constants/tasks.constants.cjs +1 -1
  166. package/constants/tasks.constants.mjs +5 -4
  167. package/constants/token-data/ERC20Registry.cjs +1 -1
  168. package/constants/token-data/ERC20Registry.mjs +48 -34
  169. package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
  170. package/constants/token-data/arbMainnetRegistry.json.mjs +1 -1
  171. package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
  172. package/constants/token-data/arbMainnetRegistryFixed.json.mjs +1 -1
  173. package/constants/token-data/arcTestnetRegistry.json.cjs +1 -1
  174. package/constants/token-data/arcTestnetRegistry.json.mjs +2 -2
  175. package/constants/token-data/avalancheRegistry.json.cjs +1 -1
  176. package/constants/token-data/avalancheRegistry.json.mjs +1 -1
  177. package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
  178. package/constants/token-data/avalancheRegistryFixed.json.mjs +1 -1
  179. package/constants/token-data/baseRegistry.json.cjs +1 -1
  180. package/constants/token-data/baseRegistry.json.mjs +3 -3
  181. package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
  182. package/constants/token-data/baseRegistryFixed.json.mjs +1 -1
  183. package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
  184. package/constants/token-data/bnbMainnetRegistry.json.mjs +2 -2
  185. package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
  186. package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +2 -2
  187. package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
  188. package/constants/token-data/ethMainnetRegistry.json.mjs +1 -1
  189. package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
  190. package/constants/token-data/ethMainnetRegistryFixed.json.mjs +1 -1
  191. package/constants/token-data/index.d.ts +2 -2
  192. package/constants/token-data/solanaMainnetRegistry.json.cjs +1 -1
  193. package/constants/token-data/solanaMainnetRegistry.json.mjs +143 -74
  194. package/constants/token-data/tronMainnetRegistry.json.cjs +1 -0
  195. package/constants/token-data/tronMainnetRegistry.json.mjs +24 -0
  196. package/constants/token-data/tronNileRegistry.json.cjs +1 -0
  197. package/constants/token-data/tronNileRegistry.json.mjs +24 -0
  198. package/constants/tokens.constants.cjs +1 -0
  199. package/constants/tokens.constants.d.ts +3 -0
  200. package/constants/tokens.constants.mjs +15 -0
  201. package/constants/tx-confirmation.constants.cjs +1 -0
  202. package/constants/tx-confirmation.constants.d.ts +4 -0
  203. package/constants/tx-confirmation.constants.mjs +7 -0
  204. package/constants/wallet.constants.cjs +1 -1
  205. package/constants/wallet.constants.d.ts +1 -7
  206. package/constants/wallet.constants.mjs +18 -8
  207. package/crypto/poseidon.cjs +1 -1
  208. package/crypto/poseidon.mjs +5 -5
  209. package/data-structures/AccountActions/AccountActions.cjs +1 -0
  210. package/data-structures/AccountActions/AccountActions.d.ts +17 -0
  211. package/data-structures/AccountActions/AccountActions.mjs +67 -0
  212. package/data-structures/AccountActions/index.d.ts +1 -0
  213. package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
  214. package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +106 -109
  215. package/data-structures/BlockchainEvent/BlockchainEvent.cjs +1 -0
  216. package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +14 -0
  217. package/data-structures/BlockchainEvent/BlockchainEvent.mjs +45 -0
  218. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  219. package/data-structures/Hinkal/Hinkal.d.ts +66 -74
  220. package/data-structures/Hinkal/Hinkal.mjs +366 -392
  221. package/data-structures/Hinkal/IHinkal.d.ts +61 -71
  222. package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
  223. package/data-structures/Hinkal/handleAutoDepositBack.d.ts +2 -4
  224. package/data-structures/Hinkal/handleAutoDepositBack.mjs +146 -79
  225. package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
  226. package/data-structures/Hinkal/hinkalActionReceive.d.ts +1 -2
  227. package/data-structures/Hinkal/hinkalActionReceive.mjs +26 -22
  228. package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
  229. package/data-structures/Hinkal/hinkalCheckTokenRegistry.d.ts +1 -0
  230. package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +34 -22
  231. package/data-structures/Hinkal/hinkalClaimUtxo.cjs +1 -0
  232. package/data-structures/Hinkal/hinkalClaimUtxo.d.ts +6 -0
  233. package/data-structures/Hinkal/hinkalClaimUtxo.mjs +119 -0
  234. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  235. package/data-structures/Hinkal/hinkalDeposit.d.ts +2 -2
  236. package/data-structures/Hinkal/hinkalDeposit.mjs +101 -92
  237. package/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -0
  238. package/data-structures/Hinkal/{hinkalDepostAndBridge.d.ts → hinkalDepositAndBridge.d.ts} +2 -2
  239. package/data-structures/Hinkal/hinkalDepositAndBridge.mjs +259 -0
  240. package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
  241. package/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +2 -2
  242. package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +159 -102
  243. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
  244. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +1 -1
  245. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +131 -92
  246. package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
  247. package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +4 -5
  248. package/data-structures/Hinkal/hinkalMultiSend.cjs +1 -1
  249. package/data-structures/Hinkal/hinkalMultiSend.d.ts +1 -1
  250. package/data-structures/Hinkal/hinkalMultiSend.mjs +4 -4
  251. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  252. package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
  253. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +121 -125
  254. package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
  255. package/data-structures/Hinkal/hinkalProoflessDeposit.d.ts +2 -1
  256. package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +188 -38
  257. package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
  258. package/data-structures/Hinkal/hinkalProxySwap.d.ts +1 -2
  259. package/data-structures/Hinkal/hinkalProxySwap.mjs +34 -31
  260. package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
  261. package/data-structures/Hinkal/hinkalProxyToPrivate.d.ts +1 -1
  262. package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +32 -28
  263. package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
  264. package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +1 -2
  265. package/data-structures/Hinkal/hinkalSignSubAccount.mjs +17 -15
  266. package/data-structures/Hinkal/hinkalSolanaClaimUtxo.cjs +1 -0
  267. package/data-structures/Hinkal/hinkalSolanaClaimUtxo.d.ts +5 -0
  268. package/data-structures/Hinkal/hinkalSolanaClaimUtxo.mjs +130 -0
  269. package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
  270. package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +6 -3
  271. package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +98 -110
  272. package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
  273. package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +3 -1
  274. package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +228 -197
  275. package/data-structures/Hinkal/hinkalSolanaProoflessDeposit.cjs +1 -0
  276. package/data-structures/Hinkal/hinkalSolanaProoflessDeposit.d.ts +5 -0
  277. package/data-structures/Hinkal/hinkalSolanaProoflessDeposit.mjs +28 -0
  278. package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
  279. package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +4 -4
  280. package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +44 -43
  281. package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
  282. package/data-structures/Hinkal/hinkalSolanaProxyShield.d.ts +2 -2
  283. package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +73 -71
  284. package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
  285. package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +3 -3
  286. package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +79 -64
  287. package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
  288. package/data-structures/Hinkal/hinkalSolanaSwap.d.ts +1 -1
  289. package/data-structures/Hinkal/hinkalSolanaSwap.mjs +122 -100
  290. package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
  291. package/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +29 -2
  292. package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +132 -70
  293. package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
  294. package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +3 -2
  295. package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +113 -75
  296. package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
  297. package/data-structures/Hinkal/hinkalSwap.d.ts +1 -1
  298. package/data-structures/Hinkal/hinkalSwap.mjs +71 -103
  299. package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
  300. package/data-structures/Hinkal/hinkalTransfer.d.ts +1 -1
  301. package/data-structures/Hinkal/hinkalTransfer.mjs +96 -96
  302. package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
  303. package/data-structures/Hinkal/hinkalWithdraw.d.ts +2 -1
  304. package/data-structures/Hinkal/hinkalWithdraw.mjs +97 -99
  305. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
  306. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.d.ts +1 -2
  307. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +204 -113
  308. package/data-structures/Hinkal/index.d.ts +4 -0
  309. package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
  310. package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
  311. package/data-structures/Hinkal/resetMerkleTrees.mjs +109 -54
  312. package/data-structures/IndexedDB/activity-db.cjs +1 -1
  313. package/data-structures/IndexedDB/activity-db.d.ts +4 -5
  314. package/data-structures/IndexedDB/activity-db.mjs +124 -131
  315. package/data-structures/IndexedDB/balances-db.cjs +1 -1
  316. package/data-structures/IndexedDB/balances-db.mjs +45 -38
  317. package/data-structures/IndexedDB/contact-db.cjs +1 -1
  318. package/data-structures/IndexedDB/contact-db.mjs +43 -36
  319. package/data-structures/IndexedDB/index.d.ts +1 -0
  320. package/data-structures/IndexedDB/pay-activity-db.cjs +1 -0
  321. package/data-structures/IndexedDB/pay-activity-db.d.ts +9 -0
  322. package/data-structures/IndexedDB/pay-activity-db.mjs +26 -0
  323. package/data-structures/IndexedDB/prices-db.cjs +1 -1
  324. package/data-structures/IndexedDB/prices-db.mjs +1 -1
  325. package/data-structures/IndexedDB/signatures-db.cjs +1 -1
  326. package/data-structures/IndexedDB/signatures-db.mjs +26 -40
  327. package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
  328. package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +82 -79
  329. package/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
  330. package/data-structures/TokenDBs/token-visibility-db.mjs +22 -36
  331. package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
  332. package/data-structures/crypto-keys/decodeUTXO.mjs +1 -1
  333. package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
  334. package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +29 -30
  335. package/data-structures/crypto-keys/keys.cjs +1 -1
  336. package/data-structures/crypto-keys/keys.d.ts +9 -11
  337. package/data-structures/crypto-keys/keys.mjs +65 -110
  338. package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
  339. package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +3 -2
  340. package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
  341. package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
  342. package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +3 -2
  343. package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
  344. package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
  345. package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +9 -4
  346. package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +65 -48
  347. package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
  348. package/data-structures/event-service/evm/AbstractEventService.d.ts +4 -2
  349. package/data-structures/event-service/evm/AbstractEventService.mjs +13 -13
  350. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
  351. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +3 -2
  352. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +5 -5
  353. package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
  354. package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +2 -2
  355. package/data-structures/event-service/evm/AbstractSnapshotService.mjs +5 -6
  356. package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
  357. package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +18 -7
  358. package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +75 -49
  359. package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +1 -0
  360. package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +11 -0
  361. package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +25 -0
  362. package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +1 -0
  363. package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +6 -0
  364. package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +16 -0
  365. package/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -0
  366. package/data-structures/event-service/helpers/ClientEventHelper.d.ts +10 -0
  367. package/data-structures/event-service/helpers/ClientEventHelper.mjs +38 -0
  368. package/data-structures/event-service/helpers/PollingEventHelper.cjs +1 -0
  369. package/data-structures/event-service/helpers/PollingEventHelper.d.ts +5 -0
  370. package/data-structures/event-service/helpers/PollingEventHelper.mjs +14 -0
  371. package/data-structures/event-service/index.d.ts +4 -0
  372. package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
  373. package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +3 -2
  374. package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
  375. package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
  376. package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +9 -4
  377. package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +65 -48
  378. package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
  379. package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +5 -10
  380. package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +13 -7
  381. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
  382. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +3 -2
  383. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +4 -4
  384. package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -1
  385. package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +1 -2
  386. package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +1 -2
  387. package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +1 -0
  388. package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +11 -0
  389. package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +26 -0
  390. package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +1 -0
  391. package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +6 -0
  392. package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +16 -0
  393. package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
  394. package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +20 -19
  395. package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +126 -76
  396. package/data-structures/index.d.ts +2 -0
  397. package/data-structures/merkle-tree/MerkleTree.cjs +1 -1
  398. package/data-structures/merkle-tree/MerkleTree.d.ts +3 -2
  399. package/data-structures/merkle-tree/MerkleTree.mjs +27 -17
  400. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +1 -1
  401. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +1 -2
  402. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +6 -6
  403. package/data-structures/presale/PresaleContractWrapper.d.ts +1 -1
  404. package/data-structures/provider-adapter/IProviderAdapter.d.ts +9 -13
  405. package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
  406. package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +23 -18
  407. package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
  408. package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +12 -7
  409. package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
  410. package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +11 -5
  411. package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
  412. package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +9 -4
  413. package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
  414. package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +9 -4
  415. package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
  416. package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +12 -6
  417. package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
  418. package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +10 -5
  419. package/error-handling/customErrors/ErrorWithIndex.cjs +1 -0
  420. package/error-handling/customErrors/ErrorWithIndex.d.ts +4 -0
  421. package/error-handling/customErrors/ErrorWithIndex.mjs +9 -0
  422. package/error-handling/customErrors/ErrorWithTx.cjs +1 -1
  423. package/error-handling/customErrors/ErrorWithTx.d.ts +2 -3
  424. package/error-handling/customErrors/ErrorWithTx.mjs +5 -5
  425. package/error-handling/customErrors/index.d.ts +1 -0
  426. package/error-handling/error-codes.constants.cjs +2 -2
  427. package/error-handling/error-codes.constants.d.ts +29 -0
  428. package/error-handling/error-codes.constants.mjs +51 -22
  429. package/error-handling/get-error.message.cjs +1 -1
  430. package/error-handling/get-error.message.mjs +46 -47
  431. package/error-handling/index.d.ts +0 -1
  432. package/error-handling/isInsufficientFundsError.cjs +1 -0
  433. package/error-handling/isInsufficientFundsError.d.ts +1 -0
  434. package/error-handling/isInsufficientFundsError.mjs +19 -0
  435. package/functions/auto-deposit-back-helpers/get-gas-token-records.cjs +1 -0
  436. package/functions/auto-deposit-back-helpers/get-gas-token-records.d.ts +9 -0
  437. package/functions/auto-deposit-back-helpers/get-gas-token-records.mjs +74 -0
  438. package/functions/auto-deposit-back-helpers/get-tokens-to-deposit-back.cjs +1 -0
  439. package/functions/auto-deposit-back-helpers/get-tokens-to-deposit-back.d.ts +3 -0
  440. package/functions/auto-deposit-back-helpers/get-tokens-to-deposit-back.mjs +61 -0
  441. package/functions/auto-deposit-back-helpers/index.d.ts +4 -0
  442. package/functions/auto-deposit-back-helpers/select-gas-token.cjs +1 -0
  443. package/functions/auto-deposit-back-helpers/select-gas-token.d.ts +13 -0
  444. package/functions/auto-deposit-back-helpers/select-gas-token.mjs +79 -0
  445. package/functions/auto-deposit-back-helpers/update-hinkal.cjs +1 -0
  446. package/functions/auto-deposit-back-helpers/update-hinkal.d.ts +3 -0
  447. package/functions/auto-deposit-back-helpers/update-hinkal.mjs +18 -0
  448. package/functions/connectors.types.d.ts +11 -3
  449. package/functions/index.d.ts +1 -0
  450. package/functions/kyc/zkMeHelper.cjs +1 -1
  451. package/functions/kyc/zkMeHelper.mjs +17 -16
  452. package/functions/pre-transaction/addressTableLookup.cjs +1 -1
  453. package/functions/pre-transaction/addressTableLookup.mjs +1 -1
  454. package/functions/pre-transaction/constructAdminData.cjs +1 -1
  455. package/functions/pre-transaction/constructAdminData.d.ts +2 -2
  456. package/functions/pre-transaction/constructAdminData.mjs +12 -18
  457. package/functions/pre-transaction/convert-okx-instructions.cjs +1 -1
  458. package/functions/pre-transaction/convert-okx-instructions.mjs +20 -16
  459. package/functions/pre-transaction/ensureAmountChanges.cjs +1 -0
  460. package/functions/pre-transaction/ensureAmountChanges.d.ts +2 -0
  461. package/functions/pre-transaction/ensureAmountChanges.mjs +11 -0
  462. package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
  463. package/functions/pre-transaction/getExternalSwapAddress.d.ts +1 -2
  464. package/functions/pre-transaction/getExternalSwapAddress.mjs +8 -8
  465. package/functions/pre-transaction/getFeeStructure.cjs +1 -1
  466. package/functions/pre-transaction/getFeeStructure.d.ts +2 -1
  467. package/functions/pre-transaction/getFeeStructure.mjs +13 -12
  468. package/functions/pre-transaction/getKycAndSignatureData.cjs +1 -0
  469. package/functions/pre-transaction/getKycAndSignatureData.d.ts +5 -0
  470. package/functions/pre-transaction/getKycAndSignatureData.mjs +20 -0
  471. package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
  472. package/functions/pre-transaction/getVolatileTransferAmount.mjs +22 -36
  473. package/functions/pre-transaction/index.d.ts +4 -0
  474. package/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
  475. package/functions/pre-transaction/merge-with-fee-structure-emporium.d.ts +1 -1
  476. package/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +17 -17
  477. package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -1
  478. package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +1 -9
  479. package/functions/pre-transaction/outputApprovalDataProcessing.mjs +19 -34
  480. package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
  481. package/functions/pre-transaction/sendV0Transaction.d.ts +4 -8
  482. package/functions/pre-transaction/sendV0Transaction.mjs +150 -86
  483. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -1
  484. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +1 -1
  485. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +7 -4
  486. package/functions/pre-transaction/store-instructions.cjs +1 -1
  487. package/functions/pre-transaction/store-instructions.mjs +11 -6
  488. package/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.cjs +1 -0
  489. package/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.d.ts +3 -0
  490. package/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.mjs +33 -0
  491. package/functions/private-wallet/emporium.helpers.cjs +1 -1
  492. package/functions/private-wallet/emporium.helpers.d.ts +12 -7
  493. package/functions/private-wallet/emporium.helpers.mjs +105 -131
  494. package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
  495. package/functions/private-wallet/emporium.swap.helpers.d.ts +1 -4
  496. package/functions/private-wallet/emporium.swap.helpers.mjs +98 -100
  497. package/functions/snarkjs/common.snarkjs.cjs +1 -1
  498. package/functions/snarkjs/common.snarkjs.d.ts +4 -5
  499. package/functions/snarkjs/common.snarkjs.mjs +113 -111
  500. package/functions/snarkjs/constant.cjs +1 -1
  501. package/functions/snarkjs/constant.mjs +7 -1
  502. package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
  503. package/functions/snarkjs/constructEmporiumProof.d.ts +4 -4
  504. package/functions/snarkjs/constructEmporiumProof.mjs +111 -121
  505. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  506. package/functions/snarkjs/constructGeneralZkProof.d.ts +2 -2
  507. package/functions/snarkjs/constructGeneralZkProof.mjs +104 -124
  508. package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
  509. package/functions/snarkjs/constructSolanaZkProof.d.ts +1 -1
  510. package/functions/snarkjs/constructSolanaZkProof.mjs +58 -64
  511. package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
  512. package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +11 -10
  513. package/functions/snarkjs/fetchOnChainRootHashes.cjs +1 -0
  514. package/functions/snarkjs/fetchOnChainRootHashes.d.ts +4 -0
  515. package/functions/snarkjs/fetchOnChainRootHashes.mjs +15 -0
  516. package/functions/snarkjs/generateCircomData.cjs +1 -1
  517. package/functions/snarkjs/generateCircomData.d.ts +3 -3
  518. package/functions/snarkjs/generateCircomData.mjs +29 -31
  519. package/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.cjs +1 -1
  520. package/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.d.ts +12 -1
  521. package/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.mjs +161 -65
  522. package/functions/snarkjs/getZKFiles.cjs +1 -1
  523. package/functions/snarkjs/getZKFiles.mjs +8 -11
  524. package/functions/snarkjs/index.d.ts +1 -0
  525. package/functions/utils/addresses.cjs +1 -1
  526. package/functions/utils/addresses.d.ts +3 -0
  527. package/functions/utils/addresses.mjs +32 -17
  528. package/functions/utils/amounts.utils.cjs +1 -1
  529. package/functions/utils/amounts.utils.d.ts +1 -1
  530. package/functions/utils/amounts.utils.mjs +2 -2
  531. package/functions/utils/buildClaimableDepositPlan.cjs +1 -0
  532. package/functions/utils/buildClaimableDepositPlan.d.ts +15 -0
  533. package/functions/utils/buildClaimableDepositPlan.mjs +40 -0
  534. package/functions/utils/cacheDevice.utils.cjs +1 -1
  535. package/functions/utils/cacheDevice.utils.mjs +8 -6
  536. package/functions/utils/cacheFunctions.cjs +1 -1
  537. package/functions/utils/cacheFunctions.mjs +2 -2
  538. package/functions/utils/create-provider.cjs +1 -1
  539. package/functions/utils/create-provider.d.ts +1 -1
  540. package/functions/utils/create-provider.mjs +11 -7
  541. package/functions/utils/enclave-signature-storage.cjs +1 -0
  542. package/functions/utils/enclave-signature-storage.d.ts +2 -0
  543. package/functions/utils/enclave-signature-storage.mjs +13 -0
  544. package/functions/utils/enclave-utxo-storage.cjs +1 -0
  545. package/functions/utils/enclave-utxo-storage.d.ts +6 -0
  546. package/functions/utils/enclave-utxo-storage.mjs +34 -0
  547. package/functions/utils/encryptInputForEnclave.cjs +1 -1
  548. package/functions/utils/encryptInputForEnclave.mjs +21 -21
  549. package/functions/utils/erc20tokenFunctions.cjs +1 -1
  550. package/functions/utils/erc20tokenFunctions.mjs +35 -35
  551. package/functions/utils/evmNetworkFunctions.cjs +1 -1
  552. package/functions/utils/evmNetworkFunctions.mjs +5 -3
  553. package/functions/utils/fees.utils.cjs +1 -1
  554. package/functions/utils/fees.utils.mjs +31 -29
  555. package/functions/utils/getBlockExplorerUrl.cjs +1 -1
  556. package/functions/utils/getBlockExplorerUrl.mjs +3 -3
  557. package/functions/utils/getDataFromTransaction.d.ts +1 -1
  558. package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
  559. package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
  560. package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
  561. package/functions/utils/getUtxosFromReceipt.utils.d.ts +2 -1
  562. package/functions/utils/getUtxosFromReceipt.utils.mjs +44 -15
  563. package/functions/utils/getUtxosFromReceiptSolana.cjs +1 -1
  564. package/functions/utils/getUtxosFromReceiptSolana.d.ts +2 -1
  565. package/functions/utils/getUtxosFromReceiptSolana.mjs +27 -16
  566. package/functions/utils/index.d.ts +12 -2
  567. package/functions/utils/involves-permit2-op.cjs +1 -1
  568. package/functions/utils/involves-permit2-op.d.ts +0 -1
  569. package/functions/utils/involves-permit2-op.mjs +4 -6
  570. package/functions/utils/mutexes.utils.cjs +1 -1
  571. package/functions/utils/mutexes.utils.d.ts +1 -1
  572. package/functions/utils/mutexes.utils.mjs +3 -3
  573. package/functions/utils/networks.utils.cjs +1 -1
  574. package/functions/utils/networks.utils.mjs +4 -2
  575. package/functions/utils/nftTokenFunctions.cjs +1 -1
  576. package/functions/utils/nftTokenFunctions.mjs +9 -23
  577. package/functions/utils/prepareHinkal.cjs +1 -1
  578. package/functions/utils/prepareHinkal.d.ts +6 -13
  579. package/functions/utils/prepareHinkal.mjs +44 -71
  580. package/functions/utils/process.utils.cjs +1 -1
  581. package/functions/utils/process.utils.d.ts +6 -0
  582. package/functions/utils/process.utils.mjs +22 -10
  583. package/functions/utils/proxyAvatar.utils.cjs +1 -0
  584. package/functions/utils/proxyAvatar.utils.d.ts +2 -0
  585. package/functions/utils/proxyAvatar.utils.mjs +5 -0
  586. package/functions/utils/publicBalance.utils.cjs +1 -1
  587. package/functions/utils/publicBalance.utils.d.ts +1 -1
  588. package/functions/utils/publicBalance.utils.mjs +55 -53
  589. package/functions/utils/serialize-utxos.utils.cjs +1 -0
  590. package/functions/utils/serialize-utxos.utils.d.ts +3 -0
  591. package/functions/utils/serialize-utxos.utils.mjs +13 -0
  592. package/functions/utils/string.utils.cjs +1 -1
  593. package/functions/utils/string.utils.d.ts +2 -0
  594. package/functions/utils/string.utils.mjs +35 -27
  595. package/functions/utils/time.utils.cjs +1 -1
  596. package/functions/utils/time.utils.mjs +1 -1
  597. package/functions/utils/token-check.utils.cjs +1 -1
  598. package/functions/utils/token-check.utils.d.ts +3 -0
  599. package/functions/utils/token-check.utils.mjs +18 -7
  600. package/functions/utils/tron.utils.cjs +1 -0
  601. package/functions/utils/tron.utils.d.ts +25 -0
  602. package/functions/utils/tron.utils.mjs +128 -0
  603. package/functions/utils/tronSimulation.utils.cjs +1 -0
  604. package/functions/utils/tronSimulation.utils.d.ts +1 -0
  605. package/functions/utils/tronSimulation.utils.mjs +30 -0
  606. package/functions/utils/tx-confirmation.utils.cjs +1 -0
  607. package/functions/utils/tx-confirmation.utils.d.ts +10 -0
  608. package/functions/utils/tx-confirmation.utils.mjs +50 -0
  609. package/functions/utils/upToDateState.cjs +1 -1
  610. package/functions/utils/upToDateState.d.ts +1 -1
  611. package/functions/utils/upToDateState.mjs +4 -4
  612. package/functions/utils/userAgent.cjs +1 -1
  613. package/functions/utils/userAgent.d.ts +0 -2
  614. package/functions/utils/userAgent.mjs +4 -23
  615. package/functions/utils/validateUsername.cjs +1 -0
  616. package/functions/utils/validateUsername.d.ts +5 -0
  617. package/functions/utils/validateUsername.mjs +16 -0
  618. package/functions/utils/walletBalances.utils.cjs +1 -1
  619. package/functions/utils/walletBalances.utils.d.ts +2 -17
  620. package/functions/utils/walletBalances.utils.mjs +5 -36
  621. package/functions/web3/connectors.utils.cjs +1 -1
  622. package/functions/web3/connectors.utils.d.ts +1 -0
  623. package/functions/web3/connectors.utils.mjs +14 -12
  624. package/functions/web3/crypto.cjs +1 -0
  625. package/functions/web3/crypto.d.ts +1 -0
  626. package/functions/web3/crypto.mjs +7 -0
  627. package/functions/web3/etherFunctions.cjs +1 -1
  628. package/functions/web3/etherFunctions.d.ts +1 -1
  629. package/functions/web3/etherFunctions.mjs +12 -15
  630. package/functions/web3/events/getApprovedBalance.cjs +1 -1
  631. package/functions/web3/events/getApprovedBalance.d.ts +3 -4
  632. package/functions/web3/events/getApprovedBalance.mjs +39 -44
  633. package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
  634. package/functions/web3/events/getInputUtxoAndBalance.d.ts +1 -1
  635. package/functions/web3/events/getInputUtxoAndBalance.mjs +127 -132
  636. package/functions/web3/events/getShieldedBalance.cjs +1 -2
  637. package/functions/web3/events/getShieldedBalance.d.ts +1 -1
  638. package/functions/web3/events/getShieldedBalance.mjs +72 -69
  639. package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
  640. package/functions/web3/events/getTransactionLogEvents.mjs +40 -36
  641. package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
  642. package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +17 -10
  643. package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
  644. package/functions/web3/functionCalls/accessTokenCalls.d.ts +1 -6
  645. package/functions/web3/functionCalls/accessTokenCalls.mjs +19 -25
  646. package/functions/web3/functionCalls/approveToken.cjs +1 -1
  647. package/functions/web3/functionCalls/approveToken.d.ts +1 -1
  648. package/functions/web3/functionCalls/approveToken.mjs +68 -63
  649. package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -1
  650. package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +1 -1
  651. package/functions/web3/functionCalls/approveTokensToHinkal.mjs +6 -6
  652. package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
  653. package/functions/web3/functionCalls/constructBatchCall.d.ts +3 -2
  654. package/functions/web3/functionCalls/constructBatchCall.mjs +53 -16
  655. package/functions/web3/functionCalls/estimateGasRelayer.d.ts +2 -3
  656. package/functions/web3/functionCalls/recoverTransactionFromError.cjs +1 -1
  657. package/functions/web3/functionCalls/recoverTransactionFromError.mjs +8 -7
  658. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  659. package/functions/web3/functionCalls/transactCallDirect.d.ts +2 -2
  660. package/functions/web3/functionCalls/transactCallDirect.mjs +58 -48
  661. package/functions/web3/functionCalls/transactCallDirectTron.cjs +1 -0
  662. package/functions/web3/functionCalls/transactCallDirectTron.d.ts +6 -0
  663. package/functions/web3/functionCalls/transactCallDirectTron.mjs +63 -0
  664. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  665. package/functions/web3/functionCalls/transactCallRelayer.d.ts +15 -6
  666. package/functions/web3/functionCalls/transactCallRelayer.mjs +72 -67
  667. package/functions/web3/functionCalls/waitForErc20Approvals.cjs +1 -0
  668. package/functions/web3/functionCalls/waitForErc20Approvals.d.ts +9 -0
  669. package/functions/web3/functionCalls/waitForErc20Approvals.mjs +54 -0
  670. package/functions/web3/getContractMetadata.cjs +1 -1
  671. package/functions/web3/getContractMetadata.mjs +14 -18
  672. package/functions/web3/getPublicAddressBalance.cjs +1 -1
  673. package/functions/web3/getPublicAddressBalance.d.ts +1 -1
  674. package/functions/web3/getPublicAddressBalance.mjs +7 -7
  675. package/functions/web3/getSolanaPriorityFee.cjs +1 -0
  676. package/functions/web3/getSolanaPriorityFee.d.ts +3 -0
  677. package/functions/web3/getSolanaPriorityFee.mjs +32 -0
  678. package/functions/web3/getTokenHolder.cjs +1 -1
  679. package/functions/web3/getTokenHolder.mjs +35 -31
  680. package/functions/web3/index.d.ts +3 -0
  681. package/functions/web3/lifiAPI.cjs +1 -1
  682. package/functions/web3/lifiAPI.d.ts +1 -1
  683. package/functions/web3/lifiAPI.mjs +12 -12
  684. package/functions/web3/odosAPI.cjs +1 -1
  685. package/functions/web3/odosAPI.mjs +4 -15
  686. package/functions/web3/okxAPI.cjs +1 -1
  687. package/functions/web3/okxAPI.mjs +13 -13
  688. package/functions/web3/oneInchAPI.cjs +1 -1
  689. package/functions/web3/oneInchAPI.mjs +9 -20
  690. package/functions/web3/runContractFunction.cjs +1 -1
  691. package/functions/web3/runContractFunction.mjs +38 -50
  692. package/functions/web3/tron-wagmi-adapter.cjs +1 -0
  693. package/functions/web3/tron-wagmi-adapter.d.ts +8 -0
  694. package/functions/web3/tron-wagmi-adapter.mjs +31 -0
  695. package/functions/web3/uniswapAPI.cjs +1 -1
  696. package/functions/web3/uniswapAPI.mjs +24 -34
  697. package/index.cjs +1 -1
  698. package/index.mjs +1079 -958
  699. package/package.json +4 -2
  700. package/providers/EthersProviderAdapter.cjs +1 -1
  701. package/providers/EthersProviderAdapter.d.ts +11 -17
  702. package/providers/EthersProviderAdapter.mjs +53 -82
  703. package/providers/SolanaProviderAdapter.cjs +1 -1
  704. package/providers/SolanaProviderAdapter.d.ts +8 -11
  705. package/providers/SolanaProviderAdapter.mjs +20 -32
  706. package/providers/TronProviderAdapter.cjs +1 -0
  707. package/providers/TronProviderAdapter.d.ts +37 -0
  708. package/providers/TronProviderAdapter.mjs +145 -0
  709. package/providers/WagmiProviderAdapter.cjs +1 -1
  710. package/providers/WagmiProviderAdapter.d.ts +14 -19
  711. package/providers/WagmiProviderAdapter.mjs +104 -130
  712. package/providers/prepareEthersHinkal.cjs +1 -1
  713. package/providers/prepareEthersHinkal.d.ts +2 -2
  714. package/providers/prepareEthersHinkal.mjs +17 -10
  715. package/providers/prepareWagmiHinkal.cjs +1 -1
  716. package/providers/prepareWagmiHinkal.mjs +21 -13
  717. package/types/TransactionSimulator.types.d.ts +2 -9
  718. package/types/activities.types.cjs +1 -1
  719. package/types/activities.types.d.ts +13 -7
  720. package/types/activities.types.mjs +18 -18
  721. package/types/admin.types.cjs +1 -1
  722. package/types/admin.types.d.ts +11 -8
  723. package/types/admin.types.mjs +2 -2
  724. package/types/balances.types.d.ts +1 -1
  725. package/types/cache.types.cjs +1 -1
  726. package/types/cache.types.d.ts +12 -4
  727. package/types/cache.types.mjs +2 -2
  728. package/types/circom-data.types.d.ts +6 -14
  729. package/types/coingecko.types.d.ts +5 -0
  730. package/types/commitments.types.d.ts +4 -0
  731. package/types/connector.types.d.ts +1 -0
  732. package/types/ethereum-network.types.d.ts +1 -1
  733. package/types/events.types.cjs +1 -0
  734. package/types/events.types.d.ts +6 -0
  735. package/types/events.types.mjs +4 -0
  736. package/types/fee.types.cjs +1 -0
  737. package/types/fee.types.d.ts +4 -0
  738. package/types/fee.types.mjs +4 -0
  739. package/types/hinkal.types.cjs +1 -1
  740. package/types/hinkal.types.d.ts +5 -1
  741. package/types/hinkal.types.mjs +14 -13
  742. package/types/index.d.ts +5 -4
  743. package/types/onramp.types.cjs +1 -0
  744. package/types/onramp.types.d.ts +58 -0
  745. package/types/onramp.types.mjs +4 -0
  746. package/types/pay-activities.types.cjs +1 -0
  747. package/types/pay-activities.types.d.ts +29 -0
  748. package/types/pay-activities.types.mjs +6 -0
  749. package/types/proxy.types.d.ts +7 -3
  750. package/types/rewards.types.d.ts +1 -1
  751. package/types/sandbox.types.cjs +1 -1
  752. package/types/sandbox.types.d.ts +12 -72
  753. package/types/sandbox.types.mjs +2 -2
  754. package/types/schedule.types.cjs +1 -0
  755. package/types/schedule.types.d.ts +7 -0
  756. package/types/schedule.types.mjs +4 -0
  757. package/types/scheduled-transactions.types.d.ts +14 -0
  758. package/types/session.types.d.ts +2 -0
  759. package/types/solana.types.d.ts +10 -0
  760. package/types/token-prices.types.cjs +1 -1
  761. package/types/token-prices.types.d.ts +7 -0
  762. package/types/token-prices.types.mjs +4 -2
  763. package/types/transactions.types.d.ts +2 -2
  764. package/types/tron.types.d.ts +10 -0
  765. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  766. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  767. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  768. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +31 -27
  769. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  770. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  771. package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
  772. package/webworker/utxoWorker/utxoWorkerLogic.mjs +1 -1
  773. package/webworker/viteWorkerURL.constant.cjs +3 -3
  774. package/webworker/viteWorkerURL.constant.mjs +3 -3
  775. package/webworker/zkProofWorker/zkProofWorker.types.d.ts +1 -2
  776. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  777. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
  778. package/webworker/zkProofWorker/zkProofWorkerLogic.cjs +1 -1
  779. package/webworker/zkProofWorker/zkProofWorkerLogic.mjs +27 -28
  780. package/API/ai-calls.cjs +0 -1
  781. package/API/ai-calls.d.ts +0 -17
  782. package/API/ai-calls.mjs +0 -21
  783. package/API/duneAPI.cjs +0 -1
  784. package/API/duneAPI.d.ts +0 -11
  785. package/API/duneAPI.mjs +0 -25
  786. package/API/enclaveCalls.cjs +0 -1
  787. package/API/enclaveCalls.d.ts +0 -9
  788. package/API/enclaveCalls.mjs +0 -11
  789. package/API/getBridgeProtocols.cjs +0 -1
  790. package/API/getBridgeProtocols.d.ts +0 -7
  791. package/API/getBridgeProtocols.mjs +0 -8
  792. package/API/getLifiStatus.cjs +0 -1
  793. package/API/getLifiStatus.d.ts +0 -24
  794. package/API/getLifiStatus.mjs +0 -15
  795. package/API/getRelayerURL.cjs +0 -1
  796. package/API/getRelayerURL.d.ts +0 -1
  797. package/API/getRelayerURL.mjs +0 -10
  798. package/API/is-tx-stateless.cjs +0 -1
  799. package/API/is-tx-stateless.mjs +0 -20
  800. package/API/passwordCalls.cjs +0 -1
  801. package/API/passwordCalls.d.ts +0 -9
  802. package/API/passwordCalls.mjs +0 -13
  803. package/API/restoreSnapshots.cjs +0 -1
  804. package/API/restoreSnapshots.d.ts +0 -1
  805. package/API/restoreSnapshots.mjs +0 -10
  806. package/constants/token-data/popularTokens.constants.cjs +0 -1
  807. package/constants/token-data/popularTokens.constants.d.ts +0 -3
  808. package/constants/token-data/popularTokens.constants.mjs +0 -13
  809. package/constants/token-data/tokenPricing.consts.d.ts +0 -2
  810. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +0 -1
  811. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +0 -7
  812. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +0 -42
  813. package/data-structures/Hinkal/hinkalApprove.cjs +0 -1
  814. package/data-structures/Hinkal/hinkalApprove.d.ts +0 -3
  815. package/data-structures/Hinkal/hinkalApprove.mjs +0 -114
  816. package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +0 -1
  817. package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +0 -230
  818. package/data-structures/Hinkal/hinkalInsideTransact.cjs +0 -1
  819. package/data-structures/Hinkal/hinkalInsideTransact.d.ts +0 -4
  820. package/data-structures/Hinkal/hinkalInsideTransact.mjs +0 -120
  821. package/error-handling/handleErrorRestore.cjs +0 -1
  822. package/error-handling/handleErrorRestore.d.ts +0 -2
  823. package/error-handling/handleErrorRestore.mjs +0 -11
  824. package/functions/kyc/authentoHelper.cjs +0 -1
  825. package/functions/kyc/authentoHelper.d.ts +0 -12
  826. package/functions/kyc/authentoHelper.mjs +0 -30
  827. package/functions/utils/ethers-formatter.utils.cjs +0 -1
  828. package/functions/utils/ethers-formatter.utils.d.ts +0 -5
  829. package/functions/utils/ethers-formatter.utils.mjs +0 -59
  830. package/functions/utils/get-hinkal-approvals.cjs +0 -1
  831. package/functions/utils/get-hinkal-approvals.d.ts +0 -3
  832. package/functions/utils/get-hinkal-approvals.mjs +0 -38
  833. package/functions/utils/replaceAddressInCalldata.cjs +0 -1
  834. package/functions/utils/replaceAddressInCalldata.d.ts +0 -1
  835. package/functions/utils/replaceAddressInCalldata.mjs +0 -7
  836. package/functions/web3/functionCalls/estimateGasRelayer.cjs +0 -1
  837. package/functions/web3/functionCalls/estimateGasRelayer.mjs +0 -22
  838. package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +0 -1
  839. package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +0 -5
  840. package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +0 -29
  841. package/types/bridging.types.d.ts +0 -29
  842. package/types/duneAPI.types.d.ts +0 -9
  843. package/types/relayer.types.d.ts +0 -25
  844. package/types/routing.types.cjs +0 -1
  845. package/types/routing.types.d.ts +0 -7
  846. package/types/routing.types.mjs +0 -4
@@ -1,20 +1,24 @@
1
1
  import { MerkleTree, MerkleTreeJson } from '../../merkle-tree';
2
- import { CommitmentEvent, EncryptedOutputWithSign } from '../../../types';
2
+ import { CommitmentEvent, EncryptedOutputWithCommitment, EncryptedOutputWithSign } from '../../../types';
3
3
  import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
4
4
  import { BlockchainEventEmitter } from './BlockchainEventEmitter';
5
+ import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
5
6
  export type CommitmentsSnapshotPayload = {
6
7
  readonly merkleTree: MerkleTree<bigint>;
7
8
  readonly encryptedOutputs: EncryptedOutputWithSign[];
9
+ readonly encryptedOutputsByCommitment: Map<bigint, string>;
8
10
  };
9
11
  export type CommitmentsSerializedSnapshot = {
10
12
  latestBlockNumber?: number;
11
13
  merkleTree?: MerkleTreeJson;
12
14
  encryptedOutputs?: EncryptedOutputWithSign<string>[];
15
+ encryptedOutputsByCommitment?: EncryptedOutputWithCommitment[];
13
16
  };
14
- export declare abstract class AbstractCommitmentsSnapshotService extends AbstractSnapshotService<CommitmentEvent<bigint>, CommitmentEvent, CommitmentsSnapshotPayload, CommitmentsSerializedSnapshot> {
17
+ export declare abstract class AbstractCommitmentsSnapshotService extends AbstractSnapshotService<CommitmentEvent<bigint>, CommitmentsSnapshotPayload, CommitmentsSerializedSnapshot> {
15
18
  constructor(hinkalEventEmitter: BlockchainEventEmitter);
16
19
  private _merkleTree;
17
20
  private _encryptedOutputs;
21
+ private _encryptedOutputsByCommitment;
18
22
  get merkleTree(): MerkleTree<bigint>;
19
23
  get encryptedOutputs(): EncryptedOutputWithSign<boolean>[];
20
24
  protected serializeSnapshot(snapshot: Snapshot<CommitmentsSnapshotPayload>): CommitmentsSerializedSnapshot;
@@ -22,8 +26,9 @@ export declare abstract class AbstractCommitmentsSnapshotService extends Abstrac
22
26
  protected getSnapshotPayload(): {
23
27
  merkleTree: MerkleTree<bigint>;
24
28
  encryptedOutputs: EncryptedOutputWithSign<boolean>[];
29
+ encryptedOutputsByCommitment: Map<bigint, string>;
25
30
  };
26
- protected populateSnapshot({ payload: { merkleTree, encryptedOutputs }, }: Snapshot<CommitmentsSnapshotPayload>): void;
27
- protected mapEvent(event: CommitmentEvent): CommitmentEvent<bigint>;
31
+ protected populateSnapshot({ payload: { merkleTree, encryptedOutputs, encryptedOutputsByCommitment }, }: Snapshot<CommitmentsSnapshotPayload>): void;
32
+ protected mapEvent(event: BlockchainEvent): CommitmentEvent<bigint>;
28
33
  protected acceptEvent(event: CommitmentEvent<bigint>, _blockNumber: number, _txHash?: string, isBlocked?: boolean): boolean;
29
34
  }
@@ -1,86 +1,103 @@
1
- import { poseidonFunction as m } from "../../../crypto/poseidon.mjs";
1
+ import { poseidonFunction as d } 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 c } from "../../merkle-tree/MerkleTree.mjs";
6
+ import { MerkleTree as l } from "../../merkle-tree/MerkleTree.mjs";
7
7
  import "ethers";
8
8
  import "../../../error-handling/error-codes.constants.mjs";
9
- import { toBigInt as p } from "../../../functions/utils/amounts.utils.mjs";
10
- import { AbstractSnapshotService as o } from "./AbstractSnapshotService.mjs";
11
- import { contructMerkleTreeFromSerialized as n } from "../../../functions/utils/merkleTree.utils.mjs";
12
- class b extends o {
13
- constructor(e) {
14
- super(e, "NewCommitment");
9
+ import { toBigInt as u } from "../../../functions/utils/amounts.utils.mjs";
10
+ import { AbstractSnapshotService as y } from "./AbstractSnapshotService.mjs";
11
+ import { contructMerkleTreeFromSerialized as a } from "../../../functions/utils/merkleTree.utils.mjs";
12
+ class v extends y {
13
+ constructor(t) {
14
+ super(t, "NewCommitment");
15
15
  }
16
16
  _merkleTree;
17
17
  _encryptedOutputs;
18
+ _encryptedOutputsByCommitment = /* @__PURE__ */ new Map();
18
19
  get merkleTree() {
19
20
  return this._merkleTree;
20
21
  }
21
22
  get encryptedOutputs() {
22
23
  return this._encryptedOutputs;
23
24
  }
24
- serializeSnapshot(e) {
25
+ serializeSnapshot(t) {
25
26
  return {
26
- merkleTree: e.payload.merkleTree.toJSON(),
27
- latestBlockNumber: e.latestBlockNumber,
28
- encryptedOutputs: e.payload.encryptedOutputs.map((t) => ({
29
- value: t.value,
30
- isPositive: String(t.isPositive),
31
- isBlocked: t.isBlocked ?? !1
32
- }))
27
+ merkleTree: t.payload.merkleTree.toJSON(),
28
+ latestBlockNumber: t.latestBlockNumber,
29
+ encryptedOutputs: t.payload.encryptedOutputs.map((e) => ({
30
+ value: e.value,
31
+ isPositive: String(e.isPositive),
32
+ isBlocked: e.isBlocked ?? !1
33
+ })),
34
+ encryptedOutputsByCommitment: Array.from(t.payload.encryptedOutputsByCommitment.entries()).map(
35
+ ([e, r]) => ({
36
+ commitment: e.toString(),
37
+ encryptedOutput: r
38
+ })
39
+ )
33
40
  };
34
41
  }
35
- deserializeSnapshot(e) {
36
- let t;
37
- e.latestBlockNumber && e.merkleTree ? t = n(e.merkleTree) : t = c.create(m, 0n);
38
- const s = e.encryptedOutputs?.map((r) => ({
39
- value: r.value,
40
- isPositive: JSON.parse(r.isPositive),
41
- isBlocked: r.isBlocked ?? !1
42
- }));
43
- return {
44
- latestBlockNumber: e.latestBlockNumber ?? 0,
42
+ deserializeSnapshot(t) {
43
+ let e;
44
+ t.latestBlockNumber && t.merkleTree ? e = a(t.merkleTree) : e = l.create(d, 0n);
45
+ const r = t.encryptedOutputs?.map((m) => ({
46
+ value: m.value,
47
+ isPositive: JSON.parse(m.isPositive),
48
+ isBlocked: m.isBlocked ?? !1
49
+ })), n = /* @__PURE__ */ new Map();
50
+ return t.encryptedOutputsByCommitment?.forEach(({ commitment: m, encryptedOutput: i }) => {
51
+ n.set(u(m), i);
52
+ }), {
53
+ latestBlockNumber: t.latestBlockNumber ?? 0,
45
54
  payload: {
46
- merkleTree: t,
47
- encryptedOutputs: s || []
55
+ merkleTree: e,
56
+ encryptedOutputs: r || [],
57
+ encryptedOutputsByCommitment: n
48
58
  }
49
59
  };
50
60
  }
51
61
  getSnapshotPayload() {
52
62
  return {
53
63
  merkleTree: this._merkleTree,
54
- encryptedOutputs: this._encryptedOutputs
64
+ encryptedOutputs: this._encryptedOutputs,
65
+ encryptedOutputsByCommitment: this._encryptedOutputsByCommitment
55
66
  };
56
67
  }
57
68
  populateSnapshot({
58
- payload: { merkleTree: e, encryptedOutputs: t }
69
+ payload: { merkleTree: t, encryptedOutputs: e, encryptedOutputsByCommitment: r }
59
70
  }) {
60
- this._merkleTree = e, this._encryptedOutputs = t;
71
+ this._merkleTree = t, this._encryptedOutputs = e, this._encryptedOutputsByCommitment = r;
61
72
  }
62
- mapEvent(e) {
63
- const { commitment: t, index: s, encryptedOutput: r } = e;
73
+ mapEvent(t) {
74
+ const e = t.getArg("commitment"), r = t.getArg("index"), n = t.getArg("encryptedOutput");
64
75
  return {
65
- commitment: p(t),
66
- index: p(s),
67
- encryptedOutput: r
76
+ commitment: u(e),
77
+ index: u(r),
78
+ encryptedOutput: n
68
79
  };
69
80
  }
70
- acceptEvent(e, t, s, r) {
71
- if (!this.encryptedOutputs.map((i) => i.value).includes(e.encryptedOutput)) {
72
- if (!this._merkleTree.insert(e.commitment, e.index >= 0 ? e.index : -1n * e.index))
73
- return !1;
74
- const u = {
75
- value: e.encryptedOutput,
76
- isPositive: e.index >= 0n,
77
- isBlocked: r ?? !1
78
- };
79
- return this._encryptedOutputs.push(u), !0;
81
+ acceptEvent(t, e, r, n) {
82
+ const m = t.index >= 0n ? t.index : -1n * t.index, i = this._merkleTree.getValue(m);
83
+ if (i === t.commitment)
84
+ return !1;
85
+ this._merkleTree.insert(t.commitment, m);
86
+ const s = i !== void 0 ? this._encryptedOutputsByCommitment.get(i) : void 0;
87
+ if (i !== void 0 && s !== void 0) {
88
+ const p = this.encryptedOutputs.findIndex((c) => c.value === s);
89
+ p !== -1 && this.encryptedOutputs.splice(p, 1), this._encryptedOutputsByCommitment.delete(i);
80
90
  }
81
- return !1;
91
+ if (this._encryptedOutputsByCommitment.set(t.commitment, t.encryptedOutput), this.encryptedOutputs.map((p) => p.value).includes(t.encryptedOutput))
92
+ return !0;
93
+ const o = {
94
+ value: t.encryptedOutput,
95
+ isPositive: t.index >= 0n,
96
+ isBlocked: n ?? !1
97
+ };
98
+ return this._encryptedOutputs.push(o), !0;
82
99
  }
83
100
  }
84
101
  export {
85
- b as AbstractCommitmentsSnapshotService
102
+ v as AbstractCommitmentsSnapshotService
86
103
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../../functions/utils/resolve-sync.utils.cjs");class h{blockchainEventEmitter;eventName;constructor(e,s){this.blockchainEventEmitter=e,this.eventName=s,e.addEventProcessorFunction(this.processEventsPage.bind(this))}get latestBlockNumber(){return this.blockchainEventEmitter.latestBlockNumber}intervalClear(){this.blockchainEventEmitter.intervalClear()}async processEventsPage(e){const s=new Set;e.forEach(t=>{t.eventName==="BlockedUtxosCreated"&&s.add(t.transactionHash)});const n=[];await v.resolveSync(e.map(t=>async()=>{if(t.eventName!==this.eventName)return;const{args:c,blockNumber:i,transactionHash:a}=t;if(!c)throw new Error("Wrong event structure");const r=this.mapEvent(c),l=s.has(a);await this.acceptEvent(r,i,a,l)&&n.push(r)}));const o=n.length;return await this.afterEventsAccepted(o),n.length}}exports.AbstractEventService=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../../functions/utils/resolve-sync.utils.cjs");class h{blockchainEventEmitter;eventName;constructor(t,s){this.blockchainEventEmitter=t,this.eventName=s,t.addEventProcessorFunction(this.processEventsPage.bind(this))}get latestBlockNumber(){return this.blockchainEventEmitter.latestBlockNumber}get chainId(){return this.blockchainEventEmitter.chainId}intervalClear(){this.blockchainEventEmitter.intervalClear()}async processEventsPage(t){const s=new Set;t.forEach(({eventName:e,transactionHash:c})=>{e==="BlockedUtxosCreated"&&s.add(c)});const n=[];await l.resolveSync(t.map(e=>async()=>{if(e.eventName!==this.eventName)return;const{blockNumber:c,transactionHash:a}=e,r=this.mapEvent(e),o=s.has(a);await this.acceptEvent(r,c,a,o)&&n.push(r)}));const i=n.length;return await this.afterEventsAccepted(i),n.length}}exports.AbstractEventService=h;
@@ -1,12 +1,14 @@
1
+ import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
1
2
  import { BlockchainEventEmitter } from './BlockchainEventEmitter';
2
- export declare abstract class AbstractEventService<EventType, SerializedEventType = unknown> {
3
+ export declare abstract class AbstractEventService<EventType> {
3
4
  protected blockchainEventEmitter: BlockchainEventEmitter;
4
5
  protected readonly eventName: string;
5
6
  protected constructor(blockchainEventEmitter: BlockchainEventEmitter, eventName: string);
6
7
  get latestBlockNumber(): number;
8
+ get chainId(): number;
7
9
  intervalClear(): void;
8
10
  private processEventsPage;
9
11
  protected abstract acceptEvent(event: EventType, blockNumber: number, txHash?: string, isBlocked?: boolean): boolean | Promise<boolean>;
10
- protected abstract mapEvent(event: SerializedEventType): EventType;
12
+ protected abstract mapEvent(event: BlockchainEvent): EventType;
11
13
  protected abstract afterEventsAccepted(eventsCount: number): Promise<void>;
12
14
  }
@@ -1,5 +1,5 @@
1
- import { resolveSync as v } from "../../../functions/utils/resolve-sync.utils.mjs";
2
- class u {
1
+ import { resolveSync as h } from "../../../functions/utils/resolve-sync.utils.mjs";
2
+ class m {
3
3
  blockchainEventEmitter;
4
4
  eventName;
5
5
  constructor(t, s) {
@@ -8,30 +8,30 @@ class u {
8
8
  get latestBlockNumber() {
9
9
  return this.blockchainEventEmitter.latestBlockNumber;
10
10
  }
11
+ get chainId() {
12
+ return this.blockchainEventEmitter.chainId;
13
+ }
11
14
  intervalClear() {
12
15
  this.blockchainEventEmitter.intervalClear();
13
16
  }
14
17
  async processEventsPage(t) {
15
18
  const s = /* @__PURE__ */ new Set();
16
- t.forEach((e) => {
17
- e.eventName === "BlockedUtxosCreated" && s.add(e.transactionHash);
19
+ t.forEach(({ eventName: e, transactionHash: c }) => {
20
+ e === "BlockedUtxosCreated" && s.add(c);
18
21
  });
19
22
  const n = [];
20
- await v(
23
+ await h(
21
24
  t.map((e) => async () => {
22
25
  if (e.eventName !== this.eventName)
23
26
  return;
24
- const { args: a, blockNumber: i, transactionHash: c } = e;
25
- if (!a)
26
- throw new Error("Wrong event structure");
27
- const r = this.mapEvent(a), h = s.has(c);
28
- await this.acceptEvent(r, i, c, h) && n.push(r);
27
+ const { blockNumber: c, transactionHash: a } = e, i = this.mapEvent(e), o = s.has(a);
28
+ await this.acceptEvent(i, c, a, o) && n.push(i);
29
29
  })
30
30
  );
31
- const o = n.length;
32
- return await this.afterEventsAccepted(o), n.length;
31
+ const r = n.length;
32
+ return await this.afterEventsAccepted(r), n.length;
33
33
  }
34
34
  }
35
35
  export {
36
- u as AbstractEventService
36
+ m as AbstractEventService
37
37
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("ethers"),i=require("./AbstractSnapshotService.cjs");class s extends i.AbstractSnapshotService{constructor(e){super(e,"Nullified")}_nullifiers;get nullifiers(){return this._nullifiers}serializeSnapshot(e){return{nullifiers:Array.from(e.payload.nullifiers).map(r=>r.toString()),latestBlockNumber:e.latestBlockNumber}}deserializeSnapshot(e){return{latestBlockNumber:e.latestBlockNumber??0,payload:{nullifiers:new Set(e.nullifiers??[])}}}acceptEvent(e,r){try{return this._nullifiers.has(e.nullifier)?!1:(this._nullifiers.add(e.nullifier),!0)}catch(t){return console.error(t),!1}}mapEvent(e){const{nullifier:r}=e;return{nullifier:l.ethers.toBeHex(r)}}getSnapshotPayload(){return{nullifiers:this._nullifiers}}populateSnapshot({payload:{nullifiers:e}}){this._nullifiers=e}}exports.AbstractNullifierSnapshotService=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./AbstractSnapshotService.cjs"),i=require("ethers");class s extends t.AbstractSnapshotService{constructor(e){super(e,"Nullified")}_nullifiers;get nullifiers(){return this._nullifiers}serializeSnapshot(e){return{nullifiers:Array.from(e.payload.nullifiers).map(r=>r.toString()),latestBlockNumber:e.latestBlockNumber}}deserializeSnapshot(e){return{latestBlockNumber:e.latestBlockNumber??0,payload:{nullifiers:new Set(e.nullifiers??[])}}}acceptEvent(e,r){try{return this._nullifiers.has(e.nullifier)?!1:(this._nullifiers.add(e.nullifier),!0)}catch(l){return console.error(l),!1}}mapEvent(e){const r=e.getArg("nullifier");return{nullifier:i.ethers.toBeHex(r)}}getSnapshotPayload(){return{nullifiers:this._nullifiers}}populateSnapshot({payload:{nullifiers:e}}){this._nullifiers=e}}exports.AbstractNullifierSnapshotService=s;
@@ -1,6 +1,7 @@
1
1
  import { NullifierEvent } from '../../../types/commitments.types';
2
2
  import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
3
3
  import { BlockchainEventEmitter } from './BlockchainEventEmitter';
4
+ import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
4
5
  export type NullifierSnapshotPayload = {
5
6
  readonly nullifiers: Set<string>;
6
7
  };
@@ -8,14 +9,14 @@ export type NullifierSerializedSnapshot = {
8
9
  latestBlockNumber?: number;
9
10
  nullifiers?: string[];
10
11
  };
11
- export declare abstract class AbstractNullifierSnapshotService extends AbstractSnapshotService<NullifierEvent<string>, NullifierEvent<bigint>, NullifierSnapshotPayload, NullifierSerializedSnapshot> {
12
+ export declare abstract class AbstractNullifierSnapshotService extends AbstractSnapshotService<NullifierEvent<string>, NullifierSnapshotPayload, NullifierSerializedSnapshot> {
12
13
  constructor(hinkalEventEmitter: BlockchainEventEmitter);
13
14
  private _nullifiers;
14
15
  get nullifiers(): Set<string>;
15
16
  protected serializeSnapshot(snapshot: Snapshot<NullifierSnapshotPayload>): NullifierSerializedSnapshot;
16
17
  protected deserializeSnapshot(serializedSnapshot: NullifierSerializedSnapshot): Snapshot<NullifierSnapshotPayload>;
17
18
  protected acceptEvent(event: NullifierEvent<string>, _blockNumber: number): boolean;
18
- protected mapEvent(event: NullifierEvent<bigint>): NullifierEvent<string>;
19
+ protected mapEvent(event: BlockchainEvent): NullifierEvent<string>;
19
20
  protected getSnapshotPayload(): NullifierSnapshotPayload;
20
21
  protected populateSnapshot({ payload: { nullifiers } }: Snapshot<NullifierSnapshotPayload>): void;
21
22
  }
@@ -1,6 +1,6 @@
1
- import { ethers as i } from "ethers";
2
- import { AbstractSnapshotService as t } from "./AbstractSnapshotService.mjs";
3
- class a extends t {
1
+ import { AbstractSnapshotService as i } from "./AbstractSnapshotService.mjs";
2
+ import { ethers as t } from "ethers";
3
+ class a extends i {
4
4
  constructor(r) {
5
5
  super(r, "Nullified");
6
6
  }
@@ -30,9 +30,9 @@ class a extends t {
30
30
  }
31
31
  }
32
32
  mapEvent(r) {
33
- const { nullifier: e } = r;
33
+ const e = r.getArg("nullifier");
34
34
  return {
35
- nullifier: i.toBeHex(e)
35
+ nullifier: t.toBeHex(e)
36
36
  };
37
37
  }
38
38
  getSnapshotPayload() {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../constants/save-depths.cjs"),a=require("./AbstractEventService.cjs"),r=require("../../../functions/utils/getSignerFromContract.cjs");class i extends a.AbstractEventService{savedLatestBlockNumber=0;chainId=0;constructor(t,e){super(t,e)}async init(){await this.loadSnapshot();const t=r.getProviderFromContract(this.blockchainEventEmitter.contract);this.chainId=Number((await t.getNetwork()).chainId)}async retrieveEventsFromLatestBlock(){await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber)}async loadSnapshot(){const t=await this.fetchSnapshot(),e=this.deserializeSnapshot(t);this.populateSnapshot(e),this.blockchainEventEmitter.syncFromAtMost(e.latestBlockNumber),this.savedLatestBlockNumber=e.latestBlockNumber}saveSnapshot(){return this.savedLatestBlockNumber=this.latestBlockNumber,this.persistSnapshot(this.serializeSnapshot({latestBlockNumber:this.latestBlockNumber,payload:this.getSnapshotPayload()}))}async afterEventsAccepted(t){(t>0||this.savedLatestBlockNumber+s.saveDepths[this.chainId]<this.latestBlockNumber)&&await this.saveSnapshot()}}exports.AbstractSnapshotService=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../constants/save-depths.cjs"),a=require("./AbstractEventService.cjs");class i extends a.AbstractEventService{savedLatestBlockNumber=0;constructor(t,e){super(t,e)}async init(){await this.loadSnapshot()}async retrieveEventsFromLatestBlock(){await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber)}get isReady(){return this.blockchainEventEmitter.isReady}async loadSnapshot(){const t=await this.fetchSnapshot(),e=this.deserializeSnapshot(t);this.populateSnapshot(e),this.blockchainEventEmitter.syncFromAtMost(e.latestBlockNumber),this.savedLatestBlockNumber=e.latestBlockNumber}saveSnapshot(){return this.savedLatestBlockNumber=this.latestBlockNumber,this.persistSnapshot(this.serializeSnapshot({latestBlockNumber:this.latestBlockNumber,payload:this.getSnapshotPayload()}))}async afterEventsAccepted(t){(t>0||this.savedLatestBlockNumber+s.saveDepths[this.chainId]<this.latestBlockNumber)&&await this.saveSnapshot()}}exports.AbstractSnapshotService=i;
@@ -4,12 +4,12 @@ export interface Snapshot<SnapshotPayloadType> {
4
4
  readonly latestBlockNumber: number;
5
5
  readonly payload: SnapshotPayloadType;
6
6
  }
7
- export declare abstract class AbstractSnapshotService<EventType, SerializedEventType, SnapshotPayloadType, SerializedSnapshotType> extends AbstractEventService<EventType, SerializedEventType> {
7
+ export declare abstract class AbstractSnapshotService<EventType, SnapshotPayloadType, SerializedSnapshotType> extends AbstractEventService<EventType> {
8
8
  private savedLatestBlockNumber;
9
- private chainId;
10
9
  protected constructor(blockchainEventEmitter: BlockchainEventEmitter, eventName: string);
11
10
  init(): Promise<void>;
12
11
  retrieveEventsFromLatestBlock(): Promise<void>;
12
+ get isReady(): boolean;
13
13
  private loadSnapshot;
14
14
  protected saveSnapshot(): Promise<unknown>;
15
15
  protected afterEventsAccepted(eventsCount: number): Promise<void>;
@@ -1,20 +1,19 @@
1
1
  import { saveDepths as e } from "../../../constants/save-depths.mjs";
2
2
  import { AbstractEventService as a } from "./AbstractEventService.mjs";
3
- import { getProviderFromContract as o } from "../../../functions/utils/getSignerFromContract.mjs";
4
- class n extends a {
3
+ class h extends a {
5
4
  savedLatestBlockNumber = 0;
6
- chainId = 0;
7
5
  constructor(t, s) {
8
6
  super(t, s);
9
7
  }
10
8
  async init() {
11
9
  await this.loadSnapshot();
12
- const t = o(this.blockchainEventEmitter.contract);
13
- this.chainId = Number((await t.getNetwork()).chainId);
14
10
  }
15
11
  async retrieveEventsFromLatestBlock() {
16
12
  await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber);
17
13
  }
14
+ get isReady() {
15
+ return this.blockchainEventEmitter.isReady;
16
+ }
18
17
  async loadSnapshot() {
19
18
  const t = await this.fetchSnapshot(), s = this.deserializeSnapshot(t);
20
19
  this.populateSnapshot(s), this.blockchainEventEmitter.syncFromAtMost(s.latestBlockNumber), this.savedLatestBlockNumber = s.latestBlockNumber;
@@ -32,5 +31,5 @@ class n extends a {
32
31
  }
33
32
  }
34
33
  export {
35
- n as AbstractSnapshotService
34
+ h as AbstractSnapshotService
36
35
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("ethers"),y=require("../../../constants/reorg-depths.constants.cjs"),h=require("../../../functions/utils/resolve-sync.utils.cjs"),f=require("../../../functions/utils/mutexes.utils.cjs"),d=require("../../../functions/utils/getSignerFromContract.cjs");class E{contract;depositOnChainUtxosContract;_latestBlockNumber;_initialBlockNumber;onEventsProcessed;eventProcessors=new Set;maxPageSize;isReady=!1;isServer;intervalId;inProgress;eventsFetchingMutex;constructor(e,r,u,s,i,a=f.balanceFetchingMutex){this.contract=e,this.depositOnChainUtxosContract=i,this._initialBlockNumber=r,this.maxPageSize=s,this.isServer=u,this.inProgress=!1,this.eventsFetchingMutex=a}get latestBlockNumber(){return this._latestBlockNumber??this._initialBlockNumber}syncFromAtMost(e){(this._latestBlockNumber===void 0||e<this._latestBlockNumber)&&(this._latestBlockNumber=e)}intervalClear(){this.isReady=!1,this.eventProcessors=new Set,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")}addEventProcessorFunction(e){if(this.isReady)throw new Error("Can't add event processor after event emitter initialized");this.eventProcessors.add(e)}async getLastBlockNumberForEventRequest(){const e=await d.getProviderFromContract(this.contract).getBlockNumber();if(!this.isServer)return e;const{chainId:r}=await d.getProviderFromContract(this.contract).getNetwork();return Math.max(this.latestBlockNumber,e-y.blockReorgDepth[Number(r)]+1)}async retrieveEvents(e,r=!1){return this.requireReady(),await this.eventsFetchingMutex.runExclusive(async()=>{try{if(this.inProgress&&!r)return!1;this.inProgress=!0;let s=0;const i=await this.getLastBlockNumberForEventRequest();if(i<e)return this.inProgress=!1,!1;const a=h.getSequence(e,i,this.maxPageSize),o=[];if(await h.resolveSync(a.map(({from:t,to:n})=>async()=>{const c=(await this.contract.queryFilter("*",t,n)).filter(l=>l instanceof v.ethers.EventLog);o.push(...c)})),this.depositOnChainUtxosContract){const{depositOnChainUtxosContract:t}=this;await h.resolveSync(a.map(({from:n,to:c})=>async()=>{const l=(await t.queryFilter("*",n,c)).filter(g=>g instanceof v.ethers.EventLog);o.push(...l)}))}const m=await Promise.all([...this.eventProcessors].map(t=>t(o)));return this._latestBlockNumber=i,s+=m.reduce((t,n)=>t+n,0),this.onEventsProcessed?.(s),this.inProgress=!1,!0}catch(s){return console.log("retrieveEvents error:",{err:s}),this.inProgress=!1,!1}})}}exports.BlockchainEventEmitter=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("ethers"),u=require("../../../constants/reorg-depths.constants.cjs"),v=require("../../../error-handling/logger.cjs"),c=require("../../../functions/utils/resolve-sync.utils.cjs"),g=require("../../BlockchainEvent/BlockchainEvent.cjs"),h=require("../../../functions/utils/getSignerFromContract.cjs");class d{RETRY_MIN_PAGE_SIZE=100;MAX_RETRIES=20;_chainId;contract;depositOnChainUtxosContract;_latestBlockNumber;_initialBlockNumber;onEventsProcessed;eventProcessors=new Set;maxPageSize;_isReady=!1;isServer;inProgress;eventsFetchingMutex;constructor(t,s,r,e,i,n,a){this.contract=s,this.depositOnChainUtxosContract=a,this._chainId=t,this._initialBlockNumber=r,this.maxPageSize=n,this.isServer=e,this.inProgress=!1,this.eventsFetchingMutex=i}get latestBlockNumber(){return this._latestBlockNumber??this._initialBlockNumber}get chainId(){return this._chainId}get isReady(){return this._isReady}syncFromAtMost(t){(this._latestBlockNumber===void 0||t<this._latestBlockNumber)&&(this._latestBlockNumber=t)}advanceLatestBlockNumber(t){const s=this._latestBlockNumber??this._initialBlockNumber;t>s&&(this._latestBlockNumber=t)}intervalClear(){this._isReady=!1,this.eventProcessors=new Set,this.clear()}async init(){if(this._isReady)throw new Error("Already initialized");this._isReady=!0,await this.retrieveEvents(this.latestBlockNumber+1),this.startUpdateListener()}requireReady(){if(!this._isReady)throw new Error("Not ready")}async getEventsForSingleContract(t,s,r,e=0){try{return(await t.queryFilter("*",s,r)).filter(i=>i instanceof l.ethers.EventLog)}catch(i){if(e<this.MAX_RETRIES&&r-s>this.RETRY_MIN_PAGE_SIZE){const n=Math.floor((s+r)/2),a=await this.getEventsForSingleContract(t,s,n,e+1),o=await this.getEventsForSingleContract(t,n+1,r,e+1);return[...a,...o]}throw i}}addEventProcessorFunction(t){if(this._isReady)throw new Error("Can't add event processor after event emitter initialized");this.eventProcessors.add(t)}async getEventsInRange(t,s){const r=[],e=c.getSequence(t,s,this.maxPageSize);await c.resolveSync(e.map(({from:n,to:a})=>async()=>{const o=await this.getEventsForSingleContract(this.contract,n,a);r.push(...o)}));const i=this.depositOnChainUtxosContract;return i&&await c.resolveSync(e.map(({from:n,to:a})=>async()=>{const o=await this.getEventsForSingleContract(i,n,a);r.push(...o)})),r.map(n=>g.BlockchainEvent.fromEthers(n))}async getLastBlockNumberForEventRequest(){const t=await h.getProviderFromContract(this.contract).getBlockNumber();if(!this.isServer)return t;const{chainId:s}=await h.getProviderFromContract(this.contract).getNetwork();return Math.max(this.latestBlockNumber,t-u.blockReorgDepth[Number(s)]+1)}async retrieveEvents(t,s=!1){return this.requireReady(),await this.eventsFetchingMutex.runExclusive(async()=>{try{if(this.inProgress&&!s)return!1;this.inProgress=!0;const e=await this.getLastBlockNumberForEventRequest();if(e<t)return this.inProgress=!1,!1;const i=await this.getEventsInRange(t,e);return await this.processEvents(i),this._latestBlockNumber=e,this.inProgress=!1,!0}catch(e){return v.Logger.error("retrieveEvents error",e),this.inProgress=!1,!1}})}async processEvents(t){const r=(await Promise.all([...this.eventProcessors].map(e=>e(t)))).reduce((e,i)=>e+i,0);this.onEventsProcessed?.(r)}}exports.BlockchainEventEmitter=d;
@@ -1,7 +1,11 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { Mutex } from 'async-mutex';
3
- export type EventProcessorFunction = (events: ethers.EventLog[]) => Promise<number> | number;
4
- export declare class BlockchainEventEmitter {
3
+ import { EventProcessorFunction } from '../../../types/events.types';
4
+ import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
5
+ export declare abstract class BlockchainEventEmitter {
6
+ private readonly RETRY_MIN_PAGE_SIZE;
7
+ private readonly MAX_RETRIES;
8
+ private readonly _chainId;
5
9
  readonly contract: ethers.Contract;
6
10
  readonly depositOnChainUtxosContract?: ethers.Contract;
7
11
  private _latestBlockNumber;
@@ -9,18 +13,25 @@ export declare class BlockchainEventEmitter {
9
13
  onEventsProcessed?: (acceptedEventCount: number) => void;
10
14
  private eventProcessors;
11
15
  private readonly maxPageSize?;
12
- private isReady;
16
+ private _isReady;
13
17
  private isServer;
14
- private intervalId?;
15
18
  private inProgress;
16
- private eventsFetchingMutex;
17
- constructor(contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, maxPageSize?: number, depositOnChainUtxosContract?: ethers.Contract, eventsFetchingMutex?: Mutex);
19
+ protected eventsFetchingMutex: Mutex;
20
+ constructor(chainId: number, contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, eventsFetchingMutex: Mutex, maxPageSize?: number, depositOnChainUtxosContract?: ethers.Contract);
18
21
  get latestBlockNumber(): number;
22
+ get chainId(): number;
23
+ get isReady(): boolean;
19
24
  syncFromAtMost(blockNumber: number): void;
25
+ protected advanceLatestBlockNumber(blockNumber: number): void;
20
26
  intervalClear(): void;
21
27
  init(): Promise<void>;
22
28
  private requireReady;
29
+ private getEventsForSingleContract;
23
30
  addEventProcessorFunction(eventProcessorFunction: EventProcessorFunction): void;
24
- private getLastBlockNumberForEventRequest;
31
+ getEventsInRange(fromBlockNumber: number, toBlockNumber: number): Promise<BlockchainEvent[]>;
32
+ getLastBlockNumberForEventRequest(): Promise<number>;
25
33
  retrieveEvents(fromBlockNumber: number, useForce?: boolean): Promise<boolean>;
34
+ protected processEvents(events: BlockchainEvent[]): Promise<void>;
35
+ protected abstract clear(): void;
36
+ protected abstract startUpdateListener(): void;
26
37
  }
@@ -1,9 +1,13 @@
1
- import { ethers as u } from "ethers";
2
- import { blockReorgDepth as g } from "../../../constants/reorg-depths.constants.mjs";
3
- import { getSequence as y, resolveSync as v } from "../../../functions/utils/resolve-sync.utils.mjs";
4
- import { balanceFetchingMutex as E } from "../../../functions/utils/mutexes.utils.mjs";
5
- import { getProviderFromContract as m } from "../../../functions/utils/getSignerFromContract.mjs";
6
- class b {
1
+ import { ethers as l } from "ethers";
2
+ import { blockReorgDepth as u } from "../../../constants/reorg-depths.constants.mjs";
3
+ import { Logger as v } from "../../../error-handling/logger.mjs";
4
+ import { getSequence as d, resolveSync as c } from "../../../functions/utils/resolve-sync.utils.mjs";
5
+ import { BlockchainEvent as m } from "../../BlockchainEvent/BlockchainEvent.mjs";
6
+ import { getProviderFromContract as h } from "../../../functions/utils/getSignerFromContract.mjs";
7
+ class k {
8
+ RETRY_MIN_PAGE_SIZE = 100;
9
+ MAX_RETRIES = 20;
10
+ _chainId;
7
11
  contract;
8
12
  depositOnChainUtxosContract;
9
13
  _latestBlockNumber;
@@ -11,84 +15,106 @@ class b {
11
15
  onEventsProcessed;
12
16
  eventProcessors = /* @__PURE__ */ new Set();
13
17
  maxPageSize;
14
- isReady = !1;
18
+ _isReady = !1;
15
19
  isServer;
16
- intervalId;
17
20
  inProgress;
18
21
  // to remove race conditions
19
22
  eventsFetchingMutex;
20
- constructor(t, r, h, s, i, n = E) {
21
- this.contract = t, this.depositOnChainUtxosContract = i, this._initialBlockNumber = r, this.maxPageSize = s, this.isServer = h, this.inProgress = !1, this.eventsFetchingMutex = n;
23
+ constructor(t, s, r, e, i, n, a) {
24
+ this.contract = s, this.depositOnChainUtxosContract = a, this._chainId = t, this._initialBlockNumber = r, this.maxPageSize = n, this.isServer = e, this.inProgress = !1, this.eventsFetchingMutex = i;
22
25
  }
23
26
  get latestBlockNumber() {
24
27
  return this._latestBlockNumber ?? this._initialBlockNumber;
25
28
  }
29
+ get chainId() {
30
+ return this._chainId;
31
+ }
32
+ get isReady() {
33
+ return this._isReady;
34
+ }
26
35
  syncFromAtMost(t) {
27
36
  (this._latestBlockNumber === void 0 || t < this._latestBlockNumber) && (this._latestBlockNumber = t);
28
37
  }
38
+ advanceLatestBlockNumber(t) {
39
+ const s = this._latestBlockNumber ?? this._initialBlockNumber;
40
+ t > s && (this._latestBlockNumber = t);
41
+ }
29
42
  intervalClear() {
30
- this.isReady = !1, this.eventProcessors = /* @__PURE__ */ new Set(), clearInterval(this.intervalId);
43
+ this._isReady = !1, this.eventProcessors = /* @__PURE__ */ new Set(), this.clear();
31
44
  }
32
45
  async init() {
33
- if (this.isReady)
46
+ if (this._isReady)
34
47
  throw new Error("Already initialized");
35
- this.isReady = !0, await this.retrieveEvents(this.latestBlockNumber + 1), this.intervalId = setInterval(async () => {
36
- await this.retrieveEvents(this.latestBlockNumber);
37
- }, 3500);
48
+ this._isReady = !0, await this.retrieveEvents(this.latestBlockNumber + 1), this.startUpdateListener();
38
49
  }
39
50
  requireReady() {
40
- if (!this.isReady)
51
+ if (!this._isReady)
41
52
  throw new Error("Not ready");
42
53
  }
54
+ async getEventsForSingleContract(t, s, r, e = 0) {
55
+ try {
56
+ return (await t.queryFilter("*", s, r)).filter(
57
+ (i) => i instanceof l.EventLog
58
+ );
59
+ } catch (i) {
60
+ if (e < this.MAX_RETRIES && r - s > this.RETRY_MIN_PAGE_SIZE) {
61
+ const n = Math.floor((s + r) / 2), a = await this.getEventsForSingleContract(t, s, n, e + 1), o = await this.getEventsForSingleContract(t, n + 1, r, e + 1);
62
+ return [...a, ...o];
63
+ }
64
+ throw i;
65
+ }
66
+ }
43
67
  addEventProcessorFunction(t) {
44
- if (this.isReady)
68
+ if (this._isReady)
45
69
  throw new Error("Can't add event processor after event emitter initialized");
46
70
  this.eventProcessors.add(t);
47
71
  }
72
+ async getEventsInRange(t, s) {
73
+ const r = [], e = d(t, s, this.maxPageSize);
74
+ await c(
75
+ e.map(({ from: n, to: a }) => async () => {
76
+ const o = await this.getEventsForSingleContract(this.contract, n, a);
77
+ r.push(...o);
78
+ })
79
+ );
80
+ const i = this.depositOnChainUtxosContract;
81
+ return i && await c(
82
+ e.map(({ from: n, to: a }) => async () => {
83
+ const o = await this.getEventsForSingleContract(i, n, a);
84
+ r.push(...o);
85
+ })
86
+ ), r.map((n) => m.fromEthers(n));
87
+ }
48
88
  async getLastBlockNumberForEventRequest() {
49
- const t = await m(this.contract).getBlockNumber();
89
+ const t = await h(this.contract).getBlockNumber();
50
90
  if (!this.isServer)
51
91
  return t;
52
- const { chainId: r } = await m(this.contract).getNetwork();
53
- return Math.max(this.latestBlockNumber, t - g[Number(r)] + 1);
92
+ const { chainId: s } = await h(this.contract).getNetwork();
93
+ return Math.max(this.latestBlockNumber, t - u[Number(s)] + 1);
54
94
  }
55
- async retrieveEvents(t, r = !1) {
95
+ async retrieveEvents(t, s = !1) {
56
96
  return this.requireReady(), await this.eventsFetchingMutex.runExclusive(async () => {
57
97
  try {
58
- if (this.inProgress && !r)
98
+ if (this.inProgress && !s)
59
99
  return !1;
60
100
  this.inProgress = !0;
61
- let s = 0;
62
- const i = await this.getLastBlockNumberForEventRequest();
63
- if (i < t)
101
+ const e = await this.getLastBlockNumberForEventRequest();
102
+ if (e < t)
64
103
  return this.inProgress = !1, !1;
65
- const n = y(t, i, this.maxPageSize), o = [];
66
- if (await v(
67
- n.map(({ from: e, to: a }) => async () => {
68
- const c = (await this.contract.queryFilter("*", e, a)).filter(
69
- (l) => l instanceof u.EventLog
70
- );
71
- o.push(...c);
72
- })
73
- ), this.depositOnChainUtxosContract) {
74
- const { depositOnChainUtxosContract: e } = this;
75
- await v(
76
- n.map(({ from: a, to: c }) => async () => {
77
- const l = (await e.queryFilter("*", a, c)).filter((f) => f instanceof u.EventLog);
78
- o.push(...l);
79
- })
80
- );
81
- }
82
- const d = await Promise.all(
83
- [...this.eventProcessors].map((e) => e(o))
84
- );
85
- return this._latestBlockNumber = i, s += d.reduce((e, a) => e + a, 0), this.onEventsProcessed?.(s), this.inProgress = !1, !0;
86
- } catch (s) {
87
- return console.log("retrieveEvents error:", { err: s }), this.inProgress = !1, !1;
104
+ const i = await this.getEventsInRange(t, e);
105
+ return await this.processEvents(i), this._latestBlockNumber = e, this.inProgress = !1, !0;
106
+ } catch (e) {
107
+ return v.error("retrieveEvents error", e), this.inProgress = !1, !1;
88
108
  }
89
109
  });
90
110
  }
111
+ async processEvents(t) {
112
+ const r = (await Promise.all(
113
+ [...this.eventProcessors].map((e) => e(t))
114
+ )).reduce((e, i) => e + i, 0);
115
+ this.onEventsProcessed?.(r);
116
+ }
91
117
  }
92
118
  export {
93
- b as BlockchainEventEmitter
119
+ k as BlockchainEventEmitter
94
120
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./BlockchainEventEmitter.cjs"),a=require("../helpers/ClientEventHelper.cjs");class E extends c.BlockchainEventEmitter{clientEventHelper;constructor(e,t,n,i,r,s,l){super(t,n,i,!1,r,s,l),this.clientEventHelper=new a.ClientEventHelper(t,e)}clear(){this.clientEventHelper.clear()}startUpdateListener(){this.clientEventHelper.startUpdateListener(async e=>{await this.eventsFetchingMutex.runExclusive(async()=>{await this.processEvents(e)})},this.latestBlockNumber+1,e=>this.advanceLatestBlockNumber(e))}}exports.ClientBlockchainEventEmitter=E;
@@ -0,0 +1,11 @@
1
+ import { ethers } from 'ethers';
2
+ import { EventCategory } from '../../../types/events.types';
3
+ import { BlockchainEventEmitter } from './BlockchainEventEmitter';
4
+ import { Mutex } from 'async-mutex';
5
+ import { ClientEventHelper } from '../helpers/ClientEventHelper';
6
+ export declare class ClientBlockchainEventEmitter extends BlockchainEventEmitter {
7
+ clientEventHelper: ClientEventHelper;
8
+ constructor(eventCategory: EventCategory, chainId: number, contract: ethers.Contract, initialBlockNumber: number, eventsFetchingMutex: Mutex, maxPageSize?: number, depositOnChainUtxosContract?: ethers.Contract);
9
+ protected clear(): void;
10
+ protected startUpdateListener(): void;
11
+ }