@hinkal/common 0.2.9 → 0.2.11
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.
- package/API/API.d.mts +49 -0
- package/API/HinkalPointsCalls.d.mts +20 -0
- package/API/callBeefyGraphAPI.d.mts +2 -0
- package/API/callCurveAPI.d.mts +9 -0
- package/API/callMonitor.d.mts +1 -0
- package/API/callOdosAPI.d.mts +63 -0
- package/API/callOneInchAPI.d.mts +18 -0
- package/API/callRelayer.d.mts +10 -0
- package/API/checkRisk.d.mts +1 -0
- package/API/dataServerCalls.d.mts +2 -0
- package/API/duneAPI.d.mts +11 -0
- package/API/fetchCommitmentsCache.d.mts +20 -0
- package/API/fetchNullifiers.d.mts +5 -0
- package/API/getAxelarGasEstimate.d.mts +5 -0
- package/API/getCoingeckoPrice.d.mts +22 -0
- package/API/getConnextReceiveFee.d.mts +2 -0
- package/API/getGasEstimates.d.mts +9 -0
- package/API/getRelayerURL.d.mts +1 -0
- package/API/getServerURL.d.mts +2 -0
- package/API/getTokenPrice.d.mts +16 -0
- package/API/index.d.mts +14 -0
- package/API/kycCalls.d.mts +30 -0
- package/API/passwordCalls.d.mts +9 -0
- package/API/referralProgramCalls.d.mts +36 -0
- package/API/relayCalls.d.mts +5 -0
- package/API/restoreSnapshots.d.mts +1 -0
- package/API/rewardsPointsCalls.d.mts +13 -0
- package/API/userVerifyTransactions.d.mts +19 -0
- package/constants/assets.constants.d.mts +13 -0
- package/constants/axelar.constants.d.mts +5 -0
- package/constants/backend.constants.d.mts +11 -0
- package/constants/beefy.registry.d.mts +8 -0
- package/constants/chains.constants.d.mts +36 -0
- package/constants/coingecko.constants.d.mts +13 -0
- package/constants/contracts.constants.d.mts +119 -0
- package/constants/crvCvx.registry.d.mts +20 -0
- package/constants/crvDynamic.registry.d.mts +1 -0
- package/constants/deploy-data/index.d.mts +11 -0
- package/constants/fees.constants.d.mts +11 -0
- package/constants/index.d.mts +20 -0
- package/constants/kyc.constants.d.mts +28 -0
- package/constants/lido.constants.d.mts +10 -0
- package/constants/pendle.registry.d.mts +21 -0
- package/constants/protocol.constants.d.mts +18 -0
- package/constants/reorg-depths.constants.d.mts +3 -0
- package/constants/rewards.constants.d.mts +19 -0
- package/constants/server.constants.d.mts +155 -0
- package/constants/token-data/ERC20Registry.d.mts +3 -0
- package/constants/token-data/index.d.mts +976 -0
- package/constants/token-data/popularTokens.constants.d.mts +3 -0
- package/constants/token-data/tokenPricing.consts.d.mts +5 -0
- package/constants/vite.constants.d.mts +14 -0
- package/crypto/babyJub.d.mts +16 -0
- package/crypto/index.d.mts +3 -0
- package/crypto/poseidon.d.mts +15 -0
- package/crypto/preProcessing.d.mts +1 -0
- package/data-structures/Hinkal/Hinkal.d.mts +100 -0
- package/data-structures/Hinkal/IHinkal.d.mts +93 -0
- package/data-structures/Hinkal/hinkalActionBeefy.d.mts +3 -0
- package/data-structures/Hinkal/hinkalActionConvex.d.mts +12 -0
- package/data-structures/Hinkal/hinkalActionCurve.d.mts +12 -0
- package/data-structures/Hinkal/hinkalActionLidoEth.d.mts +4 -0
- package/data-structures/Hinkal/hinkalActionPendle.d.mts +3 -0
- package/data-structures/Hinkal/hinkalActionPendleLP.d.mts +7 -0
- package/data-structures/Hinkal/hinkalActionStake.d.mts +3 -0
- package/data-structures/Hinkal/hinkalActionVolatile.d.mts +3 -0
- package/data-structures/Hinkal/hinkalDeposit.d.mts +3 -0
- package/data-structures/Hinkal/hinkalGetRecipientInfo.d.mts +2 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.d.mts +3 -0
- package/data-structures/Hinkal/hinkalPrivateWallet.d.mts +2 -0
- package/data-structures/Hinkal/hinkalSwap.d.mts +3 -0
- package/data-structures/Hinkal/hinkalTransfer.d.mts +1 -0
- package/data-structures/Hinkal/hinkalWithdraw.d.mts +2 -0
- package/data-structures/Hinkal/index.d.mts +12 -0
- package/data-structures/Hinkal/resetMerkleTrees.d.mts +2 -0
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.d.mts +20 -0
- package/data-structures/ValueCache/ValueCache.d.mts +10 -0
- package/data-structures/ValueCache/index.d.mts +1 -0
- package/data-structures/cacheDevices/BaseCacheDevice.d.mts +8 -0
- package/data-structures/cacheDevices/FileCacheDevice.d.mts +9 -0
- package/data-structures/cacheDevices/LocalStorageCacheDevice.d.mts +7 -0
- package/data-structures/cacheDevices/index.d.mts +2 -0
- package/data-structures/crypto-keys/decodeUTXO.d.mts +14 -0
- package/data-structures/crypto-keys/encryptDecryptUtxo.d.mts +18 -0
- package/data-structures/crypto-keys/index.d.mts +4 -0
- package/data-structures/crypto-keys/keyUtils.d.mts +2 -0
- package/data-structures/crypto-keys/keys.d.mts +58 -0
- package/data-structures/custom-token-registry/CustomTokenRegistry.d.mts +13 -0
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.d.mts +35 -0
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.d.mts +30 -0
- package/data-structures/event-service/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/AbstractEventService.d.mts +31 -0
- package/data-structures/event-service/AbstractEventService.mjs +42 -30
- package/data-structures/event-service/AbstractNullifierSnapshotService.d.mts +22 -0
- package/data-structures/event-service/AbstractSnapshotService.d.mts +23 -0
- package/data-structures/event-service/index.d.mts +5 -0
- package/data-structures/index.d.mts +13 -0
- package/data-structures/merkle-tree/MerkleTree.d.mts +78 -0
- package/data-structures/merkle-tree/MerkleTreeIncompleteError.d.mts +3 -0
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.mts +3 -0
- package/data-structures/merkle-tree/index.d.mts +3 -0
- package/data-structures/provider-adapter/IProviderAdapter.d.mts +35 -0
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.d.mts +7 -0
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +10 -5
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.d.mts +7 -0
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +10 -5
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.d.mts +7 -0
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +8 -3
- package/data-structures/token-price-fetcher/TokenChecker.d.mts +20 -0
- package/data-structures/token-price-fetcher/index.d.mts +1 -0
- package/data-structures/transactions-manager/TransactionsManager.d.mts +27 -0
- package/data-structures/transactions-manager/history/getBeefyData.d.mts +3 -0
- package/data-structures/transactions-manager/history/getConvexData.d.mts +6 -0
- package/data-structures/transactions-manager/history/getCurveData.d.mts +6 -0
- package/data-structures/transactions-manager/history/getDepositData.d.mts +2 -0
- package/data-structures/transactions-manager/history/getLidoData.d.mts +10 -0
- package/data-structures/transactions-manager/history/getPendleData.d.mts +3 -0
- package/data-structures/transactions-manager/history/getSwapData.d.mts +3 -0
- package/data-structures/transactions-manager/history/getTxDetails.d.mts +3 -0
- package/data-structures/transactions-manager/history/getVolatileData.d.mts +32 -0
- package/data-structures/transactions-manager/history/history.types.d.mts +95 -0
- package/data-structures/transactions-manager/history/history.utils.d.mts +8 -0
- package/data-structures/transactions-manager/index.d.mts +2 -0
- package/data-structures/utxo/Utxo.d.mts +63 -0
- package/data-structures/volatile-helper/VolatileHelper.d.mts +57 -0
- package/data-structures/volatile-helper/index.d.mts +1 -0
- package/error-handling/customErrors/ErrorWithAmount.d.mts +4 -0
- package/error-handling/customErrors/FeeOverTransactionValueError.d.mts +9 -0
- package/error-handling/customErrors/customErrors.helpers.d.mts +5 -0
- package/error-handling/customErrors/index.d.mts +3 -0
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.mts +181 -0
- package/error-handling/error-codes.constants.mjs +13 -13
- package/error-handling/get-error.message.d.mts +3 -0
- package/error-handling/handleErrorRestore.d.mts +2 -0
- package/error-handling/index.d.mts +7 -0
- package/error-handling/logError.d.mts +1 -0
- package/error-handling/types.d.mts +5 -0
- package/externalABIs/BUSD.d.mts +38 -0
- package/externalABIs/DAI.d.mts +45 -0
- package/externalABIs/ERC20.d.mts +1 -0
- package/externalABIs/SanctionsList.d.mts +35 -0
- package/externalABIs/USDC.d.mts +28 -0
- package/externalABIs/USDR.d.mts +28 -0
- package/externalABIs/USDR3CRV.d.mts +49 -0
- package/externalABIs/USDT.d.mts +41 -0
- package/externalABIs/WETH.d.mts +38 -0
- package/externalABIs/amToken.d.mts +28 -0
- package/externalABIs/crvFRAX.d.mts +38 -0
- package/externalABIs/index.d.mts +323 -0
- package/externalABIs/swapAbi.d.mts +77 -0
- package/functions/index.d.mts +14 -0
- package/functions/kyc/aiPriseHelper.d.mts +0 -0
- package/functions/kyc/authentoHelper.d.mts +12 -0
- package/functions/kyc/index.d.mts +3 -0
- package/functions/kyc/openDefaultPassportWindow.d.mts +1 -0
- package/functions/kyc/passportHelper.d.mts +3 -0
- package/functions/kyc/zkMeHelper.d.mts +4 -0
- package/functions/pre-transaction/getFlatFees.d.mts +12 -0
- package/functions/pre-transaction/index.d.mts +5 -0
- package/functions/pre-transaction/interaction-to-action.d.mts +2 -0
- package/functions/pre-transaction/outputUtxoProcessing.d.mts +5 -0
- package/functions/pre-transaction/process-gas-estimates.d.mts +5 -0
- package/functions/pre-transaction/processAmountChanges.d.mts +12 -0
- package/functions/private-wallet/emporium.helpers.d.mts +5 -0
- package/functions/private-wallet/index.d.mts +2 -0
- package/functions/private-wallet/opProducer.d.mts +5 -0
- package/functions/protocols/convex.protocols.d.mts +1 -0
- package/functions/protocols/curve.protocols.d.mts +1 -0
- package/functions/protocols/index.d.mts +3 -0
- package/functions/protocols/pendle.helpers.d.mts +8 -0
- package/functions/snarkjs/common.snarkjs.d.mts +22 -0
- package/functions/snarkjs/constant.d.mts +151 -0
- package/functions/snarkjs/constructEmporiumProof.d.mts +10 -0
- package/functions/snarkjs/constructGeneralZkProof.d.mts +12 -0
- package/functions/snarkjs/generateCircomData.d.mts +4 -0
- package/functions/snarkjs/generateZkProof.d.mts +5 -0
- package/functions/snarkjs/generateZkProofEnclave.d.mts +5 -0
- package/functions/snarkjs/generateZkProofSelf.d.mts +5 -0
- package/functions/snarkjs/getZKFiles.d.mts +2 -0
- package/functions/snarkjs/index.d.mts +4 -0
- package/functions/staking/index.d.mts +11 -0
- package/functions/utils/amounts.utils.d.mts +21 -0
- package/functions/utils/axelar.utils.d.mts +2 -0
- package/functions/utils/cacheDevice.utils.d.mts +3 -0
- package/functions/utils/cacheFunctions.d.mts +17 -0
- package/functions/utils/caseInsensitive.utils.d.mts +3 -0
- package/functions/utils/convertIntegrationProviderToExternalActionId.d.mts +2 -0
- package/functions/utils/create-provider.d.mts +2 -0
- package/functions/utils/enum.utils.d.mts +9 -0
- package/functions/utils/erc20tokenFunctions.d.mts +4 -0
- package/functions/utils/evmNetworkFunctions.d.mts +4 -0
- package/functions/utils/external-action.utils.d.mts +8 -0
- package/functions/utils/getDataFromTransaction.d.mts +45 -0
- package/functions/utils/index.d.mts +21 -0
- package/functions/utils/memoize.utils.d.mts +1 -0
- package/functions/utils/nickname.utils.d.mts +1 -0
- package/functions/utils/process.utils.d.mts +7 -0
- package/functions/utils/reloadPage.d.mts +1 -0
- package/functions/utils/requireEnv.d.mts +1 -0
- package/functions/utils/resolve-sync.utils.d.mts +6 -0
- package/functions/utils/serialize.utils.d.mts +1 -0
- package/functions/utils/string.utils.d.mts +8 -0
- package/functions/utils/time.utils.d.mts +1 -0
- package/functions/utils/userAgent.d.mts +2 -0
- package/functions/utils/volatile-patcher.utils.d.mts +1 -0
- package/functions/web3/etherFunctions.d.mts +20 -0
- package/functions/web3/events/balanceChangedHandler.d.mts +1 -0
- package/functions/web3/events/getInputUtxoAndBalance.d.mts +24 -0
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.mts +18 -0
- package/functions/web3/events/getShieldedBalance.mjs +66 -58
- package/functions/web3/events/index.d.mts +4 -0
- package/functions/web3/events/web3RetrieveEvents.d.mts +14 -0
- package/functions/web3/functionCalls/accessTokenCalls.d.mts +6 -0
- package/functions/web3/functionCalls/approveToken.d.mts +4 -0
- package/functions/web3/functionCalls/estimateGasRelayer.d.mts +4 -0
- package/functions/web3/functionCalls/getRootHash.d.mts +2 -0
- package/functions/web3/functionCalls/relayFunctions.d.mts +17 -0
- package/functions/web3/functionCalls/transactCallDirect.d.mts +6 -0
- package/functions/web3/functionCalls/transactCallRelayer.d.mts +7 -0
- package/functions/web3/getContractMetadata.d.mts +5 -0
- package/functions/web3/index.d.mts +6 -0
- package/functions/web3/odosAPI.d.mts +5 -0
- package/functions/web3/oneInchAPI.d.mts +5 -0
- package/functions/web3/runContractFunction.d.mts +15 -0
- package/functions/web3/uniswapAPI.d.mts +16 -0
- package/index.d.mts +8 -0
- package/package.json +42 -11
- package/providers/EthersProviderAdapter.d.mts +39 -0
- package/providers/WagmiProviderAdapter.d.mts +46 -0
- package/providers/exportProviers.d.mts +3 -0
- package/providers/prepareEthersHinkal.d.mts +4 -0
- package/providers/prepareWagmiHinkal.d.mts +3 -0
- package/types/API.types.d.mts +23 -0
- package/types/ICacheDevice.d.mts +4 -0
- package/types/IMultiThreadedUtxoUtils.d.mts +8 -0
- package/types/admin.types.d.mts +22 -0
- package/types/axelar.types.d.mts +14 -0
- package/types/beefy.types.d.mts +11 -0
- package/types/big-intable.types.d.mts +2 -0
- package/types/circom-data.types.d.mts +70 -0
- package/types/coingecko.types.d.mts +8 -0
- package/types/commitments.types.d.mts +26 -0
- package/types/connext.types.d.mts +13 -0
- package/types/crypto.types.d.mts +7 -0
- package/types/curve.types.d.mts +133 -0
- package/types/duneAPI.types.d.mts +9 -0
- package/types/ethereum-network.types.d.mts +142 -0
- package/types/external-action.types.d.mts +28 -0
- package/types/hinkal.stake.types.d.mts +11 -0
- package/types/hinkal.types.d.mts +150 -0
- package/types/hinkalTvl.types.d.mts +4 -0
- package/types/index.d.mts +27 -0
- package/types/kyc.types.d.mts +39 -0
- package/types/pendle.api.types.d.mts +233 -0
- package/types/pendle.types.d.mts +222 -0
- package/types/relayer.types.d.mts +25 -0
- package/types/remote-proof.types.d.mts +15 -0
- package/types/rewards.types.d.mts +230 -0
- package/types/slippage.types.d.mts +15 -0
- package/types/snark.types.d.mts +40 -0
- package/types/time.types.d.mts +31 -0
- package/types/token.types.d.mts +36 -0
- package/types/transactions.types.d.mts +55 -0
- package/webworker/performTaskWithWorker.d.mts +5 -0
- package/webworker/snarkjsWorker/snarkjsWorker.types.d.mts +14 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.d.mts +1 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.d.mts +10 -0
- package/webworker/utxoWorker/utxoWorker.types.d.mts +29 -0
- package/webworker/utxoWorker/utxoWorkerLauncher.d.mts +1 -0
- package/webworker/utxoWorker/utxoWorkerLogic.d.mts +8 -0
- package/webworker/viteWorkerURL.constant.d.mts +9 -0
- package/webworker/worker.registry.d.mts +10 -0
- package/webworker/worker.types.d.mts +33 -0
- package/webworker/workerErrorHandler.d.mts +1 -0
- package/webworker/workerFactory.d.mts +7 -0
- package/webworker/workerProxy.d.mts +40 -0
- package/webworker/zkProofWorker/zkProofWorker.types.d.mts +38 -0
- package/webworker/zkProofWorker/zkProofWorkerLauncher.d.mts +1 -0
- package/webworker/zkProofWorker/zkProofWorkerLogic.d.mts +8 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { MerkleTree, MerkleTreeJson } from '../merkle-tree';
|
|
3
|
+
import { CommitmentEvent, EncryptedOutputWithSign } from '../../types';
|
|
4
|
+
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
5
|
+
export type CommitmentsSnapshotPayload = {
|
|
6
|
+
readonly merkleTree: MerkleTree<bigint>;
|
|
7
|
+
readonly encryptedOutputs: EncryptedOutputWithSign[];
|
|
8
|
+
};
|
|
9
|
+
export type CommitmentsSerializedSnapshot = {
|
|
10
|
+
latestBlockNumber?: number;
|
|
11
|
+
reserveBlockNumber?: number;
|
|
12
|
+
merkleTree?: MerkleTreeJson;
|
|
13
|
+
encryptedOutputs?: EncryptedOutputWithSign<string>[];
|
|
14
|
+
};
|
|
15
|
+
export declare abstract class AbstractCommitmentsSnapshotService extends AbstractSnapshotService<CommitmentEvent<bigint>, CommitmentEvent, CommitmentsSnapshotPayload, CommitmentsSerializedSnapshot> {
|
|
16
|
+
constructor(contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, maxPageSize?: number);
|
|
17
|
+
private _merkleTree;
|
|
18
|
+
private _encryptedOutputs;
|
|
19
|
+
get merkleTree(): MerkleTree<bigint>;
|
|
20
|
+
get encryptedOutputs(): EncryptedOutputWithSign<boolean>[];
|
|
21
|
+
protected serializeSnapshot(snapshot: Snapshot<CommitmentsSnapshotPayload>): CommitmentsSerializedSnapshot;
|
|
22
|
+
protected deserializeSnapshot(serializedSnapshot: CommitmentsSerializedSnapshot): Snapshot<CommitmentsSnapshotPayload>;
|
|
23
|
+
protected getSnapshotPayload(): {
|
|
24
|
+
merkleTree: MerkleTree<bigint>;
|
|
25
|
+
encryptedOutputs: EncryptedOutputWithSign<boolean>[];
|
|
26
|
+
};
|
|
27
|
+
protected populateSnapshot({ payload: { merkleTree, encryptedOutputs }, }: Snapshot<CommitmentsSnapshotPayload>): void;
|
|
28
|
+
protected mapEvent(event: CommitmentEvent): CommitmentEvent<bigint>;
|
|
29
|
+
protected acceptEvent(event: CommitmentEvent<bigint>, _blockNumber: number): boolean;
|
|
30
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../constants/reorg-depths.constants.cjs"),o=require("../../functions/utils/resolve-sync.utils.cjs");require("ethers");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const v=require("../../error-handling/logError.cjs");class g{contract;eventConfig;_latestBlockNumber;maxPageSize;isReady=!1;_onNewEvent;isServer;intervalId;inProgress;constructor(e,r,t,s,n){this.contract=e,this.eventConfig=r,this._latestBlockNumber=t,this.maxPageSize=n,this.isServer=s,this.inProgress=!1}get latestBlockNumber(){return this._latestBlockNumber}set onNewEvent(e){this._onNewEvent=e}intervalClear(){this.isReady=!1,this._onNewEvent=void 0,clearInterval(this.intervalId)}async init(){if(this.isReady)throw new Error("Already initialized");this.isReady=!0,await this.retrieveEvents(this._latestBlockNumber+1),this.intervalId=setInterval(async()=>{await this.retrieveEvents(this.latestBlockNumber)},3500)}requireReady(){if(!this.isReady)throw new Error("Not ready")}emitNewEvent(e){this._onNewEvent?.(e)}getLastBlockNumberForEventRequest=async()=>{const e=await this.contract.provider.getBlockNumber();if(!this.isServer)return e;const{chainId:r}=await this.contract.provider.getNetwork();return Math.max(this.latestBlockNumber,e-u.blockReorgDepth[r]+1)};async retrieveEvents(e,r=!1){try{if(this.requireReady(),this.inProgress&&!r)return!1;this.inProgress=!0;const t=await this.getLastBlockNumberForEventRequest();if(t<e)return this.inProgress=!1,!1;const s=o.getSequence(e,t,this.maxPageSize);return await o.resolveSync(s.map(({from:n,to:i})=>async()=>{const c=await this.contract.queryFilter(this.contract.filters[this.eventConfig.name](),n,i);let a=[];c.length>0&&(a=await this.processEventsPage(c)),this._latestBlockNumber=i,await this.afterEventsAccepted(),a.length>0&&this.emitNewEvent()})),this.inProgress=!1,!0}catch(t){return v.logError("retrieveEvents error:",{err:t}),this.inProgress=!1,!1}}async processEventsPage(e){const r=[];return await o.resolveSync(e.map(t=>async()=>{const{args:s,blockNumber:n}=t;if(!s)throw new Error("Wrong event structure");const i=this.mapEvent(s);await this.acceptEvent(i,n)&&r.push(i)})),r}handleEvent=async(...e)=>{const{args:r}=this.eventConfig,{blockNumber:t}=e[e.length-1],s=e.slice(0,r.length),n=r.reduce((a,l,h)=>(a[l]=s[h],a),{});if(!t)throw new Error("Wrong event structure");const i=this.mapEvent(n);if(!await this.acceptEvent(i,t))throw new Error("Failed to retrieve events");this._latestBlockNumber=t,await this.afterEventsAccepted(),this.emitNewEvent(i)}}exports.AbstractEventService=g;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
export type NewEventListener<E> = (event?: E) => unknown;
|
|
3
|
+
export interface EventConfig {
|
|
4
|
+
name: string;
|
|
5
|
+
args: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class AbstractEventService<EventType, SerializedEventType = unknown> {
|
|
8
|
+
protected readonly contract: ethers.Contract;
|
|
9
|
+
protected readonly eventConfig: EventConfig;
|
|
10
|
+
protected _latestBlockNumber: number;
|
|
11
|
+
private readonly maxPageSize?;
|
|
12
|
+
private isReady;
|
|
13
|
+
private _onNewEvent?;
|
|
14
|
+
protected isServer: boolean;
|
|
15
|
+
protected intervalId?: any;
|
|
16
|
+
protected inProgress: boolean;
|
|
17
|
+
protected constructor(contract: ethers.Contract, eventConfig: EventConfig, initialBlockNumber: number, isServer: boolean, maxPageSize?: number);
|
|
18
|
+
get latestBlockNumber(): number;
|
|
19
|
+
set onNewEvent(value: NewEventListener<EventType>);
|
|
20
|
+
intervalClear(): void;
|
|
21
|
+
init(): Promise<void>;
|
|
22
|
+
protected requireReady(): void;
|
|
23
|
+
protected emitNewEvent(event?: EventType): void;
|
|
24
|
+
private getLastBlockNumberForEventRequest;
|
|
25
|
+
protected retrieveEvents(fromBlockNumber: number, useForce?: boolean): Promise<boolean>;
|
|
26
|
+
private processEventsPage;
|
|
27
|
+
protected handleEvent: (...args: unknown[]) => Promise<void>;
|
|
28
|
+
protected abstract acceptEvent(event: EventType, blockNumber: number): boolean | Promise<boolean>;
|
|
29
|
+
protected abstract mapEvent(event: SerializedEventType): EventType;
|
|
30
|
+
protected abstract afterEventsAccepted(): Promise<unknown>;
|
|
31
|
+
}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { blockReorgDepth as v } from "../../constants/reorg-depths.constants.mjs";
|
|
2
|
-
import { getSequence as
|
|
3
|
-
|
|
2
|
+
import { getSequence as m, resolveSync as c } from "../../functions/utils/resolve-sync.utils.mjs";
|
|
3
|
+
import "ethers";
|
|
4
|
+
import "axios";
|
|
5
|
+
import "../../constants/chains.constants.mjs";
|
|
6
|
+
import "../../constants/vite.constants.mjs";
|
|
7
|
+
import "../../types/circom-data.types.mjs";
|
|
8
|
+
import "../../types/transactions.types.mjs";
|
|
9
|
+
import "../../types/curve.types.mjs";
|
|
10
|
+
import "circomlibjs-hinkal-fork";
|
|
11
|
+
import "libsodium-wrappers";
|
|
12
|
+
import "process";
|
|
13
|
+
import "buffer";
|
|
14
|
+
import { logError as u } from "../../error-handling/logError.mjs";
|
|
15
|
+
class q {
|
|
4
16
|
contract;
|
|
5
17
|
eventConfig;
|
|
6
18
|
_latestBlockNumber;
|
|
@@ -11,8 +23,8 @@ class g {
|
|
|
11
23
|
intervalId;
|
|
12
24
|
inProgress;
|
|
13
25
|
// to remove race conditions
|
|
14
|
-
constructor(e, t, s,
|
|
15
|
-
this.contract = e, this.eventConfig =
|
|
26
|
+
constructor(e, r, t, s, n) {
|
|
27
|
+
this.contract = e, this.eventConfig = r, this._latestBlockNumber = t, this.maxPageSize = n, this.isServer = s, this.inProgress = !1;
|
|
16
28
|
}
|
|
17
29
|
get latestBlockNumber() {
|
|
18
30
|
return this._latestBlockNumber;
|
|
@@ -41,55 +53,55 @@ class g {
|
|
|
41
53
|
const e = await this.contract.provider.getBlockNumber();
|
|
42
54
|
if (!this.isServer)
|
|
43
55
|
return e;
|
|
44
|
-
const { chainId:
|
|
45
|
-
return Math.max(this.latestBlockNumber, e - v[
|
|
56
|
+
const { chainId: r } = await this.contract.provider.getNetwork();
|
|
57
|
+
return Math.max(this.latestBlockNumber, e - v[r] + 1);
|
|
46
58
|
};
|
|
47
|
-
async retrieveEvents(e,
|
|
59
|
+
async retrieveEvents(e, r = !1) {
|
|
48
60
|
try {
|
|
49
|
-
if (this.requireReady(), this.inProgress && !
|
|
61
|
+
if (this.requireReady(), this.inProgress && !r)
|
|
50
62
|
return !1;
|
|
51
63
|
this.inProgress = !0;
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
64
|
+
const t = await this.getLastBlockNumberForEventRequest();
|
|
65
|
+
if (t < e)
|
|
54
66
|
return this.inProgress = !1, !1;
|
|
55
|
-
const
|
|
56
|
-
return await
|
|
57
|
-
|
|
58
|
-
const
|
|
67
|
+
const s = m(e, t, this.maxPageSize);
|
|
68
|
+
return await c(
|
|
69
|
+
s.map(({ from: n, to: i }) => async () => {
|
|
70
|
+
const o = await this.contract.queryFilter(
|
|
59
71
|
this.contract.filters[this.eventConfig.name](),
|
|
60
72
|
n,
|
|
61
73
|
i
|
|
62
74
|
);
|
|
63
75
|
let a = [];
|
|
64
|
-
|
|
76
|
+
o.length > 0 && (a = await this.processEventsPage(o)), this._latestBlockNumber = i, await this.afterEventsAccepted(), a.length > 0 && this.emitNewEvent();
|
|
65
77
|
})
|
|
66
78
|
), this.inProgress = !1, !0;
|
|
67
|
-
} catch {
|
|
68
|
-
return this.inProgress = !1, !1;
|
|
79
|
+
} catch (t) {
|
|
80
|
+
return u("retrieveEvents error:", { err: t }), this.inProgress = !1, !1;
|
|
69
81
|
}
|
|
70
82
|
}
|
|
71
83
|
async processEventsPage(e) {
|
|
72
|
-
const
|
|
73
|
-
return await
|
|
74
|
-
e.map((
|
|
75
|
-
const { args:
|
|
76
|
-
if (!
|
|
84
|
+
const r = [];
|
|
85
|
+
return await c(
|
|
86
|
+
e.map((t) => async () => {
|
|
87
|
+
const { args: s, blockNumber: n } = t;
|
|
88
|
+
if (!s)
|
|
77
89
|
throw new Error("Wrong event structure");
|
|
78
|
-
const i = this.mapEvent(
|
|
79
|
-
await this.acceptEvent(i, n) &&
|
|
90
|
+
const i = this.mapEvent(s);
|
|
91
|
+
await this.acceptEvent(i, n) && r.push(i);
|
|
80
92
|
})
|
|
81
|
-
),
|
|
93
|
+
), r;
|
|
82
94
|
}
|
|
83
95
|
handleEvent = async (...e) => {
|
|
84
|
-
const { args:
|
|
85
|
-
if (!
|
|
96
|
+
const { args: r } = this.eventConfig, { blockNumber: t } = e[e.length - 1], s = e.slice(0, r.length), n = r.reduce((a, h, l) => (a[h] = s[l], a), {});
|
|
97
|
+
if (!t)
|
|
86
98
|
throw new Error("Wrong event structure");
|
|
87
99
|
const i = this.mapEvent(n);
|
|
88
|
-
if (!await this.acceptEvent(i,
|
|
100
|
+
if (!await this.acceptEvent(i, t))
|
|
89
101
|
throw new Error("Failed to retrieve events");
|
|
90
|
-
this._latestBlockNumber =
|
|
102
|
+
this._latestBlockNumber = t, await this.afterEventsAccepted(), this.emitNewEvent(i);
|
|
91
103
|
};
|
|
92
104
|
}
|
|
93
105
|
export {
|
|
94
|
-
|
|
106
|
+
q as AbstractEventService
|
|
95
107
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BigNumber, ethers } from 'ethers';
|
|
2
|
+
import { NullifierEvent } from '../../types/commitments.types';
|
|
3
|
+
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
4
|
+
export type NullifierSnapshotPayload = {
|
|
5
|
+
readonly nullifiers: Set<string>;
|
|
6
|
+
};
|
|
7
|
+
export type NullifierSerializedSnapshot = {
|
|
8
|
+
latestBlockNumber?: number;
|
|
9
|
+
reserveBlockNumber?: number;
|
|
10
|
+
nullifiers?: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare abstract class AbstractNullifierSnapshotService extends AbstractSnapshotService<NullifierEvent<string>, NullifierEvent<BigNumber>, NullifierSnapshotPayload, NullifierSerializedSnapshot> {
|
|
13
|
+
constructor(contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, maxPageSize?: number);
|
|
14
|
+
private _nullifiers;
|
|
15
|
+
get nullifiers(): Set<string>;
|
|
16
|
+
protected serializeSnapshot(snapshot: Snapshot<NullifierSnapshotPayload>): NullifierSerializedSnapshot;
|
|
17
|
+
protected deserializeSnapshot(serializedSnapshot: NullifierSerializedSnapshot): Snapshot<NullifierSnapshotPayload>;
|
|
18
|
+
protected acceptEvent(event: NullifierEvent<string>, _blockNumber: number): boolean;
|
|
19
|
+
protected mapEvent(event: NullifierEvent<BigNumber>): NullifierEvent<string>;
|
|
20
|
+
protected getSnapshotPayload(): NullifierSnapshotPayload;
|
|
21
|
+
protected populateSnapshot({ payload: { nullifiers } }: Snapshot<NullifierSnapshotPayload>): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { AbstractEventService, EventConfig } from './AbstractEventService';
|
|
3
|
+
export interface Snapshot<SnapshotPayloadType> {
|
|
4
|
+
readonly latestBlockNumber: number;
|
|
5
|
+
readonly reserveBlockNumber: number;
|
|
6
|
+
readonly payload: SnapshotPayloadType;
|
|
7
|
+
}
|
|
8
|
+
export declare abstract class AbstractSnapshotService<EventType, SerializedEventType, SnapshotPayloadType, SerializedSnapshotType> extends AbstractEventService<EventType, SerializedEventType> {
|
|
9
|
+
protected reserveBlockNumber: number;
|
|
10
|
+
protected constructor(contract: ethers.Contract, eventConfig: EventConfig, initialBlockNumber: number, isServer: boolean, maxPageSize?: number);
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
retrieveEventsFromLatestBlock(): Promise<void>;
|
|
13
|
+
restoreSnapshotState(): Promise<void>;
|
|
14
|
+
private loadSnapshot;
|
|
15
|
+
protected saveSnapshot(): Promise<unknown>;
|
|
16
|
+
protected afterEventsAccepted(): Promise<unknown>;
|
|
17
|
+
protected abstract getSnapshotPayload(): SnapshotPayloadType;
|
|
18
|
+
protected abstract populateSnapshot(snapshot: Snapshot<SnapshotPayloadType>): void;
|
|
19
|
+
protected abstract serializeSnapshot(snapshot: Snapshot<SnapshotPayloadType>): SerializedSnapshotType;
|
|
20
|
+
protected abstract deserializeSnapshot(serializedSnapshot: SerializedSnapshotType): Snapshot<SnapshotPayloadType>;
|
|
21
|
+
protected abstract fetchSnapshot(): Promise<SerializedSnapshotType>;
|
|
22
|
+
protected abstract persistSnapshot(serializedSnapshot: SerializedSnapshotType): Promise<unknown>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './ValueCache';
|
|
2
|
+
export * from './crypto-keys';
|
|
3
|
+
export * from './Hinkal';
|
|
4
|
+
export * from './merkle-tree';
|
|
5
|
+
export * from './provider-adapter/IProviderAdapter';
|
|
6
|
+
export * from './event-service';
|
|
7
|
+
export * from './utxo/Utxo';
|
|
8
|
+
export * from './custom-token-registry/CustomTokenRegistry';
|
|
9
|
+
export * from './token-price-fetcher';
|
|
10
|
+
export * from './transactions-manager';
|
|
11
|
+
export * from './volatile-helper';
|
|
12
|
+
export * from './MultiThreadedUtxoUtils/MultiThreadedUtxoUtils';
|
|
13
|
+
export * from './cacheDevices';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export type MerkleTreeJson = {
|
|
2
|
+
tree: Record<string, string>;
|
|
3
|
+
count: string;
|
|
4
|
+
index: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Merkle tree implementation that allows the user to insert in specific places in the tree
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare class MerkleTree<T> {
|
|
11
|
+
private hashFunction;
|
|
12
|
+
private levels;
|
|
13
|
+
private defaultNodeValue;
|
|
14
|
+
/**
|
|
15
|
+
* the map where the items are stored
|
|
16
|
+
*/
|
|
17
|
+
private readonly tree;
|
|
18
|
+
/**
|
|
19
|
+
* amount of elements inserted inside the bottom row of the tree
|
|
20
|
+
*/
|
|
21
|
+
private count;
|
|
22
|
+
/**
|
|
23
|
+
* the maximum index inserted into the tree
|
|
24
|
+
* used together with count to make sure that the merkle tree is complete.
|
|
25
|
+
* meaning that there aren't any missing elements between getStartIndex() and index
|
|
26
|
+
*/
|
|
27
|
+
private index;
|
|
28
|
+
static createWithData<T>(tree: Map<bigint, T>, index: bigint, count: bigint, hashFunction: (a: T, b: T) => T, levels: bigint, defaultNodeValue: T): MerkleTree<T>;
|
|
29
|
+
/**
|
|
30
|
+
* @param hashFunction the hashFunction used to fill the upper layers of the merkle tree
|
|
31
|
+
* @param levels the amount of layers in the merkle tree
|
|
32
|
+
* @param defaultNodeValue the default value of an empty node in the merkle tree
|
|
33
|
+
*/
|
|
34
|
+
static create<T>(hashFunction: (a: T, b: T) => T, levels: bigint, defaultNodeValue: T): MerkleTree<T>;
|
|
35
|
+
private constructor();
|
|
36
|
+
/**
|
|
37
|
+
* get starting nodeIndex from which inserts are allowed
|
|
38
|
+
*/
|
|
39
|
+
getStartIndex(): bigint;
|
|
40
|
+
/**
|
|
41
|
+
* implementation of logarithm2 function from merkle contract
|
|
42
|
+
*/
|
|
43
|
+
logarithm2(a: bigint): bigint;
|
|
44
|
+
bigIntMax(a: bigint, b: bigint): bigint;
|
|
45
|
+
private forceInsert;
|
|
46
|
+
/**
|
|
47
|
+
* insert value into the merkle tree
|
|
48
|
+
* @param value the value to insert
|
|
49
|
+
* @param nodeIndex the index to insert the value, you can get starting index from getStartIndex()
|
|
50
|
+
* @return true - if added, false - if already exists
|
|
51
|
+
* @throws will throw RangeError if nodeIndex is less than getStartIndex()
|
|
52
|
+
*/
|
|
53
|
+
insert(value: T, nodeIndex: bigint): boolean;
|
|
54
|
+
remove(nodeIndex: bigint): void;
|
|
55
|
+
private completenessCheck;
|
|
56
|
+
/**
|
|
57
|
+
* get root hash of the merkle tree
|
|
58
|
+
* @returns the hash, if the merkle tree is empty, will return
|
|
59
|
+
* @throws will throw MerkleTreeIncompleteError if there are missing elements in the tree
|
|
60
|
+
*/
|
|
61
|
+
getRootHash(): T | undefined;
|
|
62
|
+
getMerkleData(): Map<bigint, T>;
|
|
63
|
+
getSiblingIndex(index: bigint): bigint;
|
|
64
|
+
/**
|
|
65
|
+
* get sibling hashes needed by main.circom
|
|
66
|
+
* @throws will throw MerkleTreeIncompleteError if there are missing elements in the tree
|
|
67
|
+
*/
|
|
68
|
+
getSiblingHashesForVerification(item: T): bigint[] | T[];
|
|
69
|
+
/**
|
|
70
|
+
* get item's sibling hashes side
|
|
71
|
+
* @returns sibling's indexes
|
|
72
|
+
* @throws will throw MerkleTreeIncompleteError if there are missing elements in the tree
|
|
73
|
+
*/
|
|
74
|
+
getSiblingSides(item: T): bigint[];
|
|
75
|
+
toJSON(): MerkleTreeJson;
|
|
76
|
+
clone(): MerkleTree<T>;
|
|
77
|
+
getIndex(): bigint;
|
|
78
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TransactionRequest, TransactionResponse } from '@ethersproject/providers';
|
|
2
|
+
import { ContractMetadata, ContractType, EthereumNetwork } from '../../types/ethereum-network.types';
|
|
3
|
+
import { Contract, ethers, Signer } from 'ethers';
|
|
4
|
+
export interface ChainEventListener {
|
|
5
|
+
onAccountChanged(): void;
|
|
6
|
+
onChainChanged(chainId?: number): void;
|
|
7
|
+
}
|
|
8
|
+
export interface IProviderAdapter<ConnectorType = unknown> {
|
|
9
|
+
chainId: number | undefined;
|
|
10
|
+
initConnector(connector: ConnectorType): void;
|
|
11
|
+
initSigner?(signer: Signer): void;
|
|
12
|
+
init(chainId?: number): Promise<void>;
|
|
13
|
+
initConfig?(config?: any): Promise<void> | void;
|
|
14
|
+
connectToConnector(connector: ConnectorType): Promise<number>;
|
|
15
|
+
disconnectFromConnector(): Promise<void>;
|
|
16
|
+
connectAndPatchProvider(connector: ConnectorType): Promise<number>;
|
|
17
|
+
waitForTransaction(transactionHash: string, confirmations: number): Promise<boolean>;
|
|
18
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
19
|
+
getAddress(): Promise<string>;
|
|
20
|
+
getSelectedNetwork(): EthereumNetwork | undefined;
|
|
21
|
+
setChainEventListener(chainEventListener: ChainEventListener): void;
|
|
22
|
+
release(): void;
|
|
23
|
+
getContractMetadata(contractType: ContractType, chainId?: number): ContractMetadata;
|
|
24
|
+
getContract(contractType: ContractType, contractAddress?: string, chainId?: number): ethers.Contract;
|
|
25
|
+
getContractWithSigner(contract: ContractType, contractAddress?: string): Contract;
|
|
26
|
+
getContractWithFetcher(contract: ContractType, contractAddress?: string): Contract;
|
|
27
|
+
getContractWithFetcherForEthereum(contract: ContractType, contractAddress?: string): Contract;
|
|
28
|
+
sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
|
|
29
|
+
switchNetwork(network: EthereumNetwork): Promise<unknown>;
|
|
30
|
+
onAccountChanged(): Promise<unknown>;
|
|
31
|
+
onChainChanged(chainId?: number): Promise<unknown>;
|
|
32
|
+
isPermitterAvailable(): boolean;
|
|
33
|
+
getGasPrice(): Promise<bigint>;
|
|
34
|
+
signTypedData(domain: ethers.TypedDataDomain, types: Record<string, ethers.TypedDataField[]>, value: Record<string, unknown>): Promise<string>;
|
|
35
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const t=require("../../API/fetchCommitmentsCache.cjs");class c extends s.AbstractAccessTokenSnapshotService{constructor(r,e){super(r,0,!1,e)}async fetchSnapshot(){const{chainId:r}=await this.contract.provider.getNetwork(),e=await t.fetchAccessTokenSnapshot(r);if(e.accessTokenContractAddress!==this.contract.address||e.chainId!==r)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,senderAddresses:e.senderAddresses,senderAddressIndexMap:e.senderAddressIndexMap}}persistSnapshot(r){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=c;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const t=require("../../API/fetchCommitmentsCache.cjs");class c extends s.AbstractAccessTokenSnapshotService{constructor(r,e){super(r,0,!1,e)}async fetchSnapshot(){const{chainId:r}=await this.contract.provider.getNetwork(),e=await t.fetchAccessTokenSnapshot(r);if(e.accessTokenContractAddress!==this.contract.address||e.chainId!==r)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,senderAddresses:e.senderAddresses,senderAddressIndexMap:e.senderAddressIndexMap}}persistSnapshot(r){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=c;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractAccessTokenSnapshotService, AccessTokenSerializedSnapshot } from '../event-service';
|
|
2
|
+
import { Contract } from 'ethers';
|
|
3
|
+
export declare class ClientAccessTokenSnapshotService extends AbstractAccessTokenSnapshotService {
|
|
4
|
+
constructor(contract: Contract, maxPageSize?: number);
|
|
5
|
+
protected fetchSnapshot(): Promise<AccessTokenSerializedSnapshot>;
|
|
6
|
+
protected persistSnapshot(_serializedSnapshot: AccessTokenSerializedSnapshot): Promise<unknown>;
|
|
7
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractAccessTokenSnapshotService as
|
|
1
|
+
import { AbstractAccessTokenSnapshotService as t } from "../event-service/AbstractAccessTokenSnapshotService.mjs";
|
|
2
2
|
import "ethers";
|
|
3
3
|
import "circomlibjs-hinkal-fork";
|
|
4
4
|
import "libsodium-wrappers";
|
|
@@ -6,13 +6,18 @@ import "process";
|
|
|
6
6
|
import "buffer";
|
|
7
7
|
import "../../constants/vite.constants.mjs";
|
|
8
8
|
import "../../constants/reorg-depths.constants.mjs";
|
|
9
|
-
import
|
|
10
|
-
|
|
9
|
+
import "axios";
|
|
10
|
+
import "../../constants/chains.constants.mjs";
|
|
11
|
+
import "../../types/circom-data.types.mjs";
|
|
12
|
+
import "../../types/transactions.types.mjs";
|
|
13
|
+
import "../../types/curve.types.mjs";
|
|
14
|
+
import { fetchAccessTokenSnapshot as s } from "../../API/fetchCommitmentsCache.mjs";
|
|
15
|
+
class u extends t {
|
|
11
16
|
constructor(r, e) {
|
|
12
17
|
super(r, 0, !1, e);
|
|
13
18
|
}
|
|
14
19
|
async fetchSnapshot() {
|
|
15
|
-
const { chainId: r } = await this.contract.provider.getNetwork(), e = await
|
|
20
|
+
const { chainId: r } = await this.contract.provider.getNetwork(), e = await s(r);
|
|
16
21
|
if (e.accessTokenContractAddress !== this.contract.address || e.chainId !== r)
|
|
17
22
|
throw Error("Commitment Snapshot: incorrect contract or chain id");
|
|
18
23
|
return {
|
|
@@ -27,5 +32,5 @@ class k extends s {
|
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
export {
|
|
30
|
-
|
|
35
|
+
u as ClientAccessTokenSnapshotService
|
|
31
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const r=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const r=require("../../API/fetchCommitmentsCache.cjs"),i=require("../event-service/AbstractCommitmentsSnapshotService.cjs");class s extends i.AbstractCommitmentsSnapshotService{constructor(t,e){super(t,0,!1,e)}async fetchSnapshot(){const{chainId:t}=await this.contract.provider.getNetwork(),e=await r.fetchCommitmentsSnapshot(t);if(e.hinkalAddress!==this.contract.address||e.chainId!==t)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,encryptedOutputs:e.encryptedOutputs}}persistSnapshot(t){return Promise.resolve()}}exports.ClientCommitmentsSnapshotService=s;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractCommitmentsSnapshotService, CommitmentsSerializedSnapshot } from '../event-service';
|
|
2
|
+
import { Contract } from 'ethers';
|
|
3
|
+
export declare class ClientCommitmentsSnapshotService extends AbstractCommitmentsSnapshotService {
|
|
4
|
+
constructor(contract: Contract, maxPageSize?: number);
|
|
5
|
+
protected fetchSnapshot(): Promise<CommitmentsSerializedSnapshot>;
|
|
6
|
+
protected persistSnapshot(_serializedSnapshot: CommitmentsSerializedSnapshot): Promise<unknown>;
|
|
7
|
+
}
|
|
@@ -5,14 +5,19 @@ import "process";
|
|
|
5
5
|
import "buffer";
|
|
6
6
|
import "../../constants/vite.constants.mjs";
|
|
7
7
|
import "../../constants/reorg-depths.constants.mjs";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
8
|
+
import "axios";
|
|
9
|
+
import "../../constants/chains.constants.mjs";
|
|
10
|
+
import "../../types/circom-data.types.mjs";
|
|
11
|
+
import "../../types/transactions.types.mjs";
|
|
12
|
+
import "../../types/curve.types.mjs";
|
|
13
|
+
import { fetchCommitmentsSnapshot as e } from "../../API/fetchCommitmentsCache.mjs";
|
|
14
|
+
import { AbstractCommitmentsSnapshotService as o } from "../event-service/AbstractCommitmentsSnapshotService.mjs";
|
|
15
|
+
class v extends o {
|
|
11
16
|
constructor(r, t) {
|
|
12
17
|
super(r, 0, !1, t);
|
|
13
18
|
}
|
|
14
19
|
async fetchSnapshot() {
|
|
15
|
-
const { chainId: r } = await this.contract.provider.getNetwork(), t = await
|
|
20
|
+
const { chainId: r } = await this.contract.provider.getNetwork(), t = await e(r);
|
|
16
21
|
if (t.hinkalAddress !== this.contract.address || t.chainId !== r)
|
|
17
22
|
throw Error("Commitment Snapshot: incorrect contract or chain id");
|
|
18
23
|
return {
|
|
@@ -26,5 +31,5 @@ class u extends e {
|
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
export {
|
|
29
|
-
|
|
34
|
+
v as ClientCommitmentsSnapshotService
|
|
30
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const i=require("../../API/fetchNullifiers.cjs"),t=require("../event-service/AbstractNullifierSnapshotService.cjs");class s extends t.AbstractNullifierSnapshotService{constructor(e,r){super(e,0,!1,r)}async fetchSnapshot(){const{chainId:e}=await this.contract.provider.getNetwork(),r=await i.fetchNullifiers(e);return{latestBlockNumber:r.latestBlockNumber,nullifiers:r.nullifiers}}persistSnapshot(e){return Promise.resolve()}}exports.ClientNullifierSnapshotService=s;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractNullifierSnapshotService, NullifierSerializedSnapshot } from '../event-service';
|
|
2
|
+
import { Contract } from 'ethers';
|
|
3
|
+
export declare class ClientNullifierSnapshotService extends AbstractNullifierSnapshotService {
|
|
4
|
+
constructor(contract: Contract, maxPageSize?: number);
|
|
5
|
+
protected fetchSnapshot(): Promise<NullifierSerializedSnapshot>;
|
|
6
|
+
protected persistSnapshot(_serializedSnapshot: NullifierSerializedSnapshot): Promise<unknown>;
|
|
7
|
+
}
|
|
@@ -5,9 +5,14 @@ import "process";
|
|
|
5
5
|
import "buffer";
|
|
6
6
|
import "../../constants/vite.constants.mjs";
|
|
7
7
|
import "../../constants/reorg-depths.constants.mjs";
|
|
8
|
-
import
|
|
8
|
+
import "axios";
|
|
9
|
+
import "../../constants/chains.constants.mjs";
|
|
10
|
+
import "../../types/circom-data.types.mjs";
|
|
11
|
+
import "../../types/transactions.types.mjs";
|
|
12
|
+
import "../../types/curve.types.mjs";
|
|
9
13
|
import { fetchNullifiers as i } from "../../API/fetchNullifiers.mjs";
|
|
10
|
-
|
|
14
|
+
import { AbstractNullifierSnapshotService as o } from "../event-service/AbstractNullifierSnapshotService.mjs";
|
|
15
|
+
class b extends o {
|
|
11
16
|
constructor(t, r) {
|
|
12
17
|
super(t, 0, !1, r);
|
|
13
18
|
}
|
|
@@ -23,5 +28,5 @@ class h extends e {
|
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
export {
|
|
26
|
-
|
|
31
|
+
b as ClientNullifierSnapshotService
|
|
27
32
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ERC20Token } from '../../types/token.types';
|
|
2
|
+
export declare class TokenChecker {
|
|
3
|
+
static isCurveLPToken: (token: ERC20Token, curveTokens: string[]) => boolean;
|
|
4
|
+
static isCurveStakeToken: (token: ERC20Token) => boolean;
|
|
5
|
+
static isConvexToken: (token: ERC20Token) => boolean;
|
|
6
|
+
static isBeefyLpToken: (token: ERC20Token) => boolean;
|
|
7
|
+
static isBeefyStakeToken: (token: ERC20Token) => boolean;
|
|
8
|
+
static isLidoToken: (token: ERC20Token) => boolean;
|
|
9
|
+
static isCurveOrConvex: (token: ERC20Token, curveTokens: string[]) => boolean;
|
|
10
|
+
static isBeefyToken: (token: ERC20Token) => boolean;
|
|
11
|
+
static isStakeToken: (token: ERC20Token) => boolean;
|
|
12
|
+
static isPendleYtToken: (token: ERC20Token) => boolean;
|
|
13
|
+
static isPendleLPToken: (token: ERC20Token) => boolean;
|
|
14
|
+
static isPendleSyToken: (token: ERC20Token) => boolean;
|
|
15
|
+
static isPendleNativeToken: (token: ERC20Token) => boolean;
|
|
16
|
+
static isPendleToken: (token: ERC20Token) => boolean;
|
|
17
|
+
static isAaveToken: (token: ERC20Token) => boolean | undefined;
|
|
18
|
+
static isKinzaToken: (token: ERC20Token) => boolean;
|
|
19
|
+
static isProtocolToken: (token: ERC20Token, curveTokens: string[]) => boolean | undefined;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TokenChecker';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Contract } from 'ethers';
|
|
2
|
+
import { DecodedTx, HashInfoByChain, RawTx } from '../../types';
|
|
3
|
+
import { TransactionField } from './history/history.types';
|
|
4
|
+
import { UserKeys } from '../crypto-keys';
|
|
5
|
+
export declare class TransactionsManager {
|
|
6
|
+
readonly circuitSize: number;
|
|
7
|
+
hinkalContract: Contract;
|
|
8
|
+
init(hinkalContract: Contract): void;
|
|
9
|
+
requireInit(): void;
|
|
10
|
+
private filterOwnTransactions;
|
|
11
|
+
private saveTxsInStorage;
|
|
12
|
+
private loadTxsFromStorage;
|
|
13
|
+
getAllTransactions: (chainId: number, userKeys: UserKeys, week?: number, startWeek?: number) => Promise<RawTx[]>;
|
|
14
|
+
getHinkalHistoryBase: (chainId: number, userKeys: UserKeys, week?: number, includeOthersDeposits?: boolean, startWeek?: number) => Promise<DecodedTx[]>;
|
|
15
|
+
getHinkalHistory: (chainId: number, userKeys: UserKeys) => Promise<TransactionField[]>;
|
|
16
|
+
private sortInBatches;
|
|
17
|
+
private generateTransactionsProof;
|
|
18
|
+
private userVerifyTransactions;
|
|
19
|
+
private verifyTransactionsInBatches;
|
|
20
|
+
processAndSendTransactionsForVerification: (chainId: number, userKeys: UserKeys, ethereumAddress: string, latestCertifiedHash?: string, startWeek?: number) => Promise<{
|
|
21
|
+
trade: number;
|
|
22
|
+
transactions: number;
|
|
23
|
+
lockedDeposit: number;
|
|
24
|
+
verification: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
multiProcessAndSendTransactionsForVerification: (userKeys: UserKeys, ethereumAddress: string, lastCertifiedHashes?: HashInfoByChain) => Promise<boolean>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConvexAction, OnChainUtxo } from '../../../types';
|
|
2
|
+
import { ConvexStakeUnstake, PastTransaction, TransactionType } from './history.types';
|
|
3
|
+
export declare const getConvexData: (input: PastTransaction, utxosArray: OnChainUtxo[], chainId: number) => ConvexStakeUnstake | {
|
|
4
|
+
type: TransactionType;
|
|
5
|
+
convexAction: ConvexAction;
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CurveAction, OnChainUtxo } from '../../../types';
|
|
2
|
+
import { CurveDepositWithdrawResult, CurveStakeUnstake, PastTransaction, TransactionType } from './history.types';
|
|
3
|
+
export declare const getCurveData: (input: PastTransaction, utxosArray: OnChainUtxo[], chainId: number) => CurveDepositWithdrawResult | CurveStakeUnstake | {
|
|
4
|
+
type: TransactionType;
|
|
5
|
+
curveAction: CurveAction;
|
|
6
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ERC20Token, OnChainUtxo } from '../../../types';
|
|
2
|
+
import { PastTransaction, TransactionType } from './history.types';
|
|
3
|
+
export declare const getLidoData: (input: PastTransaction, utxosArray: OnChainUtxo[], chainId: number) => {
|
|
4
|
+
lidoToken: {
|
|
5
|
+
token: ERC20Token | undefined;
|
|
6
|
+
balance: bigint;
|
|
7
|
+
};
|
|
8
|
+
type: TransactionType;
|
|
9
|
+
lidoAction: any;
|
|
10
|
+
};
|