@hinkal/common 0.2.19 → 0.2.21

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 (281) hide show
  1. package/API/API.cjs +1 -1
  2. package/API/API.d.ts +6 -1
  3. package/API/API.mjs +48 -41
  4. package/API/enclaveCalls.cjs +1 -1
  5. package/API/enclaveCalls.mjs +5 -4
  6. package/API/index.d.ts +1 -0
  7. package/API/proxyAccountsCalls.cjs +1 -1
  8. package/API/proxyAccountsCalls.d.ts +7 -2
  9. package/API/proxyAccountsCalls.mjs +26 -20
  10. package/API/temporaryWalletCalls.cjs +1 -0
  11. package/API/temporaryWalletCalls.d.ts +13 -0
  12. package/API/temporaryWalletCalls.mjs +20 -0
  13. package/API/unspent-utxos-calls.cjs +1 -1
  14. package/API/unspent-utxos-calls.d.ts +1 -1
  15. package/API/unspent-utxos-calls.mjs +16 -14
  16. package/README.md +36 -13
  17. package/constants/chains.constants.cjs +1 -1
  18. package/constants/chains.constants.d.ts +1 -1
  19. package/constants/chains.constants.mjs +69 -51
  20. package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
  21. package/constants/deploy-data/deploy-data-solana.json.mjs +28 -2
  22. package/constants/kyc.constants.cjs +1 -1
  23. package/constants/kyc.constants.mjs +39 -40
  24. package/constants/mediaUrls.constants.cjs +1 -1
  25. package/constants/mediaUrls.constants.d.ts +1 -0
  26. package/constants/mediaUrls.constants.mjs +2 -1
  27. package/constants/server.constants.cjs +1 -1
  28. package/constants/server.constants.d.ts +6 -1
  29. package/constants/server.constants.mjs +37 -32
  30. package/constants/token-data/polygonRegistry.json.cjs +1 -1
  31. package/constants/token-data/polygonRegistry.json.mjs +4 -4
  32. package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
  33. package/constants/token-data/polygonRegistryFixed.json.mjs +4 -4
  34. package/data-structures/AccountActions/AccountActions.cjs +1 -0
  35. package/data-structures/AccountActions/AccountActions.d.ts +18 -0
  36. package/data-structures/AccountActions/AccountActions.mjs +78 -0
  37. package/data-structures/AccountActions/index.d.ts +1 -0
  38. package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
  39. package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +68 -71
  40. package/data-structures/BlockchainEvent/BlockchainEvent.cjs +1 -0
  41. package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +14 -0
  42. package/data-structures/BlockchainEvent/BlockchainEvent.mjs +41 -0
  43. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  44. package/data-structures/Hinkal/Hinkal.d.ts +14 -8
  45. package/data-structures/Hinkal/Hinkal.mjs +215 -179
  46. package/data-structures/Hinkal/IHinkal.d.ts +9 -6
  47. package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
  48. package/data-structures/Hinkal/handleAutoDepositBack.mjs +47 -48
  49. package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
  50. package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -22
  51. package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
  52. package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -12
  53. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  54. package/data-structures/Hinkal/hinkalDeposit.mjs +63 -63
  55. package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
  56. package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +60 -147
  57. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -0
  58. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -0
  59. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +103 -0
  60. package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -0
  61. package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +4 -0
  62. package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +214 -0
  63. package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
  64. package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +4 -4
  65. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  66. package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
  67. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +103 -99
  68. package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
  69. package/data-structures/Hinkal/hinkalProxySwap.mjs +44 -41
  70. package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
  71. package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +31 -28
  72. package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
  73. package/data-structures/Hinkal/hinkalSignSubAccount.mjs +16 -13
  74. package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
  75. package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +34 -34
  76. package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
  77. package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +67 -65
  78. package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
  79. package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +35 -32
  80. package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
  81. package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +59 -56
  82. package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
  83. package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +35 -32
  84. package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
  85. package/data-structures/Hinkal/hinkalSolanaSwap.mjs +10 -10
  86. package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
  87. package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +25 -25
  88. package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
  89. package/data-structures/Hinkal/hinkalSwap.mjs +34 -30
  90. package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
  91. package/data-structures/Hinkal/hinkalTransfer.mjs +43 -39
  92. package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
  93. package/data-structures/Hinkal/hinkalWithdraw.mjs +47 -43
  94. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
  95. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +50 -46
  96. package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
  97. package/data-structures/Hinkal/resetMerkleTrees.mjs +36 -34
  98. package/data-structures/IndexedDB/activity-db.cjs +1 -1
  99. package/data-structures/IndexedDB/activity-db.d.ts +1 -0
  100. package/data-structures/IndexedDB/activity-db.mjs +86 -70
  101. package/data-structures/IndexedDB/balances-db.cjs +1 -1
  102. package/data-structures/IndexedDB/balances-db.mjs +33 -30
  103. package/data-structures/IndexedDB/contact-db.cjs +1 -1
  104. package/data-structures/IndexedDB/contact-db.mjs +9 -6
  105. package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +1 -0
  106. package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +20 -0
  107. package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +124 -0
  108. package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +1 -0
  109. package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +15 -0
  110. package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +64 -0
  111. package/data-structures/PublicBalance/index.d.ts +2 -0
  112. package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
  113. package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +77 -78
  114. package/data-structures/crypto-keys/keys.cjs +1 -1
  115. package/data-structures/crypto-keys/keys.d.ts +0 -11
  116. package/data-structures/crypto-keys/keys.mjs +47 -107
  117. package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
  118. package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +3 -2
  119. package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
  120. package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
  121. package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +3 -2
  122. package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
  123. package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
  124. package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +3 -2
  125. package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +6 -6
  126. package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
  127. package/data-structures/event-service/evm/AbstractEventService.d.ts +3 -2
  128. package/data-structures/event-service/evm/AbstractEventService.mjs +16 -19
  129. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
  130. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +3 -3
  131. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +6 -5
  132. package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +1 -1
  133. package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
  134. package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +7 -4
  135. package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +35 -34
  136. package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +1 -0
  137. package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +11 -0
  138. package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +21 -0
  139. package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +1 -0
  140. package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +6 -0
  141. package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +16 -0
  142. package/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -0
  143. package/data-structures/event-service/helpers/ClientEventHelper.d.ts +11 -0
  144. package/data-structures/event-service/helpers/ClientEventHelper.mjs +26 -0
  145. package/data-structures/event-service/helpers/PollingEventHelper.cjs +1 -0
  146. package/data-structures/event-service/helpers/PollingEventHelper.d.ts +5 -0
  147. package/data-structures/event-service/helpers/PollingEventHelper.mjs +14 -0
  148. package/data-structures/event-service/index.d.ts +4 -0
  149. package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
  150. package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +3 -2
  151. package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
  152. package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
  153. package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +4 -3
  154. package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +8 -8
  155. package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
  156. package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +3 -10
  157. package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +5 -5
  158. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
  159. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +3 -2
  160. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +1 -1
  161. package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +1 -1
  162. package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +1 -0
  163. package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +11 -0
  164. package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +22 -0
  165. package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +1 -0
  166. package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +6 -0
  167. package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +16 -0
  168. package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
  169. package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +8 -14
  170. package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +68 -67
  171. package/data-structures/index.d.ts +3 -0
  172. package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
  173. package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +5 -2
  174. package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
  175. package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +5 -2
  176. package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
  177. package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +5 -2
  178. package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
  179. package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +5 -2
  180. package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
  181. package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +5 -2
  182. package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
  183. package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +5 -2
  184. package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
  185. package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +5 -2
  186. package/data-structures/utxo/Utxo.cjs +1 -1
  187. package/data-structures/utxo/Utxo.d.ts +1 -0
  188. package/data-structures/utxo/Utxo.mjs +18 -4
  189. package/error-handling/error-codes.constants.cjs +1 -1
  190. package/error-handling/error-codes.constants.mjs +2 -2
  191. package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
  192. package/functions/pre-transaction/getSolanaCalldataHash.mjs +22 -22
  193. package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
  194. package/functions/pre-transaction/sendV0Transaction.mjs +53 -50
  195. package/functions/pre-transaction/solana.cjs +1 -1
  196. package/functions/pre-transaction/solana.mjs +93 -93
  197. package/functions/private-wallet/emporium.helpers.cjs +1 -1
  198. package/functions/private-wallet/emporium.helpers.d.ts +3 -2
  199. package/functions/private-wallet/emporium.helpers.mjs +118 -93
  200. package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
  201. package/functions/snarkjs/constructEmporiumProof.d.ts +1 -2
  202. package/functions/snarkjs/constructEmporiumProof.mjs +89 -89
  203. package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
  204. package/functions/snarkjs/constructSolanaZkProof.mjs +6 -2
  205. package/functions/utils/bytes32.utils.cjs +1 -1
  206. package/functions/utils/bytes32.utils.mjs +8 -7
  207. package/functions/utils/create-provider.cjs +1 -1
  208. package/functions/utils/create-provider.d.ts +1 -1
  209. package/functions/utils/create-provider.mjs +13 -9
  210. package/functions/utils/index.d.ts +0 -1
  211. package/functions/utils/prepareHinkal.cjs +1 -1
  212. package/functions/utils/prepareHinkal.d.ts +6 -7
  213. package/functions/utils/prepareHinkal.mjs +45 -53
  214. package/functions/utils/publicBalance.utils.cjs +1 -1
  215. package/functions/utils/publicBalance.utils.mjs +49 -54
  216. package/functions/utils/socket.utils.cjs +1 -0
  217. package/functions/utils/socket.utils.d.ts +1 -0
  218. package/functions/utils/socket.utils.mjs +12 -0
  219. package/functions/utils/string.utils.cjs +1 -1
  220. package/functions/utils/string.utils.d.ts +1 -0
  221. package/functions/utils/string.utils.mjs +18 -14
  222. package/functions/utils/walletBalances.utils.cjs +1 -1
  223. package/functions/utils/walletBalances.utils.d.ts +1 -1
  224. package/functions/utils/walletBalances.utils.mjs +4 -4
  225. package/functions/web3/crypto.cjs +1 -0
  226. package/functions/web3/crypto.d.ts +1 -0
  227. package/functions/web3/crypto.mjs +7 -0
  228. package/functions/web3/events/getApprovedBalance.cjs +1 -1
  229. package/functions/web3/events/getApprovedBalance.mjs +14 -14
  230. package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
  231. package/functions/web3/events/getInputUtxoAndBalance.mjs +61 -59
  232. package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
  233. package/functions/web3/events/getTransactionLogEvents.mjs +32 -32
  234. package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
  235. package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +6 -3
  236. package/functions/web3/functionCalls/approveToken.cjs +1 -1
  237. package/functions/web3/functionCalls/approveToken.mjs +17 -17
  238. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  239. package/functions/web3/functionCalls/transactCallDirect.mjs +16 -16
  240. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  241. package/functions/web3/functionCalls/transactCallRelayer.mjs +13 -11
  242. package/functions/web3/getContractMetadata.cjs +1 -1
  243. package/functions/web3/getContractMetadata.mjs +17 -22
  244. package/functions/web3/getTokenHolder.cjs +1 -1
  245. package/functions/web3/getTokenHolder.mjs +20 -20
  246. package/functions/web3/index.d.ts +1 -0
  247. package/index.cjs +1 -1
  248. package/index.mjs +913 -890
  249. package/package.json +3 -2
  250. package/providers/EthersProviderAdapter.cjs +1 -1
  251. package/providers/EthersProviderAdapter.mjs +2 -5
  252. package/providers/prepareEthersHinkal.cjs +1 -1
  253. package/providers/prepareEthersHinkal.mjs +11 -4
  254. package/providers/prepareWagmiHinkal.cjs +1 -1
  255. package/providers/prepareWagmiHinkal.mjs +11 -4
  256. package/types/activities.types.d.ts +2 -0
  257. package/types/bridging-tx.types.d.ts +17 -0
  258. package/types/cache.types.cjs +1 -1
  259. package/types/cache.types.d.ts +5 -1
  260. package/types/cache.types.mjs +1 -1
  261. package/types/ethereum-network.types.d.ts +1 -0
  262. package/types/events.types.cjs +1 -0
  263. package/types/events.types.d.ts +9 -0
  264. package/types/events.types.mjs +5 -0
  265. package/types/index.d.ts +2 -0
  266. package/types/proxy.types.d.ts +11 -4
  267. package/types/sandbox.types.d.ts +2 -0
  268. package/types/solana.types.d.ts +8 -0
  269. package/types/token.types.d.ts +5 -0
  270. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  271. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  272. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  273. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  274. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  275. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
  276. package/functions/kyc/authentoHelper.cjs +0 -1
  277. package/functions/kyc/authentoHelper.d.ts +0 -12
  278. package/functions/kyc/authentoHelper.mjs +0 -30
  279. package/functions/utils/get-hinkal-approvals.cjs +0 -1
  280. package/functions/utils/get-hinkal-approvals.d.ts +0 -3
  281. package/functions/utils/get-hinkal-approvals.mjs +0 -38
