@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
@@ -0,0 +1,64 @@
1
+ import { TOKEN_PROGRAM_ID as o, TOKEN_2022_PROGRAM_ID as i } from "@solana/spl-token";
2
+ import { networkRegistry as l, chainIds as b } from "../../constants/chains.constants.mjs";
3
+ import { Connection as h, PublicKey as r } from "@solana/web3.js";
4
+ const u = 15e3;
5
+ class m {
6
+ connection;
7
+ subscribedAddresses = /* @__PURE__ */ new Set();
8
+ solBalances = /* @__PURE__ */ new Map();
9
+ balanceChangeCallback;
10
+ constructor() {
11
+ this.connection = new h(l[b.solanaMainnet].fetchRpcUrl ?? "", "confirmed");
12
+ }
13
+ async subscribe(e) {
14
+ if (this.subscribedAddresses.has(e))
15
+ return;
16
+ const c = new r(e);
17
+ this.subscribedAddresses.add(e);
18
+ const t = await this.connection.getBalance(c);
19
+ this.solBalances.set(e, t), this.connection.onAccountChange(c, (s) => {
20
+ const n = s.lamports, a = this.solBalances.get(e) ?? 0;
21
+ n !== a && (this.solBalances.set(e, n), this.executeCallback(e));
22
+ }), this.subscribeTokenAccounts(c, o), this.subscribeTokenAccounts(c, i);
23
+ }
24
+ unsubscribe(e) {
25
+ this.subscribedAddresses.delete(e), this.solBalances.delete(e);
26
+ }
27
+ onBalanceChange(e) {
28
+ return this.balanceChangeCallback = e, () => {
29
+ this.balanceChangeCallback = void 0;
30
+ };
31
+ }
32
+ subscribeTokenAccounts(e, c) {
33
+ this.connection.onProgramAccountChange(
34
+ c,
35
+ () => {
36
+ this.executeCallback(e.toBase58());
37
+ },
38
+ {
39
+ commitment: "confirmed",
40
+ filters: [
41
+ {
42
+ memcmp: {
43
+ offset: 32,
44
+ // owner field in SPL token account
45
+ bytes: e.toBase58()
46
+ }
47
+ }
48
+ ]
49
+ }
50
+ );
51
+ }
52
+ executeCallback(e) {
53
+ setTimeout(() => {
54
+ try {
55
+ this.balanceChangeCallback?.(e);
56
+ } catch {
57
+ }
58
+ }, u);
59
+ }
60
+ }
61
+ const f = new m();
62
+ export {
63
+ f as solanaPublicBalanceWatcher
64
+ };
@@ -0,0 +1,2 @@
1
+ export * from './PublicBalanceWatcher';
2
+ export * from './SolanaPublicBalancerWatcher';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("ethers"),T=require("idb-keyval"),_=require("../../API/API.cjs"),m=require("../../constants/chains.constants.cjs"),p=require("../../error-handling/logger.cjs"),E=require("../../functions/utils/caseInsensitive.utils.cjs"),g=require("../../types/cache.types.cjs"),d=require("../../functions/utils/string.utils.cjs"),A=require("../../constants/protocol.constants.cjs"),C=require("async-mutex"),S=require("../../functions/utils/erc20tokenFunctions.cjs"),I=require("./token-visibility-db.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("../../constants/kyc.constants.cjs");const K=require("../../functions/utils/create-provider.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../error-handling/error-codes.constants.cjs");require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");require("@solana/spl-token");require("../../constants/token-data/index.cjs");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");const x=require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");require("libsodium-wrappers");require("multiformats");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 P{fetchedTokens={};updateMutexes={};transferEventTopic=k.ethers.utils.id("Transfer(address,address,uint256)");getMutex(r){return this.updateMutexes[r]||(this.updateMutexes[r]=new C.Mutex),this.updateMutexes[r]}async getPublicTokens(r,o){const t=d.getStateKey(o,r);return(await T.get(g.StorageKeys.EVENTS_PUBLIC_TOKENS))?.[t]||[]}getFetchedTokens(r,o){const t=d.getStateKey(o,r);return this.fetchedTokens[t]||[]}async fetchAndUpdatePublicTokens(r,o){const t=d.getStateKey(r,o);await this.getMutex(t).runExclusive(async()=>{try{const s=(await this.getPublicTokens(o,r)).map(a=>a.erc20TokenAddress),{toEvents:i,fromEvents:u,latestBlock:c}=await this.getEvents(r,o),q=[...i,...u],{erc20Tokens:l}=await this.fetchPublicTokens(q,o,s),b=await I.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(o,l),B=l.filter(a=>!E.lowerCaseIncludes(b,a.erc20TokenAddress));await T.update(g.StorageKeys.EVENTS_PUBLIC_TOKENS,(a={})=>{const h=a[t]||[],w=h.map(f=>f.erc20TokenAddress),L=B.filter(f=>!E.lowerCaseIncludes(w,f.erc20TokenAddress));h.push(...L);const v=this.updateTokenIds(u,i,h),y={...a,[t]:v};return this.fetchedTokens=y,y}),c&&await this.updateLastProcessedBlock(o,r,c)}catch(e){p.Logger.error("public tokens db error",e)}})}async getLastProcessedBlock(r,o){const t=await T.get(g.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS)||{},n=d.getStateKey(o,r);return t[n]||x.EVENTS_INITIAL_BLOCKS[r]}async updateLastProcessedBlock(r,o,t){await T.update(g.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS,(n={})=>{const e=d.getStateKey(o,r);return{...n,[e]:t}})}async getEvents(r,o){try{const{fetchRpcUrl:t}=m.networkRegistry[o];if(!t)throw Error("No fetchRpcUrl in PublicTokensDB");const n=K.createCustomRpcProvider(t),e=await this.getLastProcessedBlock(o,r)+1,s=await n.getBlockNumber(),i=k.ethers.utils.hexZeroPad(r.toLowerCase(),32),u={topics:[this.transferEventTopic,null,i],fromBlock:e,toBlock:s},c={topics:[this.transferEventTopic,i,null],fromBlock:e,toBlock:s},[q,l]=await Promise.all([n.getLogs(u),n.getLogs(c)]);return{toEvents:q,fromEvents:l,latestBlock:s}}catch(t){return p.Logger.error("Error fetching events:",t),{toEvents:[],fromEvents:[],latestBlock:void 0}}}updateTokenIds(r,o,t){const n=new Map;return t.forEach(e=>{if(S.isNFTToken(e)&&e.tokenIds){const s=e.erc20TokenAddress.toLowerCase();n.set(s,[...e.tokenIds])}}),o.forEach(e=>{if(e.topics.length<=3)return;const s=e.address.toLowerCase(),i=k.ethers.BigNumber.from(e.topics[3]).toString();n.has(s)||n.set(s,[]),n.get(s)?.push(i)}),r.forEach(e=>{if(e.topics.length<=3)return;const s=e.address.toLowerCase(),i=n.get(s);if(i?.length){const u=k.ethers.BigNumber.from(e.topics[3]).toString(),c=i.indexOf(u);c!==-1&&i.splice(c,1)}}),t.forEach(e=>{if(S.isNFTToken(e)){const s=e.erc20TokenAddress.toLowerCase(),i=n.get(s);e.tokenIds=i?.length&&i.length>0?i:void 0}}),t}async fetchPublicTokens(r,o,t){try{const n=[A.zeroAddress,...new Set(r.map(s=>s.address))].filter(s=>s&&!E.lowerCaseIncludes(t,s));return n.length?{erc20Tokens:(await _.API.tokensInfoCall(o,n)).filter(s=>!!s)}:{erc20Tokens:[]}}catch(n){return p.Logger.error("Error fetching public tokens:",n),{erc20Tokens:[]}}}}const N=new P;exports.EventsPublicTokensDB=P;exports.eventsPublicTokensDB=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("ethers"),k=require("idb-keyval"),m=require("../../API/API.cjs"),f=require("../../error-handling/logger.cjs"),p=require("../../functions/utils/caseInsensitive.utils.cjs"),T=require("../../types/cache.types.cjs"),d=require("../../functions/utils/string.utils.cjs"),A=require("../../constants/protocol.constants.cjs"),C=require("async-mutex"),S=require("../../functions/utils/erc20tokenFunctions.cjs"),_=require("./token-visibility-db.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("circomlibjs-hinkal-fork");require("../../constants/kyc.constants.cjs");const I=require("../../functions/utils/create-provider.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../error-handling/error-codes.constants.cjs");require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("buffer");require("../../constants/token-data/index.cjs");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");const K=require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");require("libsodium-wrappers");require("multiformats");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 P{fetchedTokens={};updateMutexes={};transferEventTopic=l.ethers.utils.id("Transfer(address,address,uint256)");getMutex(r){return this.updateMutexes[r]||(this.updateMutexes[r]=new C.Mutex),this.updateMutexes[r]}async getPublicTokens(r,s){const t=d.getStateKey(s,r);return(await k.get(T.StorageKeys.EVENTS_PUBLIC_TOKENS))?.[t]||[]}getFetchedTokens(r,s){const t=d.getStateKey(s,r);return this.fetchedTokens[t]||[]}async fetchAndUpdatePublicTokens(r,s){const t=d.getStateKey(r,s);await this.getMutex(t).runExclusive(async()=>{try{const o=(await this.getPublicTokens(s,r)).map(a=>a.erc20TokenAddress),{toEvents:i,fromEvents:u,latestBlock:c}=await this.getEvents(r,s),g=[...i,...u],{erc20Tokens:E}=await this.fetchPublicTokens(g,s,o),b=await _.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(s,E),B=E.filter(a=>!p.lowerCaseIncludes(b,a.erc20TokenAddress));await k.update(T.StorageKeys.EVENTS_PUBLIC_TOKENS,(a={})=>{const q=a[t]||[],w=q.map(h=>h.erc20TokenAddress),L=B.filter(h=>!p.lowerCaseIncludes(w,h.erc20TokenAddress));q.push(...L);const v=this.updateTokenIds(u,i,q),y={...a,[t]:v};return this.fetchedTokens=y,y}),c&&await this.updateLastProcessedBlock(s,r,c)}catch(e){f.Logger.error("public tokens db error",e)}})}async getLastProcessedBlock(r,s){const t=await k.get(T.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS)||{},n=d.getStateKey(s,r);return t[n]||K.EVENTS_INITIAL_BLOCKS[r]}async updateLastProcessedBlock(r,s,t){await k.update(T.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS,(n={})=>{const e=d.getStateKey(s,r);return{...n,[e]:t}})}async getEvents(r,s){try{const t=I.createCustomRpcProvider(s),n=await this.getLastProcessedBlock(s,r)+1,e=await t.getBlockNumber(),o=l.ethers.utils.hexZeroPad(r.toLowerCase(),32),i={topics:[this.transferEventTopic,null,o],fromBlock:n,toBlock:e},u={topics:[this.transferEventTopic,o,null],fromBlock:n,toBlock:e},[c,g]=await Promise.all([t.getLogs(i),t.getLogs(u)]);return{toEvents:c,fromEvents:g,latestBlock:e}}catch(t){return f.Logger.error("Error fetching events:",t),{toEvents:[],fromEvents:[],latestBlock:void 0}}}updateTokenIds(r,s,t){const n=new Map;return t.forEach(e=>{if(S.isNFTToken(e)&&e.tokenIds){const o=e.erc20TokenAddress.toLowerCase();n.set(o,[...e.tokenIds])}}),s.forEach(e=>{if(e.topics.length<=3)return;const o=e.address.toLowerCase(),i=l.ethers.BigNumber.from(e.topics[3]).toString();n.has(o)||n.set(o,[]),n.get(o)?.push(i)}),r.forEach(e=>{if(e.topics.length<=3)return;const o=e.address.toLowerCase(),i=n.get(o);if(i?.length){const u=l.ethers.BigNumber.from(e.topics[3]).toString(),c=i.indexOf(u);c!==-1&&i.splice(c,1)}}),t.forEach(e=>{if(S.isNFTToken(e)){const o=e.erc20TokenAddress.toLowerCase(),i=n.get(o);e.tokenIds=i?.length&&i.length>0?i:void 0}}),t}async fetchPublicTokens(r,s,t){try{const n=[A.zeroAddress,...new Set(r.map(o=>o.address))].filter(o=>o&&!p.lowerCaseIncludes(t,o));return n.length?{erc20Tokens:(await m.API.tokensInfoCall(s,n)).filter(o=>!!o)}:{erc20Tokens:[]}}catch(n){return f.Logger.error("Error fetching public tokens:",n),{erc20Tokens:[]}}}}const x=new P;exports.EventsPublicTokensDB=P;exports.eventsPublicTokensDB=x;
@@ -1,18 +1,18 @@
1
- import { ethers as u } from "ethers";
2
- import { get as B, update as w } from "idb-keyval";
1
+ import { ethers as d } from "ethers";
2
+ import { get as B, update as S } from "idb-keyval";
3
3
  import { API as C } from "../../API/API.mjs";
