@hinkal/common 0.2.22 → 0.2.24

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 (243) hide show
  1. package/API/proxyAccountsCalls.cjs +1 -1
  2. package/API/proxyAccountsCalls.mjs +13 -13
  3. package/README.md +63 -267
  4. package/constants/activity.constants.cjs +1 -1
  5. package/constants/activity.constants.mjs +0 -1
  6. package/constants/addresses.constants.cjs +1 -1
  7. package/constants/addresses.constants.mjs +9 -10
  8. package/constants/contracts.constants.cjs +1 -1
  9. package/constants/contracts.constants.d.ts +3 -3
  10. package/constants/contracts.constants.mjs +29 -29
  11. package/constants/server.constants.cjs +1 -1
  12. package/constants/server.constants.mjs +28 -29
  13. package/constants/tasks.constants.cjs +1 -1
  14. package/constants/tasks.constants.mjs +4 -5
  15. package/crypto/poseidon.cjs +1 -1
  16. package/crypto/poseidon.mjs +10 -10
  17. package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
  18. package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +24 -24
  19. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  20. package/data-structures/Hinkal/Hinkal.mjs +4 -5
  21. package/data-structures/Hinkal/IHinkal.d.ts +2 -2
  22. package/data-structures/Hinkal/hinkalApprove.cjs +1 -1
  23. package/data-structures/Hinkal/hinkalApprove.mjs +40 -40
  24. package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
  25. package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +7 -8
  26. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  27. package/data-structures/Hinkal/hinkalDeposit.mjs +4 -5
  28. package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
  29. package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +27 -28
  30. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
  31. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +1 -0
  32. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +35 -36
  33. package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
  34. package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +86 -83
  35. package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -1
  36. package/data-structures/Hinkal/hinkalInsideTransact.mjs +14 -13
  37. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  38. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +2 -3
  39. package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
  40. package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +27 -26
  41. package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
  42. package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +72 -73
  43. package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
  44. package/data-structures/Hinkal/hinkalSolanaSwap.mjs +16 -17
  45. package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
  46. package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +24 -25
  47. package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
  48. package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +15 -16
  49. package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
  50. package/data-structures/Hinkal/hinkalSwap.mjs +2 -3
  51. package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
  52. package/data-structures/Hinkal/hinkalTransfer.mjs +2 -3
  53. package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
  54. package/data-structures/Hinkal/hinkalWithdraw.mjs +9 -10
  55. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
  56. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +8 -9
  57. package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
  58. package/data-structures/Hinkal/resetMerkleTrees.mjs +10 -10
  59. package/data-structures/IndexedDB/activity-db.cjs +1 -1
  60. package/data-structures/IndexedDB/activity-db.mjs +39 -41
  61. package/data-structures/IndexedDB/balances-db.cjs +1 -1
  62. package/data-structures/IndexedDB/balances-db.mjs +8 -9
  63. package/data-structures/IndexedDB/contact-db.cjs +1 -1
  64. package/data-structures/IndexedDB/contact-db.mjs +21 -23
  65. package/data-structures/IndexedDB/signatures-db.cjs +1 -1
  66. package/data-structures/IndexedDB/signatures-db.mjs +2 -3
  67. package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
  68. package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +34 -36
  69. package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
  70. package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
  71. package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
  72. package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
  73. package/data-structures/crypto-keys/keys.cjs +1 -1
  74. package/data-structures/crypto-keys/keys.d.ts +2 -3
  75. package/data-structures/crypto-keys/keys.mjs +56 -57
  76. package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
  77. package/data-structures/event-service/evm/AbstractEventService.mjs +14 -14
  78. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
  79. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
  80. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +5 -4
  81. package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
  82. package/data-structures/event-service/evm/AbstractSnapshotService.mjs +6 -3
  83. package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
  84. package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +1 -1
  85. package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +22 -18
  86. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
  87. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +2 -2
  88. package/data-structures/presale/PresaleContractWrapper.cjs +1 -1
  89. package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
  90. package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
  91. package/data-structures/provider-adapter/IProviderAdapter.d.ts +7 -7
  92. package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
  93. package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +16 -14
  94. package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
  95. package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +7 -5
  96. package/error-handling/get-error.message.cjs +1 -1
  97. package/error-handling/get-error.message.mjs +2 -3
  98. package/functions/kyc/zkMeHelper.cjs +1 -1
  99. package/functions/kyc/zkMeHelper.mjs +3 -3
  100. package/functions/pre-transaction/getFlatFees.cjs +1 -1
  101. package/functions/pre-transaction/getFlatFees.mjs +2 -3
  102. package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
  103. package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
  104. package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
  105. package/functions/pre-transaction/getVolatileTransferAmount.mjs +2 -3
  106. package/functions/pre-transaction/interaction-to-action.cjs +1 -1
  107. package/functions/pre-transaction/interaction-to-action.mjs +2 -3
  108. package/functions/private-wallet/emporium.helpers.cjs +1 -1
  109. package/functions/private-wallet/emporium.helpers.d.ts +6 -7
  110. package/functions/private-wallet/emporium.helpers.mjs +104 -105
  111. package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
  112. package/functions/private-wallet/emporium.swap.helpers.mjs +44 -43
  113. package/functions/private-wallet/opProducer.cjs +1 -1
  114. package/functions/private-wallet/opProducer.mjs +1 -1
  115. package/functions/snarkjs/common.snarkjs.cjs +1 -1
  116. package/functions/snarkjs/common.snarkjs.mjs +21 -18
  117. package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
  118. package/functions/snarkjs/constructSolanaZkProof.mjs +11 -12
  119. package/functions/utils/addresses.cjs +1 -1
  120. package/functions/utils/addresses.mjs +6 -6
  121. package/functions/utils/cacheFunctions.cjs +1 -1
  122. package/functions/utils/cacheFunctions.d.ts +1 -1
  123. package/functions/utils/cacheFunctions.mjs +55 -54
  124. package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
  125. package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
  126. package/functions/utils/create-provider.cjs +1 -1
  127. package/functions/utils/create-provider.d.ts +2 -2
  128. package/functions/utils/create-provider.mjs +5 -5
  129. package/functions/utils/encryptInputForEnclave.cjs +1 -1
  130. package/functions/utils/encryptInputForEnclave.mjs +9 -9
  131. package/functions/utils/ethers-formatter.utils.d.ts +1 -1
  132. package/functions/utils/external-action.utils.cjs +1 -1
  133. package/functions/utils/external-action.utils.mjs +2 -2
  134. package/functions/utils/getContractAddress.cjs +1 -0
  135. package/functions/utils/getContractAddress.d.ts +2 -0
  136. package/functions/utils/getContractAddress.mjs +9 -0
  137. package/functions/utils/getDataFromTransaction.cjs +1 -1
  138. package/functions/utils/getDataFromTransaction.d.ts +0 -11
  139. package/functions/utils/getDataFromTransaction.mjs +26 -50
  140. package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
  141. package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
  142. package/functions/utils/getSignerFromContract.cjs +1 -0
  143. package/functions/utils/getSignerFromContract.d.ts +3 -0
  144. package/functions/utils/getSignerFromContract.mjs +16 -0
  145. package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
  146. package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
  147. package/functions/utils/getUtxosFromReceipt.utils.mjs +15 -16
  148. package/functions/utils/inLogicMetadata.cjs +1 -1
  149. package/functions/utils/inLogicMetadata.mjs +2 -2
  150. package/functions/utils/nftTokenFunctions.cjs +1 -1
  151. package/functions/utils/nftTokenFunctions.mjs +2 -3
  152. package/functions/utils/publicBalance.utils.cjs +1 -1
  153. package/functions/utils/publicBalance.utils.d.ts +1 -1
  154. package/functions/utils/publicBalance.utils.mjs +42 -42
  155. package/functions/utils/rpc-int-encode.cjs +1 -1
  156. package/functions/utils/rpc-int-encode.d.ts +1 -2
  157. package/functions/utils/rpc-int-encode.mjs +3 -6
  158. package/functions/utils/solanaMint.utils.cjs +1 -1
  159. package/functions/utils/solanaMint.utils.mjs +6 -6
  160. package/functions/web3/EIP-712.cjs +1 -1
  161. package/functions/web3/EIP-712.d.ts +4 -4
  162. package/functions/web3/EIP-712.mjs +1 -1
  163. package/functions/web3/etherFunctions.cjs +1 -1
  164. package/functions/web3/etherFunctions.mjs +32 -29
  165. package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
  166. package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
  167. package/functions/web3/events/balanceChangedHandler.cjs +1 -1
  168. package/functions/web3/events/balanceChangedHandler.mjs +2 -3
  169. package/functions/web3/events/getApprovedBalance.cjs +1 -1
  170. package/functions/web3/events/getApprovedBalance.mjs +1 -1
  171. package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
  172. package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
  173. package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
  174. package/functions/web3/events/getTransactionLogEvents.d.ts +3 -3
  175. package/functions/web3/events/getTransactionLogEvents.mjs +6 -5
  176. package/functions/web3/events/index.d.ts +0 -1
  177. package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
  178. package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
  179. package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +4 -5
  180. package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
  181. package/functions/web3/functionCalls/accessTokenCalls.mjs +10 -11
  182. package/functions/web3/functionCalls/approveToken.cjs +1 -1
  183. package/functions/web3/functionCalls/approveToken.mjs +61 -58
  184. package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
  185. package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
  186. package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
  187. package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
  188. package/functions/web3/functionCalls/estimateGasRelayer.mjs +1 -1
  189. package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -1
  190. package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +18 -21
  191. package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
  192. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  193. package/functions/web3/functionCalls/transactCallDirect.mjs +38 -34
  194. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  195. package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
  196. package/functions/web3/getContractMetadata.cjs +1 -1
  197. package/functions/web3/getContractMetadata.d.ts +1 -1
  198. package/functions/web3/getContractMetadata.mjs +25 -25
  199. package/functions/web3/getPublicAddressBalance.cjs +1 -1
  200. package/functions/web3/getPublicAddressBalance.mjs +7 -6
  201. package/functions/web3/getTokenHolder.cjs +1 -1
  202. package/functions/web3/getTokenHolder.mjs +16 -15
  203. package/functions/web3/odosAPI.cjs +1 -1
  204. package/functions/web3/odosAPI.mjs +6 -7
  205. package/functions/web3/oneInchAPI.cjs +1 -1
  206. package/functions/web3/oneInchAPI.mjs +2 -3
  207. package/functions/web3/runContractFunction.cjs +1 -1
  208. package/functions/web3/runContractFunction.d.ts +6 -5
  209. package/functions/web3/runContractFunction.mjs +41 -45
  210. package/functions/web3/uniswapAPI.cjs +1 -1
  211. package/functions/web3/uniswapAPI.d.ts +2 -2
  212. package/functions/web3/uniswapAPI.mjs +23 -24
  213. package/index.cjs +1 -1
  214. package/index.mjs +336 -340
  215. package/package.json +3 -4
  216. package/providers/CustomEthersProvider.d.ts +1 -1
  217. package/providers/EthersProviderAdapter.cjs +1 -1
  218. package/providers/EthersProviderAdapter.d.ts +7 -7
  219. package/providers/EthersProviderAdapter.mjs +46 -44
  220. package/providers/SolanaProviderAdapter.d.ts +1 -1
  221. package/providers/WagmiProviderAdapter.cjs +1 -1
  222. package/providers/WagmiProviderAdapter.d.ts +5 -5
  223. package/providers/WagmiProviderAdapter.mjs +37 -33
  224. package/providers/prepareEthersHinkal.cjs +1 -1
  225. package/providers/prepareEthersHinkal.d.ts +2 -2
  226. package/providers/prepareEthersHinkal.mjs +3 -5
  227. package/providers/prepareWagmiHinkal.cjs +1 -1
  228. package/providers/prepareWagmiHinkal.mjs +3 -5
  229. package/types/activities.types.d.ts +2 -3
  230. package/types/big-intable.types.d.ts +3 -2
  231. package/types/ethereum-network.types.d.ts +10 -10
  232. package/types/transactions.types.cjs +1 -1
  233. package/types/transactions.types.d.ts +2 -3
  234. package/types/transactions.types.mjs +6 -7
  235. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  236. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  237. package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
  238. package/webworker/utxoWorker/utxoWorkerLogic.mjs +1 -1
  239. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  240. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
  241. package/functions/web3/events/web3RetrieveEvents.cjs +0 -1
  242. package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
  243. package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
