@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 +1,2 @@
1
1
  export declare const CustomJSONStringify: (args: any) => string;
2
+ export declare const CustomJSONParse: (stringifiedJSON: string) => any;
@@ -1,4 +1,5 @@
1
- const r = (i) => JSON.stringify(i, (n, t) => typeof t == "bigint" ? `bigint:${t.toString()}` : t);
1
+ const n = (i) => JSON.stringify(i, (r, t) => typeof t == "bigint" ? `bigint:${t.toString()}` : t), s = (i) => JSON.parse(i, (r, t) => typeof t == "string" && t.startsWith("bigint:") ? BigInt(t.slice(7)) : t);
2
2
  export {
3
- r as CustomJSONStringify
3
+ s as CustomJSONParse,
4
+ n as CustomJSONStringify
4
5
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(t){return t?.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.substring(1)).join(" ")}function i(t){return t.charAt(0).toUpperCase()+t.slice(1)}function n(t){return!t||t===null||Array.isArray(t)&&t.length===0?!0:Object.keys(t).length===0&&t.constructor===Object}exports.capitalizeFirstLetter=i;exports.isNullOrEmpty=n;exports.toTitleCase=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../constants/chains.constants.cjs");function i(t){return t?.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.substring(1)).join(" ")}function a(t){return t.charAt(0).toUpperCase()+t.slice(1)}function c(t){return!t||t===null||Array.isArray(t)&&t.length===0?!0:Object.keys(t).length===0&&t.constructor===Object}const l=t=>{t.startsWith("0x")&&(t=t.slice(2));const e=[];for(let r=0;r<t.length;r+=2){const s=parseInt(t.slice(r,r+2),16);e.push(s)}return new TextDecoder("utf-8").decode(new Uint8Array(e))},u=(t,e,n=!1)=>{const r=`${t}-${e}`;if(n){const{hinkalAddress:s}=o.networkRegistry[e].contractData;return`${r}-${s}`.toLowerCase()}return r.toLowerCase()},f=(t,e,n)=>{if(!e||!n)throw Error("oldPart and newPart must be provided");return t.toLowerCase().split(e.toLowerCase()).join(n.toLowerCase())};exports.capitalizeFirstLetter=a;exports.getStateKey=u;exports.hexToUtf8=l;exports.isNullOrEmpty=c;exports.replaceAllInstances=f;exports.toTitleCase=i;
@@ -6,3 +6,6 @@ export declare function toTitleCase(str: string): string;
6
6
  export declare function capitalizeFirstLetter(str: string): string;
7
7
  /** Returns true if a value is null, undefined, or an empty object, array (length 0), or string (e.g. '') */
8
8
  export declare function isNullOrEmpty(obj: unknown): boolean;
