@hinkal/common 0.0.111 → 0.0.113

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 (261) hide show
  1. package/index-DXElTGy9.mjs +254449 -0
  2. package/index.js +455 -642
  3. package/package.json +1 -1
  4. package/{webworker/snarkjsWorker/snarkjsWorkerLogic.js → snarkjsWorkerLogic-CVna_BW9.mjs} +1 -1
  5. package/utxoWorkerLogic-B1Hh-bq4.mjs +64 -0
  6. package/{webworker/workerProxy.js → workerProxy-BDj498Ht.mjs} +1 -1
  7. package/zkProofWorkerLogic-D9rxuuiK.mjs +60 -0
  8. package/API/API.js +0 -58
  9. package/API/HinkalPointsCalls.js +0 -38
  10. package/API/callBeefyGraphAPI.js +0 -37
  11. package/API/callCurveAPI.js +0 -156
  12. package/API/callMonitor.js +0 -30
  13. package/API/callOdosAPI.js +0 -44
  14. package/API/callOneInchAPI.js +0 -37
  15. package/API/callRelayer.js +0 -32
  16. package/API/checkRisk.js +0 -30
  17. package/API/dataServerCalls.js +0 -32
  18. package/API/fetchCommitmentsCache.js +0 -31
  19. package/API/fetchNullifiers.js +0 -30
  20. package/API/getAxelarGasEstimate.js +0 -37
  21. package/API/getCoingeckoPrice.js +0 -27
  22. package/API/getConnextReceiveFee.js +0 -30
  23. package/API/getGasEstimates.js +0 -38
  24. package/API/getRelayerURL.js +0 -32
  25. package/API/getServerURL.js +0 -67
  26. package/API/getTokenPrice.js +0 -41
  27. package/API/kycCalls.js +0 -32
  28. package/API/passwordCalls.js +0 -36
  29. package/API/referralProgramCalls.js +0 -58
  30. package/API/relayCalls.js +0 -30
  31. package/API/restoreSnapshots.js +0 -32
  32. package/API/rewardsPointsCalls.js +0 -40
  33. package/API/userVerifyTransactions.js +0 -45
  34. package/constants/assets.constants.js +0 -16
  35. package/constants/axelar.constants.js +0 -55
  36. package/constants/backend.constants.js +0 -18
  37. package/constants/beefy.registry.js +0 -24
  38. package/constants/chains.constants.js +0 -204
  39. package/constants/coingecko.constants.js +0 -53
  40. package/constants/contracts.constants.js +0 -276
  41. package/constants/crvCvx.registry.js +0 -636
  42. package/constants/crvDynamic.registry.js +0 -24
  43. package/constants/deploy-data/deploy-data-arbMainnet.json.js +0 -7415
  44. package/constants/deploy-data/deploy-data-avalanche.json.js +0 -7411
  45. package/constants/deploy-data/deploy-data-axelar1.json.js +0 -4329
  46. package/constants/deploy-data/deploy-data-axelar2.json.js +0 -4329
  47. package/constants/deploy-data/deploy-data-base.json.js +0 -8425
  48. package/constants/deploy-data/deploy-data-blast.json.js +0 -9600
  49. package/constants/deploy-data/deploy-data-bnbMainnet.json.js +0 -6877
  50. package/constants/deploy-data/deploy-data-ethMainnet.json.js +0 -11427
  51. package/constants/deploy-data/deploy-data-localhost.json.js +0 -13283
  52. package/constants/deploy-data/deploy-data-optimism.json.js +0 -7417
  53. package/constants/deploy-data/deploy-data-polygon.json.js +0 -7439
  54. package/constants/fees.constants.js +0 -57
  55. package/constants/kyc.constants.js +0 -118
  56. package/constants/lido.constants.js +0 -13
  57. package/constants/pendle.registry.js +0 -253
  58. package/constants/protocol.constants.js +0 -26
  59. package/constants/reorg-depths.constants.js +0 -15
  60. package/constants/rewards.constants.js +0 -27
  61. package/constants/server.constants.js +0 -157
  62. package/constants/token-data/ERC20Registry.js +0 -85
  63. package/constants/token-data/arbMainnetRegistry.json.js +0 -946
  64. package/constants/token-data/arbMainnetRegistryFixed.json.js +0 -856
  65. package/constants/token-data/avalancheRegistry.json.js +0 -591
  66. package/constants/token-data/avalancheRegistryFixed.json.js +0 -591
  67. package/constants/token-data/baseRegistry.json.js +0 -490
  68. package/constants/token-data/baseRegistryFixed.json.js +0 -463
  69. package/constants/token-data/blastRegistry.json.js +0 -137
  70. package/constants/token-data/blastRegistryFixed.json.js +0 -137
  71. package/constants/token-data/bnbMainnetRegistry.json.js +0 -973
  72. package/constants/token-data/bnbMainnetRegistryFixed.json.js +0 -973
  73. package/constants/token-data/coingeckoRegistry.json.js +0 -115623
  74. package/constants/token-data/ethMainnetRegistry.json.js +0 -2700
  75. package/constants/token-data/ethMainnetRegistryFixed.json.js +0 -2251
  76. package/constants/token-data/index.js +0 -6
  77. package/constants/token-data/localhostRegistry.json.js +0 -2768
  78. package/constants/token-data/optimismRegistry.json.js +0 -1455
  79. package/constants/token-data/optimismRegistryFixed.json.js +0 -1392
  80. package/constants/token-data/polygonRegistry.json.js +0 -1327
  81. package/constants/token-data/polygonRegistryFixed.json.js +0 -1255
  82. package/constants/token-data/popularTokens.constants.js +0 -14
  83. package/constants/token-data/tokenPricing.consts.js +0 -8
  84. package/constants/vite.constants.js +0 -29
  85. package/crypto/babyJub.js +0 -15
  86. package/crypto/poseidon.js +0 -26
  87. package/crypto/preProcessing.js +0 -9
  88. package/data-structures/Hinkal/Hinkal.js +0 -299
  89. package/data-structures/Hinkal/hinkalActionBeefy.js +0 -101
  90. package/data-structures/Hinkal/hinkalActionConvex.js +0 -83
  91. package/data-structures/Hinkal/hinkalActionCurve.js +0 -112
  92. package/data-structures/Hinkal/hinkalActionLidoEth.js +0 -91
  93. package/data-structures/Hinkal/hinkalActionPendle.js +0 -140
  94. package/data-structures/Hinkal/hinkalActionPendleLP.js +0 -96
  95. package/data-structures/Hinkal/hinkalActionStake.js +0 -138
  96. package/data-structures/Hinkal/hinkalActionVolatile.js +0 -112
  97. package/data-structures/Hinkal/hinkalDeposit.js +0 -95
  98. package/data-structures/Hinkal/hinkalGetZkMeProvider.js +0 -47
  99. package/data-structures/Hinkal/hinkalPrivateWallet.js +0 -66
  100. package/data-structures/Hinkal/hinkalSwap.js +0 -98
  101. package/data-structures/Hinkal/hinkalTransfer.js +0 -5
  102. package/data-structures/Hinkal/hinkalWithdraw.js +0 -91
  103. package/data-structures/Hinkal/resetMerkleTrees.js +0 -49
  104. package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.js +0 -83
  105. package/data-structures/ValueCache/ValueCache.js +0 -25
  106. package/data-structures/crypto-keys/decodeUTXO.js +0 -40
  107. package/data-structures/crypto-keys/encryptDecryptUtxo.js +0 -41
  108. package/data-structures/crypto-keys/keyUtils.js +0 -10
  109. package/data-structures/crypto-keys/keys.js +0 -90
  110. package/data-structures/custom-token-registry/CustomTokenRegistry.js +0 -33
  111. package/data-structures/event-service/AbstractAccessTokenSnapshotService.js +0 -131
  112. package/data-structures/event-service/AbstractCommitmentsSnapshotService.js +0 -132
  113. package/data-structures/event-service/AbstractEventService.js +0 -118
  114. package/data-structures/event-service/AbstractNullifierSnapshotService.js +0 -59
  115. package/data-structures/event-service/AbstractSnapshotService.js +0 -35
  116. package/data-structures/merkle-tree/MerkleTree.js +0 -177
  117. package/data-structures/merkle-tree/MerkleTreeIncompleteError.js +0 -8
  118. package/data-structures/snapshot/ClientAccessTokenSnapshotService.js +0 -48
  119. package/data-structures/snapshot/ClientCommitmentsSnapshotService.js +0 -47
  120. package/data-structures/snapshot/ClientNullifierSnapshotService.js +0 -44
  121. package/data-structures/token-price-fetcher/TokenChecker.js +0 -29
  122. package/data-structures/token-price-fetcher/TokenPriceFetcher.js +0 -218
  123. package/data-structures/transactions-manager/TransactionsManager.js +0 -194
  124. package/data-structures/transactions-manager/history/getBeefyData.js +0 -68
  125. package/data-structures/transactions-manager/history/getConvexData.js +0 -57
  126. package/data-structures/transactions-manager/history/getCurveData.js +0 -97
  127. package/data-structures/transactions-manager/history/getDepositData.js +0 -36
  128. package/data-structures/transactions-manager/history/getLidoData.js +0 -44
  129. package/data-structures/transactions-manager/history/getPendleData.js +0 -59
  130. package/data-structures/transactions-manager/history/getSwapData.js +0 -43
  131. package/data-structures/transactions-manager/history/getTxDetails.js +0 -74
  132. package/data-structures/transactions-manager/history/getVolatileData.js +0 -75
  133. package/data-structures/transactions-manager/history/history.types.js +0 -62
  134. package/data-structures/transactions-manager/history/history.utils.js +0 -8
  135. package/data-structures/utxo/Utxo.js +0 -134
  136. package/data-structures/volatile-helper/VolatileHelper.js +0 -181
  137. package/error-handling/customErrors/ErrorWithAmount.js +0 -9
  138. package/error-handling/customErrors/FeeOverTransactionValueError.js +0 -9
  139. package/error-handling/customErrors/customErrors.helpers.js +0 -21
  140. package/error-handling/error-codes.constants.js +0 -184
  141. package/error-handling/get-error.message.js +0 -53
  142. package/error-handling/handleErrorRestore.js +0 -35
  143. package/error-handling/logError.js +0 -7
  144. package/error-handling/types.js +0 -4
  145. package/externalABIs/BUSD.js +0 -519
  146. package/externalABIs/BabPassport.json.js +0 -24
  147. package/externalABIs/BeefyRouterAbi.json.js +0 -1022
  148. package/externalABIs/BeefyStrategyAbi.json.js +0 -1423
  149. package/externalABIs/BeefyVaultAbi.json.js +0 -570
  150. package/externalABIs/BeefyZapAbi.json.js +0 -208
  151. package/externalABIs/BeefyZapOneInchAbi.json.js +0 -340
  152. package/externalABIs/ConvexBoosterAbi.json.js +0 -674
  153. package/externalABIs/ConvexBoosterAbiMainnet.json.js +0 -1002
  154. package/externalABIs/ConvexRewardPoolAbi.json.js +0 -883
  155. package/externalABIs/CurveReadingWrapperAbi.json.js +0 -1422
  156. package/externalABIs/CurveWrappedMainPool.json.js +0 -1136
  157. package/externalABIs/CurveZap.json.js +0 -262
  158. package/externalABIs/CvxCrvUtilities.json.js +0 -264
  159. package/externalABIs/DAI.js +0 -334
  160. package/externalABIs/ERC20.json.js +0 -291
  161. package/externalABIs/GalxePassport.json.js +0 -41
  162. package/externalABIs/IQuoterV2.json.js +0 -205
  163. package/externalABIs/ISwapRouter.json.js +0 -568
  164. package/externalABIs/IUniswapV3Factory.json.js +0 -201
  165. package/externalABIs/IUniswapV3Pool.json.js +0 -999
  166. package/externalABIs/LidoStEthAbi.json.js +0 -1603
  167. package/externalABIs/LidoStMaticAbi.json.js +0 -1764
  168. package/externalABIs/LidoStakeManagerAbi.json.js +0 -2082
  169. package/externalABIs/LidoWithdrawalQueueERC721Abi.json.js +0 -2030
  170. package/externalABIs/LidoWstEthAbi.json.js +0 -480
  171. package/externalABIs/OptimismGasPriceOracle.json.js +0 -206
  172. package/externalABIs/PendleRouterAbi.json.js +0 -173
  173. package/externalABIs/PoLidoNftAbi.json.js +0 -701
  174. package/externalABIs/SanctionsList.js +0 -89
  175. package/externalABIs/USDC.js +0 -721
  176. package/externalABIs/USDR.js +0 -346
  177. package/externalABIs/USDR3CRV.js +0 -542
  178. package/externalABIs/USDT.js +0 -393
  179. package/externalABIs/UniswapV2PoolAbi.json.js +0 -80
  180. package/externalABIs/WETH.js +0 -156
  181. package/externalABIs/amToken.js +0 -350
  182. package/externalABIs/transactionsProver.json.js +0 -39
  183. package/functions/kyc/authentoHelper.js +0 -42
  184. package/functions/kyc/passportHelper.js +0 -39
  185. package/functions/kyc/zkMeHelper.js +0 -56
  186. package/functions/pre-transaction/getFlatFees.js +0 -203
  187. package/functions/pre-transaction/interaction-to-action.js +0 -57
  188. package/functions/pre-transaction/outputUtxoProcessing.js +0 -45
  189. package/functions/pre-transaction/process-gas-estimates.js +0 -57
  190. package/functions/pre-transaction/processAmountChanges.js +0 -229
  191. package/functions/private-wallet/emporium.helpers.js +0 -19
  192. package/functions/private-wallet/opProducer.js +0 -24
  193. package/functions/protocols/convex.protocols.js +0 -41
  194. package/functions/protocols/curve.protocols.js +0 -45
  195. package/functions/protocols/pendle.helpers.js +0 -108
  196. package/functions/snarkjs/common.snarkjs.js +0 -96
  197. package/functions/snarkjs/constant.js +0 -211
  198. package/functions/snarkjs/constructEmporiumProof.js +0 -105
  199. package/functions/snarkjs/constructGeneralZkProof.js +0 -129
  200. package/functions/snarkjs/generateCircomData.js +0 -60
  201. package/functions/snarkjs/generateZkProof.js +0 -18
  202. package/functions/snarkjs/getZKFiles.js +0 -30
  203. package/functions/staking/index.js +0 -40
  204. package/functions/utils/amounts.utils.js +0 -70
  205. package/functions/utils/axelar.utils.js +0 -38
  206. package/functions/utils/cacheFunctions.js +0 -67
  207. package/functions/utils/caseInsensitive.utils.js +0 -6
  208. package/functions/utils/convertIntegrationProviderToExternalActionId.js +0 -16
  209. package/functions/utils/create-provider.js +0 -5
  210. package/functions/utils/enum.utils.js +0 -14
  211. package/functions/utils/erc20tokenFunctions.js +0 -20
  212. package/functions/utils/evmNetworkFunctions.js +0 -29
  213. package/functions/utils/external-action.utils.js +0 -61
  214. package/functions/utils/getDataFromTransaction.js +0 -105
  215. package/functions/utils/memoize.utils.js +0 -14
  216. package/functions/utils/nickname.utils.js +0 -7
  217. package/functions/utils/process.utils.js +0 -4
  218. package/functions/utils/reloadPage.js +0 -4
  219. package/functions/utils/requireEnv.js +0 -7
  220. package/functions/utils/resolve-sync.utils.js +0 -22
  221. package/functions/utils/serialize.utils.js +0 -4
  222. package/functions/utils/string.utils.js +0 -14
  223. package/functions/utils/time.utils.js +0 -8
  224. package/functions/utils/userAgent.js +0 -15
  225. package/functions/utils/volatile-patcher.utils.js +0 -40
  226. package/functions/web3/etherFunctions.js +0 -41
  227. package/functions/web3/events/balanceChangedHandler.js +0 -10
  228. package/functions/web3/events/getInputUtxoAndBalance.js +0 -72
  229. package/functions/web3/events/getShieldedBalance.js +0 -107
  230. package/functions/web3/events/web3RetrieveEvents.js +0 -9
  231. package/functions/web3/functionCalls/accessTokenCalls.js +0 -48
  232. package/functions/web3/functionCalls/approveToken.js +0 -153
  233. package/functions/web3/functionCalls/estimateGasRelayer.js +0 -18
  234. package/functions/web3/functionCalls/transactCallDirect.js +0 -60
  235. package/functions/web3/functionCalls/transactCallRelayer.js +0 -42
  236. package/functions/web3/odosAPI.js +0 -65
  237. package/functions/web3/oneInchAPI.js +0 -61
  238. package/functions/web3/runContractFunction.js +0 -95
  239. package/functions/web3/uniswapAPI.js +0 -97
  240. package/types/beefy.types.js +0 -21
  241. package/types/circom-data.types.js +0 -22
  242. package/types/curve.types.js +0 -25
  243. package/types/ethereum-network.types.js +0 -4
  244. package/types/external-action.types.js +0 -4
  245. package/types/hinkal.stake.types.js +0 -4
  246. package/types/hinkal.types.js +0 -15
  247. package/types/kyc.types.js +0 -13
  248. package/types/pendle.types.js +0 -15
  249. package/types/rewards.types.js +0 -27
  250. package/types/slippage.types.js +0 -15
  251. package/types/time.types.js +0 -58
  252. package/types/token.types.js +0 -4
  253. package/types/transactions.types.js +0 -36
  254. package/webworker/performTaskWithWorker.js +0 -62
  255. package/webworker/snarkjsWorker/snarkjsWorker.types.js +0 -4
  256. package/webworker/utxoWorker/utxoWorker.types.js +0 -4
  257. package/webworker/utxoWorker/utxoWorkerLogic.js +0 -70
  258. package/webworker/worker.registry.js +0 -4
  259. package/webworker/workerFactory.js +0 -42
  260. package/webworker/zkProofWorker/zkProofWorker.types.js +0 -4
  261. package/webworker/zkProofWorker/zkProofWorkerLogic.js +0 -66