4
- import { networkRegistry as v } from "../../constants/chains.constants.mjs";
5
- import { Logger as h } from "../../error-handling/logger.mjs";
6
- import { lowerCaseIncludes as g } from "../../functions/utils/caseInsensitive.utils.mjs";
7
- import { StorageKeys as k } from "../../types/cache.types.mjs";
4
+ import { Logger as T } from "../../error-handling/logger.mjs";
5
+ import { lowerCaseIncludes as h } from "../../functions/utils/caseInsensitive.utils.mjs";
6
+ import { StorageKeys as u } from "../../types/cache.types.mjs";
8
7
  import { getStateKey as m } from "../../functions/utils/string.utils.mjs";
9
- import { zeroAddress as x } from "../../constants/protocol.constants.mjs";
10
- import { Mutex as _ } from "async-mutex";
11
- import { isNFTToken as P } from "../../functions/utils/erc20tokenFunctions.mjs";
12
- import { tokenVisibilityStorage as N } from "./token-visibility-db.mjs";
8
+ import { zeroAddress as v } from "../../constants/protocol.constants.mjs";
9
+ import { Mutex as x } from "async-mutex";
10
+ import { isNFTToken as w } from "../../functions/utils/erc20tokenFunctions.mjs";
11
+ import { tokenVisibilityStorage as _ } from "./token-visibility-db.mjs";
13
12
  import "../../types/circom-data.types.mjs";