@@ -1,12 +1,12 @@
1
- import { get as k, update as g } from "idb-keyval";
1
+ import { get as N, update as l } from "idb-keyval";
2
2
  import { BigNumber as T } from "ethers";
3
3
  import "../../types/circom-data.types.mjs";
4
- import { solanaNativeAddress as P, zeroAddress as C } from "../../constants/protocol.constants.mjs";
4
+ import { solanaNativeAddress as C, zeroAddress as q } from "../../constants/protocol.constants.mjs";
5
5
  import "../../types/transactions.types.mjs";
6
6
  import { ActivityStatus as f } from "../../types/activities.types.mjs";
7
- import { StorageKeys as l } from "../../types/cache.types.mjs";
7
+ import { StorageKeys as c } from "../../types/cache.types.mjs";
8
8
  import "../../constants/token-data/index.mjs";
9
- import { isSolanaLike as N } from "../../constants/chains.constants.mjs";
9
+ import { isSolanaLike as H } from "../../constants/chains.constants.mjs";
10
10
  import "../../constants/contracts.constants.mjs";
11
11
  import "../../constants/kyc.constants.mjs";
12
12
  import "../../constants/server.constants.mjs";
@@ -21,118 +21,134 @@ import "../../constants/tasks.constants.mjs";
21
21
  import "../../constants/events.constants.mjs";