@@ -1,40 +0,0 @@
1
- import { ethers as m } from "ethers";
2
- import { Utxo as g } from "../utxo/Utxo.js";
3
- import { UserKeys as x } from "./keys.js";
4
- const c = (o) => {
5
- const t = m.utils.defaultAbiCoder.decode(
6
- ["uint256", "address", "tuple(uint256, uint256, uint256, uint256)", "uint256", "uint256"],
7
- o
8
- ), e = t[0].toBigInt(), r = t[1], s = t[2][0].toBigInt(), n = t[2][1].toHexString(), i = t[2][2].toBigInt(), d = t[2][3].toBigInt(), u = t[3].toString(), a = t[4].toNumber();
9
- return {
10
- amount: e,
11
- erc20TokenAddress: r,
12
- randomization: s,
13
- stealthAddress: n,
14
- H0: i,
15
- H1: d,
16
- timeStamp: u,
17
- tokenId: a
18
- };
19
- }, U = (o, t) => {
20
- const { amount: e, erc20TokenAddress: r, timeStamp: s, tokenId: n, randomization: i } = c(o);
21
- return {
22
- amount: e,
23
- erc20TokenAddress: r,
24
- timeStamp: s,
25
- tokenId: n,
26
- randomization: i,
27
- shieldedPrivateKey: t
28
- };
29
- }, k = (o, t) => new g(U(o, t)), I = (o, t) => {
30
- const { randomization: e, H0: r, H1: s } = c(o), n = x.checkSignature(e, r, s, t);
31
- if (!n)
32
- throw new Error("UTXO doesn't belong to user");
33
- return n;
34
- };
35
- export {
36
- c as abiDecodeUtxo,
37
- I as checkUtxoSignature,
38
- k as decodeUtxo,
39
- U as decodeUtxoConstructorArgs
40
- };
@@ -1,41 +0,0 @@
1
- import { ethers as t } from "ethers";
2
- import a from "libsodium-wrappers";
3
- import { Utxo as d } from "../utxo/Utxo.js";
4
- import { UserKeys as l } from "./keys.js";
5
- (async () => await a.ready)();
6
- const B = (e, i) => {
7
- const o = [
8
- Buffer.from(t.utils.hexlify(i ? 0n : e.amount)),
9
- Buffer.from(t.utils.hexlify(e.erc20TokenAddress)),
10
- Buffer.from(t.utils.hexlify(e.randomization)),
11
- Buffer.from(e.getStealthAddress()),
12
- Buffer.from(t.utils.hexlify(BigInt(e.timeStamp)))
13
- ];
14
- e.tokenId > 0 && o.push(Buffer.from(t.utils.hexlify(e.tokenId)));
15
- const n = Buffer.concat(o);
16
- return a.crypto_box_seal(n, t.utils.arrayify(e.getEncryptionKey()));
17
- }, m = (e, i) => {
18
- const { publicKey: o, privateKey: n } = l.getEncryptionKeyPair(i.getShieldedPrivateKey()), y = a.crypto_box_seal_open(
19
- e,
20
- t.utils.arrayify(o),
21
- t.utils.arrayify(n)
22
- ), r = Buffer.from(y).toString("utf-8").split("0x").filter((f) => f.length !== 0).map((f, c) => {
23
- let s;
24
- return [0, 2, 4, 5].includes(c) ? s = BigInt(`0x${f}`) : [1, 3].includes(c) && (s = `0x${f}`), s;
25
- });
26
- return {
27
- amount: r[0],
28
- erc20TokenAddress: r[1],
29
- randomization: r[2],
30
- stealthAddress: r[3],
31
- shieldedPrivateKey: i.getShieldedPrivateKey(),
32
- timeStamp: r[4].toString(),
33
- tokenId: r[5] ? Number(r[5]) : 0
34
- // tokenId
35
- };
36
- }, x = (e, i) => new d(m(e, i));
37
- export {
38
- x as decryptUtxo,
39
- m as decryptUtxoConstructorArgs,
40
- B as encryptUtxo
41
- };
@@ -1,10 +0,0 @@
1
- import { CIRCOM_P as o, CIRCOM_P_HALF as t } from "../../constants/protocol.constants.js";
2
- const e = (r) => {
3
- if (r < 0n || r >= o)
4
- throw new RangeError();
5
- return r > t;
6
- }, n = (r) => e(r) ? 1n : 0n;
7
- export {
8
- n as getCircomSign,
9
- e as isCircomNegative
10
- };
@@ -1,90 +0,0 @@
1
- import { utils as S, ethers as o } from "ethers";
2
- import d from "libsodium-wrappers";
3
- import { CIRCOM_P as h } from "../../constants/protocol.constants.js";
4
- import { babyJubInstance as m } from "../../crypto/babyJub.js";
5
- import { poseidonHash as u } from "../../crypto/poseidon.js";
6
- import { memoizeFunc as c } from "../../functions/utils/memoize.utils.js";
7
- import { getCircomSign as g } from "./keyUtils.js";
8
- (async () => await d.ready)();
9
- const q = {
10
- privateKey: "",
11
- publicKey: ""
12
- };
13
- class H {
14
- signature;
15
- constructor(t) {
16
- this.signature = t;
17
- }
18
- getSignature() {
19
- return this.requireSignature(), this.signature;
20
- }
21
- setSignature(t) {
22
- this.signature = t;
23
- }
24
- requireSignature() {
25
- if (!this.signature)
26
- throw Error("No signature provided");
27
- }
28
- verifyMessage(t) {
29
- return this.requireSignature(), S.verifyMessage(t, this.signature);
30
- }
31
- /**
32
- * get shielded private key from message signature used to login to the application,
33
- * this private key is used to generate encryption keypairs as well as public key
34
- * @retuns 0x-prefixed shielded private key
35
- */
36
- getShieldedPrivateKey = () => (this.requireSignature(), o.utils.keccak256(this.signature));
37
- /**
38
- * generate shielded public key from private key
39
- * @param privateKey the key used to generate the shielded public key, this should be the signature
40
- * that the user provided
41
- * @retuns shielded public key in hexstring with 0x prefixed
42
- */
43
- getShieldedPublicKey = () => (this.requireSignature(), u(this.getShieldedPrivateKey()));
44
- /**
45
- * generate access token, this accessKey is what should be sent to the server for signing
46
- * @returns accessKey in hexstring with 0x prefixed
47
- */
48
- getAccessKey = () => (this.requireSignature(), u(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
49
- getWalletSalt = (t) => (this.requireSignature(), u(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), t));
50
- /**
51
- * generate backend token, which is used for access control on backend
52
- * @returns accessKey in hexstring with 0x prefixed
53
- */
54
- getBackendToken = () => (this.requireSignature(), u(this.getAccessKey(), this.getShieldedPublicKey()));
55
- static getRandomizedStealthPair = c(
56
- (t, i) => {
57
- const e = m(), r = BigInt(i) % h, n = t * r % h, s = e.mulPointEscalar(e.Base8, t), a = e.mulPointEscalar(e.Base8, n), l = [BigInt(e.F.toString(s[0])), BigInt(e.F.toString(s[1]))], y = [BigInt(e.F.toString(a[0])), BigInt(e.F.toString(a[1]))];
58
- return { H0: l, H1: y };
59
- }
60
- );
61
- static getStealthAddressCompressedPoints = (t, i) => {
62
- const { H0: e, H1: r } = this.getRandomizedStealthPair(t, i), [n, s] = [e, r].map((a) => BigInt(a[1]) + 2n ** 255n * g(a[0]));
63
- return { h0: n, h1: s };
64
- };
65
- static getStealthAddress = c((t, i) => {
66
- const { H0: e, H1: r } = this.getRandomizedStealthPair(t, i), s = [2n * g(e[0]) + g(r[0]), e[1], r[1]];
67
- return u(...s);
68
- });
69
- static getStealthAddressWithEKey = (t, i) => ({ stealthAddress: this.getStealthAddress(t, i), encryptionKey: this.getEncryptionKeyPair(i).publicKey });
70
- static checkSignature = (t, i, e, r) => {
71
- const { h0: n, h1: s } = this.getStealthAddressCompressedPoints(t, r);
72
- return i === n && e === s;
73
- };
74
- /**
75
- * generate private and public keypair
76
- * @param seed seed to use to deterministically generate key, must be in DataHexString format
77
- * and must correspond to 32 bytes
78
- */
79
- static getEncryptionKeyPair = (t) => {
80
- const i = d.crypto_box_seed_keypair(o.utils.arrayify(t));
81
- return {
82
- privateKey: o.utils.hexlify(i.privateKey),
83
- publicKey: o.utils.hexlify(i.publicKey)
84
- };
85
- };
86
- }
87
- export {
88
- q as EncryptionKeyPairDefaultValue,
89
- H as UserKeys
90
- };
@@ -1,33 +0,0 @@
1
- class o {
2
- localStorageKey = "tokenRegistry";
3
- tokenRegistry;
4
- constructor() {
5
- if (this.tokenRegistry = [], typeof localStorage < "u") {
6
- const t = localStorage.getItem(this.localStorageKey);
7
- t && (this.tokenRegistry = JSON.parse(t));
8
- }
9
- }
10
- persistRegistry() {
11
- typeof localStorage < "u" && localStorage.setItem(this.localStorageKey, JSON.stringify(this.tokenRegistry));
12
- }
13
- getCustomTokens(t) {
14
- return this.tokenRegistry.filter((s) => s.chainId === t);
15
- }
16
- tokenExists(t, s) {
17
- return t.find(
18
- (e) => e.erc20TokenAddress === s.erc20TokenAddress || e.symbol === s.symbol || e.name === s.name
19
- );
20
- }
21
- addCustomToken(t) {
22
- const { chainId: s } = t, e = this.getCustomTokens(s);
23
- this.tokenExists(e, t) || this.tokenRegistry.push(t), this.persistRegistry();
24
- }
25
- removeCustomToken(t) {
26
- const { chainId: s } = t, r = this.getCustomTokens(s).filter((i) => i.erc20TokenAddress !== t.erc20TokenAddress);
27
- this.tokenRegistry = r, this.persistRegistry();
28
- }
29
- }
30
- const g = new o();
31
- export {
32
- g as customTokenRegistry
33
- };
@@ -1,131 +0,0 @@
1
- import "../../constants/chains.constants.js";
2
- import "../../types/circom-data.types.js";
3
- import "../../types/transactions.types.js";
4
- import "../../types/curve.types.js";
5
- import "ethers";
6
- import { zeroAddress as i } from "../../constants/protocol.constants.js";
7
- import { poseidonFunction as m } from "../../crypto/poseidon.js";
8
- import "../crypto-keys/keys.js";
9
- import { toBigInt as t } from "../../functions/utils/amounts.utils.js";
10
- import "axios";
11
- import "../crypto-keys/encryptDecryptUtxo.js";
12
- import "../../functions/web3/events/getShieldedBalance.js";
13
- import "../../webworker/workerFactory.js";
14
- import "../../functions/utils/external-action.utils.js";
15
- import "../custom-token-registry/CustomTokenRegistry.js";
16
- import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
17
- import "../../constants/coingecko.constants.js";
18
- import "../../constants/vite.constants.js";
19
- import "../../functions/utils/userAgent.js";
20
- import "circomlibjs";
21
- import { MerkleTree as o } from "../merkle-tree/MerkleTree.js";
22
- import { AbstractSnapshotService as c } from "./AbstractSnapshotService.js";
23
- import "../../constants/reorg-depths.constants.js";
24
- import "../../constants/kyc.constants.js";
25
- import "../volatile-helper/VolatileHelper.js";
26
- import "libsodium-wrappers";
27
- import "../../constants/contracts.constants.js";
28
- import "../../constants/axelar.constants.js";
29
- import "../../constants/rewards.constants.js";
30
- class G extends c {
31
- constructor(e, s, r, d) {
32
- super(
33
- e,
34
- {
35
- name: "NewAccessKeyAdded",
36
- args: ["accessKey", "index", "senderAddress"]
37
- },
38
- s,
39
- r,
40
- d
41
- );
42
- }
43
- _merkleTree;
44
- _senderAddresses;
45
- _senderAddressIndexMap;
46
- get merkleTree() {
47
- return this._merkleTree;
48
- }
49
- get senderAddresses() {
50
- return this._senderAddresses;
51
- }
52
- get senderAddressIndexMap() {
53
- return this._senderAddressIndexMap;
54
- }
55
- serializeSnapshot(e) {
56
- return {
57
- merkleTree: e.payload.merkleTree.toJSON(),
58
- senderAddresses: Array.from(e.payload.senderAddresses),
59
- latestBlockNumber: e.latestBlockNumber,
60
- reserveBlockNumber: e.reserveBlockNumber,
61
- senderAddressIndexMap: Array.from(e.payload.senderAddressIndexMap).map(([s, r]) => ({
62
- address: s,
63
- index: r
64
- }))
65
- };
66
- }
67
- deserializeSnapshot(e) {
68
- let s, r;
69
- if (e.latestBlockNumber && e.merkleTree) {
70
- const d = new Map(
71
- Object.entries(e.merkleTree.tree).map(([n, p]) => [
72
- BigInt(n),
73
- BigInt(p)
74
- ])
75
- );
76
- s = o.createWithData(
77
- d,
78
- t(e.merkleTree.index),
79
- t(e.merkleTree.count),
80
- m,
81
- 25n,
82
- 0n
83
- );
84
- } else
85
- s = o.create(m, 25n, 0n);
86
- return e.latestBlockNumber && e.senderAddressIndexMap ? r = new Map(
87
- e.senderAddressIndexMap.map(({ address: d, index: n }) => [d, n])
88
- ) : r = /* @__PURE__ */ new Map(), {
89
- latestBlockNumber: e.latestBlockNumber ?? 0,
90
- reserveBlockNumber: e.reserveBlockNumber ?? 0,
91
- payload: {
92
- merkleTree: s,
93
- senderAddresses: e.senderAddresses ?? [],
94
- senderAddressIndexMap: r
95
- }
96
- };
97
- }
98
- acceptEvent(e, s) {
99
- try {
100
- return this._merkleTree.insert(e.accessKey, e.index), this._senderAddressIndexMap.set(
101
- e.senderAddress,
102
- Math.max(Number(e.index), this._senderAddressIndexMap.get(e.senderAddress) ?? 0)
103
- ), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress === i && this._merkleTree.remove(e.index), !0;
104
- } catch (r) {
105
- return console.error(r), !1;
106
- }
107
- }
108
- mapEvent(e) {
109
- const { accessKey: s, index: r, senderAddress: d } = e;
110
- return {
111
- accessKey: t(s),
112
- index: t(r),
113
- senderAddress: d
114
- };
115
- }
116
- getSnapshotPayload() {
117
- return {
118
- merkleTree: this._merkleTree,
119
- senderAddresses: this._senderAddresses,
120
- senderAddressIndexMap: this._senderAddressIndexMap
121
- };
122
- }
123
- populateSnapshot({
124
- payload: { merkleTree: e, senderAddresses: s, senderAddressIndexMap: r }
125
- }) {
126
- this._merkleTree = e, this._senderAddresses = s, this._senderAddressIndexMap = r;
127
- }
128
- }
129
- export {
130
- G as AbstractAccessTokenSnapshotService
131
- };
@@ -1,132 +0,0 @@
1
- import { poseidonFunction as o } from "../../crypto/poseidon.js";
2
- import "circomlibjs";
3
- import { MerkleTree as p } from "../merkle-tree/MerkleTree.js";
4
- import { toBigInt as i } from "../../functions/utils/amounts.utils.js";
5
- import "ethers";
6
- import "axios";
7
- import "../../constants/chains.constants.js";
8
- import "../../types/circom-data.types.js";
9
- import "../../types/transactions.types.js";
10
- import "../../types/curve.types.js";
11
- import "../crypto-keys/keys.js";
12
- import "../../functions/web3/events/getShieldedBalance.js";
13
- import "../../webworker/workerFactory.js";
14
- import "../crypto-keys/encryptDecryptUtxo.js";
15
- import "../../functions/utils/external-action.utils.js";
16
- import "../../constants/coingecko.constants.js";
17
- import "../../constants/vite.constants.js";
18
- import "libsodium-wrappers";
19
- import { AbstractSnapshotService as c } from "./AbstractSnapshotService.js";
20
- import "../../constants/reorg-depths.constants.js";
21
- import "../../constants/kyc.constants.js";
22
- import "../volatile-helper/VolatileHelper.js";
23
- import "../custom-token-registry/CustomTokenRegistry.js";
24
- import "../../constants/contracts.constants.js";
25
- import "../../constants/axelar.constants.js";
26
- import "../../constants/rewards.constants.js";
27
- import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
28
- import "../../functions/utils/userAgent.js";
29
- class D extends c {
30
- constructor(e, t, m, r) {
31
- super(
32
- e,
33
- {
34
- name: "NewCommitment",
35
- args: ["commitment", "index", "encryptedOutput"]
36
- },
37
- t,
38
- m,
39
- r
40
- );
41
- }
42
- _merkleTree;
43
- _encryptedOutputs;
44
- get merkleTree() {
45
- return this._merkleTree;
46
- }
47
- get encryptedOutputs() {
48
- return this._encryptedOutputs;
49
- }
50
- serializeSnapshot(e) {
51
- return {
52
- merkleTree: e.payload.merkleTree.toJSON(),
53
- latestBlockNumber: e.latestBlockNumber,
54
- reserveBlockNumber: e.reserveBlockNumber,
55
- encryptedOutputs: e.payload.encryptedOutputs.map((t) => ({
56
- value: t.value,
57
- isPositive: String(t.isPositive)
58
- }))
59
- };
60
- }
61
- deserializeSnapshot(e) {
62
- let t;
63
- if (e.latestBlockNumber && e.merkleTree) {
64
- const r = new Map(
65
- Object.entries(e.merkleTree.tree).map(([u, n]) => [
66
- BigInt(u),
67
- BigInt(n)
68
- ])
69
- );
70
- t = p.createWithData(
71
- r,
72
- i(e.merkleTree.index),
73
- i(e.merkleTree.count),
74
- o,
75
- 25n,
76
- 0n
77
- );
78
- } else
79
- t = p.create(o, 25n, 0n);
80
- const m = e.encryptedOutputs?.map((r) => ({
81
- value: r.value,
82
- isPositive: JSON.parse(r.isPositive)
83
- }));
84
- return {
85
- latestBlockNumber: e.latestBlockNumber ?? 0,
86
- reserveBlockNumber: e.reserveBlockNumber ?? 0,
87
- payload: {
88
- merkleTree: t,
89
- encryptedOutputs: m || []
90
- }
91
- };
92
- }
93
- getSnapshotPayload() {
94
- return {
95
- merkleTree: this._merkleTree,
96
- encryptedOutputs: this._encryptedOutputs
97
- };
98
- }
99
- populateSnapshot({
100
- payload: { merkleTree: e, encryptedOutputs: t }
101
- }) {
102
- this._merkleTree = e, this._encryptedOutputs = t;
103
- }
104
- mapEvent(e) {
105
- const { commitment: t, index: m, encryptedOutput: r } = e;
106
- return {
107
- commitment: i(t),
108
- index: i(m),
109
- encryptedOutput: r
110
- };
111
- }
112
- acceptEvent(e, t) {
113
- if (!this.encryptedOutputs.map((m) => m.value).includes(e.encryptedOutput)) {
114
- if (this.isServer && console.log(
115
- `Adding commitment to file ${e.commitment} at index ${e.index} for encrypted output ${e.encryptedOutput}. Block Number: ${t}
116
-
117
-
118
- `
119
- ), !this._merkleTree.insert(e.commitment, e.index >= 0 ? e.index : -1n * e.index))
120
- return console.log(`Could not add ${e.commitment} at index ${e.index} `), !1;
121
- const r = {
122
- value: e.encryptedOutput,
123
- isPositive: e.index >= 0n
124
- };
125
- return this._encryptedOutputs.push(r), !0;
126
- }
127
- return !1;
128
- }
129
- }
130
- export {
131
- D as AbstractCommitmentsSnapshotService
132
- };
@@ -1,118 +0,0 @@
1
- import { blockReorgDepth as v } from "../../constants/reorg-depths.constants.js";
2
- import "ethers";
3
- import "axios";
4
- import "../../constants/chains.constants.js";
5
- import "../../types/circom-data.types.js";
6
- import "../../types/transactions.types.js";
7
- import "../../types/curve.types.js";
8
- import "circomlibjs";
9
- import "../crypto-keys/keys.js";
10
- import "../../functions/web3/events/getShieldedBalance.js";
11
- import "../../webworker/workerFactory.js";
12
- import "../crypto-keys/encryptDecryptUtxo.js";
13
- import "../../functions/utils/external-action.utils.js";
14
- import "../../constants/coingecko.constants.js";
15
- import "../../constants/vite.constants.js";
16
- import "libsodium-wrappers";
17
- import { getSequence as m, resolveSync as c } from "../../functions/utils/resolve-sync.utils.js";
18
- import "../../constants/kyc.constants.js";
19
- import "../volatile-helper/VolatileHelper.js";
20
- import "../custom-token-registry/CustomTokenRegistry.js";
21
- import "../../constants/contracts.constants.js";
22
- import "../../constants/axelar.constants.js";
23
- import "../../constants/rewards.constants.js";
24
- import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
25
- import "../../functions/utils/userAgent.js";
26
- class M {
27
- contract;
28
- eventConfig;
29
- _latestBlockNumber;
30
- maxPageSize;
31
- isReady = !1;
32
- _onNewEvent;
33
- isServer;
34
- intervalId;
35
- inProgress;
36
- // to remove race conditions
37
- constructor(t, r, e, s, n) {
38
- this.contract = t, this.eventConfig = r, this._latestBlockNumber = e, this.maxPageSize = n, this.isServer = s, this.inProgress = !1;
39
- }
40
- get latestBlockNumber() {
41
- return this._latestBlockNumber;
42
- }
43
- set onNewEvent(t) {
44
- this._onNewEvent = t;
45
- }
46
- intervalClear() {
47
- this.isReady = !1, this._onNewEvent = void 0, clearInterval(this.intervalId);
48
- }
49
- async init() {
50
- if (this.isReady)
51
- throw new Error("Already initialized");
52
- this.isReady = !0, await this.retrieveEvents(this._latestBlockNumber + 1), this.intervalId = setInterval(async () => {
53
- await this.retrieveEvents(this.latestBlockNumber);
54
- }, 3500);
55
- }
56
- requireReady() {
57
- if (!this.isReady)
58
- throw new Error("Not ready");
59
- }
60
- emitNewEvent(t) {
61
- this._onNewEvent?.(t);
62
- }
63
- getLastBlockNumberForEventRequest = async () => {
64
- const t = await this.contract.provider.getBlockNumber();
65
- if (!this.isServer)
66
- return t;
67
- const { chainId: r } = await this.contract.provider.getNetwork();
68
- return Math.max(this.latestBlockNumber, t - v[r] + 1);
69
- };
70
- async retrieveEvents(t, r = !1) {
71
- try {
72
- if (this.requireReady(), this.inProgress && !r)
73
- return !1;
74
- this.inProgress = !0;
75
- const e = await this.getLastBlockNumberForEventRequest();
76
- if (e < t)
77
- return this.inProgress = !1, !1;
78
- const s = m(t, e, this.maxPageSize);
79
- return await c(
80
- s.map(({ from: n, to: i }) => async () => {
81
- const o = await this.contract.queryFilter(
82
- this.contract.filters[this.eventConfig.name](),
83
- n,
84
- i
85
- );
86
- let a = [];
87
- o.length > 0 && (a = await this.processEventsPage(o)), this._latestBlockNumber = i, await this.afterEventsAccepted(), a.length > 0 && this.emitNewEvent();
88
- })
89
- ), this.inProgress = !1, !0;
90
- } catch (e) {
91
- return console.log("retrieveEvents error:", { err: e }), this.inProgress = !1, !1;
92
- }
93
- }
94
- async processEventsPage(t) {
95
- const r = [];
96
- return await c(
97
- t.map((e) => async () => {
98
- const { args: s, blockNumber: n } = e;
99
- if (!s)
100
- throw new Error("Wrong event structure");
101
- const i = this.mapEvent(s);
102
- await this.acceptEvent(i, n) && r.push(i);
103
- })
104
- ), r;
105
- }
106
- handleEvent = async (...t) => {
107
- const { args: r } = this.eventConfig, { blockNumber: e } = t[t.length - 1], s = t.slice(0, r.length), n = r.reduce((a, h, l) => (a[h] = s[l], a), {});
108
- if (!e)
109
- throw new Error("Wrong event structure");
110
- const i = this.mapEvent(n);
111
- if (!await this.acceptEvent(i, e))
112
- throw new Error("Failed to retrieve events");
113
- this._latestBlockNumber = e, await this.afterEventsAccepted(), this.emitNewEvent(i);
114
- };
115
- }
116
- export {
117
- M as AbstractEventService
118
- };
@@ -1,59 +0,0 @@
1
- import { AbstractSnapshotService as i } from "./AbstractSnapshotService.js";
2
- class s extends i {
3
- constructor(e, r, l, t) {
4
- super(
5
- e,
6
- {
7
- name: "Nullified",
8
- args: ["nullifier"]
9
- },
10
- r,
11
- l,
12
- t
13
- );
14
- }
15
- _nullifiers;
16
- get nullifiers() {
17
- return this._nullifiers;
18
- }
19
- serializeSnapshot(e) {
20
- return {
21
- nullifiers: Array.from(e.payload.nullifiers).map((r) => r.toString()),
22
- latestBlockNumber: e.latestBlockNumber,
23
- reserveBlockNumber: e.reserveBlockNumber
24
- };
25
- }
26
- deserializeSnapshot(e) {
27
- return {
28
- latestBlockNumber: e.latestBlockNumber ?? 0,
29
- reserveBlockNumber: e.reserveBlockNumber ?? 0,
30
- payload: {
31
- nullifiers: new Set(e.nullifiers ?? [])
32
- }
33
- };
34
- }
35
- acceptEvent(e, r) {
36
- try {
37
- return this._nullifiers.add(e.nullifier), !0;
38
- } catch (l) {
39
- return console.error(l), !1;
40
- }
41
- }
42
- mapEvent(e) {
43
- const { nullifier: r } = e;
44
- return {
45
- nullifier: r.toHexString()
46
- };
47
- }
48
- getSnapshotPayload() {
49
- return {
50
- nullifiers: this._nullifiers
51
- };
52
- }
53
- populateSnapshot({ payload: { nullifiers: e } }) {
54
- this._nullifiers = e;
55
- }
56
- }
57
- export {
58
- s as AbstractNullifierSnapshotService
59
- };
@@ -1,35 +0,0 @@
1
- import { AbstractEventService as o } from "./AbstractEventService.js";
2
- class h extends o {
3
- reserveBlockNumber;
4
- constructor(t, e, s, r, a) {
5
- super(t, e, s, r, a), this.reserveBlockNumber = s;
6
- }
7
- async init() {
8
- await this.loadSnapshot(), await super.init();
9
- }
10
- async retrieveEventsFromLatestBlock() {
11
- await super.retrieveEvents(this._latestBlockNumber);
12
- }
13
- async restoreSnapshotState() {
14
- await this.retrieveEvents(this.reserveBlockNumber, !0) && (this.reserveBlockNumber = this.latestBlockNumber, await this.afterEventsAccepted());
15
- }
16
- async loadSnapshot() {
17
- const t = await this.fetchSnapshot(), e = this.deserializeSnapshot(t);
18
- this.populateSnapshot(e), this._latestBlockNumber = e.latestBlockNumber, this.reserveBlockNumber = e.reserveBlockNumber;
19
- }
20
- saveSnapshot() {
21
- return this.persistSnapshot(
22
- this.serializeSnapshot({
23
- latestBlockNumber: this._latestBlockNumber,
24
- reserveBlockNumber: this.reserveBlockNumber,
25
- payload: this.getSnapshotPayload()
26
- })
27
- );
28
- }
29
- afterEventsAccepted() {
30
- return this.saveSnapshot();
31
- }
32
- }
33
- export {
34
- h as AbstractSnapshotService
35
- };