9
+ export declare const hexToUtf8: (hex: string) => string;
10
+ export declare const getStateKey: (address: string, chainId: number, withHinkalContractAddress?: boolean) => string;
11
+ export declare const replaceAllInstances: (text: string, oldPart: string, newPart: string) => string;
@@ -1,14 +1,38 @@
1
- function e(t) {
2
- return t?.toLowerCase().split(" ").map((r) => r.charAt(0).toUpperCase() + r.substring(1)).join(" ");
1
+ import { networkRegistry as o } from "../../constants/chains.constants.mjs";
2
+ function a(t) {
3
+ return t?.toLowerCase().split(" ").map((e) => e.charAt(0).toUpperCase() + e.substring(1)).join(" ");
3
4
  }
4
- function n(t) {
5
+ function c(t) {
5
6
  return t.charAt(0).toUpperCase() + t.slice(1);
6
7
  }
7
- function i(t) {
8
+ function u(t) {
8
9
  return !t || t === null || Array.isArray(t) && t.length === 0 ? !0 : Object.keys(t).length === 0 && t.constructor === Object;
9
10
  }
11
+ const l = (t) => {
12
+ t.startsWith("0x") && (t = t.slice(2));
13
+ const e = [];
14
+ for (let r = 0; r < t.length; r += 2) {
15
+ const s = parseInt(t.slice(r, r + 2), 16);
16
+ e.push(s);
17
+ }
18
+ return new TextDecoder("utf-8").decode(new Uint8Array(e));
19
+ }, f = (t, e, n = !1) => {
20
+ const r = `${t}-${e}`;
21
+ if (n) {
22
+ const { hinkalAddress: s } = o[e].contractData;
23
+ return `${r}-${s}`.toLowerCase();
24
+ }
25
+ return r.toLowerCase();
26
+ }, p = (t, e, n) => {
27
+ if (!e || !n)
28
+ throw Error("oldPart and newPart must be provided");
29
+ return t.toLowerCase().split(e.toLowerCase()).join(n.toLowerCase());
30
+ };
10
31
  export {
11
- n as capitalizeFirstLetter,
12
- i as isNullOrEmpty,
13
- e as toTitleCase
32
+ c as capitalizeFirstLetter,
33
+ f as getStateKey,
34
+ l as hexToUtf8,
35
+ u as isNullOrEmpty,
36
+ p as replaceAllInstances,
37
+ a as toTitleCase
14
38
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=(t=1e3)=>new Promise(e=>{setTimeout(()=>{e(void 0)},t)});exports.waitLittle=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(e=1e3)=>new Promise(t=>{setTimeout(()=>{t(void 0)},e)}),i=()=>Math.floor(Date.now()/1e3);exports.getCurrentTimeInSeconds=i;exports.waitLittle=o;
@@ -1 +1,2 @@
1
1
  export declare const waitLittle: (time?: number) => Promise<unknown>;
2
+ export declare const getCurrentTimeInSeconds: () => number;
@@ -1,8 +1,9 @@
1
- const i = (e = 1e3) => new Promise((t) => {
1
+ const o = (e = 1e3) => new Promise((t) => {
2
2
  setTimeout(() => {
3
3
  t(void 0);
4
4
  }, e);
5
- });
5
+ }), n = () => Math.floor(Date.now() / 1e3);
6
6
  export {
7
- i as waitLittle
7
+ n as getCurrentTimeInSeconds,
8
+ o as waitLittle
8
9
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/API.cjs"),l=async(t,o)=>{const a=await i.API.tokensInfoCall(t,o),n=[];return a.forEach((e,c)=>{(!e||!e.balanceStorageOffset||!e.allowanceStorageOffset)&&n.push(o[c])}),n};exports.checkTokensForShielding=l;
@@ -0,0 +1 @@
1
+ export declare const checkTokensForShielding: (chainId: number, erc20Addresses: string[]) => Promise<string[]>;
@@ -0,0 +1,10 @@
1
+ import { API as f } from "../../API/API.mjs";
2
+ const s = async (t, n) => {
3
+ const e = await f.tokensInfoCall(t, n), a = [];
4
+ return e.forEach((o, c) => {
5
+ (!o || !o.balanceStorageOffset || !o.allowanceStorageOffset) && a.push(n[c]);
6
+ }), a;
7
+ };
8
+ export {
9
+ s as checkTokensForShielding
10
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../error-handling/error-codes.constants.cjs"),d=require("./caseInsensitive.utils.cjs"),o=async(e,r,t)=>{const s=await e.getEthereumAddress();if(e.getCurrentChainId()!==r||!d.caseInsensitiveEqual(s,t))throw Error(n.transactionErrorCodes.ERROR_MESSAGE_CHAIN_ADDRESS_CHANGED);return!0};exports.checkChainOrAddressNotUpdated=o;
@@ -0,0 +1,2 @@
1
+ import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
2
+ export declare const checkChainOrAddressNotUpdated: (hinkal: IHinkal, oldChainId: number, oldEthAddress: string) => Promise<boolean>;
@@ -0,0 +1,11 @@
1
+ import { transactionErrorCodes as s } from "../../error-handling/error-codes.constants.mjs";
2
+ import { caseInsensitiveEqual as o } from "./caseInsensitive.utils.mjs";
3
+ const E = async (r, e, t) => {
4
+ const n = await r.getEthereumAddress();
5
+ if (r.getCurrentChainId() !== e || !o(n, t))
6
+ throw Error(s.ERROR_MESSAGE_CHAIN_ADDRESS_CHANGED);
7
+ return !0;
8
+ };
9
+ export {
10
+ E as checkChainOrAddressNotUpdated
11
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../types/circom-data.types.cjs");const a=require("../../../types/hinkal.types.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");require("../../../types/activities.types.cjs");const r=n=>{const t=a.EventType.BalanceChange,e=new CustomEvent(t,{detail:n});typeof document<"u"?document.dispatchEvent(e):process?.emit("message",e,void 0)};exports.balanceChangedCustomHandler=r;
@@ -0,0 +1,2 @@
1
+ import { PrivateBalanceUpdateEventType } from '../../../types';
2
+ export declare const balanceChangedCustomHandler: (detail: PrivateBalanceUpdateEventType) => void;
@@ -0,0 +1,14 @@
1
+ import "../../../types/circom-data.types.mjs";
2
+ import { EventType as o } from "../../../types/hinkal.types.mjs";
3
+ import "../../../types/transactions.types.mjs";
4
+ import "../../../types/curve.types.mjs";
5
+ import "../../../types/activities.types.mjs";
6
+ const i = (t) => {
7
+ const n = o.BalanceChange, e = new CustomEvent(n, {
8
+ detail: t
9
+ });
10
+ typeof document < "u" ? document.dispatchEvent(e) : process?.emit("message", e, void 0);
11
+ };
12
+ export {
13
+ i as balanceChangedCustomHandler
14
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../types/circom-data.types.cjs");const n=require("../../../types/hinkal.types.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");const t=()=>{const e=n.EventType.BalanceChange;typeof document<"u"?document.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)};exports.balanceChangedHandler=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../types/circom-data.types.cjs");const n=require("../../../types/hinkal.types.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");require("../../../types/activities.types.cjs");const t=()=>{const e=n.EventType.BalanceChange;typeof document<"u"?document.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)};exports.balanceChangedHandler=t;
@@ -1,11 +1,12 @@
1
1
  import "../../../types/circom-data.types.mjs";
2
- import { EventType as n } from "../../../types/hinkal.types.mjs";
2
+ import { EventType as t } from "../../../types/hinkal.types.mjs";
3
3
  import "../../../types/transactions.types.mjs";
4
4
  import "../../../types/curve.types.mjs";
5
- const i = () => {
6
- const e = n.BalanceChange;
5
+ import "../../../types/activities.types.mjs";
6
+ const a = () => {
7
+ const e = t.BalanceChange;
7
8
  typeof document < "u" ? document.dispatchEvent(new Event(e)) : process?.emit("message", e, void 0);
8
9
  };
9
10
  export {
10
- i as balanceChangedHandler
11
+ a as balanceChangedHandler
11
12
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("../../utils/caseInsensitive.utils.cjs"),l=require("../../utils/cacheFunctions.cjs"),m=require("async-mutex"),k=require("ethers"),y=require("../../../error-handling/logger.cjs");require("../../utils/external-action.utils.cjs");const I=require("../../utils/erc20tokenFunctions.cjs");require("../../utils/convertIntegrationProviderToExternalActionId.cjs");require("../../../types/circom-data.types.cjs");const g=require("../../../constants/vite.constants.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");require("../../../types/activities.types.cjs");require("circomlibjs-hinkal-fork");require("../../../error-handling/error-codes.constants.cjs");require("../../../data-structures/crypto-keys/keys.cjs");require("axios");require("../../../constants/chains.constants.cjs");require("libsodium-wrappers");require("process");require("buffer");require("../../../constants/reorg-depths.constants.cjs");require("../../../constants/token-data/index.cjs");require("../../../constants/contracts.constants.cjs");require("../../../constants/kyc.constants.cjs");require("../../../constants/coingecko.constants.cjs");require("../../../constants/axelar.constants.cjs");require("../../../constants/rewards.constants.cjs");require("../../../constants/addresses.constants.cjs");require("../../../constants/token.limits.constants.cjs");require("../../utils/userAgent.cjs");require("../../../data-structures/volatile-helper/VolatileHelper.cjs");const v=require("../../../data-structures/TokenDBs/PrivateTokensDB.cjs"),h=new m.Mutex,f=(e,a,s)=>(e.forEach(r=>{r.inHinkalAddress===s&&a.push(r)}),a),A=(e,a=!1)=>{const{userKeys:s}=e,r=e.getCurrentChainId();a&&l.resetInHinkalAddressesCache(e,r,s.getShieldedPublicKey());const{approvals:o}=e,n=l.getInHinkalAddressesCache(e,r,s.getShieldedPublicKey());let u=[];return o.forEach((c,d)=>{const t=n[d];let i;t?i=BigInt(t):(i=s.getInHinkalAddress(d),n[d]=i.toString()),u=f(c.map(p=>({...p,interactionAddress:d})),u,i)}),l.setInHinkalAddressesCache(n,e,r,s.getShieldedPublicKey()),u},x=(e,a,s)=>A(e,s).filter(o=>q.caseInsensitiveEqual(o.tokenAddress,a)).sort((o,n)=>o.amount===n.amount?0:o.amount>n.amount?-1:1),E=async(e,a,s)=>{const r=e.getCurrentChainId(),o=await e.getEthereumAddress();let n=[];const u=new Map;return await h.runExclusive(async()=>{const c=A(e,a);s&&g.isExtension&&await v.privateTokensDB.fetchAndUpdatePrivateTokens(c.map(t=>t.tokenAddress),r,o),y.Logger.log({myApprovals:c}),n=(g.isExtension?await v.privateTokensDB.getPrivateTokens(r,o):I.getErc20TokensForChain(r)).map(t=>({token:t,balance:c.reduce((i,p)=>q.caseInsensitiveEqual(t.erc20TokenAddress,p.tokenAddress)?i+p.amount:i,0n),timestamp:"0",nfts:[]})),n.forEach(t=>{u.set(t.token.erc20TokenAddress.toLowerCase(),t)})}),u},T=(e,a,s)=>{const{userKeys:r,approvals:o}=e,n=k.ethers.utils.getAddress(a),u=o.get(n)??[],c=r.getInHinkalAddress(n);return u.reduce((t,i)=>q.caseInsensitiveEqual(i.tokenAddress,s)&&i.inHinkalAddress===c?t+i.amount:t,0n)};exports.getApprovedBalance=E;exports.getApprovedUtxos=A;exports.getApprovedUtxosForToken=x;exports.getMyApprovalAmountForInteraction=T;
@@ -0,0 +1,7 @@
1
+ import type { ApprovedUtxoWithInteractionAddress } from '../../../types/hinkal.types';
2
+ import { type IHinkal } from '../../../data-structures/Hinkal/IHinkal';
3
+ import type { TokenBalance } from '../../../types/token.types';
4
+ export declare const getApprovedUtxos: (hinkal: IHinkal, resetCacheBefore?: boolean) => ApprovedUtxoWithInteractionAddress[];
5
+ export declare const getApprovedUtxosForToken: (hinkal: IHinkal, erc20Address: string, resetCacheBefore: boolean) => ApprovedUtxoWithInteractionAddress[];
6
+ export declare const getApprovedBalance: (hinkal: IHinkal, resetCacheBefore: boolean, updateTokensListBefore: boolean) => Promise<Map<string, TokenBalance>>;
7
+ export declare const getMyApprovalAmountForInteraction: (hinkal: IHinkal, interactionAddress: string, tokenAddress: string) => bigint;
@@ -0,0 +1,80 @@
1
+ import { caseInsensitiveEqual as u } from "../../utils/caseInsensitive.utils.mjs";
2
+ import { resetInHinkalAddressesCache as f, getInHinkalAddressesCache as v, setInHinkalAddressesCache as k } from "../../utils/cacheFunctions.mjs";
3
+ import { Mutex as h } from "async-mutex";
4
+ import { ethers as y } from "ethers";
5
+ import { Logger as I } from "../../../error-handling/logger.mjs";
6
+ import "../../utils/external-action.utils.mjs";
7
+ import { getErc20TokensForChain as C } from "../../utils/erc20tokenFunctions.mjs";
8
+ import "../../utils/convertIntegrationProviderToExternalActionId.mjs";
9
+ import "../../../types/circom-data.types.mjs";
10
+ import { isExtension as l } from "../../../constants/vite.constants.mjs";
11
+ import "../../../types/transactions.types.mjs";
12
+ import "../../../types/curve.types.mjs";
13
+ import "../../../types/activities.types.mjs";
14
+ import "circomlibjs-hinkal-fork";
15
+ import "../../../error-handling/error-codes.constants.mjs";
16
+ import "../../../data-structures/crypto-keys/keys.mjs";
17
+ import "axios";
18
+ import "../../../constants/chains.constants.mjs";
19
+ import "libsodium-wrappers";
20
+ import "process";
21
+ import "buffer";
22
+ import "../../../constants/reorg-depths.constants.mjs";
23
+ import "../../../constants/token-data/index.mjs";
24
+ import "../../../constants/contracts.constants.mjs";
25
+ import "../../../constants/kyc.constants.mjs";
26
+ import "../../../constants/coingecko.constants.mjs";
27
+ import "../../../constants/axelar.constants.mjs";
28
+ import "../../../constants/rewards.constants.mjs";
29
+ import "../../../constants/addresses.constants.mjs";
30
+ import "../../../constants/token.limits.constants.mjs";
31
+ import "../../utils/userAgent.mjs";
32
+ import "../../../data-structures/volatile-helper/VolatileHelper.mjs";
33
+ import { privateTokensDB as A } from "../../../data-structures/TokenDBs/PrivateTokensDB.mjs";
34
+ const H = new h(), x = (e, p, o) => (e.forEach((t) => {
35
+ t.inHinkalAddress === o && p.push(t);
36
+ }), p), g = (e, p = !1) => {
37
+ const { userKeys: o } = e, t = e.getCurrentChainId();
38
+ p && f(e, t, o.getShieldedPublicKey());
39
+ const { approvals: n } = e, s = v(e, t, o.getShieldedPublicKey());
40
+ let a = [];
41
+ return n.forEach((m, d) => {
42
+ const r = s[d];
43
+ let i;
44
+ r ? i = BigInt(r) : (i = o.getInHinkalAddress(d), s[d] = i.toString()), a = x(
45
+ m.map(
46
+ (c) => ({ ...c, interactionAddress: d })
47
+ ),
48
+ a,
49
+ i
50
+ );
51
+ }), k(s, e, t, o.getShieldedPublicKey()), a;
52
+ }, se = (e, p, o) => g(e, o).filter((n) => u(n.tokenAddress, p)).sort((n, s) => n.amount === s.amount ? 0 : n.amount > s.amount ? -1 : 1), ne = async (e, p, o) => {
53
+ const t = e.getCurrentChainId(), n = await e.getEthereumAddress();
54
+ let s = [];
55
+ const a = /* @__PURE__ */ new Map();
56
+ return await H.runExclusive(async () => {
57
+ const m = g(e, p);
58
+ o && l && await A.fetchAndUpdatePrivateTokens(
59
+ m.map((r) => r.tokenAddress),
60
+ t,
61
+ n
62
+ ), I.log({ myApprovals: m }), s = (l ? await A.getPrivateTokens(t, n) : C(t)).map((r) => ({
63
+ token: r,
64
+ balance: m.reduce((i, c) => u(r.erc20TokenAddress, c.tokenAddress) ? i + c.amount : i, 0n),
65
+ timestamp: "0",
66
+ nfts: []
67
+ })), s.forEach((r) => {
68
+ a.set(r.token.erc20TokenAddress.toLowerCase(), r);
69
+ });
70
+ }), a;
71
+ }, ie = (e, p, o) => {
72
+ const { userKeys: t, approvals: n } = e, s = y.utils.getAddress(p), a = n.get(s) ?? [], m = t.getInHinkalAddress(s);
73
+ return a.reduce((r, i) => u(i.tokenAddress, o) && i.inHinkalAddress === m ? r + i.amount : r, 0n);
74
+ };
75
+ export {
76
+ ne as getApprovedBalance,
77
+ g as getApprovedUtxos,
78
+ se as getApprovedUtxosForToken,
79
+ ie as getMyApprovalAmountForInteraction
80
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../data-structures/utxo/Utxo.cjs"),g=require("../../utils/cacheFunctions.cjs"),h=async(t,i,a,u,n=0)=>(await t.utxoUtils.buildBatchProcess(i,a)).reduce((o,e)=>u&&n!==0?e.erc20TokenAddress.toLowerCase()===u.toLowerCase()&&e.tokenId===n?[...o,e]:o:u?e.erc20TokenAddress.toLowerCase()===u.toLowerCase()?[...o,e]:o:[...o,e],[]),O=async(t,i,a,u,n,r,o,e=0)=>{const s=await t.utxoUtils.batchFilterUtxosWithNullifier(i,a);if(o){for(s.sort((d,l)=>d.amount<=l.amount?1:-1);s.length<u||s.length>u&&s.length<6;)s.push(new f.Utxo({amount:0n,erc20TokenAddress:o,shieldedPrivateKey:r,tokenId:e}));if(n)for(;s.length>6;)s.splice(s.length-1)}return{inputUtxos:s}},C=async({hinkal:t,erc20TokenAddress:i=void 0,minInput:a=2,sliceIfMore6:u=!0,tokenId:n=0})=>{if(!t.getCurrentChainId||!t.getSelectedNetwork())return{inputUtxos:[]};const{encryptedOutputs:r,nullifiers:o,userKeys:e}=t,s=Array.from(r),d=e.getShieldedPrivateKey();let l=[],U=[],{encryptedOutputs:y,lastOutput:c}=g.getHinkalCache(t),p=s.findIndex(x=>x.value===c);if(p>-1||y.length===0){p+=1;const x=s.slice(p);({lastOutput:c,additionalEncryptedOutputs:U}=await t.utxoUtils.batchProcess(x,c,e)),l=[...y,...U],g.setHinkalCache({lastOutput:c,encryptedOutputs:l},t)}const w=await h(t,l,e,i,n);return await O(t,w,o,a,u,d,i,n)};exports.getInputUtxoAndBalance=C;exports.getInputUtxosFromEncryptedOutputs=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("../../../data-structures/crypto-keys/keys.cjs"),C=require("../../../data-structures/utxo/Utxo.cjs"),v=require("../../utils/upToDateState.cjs"),O=require("../../utils/cacheFunctions.cjs"),b=require("axios"),q=require("../../snarkjs/constant.cjs"),m=require("../../utils/encryptInputForEnclave.cjs"),f=require("ethers"),N=require("../../utils/caseInsensitive.utils.cjs"),w=require("../../utils/encodeTokenWithId.cjs"),S=async(t,r,n)=>await t.utxoUtils.buildBatchProcess(r,n),B=async(t,r)=>{const n=t.getCurrentChainId(),o=r.getShieldedPrivateKey(),{privateKey:u,publicKey:c}=K.UserKeys.getEncryptionKeyPair(o),a=f.ethers.utils.solidityPack(["uint256","uint256","uint256"],[c,u,o]),e=f.ethers.utils.arrayify(a),{keyCiphertext:p,inputCiphertext:h}=await m.makeEnclaveHandshakeAndEncryptUint8Array(e),x=(await b.post(`${q.ENCLAVE_EC2_URL}/decrypt-utxos`,{chainId:n,input:h,key:p})).data;return{utxos:x.utxos.map(l=>new C.Utxo({...l,amount:BigInt(l.amount),randomization:l.randomization?BigInt(l.randomization):void 0,shieldedPrivateKey:o})),encryptedOutputs:x.encryptedOutputs,lastOutput:x.lastOutput}},E=async(t,r,n,o)=>{let u=[],c;if(o){const{utxos:a,encryptedOutputs:e,lastOutput:p}=await B(t,n);u=a,c={encryptedOutputs:e,lastOutput:p}}else u=await S(t,r,n);return{utxos:u,cacheOverride:c}},F=t=>{if(Array.isArray(t))return t;if(t!==void 0)return[t]},H=async(t,r,n)=>await t.utxoUtils.batchFilterUtxosWithNullifier(r,n),z=(t,r,n,o,u,c)=>{for(t.sort((a,e)=>a.amount<=e.amount?1:-1);t.length<r||t.length>r&&t.length<6;)if(t.push(new C.Utxo({amount:0n,erc20TokenAddress:u,shieldedPrivateKey:o,tokenId:c})),n)for(;t.length>6;)t.splice(t.length-1)},k=async({hinkal:t,chainId:r=void 0,passedShieldedPublicKey:n=void 0,ethAddress:o=void 0,resetCacheBefore:u=!1,allowRemoteDecryption:c=!1})=>{if(!t.getCurrentChainId||!t.getSelectedNetwork())return console.log("returning empty balance"),{inputUtxos:[]};const a=o??await t.getEthereumAddress(),e=r??t.getCurrentChainId(),p=n??t.userKeys.getShieldedPublicKey(),{encryptedOutputs:h,nullifiers:x,userKeys:l}=t,U=Array.from(h);u&&O.resetCache(t,e,p);let{encryptedOutputs:d,lastOutput:s}=O.getHinkalCache(t,e,p),i=[...d],g=[];await v.checkChainOrAddressNotUpdated(t,e,a);let y=U.findIndex(A=>A.value===s);const T=d.length===0&&c;if(y>-1||d.length===0&&!c&&!t.areMerkleTreeUpdatesDisabled()){y+=1;const A=U.slice(y);({lastOutput:s,additionalEncryptedOutputs:g}=await t.utxoUtils.batchProcess(A,s,l)),i=[...d,...g],await v.checkChainOrAddressNotUpdated(t,e,a),O.setHinkalCache({lastOutput:s,encryptedOutputs:i},t,e,p)}await v.checkChainOrAddressNotUpdated(t,e,a);const{utxos:P,cacheOverride:I}=await E(t,i,l,T);return await v.checkChainOrAddressNotUpdated(t,e,a),I&&O.setHinkalCache(I,t,e,p),{inputUtxos:await H(t,P,x)}},L=async({hinkal:t,tokenWithId:r,minInput:n=2,sliceIfMore6:o=!0,chainId:u=void 0,passedShieldedPrivateKey:c=void 0,passedShieldedPublicKey:a=void 0,ethAddress:e=void 0,resetCacheBefore:p=!1,ensuredTokensWithId:h})=>{const x=c??t.userKeys.getShieldedPrivateKey(),{inputUtxos:l}=await k({hinkal:t,minInput:n,sliceIfMore6:o,chainId:u,passedShieldedPrivateKey:c,passedShieldedPublicKey:a,ethAddress:e,resetCacheBefore:p}),U=F(r),d=new Map;l.forEach(s=>{if(U&&!U.some(y=>N.caseInsensitiveEqual(y.erc20TokenAddress,s.erc20TokenAddress)&&y.tokenId===s.tokenId))return;const i=w.encodeTokenWithId({erc20TokenAddress:s.erc20TokenAddress,tokenId:s.tokenId}),g=d.get(i)??[];d.set(i,[...g,s])}),h?.forEach(s=>{const i=w.encodeTokenWithId({erc20TokenAddress:s.erc20TokenAddress,tokenId:s.tokenId});d.set(i,d.get(i)??[])});for(const[s,i]of d){const g=s.split("-")[0],y=Number(s.split("-")[1]);z(i,n,o,x,g,y)}return d};exports.getInputUtxoAndBalance=k;exports.getInputUtxoAndBalancePerToken=L;exports.getInputUtxosFromEncryptedOutputs=E;
@@ -2,14 +2,26 @@ import { IHinkal } from '../../../data-structures/Hinkal/IHinkal';
2
2
  import { UserKeys } from '../../../data-structures/crypto-keys/keys';
3
3
  import { Utxo } from '../../../data-structures/utxo/Utxo';
4
4
  import { EncryptedOutputWithSign } from '../../../types/commitments.types';
5
+ import { HinkalCacheInterface } from '../../utils/cacheFunctions';
6
+ import { type TokenWithId } from '../../../types/token-with-id.types';
5
7
  interface IGetInputUtxos {
6
8
  hinkal: IHinkal;
7
- erc20TokenAddress?: string;
9
+ tokenWithId?: TokenWithId | TokenWithId[];
8
10
  minInput?: number;
9
11
  sliceIfMore6?: boolean;
10
12
  tokenId?: number;
13
+ chainId?: number;
14
+ passedShieldedPrivateKey?: string;
15
+ passedShieldedPublicKey?: string;
16
+ ethAddress?: string;
17
+ resetCacheBefore?: boolean;
18
+ allowRemoteDecryption?: boolean;
19
+ ensuredTokensWithId?: TokenWithId[];
11
20
  }
12
- export declare const getInputUtxosFromEncryptedOutputs: (hinkal: IHinkal, encryptedOutputs: EncryptedOutputWithSign[], userKeys: UserKeys, erc20TokenAddress?: string, tokenId?: number) => Promise<Utxo[]>;
21
+ export declare const getInputUtxosFromEncryptedOutputs: (hinkal: IHinkal, encryptedOutputs: EncryptedOutputWithSign[], userKeys: UserKeys, decryptRemotely?: boolean) => Promise<{
22
+ utxos: Utxo[];
23
+ cacheOverride?: HinkalCacheInterface | undefined;
24
+ }>;
13
25
  /**
14
26
  *
15
27
  * @param hinkal instance of the hinkal class
@@ -18,7 +30,8 @@ export declare const getInputUtxosFromEncryptedOutputs: (hinkal: IHinkal, encryp
18
30
  * @param sliceIfMore6 max upper bound on input UTXOs controller
19
31
  * @returns UTXOs for particular erc20 token address
20
32
  */
21
- export declare const getInputUtxoAndBalance: ({ hinkal, erc20TokenAddress, minInput, sliceIfMore6, tokenId, }: IGetInputUtxos) => Promise<{
33
+ export declare const getInputUtxoAndBalance: ({ hinkal, chainId, passedShieldedPublicKey, ethAddress, resetCacheBefore, allowRemoteDecryption, }: IGetInputUtxos) => Promise<{
22
34
  inputUtxos: Utxo[];
23
35
  }>;
36
+ export declare const getInputUtxoAndBalancePerToken: ({ hinkal, tokenWithId, minInput, sliceIfMore6, chainId, passedShieldedPrivateKey, passedShieldedPublicKey, ethAddress, resetCacheBefore, ensuredTokensWithId, }: IGetInputUtxos) => Promise<Map<string, Utxo[]>>;
24
37
  export {};
@@ -1,62 +1,144 @@
1
- import { Utxo as y } from "../../../data-structures/utxo/Utxo.mjs";
2
- import { getHinkalCache as h, setHinkalCache as g } from "../../utils/cacheFunctions.mjs";
3
- const O = async (t, i, l, u, n = 0) => (await t.utxoUtils.buildBatchProcess(i, l)).reduce((o, e) => u && n !== 0 ? e.erc20TokenAddress.toLowerCase() === u.toLowerCase() && e.tokenId === n ? [...o, e] : o : u ? e.erc20TokenAddress.toLowerCase() === u.toLowerCase() ? [...o, e] : o : [...o, e], []), m = async (t, i, l, u, n, r, o, e = 0) => {
4
- const s = await t.utxoUtils.batchFilterUtxosWithNullifier(i, l);
5
- if (o) {
6
- for (s.sort((p, a) => p.amount <= a.amount ? 1 : -1); s.length < u || s.length > u && s.length < 6; )
7
- s.push(new y({ amount: 0n, erc20TokenAddress: o, shieldedPrivateKey: r, tokenId: e }));
8
- if (n)
9
- for (; s.length > 6; )
10
- s.splice(s.length - 1);
11
- }
1
+ import { UserKeys as K } from "../../../data-structures/crypto-keys/keys.mjs";
2
+ import { Utxo as I } from "../../../data-structures/utxo/Utxo.mjs";
3
+ import { checkChainOrAddressNotUpdated as v } from "../../utils/upToDateState.mjs";
4
+ import { resetCache as P, getHinkalCache as T, setHinkalCache as O } from "../../utils/cacheFunctions.mjs";
5
+ import b from "axios";
6
+ import { ENCLAVE_EC2_URL as k } from "../../snarkjs/constant.mjs";
7
+ import { makeEnclaveHandshakeAndEncryptUint8Array as B } from "../../utils/encryptInputForEnclave.mjs";
8
+ import { ethers as U } from "ethers";
9
+ import { caseInsensitiveEqual as N } from "../../utils/caseInsensitive.utils.mjs";
10
+ import { encodeTokenWithId as A } from "../../utils/encodeTokenWithId.mjs";
11
+ const S = async (t, r, o) => await t.utxoUtils.buildBatchProcess(r, o), z = async (t, r) => {
12
+ const o = t.getCurrentChainId(), n = r.getShieldedPrivateKey(), { privateKey: u, publicKey: a } = K.getEncryptionKeyPair(n), c = U.utils.solidityPack(
13
+ ["uint256", "uint256", "uint256"],
14
+ [a, u, n]
15
+ ), e = U.utils.arrayify(c), { keyCiphertext: p, inputCiphertext: g } = await B(e), f = (await b.post(`${k}/decrypt-utxos`, {
16
+ chainId: o,
17
+ input: g,
18
+ key: p
19
+ })).data;
20
+ return {
21
+ utxos: f.utxos.map(
22
+ (l) => new I({
23
+ ...l,
24
+ amount: BigInt(l.amount),
25
+ randomization: l.randomization ? BigInt(l.randomization) : void 0,
26
+ shieldedPrivateKey: n
27
+ })
28
+ ),
29
+ encryptedOutputs: f.encryptedOutputs,
30
+ lastOutput: f.lastOutput
31
+ };
32
+ }, H = async (t, r, o, n) => {
33
+ let u = [], a;
34
+ if (n) {
35
+ const { utxos: c, encryptedOutputs: e, lastOutput: p } = await z(t, o);
36
+ u = c, a = {
37
+ encryptedOutputs: e,
38
+ lastOutput: p
39
+ };
40
+ } else
41
+ u = await S(t, r, o);
12
42
  return {
13
- inputUtxos: s
43
+ utxos: u,
44
+ cacheOverride: a
14
45
  };
15
- }, P = async ({
46
+ }, L = (t) => {
47
+ if (Array.isArray(t))
48
+ return t;
49
+ if (t !== void 0)
50
+ return [t];
51
+ }, R = async (t, r, o) => await t.utxoUtils.batchFilterUtxosWithNullifier(r, o), F = (t, r, o, n, u, a) => {
52
+ for (t.sort((c, e) => c.amount <= e.amount ? 1 : -1); t.length < r || t.length > r && t.length < 6; )
53
+ if (t.push(new I({ amount: 0n, erc20TokenAddress: u, shieldedPrivateKey: n, tokenId: a })), o)
54
+ for (; t.length > 6; )
55
+ t.splice(t.length - 1);
56
+ }, _ = async ({
16
57
  hinkal: t,
17
- erc20TokenAddress: i = void 0,
18
- minInput: l = 2,
19
- sliceIfMore6: u = !0,
20
- tokenId: n = 0
58
+ chainId: r = void 0,
59
+ passedShieldedPublicKey: o = void 0,
60
+ ethAddress: n = void 0,
61
+ resetCacheBefore: u = !1,
62
+ allowRemoteDecryption: a = !1
21
63
  }) => {
22
64
  if (!t.getCurrentChainId || !t.getSelectedNetwork())
23
- return { inputUtxos: [] };
24
- const { encryptedOutputs: r, nullifiers: o, userKeys: e } = t, s = Array.from(r), p = e.getShieldedPrivateKey();
25
- let a = [], U = [], { encryptedOutputs: f, lastOutput: c } = h(t), d = s.findIndex((x) => x.value === c);
26
- if (d > -1 || f.length === 0) {
27
- d += 1;
28
- const x = s.slice(d);
29
- ({ lastOutput: c, additionalEncryptedOutputs: U } = await t.utxoUtils.batchProcess(
30
- x,
31
- c,
32
- e
33
- )), a = [...f, ...U], g(
65
+ return console.log("returning empty balance"), { inputUtxos: [] };
66
+ const c = n ?? await t.getEthereumAddress(), e = r ?? t.getCurrentChainId(), p = o ?? t.userKeys.getShieldedPublicKey(), { encryptedOutputs: g, nullifiers: f, userKeys: l } = t, m = Array.from(g);
67
+ u && P(t, e, p);
68
+ let { encryptedOutputs: d, lastOutput: s } = T(
69
+ t,
70
+ e,
71
+ p
72
+ ), i = [...d], x = [];
73
+ await v(t, e, c);
74
+ let y = m.findIndex((w) => w.value === s);
75
+ const E = d.length === 0 && a;
76
+ if (y > -1 || d.length === 0 && !a && !t.areMerkleTreeUpdatesDisabled()) {
77
+ y += 1;
78
+ const w = m.slice(y);
79
+ ({ lastOutput: s, additionalEncryptedOutputs: x } = await t.utxoUtils.batchProcess(
80
+ w,
81
+ s,
82
+ l
83
+ )), i = [...d, ...x], await v(t, e, c), O(
34
84
  {
35
- lastOutput: c,
36
- encryptedOutputs: a
85
+ lastOutput: s,
86
+ encryptedOutputs: i
37
87
  },
38
- t
88
+ t,
89
+ e,
90
+ p
39
91
  );
40
92
  }
41
- const w = await O(
93
+ await v(t, e, c);
94
+ const { utxos: C, cacheOverride: h } = await H(
42
95
  t,
43
- a,
44
- e,
45
96
  i,
46
- n
47
- );
48
- return await m(
49
- t,
50
- w,
51
- o,
52
97
  l,
53
- u,
54
- p,
55
- i,
56
- n
98
+ E
57
99
  );
100
+ return await v(t, e, c), h && O(h, t, e, p), { inputUtxos: await R(t, C, f) };
101
+ }, Y = async ({
102
+ hinkal: t,
103
+ tokenWithId: r,
104
+ minInput: o = 2,
105
+ sliceIfMore6: n = !0,
106
+ chainId: u = void 0,
107
+ passedShieldedPrivateKey: a = void 0,
108
+ passedShieldedPublicKey: c = void 0,
109
+ ethAddress: e = void 0,
110
+ resetCacheBefore: p = !1,
111
+ ensuredTokensWithId: g
112
+ }) => {
113
+ const f = a ?? t.userKeys.getShieldedPrivateKey(), { inputUtxos: l } = await _({
114
+ hinkal: t,
115
+ minInput: o,
116
+ sliceIfMore6: n,
117
+ chainId: u,
118
+ passedShieldedPrivateKey: a,
119
+ passedShieldedPublicKey: c,
120
+ ethAddress: e,
121
+ resetCacheBefore: p
122
+ }), m = L(r), d = /* @__PURE__ */ new Map();
123
+ l.forEach((s) => {
124
+ if (m && !m.some(
125
+ (y) => N(y.erc20TokenAddress, s.erc20TokenAddress) && y.tokenId === s.tokenId
126
+ ))
127
+ return;
128
+ const i = A({ erc20TokenAddress: s.erc20TokenAddress, tokenId: s.tokenId }), x = d.get(i) ?? [];
129
+ d.set(i, [...x, s]);
130
+ }), g?.forEach((s) => {
131
+ const i = A({ erc20TokenAddress: s.erc20TokenAddress, tokenId: s.tokenId });
132
+ d.set(i, d.get(i) ?? []);
133
+ });
134
+ for (const [s, i] of d) {
135
+ const x = s.split("-")[0], y = Number(s.split("-")[1]);
136
+ F(i, o, n, f, x, y);
137
+ }
138
+ return d;
58
139
  };
59
140
  export {
60
- P as getInputUtxoAndBalance,
61
- O as getInputUtxosFromEncryptedOutputs
141
+ _ as getInputUtxoAndBalance,
142
+ Y as getInputUtxoAndBalancePerToken,
143
+ H as getInputUtxosFromEncryptedOutputs
62
144
  };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("async-mutex"),q=require("../../../constants/token-data/ERC20Registry.cjs"),I=require("../../utils/erc20tokenFunctions.cjs"),f=require("../../utils/caseInsensitive.utils.cjs"),k=require("../../utils/volatile-patcher.utils.cjs"),w=require("../../../data-structures/utxo/Utxo.cjs"),U=require("../../../data-structures/custom-token-registry/CustomTokenRegistry.cjs"),x=require("../../../data-structures/volatile-helper/VolatileHelper.cjs"),P=require("../etherFunctions.cjs"),b=require("../../../error-handling/customErrors/ErrorWithAmount.cjs"),y=require("./getInputUtxoAndBalance.cjs"),E=new A.Mutex,S=async a=>{const i=await E.acquire();try{const{inputUtxos:r}=await y.getInputUtxoAndBalance({hinkal:a,sliceIfMore6:!1}),s=a.getCurrentChainId(),u=[...q.getERC20Registry(s),...U.customTokenRegistry.getCustomTokens(s)];await k.patchRegistry(s);const h=u.map(e=>({token:e,balance:r.reduce((t,c)=>{const n=e.isVolatile?e.sharedAddress:e.erc20TokenAddress;return f.caseInsensitiveEqual(n,c.erc20TokenAddress)?t+c.amount:t},0n),timestamp:r.filter(t=>f.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress))[0]?.timeStamp,nfts:r.filter(t=>f.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress)&&t.tokenId!==0).map(t=>({tokenId:t.tokenId,timestamp:t.timeStamp}))}));return await Promise.all(h.map(async e=>{if(!e.token.isVolatile)return e;e.token?.sharedAddress||console.log("VolatileToken must have a corresponding sharedAddress");let t=0n;return e.balance>0n&&(t=await x.VolatileHelper.getVolatileTokenBalance(s,e.token.sharedAddress,e.balance)),{...e,balance:BigInt(t)}}))}catch(r){console.log("Error while processing shielded balance:",r)}finally{i()}return[]},v=async(a,i,r,s=6,u=i.map(()=>0),h=!1)=>{const{userKeys:p}=a,e=[],t=[];let c=0;for(let n=0;n<i.length;n+=1)if(h===!1){const{inputUtxos:o}=await y.getInputUtxoAndBalance({hinkal:a,erc20TokenAddress:i[n],tokenId:u[n],sliceIfMore6:!1});c=Math.max(o.length,c),t.push(o)}else t.push([]);return c===2?t:(t.forEach((n,o)=>{if(n.length>s){const l=n.slice(0,s),d=l.reduce((g,m)=>g+m.amount,0n);if(r[o]<0n&&d<-r[o]){const g=I.getERC20Token(i[o],a.getCurrentChainId()),m=Number(P.getAmountWithPrecision(d,g,2)),T=`Unfortunately your transaction did not go through due to UTXOs limitations.
2
- Please try again with ${g.symbol}`;throw new b.ErrorWithAmount(m,T)}e.push(l)}else if(n.length<=s){const l=[...n];let d=s-n.length;for(;d>0;)d-=1,l.push(new w.Utxo({amount:0n,erc20TokenAddress:i[o],shieldedPrivateKey:p.getShieldedPrivateKey(),tokenId:u[o]}));e.push(l)}}),e)};exports.addPaddingToUtxos=v;exports.getShieldedBalance=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("async-mutex"),x=require("../../utils/erc20tokenFunctions.cjs"),p=require("../../utils/caseInsensitive.utils.cjs"),U=require("../../utils/volatile-patcher.utils.cjs"),v=require("../../../data-structures/utxo/Utxo.cjs"),A=require("../etherFunctions.cjs"),E=require("../../../error-handling/customErrors/ErrorWithAmount.cjs");require("../../../error-handling/error-codes.constants.cjs");const w=require("./getInputUtxoAndBalance.cjs"),y=require("../../../data-structures/TokenDBs/PrivateTokensDB.cjs"),h=require("../../../constants/vite.constants.cjs"),I=require("../../utils/encodeTokenWithId.cjs"),S=new P.Mutex,B=async(u,o,f,a,i,k=!1,T,d=!1)=>S.runExclusive(async()=>{const{inputUtxos:s}=await w.getInputUtxoAndBalance({hinkal:u,sliceIfMore6:!1,chainId:o,passedShieldedPrivateKey:f,passedShieldedPublicKey:a,ethAddress:i,resetCacheBefore:k,allowRemoteDecryption:T});d&&h.isExtension&&await y.privateTokensDB.fetchAndUpdatePrivateTokens(s.map(e=>e.erc20TokenAddress),o,i);const g=h.isExtension?await y.privateTokensDB.getPrivateTokens(o,i):x.getErc20TokensForChain(o);h.isExtension||await U.patchRegistry(o);const l=g.map(e=>({token:e,balance:s.reduce((t,r)=>{const c=e.erc20TokenAddress;return p.caseInsensitiveEqual(c,r.erc20TokenAddress)?t+r.amount:t},0n),timestamp:s.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress))[0]?.timeStamp,nfts:s.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress)&&t.tokenId!==0).map(t=>({tokenId:t.tokenId,timestamp:t.timeStamp}))})),n=new Map;return l.forEach(e=>{n.set(e.token.erc20TokenAddress.toLowerCase(),e)}),n}),M=async(u,o,f,a=6,i=o.map(()=>0),k=!1)=>{const{userKeys:T}=u,d=[],s=[],g=await w.getInputUtxoAndBalancePerToken({hinkal:u,sliceIfMore6:!1,ensuredTokensWithId:o.map((n,e)=>({erc20TokenAddress:o[e],tokenId:i[e]})),allowRemoteDecryption:!1});let l=0;for(let n=0;n<o.length;n+=1)if(k===!1){const e=g.get(I.encodeTokenWithId({erc20TokenAddress:o[n],tokenId:i[n]}))??[];if(!e)throw new Error("Missing utxos for token");l=Math.max(e.length,l),s.push(e)}else s.push([]);return l===2?s:(s.forEach((n,e)=>{if(n.length>a){const t=n.slice(0,a),r=t.reduce((c,m)=>c+m.amount,0n);if(f[e]<0n&&r<-f[e]){const c=x.getERC20Token(o[e],u.getCurrentChainId()),m=Number(A.getAmountWithPrecision(r,c,2)),q=`Unfortunately your transaction did not go through due to UTXOs limitations.
2
+ Please try again with ${c.symbol}`;throw new E.ErrorWithAmount(m,q)}d.push(t)}else if(n.length<=a){const t=[...n];let r=a-n.length;for(;r>0;)r-=1,t.push(new v.Utxo({amount:0n,erc20TokenAddress:o[e],shieldedPrivateKey:T.getShieldedPrivateKey(),tokenId:i[e]}));d.push(t)}}),d)};exports.addPaddingToUtxos=M;exports.getShieldedBalance=B;
@@ -6,7 +6,7 @@ import { IHinkal } from '../../../data-structures/Hinkal/IHinkal';
6
6
  * @param UserKeys to access user's encryption keys
7
7
  * @returns shielded balance
8
8
  */
9
- export declare const getShieldedBalance: (hinkal: IHinkal) => Promise<TokenBalance[]>;
9
+ export declare const getShieldedBalance: (hinkal: IHinkal, chainId: number, passedShieldedPrivateKey: string, passedShieldedPublicKey: string, ethAddress: string, resetCacheBefore?: boolean, allowRemoteDecryption?: boolean, updateTokensListBefore?: boolean) => Promise<Map<string, TokenBalance>>;
10
10
  /**
11
11
  *
12
12
  * @param hinkal hinkal instance to get userKeys