22
22
  import "@coral-xyz/anchor";
23
23
  import "@solana/web3.js";
24
- import { fixDecimalsAmount as b } from "../../functions/utils/amounts.utils.mjs";
24
+ import { fixDecimalsAmount as _ } from "../../functions/utils/amounts.utils.mjs";
25
25
  import "circomlibjs-hinkal-fork";
26
26
  import "../http/HttpClient.mjs";
27
- import { Logger as q } from "../../error-handling/logger.mjs";
28
- import { getERC20Token as _ } from "../../functions/utils/erc20tokenFunctions.mjs";
27
+ import { Logger as b } from "../../error-handling/logger.mjs";
28
+ import { getERC20Token as E } from "../../functions/utils/erc20tokenFunctions.mjs";
29
29
  import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
30
- import { getAmountInToken as E } from "../../functions/web3/etherFunctions.mjs";
30
+ import { getAmountInToken as R } from "../../functions/web3/etherFunctions.mjs";
31
31
  import "../crypto-keys/keys.mjs";
32
32
  import "../../error-handling/error-codes.constants.mjs";
33
33
  import "../../API/getServerURL.mjs";
34
34
  import "axios";
35
35
  import "@solana/spl-token";
36
+ import "ethers-v6h";
37
+ import "tweetnacl";
38
+ import "bs58";
39
+ import "buffer";
36
40
  import "../../functions/utils/userAgent.mjs";
37
41
  import "libsodium-wrappers";
38
42
  import "multiformats";
39
- import { API as H } from "../../API/API.mjs";
43
+ import { API as F } from "../../API/API.mjs";
40
44
  import "async-mutex";
41
- import "../../API/tenderly.api.mjs";
42
45
  import "process";
43
- import "buffer";
44
46
  import "../../providers/EthersProviderAdapter.mjs";
45
- import "node-forge";
47
+ import "../../functions/web3/events/getInputUtxoAndBalance.mjs";
46
48
  import "../../functions/web3/events/getApprovedBalance.mjs";
47
49
  import "../../functions/web3/getTokenHolder.mjs";
