@hinkal/common 0.2.12 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (574) hide show
  1. package/API/API.cjs +1 -1
  2. package/API/API.d.ts +9 -3
  3. package/API/API.mjs +44 -34
  4. package/API/ai-calls.cjs +1 -0
  5. package/API/ai-calls.d.ts +9 -0
  6. package/API/ai-calls.mjs +13 -0
  7. package/API/callCurveAPI.cjs +1 -1
  8. package/API/callCurveAPI.mjs +28 -22
  9. package/API/callRelayer.d.ts +3 -2
  10. package/API/dataServerCalls.cjs +1 -1
  11. package/API/dataServerCalls.d.ts +4 -0
  12. package/API/dataServerCalls.mjs +11 -7
  13. package/API/duneAPI.cjs +1 -1
  14. package/API/duneAPI.mjs +6 -4
  15. package/API/fetchCommitmentsCache.cjs +1 -1
  16. package/API/fetchCommitmentsCache.d.ts +9 -1
  17. package/API/fetchCommitmentsCache.mjs +6 -5
  18. package/API/getGasEstimates.cjs +1 -1
  19. package/API/getGasEstimates.d.ts +2 -1
  20. package/API/getGasEstimates.mjs +10 -9
  21. package/API/getServerURL.d.ts +1 -1
  22. package/API/index.d.ts +2 -0
  23. package/API/is-tx-stateless.cjs +1 -0
  24. package/API/is-tx-stateless.d.ts +3 -0
  25. package/API/is-tx-stateless.mjs +9 -0
  26. package/API/kycCalls.cjs +1 -1
  27. package/API/kycCalls.d.ts +0 -4
  28. package/API/kycCalls.mjs +11 -15
  29. package/API/rewardsPointsCalls.d.ts +0 -3
  30. package/API/tenderly.api.cjs +1 -0
  31. package/API/tenderly.api.d.ts +12 -0
  32. package/API/tenderly.api.mjs +47 -0
  33. package/API/token-calls.cjs +1 -0
  34. package/API/token-calls.d.ts +2 -0
  35. package/API/token-calls.mjs +9 -0
  36. package/README.md +0 -61
  37. package/constants/addresses.constants.cjs +1 -0
  38. package/constants/addresses.constants.d.ts +16 -0
  39. package/constants/addresses.constants.mjs +50 -0
  40. package/constants/assets.constants.cjs +1 -1
  41. package/constants/assets.constants.mjs +13 -13
  42. package/constants/axelar.constants.cjs +1 -1
  43. package/constants/axelar.constants.mjs +5 -5
  44. package/constants/balance.constants.cjs +1 -0
  45. package/constants/balance.constants.d.ts +1 -0
  46. package/constants/balance.constants.mjs +4 -0
  47. package/constants/chains.constants.cjs +1 -1
  48. package/constants/chains.constants.d.ts +0 -2
  49. package/constants/chains.constants.mjs +26 -38
  50. package/constants/contracts.constants.cjs +1 -1
  51. package/constants/contracts.constants.mjs +108 -108
  52. package/constants/conversion.constants.cjs +1 -0
  53. package/constants/conversion.constants.d.ts +1 -0
  54. package/constants/conversion.constants.mjs +4 -0
  55. package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
  56. package/constants/deploy-data/deploy-data-localhost.json.mjs +1652 -829
  57. package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
  58. package/constants/deploy-data/deploy-data-optimism.json.mjs +9707 -3957
  59. package/constants/fees.constants.cjs +1 -1
  60. package/constants/fees.constants.d.ts +5 -3
  61. package/constants/fees.constants.mjs +22 -19
  62. package/constants/index.d.ts +6 -0
  63. package/constants/mediaUrls.constants.cjs +1 -0
  64. package/constants/mediaUrls.constants.d.ts +23 -0
  65. package/constants/mediaUrls.constants.mjs +26 -0
  66. package/constants/permit2.constants.cjs +1 -0
  67. package/constants/permit2.constants.d.ts +2 -0
  68. package/constants/permit2.constants.mjs +5 -0
  69. package/constants/protocol.constants.cjs +1 -1
  70. package/constants/protocol.constants.d.ts +6 -0
  71. package/constants/protocol.constants.mjs +27 -15
  72. package/constants/rewards.constants.cjs +1 -1
  73. package/constants/rewards.constants.d.ts +0 -1
  74. package/constants/rewards.constants.mjs +14 -13
  75. package/constants/server.constants.cjs +1 -1
  76. package/constants/server.constants.d.ts +8 -3
  77. package/constants/server.constants.mjs +16 -11
  78. package/constants/token-data/ERC20Registry.cjs +1 -1
  79. package/constants/token-data/ERC20Registry.mjs +10 -9
  80. package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
  81. package/constants/token-data/arbMainnetRegistry.json.mjs +88 -88
  82. package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
  83. package/constants/token-data/arbMainnetRegistryFixed.json.mjs +78 -78
  84. package/constants/token-data/avalancheRegistry.json.cjs +1 -1
  85. package/constants/token-data/avalancheRegistry.json.mjs +49 -49
  86. package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
  87. package/constants/token-data/avalancheRegistryFixed.json.mjs +49 -49
  88. package/constants/token-data/baseRegistry.json.cjs +1 -1
  89. package/constants/token-data/baseRegistry.json.mjs +32 -32
  90. package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
  91. package/constants/token-data/baseRegistryFixed.json.mjs +29 -29
  92. package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
  93. package/constants/token-data/bnbMainnetRegistry.json.mjs +65 -65
  94. package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
  95. package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +65 -65
  96. package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
  97. package/constants/token-data/ethMainnetRegistry.json.mjs +227 -227
  98. package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
  99. package/constants/token-data/ethMainnetRegistryFixed.json.mjs +191 -191
  100. package/constants/token-data/index.d.ts +91 -0
  101. package/constants/token-data/localhostRegistry.json.cjs +1 -1
  102. package/constants/token-data/localhostRegistry.json.mjs +294 -277
  103. package/constants/token-data/optimismRegistry.json.cjs +1 -1
  104. package/constants/token-data/optimismRegistry.json.mjs +702 -182
  105. package/constants/token-data/optimismRegistryFixed.json.cjs +1 -1
  106. package/constants/token-data/optimismRegistryFixed.json.mjs +678 -175
  107. package/constants/token-data/polygonRegistry.json.cjs +1 -1
  108. package/constants/token-data/polygonRegistry.json.mjs +109 -109
  109. package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
  110. package/constants/token-data/polygonRegistryFixed.json.mjs +101 -101
  111. package/constants/token.limits.constants.cjs +1 -0
  112. package/constants/token.limits.constants.d.ts +5 -0
  113. package/constants/token.limits.constants.mjs +30 -0
  114. package/constants/vite.constants.cjs +1 -1
  115. package/constants/vite.constants.d.ts +5 -0
  116. package/constants/vite.constants.mjs +26 -22
  117. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  118. package/data-structures/Hinkal/Hinkal.d.ts +46 -21
  119. package/data-structures/Hinkal/Hinkal.mjs +260 -92
  120. package/data-structures/Hinkal/IHinkal.d.ts +35 -11
  121. package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
  122. package/data-structures/Hinkal/hinkalActionBeefy.mjs +5 -4
  123. package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
  124. package/data-structures/Hinkal/hinkalActionConvex.mjs +4 -3
  125. package/data-structures/Hinkal/hinkalActionCurve.cjs +1 -1
  126. package/data-structures/Hinkal/hinkalActionCurve.mjs +5 -4
  127. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +1 -0
  128. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +3 -0
  129. package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +61 -0
  130. package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
  131. package/data-structures/Hinkal/hinkalActionLidoEth.mjs +9 -8
  132. package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
  133. package/data-structures/Hinkal/hinkalActionPendle.mjs +17 -16
  134. package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
  135. package/data-structures/Hinkal/hinkalActionPendleLP.mjs +14 -12
  136. package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -0
  137. package/data-structures/Hinkal/hinkalActionReceive.d.ts +4 -0
  138. package/data-structures/Hinkal/hinkalActionReceive.mjs +39 -0
  139. package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
  140. package/data-structures/Hinkal/hinkalActionStake.mjs +12 -9
  141. package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
  142. package/data-structures/Hinkal/hinkalActionVolatile.mjs +25 -21
  143. package/data-structures/Hinkal/hinkalApprove.cjs +1 -0
  144. package/data-structures/Hinkal/hinkalApprove.d.ts +2 -0
  145. package/data-structures/Hinkal/hinkalApprove.mjs +120 -0
  146. package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -0
  147. package/data-structures/Hinkal/hinkalCheckTokenRegistry.d.ts +3 -0
  148. package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -0
  149. package/data-structures/Hinkal/hinkalDeploySubAccount.cjs +1 -0
  150. package/data-structures/Hinkal/hinkalDeploySubAccount.d.ts +3 -0
  151. package/data-structures/Hinkal/hinkalDeploySubAccount.mjs +15 -0
  152. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  153. package/data-structures/Hinkal/hinkalDeposit.d.ts +3 -2
  154. package/data-structures/Hinkal/hinkalDeposit.mjs +96 -71
  155. package/data-structures/Hinkal/hinkalGetRecipientInfo.cjs +1 -1
  156. package/data-structures/Hinkal/hinkalGetRecipientInfo.d.ts +1 -1
  157. package/data-structures/Hinkal/hinkalGetRecipientInfo.mjs +5 -11
  158. package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
  159. package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +6 -18
  160. package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -0
  161. package/data-structures/Hinkal/hinkalInsideTransact.d.ts +2 -0
  162. package/data-structures/Hinkal/hinkalInsideTransact.mjs +111 -0
  163. package/data-structures/Hinkal/hinkalMultiSend.cjs +1 -0
  164. package/data-structures/Hinkal/hinkalMultiSend.d.ts +3 -0
  165. package/data-structures/Hinkal/hinkalMultiSend.mjs +13 -0
  166. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  167. package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -1
  168. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +83 -38
  169. package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -0
  170. package/data-structures/Hinkal/hinkalProoflessDeposit.d.ts +4 -0
  171. package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +46 -0
  172. package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -0
  173. package/data-structures/Hinkal/hinkalProxySwap.d.ts +5 -0
  174. package/data-structures/Hinkal/hinkalProxySwap.mjs +36 -0
  175. package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -0
  176. package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +3 -0
  177. package/data-structures/Hinkal/hinkalSignSubAccount.mjs +20 -0
  178. package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
  179. package/data-structures/Hinkal/hinkalSwap.d.ts +2 -1
  180. package/data-structures/Hinkal/hinkalSwap.mjs +68 -60
  181. package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
  182. package/data-structures/Hinkal/hinkalWithdraw.d.ts +3 -1
  183. package/data-structures/Hinkal/hinkalWithdraw.mjs +76 -50
  184. package/data-structures/Hinkal/index.d.ts +1 -0
  185. package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
  186. package/data-structures/Hinkal/resetMerkleTrees.mjs +18 -11
  187. package/data-structures/IndexedDB/activity-db.cjs +1 -0
  188. package/data-structures/IndexedDB/activity-db.d.ts +16 -0
  189. package/data-structures/IndexedDB/activity-db.mjs +124 -0
  190. package/data-structures/IndexedDB/balances-db.cjs +1 -0
  191. package/data-structures/IndexedDB/balances-db.d.ts +13 -0
  192. package/data-structures/IndexedDB/balances-db.mjs +75 -0
  193. package/data-structures/IndexedDB/contact-db.cjs +1 -0
  194. package/data-structures/IndexedDB/contact-db.d.ts +11 -0
  195. package/data-structures/IndexedDB/contact-db.mjs +44 -0
  196. package/data-structures/IndexedDB/index.d.ts +5 -0
  197. package/data-structures/IndexedDB/prices-db.cjs +1 -0
  198. package/data-structures/IndexedDB/prices-db.d.ts +9 -0
  199. package/data-structures/IndexedDB/prices-db.mjs +62 -0
  200. package/data-structures/IndexedDB/private-balances-db.cjs +1 -0
  201. package/data-structures/IndexedDB/private-balances-db.d.ts +9 -0
  202. package/data-structures/IndexedDB/private-balances-db.mjs +28 -0
  203. package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs +1 -1
  204. package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs +47 -44
  205. package/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -0
  206. package/data-structures/TokenDBs/PrivateTokensDB.d.ts +11 -0
  207. package/data-structures/TokenDBs/PrivateTokensDB.mjs +53 -0
  208. package/data-structures/TokenDBs/PublicTokensDB.cjs +1 -0
  209. package/data-structures/TokenDBs/PublicTokensDB.d.ts +13 -0
  210. package/data-structures/TokenDBs/PublicTokensDB.mjs +81 -0
  211. package/data-structures/TokenDBs/index.d.ts +2 -0
  212. package/data-structures/cacheDevices/AttachableMemoryCacheDevice.cjs +1 -0
  213. package/data-structures/cacheDevices/AttachableMemoryCacheDevice.d.ts +8 -0
  214. package/data-structures/cacheDevices/AttachableMemoryCacheDevice.mjs +28 -0
  215. package/data-structures/cacheDevices/BaseCacheDevice.cjs +1 -1
  216. package/data-structures/cacheDevices/BaseCacheDevice.d.ts +9 -6
  217. package/data-structures/cacheDevices/BaseCacheDevice.mjs +13 -4
  218. package/data-structures/cacheDevices/FileCacheDevice.cjs +1 -1
  219. package/data-structures/cacheDevices/FileCacheDevice.d.ts +1 -0
  220. package/data-structures/cacheDevices/FileCacheDevice.mjs +7 -3
  221. package/data-structures/cacheDevices/LocalStorageCacheDevice.cjs +1 -1
  222. package/data-structures/cacheDevices/LocalStorageCacheDevice.d.ts +2 -1
  223. package/data-structures/cacheDevices/LocalStorageCacheDevice.mjs +10 -5
  224. package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
  225. package/data-structures/crypto-keys/decodeUTXO.mjs +13 -12
  226. package/data-structures/crypto-keys/keys.cjs +1 -1
  227. package/data-structures/crypto-keys/keys.d.ts +13 -3
  228. package/data-structures/crypto-keys/keys.mjs +45 -34
  229. package/data-structures/custom-token-registry/CustomTokenRegistry.cjs +1 -1
  230. package/data-structures/custom-token-registry/CustomTokenRegistry.d.ts +2 -3
  231. package/data-structures/custom-token-registry/CustomTokenRegistry.mjs +17 -21
  232. package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
  233. package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +15 -29
  234. package/data-structures/event-service/AbstractApprovalsSnapshotService.cjs +1 -0
  235. package/data-structures/event-service/AbstractApprovalsSnapshotService.d.ts +30 -0
  236. package/data-structures/event-service/AbstractApprovalsSnapshotService.mjs +104 -0
  237. package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -1
  238. package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +24 -37
  239. package/data-structures/event-service/AbstractEventService.cjs +1 -1
  240. package/data-structures/event-service/AbstractEventService.d.ts +1 -1
  241. package/data-structures/event-service/AbstractEventService.mjs +34 -46
  242. package/data-structures/event-service/index.d.ts +1 -0
  243. package/data-structures/index.d.ts +2 -0
  244. package/data-structures/merkle-tree/MerkleTree.cjs +1 -1
  245. package/data-structures/merkle-tree/MerkleTree.d.ts +4 -1
  246. package/data-structures/merkle-tree/MerkleTree.mjs +66 -65
  247. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +1 -1
  248. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +1 -1
  249. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +10 -6
  250. package/data-structures/provider-adapter/IProviderAdapter.d.ts +2 -0
  251. package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
  252. package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +6 -10
  253. package/data-structures/snapshot/ClientApprovalsSnapshotService.cjs +1 -0
  254. package/data-structures/snapshot/ClientApprovalsSnapshotService.d.ts +8 -0
  255. package/data-structures/snapshot/ClientApprovalsSnapshotService.mjs +23 -0
  256. package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
  257. package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +6 -10
  258. package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
  259. package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +6 -10
  260. package/data-structures/token-price-fetcher/TokenChecker.cjs +1 -1
  261. package/data-structures/token-price-fetcher/TokenChecker.d.ts +1 -0
  262. package/data-structures/token-price-fetcher/TokenChecker.mjs +4 -2
  263. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  264. package/data-structures/transactions-manager/TransactionsManager.d.ts +6 -5
  265. package/data-structures/transactions-manager/TransactionsManager.mjs +95 -100
  266. package/data-structures/transactions-manager/history/getBeefyData.cjs +1 -1
  267. package/data-structures/transactions-manager/history/getBeefyData.mjs +3 -2
  268. package/data-structures/transactions-manager/history/getConvexData.cjs +1 -1
  269. package/data-structures/transactions-manager/history/getConvexData.mjs +3 -2
  270. package/data-structures/transactions-manager/history/getCurveData.cjs +1 -1
  271. package/data-structures/transactions-manager/history/getCurveData.mjs +3 -2
  272. package/data-structures/transactions-manager/history/getLidoData.cjs +1 -1
  273. package/data-structures/transactions-manager/history/getLidoData.mjs +3 -2
  274. package/data-structures/transactions-manager/history/getPendleData.cjs +1 -1
  275. package/data-structures/transactions-manager/history/getPendleData.mjs +13 -12
  276. package/data-structures/transactions-manager/history/getTxDetails.cjs +1 -1
  277. package/data-structures/transactions-manager/history/getTxDetails.mjs +22 -20
  278. package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
  279. package/data-structures/transactions-manager/history/getVolatileData.mjs +11 -10
  280. package/data-structures/transactions-manager/history/history.types.cjs +1 -1
  281. package/data-structures/transactions-manager/history/history.types.mjs +4 -2
  282. package/data-structures/utxo/Utxo.cjs +1 -1
  283. package/data-structures/utxo/Utxo.d.ts +3 -3
  284. package/data-structures/utxo/Utxo.mjs +8 -7
  285. package/error-handling/error-codes.constants.cjs +2 -2
  286. package/error-handling/error-codes.constants.d.ts +20 -3
  287. package/error-handling/error-codes.constants.mjs +139 -126
  288. package/error-handling/get-error.message.cjs +1 -1
  289. package/error-handling/get-error.message.mjs +29 -25
  290. package/error-handling/index.d.ts +1 -0
  291. package/error-handling/logger.cjs +1 -0
  292. package/error-handling/logger.d.ts +5 -0
  293. package/error-handling/logger.mjs +16 -0
  294. package/error-handling/types.cjs +1 -1
  295. package/error-handling/types.d.ts +3 -1
  296. package/error-handling/types.mjs +2 -2
  297. package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -0
  298. package/functions/pre-transaction/getExternalSwapAddress.d.ts +3 -0
  299. package/functions/pre-transaction/getExternalSwapAddress.mjs +26 -0
  300. package/functions/pre-transaction/getFeeStructure.cjs +1 -0
  301. package/functions/pre-transaction/getFeeStructure.d.ts +4 -0
  302. package/functions/pre-transaction/getFeeStructure.mjs +30 -0
  303. package/functions/pre-transaction/getFlatFees.cjs +1 -1
  304. package/functions/pre-transaction/getFlatFees.d.ts +3 -7
  305. package/functions/pre-transaction/getFlatFees.mjs +52 -46
  306. package/functions/pre-transaction/getSignatureDataForTransact.cjs +1 -0
  307. package/functions/pre-transaction/getSignatureDataForTransact.d.ts +3 -0
  308. package/functions/pre-transaction/getSignatureDataForTransact.mjs +6 -0
  309. package/functions/pre-transaction/index.d.ts +1 -0
  310. package/functions/pre-transaction/interaction-to-action.cjs +1 -1
  311. package/functions/pre-transaction/interaction-to-action.mjs +3 -2
  312. package/functions/pre-transaction/merge-with-fee-structure.cjs +1 -0
  313. package/functions/pre-transaction/merge-with-fee-structure.d.ts +2 -0
  314. package/functions/pre-transaction/merge-with-fee-structure.mjs +25 -0
  315. package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -0
  316. package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +16 -0
  317. package/functions/pre-transaction/outputApprovalDataProcessing.mjs +42 -0
  318. package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
  319. package/functions/pre-transaction/outputUtxoProcessing.d.ts +1 -1
  320. package/functions/pre-transaction/outputUtxoProcessing.mjs +19 -30
  321. package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
  322. package/functions/pre-transaction/process-gas-estimates.d.ts +2 -2
  323. package/functions/pre-transaction/process-gas-estimates.mjs +17 -28
  324. package/functions/pre-transaction/processAmountChanges.cjs +1 -1
  325. package/functions/pre-transaction/processAmountChanges.mjs +34 -23
  326. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -0
  327. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +6 -0
  328. package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +7 -0
  329. package/functions/private-wallet/emporium.helpers.cjs +1 -1
  330. package/functions/private-wallet/emporium.helpers.d.ts +17 -4
  331. package/functions/private-wallet/emporium.helpers.mjs +119 -12
  332. package/functions/private-wallet/emporium.swap.helpers.cjs +1 -0
  333. package/functions/private-wallet/emporium.swap.helpers.d.ts +5 -0
  334. package/functions/private-wallet/emporium.swap.helpers.mjs +92 -0
  335. package/functions/private-wallet/index.d.ts +2 -0
  336. package/functions/private-wallet/opProducer.cjs +1 -1
  337. package/functions/private-wallet/opProducer.mjs +1 -1
  338. package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -0
  339. package/functions/private-wallet/smartContractWalletCalculator.d.ts +5 -0
  340. package/functions/private-wallet/smartContractWalletCalculator.mjs +25 -0
  341. package/functions/protocols/convex.protocols.cjs +1 -1
  342. package/functions/protocols/convex.protocols.mjs +10 -8
  343. package/functions/protocols/pendle.helpers.cjs +1 -1
  344. package/functions/protocols/pendle.helpers.mjs +16 -12
  345. package/functions/snarkjs/common.snarkjs.cjs +1 -1
  346. package/functions/snarkjs/common.snarkjs.d.ts +8 -5
  347. package/functions/snarkjs/common.snarkjs.mjs +177 -87
  348. package/functions/snarkjs/constant.cjs +1 -1
  349. package/functions/snarkjs/constant.d.ts +223 -2
  350. package/functions/snarkjs/constant.mjs +313 -93
  351. package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
  352. package/functions/snarkjs/constructEmporiumProof.d.ts +6 -3
  353. package/functions/snarkjs/constructEmporiumProof.mjs +148 -84
  354. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  355. package/functions/snarkjs/constructGeneralZkProof.d.ts +5 -3
  356. package/functions/snarkjs/constructGeneralZkProof.mjs +141 -86
  357. package/functions/snarkjs/generateCircomData.cjs +1 -1
  358. package/functions/snarkjs/generateCircomData.d.ts +3 -2
  359. package/functions/snarkjs/generateCircomData.mjs +33 -35
  360. package/functions/snarkjs/generateZkProof.cjs +1 -1
  361. package/functions/snarkjs/generateZkProof.d.ts +2 -2
  362. package/functions/snarkjs/generateZkProof.mjs +4 -4
  363. package/functions/snarkjs/generateZkProofEnclave.cjs +1 -1
  364. package/functions/snarkjs/generateZkProofEnclave.d.ts +2 -1
  365. package/functions/snarkjs/generateZkProofEnclave.mjs +22 -29
  366. package/functions/snarkjs/generateZkProofSelf.cjs +1 -1
  367. package/functions/snarkjs/generateZkProofSelf.d.ts +2 -2
  368. package/functions/snarkjs/generateZkProofSelf.mjs +10 -10
  369. package/functions/snarkjs/getOriginalSender.cjs +1 -0
  370. package/functions/snarkjs/getOriginalSender.d.ts +1 -0
  371. package/functions/snarkjs/getOriginalSender.mjs +5 -0
  372. package/functions/snarkjs/getZKFiles.cjs +1 -1
  373. package/functions/snarkjs/getZKFiles.d.ts +3 -2
  374. package/functions/snarkjs/getZKFiles.mjs +14 -5
  375. package/functions/utils/addresses.cjs +1 -0
  376. package/functions/utils/addresses.d.ts +4 -0
  377. package/functions/utils/addresses.mjs +20 -0
  378. package/functions/utils/amounts.utils.cjs +1 -1
  379. package/functions/utils/amounts.utils.d.ts +4 -1
  380. package/functions/utils/amounts.utils.mjs +29 -27
  381. package/functions/utils/arraysMatch.cjs +1 -0
  382. package/functions/utils/arraysMatch.d.ts +1 -0
  383. package/functions/utils/arraysMatch.mjs +4 -0
  384. package/functions/utils/axelar.utils.cjs +1 -1
  385. package/functions/utils/axelar.utils.d.ts +1 -0
  386. package/functions/utils/axelar.utils.mjs +31 -9
  387. package/functions/utils/cacheDevice.utils.cjs +1 -1
  388. package/functions/utils/cacheDevice.utils.mjs +5 -3
  389. package/functions/utils/cacheFunctions.cjs +1 -1
  390. package/functions/utils/cacheFunctions.d.ts +10 -7
  391. package/functions/utils/cacheFunctions.mjs +62 -39
  392. package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -0
  393. package/functions/utils/convertEmporiumOpToCallInfo.d.ts +2 -0
  394. package/functions/utils/convertEmporiumOpToCallInfo.mjs +10 -0
  395. package/functions/utils/convertIntegrationProviderToExternalActionId.cjs +1 -1
  396. package/functions/utils/convertIntegrationProviderToExternalActionId.d.ts +2 -1
  397. package/functions/utils/convertIntegrationProviderToExternalActionId.mjs +7 -10
  398. package/functions/utils/encodeTokenWithId.cjs +1 -0
  399. package/functions/utils/encodeTokenWithId.d.ts +2 -0
  400. package/functions/utils/encodeTokenWithId.mjs +4 -0
  401. package/functions/utils/encryptInputForEnclave.cjs +1 -0
  402. package/functions/utils/encryptInputForEnclave.d.ts +8 -0
  403. package/functions/utils/encryptInputForEnclave.mjs +43 -0
  404. package/functions/utils/erc20tokenFunctions.cjs +1 -1
  405. package/functions/utils/erc20tokenFunctions.d.ts +8 -2
  406. package/functions/utils/erc20tokenFunctions.mjs +22 -14
  407. package/functions/utils/evmNetworkFunctions.cjs +1 -1
  408. package/functions/utils/evmNetworkFunctions.mjs +6 -4
  409. package/functions/utils/external-action.utils.d.ts +2 -2
  410. package/functions/utils/fees.utils.cjs +1 -0
  411. package/functions/utils/fees.utils.d.ts +2 -0
  412. package/functions/utils/fees.utils.mjs +14 -0
  413. package/functions/utils/getBlockExplorerUrl.cjs +1 -0
  414. package/functions/utils/getBlockExplorerUrl.d.ts +1 -0
  415. package/functions/utils/getBlockExplorerUrl.mjs +6 -0
  416. package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -0
  417. package/functions/utils/getRecipientInfoFromUserKeys.d.ts +3 -0
  418. package/functions/utils/getRecipientInfoFromUserKeys.mjs +18 -0
  419. package/functions/utils/index.d.ts +12 -0
  420. package/functions/utils/involves-permit2-op.cjs +1 -0
  421. package/functions/utils/involves-permit2-op.d.ts +1 -0
  422. package/functions/utils/involves-permit2-op.mjs +5 -0
  423. package/functions/utils/merkleTree.utils.cjs +1 -0
  424. package/functions/utils/merkleTree.utils.d.ts +2 -0
  425. package/functions/utils/merkleTree.utils.mjs +19 -0
  426. package/functions/utils/prepareHinkal.d.ts +6 -0
  427. package/functions/utils/processUseApprovalUtxoData.cjs +1 -0
  428. package/functions/utils/processUseApprovalUtxoData.d.ts +3 -0
  429. package/functions/utils/processUseApprovalUtxoData.mjs +19 -0
  430. package/functions/utils/publicBalance.utils.cjs +1 -0
  431. package/functions/utils/publicBalance.utils.d.ts +5 -0
  432. package/functions/utils/publicBalance.utils.mjs +25 -0
  433. package/functions/utils/replaceAddressInCalldata.cjs +1 -0
  434. package/functions/utils/replaceAddressInCalldata.d.ts +1 -0
  435. package/functions/utils/replaceAddressInCalldata.mjs +7 -0
  436. package/functions/utils/rpc-int-encode.cjs +1 -0
  437. package/functions/utils/rpc-int-encode.d.ts +2 -0
  438. package/functions/utils/rpc-int-encode.mjs +8 -0
  439. package/functions/utils/serialize.utils.cjs +1 -1
  440. package/functions/utils/serialize.utils.d.ts +1 -0
  441. package/functions/utils/serialize.utils.mjs +3 -2
  442. package/functions/utils/string.utils.cjs +1 -1
  443. package/functions/utils/string.utils.d.ts +3 -0
  444. package/functions/utils/string.utils.mjs +31 -7
  445. package/functions/utils/time.utils.cjs +1 -1
  446. package/functions/utils/time.utils.d.ts +1 -0
  447. package/functions/utils/time.utils.mjs +4 -3
  448. package/functions/utils/token-check.utils.cjs +1 -0
  449. package/functions/utils/token-check.utils.d.ts +1 -0
  450. package/functions/utils/token-check.utils.mjs +10 -0
  451. package/functions/utils/upToDateState.cjs +1 -0
  452. package/functions/utils/upToDateState.d.ts +2 -0
  453. package/functions/utils/upToDateState.mjs +11 -0
  454. package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -0
  455. package/functions/web3/events/balanceChangedCustomHandler.d.ts +2 -0
  456. package/functions/web3/events/balanceChangedCustomHandler.mjs +14 -0
  457. package/functions/web3/events/balanceChangedHandler.cjs +1 -1
  458. package/functions/web3/events/balanceChangedHandler.mjs +5 -4
  459. package/functions/web3/events/getApprovedBalance.cjs +1 -0
  460. package/functions/web3/events/getApprovedBalance.d.ts +7 -0
  461. package/functions/web3/events/getApprovedBalance.mjs +80 -0
  462. package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
  463. package/functions/web3/events/getInputUtxoAndBalance.d.ts +16 -3
  464. package/functions/web3/events/getInputUtxoAndBalance.mjs +128 -46
  465. package/functions/web3/events/getShieldedBalance.cjs +2 -2
  466. package/functions/web3/events/getShieldedBalance.d.ts +1 -1
  467. package/functions/web3/events/getShieldedBalance.mjs +79 -82
  468. package/functions/web3/events/index.d.ts +2 -0
  469. package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
  470. package/functions/web3/functionCalls/accessTokenCalls.d.ts +2 -2
  471. package/functions/web3/functionCalls/accessTokenCalls.mjs +19 -17
  472. package/functions/web3/functionCalls/approveToken.cjs +1 -1
  473. package/functions/web3/functionCalls/approveToken.mjs +8 -7
  474. package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -0
  475. package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +4 -0
  476. package/functions/web3/functionCalls/approveTokensToHinkal.mjs +11 -0
  477. package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
  478. package/functions/web3/functionCalls/estimateGasRelayer.d.ts +2 -2
  479. package/functions/web3/functionCalls/estimateGasRelayer.mjs +14 -8
  480. package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -0
  481. package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +5 -0
  482. package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +32 -0
  483. package/functions/web3/functionCalls/relayFunctions.d.ts +1 -15
  484. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  485. package/functions/web3/functionCalls/transactCallDirect.d.ts +2 -2
  486. package/functions/web3/functionCalls/transactCallDirect.mjs +29 -42
  487. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  488. package/functions/web3/functionCalls/transactCallRelayer.d.ts +2 -2
  489. package/functions/web3/functionCalls/transactCallRelayer.mjs +26 -5
  490. package/functions/web3/odosAPI.cjs +1 -1
  491. package/functions/web3/odosAPI.mjs +6 -3
  492. package/functions/web3/oneInchAPI.cjs +1 -1
  493. package/functions/web3/oneInchAPI.mjs +6 -3
  494. package/functions/web3/runContractFunction.cjs +1 -1
  495. package/functions/web3/runContractFunction.mjs +3 -2
  496. package/functions/web3/uniswapAPI.cjs +1 -1
  497. package/functions/web3/uniswapAPI.mjs +6 -3
  498. package/index.cjs +1 -1
  499. package/index.mjs +756 -612
  500. package/package.json +6 -2
  501. package/providers/EthersProviderAdapter.cjs +1 -1
  502. package/providers/EthersProviderAdapter.d.ts +7 -3
  503. package/providers/EthersProviderAdapter.mjs +31 -11
  504. package/providers/WagmiProviderAdapter.cjs +1 -1
  505. package/providers/WagmiProviderAdapter.d.ts +3 -1
  506. package/providers/WagmiProviderAdapter.mjs +12 -4
  507. package/providers/prepareEthersHinkal.cjs +1 -1
  508. package/providers/prepareEthersHinkal.mjs +17 -11
  509. package/providers/prepareWagmiHinkal.cjs +1 -1
  510. package/providers/prepareWagmiHinkal.mjs +17 -11
  511. package/types/API.types.d.ts +21 -0
  512. package/types/ICacheDevice.d.ts +4 -3
  513. package/types/TransactionSimulator.types.d.ts +9 -0
  514. package/types/activities.types.cjs +1 -0
  515. package/types/activities.types.d.ts +45 -0
  516. package/types/activities.types.mjs +13 -0
  517. package/types/balances.types.cjs +1 -0
  518. package/types/balances.types.d.ts +17 -0
  519. package/types/balances.types.mjs +4 -0
  520. package/types/cache.types.cjs +1 -0
  521. package/types/cache.types.d.ts +27 -0
  522. package/types/cache.types.mjs +4 -0
  523. package/types/circom-data.types.d.ts +29 -9
  524. package/types/commitments.types.d.ts +6 -0
  525. package/types/contacts.types.d.ts +5 -0
  526. package/types/crypto.types.d.ts +1 -0
  527. package/types/earlyAccessCode.types.d.ts +4 -0
  528. package/types/ethereum-network.types.cjs +1 -1
  529. package/types/ethereum-network.types.d.ts +66 -62
  530. package/types/ethereum-network.types.mjs +1 -1
  531. package/types/external-action.types.cjs +1 -1
  532. package/types/external-action.types.d.ts +2 -1
  533. package/types/external-action.types.mjs +1 -1
  534. package/types/fee.types.d.ts +9 -0
  535. package/types/hinkal.types.cjs +1 -1
  536. package/types/hinkal.types.d.ts +43 -5
  537. package/types/hinkal.types.mjs +37 -13
  538. package/types/index.d.ts +9 -0
  539. package/types/rewards.types.cjs +1 -1
  540. package/types/rewards.types.d.ts +3 -4
  541. package/types/rewards.types.mjs +12 -12
  542. package/types/sandbox.types.cjs +1 -0
  543. package/types/sandbox.types.d.ts +157 -0
  544. package/types/sandbox.types.mjs +4 -0
  545. package/types/tenderly.api.types.d.ts +180 -0
  546. package/types/token-with-id.types.d.ts +4 -0
  547. package/types/token.types.d.ts +23 -0
  548. package/types/transactions.types.cjs +1 -1
  549. package/types/transactions.types.d.ts +31 -0
  550. package/types/transactions.types.mjs +8 -5
  551. package/types/wc.types.d.ts +89 -0
  552. package/types/with-id.types.d.ts +3 -0
  553. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  554. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  555. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  556. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +26 -31
  557. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  558. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  559. package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
  560. package/webworker/utxoWorker/utxoWorkerLogic.mjs +58 -50
  561. package/webworker/viteWorkerURL.constant.cjs +3 -3
  562. package/webworker/viteWorkerURL.constant.mjs +3 -3
  563. package/webworker/workerFactory.cjs +1 -1
  564. package/webworker/workerFactory.mjs +2 -2
  565. package/webworker/workerProxy.cjs +1 -1
  566. package/webworker/workerProxy.d.ts +11 -11
  567. package/webworker/workerProxy.mjs +24 -26
  568. package/webworker/zkProofWorker/zkProofWorker.types.d.ts +2 -0
  569. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  570. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
  571. package/webworker/zkProofWorker/zkProofWorkerLogic.cjs +1 -1
  572. package/webworker/zkProofWorker/zkProofWorkerLogic.mjs +47 -61
  573. package/functions/utils/memoize.utils.cjs +0 -1
  574. package/functions/utils/memoize.utils.mjs +0 -14