@@ -1,99 +1,99 @@
1
- import { ethers as a } from "ethers";
2
1
  import { PublicKey as T } from "@solana/web3.js";
3
- import { poseidonHash as E } from "../../crypto/poseidon.mjs";
2
+ import { poseidonHash as C } from "../../crypto/poseidon.mjs";
4
3
  import { isSolanaLike as y } from "../../constants/chains.constants.mjs";
5
- import { Utxo as z } from "../utxo/Utxo.mjs";
6
- import { UserKeys as C } from "./keys.mjs";
7
- const x = "solana-on-chain-utxo:", f = 8, F = (o) => {
8
- if (o.length !== f)
9
- throw new Error(`Expected ${f} on-chain fields, received ${o.length}`);
10
- const t = o.map((e, r) => {
11
- const n = e instanceof Uint8Array ? e : Uint8Array.from(e);
4
+ import { Utxo as E } from "../utxo/Utxo.mjs";
5
+ import { UserKeys as z } from "./keys.mjs";
6
+ import { ethers as d } from "ethers";
7
+ const f = "solana-on-chain-utxo:", x = 8, F = (e) => {
8
+ if (e.length !== x)
9
+ throw new Error(`Expected ${x} on-chain fields, received ${e.length}`);
10
+ const t = e.map((o, r) => {
11
+ const n = o instanceof Uint8Array ? o : Uint8Array.from(o);
12
12
  if (n.length !== 32)
13
13
  throw new Error(`Expected bytes32 length 32 at position ${r}, got ${n.length}`);
14
14
  return `0x${Buffer.from(n).toString("hex")}`;
15
15
  });
16
- return `${x}${a.utils.defaultAbiCoder.encode(["bytes32[8]"], [t])}`;
17
- }, N = (o) => o.startsWith(x), S = (o) => {
18
- if (!N(o))
16
+ return `${f}${d.AbiCoder.defaultAbiCoder().encode(["bytes32[8]"], [t])}`;
17
+ }, O = (e) => e.startsWith(f), B = (e) => {
18
+ if (!O(e))
19
19
  throw new Error("Invalid encoded Solana UTXO payload");
20
- const [t] = a.utils.defaultAbiCoder.decode(
20
+ const [t] = d.AbiCoder.defaultAbiCoder().decode(
21
21
  ["bytes32[8]"],
22
- o.slice(x.length)
23
- ), e = t;
24
- if (!Array.isArray(e) || e.length !== f)
22
+ e.slice(f.length)
23
+ ), o = t;
24
+ if (!Array.isArray(o) || o.length !== x)
25
25
  throw new Error("Malformed encoded Solana UTXO payload");
26
26
  const [
27
27
  r,
28
28
  n,
29
29
  s,
30
30
  i,
31
- d,
31
+ a,
32
32
  c,
33
33
  m,
34
- l
35
- ] = e, A = BigInt(r), u = BigInt(i), h = a.BigNumber.from(d).toHexString(), g = BigInt(c), I = BigInt(m), p = BigInt(l).toString(), B = Array.from(a.utils.arrayify(n)), U = Array.from(a.utils.arrayify(s)), b = Uint8Array.from([...B.slice(16), ...U.slice(16)]), w = new T(b).toBase58(), k = E(BigInt(n), BigInt(s));
34
+ A
35
+ ] = o, l = BigInt(r), g = BigInt(i), h = d.toBeHex(BigInt(a)), u = BigInt(c), H = BigInt(m), S = BigInt(A).toString(), p = Array.from(d.getBytes(n)), U = Array.from(d.getBytes(s)), b = Uint8Array.from([...p.slice(16), ...U.slice(16)]), w = new T(b).toBase58(), k = C(BigInt(n), BigInt(s));
36
36
  return {
37
- amount: A,
37
+ amount: l,
38
38
  erc20TokenAddress: k,
39
39
  mintAddress: w,
40
- randomization: u,
40
+ randomization: g,
41
41
  stealthAddress: h,
42
- H0: g,
43
- H1: I,
44
- timeStamp: p
42
+ H0: u,
43
+ H1: H,
44
+ timeStamp: S
45
45
  };
46
- }, H = (o) => {
47
- const t = a.utils.defaultAbiCoder.decode(
46
+ }, I = (e) => {
47
+ const t = d.AbiCoder.defaultAbiCoder().decode(
48
48
  ["uint256", "address", "tuple(uint256, uint256, uint256, uint256)", "uint256", "uint256"],
49
- o
50
- ), e = t[0].toBigInt(), r = t[1], n = t[2][0].toBigInt(), s = t[2][1].toHexString(), i = t[2][2].toBigInt(), d = t[2][3].toBigInt(), c = t[3].toString(), m = t[4].toNumber();
49
+ e
50
+ ), o = BigInt(t[0]), r = t[1], n = BigInt(t[2][0]), s = d.toBeHex(BigInt(t[2][1])), i = BigInt(t[2][2]), a = BigInt(t[2][3]), c = BigInt(t[3]).toString(), m = Number(t[4]);
51
51
  return {
52
- amount: e,
52
+ amount: o,
53
53
  erc20TokenAddress: r,
54
54
  randomization: n,
55
55
  stealthAddress: s,
56
56
  H0: i,
57
- H1: d,
57
+ H1: a,
58
58
  timeStamp: c,
59
59
  tokenId: m
60
60
  };
61
- }, O = (o, t, e) => {
62
- if (y(e)) {
63
- const { amount: m, erc20TokenAddress: l, mintAddress: A, randomization: u, stealthAddress: h, timeStamp: g } = S(o);
61
+ }, $ = (e, t, o) => {
62
+ if (y(o)) {
63
+ const { amount: m, erc20TokenAddress: A, mintAddress: l, randomization: g, stealthAddress: h, timeStamp: u } = B(e);
64
64
  return {
65
65
  amount: m,
66
- erc20TokenAddress: l,
67
- mintAddress: A,
68
- timeStamp: g,
66
+ erc20TokenAddress: A,
67
+ mintAddress: l,
68
+ timeStamp: u,
69
69
  tokenId: 0,
70
- randomization: u,
70
+ randomization: g,
71
71
  shieldedPrivateKey: t,
72
72
  stealthAddress: h
73
73
  };
74
74
  }
75
- const { amount: r, erc20TokenAddress: n, timeStamp: s, tokenId: i, randomization: d, stealthAddress: c } = H(o);
75
+ const { amount: r, erc20TokenAddress: n, timeStamp: s, tokenId: i, randomization: a, stealthAddress: c } = I(e);
76
76
  return {
77
77
  amount: r,
78
78
  erc20TokenAddress: n,
79
79
  timeStamp: s,
80
80
  tokenId: i,
81
- randomization: d,
81
+ randomization: a,
82
82
  shieldedPrivateKey: t,
83
83
  stealthAddress: c
84
84
  };
85
- }, v = (o, t, e) => new z(O(o, t, e)), M = (o, t, e) => {
86
- const { randomization: r, H0: n, H1: s } = y(e) ? S(o) : H(o), i = C.checkSignature(r, n, s, t);
85
+ }, v = (e, t, o) => new E($(e, t, o)), M = (e, t, o) => {
86
+ const { randomization: r, H0: n, H1: s } = y(o) ? B(e) : I(e), i = z.checkSignature(r, n, s, t);
87
87
  if (!i)
88
88
  throw new Error("UTXO doesn't belong to user");
89
89
  return i;
90
90
  };
91
91
  export {
92
- H as abiDecodeUtxo,
92
+ I as abiDecodeUtxo,
93
93
  M as checkUtxoSignature,
94
- S as decodeSolanaOnChainUtxo,
94
+ B as decodeSolanaOnChainUtxo,
95
95
  v as decodeUtxo,
96
- O as decodeUtxoConstructorArgs,
96
+ $ as decodeUtxoConstructorArgs,
97
97
  F as encodeSolanaOnChainUtxo,
98
- N as isSolanaOnChainUtxo
98
+ O as isSolanaOnChainUtxo
99
99
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("ethers"),a=require("libsodium-wrappers"),p=require("../utxo/Utxo.cjs"),l=require("@solana/web3.js"),h=require("./keys.cjs"),g=e=>{const s=[Buffer.from(r.ethers.utils.hexlify(e.amount)),Buffer.from(r.ethers.utils.hexlify(e.erc20TokenAddress)),Buffer.from(r.ethers.utils.hexlify(e.randomization)),Buffer.from(e.getStealthAddress()),Buffer.from(r.ethers.utils.hexlify(BigInt(e.timeStamp))),Buffer.from(r.ethers.utils.hexlify(e.tokenId??0))];if(e.mintAddress){const o=new l.PublicKey(e.mintAddress),t=r.ethers.utils.hexlify(o.toBytes());s.push(Buffer.from(t))}const n=Buffer.concat(s);return a.crypto_box_seal(n,r.ethers.utils.arrayify(e.getEncryptionKey()))},u=(e,s)=>{const{publicKey:n,privateKey:c}=h.UserKeys.getEncryptionKeyPair(s.getShieldedPrivateKey()),o=a.crypto_box_seal_open(e,r.ethers.utils.arrayify(n),r.ethers.utils.arrayify(c)),t=Buffer.from(o).toString("utf-8").split("0x").filter(i=>i.length!==0).map((i,d)=>{let f;return[0,2,4,5].includes(d)?f=BigInt(`0x${i}`):[1,3,6].includes(d)&&(f=`0x${i}`),f}),y=typeof t[6]=="string"?t[6]:void 0,m=y?new l.PublicKey(Buffer.from(y.slice(2),"hex")).toString():void 0;return{amount:t[0],erc20TokenAddress:t[1],randomization:t[2],stealthAddress:t[3],shieldedPrivateKey:s.getShieldedPrivateKey(),timeStamp:t[4].toString(),tokenId:t[5]?Number(t[5]):0,mintAddress:m}},x=(e,s)=>new p.Utxo(u(e,s));exports.decryptUtxo=x;exports.decryptUtxoConstructorArgs=u;exports.encryptUtxo=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),a=require("libsodium-wrappers"),l=require("../utxo/Utxo.cjs"),m=require("@solana/web3.js"),B=require("./keys.cjs"),g=e=>{const r=[Buffer.from(o.ethers.toBeHex(e.amount)),Buffer.from(e.erc20TokenAddress),Buffer.from(o.ethers.toBeHex(e.randomization)),Buffer.from(e.getStealthAddress()),Buffer.from(o.ethers.toBeHex(BigInt(e.timeStamp))),Buffer.from(o.ethers.toBeHex(e.tokenId??0))];if(e.mintAddress){const t=new m.PublicKey(e.mintAddress).toBytes();r.push(Buffer.from(t))}const n=Buffer.concat(r);return a.crypto_box_seal(n,o.ethers.getBytes(e.getEncryptionKey()))},p=(e,r)=>{const{publicKey:n,privateKey:c}=B.UserKeys.getEncryptionKeyPair(r.getShieldedPrivateKey()),d=a.crypto_box_seal_open(e,o.ethers.getBytes(n),o.ethers.getBytes(c)),t=Buffer.from(d).toString("utf-8").split("0x").filter(s=>s.length!==0).map((s,y)=>{let i;return[0,2,4,5].includes(y)?i=BigInt(`0x${s}`):[1,3,6].includes(y)&&(i=`0x${s}`),i}),f=typeof t[6]=="string"?t[6]:void 0,u=f?new m.PublicKey(Buffer.from(f.slice(2),"hex")).toString():void 0;return{amount:t[0],erc20TokenAddress:t[1],randomization:t[2],stealthAddress:t[3],shieldedPrivateKey:r.getShieldedPrivateKey(),timeStamp:t[4].toString(),tokenId:t[5]?Number(t[5]):0,mintAddress:u}},h=(e,r)=>new l.Utxo(p(e,r));exports.decryptUtxo=h;exports.decryptUtxoConstructorArgs=p;exports.encryptUtxo=g;
@@ -1,46 +1,47 @@
1
- import { ethers as r } from "ethers";
2
- import m from "libsodium-wrappers";
3
- import { Utxo as p } from "../utxo/Utxo.mjs";
4
- import { PublicKey as c } from "@solana/web3.js";
5
- import { UserKeys as u } from "./keys.mjs";
1
+ import { ethers as o } from "ethers";
2
+ import a from "libsodium-wrappers";
3
+ import { Utxo as B } from "../utxo/Utxo.mjs";
4
+ import { PublicKey as p } from "@solana/web3.js";
5
+ import { UserKeys as l } from "./keys.mjs";
6
6
  const K = (e) => {
7
- const i = [
8
- Buffer.from(r.utils.hexlify(e.amount)),
9
- Buffer.from(r.utils.hexlify(e.erc20TokenAddress)),
10
- Buffer.from(r.utils.hexlify(e.randomization)),
7
+ const r = [
8
+ Buffer.from(o.toBeHex(e.amount)),
9
+ Buffer.from(e.erc20TokenAddress),
10
+ // if it is zeroAddress toBeHex will return 0x00
11
+ Buffer.from(o.toBeHex(e.randomization)),
11
12
  Buffer.from(e.getStealthAddress()),
12
- Buffer.from(r.utils.hexlify(BigInt(e.timeStamp))),
13
- Buffer.from(r.utils.hexlify(e.tokenId ?? 0))
13
+ Buffer.from(o.toBeHex(BigInt(e.timeStamp))),
14
+ Buffer.from(o.toBeHex(e.tokenId ?? 0))
14
15
  ];
15
16
  if (e.mintAddress) {
16
- const s = new c(e.mintAddress), t = r.utils.hexlify(s.toBytes());
17
- i.push(Buffer.from(t));
17
+ const t = new p(e.mintAddress).toBytes();
18
+ r.push(Buffer.from(t));
18
19
  }
19
- const n = Buffer.concat(i);
20
- return m.crypto_box_seal(n, r.utils.arrayify(e.getEncryptionKey()));
21
- }, h = (e, i) => {
22
- const { publicKey: n, privateKey: a } = u.getEncryptionKeyPair(i.getShieldedPrivateKey()), s = m.crypto_box_seal_open(
20
+ const s = Buffer.concat(r);
21
+ return a.crypto_box_seal(s, o.getBytes(e.getEncryptionKey()));
22
+ }, g = (e, r) => {
23
+ const { publicKey: s, privateKey: f } = l.getEncryptionKeyPair(r.getShieldedPrivateKey()), d = a.crypto_box_seal_open(
23
24
  e,
24
- r.utils.arrayify(n),
25
- r.utils.arrayify(a)
26
- ), t = Buffer.from(s).toString("utf-8").split("0x").filter((o) => o.length !== 0).map((o, d) => {
27
- let f;
28
- return [0, 2, 4, 5].includes(d) ? f = BigInt(`0x${o}`) : [1, 3, 6].includes(d) && (f = `0x${o}`), f;
29
- }), y = typeof t[6] == "string" ? t[6] : void 0, l = y ? new c(Buffer.from(y.slice(2), "hex")).toString() : void 0;
25
+ o.getBytes(s),
26
+ o.getBytes(f)
27
+ ), t = Buffer.from(d).toString("utf-8").split("0x").filter((n) => n.length !== 0).map((n, c) => {
28
+ let i;
29
+ return [0, 2, 4, 5].includes(c) ? i = BigInt(`0x${n}`) : [1, 3, 6].includes(c) && (i = `0x${n}`), i;
30
+ }), m = typeof t[6] == "string" ? t[6] : void 0, y = m ? new p(Buffer.from(m.slice(2), "hex")).toString() : void 0;
30
31
  return {
31
32
  amount: t[0],
32
33
  erc20TokenAddress: t[1],
33
34
  randomization: t[2],
34
35
  stealthAddress: t[3],
35
- shieldedPrivateKey: i.getShieldedPrivateKey(),
36
+ shieldedPrivateKey: r.getShieldedPrivateKey(),
36
37
  timeStamp: t[4].toString(),
37
38
  tokenId: t[5] ? Number(t[5]) : 0,
38
39
  // tokenId
39
- mintAddress: l
40
+ mintAddress: y
40
41
  };
41
- }, S = (e, i) => new p(h(e, i));
42
+ }, S = (e, r) => new B(g(e, r));
42
43
  export {
43
44
  S as decryptUtxo,
44
- h as decryptUtxoConstructorArgs,
45
+ g as decryptUtxoConstructorArgs,
45
46
  K as encryptUtxo
46
47
  };
@@ -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 n=require("ethers"),w=require("libsodium-wrappers"),S=require("../../constants/protocol.constants.cjs"),f=require("../../crypto/babyJub.cjs"),h=require("../../crypto/poseidon.cjs"),d=require("./keyUtils.cjs"),K=require("../cacheDevices/AttachableMemoryCacheDevice.cjs"),l=require("../../constants/chains.constants.cjs"),c=require("@solana/web3.js"),m=require("tweetnacl"),p=require("bs58"),b=require("../../functions/utils/create-provider.cjs"),v=new K.AttachableMemoryCacheDevice,P=new K.AttachableMemoryCacheDevice,q={privateKey:"",publicKey:""};class g{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(),n.ethers.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),n.ethers.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),h.poseidonHash(this.getShieldedPrivateKey()));getDerivedEthereumAddress=()=>(this.requireSignature(),new n.ethers.Wallet(this.getShieldedPrivateKey()).address);getDerivedSolanaPublicKey=()=>(this.requireSignature(),c.Keypair.fromSeed(n.ethers.getBytes(this.getShieldedPrivateKey())).publicKey.toBase58());getAccessKey=()=>(this.requireSignature(),h.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getSignerPrivateKeyFromNonce=e=>{this.requireSignature();const r=h.poseidonHash(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return n.ethers.keccak256(n.ethers.toUtf8Bytes(r))};getSignerSolanaPrivateKeyFromNonce=e=>{const r=this.getSignerPrivateKeyFromNonce(e),t=n.ethers.getBytes(r),i=c.Keypair.fromSeed(t);return p.encode(i.secretKey)};getEvmPrivateKeyFromSolanaPrivateKey=e=>{const t=p.decode(e).slice(0,32);return n.ethers.hexlify(t)};static getSignerFromPrivateKey=(e,r)=>{if(l.isSolanaLike(e)){const i=n.ethers.getBytes(r);return c.Keypair.fromSeed(i)}return new n.ethers.Wallet(r)};static getSignerAddressFromPrivateKey(e,r){const t=g.getSignerFromPrivateKey(e,r);return t instanceof c.Keypair?t.publicKey.toString():t.address}static signMessageFromPrivateKey=async(e,r,t)=>{const i=g.getSignerFromPrivateKey(e,r);if(i instanceof c.Keypair){const a=n.ethers.isHexString(t)?n.ethers.getBytes(t):new TextEncoder().encode(t),o=m.sign.detached(a,i.secretKey);return`0x${Buffer.from(o).toString("hex")}`}const s=n.ethers.isHexString(t)?n.ethers.getBytes(t):t;return i.signMessage(s)};static signSolanaTransactionFromPrivateKey=(e,r,t)=>{if(!l.isSolanaLike(e))throw new Error("Solana transaction signing is only available for Solana chains");const i=g.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=g.getSignerFromPrivateKey(e,r),{fetchRpcUrl:s}=l.networkRegistry[e];if(!s)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 b.createCustomSolanaConnection(s).sendRawTransaction(t.serialize())}if(t instanceof c.VersionedTransaction)throw new Error("Invalid transaction type for EVM");const a=new n.ethers.JsonRpcProvider(s);return(await i.connect(a).sendTransaction(t)).hash};static signTypedDataFromPrivateKey=async(e,r,t,i,s)=>{if(l.isSolanaLike(e))throw new Error("Solana does not support typed data");return await g.getSignerFromPrivateKey(e,r).signTypedData(t,i,s)};static authorizeDelegation=async(e,r,t,i)=>{if(l.isSolanaLike(e))throw new Error("Solana does not support delegation");const s=new n.ethers.JsonRpcProvider(l.networkRegistry[e].fetchRpcUrl);return await g.getSignerFromPrivateKey(e,r).connect(s).authorize({address:t,...i!==void 0&&{nonce:i}})};getWalletSalt=e=>(this.requireSignature(),h.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getInHinkalAddress=e=>{this.requireSignature();const r=h.poseidonHash(this.getShieldedPrivateKey(),e);return BigInt(r)};getBackendToken=()=>(this.requireSignature(),h.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=v.attach((e,r)=>{const t=f.babyJubInstance(),i=BigInt(r)%S.CIRCOM_P,s=e*i%S.CIRCOM_P,a=t.mulPointEscalar(t.Base8,e),o=t.mulPointEscalar(t.Base8,s),u=[BigInt(t.F.toString(a[0])),BigInt(t.F.toString(a[1]))],y=[BigInt(t.F.toString(o[0])),BigInt(t.F.toString(o[1]))];return{H0:u,H1:y}});static getStealthAddressCompressedPoints=(e,r)=>{const{H0:t,H1:i}=this.getRandomizedStealthPair(e,r),[s,a]=[t,i].map(o=>BigInt(o[1])+2n**255n*d.getCircomSign(o[0]));return{h0:s,h1:a}};static getStealthAddress=P.attach((e,r)=>{const{H0:t,H1:i}=this.getRandomizedStealthPair(e,r),a=[2n*d.getCircomSign(t[0])+d.getCircomSign(i[0]),t[1],i[1]];return h.poseidonHash(...a)});static getStealthAddressWithEKey=(e,r)=>({stealthAddress:this.getStealthAddress(e,r),encryptionKey:this.getEncryptionKeyPair(r).publicKey});static checkSignature=(e,r,t,i)=>{const{h0:s,h1:a}=this.getStealthAddressCompressedPoints(e,i);return r===s&&t===a};static getEncryptionKeyPair=e=>{const r=w.crypto_box_seed_keypair(n.ethers.getBytes(e));return{privateKey:n.ethers.hexlify(r.privateKey),publicKey:n.ethers.hexlify(r.publicKey)}}}exports.EncryptionKeyPairDefaultValue=q;exports.UserKeys=g;exports.stealthAddressCacheDevice=P;exports.stealthPairCacheDevice=v;
@@ -1,6 +1,5 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { AttachableMemoryCacheDevice } from '../cacheDevices/AttachableMemoryCacheDevice';
3
- import { ethers as ethersV6 } from 'ethers-v6h';
4
3
  import { VersionedTransaction } from '@solana/web3.js';
5
4
  export declare const stealthPairCacheDevice: AttachableMemoryCacheDevice<{
6
5
  H0: [bigint, bigint];
@@ -52,9 +51,9 @@ export declare class UserKeys {
52
51
  static getSignerAddressFromPrivateKey(chainId: number, privateKey: string): string;
53
52
  static signMessageFromPrivateKey: (chainId: number, privateKey: string, message: string) => Promise<string>;
54
53
  static signSolanaTransactionFromPrivateKey: (chainId: number, privateKey: string, transaction: VersionedTransaction) => void;
55
- static sendAndSignTransactionFromPrivateKey: (chainId: number, privateKey: string, transaction: ethersV6.TransactionRequest | VersionedTransaction) => Promise<string>;
54
+ static sendAndSignTransactionFromPrivateKey: (chainId: number, privateKey: string, transaction: ethers.TransactionRequest | VersionedTransaction) => Promise<string>;
56
55
  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>;
56
+ static authorizeDelegation: (chainId: number, privateKey: string, implementation: string, nonce?: number) => Promise<ethers.Authorization>;
58
57
  getWalletSalt: (walletNonce: bigint) => string;
59
58
  /**
60
59
  * generate inHinkalAddress - a user unique address linking him with a specific app
@@ -1,17 +1,16 @@
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";
1
+ import { ethers as n } from "ethers";
2
+ import P from "libsodium-wrappers";
3
+ import { CIRCOM_P as S } from "../../constants/protocol.constants.mjs";
4
+ import { babyJubInstance as v } from "../../crypto/babyJub.mjs";
5
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 = {
6
+ import { getCircomSign as u } from "./keyUtils.mjs";
7
+ import { AttachableMemoryCacheDevice as K } from "../cacheDevices/AttachableMemoryCacheDevice.mjs";
8
+ import { isSolanaLike as d, networkRegistry as p } from "../../constants/chains.constants.mjs";
9
+ import { Keypair as g, VersionedTransaction as m } from "@solana/web3.js";
10
+ import w from "tweetnacl";
11
+ import f from "bs58";
12
+ import { createCustomSolanaConnection as b } from "../../functions/utils/create-provider.mjs";
13
+ const F = new K(), B = new K(), W = {
15
14
  privateKey: "",
16
15
  publicKey: ""
17
16
  };
@@ -31,14 +30,14 @@ class l {
31
30
  throw Error("No signature provided");
32
31
  }
33
32
  verifyMessage(e) {
34
- return this.requireSignature(), o.verifyMessage(e, this.signature);
33
+ return this.requireSignature(), n.verifyMessage(e, this.signature);
35
34
  }
36
35
  /**
37
36
  * get shielded private key from message signature used to login to the application,
38
37
  * this private key is used to generate encryption keypairs as well as public key
39
38
  * @retuns 0x-prefixed shielded private key
40
39
  */
41
- getShieldedPrivateKey = () => (this.requireSignature(), d.utils.keccak256(this.signature));
40
+ getShieldedPrivateKey = () => (this.requireSignature(), n.keccak256(this.signature));
42
41
  /**
43
42
  * generate shielded public key from private key
44
43
  * @param privateKey the key used to generate the shielded public key, this should be the signature
@@ -49,11 +48,11 @@ class l {
49
48
  /**
50
49
  * deterministically derive an EVM address from the shielded private key
51
50
  */
52
- getDerivedEthereumAddress = () => (this.requireSignature(), new u.Wallet(this.getShieldedPrivateKey()).address);
51
+ getDerivedEthereumAddress = () => (this.requireSignature(), new n.Wallet(this.getShieldedPrivateKey()).address);
53
52
  /**
54
53
  * deterministically derive a Solana public key from the shielded private key
55
54
  */
56
- getDerivedSolanaPublicKey = () => (this.requireSignature(), g.fromSeed(o.arrayify(this.getShieldedPrivateKey())).publicKey.toBase58());
55
+ getDerivedSolanaPublicKey = () => (this.requireSignature(), g.fromSeed(n.getBytes(this.getShieldedPrivateKey())).publicKey.toBase58());
57
56
  /**
58
57
  * generate access token, this accessKey is what should be sent to the server for signing
59
58
  * @returns accessKey in hexstring with 0x prefixed
@@ -62,22 +61,22 @@ class l {
62
61
  getSignerPrivateKeyFromNonce = (e) => {
63
62
  this.requireSignature();
64
63
  const r = c(e, this.getShieldedPrivateKey(), this.getShieldedPublicKey());
65
- return o.keccak256(o.toUtf8Bytes(r));
64
+ return n.keccak256(n.toUtf8Bytes(r));
66
65
  };
67
66
  getSignerSolanaPrivateKeyFromNonce = (e) => {
68
- const r = this.getSignerPrivateKeyFromNonce(e), t = o.arrayify(r), i = g.fromSeed(t);
69
- return P.encode(i.secretKey);
67
+ const r = this.getSignerPrivateKeyFromNonce(e), t = n.getBytes(r), i = g.fromSeed(t);
68
+ return f.encode(i.secretKey);
70
69
  };
71
70
  getEvmPrivateKeyFromSolanaPrivateKey = (e) => {
72
- const t = P.decode(e).slice(0, 32);
73
- return F(t);
71
+ const t = f.decode(e).slice(0, 32);
72
+ return n.hexlify(t);
74
73
  };
75
74
  static getSignerFromPrivateKey = (e, r) => {
76
- if (h(e)) {
77
- const i = o.arrayify(r);
75
+ if (d(e)) {
76
+ const i = n.getBytes(r);
78
77
  return g.fromSeed(i);
79
78
  }
80
- return new u.Wallet(r);
79
+ return new n.Wallet(r);
81
80
  };
82
81
  static getSignerAddressFromPrivateKey(e, r) {
83
82
  const t = l.getSignerFromPrivateKey(e, r);
@@ -86,14 +85,14 @@ class l {
86
85
  static signMessageFromPrivateKey = async (e, r, t) => {
87
86
  const i = l.getSignerFromPrivateKey(e, r);
88
87
  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")}`;
88
+ const a = n.isHexString(t) ? n.getBytes(t) : new TextEncoder().encode(t), o = w.sign.detached(a, i.secretKey);
89
+ return `0x${Buffer.from(o).toString("hex")}`;
91
90
  }
92
- const n = o.isHexString(t) ? o.arrayify(t) : t;
93
- return i.signMessage(n);
91
+ const s = n.isHexString(t) ? n.getBytes(t) : t;
92
+ return i.signMessage(s);
94
93
  };
95
94
  static signSolanaTransactionFromPrivateKey = (e, r, t) => {
96
- if (!h(e))
95
+ if (!d(e))
97
96
  throw new Error("Solana transaction signing is only available for Solana chains");
98
97
  const i = l.getSignerFromPrivateKey(e, r);
99
98
  if (!(i instanceof g))
@@ -101,29 +100,29 @@ class l {
101
100
  t.sign([i]);
102
101
  };
103
102
  static sendAndSignTransactionFromPrivateKey = async (e, r, t) => {
104
- const i = l.getSignerFromPrivateKey(e, r), { fetchRpcUrl: n } = p[e];
105
- if (!n)
103
+ const i = l.getSignerFromPrivateKey(e, r), { fetchRpcUrl: s } = p[e];
104
+ if (!s)
106
105
  throw new Error("No RPC URL found for chainId");
107
106
  if (i instanceof g) {
108
- if (!(t instanceof K))
107
+ if (!(t instanceof m))
109
108
  throw new Error("Invalid transaction type for Solana");
110
- return t.sign([i]), await A(n).sendRawTransaction(t.serialize());
109
+ return t.sign([i]), await b(s).sendRawTransaction(t.serialize());
111
110
  }
112
- if (t instanceof K)
111
+ if (t instanceof m)
113
112
  throw new Error("Invalid transaction type for EVM");
114
- const a = new u.JsonRpcProvider(n);
113
+ const a = new n.JsonRpcProvider(s);
115
114
  return (await i.connect(a).sendTransaction(t)).hash;
116
115
  };
117
- static signTypedDataFromPrivateKey = async (e, r, t, i, n) => {
118
- if (h(e))
116
+ static signTypedDataFromPrivateKey = async (e, r, t, i, s) => {
117
+ if (d(e))
119
118
  throw new Error("Solana does not support typed data");
120
- return await l.getSignerFromPrivateKey(e, r).signTypedData(t, i, n);
119
+ return await l.getSignerFromPrivateKey(e, r).signTypedData(t, i, s);
121
120
  };
122
121
  static authorizeDelegation = async (e, r, t, i) => {
123
- if (h(e))
122
+ if (d(e))
124
123
  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 } });
124
+ const s = new n.JsonRpcProvider(p[e].fetchRpcUrl);
125
+ return await l.getSignerFromPrivateKey(e, r).connect(s).authorize({ address: t, ...i !== void 0 && { nonce: i } });
127
126
  };
128
127
  getWalletSalt = (e) => (this.requireSignature(), c(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), e));
129
128
  /**
@@ -140,24 +139,24 @@ class l {
140
139
  * @returns accessKey in hexstring with 0x prefixed
141
140
  */
142
141
  getBackendToken = () => (this.requireSignature(), c(this.getAccessKey(), this.getShieldedPublicKey()));
143
- static getRandomizedStealthPair = E.attach(
142
+ static getRandomizedStealthPair = F.attach(
144
143
  (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 };
144
+ const t = v(), i = BigInt(r) % S, s = e * i % S, a = t.mulPointEscalar(t.Base8, e), o = t.mulPointEscalar(t.Base8, s), h = [BigInt(t.F.toString(a[0])), BigInt(t.F.toString(a[1]))], y = [BigInt(t.F.toString(o[0])), BigInt(t.F.toString(o[1]))];
145
+ return { H0: h, H1: y };
147
146
  }
148
147
  );
149
148
  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 };
149
+ const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), [s, a] = [t, i].map((o) => BigInt(o[1]) + 2n ** 255n * u(o[0]));
150
+ return { h0: s, h1: a };
152
151
  };
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]];
152
+ static getStealthAddress = B.attach((e, r) => {
153
+ const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), a = [2n * u(t[0]) + u(i[0]), t[1], i[1]];
155
154
  return c(...a);
156
155
  });