48
- import "ethers-v6h";
49
- class R {
50
+ import "node-forge";
51
+ class V {
50
52
  generateTxId() {
51
53
  const t = (/* @__PURE__ */ new Date()).getTime(), o = Math.random().toString(36).substring(2, 15);
52
54
  return `tx_${t}_${o}`;
53
55
  }
54
56
  async getTransactionRecord() {
55
- return await k(l.TX_ACTIVITY) || {};
57
+ return await N(c.TX_ACTIVITY) || {};
56
58
  }
57
59
  async saveTxRequest(t) {
58
60
  const {
59
61
  from: o,
60
62
  to: r,
61
- gas: i,
63
+ gas: e,
62
64
  gasPrice: a,
63
65
  gasInDollar: s,
64
- value: n,
65
- chainId: m,
66
- status: e,
67
- txHash: u,
68
- activityType: c,
69
- tokensReceive: p,
70
- tokensSpend: v,
71
- tokensApprove: y,
72
- ownerPublicAddress: w,
73
- activityIcon: A,
74
- dappUrl: h,
75
- dappName: x,
76
- integrationProvider: D
77
- } = t, d = this.generateTxId(), S = {
78
- id: d,
66
+ extraNativeTokenFee: n,
67
+ value: m,
68
+ chainId: i,
69
+ status: d,
70
+ txHash: p,
71
+ activityType: u,
72
+ tokensReceive: I,
73
+ tokensSpend: w,
74
+ tokensApprove: x,
75
+ ownerPublicAddress: h,
76
+ activityIcon: y,
77
+ dappUrl: A,
78
+ dappName: D,
79
+ integrationProvider: S,
80
+ knownPartialSignature: k
81
+ } = t, g = this.generateTxId(), P = {
82
+ id: g,
79
83
  from: o,
80
84
  to: r,
81
- gas: i,
85
+ gas: e,
82
86
  gasPrice: a,
83
87
  gasInDollar: s?.toString(),
84
- value: n,
85
- chainId: m,
86
- txHash: u,
87
- activityType: c,
88
- status: e ?? f.PENDING,
88
+ extraNativeTokenFee: n?.toString(),
89
+ value: m,
90
+ chainId: i,
91
+ txHash: p,
92
+ activityType: u,
93
+ status: d ?? f.PENDING,
89
94
  timestamp: /* @__PURE__ */ new Date(),
90
- tokensReceive: p,
91
- tokensSpend: v,
92
- tokensApprove: y,
93
- ownerPublicAddress: w,
94
- activityIcon: A,
95
- dappUrl: h,
96
- dappName: x,
97
- integrationProvider: D
95
+ tokensReceive: I,
96
+ tokensSpend: w,
97
+ tokensApprove: x,
98
+ ownerPublicAddress: h,
99
+ activityIcon: y,
100
+ dappUrl: A,
101
+ dappName: D,
102
+ integrationProvider: S,
103
+ knownPartialSignature: k
98
104
  };
99
- return await g(l.TX_ACTIVITY, (I = {}) => (I[d] = S, I)), d;
105
+ return await l(c.TX_ACTIVITY, (v = {}) => (v[g] = P, v)), g;
100
106
  }
101
107
  async getTxRequest(t) {
102
108
  return (await this.getTransactionRecord())[t] || null;
103
109
  }
104
110
  async getAllTxRequests(t) {
105
111
  const o = await this.getTransactionRecord();
106
- return Object.values(o).filter((r) => r.chainId === t).sort((r, i) => new Date(i.timestamp).getTime() - new Date(r.timestamp).getTime());
112
+ return Object.values(o).filter((r) => r.chainId === t).sort((r, e) => new Date(e.timestamp).getTime() - new Date(r.timestamp).getTime());
113
+ }
114
+ async updateTxHash(t, o) {
115
+ const r = await this.getTxRequest(t);
116
+ if (!r)
117
+ throw new Error("Activity not found");
118
+ const e = {
119
+ ...r,
120
+ txHash: o
121
+ };
122
+ await l(c.TX_ACTIVITY, (a = {}) => (a[t] = e, a));
107
123
  }
108
- async updateTxStatusAndHash(t, o, r, i, a, s, n, m) {
109
- const e = await this.getTxRequest(t);
110
- if (!e)
124
+ async updateTxStatusAndHash(t, o, r, e, a, s, n, m) {
125
+ const i = await this.getTxRequest(t);
126
+ if (!i)
111
127
  throw new Error("Transaction not found");
112
- const u = await this.getGasInDollar(n, m, e.chainId), c = {
113
- ...e,
128
+ const d = await this.getGasInDollar(n, m, i.chainId), p = {
129
+ ...i,
114
130
  status: o,
115
131
  txHash: r,
116
- value: e.value ?? i,
117
- from: e.from ?? a,
118
- to: e.to ?? s,
132
+ value: i.value ?? e,
133
+ from: i.from ?? a,
134
+ to: i.to ?? s,
119
135
  gas: n,
120
136
  gasPrice: m,
121
- gasInDollar: e.gasInDollar ?? u?.toString(),
137
+ gasInDollar: i.gasInDollar ?? d?.toString(),
122
138
  timestamp: /* @__PURE__ */ new Date()
123
139
  };
124
- return await g(l.TX_ACTIVITY, (p = {}) => (p[t] = c, p)), c;
140
+ return await l(c.TX_ACTIVITY, (u = {}) => (u[t] = p, u)), p;
125
141
  }
126
- async updateActivity(t, o, r, i, a, s, n, m) {
142
+ async updateActivity(t, o, r, e, a, s, n, m) {
127
143
  try {
128
- await this.updateTxStatusAndHash(t, o, r, i, a, s, n, m);
129
- } catch (e) {
130
- console.log("error in updating tx request", e);
144
+ await this.updateTxStatusAndHash(t, o, r, e, a, s, n, m);
145
+ } catch (i) {
146
+ console.log("error in updating tx request", i);
131
147
  }
132
148
  }
133
149
  async removePendingTransactions(t) {
134
150
  try {
135
- await g(l.TX_ACTIVITY, (o = {}) => (delete o[t], o));
151
+ await l(c.TX_ACTIVITY, (o = {}) => (delete o[t], o));
136
152
  } catch (o) {
137
153
  console.log("error in deleting tx requests", o);
138
154
  }
@@ -167,21 +183,21 @@ class R {
167
183
  getGasInDollar = async (t, o, r) => {
168
184
  if (!(!t || !o))
169
185
  try {
170
- const i = N(r) ? P : C, a = _(i, r);
186
+ const e = H(r) ? C : q, a = E(e, r);
171
187
  if (!a)
172
188
  return;
173
- const { prices: s } = await H.getTokenPrices(r, [a.erc20TokenAddress]), n = s[0];
189
+ const { prices: s } = await F.getTokenPrices(r, [a.erc20TokenAddress]), n = s[0];
174
190
  if (!n)
175
191
  return;
176
- const e = n * Number(E(a, o.toBigInt())) * Number(t.toBigInt());
177
- return b(e);
178
- } catch (i) {
179
- q.error("Failed to calculate gas cost in dollars:", { chainId: r, error: i });
192
+ const i = n * Number(R(a, o.toBigInt())) * Number(t.toBigInt());
193
+ return _(i);
194
+ } catch (e) {
195
+ b.error("Failed to calculate gas cost in dollars:", { chainId: r, error: e });
180
196
  return;
181
197
  }
182
198
  };
183
199
  }
184
- const qt = new R();
200
+ const Rt = new V();
185
201
  export {
186
- qt as activityStorage
202
+ Rt as activityStorage
187
203
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("idb-keyval");require("ethers");require("../../constants/chains.constants.cjs");require("@solana/web3.js");require("../http/HttpClient.cjs");const B=require("../../error-handling/logger.cjs");require("../../constants/token-data/index.cjs");require("../../error-handling/error-codes.constants.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("circomlibjs-hinkal-fork");require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/vite.constants.cjs");require("@coral-xyz/anchor");require("@solana/spl-token");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");const q=require("../../functions/utils/string.utils.cjs");require("libsodium-wrappers");require("multiformats");require("async-mutex");require("../../API/tenderly.api.cjs");require("process");require("buffer");require("../../providers/EthersProviderAdapter.cjs");class y{balancesRecordLabel="walletsBalances";async getBalances(){return await c.get(this.balancesRecordLabel)}async getBalancesByWallet(r,a){const e=await this.getBalances();if(!e)return;const i=q.getStateKey(r,a);return e[i]}async setBalances(r,a,e,i){let n=[];if(!i)return await c.update(this.balancesRecordLabel,(t={})=>{const u=q.getStateKey(a,r);return{...t,[u]:e}}),e;if(i.length===0)return await this.getBalancesByWallet(a,r)??[];try{await c.update(this.balancesRecordLabel,(t={})=>{const u=q.getStateKey(a,r),s=this.createBalanceLookup(t[u]),o=this.createBalanceLookup(e);return i.forEach(({erc20TokenAddress:g})=>{const l=g.toLowerCase();l in o?s[l]=o[l]:delete s[l]}),n=Object.values(s),{...t,[u]:n}})}catch(t){B.Logger.error("Failed to update wallet balances:",t)}return n}createBalanceLookup(r=[]){return r.reduce((a,e)=>({...a,[e.token.erc20TokenAddress.toLowerCase()]:e}),{})}}const w=new y;exports.publicBalancesStorage=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("idb-keyval");require("ethers");require("../../constants/chains.constants.cjs");require("@solana/web3.js");require("../http/HttpClient.cjs");const B=require("../../error-handling/logger.cjs");require("../../constants/token-data/index.cjs");require("../../error-handling/error-codes.constants.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("circomlibjs-hinkal-fork");require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/vite.constants.cjs");require("@coral-xyz/anchor");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("buffer");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");const q=require("../../functions/utils/string.utils.cjs");require("libsodium-wrappers");require("multiformats");require("../../API/enclaveCalls.cjs");require("async-mutex");require("process");require("../../providers/EthersProviderAdapter.cjs");class y{balancesRecordLabel="walletsBalances";async getBalances(){return await c.get(this.balancesRecordLabel)}async getBalancesByWallet(r,a){const e=await this.getBalances();if(!e)return;const i=q.getStateKey(r,a);return e[i]}async setBalances(r,a,e,i){let n=[];if(!i)return await c.update(this.balancesRecordLabel,(t={})=>{const u=q.getStateKey(a,r);return{...t,[u]:e}}),e;if(i.length===0)return await this.getBalancesByWallet(a,r)??[];try{await c.update(this.balancesRecordLabel,(t={})=>{const u=q.getStateKey(a,r),s=this.createBalanceLookup(t[u]),o=this.createBalanceLookup(e);return i.forEach(({erc20TokenAddress:g})=>{const l=g.toLowerCase();l in o?s[l]=o[l]:delete s[l]}),n=Object.values(s),{...t,[u]:n}})}catch(t){B.Logger.error("Failed to update wallet balances:",t)}return n}createBalanceLookup(r=[]){return r.reduce((a,e)=>({...a,[e.token.erc20TokenAddress.toLowerCase()]:e}),{})}}const w=new y;exports.publicBalancesStorage=w;
@@ -18,6 +18,10 @@ import "axios";
18
18
  import "../../constants/vite.constants.mjs";
19
19
  import "@coral-xyz/anchor";
20
20
  import "@solana/spl-token";
21
+ import "ethers-v6h";
22
+ import "tweetnacl";
23
+ import "bs58";
24
+ import "buffer";
21
25
  import "../../constants/contracts.constants.mjs";
22
26
  import "../../constants/kyc.constants.mjs";
23
27
  import "../../constants/coingecko.constants.mjs";
@@ -29,65 +33,64 @@ import "../../constants/activity.constants.mjs";
29
33
  import "../../constants/tasks.constants.mjs";
30
34
  import "../../constants/events.constants.mjs";
31
35
  import "../../functions/utils/userAgent.mjs";
32
- import { getStateKey as c } from "../../functions/utils/string.utils.mjs";
36
+ import { getStateKey as n } from "../../functions/utils/string.utils.mjs";
33
37
  import "libsodium-wrappers";
34
38
  import "multiformats";
39
+ import "../../API/enclaveCalls.mjs";
35
40
  import "async-mutex";
36
- import "../../API/tenderly.api.mjs";
37
41
  import "process";
38
- import "buffer";
39
42
  import "../../providers/EthersProviderAdapter.mjs";
40
43
  class g {
41
44
  balancesRecordLabel = "walletsBalances";
42
45
  async getBalances() {
43
46
  return await u(this.balancesRecordLabel);
44
47
  }
45
- async getBalancesByWallet(e, r) {
48
+ async getBalancesByWallet(r, e) {
46
49
  const t = await this.getBalances();
47
50
  if (!t)
48
51
  return;
49
- const o = c(e, r);
50
- return t[o];
52
+ const a = n(r, e);
53
+ return t[a];
51
54
  }
52
- async setBalances(e, r, t, o) {
53
- let l = [];
54
- if (!o)
55
- return await s(this.balancesRecordLabel, (a = {}) => {
56
- const i = c(r, e);
55
+ async setBalances(r, e, t, a) {
56
+ let m = [];
57
+ if (!a)
58
+ return await s(this.balancesRecordLabel, (o = {}) => {
59
+ const i = n(e, r);
57
60
  return {
58
- ...a,
61
+ ...o,
59
62
  [i]: t
60
63
  };
61
64
  }), t;
62
- if (o.length === 0)
63
- return await this.getBalancesByWallet(r, e) ?? [];
65
+ if (a.length === 0)
66
+ return await this.getBalancesByWallet(e, r) ?? [];
64
67
  try {
65
- await s(this.balancesRecordLabel, (a = {}) => {
66
- const i = c(r, e), n = this.createBalanceLookup(a[i]), m = this.createBalanceLookup(t);
67
- return o.forEach(({ erc20TokenAddress: B }) => {
68
+ await s(this.balancesRecordLabel, (o = {}) => {
69
+ const i = n(e, r), l = this.createBalanceLookup(o[i]), c = this.createBalanceLookup(t);
70
+ return a.forEach(({ erc20TokenAddress: B }) => {
68
71
  const p = B.toLowerCase();
69
- p in m ? n[p] = m[p] : delete n[p];
70
- }), l = Object.values(n), {
71
- ...a,
72
- [i]: l
72
+ p in c ? l[p] = c[p] : delete l[p];
73
+ }), m = Object.values(l), {
74
+ ...o,
75
+ [i]: m
73
76
  };
74
77
  });
75
- } catch (a) {
76
- w.error("Failed to update wallet balances:", a);
78
+ } catch (o) {
79
+ w.error("Failed to update wallet balances:", o);
77
80
  }
78
- return l;
81
+ return m;
79
82
  }
80
- createBalanceLookup(e = []) {
81
- return e.reduce(
82
- (r, t) => ({
83
- ...r,
83
+ createBalanceLookup(r = []) {
84
+ return r.reduce(
85
+ (e, t) => ({
86
+ ...e,
84
87
  [t.token.erc20TokenAddress.toLowerCase()]: t
85
88
  }),
86
89
  {}
87
90
  );
88
91
  }
89
92
  }
90
- const rt = new g();
93
+ const it = new g();
91
94
  export {
92
- rt as publicBalancesStorage
95
+ it as publicBalancesStorage
93
96
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("idb-keyval"),q=require("../../error-handling/logger.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("../../constants/chains.constants.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("ethers");require("circomlibjs-hinkal-fork");require("../../constants/kyc.constants.cjs");require("../http/HttpClient.cjs");require("../../constants/token-data/index.cjs");require("../../error-handling/error-codes.constants.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/vite.constants.cjs");const d=require("../../functions/utils/caseInsensitive.utils.cjs");require("@solana/spl-token");require("../../constants/contracts.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");require("libsodium-wrappers");require("multiformats");require("async-mutex");require("../../API/tenderly.api.cjs");require("process");require("buffer");require("../../providers/EthersProviderAdapter.cjs");require("node-forge");require("../../functions/web3/events/getApprovedBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");require("ethers-v6h");class l{STORAGE_KEY="contacts";checkForDuplicate(o,e,r){if(o.find(({ethereumAddress:t,nickname:i})=>(t===e.ethereumAddress||i===e.nickname)&&t!==r)!==void 0)throw new Error("Duplicate Contact attribute")}async createContact(o,e){const r=o.toLowerCase();await s.update(this.STORAGE_KEY,c=>{const t=c??{},i=t[r]??[];return this.checkForDuplicate(i,e),i.push(e),t[r]=i,t})}async getContacts(o){try{const e=o.toLowerCase(),r=await s.get(this.STORAGE_KEY);return!r||!r[e]?[]:r[e]}catch(e){return q.Logger.error("Error while getting contacts:",e),[]}}async editContact(o,e,r){const c=o.toLowerCase();await s.update(this.STORAGE_KEY,t=>{const i=t??{},a=i[c];if(!i||!a)throw new Error("Contacts could not be fetched");this.checkForDuplicate(a,r,e);const n=a.findIndex(({ethereumAddress:u})=>d.caseInsensitiveEqual(u,e));if(n===-1)throw new Error("Contact to be edited was not found");return a[n]=r,i[c]=a,i})}async deleteContact(o,e){const r=o.toLowerCase();await s.update(this.STORAGE_KEY,c=>{const t=c??{},i=t[r];if(!t||!i)throw new Error("Contacts could not be fetched");const a=i.filter(({ethereumAddress:n})=>n!==e);return t[r]=a,t})}}const w=new l;exports.contactStorage=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("idb-keyval"),q=require("../../error-handling/logger.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("../../constants/chains.constants.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("ethers");require("circomlibjs-hinkal-fork");require("../../constants/kyc.constants.cjs");require("../http/HttpClient.cjs");require("../../constants/token-data/index.cjs");require("../../error-handling/error-codes.constants.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/vite.constants.cjs");const d=require("../../functions/utils/caseInsensitive.utils.cjs");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("buffer");require("../../constants/contracts.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");require("libsodium-wrappers");require("multiformats");require("../../API/enclaveCalls.cjs");require("async-mutex");require("process");require("../../providers/EthersProviderAdapter.cjs");require("../../functions/web3/events/getInputUtxoAndBalance.cjs");require("../../functions/web3/events/getApprovedBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");require("node-forge");class l{STORAGE_KEY="contacts";checkForDuplicate(o,e,r){if(o.find(({ethereumAddress:t,nickname:i})=>(t===e.ethereumAddress||i===e.nickname)&&t!==r)!==void 0)throw new Error("Duplicate Contact attribute")}async createContact(o,e){const r=o.toLowerCase();await u.update(this.STORAGE_KEY,c=>{const t=c??{},i=t[r]??[];return this.checkForDuplicate(i,e),i.push(e),t[r]=i,t})}async getContacts(o){try{const e=o.toLowerCase(),r=await u.get(this.STORAGE_KEY);return!r||!r[e]?[]:r[e]}catch(e){return q.Logger.error("Error while getting contacts:",e),[]}}async editContact(o,e,r){const c=o.toLowerCase();await u.update(this.STORAGE_KEY,t=>{const i=t??{},a=i[c];if(!i||!a)throw new Error("Contacts could not be fetched");this.checkForDuplicate(a,r,e);const n=a.findIndex(({ethereumAddress:s})=>d.caseInsensitiveEqual(s,e));if(n===-1)throw new Error("Contact to be edited was not found");return a[n]=r,i[c]=a,i})}async deleteContact(o,e){const r=o.toLowerCase();await u.update(this.STORAGE_KEY,c=>{const t=c??{},i=t[r];if(!t||!i)throw new Error("Contacts could not be fetched");const a=i.filter(({ethereumAddress:n})=>n!==e);return t[r]=a,t})}}const w=new l;exports.contactStorage=w;
@@ -20,6 +20,10 @@ import "axios";
20
20
  import "../../constants/vite.constants.mjs";
21
21
  import { caseInsensitiveEqual as l } from "../../functions/utils/caseInsensitive.utils.mjs";
22
22
  import "@solana/spl-token";
23
+ import "ethers-v6h";
24
+ import "tweetnacl";
25
+ import "bs58";
26
+ import "buffer";
23
27
  import "../../constants/contracts.constants.mjs";
24
28
  import "../../constants/coingecko.constants.mjs";
25
29
  import "../../constants/reorg-depths.constants.mjs";
@@ -32,15 +36,14 @@ import "../../constants/events.constants.mjs";
32
36
  import "../../functions/utils/userAgent.mjs";
33
37
  import "libsodium-wrappers";
34
38
  import "multiformats";
39
+ import "../../API/enclaveCalls.mjs";
35
40
  import "async-mutex";
36
- import "../../API/tenderly.api.mjs";
37
41
  import "process";
38
- import "buffer";
39
42
  import "../../providers/EthersProviderAdapter.mjs";
40
- import "node-forge";
43
+ import "../../functions/web3/events/getInputUtxoAndBalance.mjs";
41
44
  import "../../functions/web3/events/getApprovedBalance.mjs";
42
45
  import "../../functions/web3/getTokenHolder.mjs";
43
- import "ethers-v6h";
46
+ import "node-forge";
44
47
  class w {
45
48
  STORAGE_KEY = "contacts";
46
49
  checkForDuplicate(e, t, o) {
@@ -92,7 +95,7 @@ class w {
92
95
  });
93
96
  }
94
97
  }
95
- const et = new w();
98
+ const nt = new w();
96
99
  export {
97
- et as contactStorage
100
+ nt as contactStorage
98
101
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("ethers-v6h"),u=require("../../constants/chains.constants.cjs"),b=require("../../externalABIs/index.cjs"),l=require("../../functions/utils/caseInsensitive.utils.cjs"),d=require("../../functions/utils/string.utils.cjs"),C=1e4;class g{subscribedAddresses=new Set;providers=new Map;nativeBalances=new Map;balanceChangeCallback;eventListeners=new Map;constructor(){u.WALLET_SUPPORTED_CHAINS.forEach(e=>{u.isSolanaLike(e)||this.initializeChain(e)})}initializeChain(e){const{wsRpcUrl:t}=u.networkRegistry[e];if(!t)return;const n=new i.WebSocketProvider(t,e);this.providers.set(e,n),this.eventListeners.set(e,[]),this.setupNativeBalanceListener(n,e),this.setupFilteredEventListeners(n,e)}setupFilteredEventListeners(e,t){if(this.eventListeners.get(t)?.forEach(h=>h()),this.eventListeners.set(t,[]),this.subscribedAddresses.size===0)return;const s=Array.from(this.subscribedAddresses).map(h=>i.zeroPadValue(h,32)),r=i.keccak256(i.toUtf8Bytes("Transfer(address,address,uint256)")),c=i.keccak256(i.toUtf8Bytes("TransferSingle(address,address,address,uint256,uint256)")),o=i.keccak256(i.toUtf8Bytes("TransferBatch(address,address,address,uint256[],uint256[])")),a=this.setupERC20Listener(e,[r,s]),f=this.setupERC20Listener(e,[r,null,s]),v=this.setupERC1155Listener(e,[c,null,s]),p=this.setupERC1155Listener(e,[c,null,null,s]),E=this.setupERC1155Listener(e,[o,null,s]),L=this.setupERC1155Listener(e,[o,null,null,s]);this.eventListeners.set(t,[a,f,v,p,E,L])}setupERC20Listener(e,t){const n=s=>{try{const r=new i.Interface(b.ERC20ABI).parseLog({topics:s.topics,data:s.data});if(!r)return;const{from:c,to:o}=r.args;Array.from(this.subscribedAddresses).filter(a=>l.caseInsensitiveEqual(a,c)||l.caseInsensitiveEqual(a,o)).forEach(a=>this.balanceChangeCallback?.(a))}catch{}};return e.on({topics:t},n),()=>e.off({topics:t},n)}setupERC1155Listener(e,t){const n=s=>{try{const r=new i.Interface(b.ERC1155ABI).parseLog({topics:s.topics,data:s.data});if(!r)return;const{from:c,to:o}=r.args;Array.from(this.subscribedAddresses).filter(a=>l.caseInsensitiveEqual(a,c)||l.caseInsensitiveEqual(a,o)).forEach(a=>this.balanceChangeCallback?.(a))}catch{}};return e.on({topics:t},n),()=>e.off({topics:t},n)}setupNativeBalanceListener(e,t){setInterval(async()=>{if(this.subscribedAddresses.size!==0)try{await Promise.all(Array.from(this.subscribedAddresses).map(async n=>{const s=await e.getBalance(n),r=d.getStateKey(n,t),c=this.nativeBalances.get(r)??0n;s!==c&&(this.nativeBalances.set(r,s),this.balanceChangeCallback?.(n))}))}catch{}},C)}async subscribe(e){const t=e.toLowerCase();this.subscribedAddresses.has(t)||(this.subscribedAddresses.add(t),this.providers.forEach((n,s)=>this.setupFilteredEventListeners(n,s)),await Promise.all(u.WALLET_SUPPORTED_CHAINS.map(async n=>{const s=this.providers.get(n);if(s)try{const r=await s.getBalance(t);this.nativeBalances.set(d.getStateKey(t,n),r)}catch{}})))}unsubscribe(e){const t=e.toLowerCase();this.subscribedAddresses.delete(t),this.nativeBalances.forEach((n,s)=>{l.caseInsensitiveEqual(d.getAddressFromStateKey(s),t)&&this.nativeBalances.delete(s)}),this.providers.forEach((n,s)=>this.setupFilteredEventListeners(n,s))}onBalanceChange(e){return this.balanceChangeCallback=e,()=>{this.balanceChangeCallback=void 0}}cleanup(){this.eventListeners.forEach(e=>e.forEach(t=>t())),this.eventListeners.clear()}}const A=new g;exports.publicBalanceWatcher=A;
@@ -0,0 +1,20 @@
1
+ type BalanceChangeCallback = (walletAddress: string) => void | Promise<void>;
2
+ declare class PublicBalanceWatcher {
3
+ private subscribedAddresses;
4
+ private providers;
5
+ private nativeBalances;
6
+ private balanceChangeCallback?;
7
+ private eventListeners;
8
+ constructor();
9
+ private initializeChain;
10
+ private setupFilteredEventListeners;
11
+ private setupERC20Listener;
12
+ private setupERC1155Listener;
13
+ private setupNativeBalanceListener;
14
+ subscribe(address: string): Promise<void>;
15
+ unsubscribe(address: string): void;
16
+ onBalanceChange(callback: BalanceChangeCallback): () => void;
17
+ cleanup(): void;
18
+ }
19
+ export declare const publicBalanceWatcher: PublicBalanceWatcher;
20
+ export {};
@@ -0,0 +1,124 @@
1
+ import { WebSocketProvider as E, zeroPadValue as A, keccak256 as h, toUtf8Bytes as d, Interface as u } from "ethers-v6h";
2
+ import { WALLET_SUPPORTED_CHAINS as f, isSolanaLike as B, networkRegistry as g } from "../../constants/chains.constants.mjs";
3
+ import { ERC20ABI as w, ERC1155ABI as y } from "../../externalABIs/index.mjs";
4
+ import { caseInsensitiveEqual as o } from "../../functions/utils/caseInsensitive.utils.mjs";
5
+ import { getStateKey as b, getAddressFromStateKey as T } from "../../functions/utils/string.utils.mjs";
6
+ const R = 1e4;
7
+ class k {
8
+ subscribedAddresses = /* @__PURE__ */ new Set();
9
+ providers = /* @__PURE__ */ new Map();
10
+ nativeBalances = /* @__PURE__ */ new Map();
11
+ balanceChangeCallback;
12
+ eventListeners = /* @__PURE__ */ new Map();
13
+ constructor() {
14
+ f.forEach((e) => {
15
+ B(e) || this.initializeChain(e);
16
+ });
17
+ }
18
+ initializeChain(e) {
19
+ const { wsRpcUrl: t } = g[e];
20
+ if (!t)
21
+ return;
22
+ const r = new E(t, e);
23
+ this.providers.set(e, r), this.eventListeners.set(e, []), this.setupNativeBalanceListener(r, e), this.setupFilteredEventListeners(r, e);
24
+ }
25
+ setupFilteredEventListeners(e, t) {
26
+ if (this.eventListeners.get(t)?.forEach((l) => l()), this.eventListeners.set(t, []), this.subscribedAddresses.size === 0)
27
+ return;
28
+ const s = Array.from(this.subscribedAddresses).map((l) => A(l, 32)), a = h(d("Transfer(address,address,uint256)")), i = h(
29
+ d("TransferSingle(address,address,address,uint256,uint256)")
30
+ ), c = h(
31
+ d("TransferBatch(address,address,address,uint256[],uint256[])")
32
+ ), n = this.setupERC20Listener(e, [a, s]), p = this.setupERC20Listener(e, [a, null, s]), L = this.setupERC1155Listener(e, [i, null, s]), m = this.setupERC1155Listener(e, [
33
+ i,
34
+ null,
35
+ null,
36
+ s
37
+ ]), v = this.setupERC1155Listener(e, [c, null, s]), C = this.setupERC1155Listener(e, [
38
+ c,
39
+ null,
40
+ null,
41
+ s
42
+ ]);
43
+ this.eventListeners.set(t, [
44
+ n,
45
+ p,
46
+ L,
47
+ m,
48
+ v,
49
+ C
50
+ ]);
51
+ }
52
+ setupERC20Listener(e, t) {
53
+ const r = (s) => {
54
+ try {
55
+ const a = new u(w).parseLog({ topics: s.topics, data: s.data });
56
+ if (!a)
57
+ return;
58
+ const { from: i, to: c } = a.args;
59
+ Array.from(this.subscribedAddresses).filter((n) => o(n, i) || o(n, c)).forEach((n) => this.balanceChangeCallback?.(n));
60
+ } catch {
61
+ }
62
+ };
63
+ return e.on({ topics: t }, r), () => e.off({ topics: t }, r);
64
+ }
65
+ setupERC1155Listener(e, t) {
66
+ const r = (s) => {
67
+ try {
68
+ const a = new u(y).parseLog({ topics: s.topics, data: s.data });
69
+ if (!a)
70
+ return;
71
+ const { from: i, to: c } = a.args;
72
+ Array.from(this.subscribedAddresses).filter((n) => o(n, i) || o(n, c)).forEach((n) => this.balanceChangeCallback?.(n));
73
+ } catch {
74
+ }
75
+ };
76
+ return e.on({ topics: t }, r), () => e.off({ topics: t }, r);
77
+ }
78
+ setupNativeBalanceListener(e, t) {
79
+ setInterval(async () => {
80
+ if (this.subscribedAddresses.size !== 0)
81
+ try {
82
+ await Promise.all(
83
+ Array.from(this.subscribedAddresses).map(async (r) => {
84
+ const s = await e.getBalance(r), a = b(r, t), i = this.nativeBalances.get(a) ?? 0n;
85
+ s !== i && (this.nativeBalances.set(a, s), this.balanceChangeCallback?.(r));
86
+ })
87
+ );
88
+ } catch {
89
+ }
90
+ }, R);
91
+ }
92
+ async subscribe(e) {
93
+ const t = e.toLowerCase();
94
+ this.subscribedAddresses.has(t) || (this.subscribedAddresses.add(t), this.providers.forEach((r, s) => this.setupFilteredEventListeners(r, s)), await Promise.all(
95
+ f.map(async (r) => {
96
+ const s = this.providers.get(r);
97
+ if (s)
98
+ try {
99
+ const a = await s.getBalance(t);
100
+ this.nativeBalances.set(b(t, r), a);
101
+ } catch {
102
+ }
103
+ })
104
+ ));
105
+ }
106
+ unsubscribe(e) {
107
+ const t = e.toLowerCase();
108
+ this.subscribedAddresses.delete(t), this.nativeBalances.forEach((r, s) => {
109
+ o(T(s), t) && this.nativeBalances.delete(s);
110
+ }), this.providers.forEach((r, s) => this.setupFilteredEventListeners(r, s));
111
+ }
112
+ onBalanceChange(e) {
113
+ return this.balanceChangeCallback = e, () => {
114
+ this.balanceChangeCallback = void 0;
115
+ };
116
+ }
117
+ cleanup() {
118
+ this.eventListeners.forEach((e) => e.forEach((t) => t())), this.eventListeners.clear();
119
+ }
120
+ }
121
+ const W = new k();
122
+ export {
123
+ W as publicBalanceWatcher
124
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@solana/spl-token"),t=require("../../constants/chains.constants.cjs"),a=require("@solana/web3.js"),b=15e3;class r{connection;subscribedAddresses=new Set;solBalances=new Map;balanceChangeCallback;constructor(){this.connection=new a.Connection(t.networkRegistry[t.chainIds.solanaMainnet].fetchRpcUrl??"","confirmed")}async subscribe(e){if(this.subscribedAddresses.has(e))return;const c=new a.PublicKey(e);this.subscribedAddresses.add(e);const o=await this.connection.getBalance(c);this.solBalances.set(e,o),this.connection.onAccountChange(c,i=>{const n=i.lamports,l=this.solBalances.get(e)??0;n!==l&&(this.solBalances.set(e,n),this.executeCallback(e))}),this.subscribeTokenAccounts(c,s.TOKEN_PROGRAM_ID),this.subscribeTokenAccounts(c,s.TOKEN_2022_PROGRAM_ID)}unsubscribe(e){this.subscribedAddresses.delete(e),this.solBalances.delete(e)}onBalanceChange(e){return this.balanceChangeCallback=e,()=>{this.balanceChangeCallback=void 0}}subscribeTokenAccounts(e,c){this.connection.onProgramAccountChange(c,()=>{this.executeCallback(e.toBase58())},{commitment:"confirmed",filters:[{memcmp:{offset:32,bytes:e.toBase58()}}]})}executeCallback(e){setTimeout(()=>{try{this.balanceChangeCallback?.(e)}catch{}},b)}}const h=new r;exports.solanaPublicBalanceWatcher=h;
@@ -0,0 +1,15 @@
1
+ type BalanceChangeCallback = (walletAddress: string) => void | Promise<void>;
2
+ declare class SolanaPublicBalanceWatcher {
3
+ private connection;
4
+ private subscribedAddresses;
5
+ private solBalances;
6
+ private balanceChangeCallback?;
7
+ constructor();
8
+ subscribe(address: string): Promise<void>;
9
+ unsubscribe(address: string): void;
10
+ onBalanceChange(callback: BalanceChangeCallback): () => void;
11
+ private subscribeTokenAccounts;
12
+ private executeCallback;
13
+ }
14
+ export declare const solanaPublicBalanceWatcher: SolanaPublicBalanceWatcher;
15
+ export {};