14
13
  import "../../types/transactions.types.mjs";
15
14
  import "../../types/activities.types.mjs";
15
+ import "../../constants/chains.constants.mjs";
16
16
  import "@coral-xyz/anchor";
17
17
  import "@solana/web3.js";
18
18
  import "circomlibjs-hinkal-fork";
@@ -27,6 +27,10 @@ import "../http/HttpClient.mjs";
27
27
  import "axios";
28
28
  import "../../constants/vite.constants.mjs";
29
29
  import "@solana/spl-token";
30
+ import "ethers-v6h";
31
+ import "tweetnacl";
32
+ import "bs58";
33
+ import "buffer";
30
34
  import "../../constants/token-data/index.mjs";
31
35
  import "../../constants/contracts.constants.mjs";
32
36
  import "../../constants/coingecko.constants.mjs";
@@ -36,137 +40,132 @@ import "../../constants/token.limits.constants.mjs";
36
40
  import "../../constants/presale.constants.mjs";
37
41
  import "../../constants/activity.constants.mjs";
38
42
  import "../../constants/tasks.constants.mjs";
39
- import { EVENTS_INITIAL_BLOCKS as O } from "../../constants/events.constants.mjs";
43
+ import { EVENTS_INITIAL_BLOCKS as N } from "../../constants/events.constants.mjs";
40
44
  import "../../functions/utils/userAgent.mjs";
41
45
  import "libsodium-wrappers";
42
46
  import "multiformats";
43
- import "../../API/tenderly.api.mjs";
44
47
  import "process";
45
- import "buffer";
46
48
  import "../../providers/EthersProviderAdapter.mjs";
47
- import "node-forge";
49
+ import "../../functions/web3/events/getInputUtxoAndBalance.mjs";
48
50
  import "../../functions/web3/events/getApprovedBalance.mjs";
49
51
  import "../../functions/web3/getTokenHolder.mjs";