@@ -1,6 +1,7 @@
1
+ import { CustomJSONStringify as h } from "../../functions/utils/serialize.utils.mjs";
1
2
  import { logError as r } from "../../error-handling/logError.mjs";
2
- import { BaseCacheDevice as h } from "./BaseCacheDevice.mjs";
3
- class l extends h {
3
+ import { BaseCacheDevice as o } from "./BaseCacheDevice.mjs";
4
+ class m extends o {
4
5
  filePath;
5
6
  useFileCache;
6
7
  constructor(e, i) {
@@ -31,7 +32,10 @@ class l extends h {
31
32
  r("FileCacheDevice set function", { err: t });
32
33
  }
33
34
  }
35
+ serialize() {
36
+ return Object.fromEntries([...this.inMemoryCache].map(([e, i]) => [e, h(i)]));
37
+ }
34
38
  }
35
39
  export {
36
- l as FileCacheDevice
40
+ m as FileCacheDevice
37
41
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./BaseCacheDevice.cjs");class o extends a.BaseCacheDevice{localDataStorage;constructor(){super(),typeof localStorage<"u"&&(this.localDataStorage=localStorage)}get(e){return this.localDataStorage?this.localDataStorage.getItem(e)??void 0:this.getInMemory(e)}set(e,t){this.localDataStorage?this.localDataStorage.setItem(e,t):this.setInMemory(e,t)}}exports.LocalStorageCacheDevice=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../functions/utils/serialize.utils.cjs"),r=require("./BaseCacheDevice.cjs");class i extends r.BaseCacheDevice{localDataStorage;constructor(e,t){super(),!e&&typeof localStorage<"u"&&(this.localDataStorage=localStorage),t&&this.mergeWithSerialized(t)}get(e){return this.localDataStorage?this.localDataStorage.getItem(e)??void 0:this.getInMemory(e)}set(e,t){this.localDataStorage?this.localDataStorage.setItem(e,t):this.setInMemory(e,t)}serialize(){const e=this.localDataStorage?Object.entries(localStorage):[...this.inMemoryCache];return Object.fromEntries(e.map(([t,a])=>[t,o.CustomJSONStringify(a)]))}}exports.LocalStorageCacheDevice=i;
@@ -1,7 +1,8 @@
1
1
  import { BaseCacheDevice } from './BaseCacheDevice';
2
2
  export declare class LocalStorageCacheDevice extends BaseCacheDevice {
3
3
  private localDataStorage;
4
- constructor();
4
+ constructor(disableCaching?: boolean, serializedCache?: Record<string, string>);
5
5
  get(key: string): string | undefined;
6
6
  set(key: string, value: string): void;
7
+ serialize(): Record<string, string>;
7
8
  }
@@ -1,8 +1,9 @@
1
- import { BaseCacheDevice as a } from "./BaseCacheDevice.mjs";
2
- class l extends a {
1
+ import { CustomJSONStringify as o } from "../../functions/utils/serialize.utils.mjs";
2
+ import { BaseCacheDevice as r } from "./BaseCacheDevice.mjs";
3
+ class c extends r {
3
4
  localDataStorage;
4
- constructor() {
5
- super(), typeof localStorage < "u" && (this.localDataStorage = localStorage);
5
+ constructor(t, e) {
6
+ super(), !t && typeof localStorage < "u" && (this.localDataStorage = localStorage), e && this.mergeWithSerialized(e);
6
7
  }
7
8
  get(t) {
8
9
  return this.localDataStorage ? this.localDataStorage.getItem(t) ?? void 0 : this.getInMemory(t);
@@ -10,7 +11,11 @@ class l extends a {
10
11
  set(t, e) {
11
12
  this.localDataStorage ? this.localDataStorage.setItem(t, e) : this.setInMemory(t, e);
12
13
  }
14
+ serialize() {
15
+ const t = this.localDataStorage ? Object.entries(localStorage) : [...this.inMemoryCache];
16
+ return Object.fromEntries(t.map(([e, a]) => [e, o(a)]));
17
+ }
13
18
  }
14
19
  export {
15
- l as LocalStorageCacheDevice
20
+ c as LocalStorageCacheDevice
16
21
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("ethers"),x=require("../utxo/Utxo.cjs"),m=require("./keys.cjs"),i=e=>{const t=U.ethers.utils.defaultAbiCoder.decode(["uint256","address","tuple(uint256, uint256, uint256, uint256)","uint256","uint256"],e),n=t[0].toBigInt(),r=t[1],s=t[2][0].toBigInt(),o=t[2][1].toHexString(),c=t[2][2].toBigInt(),u=t[2][3].toBigInt(),a=t[3].toString(),g=t[4].toNumber();return{amount:n,erc20TokenAddress:r,randomization:s,stealthAddress:o,H0:c,H1:u,timeStamp:a,tokenId:g}},d=(e,t)=>{const{amount:n,erc20TokenAddress:r,timeStamp:s,tokenId:o,randomization:c}=i(e);return{amount:n,erc20TokenAddress:r,timeStamp:s,tokenId:o,randomization:c,shieldedPrivateKey:t}},l=(e,t)=>new x.Utxo(d(e,t)),S=(e,t)=>{const{randomization:n,H0:r,H1:s}=i(e),o=m.UserKeys.checkSignature(n,r,s,t);if(!o)throw new Error("UTXO doesn't belong to user");return o};exports.abiDecodeUtxo=i;exports.checkUtxoSignature=S;exports.decodeUtxo=l;exports.decodeUtxoConstructorArgs=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("ethers"),x=require("../utxo/Utxo.cjs"),l=require("./keys.cjs"),i=e=>{const t=U.ethers.utils.defaultAbiCoder.decode(["uint256","address","tuple(uint256, uint256, uint256, uint256)","uint256","uint256"],e),n=t[0].toBigInt(),r=t[1],s=t[2][0].toBigInt(),o=t[2][1].toHexString(),c=t[2][2].toBigInt(),d=t[2][3].toBigInt(),a=t[3].toString(),g=t[4].toNumber();return{amount:n,erc20TokenAddress:r,randomization:s,stealthAddress:o,H0:c,H1:d,timeStamp:a,tokenId:g}},u=(e,t)=>{const{amount:n,erc20TokenAddress:r,timeStamp:s,tokenId:o,randomization:c,stealthAddress:d}=i(e);return{amount:n,erc20TokenAddress:r,timeStamp:s,tokenId:o,randomization:c,shieldedPrivateKey:t,stealthAddress:d}},m=(e,t)=>new x.Utxo(u(e,t)),h=(e,t)=>{const{randomization:n,H0:r,H1:s}=i(e),o=l.UserKeys.checkSignature(n,r,s,t);if(!o)throw new Error("UTXO doesn't belong to user");return o};exports.abiDecodeUtxo=i;exports.checkUtxoSignature=h;exports.decodeUtxo=m;exports.decodeUtxoConstructorArgs=u;
@@ -5,36 +5,37 @@ const c = (o) => {
5
5
  const t = m.utils.defaultAbiCoder.decode(
6
6
  ["uint256", "address", "tuple(uint256, uint256, uint256, uint256)", "uint256", "uint256"],
7
7
  o
8
- ), e = t[0].toBigInt(), r = t[1], s = t[2][0].toBigInt(), n = t[2][1].toHexString(), i = t[2][2].toBigInt(), d = t[2][3].toBigInt(), u = t[3].toString(), a = t[4].toNumber();
8
+ ), n = t[0].toBigInt(), r = t[1], s = t[2][0].toBigInt(), e = t[2][1].toHexString(), i = t[2][2].toBigInt(), d = t[2][3].toBigInt(), u = t[3].toString(), a = t[4].toNumber();
9
9
  return {
10
- amount: e,
10
+ amount: n,
11
11
  erc20TokenAddress: r,
12
12
  randomization: s,
13
- stealthAddress: n,
13
+ stealthAddress: e,
14
14
  H0: i,
15
15
  H1: d,
16
16
  timeStamp: u,
17
17
  tokenId: a
18
18
  };
19
19
  }, U = (o, t) => {
20
- const { amount: e, erc20TokenAddress: r, timeStamp: s, tokenId: n, randomization: i } = c(o);
20
+ const { amount: n, erc20TokenAddress: r, timeStamp: s, tokenId: e, randomization: i, stealthAddress: d } = c(o);
21
21
  return {
22
- amount: e,
22
+ amount: n,
23
23
  erc20TokenAddress: r,
24
24
  timeStamp: s,
25
- tokenId: n,
25
+ tokenId: e,
26
26
  randomization: i,
27
- shieldedPrivateKey: t
27
+ shieldedPrivateKey: t,
28
+ stealthAddress: d
28
29
  };
29
- }, k = (o, t) => new g(U(o, t)), I = (o, t) => {
30
- const { randomization: e, H0: r, H1: s } = c(o), n = x.checkSignature(e, r, s, t);
31
- if (!n)
30
+ }, k = (o, t) => new g(U(o, t)), A = (o, t) => {
31
+ const { randomization: n, H0: r, H1: s } = c(o), e = x.checkSignature(n, r, s, t);
32
+ if (!e)
32
33
  throw new Error("UTXO doesn't belong to user");
33
- return n;
34
+ return e;
34
35
  };
35
36
  export {
36
37
  c as abiDecodeUtxo,
37
- I as checkUtxoSignature,
38
+ A as checkUtxoSignature,
38
39
  k as decodeUtxo,
39
40
  U as decodeUtxoConstructorArgs
40
41
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),y=require("libsodium-wrappers"),g=require("../../constants/protocol.constants.cjs"),S=require("../../crypto/babyJub.cjs"),o=require("../../crypto/poseidon.cjs"),h=require("../../functions/utils/memoize.utils.cjs"),c=require("./keyUtils.cjs"),p={privateKey:"",publicKey:""};class K{signature;constructor(e){this.signature=e}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error("No signature provided")}verifyMessage(e){return this.requireSignature(),u.utils.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),u.ethers.utils.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),o.poseidonHash(this.getShieldedPrivateKey()));getAccessKey=()=>(this.requireSignature(),o.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getWalletSalt=e=>(this.requireSignature(),o.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getBackendToken=()=>(this.requireSignature(),o.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=h.memoizeFunc((e,i)=>{const t=S.babyJubInstance(),s=BigInt(i)%g.CIRCOM_P,n=e*s%g.CIRCOM_P,r=t.mulPointEscalar(t.Base8,e),a=t.mulPointEscalar(t.Base8,n),d=[BigInt(t.F.toString(r[0])),BigInt(t.F.toString(r[1]))],l=[BigInt(t.F.toString(a[0])),BigInt(t.F.toString(a[1]))];return{H0:d,H1:l}});static getStealthAddressCompressedPoints=(e,i)=>{const{H0:t,H1:s}=this.getRandomizedStealthPair(e,i),[n,r]=[t,s].map(a=>BigInt(a[1])+2n**255n*c.getCircomSign(a[0]));return{h0:n,h1:r}};static getStealthAddress=h.memoizeFunc((e,i)=>{const{H0:t,H1:s}=this.getRandomizedStealthPair(e,i),r=[2n*c.getCircomSign(t[0])+c.getCircomSign(s[0]),t[1],s[1]];return o.poseidonHash(...r)});static getStealthAddressWithEKey=(e,i)=>({stealthAddress:this.getStealthAddress(e,i),encryptionKey:this.getEncryptionKeyPair(i).publicKey});static checkSignature=(e,i,t,s)=>{const{h0:n,h1:r}=this.getStealthAddressCompressedPoints(e,s);return i===n&&t===r};static getEncryptionKeyPair=e=>{const i=y.crypto_box_seed_keypair(u.ethers.utils.arrayify(e));return{privateKey:u.ethers.utils.hexlify(i.privateKey),publicKey:u.ethers.utils.hexlify(i.publicKey)}}}exports.EncryptionKeyPairDefaultValue=p;exports.UserKeys=K;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("ethers"),p=require("libsodium-wrappers"),u=require("../../constants/protocol.constants.cjs"),K=require("../../crypto/babyJub.cjs"),a=require("../../crypto/poseidon.cjs"),o=require("./keyUtils.cjs"),g=require("../cacheDevices/AttachableMemoryCacheDevice.cjs"),d=new g.AttachableMemoryCacheDevice,l=new g.AttachableMemoryCacheDevice,P={privateKey:"",publicKey:""};class b{signature;constructor(e){this.signature=e}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error("No signature provided")}verifyMessage(e){return this.requireSignature(),h.utils.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),h.ethers.utils.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),a.poseidonHash(this.getShieldedPrivateKey()));getAccessKey=()=>(this.requireSignature(),a.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getWalletSalt=e=>(this.requireSignature(),a.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getInHinkalAddress=e=>{this.requireSignature();const t=a.poseidonHash(this.getShieldedPrivateKey(),e);return BigInt(t)};getBackendToken=()=>(this.requireSignature(),a.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=d.attach((e,t)=>{const i=K.babyJubInstance(),s=BigInt(t)%u.CIRCOM_P,n=e*s%u.CIRCOM_P,r=i.mulPointEscalar(i.Base8,e),c=i.mulPointEscalar(i.Base8,n),y=[BigInt(i.F.toString(r[0])),BigInt(i.F.toString(r[1]))],S=[BigInt(i.F.toString(c[0])),BigInt(i.F.toString(c[1]))];return{H0:y,H1:S}});static getStealthAddressCompressedPoints=(e,t)=>{const{H0:i,H1:s}=this.getRandomizedStealthPair(e,t),[n,r]=[i,s].map(c=>BigInt(c[1])+2n**255n*o.getCircomSign(c[0]));return{h0:n,h1:r}};static getStealthAddress=l.attach((e,t)=>{const{H0:i,H1:s}=this.getRandomizedStealthPair(e,t),r=[2n*o.getCircomSign(i[0])+o.getCircomSign(s[0]),i[1],s[1]];return a.poseidonHash(...r)});static getStealthAddressWithEKey=(e,t)=>({stealthAddress:this.getStealthAddress(e,t),encryptionKey:this.getEncryptionKeyPair(t).publicKey});static checkSignature=(e,t,i,s)=>{const{h0:n,h1:r}=this.getStealthAddressCompressedPoints(e,s);return t===n&&i===r};static getEncryptionKeyPair=e=>{const t=p.crypto_box_seed_keypair(h.ethers.utils.arrayify(e));return{privateKey:h.ethers.utils.hexlify(t.privateKey),publicKey:h.ethers.utils.hexlify(t.publicKey)}}}exports.EncryptionKeyPairDefaultValue=P;exports.UserKeys=b;exports.stealthAddressCacheDevice=l;exports.stealthPairCacheDevice=d;
@@ -1,4 +1,9 @@
1
- import { JubPoint } from '../../crypto/babyJub';
1
+ import { AttachableMemoryCacheDevice } from '../cacheDevices/AttachableMemoryCacheDevice';
2
+ export declare const stealthPairCacheDevice: AttachableMemoryCacheDevice<{
3
+ H0: [bigint, bigint];
4
+ H1: [bigint, bigint];
5
+ }>;
6
+ export declare const stealthAddressCacheDevice: AttachableMemoryCacheDevice<string>;
2
7
  export interface EncryptionKeyPair {
3
8
  privateKey: string;
4
9
  publicKey: string;
@@ -30,14 +35,19 @@ export declare class UserKeys {
30
35
  */
31
36
  getAccessKey: () => string;
32
37
  getWalletSalt: (walletNonce: bigint) => string;
38
+ /**
39
+ * generate inHinkalAddress - a user unique address linking him with a specific app
40
+ * @returns inHinkalAddress in bigint
41
+ */
42
+ getInHinkalAddress: (interactionAddress: string) => bigint;
33
43
  /**
34
44
  * generate backend token, which is used for access control on backend
35
45
  * @returns accessKey in hexstring with 0x prefixed
36
46
  */
37
47
  getBackendToken: () => string;
38
48
  static getRandomizedStealthPair: (s: bigint, privateKey: string) => {
39
- H0: JubPoint;
40
- H1: JubPoint;
49
+ H0: [bigint, bigint];
50
+ H1: [bigint, bigint];
41
51
  };
42
52
  static getStealthAddressCompressedPoints: (s: bigint, privateKey: string) => {
43
53
  h0: bigint;
@@ -1,31 +1,31 @@
1
1
  import { utils as y, ethers as o } from "ethers";
2
2
  import S from "libsodium-wrappers";
3
- import { CIRCOM_P as h } from "../../constants/protocol.constants.mjs";
3
+ import { CIRCOM_P as g } from "../../constants/protocol.constants.mjs";
4
4
  import { babyJubInstance as m } from "../../crypto/babyJub.mjs";
5
- import { poseidonHash as u } from "../../crypto/poseidon.mjs";
6
- import { memoizeFunc as c } from "../../functions/utils/memoize.utils.mjs";
7
- import { getCircomSign as g } from "./keyUtils.mjs";
8
- const q = {
5
+ import { poseidonHash as a } from "../../crypto/poseidon.mjs";
6
+ import { getCircomSign as u } from "./keyUtils.mjs";
7
+ import { AttachableMemoryCacheDevice as c } from "../cacheDevices/AttachableMemoryCacheDevice.mjs";
8
+ const p = new c(), K = new c(), H = {
9
9
  privateKey: "",
10
10
  publicKey: ""
11
11
  };
12
- class H {
12
+ class k {
13
13
  signature;
14
- constructor(t) {
15
- this.signature = t;
14
+ constructor(e) {
15
+ this.signature = e;
16
16
  }
17
17
  getSignature() {
18
18
  return this.requireSignature(), this.signature;
19
19
  }
20
- setSignature(t) {
21
- this.signature = t;
20
+ setSignature(e) {
21
+ this.signature = e;
22
22
  }
23
23
  requireSignature() {
24
24
  if (!this.signature)
25
25
  throw Error("No signature provided");
26
26
  }
27
- verifyMessage(t) {
28
- return this.requireSignature(), y.verifyMessage(t, this.signature);
27
+ verifyMessage(e) {
28
+ return this.requireSignature(), y.verifyMessage(e, this.signature);
29
29
  }
30
30
  /**
31
31
  * get shielded private key from message signature used to login to the application,
@@ -39,51 +39,62 @@ class H {
39
39
  * that the user provided
40
40
  * @retuns shielded public key in hexstring with 0x prefixed
41
41
  */
42
- getShieldedPublicKey = () => (this.requireSignature(), u(this.getShieldedPrivateKey()));
42
+ getShieldedPublicKey = () => (this.requireSignature(), a(this.getShieldedPrivateKey()));
43
43
  /**
44
44
  * generate access token, this accessKey is what should be sent to the server for signing
45
45
  * @returns accessKey in hexstring with 0x prefixed
46
46
  */
47
- getAccessKey = () => (this.requireSignature(), u(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
48
- getWalletSalt = (t) => (this.requireSignature(), u(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), t));
47
+ getAccessKey = () => (this.requireSignature(), a(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
48
+ getWalletSalt = (e) => (this.requireSignature(), a(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), e));
49
+ /**
50
+ * generate inHinkalAddress - a user unique address linking him with a specific app
51
+ * @returns inHinkalAddress in bigint
52
+ */
53
+ getInHinkalAddress = (e) => {
54
+ this.requireSignature();
55
+ const t = a(this.getShieldedPrivateKey(), e);
56
+ return BigInt(t);
57
+ };
49
58
  /**
50
59
  * generate backend token, which is used for access control on backend
51
60
  * @returns accessKey in hexstring with 0x prefixed
52
61
  */
53
- getBackendToken = () => (this.requireSignature(), u(this.getAccessKey(), this.getShieldedPublicKey()));
54
- static getRandomizedStealthPair = c(
55
- (t, i) => {
56
- const e = m(), r = BigInt(i) % h, n = t * r % h, s = e.mulPointEscalar(e.Base8, t), a = e.mulPointEscalar(e.Base8, n), d = [BigInt(e.F.toString(s[0])), BigInt(e.F.toString(s[1]))], l = [BigInt(e.F.toString(a[0])), BigInt(e.F.toString(a[1]))];
62
+ getBackendToken = () => (this.requireSignature(), a(this.getAccessKey(), this.getShieldedPublicKey()));
63
+ static getRandomizedStealthPair = p.attach(
64
+ (e, t) => {
65
+ const i = m(), r = BigInt(t) % g, n = e * r % g, s = i.mulPointEscalar(i.Base8, e), h = i.mulPointEscalar(i.Base8, n), d = [BigInt(i.F.toString(s[0])), BigInt(i.F.toString(s[1]))], l = [BigInt(i.F.toString(h[0])), BigInt(i.F.toString(h[1]))];
57
66
  return { H0: d, H1: l };
58
67
  }
59
68
  );
60
- static getStealthAddressCompressedPoints = (t, i) => {
61
- const { H0: e, H1: r } = this.getRandomizedStealthPair(t, i), [n, s] = [e, r].map((a) => BigInt(a[1]) + 2n ** 255n * g(a[0]));
69
+ static getStealthAddressCompressedPoints = (e, t) => {
70
+ const { H0: i, H1: r } = this.getRandomizedStealthPair(e, t), [n, s] = [i, r].map((h) => BigInt(h[1]) + 2n ** 255n * u(h[0]));
62
71
  return { h0: n, h1: s };
63
72
  };
64
- static getStealthAddress = c((t, i) => {
65
- const { H0: e, H1: r } = this.getRandomizedStealthPair(t, i), s = [2n * g(e[0]) + g(r[0]), e[1], r[1]];
66
- return u(...s);
73
+ static getStealthAddress = K.attach((e, t) => {
74
+ const { H0: i, H1: r } = this.getRandomizedStealthPair(e, t), s = [2n * u(i[0]) + u(r[0]), i[1], r[1]];
75
+ return a(...s);
67
76
  });
68
- static getStealthAddressWithEKey = (t, i) => ({ stealthAddress: this.getStealthAddress(t, i), encryptionKey: this.getEncryptionKeyPair(i).publicKey });
69
- static checkSignature = (t, i, e, r) => {
70
- const { h0: n, h1: s } = this.getStealthAddressCompressedPoints(t, r);
71
- return i === n && e === s;
77
+ static getStealthAddressWithEKey = (e, t) => ({ stealthAddress: this.getStealthAddress(e, t), encryptionKey: this.getEncryptionKeyPair(t).publicKey });
78
+ static checkSignature = (e, t, i, r) => {
79
+ const { h0: n, h1: s } = this.getStealthAddressCompressedPoints(e, r);
80
+ return t === n && i === s;
72
81
  };
73
82
  /**
74
83
  * generate private and public keypair
75
84
  * @param seed seed to use to deterministically generate key, must be in DataHexString format
76
85
  * and must correspond to 32 bytes
77
86
  */
78
- static getEncryptionKeyPair = (t) => {
79
- const i = S.crypto_box_seed_keypair(o.utils.arrayify(t));
87
+ static getEncryptionKeyPair = (e) => {
88
+ const t = S.crypto_box_seed_keypair(o.utils.arrayify(e));
80
89
  return {
81
- privateKey: o.utils.hexlify(i.privateKey),
82
- publicKey: o.utils.hexlify(i.publicKey)
90
+ privateKey: o.utils.hexlify(t.privateKey),
91
+ publicKey: o.utils.hexlify(t.publicKey)
83
92
  };
84
93
  };
85
94
  }
86
95
  export {
87
- q as EncryptionKeyPairDefaultValue,
88
- H as UserKeys
96
+ H as EncryptionKeyPairDefaultValue,
97
+ k as UserKeys,
98
+ K as stealthAddressCacheDevice,
99
+ p as stealthPairCacheDevice
89
100
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o{localStorageKey="tokenRegistry";tokenRegistry;constructor(){if(this.tokenRegistry=[],typeof localStorage<"u"){const t=localStorage.getItem(this.localStorageKey);t&&(this.tokenRegistry=JSON.parse(t))}}persistRegistry(){typeof localStorage<"u"&&localStorage.setItem(this.localStorageKey,JSON.stringify(this.tokenRegistry))}getCustomTokens(t){return this.tokenRegistry.filter(e=>e.chainId===t)}tokenExists(t,e){return t.find(s=>s.erc20TokenAddress===e.erc20TokenAddress||s.symbol===e.symbol||s.name===e.name)}addCustomToken(t){const{chainId:e}=t,s=this.getCustomTokens(e);this.tokenExists(s,t)||this.tokenRegistry.push(t),this.persistRegistry()}removeCustomToken(t){const{chainId:e}=t,r=this.getCustomTokens(e).filter(i=>i.erc20TokenAddress!==t.erc20TokenAddress);this.tokenRegistry=r,this.persistRegistry()}}const n=new o;exports.customTokenRegistry=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i{tokenRegistry;constructor(){this.tokenRegistry=[]}setTokensFromCache(s){this.tokenRegistry=s}getCustomTokens(s){return this.tokenRegistry.filter(t=>t.chainId===s)}tokenExists(s,t){return s.find(e=>e.erc20TokenAddress===t.erc20TokenAddress||e.symbol===t.symbol||e.name===t.name)}addCustomToken(s){const{chainId:t}=s,e=this.getCustomTokens(t);this.tokenExists(e,s)||this.tokenRegistry.push(s)}removeCustomToken(s){const{chainId:t}=s,r=this.getCustomTokens(t).filter(o=>o.erc20TokenAddress!==s.erc20TokenAddress);this.tokenRegistry=r}}const n=new i;exports.customTokenRegistry=n;
@@ -1,9 +1,8 @@
1
- import { ERC20Token } from '../../types/token.types';
1
+ import { ERC20Token } from '../../types';
2
2
  declare class CustomTokenRegistry {
3
- private localStorageKey;
4
3
  tokenRegistry: ERC20Token[];
5
4
  constructor();
6
- private persistRegistry;
5
+ setTokensFromCache(newTokenRegistries: ERC20Token[]): void;
7
6
  getCustomTokens(chainId: number): ERC20Token[];
8
7
  tokenExists(registry: ERC20Token[], tokenToCheck: ERC20Token): ERC20Token | undefined;
9
8
  addCustomToken(token: ERC20Token): void;
@@ -1,33 +1,29 @@
1
- class o {
2
- localStorageKey = "tokenRegistry";
1
+ class i {
3
2
  tokenRegistry;
4
3
  constructor() {
5
- if (this.tokenRegistry = [], typeof localStorage < "u") {
6
- const t = localStorage.getItem(this.localStorageKey);
7
- t && (this.tokenRegistry = JSON.parse(t));
8
- }
4
+ this.tokenRegistry = [];
9
5
  }
10
- persistRegistry() {
11
- typeof localStorage < "u" && localStorage.setItem(this.localStorageKey, JSON.stringify(this.tokenRegistry));
6
+ setTokensFromCache(s) {
7
+ this.tokenRegistry = s;
12
8
  }
13
- getCustomTokens(t) {
14
- return this.tokenRegistry.filter((s) => s.chainId === t);
9
+ getCustomTokens(s) {
10
+ return this.tokenRegistry.filter((t) => t.chainId === s);
15
11
  }
16
- tokenExists(t, s) {
17
- return t.find(
18
- (e) => e.erc20TokenAddress === s.erc20TokenAddress || e.symbol === s.symbol || e.name === s.name
12
+ tokenExists(s, t) {
13
+ return s.find(
14
+ (e) => e.erc20TokenAddress === t.erc20TokenAddress || e.symbol === t.symbol || e.name === t.name
19
15
  );
20
16
  }
21
- addCustomToken(t) {
22
- const { chainId: s } = t, e = this.getCustomTokens(s);
23
- this.tokenExists(e, t) || this.tokenRegistry.push(t), this.persistRegistry();
17
+ addCustomToken(s) {
18
+ const { chainId: t } = s, e = this.getCustomTokens(t);
19
+ this.tokenExists(e, s) || this.tokenRegistry.push(s);
24
20
  }
25
- removeCustomToken(t) {
26
- const { chainId: s } = t, r = this.getCustomTokens(s).filter((i) => i.erc20TokenAddress !== t.erc20TokenAddress);
27
- this.tokenRegistry = r, this.persistRegistry();
21
+ removeCustomToken(s) {
22
+ const { chainId: t } = s, r = this.getCustomTokens(t).filter((n) => n.erc20TokenAddress !== s.erc20TokenAddress);
23
+ this.tokenRegistry = r;
28
24
  }
29
25
  }
30
- const g = new o();
26
+ const c = new i();
31
27
  export {
32
- g as customTokenRegistry
28
+ c as customTokenRegistry
33
29
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../constants/protocol.constants.cjs"),c=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const n=require("../../functions/utils/amounts.utils.cjs"),o=require("../merkle-tree/MerkleTree.cjs"),u=require("./AbstractSnapshotService.cjs");class A extends u.AbstractSnapshotService{constructor(e,s,r,d){super(e,{name:"NewAccessKeyAdded",args:["accessKey","index","senderAddress"]},s,r,d)}_merkleTree;_senderAddresses;_senderAddressIndexMap;get merkleTree(){return this._merkleTree}get senderAddresses(){return this._senderAddresses}get senderAddressIndexMap(){return this._senderAddressIndexMap}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),senderAddresses:Array.from(e.payload.senderAddresses),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;if(e.latestBlockNumber&&e.merkleTree){const d=new Map(Object.entries(e.merkleTree.tree).map(([t,a])=>[BigInt(t),BigInt(a)]));s=o.MerkleTree.createWithData(d,n.toBigInt(e.merkleTree.index),n.toBigInt(e.merkleTree.count),c.poseidonFunction,25n,0n)}else s=o.MerkleTree.create(c.poseidonFunction,25n,0n);return e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:t})=>[d,t])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.accessKey,e.index),this._senderAddressIndexMap.set(e.senderAddress,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.senderAddress)??0)),this._senderAddresses.includes(e.senderAddress)||this._senderAddresses.push(e.senderAddress),e.accessKey===0n&&e.senderAddress===l.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const{accessKey:s,index:r,senderAddress:d}=e;return{accessKey:n.toBigInt(s),index:n.toBigInt(r),senderAddress:d}}getSnapshotPayload(){return{merkleTree:this._merkleTree,senderAddresses:this._senderAddresses,senderAddressIndexMap:this._senderAddressIndexMap}}populateSnapshot({payload:{merkleTree:e,senderAddresses:s,senderAddressIndexMap:r}}){this._merkleTree=e,this._senderAddresses=s,this._senderAddressIndexMap=r}}exports.AbstractAccessTokenSnapshotService=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../constants/protocol.constants.cjs"),a=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const n=require("../../functions/utils/amounts.utils.cjs"),o=require("../merkle-tree/MerkleTree.cjs");require("ethers");require("../../error-handling/error-codes.constants.cjs");const l=require("./AbstractSnapshotService.cjs"),u=require("../../functions/utils/merkleTree.utils.cjs");class i extends l.AbstractSnapshotService{constructor(e,s,r,d){super(e,{name:"NewAccessKeyAdded",args:["accessKey","index","senderAddress"]},s,r,d)}_merkleTree;_senderAddresses;_senderAddressIndexMap;get merkleTree(){return this._merkleTree}get senderAddresses(){return this._senderAddresses}get senderAddressIndexMap(){return this._senderAddressIndexMap}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),senderAddresses:Array.from(e.payload.senderAddresses),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;return e.latestBlockNumber&&e.merkleTree?s=u.contructMerkleTreeFromSerialized(e.merkleTree):s=o.MerkleTree.create(a.poseidonFunction,25n,0n),e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:t})=>[d,t])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.accessKey,e.index),this._senderAddressIndexMap.set(e.senderAddress,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.senderAddress)??0)),this._senderAddresses.includes(e.senderAddress)||this._senderAddresses.push(e.senderAddress),e.accessKey===0n&&e.senderAddress===c.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const{accessKey:s,index:r,senderAddress:d}=e;return{accessKey:n.toBigInt(s),index:n.toBigInt(r),senderAddress:d}}getSnapshotPayload(){return{merkleTree:this._merkleTree,senderAddresses:this._senderAddresses,senderAddressIndexMap:this._senderAddressIndexMap}}populateSnapshot({payload:{merkleTree:e,senderAddresses:s,senderAddressIndexMap:r}}){this._merkleTree=e,this._senderAddresses=s,this._senderAddressIndexMap=r}}exports.AbstractAccessTokenSnapshotService=i;
@@ -1,13 +1,16 @@
1
- import { zeroAddress as o } from "../../constants/protocol.constants.mjs";
2
- import { poseidonFunction as m } from "../../crypto/poseidon.mjs";
1
+ import { zeroAddress as m } from "../../constants/protocol.constants.mjs";
2
+ import { poseidonFunction as o } from "../../crypto/poseidon.mjs";
3
3
  import "circomlibjs-hinkal-fork";
4
4
  import "libsodium-wrappers";
5
5
  import "process";
6
6
  import "buffer";
7
- import { toBigInt as n } from "../../functions/utils/amounts.utils.mjs";
8
- import { MerkleTree as c } from "../merkle-tree/MerkleTree.mjs";
9
- import { AbstractSnapshotService as l } from "./AbstractSnapshotService.mjs";
10
- class I extends l {
7
+ import { toBigInt as t } from "../../functions/utils/amounts.utils.mjs";
8
+ import { MerkleTree as a } from "../merkle-tree/MerkleTree.mjs";
9
+ import "ethers";
10
+ import "../../error-handling/error-codes.constants.mjs";
11
+ import { AbstractSnapshotService as c } from "./AbstractSnapshotService.mjs";
12
+ import { contructMerkleTreeFromSerialized as l } from "../../functions/utils/merkleTree.utils.mjs";
13
+ class f extends c {
11
14
  constructor(e, s, r, d) {
12
15
  super(
13
16
  e,
@@ -46,25 +49,8 @@ class I extends l {
46
49
  }
47
50
  deserializeSnapshot(e) {
48
51
  let s, r;
49
- if (e.latestBlockNumber && e.merkleTree) {
50
- const d = new Map(
51
- Object.entries(e.merkleTree.tree).map(([t, a]) => [
52
- BigInt(t),
53
- BigInt(a)
54
- ])
55
- );
56
- s = c.createWithData(
57
- d,
58
- n(e.merkleTree.index),
59
- n(e.merkleTree.count),
60
- m,
61
- 25n,
62
- 0n
63
- );
64
- } else
65
- s = c.create(m, 25n, 0n);
66
- return e.latestBlockNumber && e.senderAddressIndexMap ? r = new Map(
67
- e.senderAddressIndexMap.map(({ address: d, index: t }) => [d, t])
52
+ return e.latestBlockNumber && e.merkleTree ? s = l(e.merkleTree) : s = a.create(o, 25n, 0n), e.latestBlockNumber && e.senderAddressIndexMap ? r = new Map(
53
+ e.senderAddressIndexMap.map(({ address: d, index: n }) => [d, n])
68
54
  ) : r = /* @__PURE__ */ new Map(), {
69
55
  latestBlockNumber: e.latestBlockNumber ?? 0,
70
56
  reserveBlockNumber: e.reserveBlockNumber ?? 0,
@@ -80,7 +66,7 @@ class I extends l {
80
66
  return this._merkleTree.insert(e.accessKey, e.index), this._senderAddressIndexMap.set(
81
67
  e.senderAddress,
82
68
  Math.max(Number(e.index), this._senderAddressIndexMap.get(e.senderAddress) ?? 0)
83
- ), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress === o && this._merkleTree.remove(e.index), !0;
69
+ ), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress === m && this._merkleTree.remove(e.index), !0;
84
70
  } catch (r) {
85
71
  return console.error(r), !1;
86
72
  }
@@ -88,8 +74,8 @@ class I extends l {
88
74
  mapEvent(e) {
89
75
  const { accessKey: s, index: r, senderAddress: d } = e;
90
76
  return {
91
- accessKey: n(s),
92
- index: n(r),
77
+ accessKey: t(s),
78
+ index: t(r),
93
79
  senderAddress: d
94
80
  };
95
81
  }
@@ -107,5 +93,5 @@ class I extends l {
107
93
  }
108
94
  }
109
95
  export {
110
- I as AbstractAccessTokenSnapshotService
96
+ f as AbstractAccessTokenSnapshotService
111
97
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./AbstractSnapshotService.cjs"),d=require("../../functions/utils/amounts.utils.cjs"),u=require("../../functions/utils/caseInsensitive.utils.cjs");class A extends c.AbstractSnapshotService{constructor(e,t,r,s){super(e,{name:"NewApprovedUtxo",args:["approveTo","tokenAddress","amount","inHinkalAddress"]},t,r,s)}_approvals=new Map;events=new Set;get approvals(){return this._approvals}getEventKey(e,t){return typeof e!="bigint"||typeof t!="string"?null:`${t}-${e}`}serializeSnapshot(e){const t=Object.fromEntries(e.payload.approvals),r=Object.entries(t).map(([p,l])=>{const i=l.map(n=>({amount:n.amount.toString(),tokenAddress:n.tokenAddress,inHinkalAddress:n.inHinkalAddress.toString()}));return[p,i]}),s=Object.fromEntries(r);return{latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,approvals:s,events:[...this.events]}}deserializeSnapshot(e){console.log({serializedSnapshot:e});const t=e.approvals,r=Object.entries(t).map(([p,l])=>{const i=l.map(n=>({amount:BigInt(n.amount),tokenAddress:n.tokenAddress,inHinkalAddress:BigInt(n.inHinkalAddress)}));return[p,i]}),s=new Map(r);return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{approvals:s,events:new Set(e.events)}}}getSnapshotPayload(){return{approvals:this._approvals,events:this.events}}populateSnapshot({payload:{approvals:e,events:t}}){this._approvals=e,this.events=t}mapEvent(e){const{approveTo:t,tokenAddress:r,amount:s,inHinkalAddress:p}=e;return{approveTo:t,tokenAddress:r,amount:d.toBigInt(s),inHinkalAddress:d.toBigInt(p)}}acceptEvent(e,t,r){const s=this.getEventKey(e.inHinkalAddress,r);if(s&&!this.events.has(s)){const{amount:p,tokenAddress:l,inHinkalAddress:i}=e,n={amount:p,tokenAddress:l,inHinkalAddress:i};let a=this.approvals.get(e.approveTo)||[],v=!1;for(let o=0;o<a.length;o+=1)u.caseInsensitiveEqual(l,a[o].tokenAddress)&&i===a[o].inHinkalAddress&&(a[o].amount+=p,v=!0);if(a=a.filter(o=>o.amount!==0n),v&&a.length===0)this.approvals.delete(e.approveTo);else{const o=v?a:[...a,n];this.approvals.set(e.approveTo,o)}return r&&this.events.add(s),!0}return!1}}exports.AbstractApprovalsSnapshotService=A;
@@ -0,0 +1,30 @@
1
+ import { ethers } from 'ethers';
2
+ import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
3
+ import { NewApprovedUtxoEvent } from '../../types/commitments.types';
4
+ import { ApprovedUtxo } from '../../types/hinkal.types';
5
+ export type ApprovalsSnapshotPayload = {
6
+ readonly approvals: Map<string, ApprovedUtxo[]>;
7
+ readonly events: Set<string>;
8
+ };
9
+ export type ApprovalsSerializedSnapshot = {
10
+ latestBlockNumber?: number;
11
+ reserveBlockNumber?: number;
12
+ approvals: Record<string, ApprovedUtxo<string>[]>;
13
+ events: string[];
14
+ };
15
+ export declare abstract class AbstractApprovalsSnapshotService extends AbstractSnapshotService<NewApprovedUtxoEvent, NewApprovedUtxoEvent<string>, ApprovalsSnapshotPayload, ApprovalsSerializedSnapshot> {
16
+ constructor(contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, maxPageSize?: number);
17
+ private _approvals;
18
+ events: Set<string>;
19
+ get approvals(): Map<string, ApprovedUtxo[]>;
20
+ private getEventKey;
21
+ protected serializeSnapshot(snapshot: Snapshot<ApprovalsSnapshotPayload>): ApprovalsSerializedSnapshot;
22
+ protected deserializeSnapshot(serializedSnapshot: ApprovalsSerializedSnapshot): Snapshot<ApprovalsSnapshotPayload>;
23
+ protected getSnapshotPayload(): {
24
+ approvals: Map<string, ApprovedUtxo[]>;
25
+ events: Set<string>;
26
+ };
27
+ protected populateSnapshot({ payload: { approvals, events } }: Snapshot<ApprovalsSnapshotPayload>): void;
28
+ protected mapEvent(event: NewApprovedUtxoEvent<string>): NewApprovedUtxoEvent;
29
+ protected acceptEvent(event: NewApprovedUtxoEvent, _blockNumber: number, txHash: string): boolean;
30
+ }
@@ -0,0 +1,104 @@
1
+ import { AbstractSnapshotService as c } from "./AbstractSnapshotService.mjs";
2
+ import { toBigInt as v } from "../../functions/utils/amounts.utils.mjs";
3
+ import { caseInsensitiveEqual as u } from "../../functions/utils/caseInsensitive.utils.mjs";
4
+ class f extends c {
5
+ constructor(e, t, r, s) {
6
+ super(
7
+ e,
8
+ {
9
+ name: "NewApprovedUtxo",
10
+ args: ["approveTo", "tokenAddress", "amount", "inHinkalAddress"]
11
+ },
12
+ t,
13
+ r,
14
+ s
15
+ );
16
+ }
17
+ _approvals = /* @__PURE__ */ new Map();
18
+ events = /* @__PURE__ */ new Set();
19
+ get approvals() {
20
+ return this._approvals;
21
+ }
22
+ getEventKey(e, t) {
23
+ return typeof e != "bigint" || typeof t != "string" ? null : `${t}-${e}`;
24
+ }
25
+ serializeSnapshot(e) {
26
+ const t = Object.fromEntries(e.payload.approvals), r = Object.entries(t).map(([p, l]) => {
27
+ const i = l.map((n) => ({
28
+ amount: n.amount.toString(),
29
+ tokenAddress: n.tokenAddress,
30
+ inHinkalAddress: n.inHinkalAddress.toString()
31
+ }));
32
+ return [p, i];
33
+ }), s = Object.fromEntries(r);
34
+ return {
35
+ latestBlockNumber: e.latestBlockNumber,
36
+ reserveBlockNumber: e.reserveBlockNumber,
37
+ approvals: s,
38
+ events: [...this.events]
39
+ };
40
+ }
41
+ deserializeSnapshot(e) {
42
+ console.log({ serializedSnapshot: e });
43
+ const t = e.approvals, r = Object.entries(t).map(
44
+ ([p, l]) => {
45
+ const i = l.map((n) => ({
46
+ amount: BigInt(n.amount),
47
+ tokenAddress: n.tokenAddress,
48
+ inHinkalAddress: BigInt(n.inHinkalAddress)
49
+ }));
50
+ return [p, i];
51
+ }
52
+ ), s = new Map(r);
53
+ return {
54
+ latestBlockNumber: e.latestBlockNumber ?? 0,
55
+ reserveBlockNumber: e.reserveBlockNumber ?? 0,
56
+ payload: {
57
+ approvals: s,
58
+ events: new Set(e.events)
59
+ }
60
+ };
61
+ }
62
+ getSnapshotPayload() {
63
+ return {
64
+ approvals: this._approvals,
65
+ events: this.events
66
+ };
67
+ }
68
+ populateSnapshot({ payload: { approvals: e, events: t } }) {
69
+ this._approvals = e, this.events = t;
70
+ }
71
+ mapEvent(e) {
72
+ const { approveTo: t, tokenAddress: r, amount: s, inHinkalAddress: p } = e;
73
+ return {
74
+ approveTo: t,
75
+ tokenAddress: r,
76
+ amount: v(s),
77
+ inHinkalAddress: v(p)
78
+ };
79
+ }
80
+ acceptEvent(e, t, r) {
81
+ const s = this.getEventKey(e.inHinkalAddress, r);
82
+ if (s && !this.events.has(s)) {
83
+ const { amount: p, tokenAddress: l, inHinkalAddress: i } = e, n = {
84
+ amount: p,
85
+ tokenAddress: l,
86
+ inHinkalAddress: i
87
+ };
88
+ let o = this.approvals.get(e.approveTo) || [], d = !1;
89
+ for (let a = 0; a < o.length; a += 1)
90
+ u(l, o[a].tokenAddress) && i === o[a].inHinkalAddress && (o[a].amount += p, d = !0);
91
+ if (o = o.filter((a) => a.amount !== 0n), d && o.length === 0)
92
+ this.approvals.delete(e.approveTo);
93
+ else {
94
+ const a = d ? o : [...o, n];
95
+ this.approvals.set(e.approveTo, a);
96
+ }
97
+ return r && this.events.add(s), !0;
98
+ }
99
+ return !1;
100
+ }
101
+ }
102
+ export {
103
+ f as AbstractApprovalsSnapshotService
104
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const i=require("../merkle-tree/MerkleTree.cjs"),n=require("../../functions/utils/amounts.utils.cjs"),m=require("./AbstractSnapshotService.cjs");class p extends m.AbstractSnapshotService{constructor(e,t,u,r){super(e,{name:"NewCommitment",args:["commitment","index","encryptedOutput"]},t,u,r)}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive)}))}}deserializeSnapshot(e){let t;if(e.latestBlockNumber&&e.merkleTree){const r=new Map(Object.entries(e.merkleTree.tree).map(([c,o])=>[BigInt(c),BigInt(o)]));t=i.MerkleTree.createWithData(r,n.toBigInt(e.merkleTree.index),n.toBigInt(e.merkleTree.count),s.poseidonFunction,25n,0n)}else t=i.MerkleTree.create(s.poseidonFunction,25n,0n);const u=e.encryptedOutputs?.map(r=>({value:r.value,isPositive:JSON.parse(r.isPositive)}));return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:u||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:u,encryptedOutput:r}=e;return{commitment:n.toBigInt(t),index:n.toBigInt(u),encryptedOutput:r}}acceptEvent(e,t){if(!this.encryptedOutputs.map(u=>u.value).includes(e.encryptedOutput)){if(!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return!1;const r={value:e.encryptedOutput,isPositive:e.index>=0n};return this._encryptedOutputs.push(r),!0}return!1}}exports.AbstractCommitmentsSnapshotService=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const n=require("../merkle-tree/MerkleTree.cjs");require("ethers");require("../../error-handling/error-codes.constants.cjs");const s=require("../../functions/utils/amounts.utils.cjs"),c=require("./AbstractSnapshotService.cjs"),l=require("../../functions/utils/merkleTree.utils.cjs");class m extends c.AbstractSnapshotService{constructor(e,t,r,u){super(e,{name:"NewCommitment",args:["commitment","index","encryptedOutput"]},t,r,u)}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive)}))}}deserializeSnapshot(e){let t;e.latestBlockNumber&&e.merkleTree?t=l.contructMerkleTreeFromSerialized(e.merkleTree):t=n.MerkleTree.create(i.poseidonFunction,25n,0n);const r=e.encryptedOutputs?.map(u=>({value:u.value,isPositive:JSON.parse(u.isPositive)}));return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:r||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:r,encryptedOutput:u}=e;return{commitment:s.toBigInt(t),index:s.toBigInt(r),encryptedOutput:u}}acceptEvent(e,t){if(!this.encryptedOutputs.map(r=>r.value).includes(e.encryptedOutput)){if(!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return!1;const u={value:e.encryptedOutput,isPositive:e.index>=0n};return this._encryptedOutputs.push(u),!0}return!1}}exports.AbstractCommitmentsSnapshotService=m;