157
156
  static getStealthAddressWithEKey = (e, r) => ({ stealthAddress: this.getStealthAddress(e, r), encryptionKey: this.getEncryptionKeyPair(r).publicKey });
158
157
  static checkSignature = (e, r, t, i) => {
159
- const { h0: n, h1: a } = this.getStealthAddressCompressedPoints(e, i);
160
- return r === n && t === a;
158
+ const { h0: s, h1: a } = this.getStealthAddressCompressedPoints(e, i);
159
+ return r === s && t === a;
161
160
  };
162
161
  /**
163
162
  * generate private and public keypair
@@ -165,16 +164,16 @@ class l {
165
164
  * and must correspond to 32 bytes
166
165
  */
167
166
  static getEncryptionKeyPair = (e) => {
168
- const r = w.crypto_box_seed_keypair(d.utils.arrayify(e));
167
+ const r = P.crypto_box_seed_keypair(n.getBytes(e));
169
168
  return {
170
- privateKey: d.utils.hexlify(r.privateKey),
171
- publicKey: d.utils.hexlify(r.publicKey)
169
+ privateKey: n.hexlify(r.privateKey),
170
+ publicKey: n.hexlify(r.publicKey)
172
171
  };
173
172
  };
174
173
  }
175
174
  export {
176
- L as EncryptionKeyPairDefaultValue,
175
+ W as EncryptionKeyPairDefaultValue,
177
176
  l as UserKeys,
178
- R as stealthAddressCacheDevice,
179
- E as stealthPairCacheDevice
177
+ B as stealthAddressCacheDevice,
178
+ F as stealthPairCacheDevice
180
179
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../../functions/utils/resolve-sync.utils.cjs");class h{blockchainEventEmitter;eventName;constructor(e,t){this.blockchainEventEmitter=e,this.eventName=t,e.addEventProcessorFunction(this.processEventsPage.bind(this))}get latestBlockNumber(){return this.blockchainEventEmitter.latestBlockNumber}intervalClear(){this.blockchainEventEmitter.intervalClear()}async processEventsPage(e){const t=new Set;e.forEach(({event:s,transactionHash:n})=>{s==="BlockedUtxosCreated"&&t.add(n)});const c=[];await v.resolveSync(e.map(s=>async()=>{if(s.event!==this.eventName)return;const{args:n,blockNumber:i,transactionHash:r}=s;if(!n)throw new Error("Wrong event structure");const a=this.mapEvent(n),l=t.has(r);await this.acceptEvent(a,i,r,l)&&c.push(a)}));const o=c.length;return await this.afterEventsAccepted(o),c.length}}exports.AbstractEventService=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../../functions/utils/resolve-sync.utils.cjs");class h{blockchainEventEmitter;eventName;constructor(e,s){this.blockchainEventEmitter=e,this.eventName=s,e.addEventProcessorFunction(this.processEventsPage.bind(this))}get latestBlockNumber(){return this.blockchainEventEmitter.latestBlockNumber}intervalClear(){this.blockchainEventEmitter.intervalClear()}async processEventsPage(e){const s=new Set;e.forEach(t=>{t.eventName==="BlockedUtxosCreated"&&s.add(t.transactionHash)});const n=[];await v.resolveSync(e.map(t=>async()=>{if(t.eventName!==this.eventName)return;const{args:c,blockNumber:i,transactionHash:a}=t;if(!c)throw new Error("Wrong event structure");const r=this.mapEvent(c),l=s.has(a);await this.acceptEvent(r,i,a,l)&&n.push(r)}));const o=n.length;return await this.afterEventsAccepted(o),n.length}}exports.AbstractEventService=h;
@@ -2,8 +2,8 @@ import { resolveSync as v } from "../../../functions/utils/resolve-sync.utils.mj
2
2
  class u {
3
3
  blockchainEventEmitter;
4
4
  eventName;
5
- constructor(t, e) {
6
- this.blockchainEventEmitter = t, this.eventName = e, t.addEventProcessorFunction(this.processEventsPage.bind(this));
5
+ constructor(t, s) {
6
+ this.blockchainEventEmitter = t, this.eventName = s, t.addEventProcessorFunction(this.processEventsPage.bind(this));
7
7
  }
8
8
  get latestBlockNumber() {
9
9
  return this.blockchainEventEmitter.latestBlockNumber;
@@ -12,24 +12,24 @@ class u {
12
12
  this.blockchainEventEmitter.intervalClear();
13
13
  }
14
14
  async processEventsPage(t) {
15
- const e = /* @__PURE__ */ new Set();
16
- t.forEach(({ event: s, transactionHash: n }) => {
17
- s === "BlockedUtxosCreated" && e.add(n);
15
+ const s = /* @__PURE__ */ new Set();
16
+ t.forEach((e) => {
17
+ e.eventName === "BlockedUtxosCreated" && s.add(e.transactionHash);
18
18
  });
19
- const c = [];
19
+ const n = [];
20
20
  await v(
21
- t.map((s) => async () => {
22
- if (s.event !== this.eventName)
21
+ t.map((e) => async () => {
22
+ if (e.eventName !== this.eventName)
23
23
  return;
24
- const { args: n, blockNumber: i, transactionHash: a } = s;
25
- if (!n)
24
+ const { args: a, blockNumber: i, transactionHash: c } = e;
25
+ if (!a)
26
26
  throw new Error("Wrong event structure");
27
- const r = this.mapEvent(n), h = e.has(a);
28
- await this.acceptEvent(r, i, a, h) && c.push(r);
27
+ const r = this.mapEvent(a), h = s.has(c);
28
+ await this.acceptEvent(r, i, c, h) && n.push(r);
29
29
  })
30
30
  );
31
- const o = c.length;
32
- return await this.afterEventsAccepted(o), c.length;
31
+ const o = n.length;
32
+ return await this.afterEventsAccepted(o), n.length;
33
33
  }
34
34
  }
35
35
  export {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./AbstractSnapshotService.cjs");class i extends t.AbstractSnapshotService{constructor(e){super(e,"Nullified")}_nullifiers;get nullifiers(){return this._nullifiers}serializeSnapshot(e){return{nullifiers:Array.from(e.payload.nullifiers).map(r=>r.toString()),latestBlockNumber:e.latestBlockNumber}}deserializeSnapshot(e){return{latestBlockNumber:e.latestBlockNumber??0,payload:{nullifiers:new Set(e.nullifiers??[])}}}acceptEvent(e,r){try{return this._nullifiers.has(e.nullifier)?!1:(this._nullifiers.add(e.nullifier),!0)}catch(l){return console.error(l),!1}}mapEvent(e){const{nullifier:r}=e;return{nullifier:r.toHexString()}}getSnapshotPayload(){return{nullifiers:this._nullifiers}}populateSnapshot({payload:{nullifiers:e}}){this._nullifiers=e}}exports.AbstractNullifierSnapshotService=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("ethers"),i=require("./AbstractSnapshotService.cjs");class s extends i.AbstractSnapshotService{constructor(e){super(e,"Nullified")}_nullifiers;get nullifiers(){return this._nullifiers}serializeSnapshot(e){return{nullifiers:Array.from(e.payload.nullifiers).map(r=>r.toString()),latestBlockNumber:e.latestBlockNumber}}deserializeSnapshot(e){return{latestBlockNumber:e.latestBlockNumber??0,payload:{nullifiers:new Set(e.nullifiers??[])}}}acceptEvent(e,r){try{return this._nullifiers.has(e.nullifier)?!1:(this._nullifiers.add(e.nullifier),!0)}catch(t){return console.error(t),!1}}mapEvent(e){const{nullifier:r}=e;return{nullifier:l.ethers.toBeHex(r)}}getSnapshotPayload(){return{nullifiers:this._nullifiers}}populateSnapshot({payload:{nullifiers:e}}){this._nullifiers=e}}exports.AbstractNullifierSnapshotService=s;
@@ -1,4 +1,3 @@
1
- import { BigNumber } from 'ethers';
2
1
  import { NullifierEvent } from '../../../types/commitments.types';
3
2
  import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
4
3
  import { BlockchainEventEmitter } from './BlockchainEventEmitter';
@@ -9,14 +8,14 @@ export type NullifierSerializedSnapshot = {
9
8
  latestBlockNumber?: number;
10
9
  nullifiers?: string[];
11
10
  };
12
- export declare abstract class AbstractNullifierSnapshotService extends AbstractSnapshotService<NullifierEvent<string>, NullifierEvent<BigNumber>, NullifierSnapshotPayload, NullifierSerializedSnapshot> {
11
+ export declare abstract class AbstractNullifierSnapshotService extends AbstractSnapshotService<NullifierEvent<string>, NullifierEvent<bigint>, NullifierSnapshotPayload, NullifierSerializedSnapshot> {
13
12
  constructor(hinkalEventEmitter: BlockchainEventEmitter);
14
13
  private _nullifiers;
15
14
  get nullifiers(): Set<string>;
16
15
  protected serializeSnapshot(snapshot: Snapshot<NullifierSnapshotPayload>): NullifierSerializedSnapshot;
17
16
  protected deserializeSnapshot(serializedSnapshot: NullifierSerializedSnapshot): Snapshot<NullifierSnapshotPayload>;
18
17
  protected acceptEvent(event: NullifierEvent<string>, _blockNumber: number): boolean;
19
- protected mapEvent(event: NullifierEvent<BigNumber>): NullifierEvent<string>;
18
+ protected mapEvent(event: NullifierEvent<bigint>): NullifierEvent<string>;
20
19
  protected getSnapshotPayload(): NullifierSnapshotPayload;
21
20
  protected populateSnapshot({ payload: { nullifiers } }: Snapshot<NullifierSnapshotPayload>): void;
22
21
  }
@@ -1,5 +1,6 @@
1
- import { AbstractSnapshotService as i } from "./AbstractSnapshotService.mjs";
2
- class n extends i {
1
+ import { ethers as i } from "ethers";
2
+ import { AbstractSnapshotService as t } from "./AbstractSnapshotService.mjs";
3
+ class a extends t {
3
4
  constructor(r) {
4
5
  super(r, "Nullified");
5
6
  }
@@ -31,7 +32,7 @@ class n extends i {
31
32
  mapEvent(r) {
32
33
  const { nullifier: e } = r;
33
34
  return {
34
- nullifier: e.toHexString()
35
+ nullifier: i.toBeHex(e)
35
36
  };
36
37
  }
37
38
  getSnapshotPayload() {
@@ -44,5 +45,5 @@ class n extends i {
44
45
  }
45
46
  }
46
47
  export {
47
- n as AbstractNullifierSnapshotService
48
+ a as AbstractNullifierSnapshotService
48
49
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../constants/save-depths.cjs"),a=require("./AbstractEventService.cjs");class i extends a.AbstractEventService{savedLatestBlockNumber=0;chainId=0;constructor(t,e){super(t,e)}async init(){await this.loadSnapshot(),this.chainId=(await this.blockchainEventEmitter.contract.provider.getNetwork()).chainId}async retrieveEventsFromLatestBlock(){await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber)}async loadSnapshot(){const t=await this.fetchSnapshot(),e=this.deserializeSnapshot(t);this.populateSnapshot(e),this.blockchainEventEmitter.syncFromAtMost(e.latestBlockNumber),this.savedLatestBlockNumber=e.latestBlockNumber}saveSnapshot(){return this.savedLatestBlockNumber=this.latestBlockNumber,this.persistSnapshot(this.serializeSnapshot({latestBlockNumber:this.latestBlockNumber,payload:this.getSnapshotPayload()}))}async afterEventsAccepted(t){(t>0||this.savedLatestBlockNumber+s.saveDepths[this.chainId]<this.latestBlockNumber)&&await this.saveSnapshot()}}exports.AbstractSnapshotService=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../constants/save-depths.cjs"),a=require("./AbstractEventService.cjs"),r=require("../../../functions/utils/getSignerFromContract.cjs");class i extends a.AbstractEventService{savedLatestBlockNumber=0;chainId=0;constructor(t,e){super(t,e)}async init(){await this.loadSnapshot();const t=r.getProviderFromContract(this.blockchainEventEmitter.contract);this.chainId=Number((await t.getNetwork()).chainId)}async retrieveEventsFromLatestBlock(){await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber)}async loadSnapshot(){const t=await this.fetchSnapshot(),e=this.deserializeSnapshot(t);this.populateSnapshot(e),this.blockchainEventEmitter.syncFromAtMost(e.latestBlockNumber),this.savedLatestBlockNumber=e.latestBlockNumber}saveSnapshot(){return this.savedLatestBlockNumber=this.latestBlockNumber,this.persistSnapshot(this.serializeSnapshot({latestBlockNumber:this.latestBlockNumber,payload:this.getSnapshotPayload()}))}async afterEventsAccepted(t){(t>0||this.savedLatestBlockNumber+s.saveDepths[this.chainId]<this.latestBlockNumber)&&await this.saveSnapshot()}}exports.AbstractSnapshotService=i;