50
- import "ethers-v6h";
51
- class K {
52
+ import "node-forge";
53
+ class O {
52
54
  fetchedTokens = {};
53
55
  updateMutexes = {};
54
- transferEventTopic = u.utils.id("Transfer(address,address,uint256)");
56
+ transferEventTopic = d.utils.id("Transfer(address,address,uint256)");
55
57
  getMutex(e) {
56
- return this.updateMutexes[e] || (this.updateMutexes[e] = new _()), this.updateMutexes[e];
58
+ return this.updateMutexes[e] || (this.updateMutexes[e] = new x()), this.updateMutexes[e];
57
59
  }
58
- async getPublicTokens(e, s) {
59
- const o = m(s, e);
60
- return (await B(k.EVENTS_PUBLIC_TOKENS))?.[o] || [];
60
+ async getPublicTokens(e, r) {
61
+ const o = m(r, e);
62
+ return (await B(u.EVENTS_PUBLIC_TOKENS))?.[o] || [];
61
63
  }
62
- getFetchedTokens(e, s) {
63
- const o = m(s, e);
64
+ getFetchedTokens(e, r) {
65
+ const o = m(r, e);
64
66
  return this.fetchedTokens[o] || [];
65
67
  }
66
- async fetchAndUpdatePublicTokens(e, s) {
67
- const o = m(e, s);
68
+ async fetchAndUpdatePublicTokens(e, r) {
69
+ const o = m(e, r);
68
70
  await this.getMutex(o).runExclusive(async () => {
69
71
  try {
70
- const r = (await this.getPublicTokens(s, e)).map((a) => a.erc20TokenAddress), { toEvents: i, fromEvents: p, latestBlock: c } = await this.getEvents(e, s), l = [...i, ...p], { erc20Tokens: d } = await this.fetchPublicTokens(l, s, r), S = await N.hideSpamsAndFetchHiddenTokensAddresses(
71
- s,
72
- d
73
- ), L = d.filter(
74
- (a) => !g(S, a.erc20TokenAddress)
72
+ const s = (await this.getPublicTokens(r, e)).map((a) => a.erc20TokenAddress), { toEvents: i, fromEvents: p, latestBlock: c } = await this.getEvents(e, r), k = [...i, ...p], { erc20Tokens: g } = await this.fetchPublicTokens(k, r, s), L = await _.hideSpamsAndFetchHiddenTokensAddresses(
73
+ r,
74
+ g
75
+ ), P = g.filter(
76
+ (a) => !h(L, a.erc20TokenAddress)
75
77
  // filter out hidden tokens
76
78
  );
77
- await w(k.EVENTS_PUBLIC_TOKENS, (a = {}) => {
78
- const f = a[o] || [], b = f.map((T) => T.erc20TokenAddress), y = L.filter(
79
- (T) => !g(b, T.erc20TokenAddress)
79
+ await S(u.EVENTS_PUBLIC_TOKENS, (a = {}) => {
80
+ const l = a[o] || [], b = l.map((f) => f.erc20TokenAddress), y = P.filter(
81
+ (f) => !h(b, f.erc20TokenAddress)
80
82
  );
81
- f.push(...y);
82
- const A = this.updateTokenIds(p, i, f), E = {
83
+ l.push(...y);
84
+ const A = this.updateTokenIds(p, i, l), E = {
83
85
  ...a,
84
86
  [o]: A
85
87
  };
86
88
  return this.fetchedTokens = E, E;
87
- }), c && await this.updateLastProcessedBlock(s, e, c);
89
+ }), c && await this.updateLastProcessedBlock(r, e, c);
88
90
  } catch (t) {
89
- h.error("public tokens db error", t);
91
+ T.error("public tokens db error", t);
90
92
  }
91
93
  });
92
94
  }
93
- async getLastProcessedBlock(e, s) {
94
- const o = await B(k.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS) || {}, n = m(s, e);
95
- return o[n] || O[e];
95
+ async getLastProcessedBlock(e, r) {
96
+ const o = await B(u.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS) || {}, n = m(r, e);
97
+ return o[n] || N[e];
96
98
  }
97
- async updateLastProcessedBlock(e, s, o) {
98
- await w(k.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS, (n = {}) => {
99
- const t = m(s, e);
99
+ async updateLastProcessedBlock(e, r, o) {
100
+ await S(u.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS, (n = {}) => {
101
+ const t = m(r, e);
100
102
  return {
101
103
  ...n,
102
104
  [t]: o
103
105
  };
104
106
  });
105
107
  }
106
- async getEvents(e, s) {
108
+ async getEvents(e, r) {
107
109
  try {
108
- const { fetchRpcUrl: o } = v[s];
109
- if (!o)
110
- throw Error("No fetchRpcUrl in PublicTokensDB");
111
- const n = I(o), t = await this.getLastProcessedBlock(s, e) + 1, r = await n.getBlockNumber(), i = u.utils.hexZeroPad(e.toLowerCase(), 32), p = {
112
- topics: [this.transferEventTopic, null, i],
113
- fromBlock: t,
114
- toBlock: r
115
- }, c = {
116
- topics: [this.transferEventTopic, i, null],
117
- fromBlock: t,
118
- toBlock: r
119
- }, [l, d] = await Promise.all([n.getLogs(p), n.getLogs(c)]);
120
- return { toEvents: l, fromEvents: d, latestBlock: r };
110
+ const o = I(r), n = await this.getLastProcessedBlock(r, e) + 1, t = await o.getBlockNumber(), s = d.utils.hexZeroPad(e.toLowerCase(), 32), i = {
111
+ topics: [this.transferEventTopic, null, s],
112
+ fromBlock: n,
113
+ toBlock: t
114
+ }, p = {
115
+ topics: [this.transferEventTopic, s, null],
116
+ fromBlock: n,
117
+ toBlock: t
118
+ }, [c, k] = await Promise.all([o.getLogs(i), o.getLogs(p)]);
119
+ return { toEvents: c, fromEvents: k, latestBlock: t };
121
120
  } catch (o) {
122
- return h.error("Error fetching events:", o), { toEvents: [], fromEvents: [], latestBlock: void 0 };
121
+ return T.error("Error fetching events:", o), { toEvents: [], fromEvents: [], latestBlock: void 0 };
123
122
  }
124
123
  }
125
124
  // First get existed tokenIds from tokens
126
125
  // Then add new tokenIds from toEvents (incoming transfers)
127
126
  // Then remove tokenIds from fromEvents (outgoing transfers)
128
- updateTokenIds(e, s, o) {
127
+ updateTokenIds(e, r, o) {
129
128
  const n = /* @__PURE__ */ new Map();
130
129
  return o.forEach((t) => {
131
- if (P(t) && t.tokenIds) {
132
- const r = t.erc20TokenAddress.toLowerCase();
133
- n.set(r, [...t.tokenIds]);
130
+ if (w(t) && t.tokenIds) {
131
+ const s = t.erc20TokenAddress.toLowerCase();
132
+ n.set(s, [...t.tokenIds]);
134
133
  }
135
- }), s.forEach((t) => {
134
+ }), r.forEach((t) => {
136
135
  if (t.topics.length <= 3)
137
136
  return;
138
- const r = t.address.toLowerCase(), i = u.BigNumber.from(t.topics[3]).toString();
139
- n.has(r) || n.set(r, []), n.get(r)?.push(i);
137
+ const s = t.address.toLowerCase(), i = d.BigNumber.from(t.topics[3]).toString();
138
+ n.has(s) || n.set(s, []), n.get(s)?.push(i);
140
139
  }), e.forEach((t) => {
141
140
  if (t.topics.length <= 3)
142
141
  return;
143
- const r = t.address.toLowerCase(), i = n.get(r);
142
+ const s = t.address.toLowerCase(), i = n.get(s);
144
143
  if (i?.length) {
145
- const p = u.BigNumber.from(t.topics[3]).toString(), c = i.indexOf(p);
144
+ const p = d.BigNumber.from(t.topics[3]).toString(), c = i.indexOf(p);
146
145
  c !== -1 && i.splice(c, 1);
147
146
  }
148
147
  }), o.forEach((t) => {
149
- if (P(t)) {
150
- const r = t.erc20TokenAddress.toLowerCase(), i = n.get(r);
148
+ if (w(t)) {
149
+ const s = t.erc20TokenAddress.toLowerCase(), i = n.get(s);
151
150
  t.tokenIds = i?.length && i.length > 0 ? i : void 0;
152
151
  }
153
152
  }), o;
154
153
  }
155
- async fetchPublicTokens(e, s, o) {
154
+ async fetchPublicTokens(e, r, o) {
156
155
  try {
157
- const n = [x, ...new Set(e.map((r) => r.address))].filter(
158
- (r) => r && !g(o, r)
156
+ const n = [v, ...new Set(e.map((s) => s.address))].filter(
157
+ (s) => s && !h(o, s)
159
158
  );
160
- return n.length ? { erc20Tokens: (await C.tokensInfoCall(s, n)).filter(
161
- (r) => !!r
159
+ return n.length ? { erc20Tokens: (await C.tokensInfoCall(r, n)).filter(
160
+ (s) => !!s
162
161
  ) } : { erc20Tokens: [] };
163
162
  } catch (n) {
164
- return h.error("Error fetching public tokens:", n), { erc20Tokens: [] };
163
+ return T.error("Error fetching public tokens:", n), { erc20Tokens: [] };
165
164
  }
166
165
  }
167
166
  }
168
- const It = new K();
167
+ const Ot = new O();
169
168
  export {
170
- K as EventsPublicTokensDB,
171
- It as eventsPublicTokensDB
169
+ O as EventsPublicTokensDB,
170
+ Ot as eventsPublicTokensDB
172
171
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("ethers"),w=require("libsodium-wrappers"),p=require("../../constants/protocol.constants.cjs"),m=require("../../crypto/babyJub.cjs"),u=require("../../crypto/poseidon.cjs"),h=require("./keyUtils.cjs"),v=require("../cacheDevices/AttachableMemoryCacheDevice.cjs"),d=require("ethers-v6h"),g=require("../../constants/chains.constants.cjs"),c=require("@solana/web3.js"),b=require("tweetnacl"),K=require("bs58"),q=require("../../functions/utils/create-provider.cjs"),P=new v.AttachableMemoryCacheDevice,f=new v.AttachableMemoryCacheDevice,k={privateKey:"",publicKey:""};class l{signature;constructor(e){this.signature=e}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error("No signature provided")}verifyMessage(e){return this.requireSignature(),a.utils.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),a.ethers.utils.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),u.poseidonHash(this.getShieldedPrivateKey()));getDerivedEthereumAddress=()=>(this.requireSignature(),new d.ethers.Wallet(this.getShieldedPrivateKey()).address);getDerivedSolanaPublicKey=()=>(this.requireSignature(),c.Keypair.fromSeed(a.utils.arrayify(this.getShieldedPrivateKey())).publicKey.toBase58());getAccessKey=()=>(this.requireSignature(),u.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getSignerPrivateKeyFromNonce=e=>{this.requireSignature();const r=u.poseidonHash(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return a.utils.keccak256(a.utils.toUtf8Bytes(r))};getSignerSolanaPrivateKeyFromNonce=e=>{const r=this.getSignerPrivateKeyFromNonce(e),t=a.utils.arrayify(r),i=c.Keypair.fromSeed(t);return K.encode(i.secretKey)};getEvmPrivateKeyFromSolanaPrivateKey=e=>{const t=K.decode(e).slice(0,32);return d.hexlify(t)};static getSignerFromPrivateKey=(e,r)=>{if(g.isSolanaLike(e)){const i=a.utils.arrayify(r);return c.Keypair.fromSeed(i)}return new d.ethers.Wallet(r)};static getSignerAddressFromPrivateKey(e,r){const t=l.getSignerFromPrivateKey(e,r);return t instanceof c.Keypair?t.publicKey.toString():t.address}static signMessageFromPrivateKey=async(e,r,t)=>{const i=l.getSignerFromPrivateKey(e,r);if(i instanceof c.Keypair){const s=a.utils.isHexString(t)?a.utils.arrayify(t):new TextEncoder().encode(t),o=b.sign.detached(s,i.secretKey);return`0x${Buffer.from(o).toString("hex")}`}const n=a.utils.isHexString(t)?a.utils.arrayify(t):t;return i.signMessage(n)};static signSolanaTransactionFromPrivateKey=(e,r,t)=>{if(!g.isSolanaLike(e))throw new Error("Solana transaction signing is only available for Solana chains");const i=l.getSignerFromPrivateKey(e,r);if(!(i instanceof c.Keypair))throw new Error("Unable to derive Solana keypair for signing");t.sign([i])};static sendAndSignTransactionFromPrivateKey=async(e,r,t)=>{const i=l.getSignerFromPrivateKey(e,r),{fetchRpcUrl:n}=g.networkRegistry[e];if(!n)throw new Error("No RPC URL found for chainId");if(i instanceof c.Keypair){if(!(t instanceof c.VersionedTransaction))throw new Error("Invalid transaction type for Solana");return t.sign([i]),await q.createCustomSolanaConnection(n).sendRawTransaction(t.serialize())}if(t instanceof c.VersionedTransaction)throw new Error("Invalid transaction type for EVM");const s=new d.ethers.JsonRpcProvider(n);return(await i.connect(s).sendTransaction(t)).hash};static signTypedDataFromPrivateKey=async(e,r,t,i,n)=>{if(g.isSolanaLike(e))throw new Error("Solana does not support typed data");return await l.getSignerFromPrivateKey(e,r).signTypedData(t,i,n)};static authorizeDelegation=async(e,r,t,i)=>{if(g.isSolanaLike(e))throw new Error("Solana does not support delegation");const n=new d.ethers.JsonRpcProvider(g.networkRegistry[e].fetchRpcUrl);return await l.getSignerFromPrivateKey(e,r).connect(n).authorize({address:t,...i!==void 0&&{nonce:i}})};getWalletSalt=e=>(this.requireSignature(),u.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getInHinkalAddress=e=>{this.requireSignature();const r=u.poseidonHash(this.getShieldedPrivateKey(),e);return BigInt(r)};getBackendToken=()=>(this.requireSignature(),u.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=P.attach((e,r)=>{const t=m.babyJubInstance(),i=BigInt(r)%p.CIRCOM_P,n=e*i%p.CIRCOM_P,s=t.mulPointEscalar(t.Base8,e),o=t.mulPointEscalar(t.Base8,n),y=[BigInt(t.F.toString(s[0])),BigInt(t.F.toString(s[1]))],S=[BigInt(t.F.toString(o[0])),BigInt(t.F.toString(o[1]))];return{H0:y,H1:S}});static getStealthAddressCompressedPoints=(e,r)=>{const{H0:t,H1:i}=this.getRandomizedStealthPair(e,r),[n,s]=[t,i].map(o=>BigInt(o[1])+2n**255n*h.getCircomSign(o[0]));return{h0:n,h1:s}};static getStealthAddress=f.attach((e,r)=>{const{H0:t,H1:i}=this.getRandomizedStealthPair(e,r),s=[2n*h.getCircomSign(t[0])+h.getCircomSign(i[0]),t[1],i[1]];return u.poseidonHash(...s)});static getStealthAddressWithEKey=(e,r)=>({stealthAddress:this.getStealthAddress(e,r),encryptionKey:this.getEncryptionKeyPair(r).publicKey});static checkSignature=(e,r,t,i)=>{const{h0:n,h1:s}=this.getStealthAddressCompressedPoints(e,i);return r===n&&t===s};static getEncryptionKeyPair=e=>{const r=w.crypto_box_seed_keypair(a.ethers.utils.arrayify(e));return{privateKey:a.ethers.utils.hexlify(r.privateKey),publicKey:a.ethers.utils.hexlify(r.publicKey)}}}exports.EncryptionKeyPairDefaultValue=k;exports.UserKeys=l;exports.stealthAddressCacheDevice=f;exports.stealthPairCacheDevice=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@solana/web3.js"),p=require("bs58"),s=require("ethers"),P=require("ethers-v6h"),b=require("libsodium-wrappers"),d=require("../../constants/protocol.constants.cjs"),v=require("../../crypto/babyJub.cjs"),n=require("../../crypto/poseidon.cjs"),g=require("../cacheDevices/AttachableMemoryCacheDevice.cjs"),h=require("./keyUtils.cjs"),l=new g.AttachableMemoryCacheDevice,y=new g.AttachableMemoryCacheDevice,m={privateKey:"",publicKey:""};class q{signature;constructor(e){this.signature=e}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error("No signature provided")}verifyMessage(e){return this.requireSignature(),s.utils.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),s.ethers.utils.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),n.poseidonHash(this.getShieldedPrivateKey()));getDerivedEthereumAddress=()=>(this.requireSignature(),new P.ethers.Wallet(this.getShieldedPrivateKey()).address);getDerivedSolanaPublicKey=()=>(this.requireSignature(),u.Keypair.fromSeed(s.utils.arrayify(this.getShieldedPrivateKey())).publicKey.toBase58());getAccessKey=()=>(this.requireSignature(),n.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getSignerPrivateKeyFromNonce=e=>{this.requireSignature();const t=n.poseidonHash(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return s.utils.keccak256(s.utils.toUtf8Bytes(t))};getSignerSolanaPrivateKeyFromNonce=e=>{const t=this.getSignerPrivateKeyFromNonce(e),i=s.utils.arrayify(t),r=u.Keypair.fromSeed(i);return p.encode(r.secretKey)};getWalletSalt=e=>(this.requireSignature(),n.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getInHinkalAddress=e=>{this.requireSignature();const t=n.poseidonHash(this.getShieldedPrivateKey(),e);return BigInt(t)};getBackendToken=()=>(this.requireSignature(),n.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=l.attach((e,t)=>{const i=v.babyJubInstance(),r=BigInt(t)%d.CIRCOM_P,c=e*r%d.CIRCOM_P,a=i.mulPointEscalar(i.Base8,e),o=i.mulPointEscalar(i.Base8,c),S=[BigInt(i.F.toString(a[0])),BigInt(i.F.toString(a[1]))],K=[BigInt(i.F.toString(o[0])),BigInt(i.F.toString(o[1]))];return{H0:S,H1:K}});static getStealthAddressCompressedPoints=(e,t)=>{const{H0:i,H1:r}=this.getRandomizedStealthPair(e,t),[c,a]=[i,r].map(o=>BigInt(o[1])+2n**255n*h.getCircomSign(o[0]));return{h0:c,h1:a}};static getStealthAddress=y.attach((e,t)=>{const{H0:i,H1:r}=this.getRandomizedStealthPair(e,t),a=[2n*h.getCircomSign(i[0])+h.getCircomSign(r[0]),i[1],r[1]];return n.poseidonHash(...a)});static getStealthAddressWithEKey=(e,t)=>({stealthAddress:this.getStealthAddress(e,t),encryptionKey:this.getEncryptionKeyPair(t).publicKey});static checkSignature=(e,t,i,r)=>{const{h0:c,h1:a}=this.getStealthAddressCompressedPoints(e,r);return t===c&&i===a};static getEncryptionKeyPair=e=>{const t=b.crypto_box_seed_keypair(s.ethers.utils.arrayify(e));return{privateKey:s.ethers.utils.hexlify(t.privateKey),publicKey:s.ethers.utils.hexlify(t.publicKey)}}}exports.EncryptionKeyPairDefaultValue=m;exports.UserKeys=q;exports.stealthAddressCacheDevice=y;exports.stealthPairCacheDevice=l;
@@ -1,7 +1,4 @@
1
- import { ethers } from 'ethers';
2
1
  import { AttachableMemoryCacheDevice } from '../cacheDevices/AttachableMemoryCacheDevice';
3
- import { ethers as ethersV6 } from 'ethers-v6h';
4
- import { VersionedTransaction } from '@solana/web3.js';
5
2
  export declare const stealthPairCacheDevice: AttachableMemoryCacheDevice<{
6
3
  H0: [bigint, bigint];
7
4
  H1: [bigint, bigint];
@@ -47,14 +44,6 @@ export declare class UserKeys {
47
44
  getAccessKey: () => string;
48
45
  getSignerPrivateKeyFromNonce: (walletNonce: bigint) => string;
49
46
  getSignerSolanaPrivateKeyFromNonce: (walletNonce: bigint) => string;
50
- getEvmPrivateKeyFromSolanaPrivateKey: (solanaPrivateKey: string) => string;
51
- private static getSignerFromPrivateKey;
52
- static getSignerAddressFromPrivateKey(chainId: number, privateKey: string): string;
53
- static signMessageFromPrivateKey: (chainId: number, privateKey: string, message: string) => Promise<string>;
54
- static signSolanaTransactionFromPrivateKey: (chainId: number, privateKey: string, transaction: VersionedTransaction) => void;
55
- static sendAndSignTransactionFromPrivateKey: (chainId: number, privateKey: string, transaction: ethersV6.TransactionRequest | VersionedTransaction) => Promise<string>;
56
- static signTypedDataFromPrivateKey: (chainId: number, privateKey: string, domain: ethers.TypedDataDomain, types: Record<string, Array<ethers.TypedDataField>>, value: Record<string, any>) => Promise<string>;
57
- static authorizeDelegation: (chainId: number, privateKey: string, implementation: string, nonce?: number) => Promise<ethersV6.Authorization>;
58
47
  getWalletSalt: (walletNonce: bigint) => string;
59
48
  /**
60
49
  * generate inHinkalAddress - a user unique address linking him with a specific app
@@ -1,21 +1,18 @@
1
- import { utils as o, ethers as d } from "ethers";
2
- import w from "libsodium-wrappers";
3
- import { CIRCOM_P as m } from "../../constants/protocol.constants.mjs";
4
- import { babyJubInstance as b } from "../../crypto/babyJub.mjs";
5
- import { poseidonHash as c } from "../../crypto/poseidon.mjs";
6
- import { getCircomSign as y } from "./keyUtils.mjs";
7
- import { AttachableMemoryCacheDevice as v } from "../cacheDevices/AttachableMemoryCacheDevice.mjs";
8
- import { ethers as u, hexlify as F } from "ethers-v6h";
9
- import { isSolanaLike as h, networkRegistry as p } from "../../constants/chains.constants.mjs";
10
- import { Keypair as g, VersionedTransaction as K } from "@solana/web3.js";
11
- import k from "tweetnacl";
12
- import P from "bs58";
13
- import { createCustomSolanaConnection as A } from "../../functions/utils/create-provider.mjs";
14
- const E = new v(), R = new v(), L = {
1
+ import { Keypair as u } from "@solana/web3.js";
2
+ import m from "bs58";
3
+ import { utils as h, ethers as c } from "ethers";
4
+ import { ethers as K } from "ethers-v6h";
5
+ import p from "libsodium-wrappers";
6
+ import { CIRCOM_P as d } from "../../constants/protocol.constants.mjs";
7
+ import { babyJubInstance as P } from "../../crypto/babyJub.mjs";
8
+ import { poseidonHash as a } from "../../crypto/poseidon.mjs";
9
+ import { AttachableMemoryCacheDevice as l } from "../cacheDevices/AttachableMemoryCacheDevice.mjs";
10
+ import { getCircomSign as g } from "./keyUtils.mjs";
11
+ const v = new l(), f = new l(), D = {
15
12
  privateKey: "",
16
13
  publicKey: ""
17
14
  };
18
- class l {
15
+ class x {
19
16
  signature;
20
17
  constructor(e) {
21
18
  this.signature = e;
@@ -31,133 +28,76 @@ class l {
31
28
  throw Error("No signature provided");
32
29
  }
33
30
  verifyMessage(e) {
34
- return this.requireSignature(), o.verifyMessage(e, this.signature);
31
+ return this.requireSignature(), h.verifyMessage(e, this.signature);
35
32
  }
36
33
  /**
37
34
  * get shielded private key from message signature used to login to the application,
38
35
  * this private key is used to generate encryption keypairs as well as public key
39
36
  * @retuns 0x-prefixed shielded private key
40
37
  */
41
- getShieldedPrivateKey = () => (this.requireSignature(), d.utils.keccak256(this.signature));
38
+ getShieldedPrivateKey = () => (this.requireSignature(), c.utils.keccak256(this.signature));
42
39
  /**
43
40
  * generate shielded public key from private key
44
41
  * @param privateKey the key used to generate the shielded public key, this should be the signature
45
42
  * that the user provided
46
43
  * @retuns shielded public key in hexstring with 0x prefixed
47
44
  */
48
- getShieldedPublicKey = () => (this.requireSignature(), c(this.getShieldedPrivateKey()));
45
+ getShieldedPublicKey = () => (this.requireSignature(), a(this.getShieldedPrivateKey()));
49
46
  /**
50
47
  * deterministically derive an EVM address from the shielded private key
51
48
  */
52
- getDerivedEthereumAddress = () => (this.requireSignature(), new u.Wallet(this.getShieldedPrivateKey()).address);
49
+ getDerivedEthereumAddress = () => (this.requireSignature(), new K.Wallet(this.getShieldedPrivateKey()).address);
53
50
  /**
54
51
  * deterministically derive a Solana public key from the shielded private key
55
52
  */
56
- getDerivedSolanaPublicKey = () => (this.requireSignature(), g.fromSeed(o.arrayify(this.getShieldedPrivateKey())).publicKey.toBase58());
53
+ getDerivedSolanaPublicKey = () => (this.requireSignature(), u.fromSeed(h.arrayify(this.getShieldedPrivateKey())).publicKey.toBase58());
57
54
  /**
58
55
  * generate access token, this accessKey is what should be sent to the server for signing
59
56
  * @returns accessKey in hexstring with 0x prefixed
60
57
  */
61
- getAccessKey = () => (this.requireSignature(), c(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
58
+ getAccessKey = () => (this.requireSignature(), a(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
62
59
  getSignerPrivateKeyFromNonce = (e) => {
63
60
  this.requireSignature();
64
- const r = c(e, this.getShieldedPrivateKey(), this.getShieldedPublicKey());
65
- return o.keccak256(o.toUtf8Bytes(r));
61
+ const t = a(e, this.getShieldedPrivateKey(), this.getShieldedPublicKey());
62
+ return h.keccak256(h.toUtf8Bytes(t));
66
63
  };
67
64
  getSignerSolanaPrivateKeyFromNonce = (e) => {
68
- const r = this.getSignerPrivateKeyFromNonce(e), t = o.arrayify(r), i = g.fromSeed(t);
69
- return P.encode(i.secretKey);
65
+ const t = this.getSignerPrivateKeyFromNonce(e), r = h.arrayify(t), i = u.fromSeed(r);
66
+ return m.encode(i.secretKey);
70
67
  };
71
- getEvmPrivateKeyFromSolanaPrivateKey = (e) => {
72
- const t = P.decode(e).slice(0, 32);
73
- return F(t);
74
- };
75
- static getSignerFromPrivateKey = (e, r) => {
76
- if (h(e)) {
77
- const i = o.arrayify(r);
78
- return g.fromSeed(i);
79
- }
80
- return new u.Wallet(r);
81
- };
82
- static getSignerAddressFromPrivateKey(e, r) {
83
- const t = l.getSignerFromPrivateKey(e, r);
84
- return t instanceof g ? t.publicKey.toString() : t.address;
85
- }
86
- static signMessageFromPrivateKey = async (e, r, t) => {
87
- const i = l.getSignerFromPrivateKey(e, r);
88
- if (i instanceof g) {
89
- const a = o.isHexString(t) ? o.arrayify(t) : new TextEncoder().encode(t), s = k.sign.detached(a, i.secretKey);
90
- return `0x${Buffer.from(s).toString("hex")}`;
91
- }
92
- const n = o.isHexString(t) ? o.arrayify(t) : t;
93
- return i.signMessage(n);
94
- };
95
- static signSolanaTransactionFromPrivateKey = (e, r, t) => {
96
- if (!h(e))
97
- throw new Error("Solana transaction signing is only available for Solana chains");
98
- const i = l.getSignerFromPrivateKey(e, r);
99
- if (!(i instanceof g))
100
- throw new Error("Unable to derive Solana keypair for signing");
101
- t.sign([i]);
102
- };
103
- static sendAndSignTransactionFromPrivateKey = async (e, r, t) => {
104
- const i = l.getSignerFromPrivateKey(e, r), { fetchRpcUrl: n } = p[e];
105
- if (!n)
106
- throw new Error("No RPC URL found for chainId");
107
- if (i instanceof g) {
108
- if (!(t instanceof K))
109
- throw new Error("Invalid transaction type for Solana");
110
- return t.sign([i]), await A(n).sendRawTransaction(t.serialize());
111
- }
112
- if (t instanceof K)
113
- throw new Error("Invalid transaction type for EVM");
114
- const a = new u.JsonRpcProvider(n);
115
- return (await i.connect(a).sendTransaction(t)).hash;
116
- };
117
- static signTypedDataFromPrivateKey = async (e, r, t, i, n) => {
118
- if (h(e))
119
- throw new Error("Solana does not support typed data");
120
- return await l.getSignerFromPrivateKey(e, r).signTypedData(t, i, n);
121
- };
122
- static authorizeDelegation = async (e, r, t, i) => {
123
- if (h(e))
124
- throw new Error("Solana does not support delegation");
125
- const n = new u.JsonRpcProvider(p[e].fetchRpcUrl);
126
- return await l.getSignerFromPrivateKey(e, r).connect(n).authorize({ address: t, ...i !== void 0 && { nonce: i } });
127
- };
128
- getWalletSalt = (e) => (this.requireSignature(), c(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), e));
68
+ getWalletSalt = (e) => (this.requireSignature(), a(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), e));
129
69
  /**
130
70
  * generate inHinkalAddress - a user unique address linking him with a specific app
131
71
  * @returns inHinkalAddress in bigint
132
72
  */
133
73
  getInHinkalAddress = (e) => {
134
74
  this.requireSignature();
135
- const r = c(this.getShieldedPrivateKey(), e);
136
- return BigInt(r);
75
+ const t = a(this.getShieldedPrivateKey(), e);
76
+ return BigInt(t);
137
77
  };
138
78
  /**
139
79
  * generate backend token, which is used for access control on backend
140
80
  * @returns accessKey in hexstring with 0x prefixed
141
81
  */
142
- getBackendToken = () => (this.requireSignature(), c(this.getAccessKey(), this.getShieldedPublicKey()));
143
- static getRandomizedStealthPair = E.attach(
144
- (e, r) => {
145
- const t = b(), i = BigInt(r) % m, n = e * i % m, a = t.mulPointEscalar(t.Base8, e), s = t.mulPointEscalar(t.Base8, n), S = [BigInt(t.F.toString(a[0])), BigInt(t.F.toString(a[1]))], f = [BigInt(t.F.toString(s[0])), BigInt(t.F.toString(s[1]))];
146
- return { H0: S, H1: f };
82
+ getBackendToken = () => (this.requireSignature(), a(this.getAccessKey(), this.getShieldedPublicKey()));
83
+ static getRandomizedStealthPair = v.attach(
84
+ (e, t) => {
85
+ const r = P(), i = BigInt(t) % d, n = e * i % d, s = r.mulPointEscalar(r.Base8, e), o = r.mulPointEscalar(r.Base8, n), y = [BigInt(r.F.toString(s[0])), BigInt(r.F.toString(s[1]))], S = [BigInt(r.F.toString(o[0])), BigInt(r.F.toString(o[1]))];
86
+ return { H0: y, H1: S };
147
87
  }
148
88
  );
149
- static getStealthAddressCompressedPoints = (e, r) => {
150
- const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), [n, a] = [t, i].map((s) => BigInt(s[1]) + 2n ** 255n * y(s[0]));
151
- return { h0: n, h1: a };
89
+ static getStealthAddressCompressedPoints = (e, t) => {
90
+ const { H0: r, H1: i } = this.getRandomizedStealthPair(e, t), [n, s] = [r, i].map((o) => BigInt(o[1]) + 2n ** 255n * g(o[0]));
91
+ return { h0: n, h1: s };
152
92
  };
153
- static getStealthAddress = R.attach((e, r) => {
154
- const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), a = [2n * y(t[0]) + y(i[0]), t[1], i[1]];
155
- return c(...a);
93
+ static getStealthAddress = f.attach((e, t) => {
94
+ const { H0: r, H1: i } = this.getRandomizedStealthPair(e, t), s = [2n * g(r[0]) + g(i[0]), r[1], i[1]];
95
+ return a(...s);
156
96
  });
157
- static getStealthAddressWithEKey = (e, r) => ({ stealthAddress: this.getStealthAddress(e, r), encryptionKey: this.getEncryptionKeyPair(r).publicKey });
158
- static checkSignature = (e, r, t, i) => {
159
- const { h0: n, h1: a } = this.getStealthAddressCompressedPoints(e, i);
160
- return r === n && t === a;
97
+ static getStealthAddressWithEKey = (e, t) => ({ stealthAddress: this.getStealthAddress(e, t), encryptionKey: this.getEncryptionKeyPair(t).publicKey });
98
+ static checkSignature = (e, t, r, i) => {
99
+ const { h0: n, h1: s } = this.getStealthAddressCompressedPoints(e, i);
100
+ return t === n && r === s;
161
101
  };
162
102
  /**
163
103
  * generate private and public keypair
@@ -165,16 +105,16 @@ class l {
165
105
  * and must correspond to 32 bytes
166
106
  */
167
107
  static getEncryptionKeyPair = (e) => {
168
- const r = w.crypto_box_seed_keypair(d.utils.arrayify(e));
108
+ const t = p.crypto_box_seed_keypair(c.utils.arrayify(e));
169
109
  return {
170
- privateKey: d.utils.hexlify(r.privateKey),
171
- publicKey: d.utils.hexlify(r.publicKey)
110
+ privateKey: c.utils.hexlify(t.privateKey),
111
+ publicKey: c.utils.hexlify(t.publicKey)
172
112
  };
173
113
  };
174
114
  }
175
115
  export {
176
- L as EncryptionKeyPairDefaultValue,
177
- l as UserKeys,
178
- R as stealthAddressCacheDevice,
179
- E as stealthPairCacheDevice
116
+ D as EncryptionKeyPairDefaultValue,
117
+ x as UserKeys,
118
+ f as stealthAddressCacheDevice,
119
+ v as stealthPairCacheDevice
180
120
  };