@hinkal/common 0.2.21 → 0.2.23
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.cjs +1 -1
- package/API/API.d.ts +14 -14
- package/API/API.mjs +88 -87
- package/API/admin-calls.cjs +1 -1
- package/API/admin-calls.d.ts +1 -1
- package/API/admin-calls.mjs +4 -4
- package/API/ai-calls.cjs +1 -0
- package/API/ai-calls.d.ts +17 -0
- package/API/ai-calls.mjs +21 -0
- package/API/callLifiAPI.cjs +1 -1
- package/API/callLifiAPI.d.ts +1 -1
- package/API/callLifiAPI.mjs +5 -5
- package/API/callMonitor.cjs +1 -1
- package/API/callMonitor.d.ts +1 -1
- package/API/callMonitor.mjs +7 -7
- package/API/callOdosAPI.cjs +1 -1
- package/API/callOdosAPI.mjs +11 -11
- package/API/callOkxAPI.cjs +1 -1
- package/API/callOkxAPI.d.ts +1 -1
- package/API/callOkxAPI.mjs +5 -5
- package/API/callOneInchAPI.cjs +1 -1
- package/API/callOneInchAPI.mjs +11 -10
- package/API/callRelayer.cjs +1 -1
- package/API/callRelayer.d.ts +5 -6
- package/API/callRelayer.mjs +11 -11
- package/API/checkRisk.cjs +1 -1
- package/API/checkRisk.d.ts +1 -1
- package/API/checkRisk.mjs +4 -4
- package/API/deposit-and-withdraw-status-calls.cjs +1 -0
- package/API/deposit-and-withdraw-status-calls.d.ts +20 -0
- package/API/deposit-and-withdraw-status-calls.mjs +18 -0
- package/API/duneAPI.cjs +1 -0
- package/API/duneAPI.d.ts +11 -0
- package/API/duneAPI.mjs +25 -0
- package/API/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +4 -5
- package/API/fetchCommitmentsCache.cjs +1 -1
- package/API/fetchCommitmentsCache.mjs +9 -9
- package/API/get-token-data.cjs +1 -1
- package/API/get-token-data.d.ts +1 -1
- package/API/get-token-data.mjs +5 -5
- package/API/getBridgeProtocols.cjs +1 -0
- package/API/getBridgeProtocols.d.ts +7 -0
- package/API/getBridgeProtocols.mjs +8 -0
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.mjs +9 -9
- package/API/getLifiStatus.cjs +1 -0
- package/API/getLifiStatus.d.ts +24 -0
- package/API/getLifiStatus.mjs +15 -0
- package/API/getRelayerURL.cjs +1 -0
- package/API/getRelayerURL.d.ts +1 -0
- package/API/getRelayerURL.mjs +10 -0
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.d.ts +3 -3
- package/API/getServerURL.mjs +67 -51
- package/API/getTokenPrice.cjs +1 -1
- package/API/getTokenPrice.d.ts +0 -5
- package/API/getTokenPrice.mjs +7 -14
- package/API/index.d.ts +3 -1
- package/API/is-tx-stateless.cjs +1 -1
- package/API/is-tx-stateless.d.ts +1 -1
- package/API/is-tx-stateless.mjs +12 -10
- package/API/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +8 -4
- package/API/kycCalls.mjs +26 -23
- package/API/passwordCalls.cjs +1 -0
- package/API/passwordCalls.d.ts +9 -0
- package/API/passwordCalls.mjs +13 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +2 -7
- package/API/proxyAccountsCalls.mjs +21 -27
- package/API/relayCalls.cjs +1 -1
- package/API/relayCalls.mjs +4 -4
- package/API/restoreSnapshots.cjs +1 -0
- package/API/restoreSnapshots.d.ts +1 -0
- package/API/restoreSnapshots.mjs +10 -0
- package/API/scheduled-transactions-calls.cjs +1 -1
- package/API/scheduled-transactions-calls.d.ts +9 -1
- package/API/scheduled-transactions-calls.mjs +9 -5
- package/API/simulate-batch-tx.cjs +1 -1
- package/API/simulate-batch-tx.d.ts +2 -2
- package/API/simulate-batch-tx.mjs +6 -7
- package/API/solana-calls.cjs +1 -1
- package/API/solana-calls.d.ts +3 -6
- package/API/solana-calls.mjs +15 -15
- package/API/temporaryWalletCalls.cjs +1 -1
- package/API/temporaryWalletCalls.mjs +19 -13
- package/API/token-calls.cjs +1 -1
- package/API/token-calls.mjs +5 -6
- package/README.md +64 -256
- package/constants/activity.constants.cjs +1 -1
- package/constants/activity.constants.mjs +0 -1
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.mjs +9 -10
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +6 -0
- package/constants/chains.constants.mjs +52 -58
- package/constants/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.d.ts +0 -1
- package/constants/coingecko.constants.mjs +10 -11
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.d.ts +3 -3
- package/constants/contracts.constants.mjs +29 -29
- package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-solana.json.mjs +2 -28
- package/constants/function-signatures.constants.cjs +1 -1
- package/constants/function-signatures.constants.d.ts +1 -0
- package/constants/function-signatures.constants.mjs +4 -3
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +40 -39
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +0 -1
- package/constants/mediaUrls.constants.mjs +1 -2
- package/constants/permit2.constants.cjs +1 -1
- package/constants/permit2.constants.d.ts +1 -0
- package/constants/permit2.constants.mjs +11 -10
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +123 -19
- package/constants/server.constants.mjs +138 -35
- package/constants/tasks.constants.cjs +1 -1
- package/constants/tasks.constants.mjs +4 -5
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +13 -36
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +10 -10
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +86 -83
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +56 -45
- package/data-structures/Hinkal/Hinkal.mjs +348 -315
- package/data-structures/Hinkal/IHinkal.d.ts +56 -42
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +49 -48
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +7 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +42 -0
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +24 -29
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -0
- package/data-structures/Hinkal/hinkalApprove.d.ts +3 -0
- package/data-structures/Hinkal/hinkalApprove.mjs +114 -0
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +19 -20
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +84 -89
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +96 -78
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +79 -75
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +151 -140
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +5 -4
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalInsideTransact.d.ts +4 -0
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +120 -0
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +118 -115
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +29 -30
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +36 -40
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +32 -37
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +15 -17
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +3 -4
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +95 -84
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +180 -154
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +3 -2
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +40 -43
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +67 -71
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +59 -63
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +46 -50
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +50 -52
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +65 -69
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +77 -71
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +70 -72
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +78 -81
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +103 -106
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +54 -108
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.d.ts +0 -1
- package/data-structures/IndexedDB/activity-db.mjs +79 -97
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +39 -43
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +31 -36
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +40 -26
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +82 -82
- package/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
- package/data-structures/TokenDBs/token-visibility-db.mjs +36 -22
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +10 -0
- package/data-structures/crypto-keys/keys.mjs +106 -47
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +6 -6
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +2 -4
- package/data-structures/event-service/evm/AbstractEventService.mjs +13 -13
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +3 -3
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +2 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +6 -2
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +5 -10
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +40 -40
- package/data-structures/event-service/index.d.ts +0 -4
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +2 -3
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +3 -4
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +8 -8
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +10 -4
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +7 -10
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +2 -2
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +2 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +2 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +16 -11
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +66 -64
- package/data-structures/index.d.ts +0 -3
- package/data-structures/presale/PresaleContractWrapper.cjs +1 -1
- package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
- package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +16 -11
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +18 -18
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +9 -9
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +4 -6
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +4 -6
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +4 -6
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +4 -5
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +4 -6
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +0 -1
- package/error-handling/error-codes.constants.mjs +3 -4
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +27 -22
- package/error-handling/handleErrorRestore.cjs +1 -0
- package/error-handling/handleErrorRestore.d.ts +2 -0
- package/error-handling/handleErrorRestore.mjs +11 -0
- package/error-handling/index.d.ts +1 -0
- package/functions/kyc/authentoHelper.cjs +1 -0
- package/functions/kyc/authentoHelper.d.ts +12 -0
- package/functions/kyc/authentoHelper.mjs +30 -0
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +16 -17
- package/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/functions/pre-transaction/constructAdminData.d.ts +2 -2
- package/functions/pre-transaction/constructAdminData.mjs +18 -12
- package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/functions/pre-transaction/getExternalSwapAddress.d.ts +2 -1
- package/functions/pre-transaction/getExternalSwapAddress.mjs +8 -8
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +2 -3
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +36 -22
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +2 -3
- package/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.d.ts +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +17 -17
- package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +9 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.mjs +34 -19
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.mjs +50 -53
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +4 -4
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +12 -10
- package/functions/private-wallet/emporium.helpers.mjs +139 -102
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.d.ts +4 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +106 -103
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +21 -18
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.mjs +49 -49
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +11 -10
- package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
- package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +10 -11
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.d.ts +0 -1
- package/functions/utils/addresses.mjs +11 -12
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +1 -1
- package/functions/utils/cacheFunctions.mjs +55 -54
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +2 -2
- package/functions/utils/create-provider.mjs +7 -11
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +9 -9
- package/functions/utils/ethers-formatter.utils.d.ts +1 -1
- package/functions/utils/external-action.utils.cjs +1 -1
- package/functions/utils/external-action.utils.mjs +2 -2
- package/functions/utils/get-hinkal-approvals.cjs +1 -0
- package/functions/utils/get-hinkal-approvals.d.ts +3 -0
- package/functions/utils/get-hinkal-approvals.mjs +38 -0
- package/functions/utils/getContractAddress.cjs +1 -0
- package/functions/utils/getContractAddress.d.ts +2 -0
- package/functions/utils/getContractAddress.mjs +9 -0
- package/functions/utils/getDataFromTransaction.cjs +1 -1
- package/functions/utils/getDataFromTransaction.d.ts +0 -11
- package/functions/utils/getDataFromTransaction.mjs +26 -50
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
- package/functions/utils/getSignerFromContract.cjs +1 -0
- package/functions/utils/getSignerFromContract.d.ts +3 -0
- package/functions/utils/getSignerFromContract.mjs +16 -0
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +14 -15
- package/functions/utils/inLogicMetadata.cjs +1 -1
- package/functions/utils/inLogicMetadata.mjs +2 -2
- package/functions/utils/index.d.ts +1 -0
- package/functions/utils/involves-permit2-op.cjs +1 -1
- package/functions/utils/involves-permit2-op.d.ts +1 -0
- package/functions/utils/involves-permit2-op.mjs +6 -4
- package/functions/utils/mutexes.utils.cjs +1 -1
- package/functions/utils/mutexes.utils.d.ts +1 -1
- package/functions/utils/mutexes.utils.mjs +3 -3
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +23 -9
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +13 -6
- package/functions/utils/prepareHinkal.mjs +72 -45
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.d.ts +1 -1
- package/functions/utils/publicBalance.utils.mjs +62 -57
- package/functions/utils/replaceAddressInCalldata.cjs +1 -0
- package/functions/utils/replaceAddressInCalldata.d.ts +1 -0
- package/functions/utils/replaceAddressInCalldata.mjs +7 -0
- package/functions/utils/rpc-int-encode.cjs +1 -1
- package/functions/utils/rpc-int-encode.d.ts +1 -2
- package/functions/utils/rpc-int-encode.mjs +3 -6
- package/functions/utils/solanaMint.utils.cjs +1 -1
- package/functions/utils/solanaMint.utils.mjs +6 -6
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +0 -1
- package/functions/utils/string.utils.mjs +14 -18
- package/functions/utils/token-check.utils.cjs +1 -1
- package/functions/utils/token-check.utils.d.ts +0 -3
- package/functions/utils/token-check.utils.mjs +7 -18
- package/functions/utils/upToDateState.cjs +1 -1
- package/functions/utils/upToDateState.d.ts +1 -1
- package/functions/utils/upToDateState.mjs +4 -4
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +17 -2
- package/functions/utils/walletBalances.utils.mjs +36 -5
- package/functions/web3/EIP-712.cjs +1 -1
- package/functions/web3/EIP-712.d.ts +4 -4
- package/functions/web3/EIP-712.mjs +1 -1
- package/functions/web3/etherFunctions.cjs +1 -1
- package/functions/web3/etherFunctions.mjs +32 -29
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +2 -3
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.d.ts +4 -3
- package/functions/web3/events/getApprovedBalance.mjs +44 -39
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.d.ts +3 -3
- package/functions/web3/events/getInputUtxoAndBalance.mjs +150 -129
- package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.mjs +75 -73
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.d.ts +3 -3
- package/functions/web3/events/getTransactionLogEvents.mjs +41 -40
- package/functions/web3/events/index.d.ts +0 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +12 -16
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +6 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +20 -12
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +68 -69
- package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.mjs +6 -6
- package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
- package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
- package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.d.ts +2 -1
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +10 -10
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +5 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +29 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +47 -39
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +3 -3
- package/functions/web3/functionCalls/transactCallRelayer.mjs +54 -56
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.d.ts +1 -1
- package/functions/web3/getContractMetadata.mjs +21 -16
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.d.ts +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +7 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +32 -31
- package/functions/web3/index.d.ts +0 -1
- package/functions/web3/lifiAPI.cjs +1 -1
- package/functions/web3/lifiAPI.d.ts +1 -1
- package/functions/web3/lifiAPI.mjs +12 -12
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +15 -3
- package/functions/web3/okxAPI.cjs +1 -1
- package/functions/web3/okxAPI.mjs +13 -13
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +20 -8
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.d.ts +6 -5
- package/functions/web3/runContractFunction.mjs +60 -46
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +2 -2
- package/functions/web3/uniswapAPI.mjs +49 -38
- package/index.cjs +1 -1
- package/index.mjs +912 -914
- package/package.json +4 -6
- package/providers/CustomEthersProvider.d.ts +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +21 -14
- package/providers/EthersProviderAdapter.mjs +86 -53
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +12 -8
- package/providers/SolanaProviderAdapter.mjs +31 -16
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +20 -14
- package/providers/WagmiProviderAdapter.mjs +126 -91
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +2 -2
- package/providers/prepareEthersHinkal.mjs +9 -16
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +9 -17
- package/types/TransactionSimulator.types.d.ts +9 -2
- package/types/activities.types.d.ts +2 -5
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +6 -0
- package/types/admin.types.mjs +2 -2
- package/types/balances.types.d.ts +1 -0
- package/types/big-intable.types.d.ts +3 -2
- package/types/bridging.types.d.ts +29 -0
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +3 -6
- package/types/cache.types.mjs +1 -1
- package/types/coingecko.types.d.ts +0 -5
- package/types/duneAPI.types.d.ts +9 -0
- package/types/ethereum-network.types.d.ts +10 -11
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +1 -1
- package/types/hinkal.types.mjs +18 -18
- package/types/index.d.ts +2 -2
- package/types/proxy.types.d.ts +3 -6
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +39 -10
- package/types/sandbox.types.mjs +2 -2
- package/types/scheduled-transactions.types.cjs +1 -1
- package/types/scheduled-transactions.types.d.ts +6 -0
- package/types/scheduled-transactions.types.mjs +3 -2
- package/types/session.types.d.ts +0 -2
- package/types/solana.types.d.ts +0 -9
- package/types/token-prices.types.cjs +1 -1
- package/types/token-prices.types.d.ts +0 -7
- package/types/token-prices.types.mjs +2 -4
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -3
- package/types/transactions.types.mjs +6 -7
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +1 -1
- package/webworker/viteWorkerURL.constant.cjs +3 -3
- package/webworker/viteWorkerURL.constant.mjs +3 -3
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/API/get-token-price-chart-data.cjs +0 -1
- package/API/get-token-price-chart-data.d.ts +0 -16
- package/API/get-token-price-chart-data.mjs +0 -13
- package/API/onrampCalls.cjs +0 -1
- package/API/onrampCalls.d.ts +0 -20
- package/API/onrampCalls.mjs +0 -15
- package/API/unspent-utxos-calls.cjs +0 -1
- package/API/unspent-utxos-calls.d.ts +0 -26
- package/API/unspent-utxos-calls.mjs +0 -26
- package/data-structures/AccountActions/AccountActions.cjs +0 -1
- package/data-structures/AccountActions/AccountActions.d.ts +0 -18
- package/data-structures/AccountActions/AccountActions.mjs +0 -78
- package/data-structures/AccountActions/index.d.ts +0 -1
- package/data-structures/BlockchainEvent/BlockchainEvent.cjs +0 -1
- package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +0 -14
- package/data-structures/BlockchainEvent/BlockchainEvent.mjs +0 -41
- package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +0 -1
- package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +0 -20
- package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +0 -124
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +0 -1
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +0 -15
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +0 -64
- package/data-structures/PublicBalance/index.d.ts +0 -2
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +0 -11
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +0 -21
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +0 -6
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +0 -16
- package/data-structures/event-service/helpers/ClientEventHelper.cjs +0 -1
- package/data-structures/event-service/helpers/ClientEventHelper.d.ts +0 -11
- package/data-structures/event-service/helpers/ClientEventHelper.mjs +0 -26
- package/data-structures/event-service/helpers/PollingEventHelper.cjs +0 -1
- package/data-structures/event-service/helpers/PollingEventHelper.d.ts +0 -5
- package/data-structures/event-service/helpers/PollingEventHelper.mjs +0 -14
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +0 -11
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +0 -22
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +0 -6
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +0 -16
- package/functions/utils/enum.utils.cjs +0 -1
- package/functions/utils/enum.utils.mjs +0 -14
- package/functions/utils/socket.utils.cjs +0 -1
- package/functions/utils/socket.utils.d.ts +0 -1
- package/functions/utils/socket.utils.mjs +0 -12
- package/functions/web3/crypto.cjs +0 -1
- package/functions/web3/crypto.d.ts +0 -1
- package/functions/web3/crypto.mjs +0 -7
- package/functions/web3/events/web3RetrieveEvents.cjs +0 -1
- package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
- package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
- package/types/events.types.cjs +0 -1
- package/types/events.types.d.ts +0 -9
- package/types/events.types.mjs +0 -5
- package/types/onramp.types.cjs +0 -1
- package/types/onramp.types.d.ts +0 -58
- package/types/onramp.types.mjs +0 -4
|
@@ -2,7 +2,6 @@ import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
|
2
2
|
import { NewApprovedUtxoEvent } from '../../../types/commitments.types';
|
|
3
3
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
4
4
|
import { ApprovedUtxo } from '../../../types/hinkal.types';
|
|
5
|
-
import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
|
|
6
5
|
export type ApprovalsSnapshotPayload = {
|
|
7
6
|
readonly approvals: Map<string, ApprovedUtxo[]>;
|
|
8
7
|
readonly events: Set<string>;
|
|
@@ -12,7 +11,7 @@ export type ApprovalsSerializedSnapshot = {
|
|
|
12
11
|
approvals: Record<string, ApprovedUtxo<string>[]>;
|
|
13
12
|
events: string[];
|
|
14
13
|
};
|
|
15
|
-
export declare abstract class AbstractApprovalsSnapshotService extends AbstractSnapshotService<NewApprovedUtxoEvent, ApprovalsSnapshotPayload, ApprovalsSerializedSnapshot> {
|
|
14
|
+
export declare abstract class AbstractApprovalsSnapshotService extends AbstractSnapshotService<NewApprovedUtxoEvent, NewApprovedUtxoEvent<string>, ApprovalsSnapshotPayload, ApprovalsSerializedSnapshot> {
|
|
16
15
|
constructor(hinkalEventEmitter: BlockchainEventEmitter);
|
|
17
16
|
private _approvals;
|
|
18
17
|
events: Set<string>;
|
|
@@ -25,6 +24,6 @@ export declare abstract class AbstractApprovalsSnapshotService extends AbstractS
|
|
|
25
24
|
events: Set<string>;
|
|
26
25
|
};
|
|
27
26
|
protected populateSnapshot({ payload: { approvals, events } }: Snapshot<ApprovalsSnapshotPayload>): void;
|
|
28
|
-
protected mapEvent(event:
|
|
27
|
+
protected mapEvent(event: NewApprovedUtxoEvent<string>): NewApprovedUtxoEvent;
|
|
29
28
|
protected acceptEvent(event: NewApprovedUtxoEvent, _blockNumber: number, txHash: string): boolean;
|
|
30
29
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractSnapshotService as c } from "./AbstractSnapshotService.mjs";
|
|
2
2
|
import { toBigInt as v } from "../../../functions/utils/amounts.utils.mjs";
|
|
3
|
-
import { caseInsensitiveEqual as
|
|
4
|
-
class
|
|
3
|
+
import { caseInsensitiveEqual as u } from "../../../functions/utils/caseInsensitive.utils.mjs";
|
|
4
|
+
class g extends c {
|
|
5
5
|
constructor(e) {
|
|
6
6
|
super(e, "NewApprovedUtxo");
|
|
7
7
|
}
|
|
@@ -57,7 +57,7 @@ class f extends c {
|
|
|
57
57
|
this._approvals = e, this.events = t;
|
|
58
58
|
}
|
|
59
59
|
mapEvent(e) {
|
|
60
|
-
const
|
|
60
|
+
const { approveTo: t, tokenAddress: s, amount: r, inHinkalAddress: p } = e;
|
|
61
61
|
return {
|
|
62
62
|
approveTo: t,
|
|
63
63
|
tokenAddress: s,
|
|
@@ -75,7 +75,7 @@ class f extends c {
|
|
|
75
75
|
};
|
|
76
76
|
let a = this.approvals.get(e.approveTo) || [], d = !1;
|
|
77
77
|
for (let o = 0; o < a.length; o += 1)
|
|
78
|
-
|
|
78
|
+
u(i, a[o].tokenAddress) && l === a[o].inHinkalAddress && (a[o].amount += p, d = !0);
|
|
79
79
|
if (a = a.filter((o) => o.amount !== 0n), d && a.length === 0)
|
|
80
80
|
this.approvals.delete(e.approveTo);
|
|
81
81
|
else {
|
|
@@ -88,5 +88,5 @@ class f extends c {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
export {
|
|
91
|
-
|
|
91
|
+
g as AbstractApprovalsSnapshotService
|
|
92
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const l=require("../../merkle-tree/MerkleTree.cjs");require("ethers");require("../../../error-handling/error-codes.constants.cjs");const u=require("../../../functions/utils/amounts.utils.cjs"),o=require("./AbstractSnapshotService.cjs"),p=require("../../../functions/utils/merkleTree.utils.cjs");class a extends o.AbstractSnapshotService{constructor(e){super(e,"NewCommitment")}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive),isBlocked:t.isBlocked??!1}))}}deserializeSnapshot(e){let t;e.latestBlockNumber&&e.merkleTree?t=p.contructMerkleTreeFromSerialized(e.merkleTree):t=l.MerkleTree.create(c.poseidonFunction,0n);const s=e.encryptedOutputs?.map(r=>({value:r.value,isPositive:JSON.parse(r.isPositive),isBlocked:r.isBlocked??!1}));return{latestBlockNumber:e.latestBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:s||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:s,encryptedOutput:r}=e;return{commitment:u.toBigInt(t),index:u.toBigInt(s),encryptedOutput:r}}acceptEvent(e,t,s,r){if(!this.encryptedOutputs.map(i=>i.value).includes(e.encryptedOutput)){if(!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return!1;const n={value:e.encryptedOutput,isPositive:e.index>=0n,isBlocked:r??!1};return this._encryptedOutputs.push(n),!0}return!1}}exports.AbstractCommitmentsSnapshotService=a;
|
|
@@ -2,7 +2,6 @@ import { MerkleTree, MerkleTreeJson } from '../../merkle-tree';
|
|
|
2
2
|
import { CommitmentEvent, EncryptedOutputWithSign } from '../../../types';
|
|
3
3
|
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
4
4
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
5
|
-
import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
|
|
6
5
|
export type CommitmentsSnapshotPayload = {
|
|
7
6
|
readonly merkleTree: MerkleTree<bigint>;
|
|
8
7
|
readonly encryptedOutputs: EncryptedOutputWithSign[];
|
|
@@ -12,7 +11,7 @@ export type CommitmentsSerializedSnapshot = {
|
|
|
12
11
|
merkleTree?: MerkleTreeJson;
|
|
13
12
|
encryptedOutputs?: EncryptedOutputWithSign<string>[];
|
|
14
13
|
};
|
|
15
|
-
export declare abstract class AbstractCommitmentsSnapshotService extends AbstractSnapshotService<CommitmentEvent<bigint>, CommitmentsSnapshotPayload, CommitmentsSerializedSnapshot> {
|
|
14
|
+
export declare abstract class AbstractCommitmentsSnapshotService extends AbstractSnapshotService<CommitmentEvent<bigint>, CommitmentEvent, CommitmentsSnapshotPayload, CommitmentsSerializedSnapshot> {
|
|
16
15
|
constructor(hinkalEventEmitter: BlockchainEventEmitter);
|
|
17
16
|
private _merkleTree;
|
|
18
17
|
private _encryptedOutputs;
|
|
@@ -25,6 +24,6 @@ export declare abstract class AbstractCommitmentsSnapshotService extends Abstrac
|
|
|
25
24
|
encryptedOutputs: EncryptedOutputWithSign<boolean>[];
|
|
26
25
|
};
|
|
27
26
|
protected populateSnapshot({ payload: { merkleTree, encryptedOutputs }, }: Snapshot<CommitmentsSnapshotPayload>): void;
|
|
28
|
-
protected mapEvent(event:
|
|
27
|
+
protected mapEvent(event: CommitmentEvent): CommitmentEvent<bigint>;
|
|
29
28
|
protected acceptEvent(event: CommitmentEvent<bigint>, _blockNumber: number, _txHash?: string, isBlocked?: boolean): boolean;
|
|
30
29
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { poseidonFunction as
|
|
1
|
+
import { poseidonFunction as m } from "../../../crypto/poseidon.mjs";
|
|
2
2
|
import "circomlibjs-hinkal-fork";
|
|
3
3
|
import "libsodium-wrappers";
|
|
4
4
|
import "process";
|
|
5
5
|
import "buffer";
|
|
6
|
-
import { MerkleTree as
|
|
6
|
+
import { MerkleTree as c } from "../../merkle-tree/MerkleTree.mjs";
|
|
7
7
|
import "ethers";
|
|
8
8
|
import "../../../error-handling/error-codes.constants.mjs";
|
|
9
9
|
import { toBigInt as p } from "../../../functions/utils/amounts.utils.mjs";
|
|
10
10
|
import { AbstractSnapshotService as o } from "./AbstractSnapshotService.mjs";
|
|
11
11
|
import { contructMerkleTreeFromSerialized as n } from "../../../functions/utils/merkleTree.utils.mjs";
|
|
12
|
-
class
|
|
12
|
+
class b extends o {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super(e, "NewCommitment");
|
|
15
15
|
}
|
|
@@ -34,7 +34,7 @@ class x extends o {
|
|
|
34
34
|
}
|
|
35
35
|
deserializeSnapshot(e) {
|
|
36
36
|
let t;
|
|
37
|
-
e.latestBlockNumber && e.merkleTree ? t = n(e.merkleTree) : t =
|
|
37
|
+
e.latestBlockNumber && e.merkleTree ? t = n(e.merkleTree) : t = c.create(m, 0n);
|
|
38
38
|
const s = e.encryptedOutputs?.map((r) => ({
|
|
39
39
|
value: r.value,
|
|
40
40
|
isPositive: JSON.parse(r.isPositive),
|
|
@@ -60,7 +60,7 @@ class x extends o {
|
|
|
60
60
|
this._merkleTree = e, this._encryptedOutputs = t;
|
|
61
61
|
}
|
|
62
62
|
mapEvent(e) {
|
|
63
|
-
const
|
|
63
|
+
const { commitment: t, index: s, encryptedOutput: r } = e;
|
|
64
64
|
return {
|
|
65
65
|
commitment: p(t),
|
|
66
66
|
index: p(s),
|
|
@@ -82,5 +82,5 @@ class x extends o {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
export {
|
|
85
|
-
|
|
85
|
+
b as AbstractCommitmentsSnapshotService
|
|
86
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
|
|
2
1
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
3
|
-
export declare abstract class AbstractEventService<EventType> {
|
|
2
|
+
export declare abstract class AbstractEventService<EventType, SerializedEventType = unknown> {
|
|
4
3
|
protected blockchainEventEmitter: BlockchainEventEmitter;
|
|
5
4
|
protected readonly eventName: string;
|
|
6
5
|
protected constructor(blockchainEventEmitter: BlockchainEventEmitter, eventName: string);
|
|
7
6
|
get latestBlockNumber(): number;
|
|
8
|
-
get chainId(): number;
|
|
9
7
|
intervalClear(): void;
|
|
10
8
|
private processEventsPage;
|
|
11
9
|
protected abstract acceptEvent(event: EventType, blockNumber: number, txHash?: string, isBlocked?: boolean): boolean | Promise<boolean>;
|
|
12
|
-
protected abstract mapEvent(event:
|
|
10
|
+
protected abstract mapEvent(event: SerializedEventType): EventType;
|
|
13
11
|
protected abstract afterEventsAccepted(eventsCount: number): Promise<void>;
|
|
14
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveSync as
|
|
2
|
-
class
|
|
1
|
+
import { resolveSync as v } from "../../../functions/utils/resolve-sync.utils.mjs";
|
|
2
|
+
class u {
|
|
3
3
|
blockchainEventEmitter;
|
|
4
4
|
eventName;
|
|
5
5
|
constructor(t, s) {
|
|
@@ -8,30 +8,30 @@ class m {
|
|
|
8
8
|
get latestBlockNumber() {
|
|
9
9
|
return this.blockchainEventEmitter.latestBlockNumber;
|
|
10
10
|
}
|
|
11
|
-
get chainId() {
|
|
12
|
-
return this.blockchainEventEmitter.chainId;
|
|
13
|
-
}
|
|
14
11
|
intervalClear() {
|
|
15
12
|
this.blockchainEventEmitter.intervalClear();
|
|
16
13
|
}
|
|
17
14
|
async processEventsPage(t) {
|
|
18
15
|
const s = /* @__PURE__ */ new Set();
|
|
19
|
-
t.forEach((
|
|
20
|
-
e === "BlockedUtxosCreated" && s.add(
|
|
16
|
+
t.forEach((e) => {
|
|
17
|
+
e.eventName === "BlockedUtxosCreated" && s.add(e.transactionHash);
|
|
21
18
|
});
|
|
22
19
|
const n = [];
|
|
23
|
-
await
|
|
20
|
+
await v(
|
|
24
21
|
t.map((e) => async () => {
|
|
25
22
|
if (e.eventName !== this.eventName)
|
|
26
23
|
return;
|
|
27
|
-
const { blockNumber:
|
|
28
|
-
|
|
24
|
+
const { args: a, blockNumber: i, transactionHash: c } = e;
|
|
25
|
+
if (!a)
|
|
26
|
+
throw new Error("Wrong event structure");
|
|
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
|
|
32
|
-
return await this.afterEventsAccepted(
|
|
31
|
+
const o = n.length;
|
|
32
|
+
return await this.afterEventsAccepted(o), n.length;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
export {
|
|
36
|
-
|
|
36
|
+
u as AbstractEventService
|
|
37
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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,7 +1,6 @@
|
|
|
1
1
|
import { NullifierEvent } from '../../../types/commitments.types';
|
|
2
2
|
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
3
3
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
4
|
-
import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
|
|
5
4
|
export type NullifierSnapshotPayload = {
|
|
6
5
|
readonly nullifiers: Set<string>;
|
|
7
6
|
};
|
|
@@ -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>, 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:
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ethers as i } from "ethers";
|
|
2
2
|
import { AbstractSnapshotService as t } from "./AbstractSnapshotService.mjs";
|
|
3
3
|
class a extends t {
|
|
4
4
|
constructor(r) {
|
|
@@ -30,9 +30,9 @@ class a extends t {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
mapEvent(r) {
|
|
33
|
-
const e = r
|
|
33
|
+
const { nullifier: e } = r;
|
|
34
34
|
return {
|
|
35
|
-
nullifier: i.
|
|
35
|
+
nullifier: i.toBeHex(e)
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
getSnapshotPayload() {
|
|
@@ -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;constructor(t,e){super(t,e)}async init(){await this.loadSnapshot()}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;
|
|
@@ -4,8 +4,9 @@ export interface Snapshot<SnapshotPayloadType> {
|
|
|
4
4
|
readonly latestBlockNumber: number;
|
|
5
5
|
readonly payload: SnapshotPayloadType;
|
|
6
6
|
}
|
|
7
|
-
export declare abstract class AbstractSnapshotService<EventType, SnapshotPayloadType, SerializedSnapshotType> extends AbstractEventService<EventType> {
|
|
7
|
+
export declare abstract class AbstractSnapshotService<EventType, SerializedEventType, SnapshotPayloadType, SerializedSnapshotType> extends AbstractEventService<EventType, SerializedEventType> {
|
|
8
8
|
private savedLatestBlockNumber;
|
|
9
|
+
private chainId;
|
|
9
10
|
protected constructor(blockchainEventEmitter: BlockchainEventEmitter, eventName: string);
|
|
10
11
|
init(): Promise<void>;
|
|
11
12
|
retrieveEventsFromLatestBlock(): Promise<void>;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { saveDepths as e } from "../../../constants/save-depths.mjs";
|
|
2
2
|
import { AbstractEventService as a } from "./AbstractEventService.mjs";
|
|
3
|
-
|
|
3
|
+
import { getProviderFromContract as o } from "../../../functions/utils/getSignerFromContract.mjs";
|
|
4
|
+
class n extends a {
|
|
4
5
|
savedLatestBlockNumber = 0;
|
|
6
|
+
chainId = 0;
|
|
5
7
|
constructor(t, s) {
|
|
6
8
|
super(t, s);
|
|
7
9
|
}
|
|
8
10
|
async init() {
|
|
9
11
|
await this.loadSnapshot();
|
|
12
|
+
const t = o(this.blockchainEventEmitter.contract);
|
|
13
|
+
this.chainId = Number((await t.getNetwork()).chainId);
|
|
10
14
|
}
|
|
11
15
|
async retrieveEventsFromLatestBlock() {
|
|
12
16
|
await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber);
|
|
@@ -28,5 +32,5 @@ class r extends a {
|
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
export {
|
|
31
|
-
|
|
35
|
+
n as AbstractSnapshotService
|
|
32
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../../constants/reorg-depths.constants.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("ethers"),y=require("../../../constants/reorg-depths.constants.cjs"),h=require("../../../functions/utils/resolve-sync.utils.cjs"),f=require("../../../functions/utils/mutexes.utils.cjs"),d=require("../../../functions/utils/getSignerFromContract.cjs");class E{contract;depositOnChainUtxosContract;_latestBlockNumber;_initialBlockNumber;onEventsProcessed;eventProcessors=new Set;maxPageSize;isReady=!1;isServer;intervalId;inProgress;eventsFetchingMutex;constructor(e,r,u,s,i,a=f.balanceFetchingMutex){this.contract=e,this.depositOnChainUtxosContract=i,this._initialBlockNumber=r,this.maxPageSize=s,this.isServer=u,this.inProgress=!1,this.eventsFetchingMutex=a}get latestBlockNumber(){return this._latestBlockNumber??this._initialBlockNumber}syncFromAtMost(e){(this._latestBlockNumber===void 0||e<this._latestBlockNumber)&&(this._latestBlockNumber=e)}intervalClear(){this.isReady=!1,this.eventProcessors=new Set,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")}addEventProcessorFunction(e){if(this.isReady)throw new Error("Can't add event processor after event emitter initialized");this.eventProcessors.add(e)}async getLastBlockNumberForEventRequest(){const e=await d.getProviderFromContract(this.contract).getBlockNumber();if(!this.isServer)return e;const{chainId:r}=await d.getProviderFromContract(this.contract).getNetwork();return Math.max(this.latestBlockNumber,e-y.blockReorgDepth[Number(r)]+1)}async retrieveEvents(e,r=!1){return this.requireReady(),await this.eventsFetchingMutex.runExclusive(async()=>{try{if(this.inProgress&&!r)return!1;this.inProgress=!0;let s=0;const i=await this.getLastBlockNumberForEventRequest();if(i<e)return this.inProgress=!1,!1;const a=h.getSequence(e,i,this.maxPageSize),o=[];if(await h.resolveSync(a.map(({from:t,to:n})=>async()=>{const c=(await this.contract.queryFilter("*",t,n)).filter(l=>l instanceof v.ethers.EventLog);o.push(...c)})),this.depositOnChainUtxosContract){const{depositOnChainUtxosContract:t}=this;await h.resolveSync(a.map(({from:n,to:c})=>async()=>{const l=(await t.queryFilter("*",n,c)).filter(g=>g instanceof v.ethers.EventLog);o.push(...l)}))}const m=await Promise.all([...this.eventProcessors].map(t=>t(o)));return this._latestBlockNumber=i,s+=m.reduce((t,n)=>t+n,0),this.onEventsProcessed?.(s),this.inProgress=!1,!0}catch(s){return console.log("retrieveEvents error:",{err:s}),this.inProgress=!1,!1}})}}exports.BlockchainEventEmitter=E;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { Mutex } from 'async-mutex';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare abstract class BlockchainEventEmitter {
|
|
6
|
-
private readonly _chainId;
|
|
3
|
+
export type EventProcessorFunction = (events: ethers.EventLog[]) => Promise<number> | number;
|
|
4
|
+
export declare class BlockchainEventEmitter {
|
|
7
5
|
readonly contract: ethers.Contract;
|
|
8
6
|
readonly depositOnChainUtxosContract?: ethers.Contract;
|
|
9
7
|
private _latestBlockNumber;
|
|
@@ -13,11 +11,11 @@ export declare abstract class BlockchainEventEmitter {
|
|
|
13
11
|
private readonly maxPageSize?;
|
|
14
12
|
private isReady;
|
|
15
13
|
private isServer;
|
|
14
|
+
private intervalId?;
|
|
16
15
|
private inProgress;
|
|
17
|
-
|
|
18
|
-
constructor(
|
|
16
|
+
private eventsFetchingMutex;
|
|
17
|
+
constructor(contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, maxPageSize?: number, depositOnChainUtxosContract?: ethers.Contract, eventsFetchingMutex?: Mutex);
|
|
19
18
|
get latestBlockNumber(): number;
|
|
20
|
-
get chainId(): number;
|
|
21
19
|
syncFromAtMost(blockNumber: number): void;
|
|
22
20
|
intervalClear(): void;
|
|
23
21
|
init(): Promise<void>;
|
|
@@ -25,7 +23,4 @@ export declare abstract class BlockchainEventEmitter {
|
|
|
25
23
|
addEventProcessorFunction(eventProcessorFunction: EventProcessorFunction): void;
|
|
26
24
|
private getLastBlockNumberForEventRequest;
|
|
27
25
|
retrieveEvents(fromBlockNumber: number, useForce?: boolean): Promise<boolean>;
|
|
28
|
-
protected processEvents(events: BlockchainEvent[]): Promise<void>;
|
|
29
|
-
protected abstract clear(): void;
|
|
30
|
-
protected abstract startUpdateListener(): Promise<void> | void;
|
|
31
26
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ethers as u } from "ethers";
|
|
2
|
+
import { blockReorgDepth as g } from "../../../constants/reorg-depths.constants.mjs";
|
|
3
|
+
import { getSequence as y, resolveSync as v } from "../../../functions/utils/resolve-sync.utils.mjs";
|
|
4
|
+
import { balanceFetchingMutex as E } from "../../../functions/utils/mutexes.utils.mjs";
|
|
5
|
+
import { getProviderFromContract as m } from "../../../functions/utils/getSignerFromContract.mjs";
|
|
6
|
+
class b {
|
|
6
7
|
contract;
|
|
7
8
|
depositOnChainUtxosContract;
|
|
8
9
|
_latestBlockNumber;
|
|
@@ -12,28 +13,28 @@ class g {
|
|
|
12
13
|
maxPageSize;
|
|
13
14
|
isReady = !1;
|
|
14
15
|
isServer;
|
|
16
|
+
intervalId;
|
|
15
17
|
inProgress;
|
|
16
18
|
// to remove race conditions
|
|
17
19
|
eventsFetchingMutex;
|
|
18
|
-
constructor(t,
|
|
19
|
-
this.contract =
|
|
20
|
+
constructor(t, r, h, s, i, n = E) {
|
|
21
|
+
this.contract = t, this.depositOnChainUtxosContract = i, this._initialBlockNumber = r, this.maxPageSize = s, this.isServer = h, this.inProgress = !1, this.eventsFetchingMutex = n;
|
|
20
22
|
}
|
|
21
23
|
get latestBlockNumber() {
|
|
22
24
|
return this._latestBlockNumber ?? this._initialBlockNumber;
|
|
23
25
|
}
|
|
24
|
-
get chainId() {
|
|
25
|
-
return this._chainId;
|
|
26
|
-
}
|
|
27
26
|
syncFromAtMost(t) {
|
|
28
27
|
(this._latestBlockNumber === void 0 || t < this._latestBlockNumber) && (this._latestBlockNumber = t);
|
|
29
28
|
}
|
|
30
29
|
intervalClear() {
|
|
31
|
-
this.isReady = !1, this.eventProcessors = /* @__PURE__ */ new Set(), this.
|
|
30
|
+
this.isReady = !1, this.eventProcessors = /* @__PURE__ */ new Set(), clearInterval(this.intervalId);
|
|
32
31
|
}
|
|
33
32
|
async init() {
|
|
34
33
|
if (this.isReady)
|
|
35
34
|
throw new Error("Already initialized");
|
|
36
|
-
this.isReady = !0, await this.retrieveEvents(this.latestBlockNumber + 1),
|
|
35
|
+
this.isReady = !0, await this.retrieveEvents(this.latestBlockNumber + 1), this.intervalId = setInterval(async () => {
|
|
36
|
+
await this.retrieveEvents(this.latestBlockNumber);
|
|
37
|
+
}, 3500);
|
|
37
38
|
}
|
|
38
39
|
requireReady() {
|
|
39
40
|
if (!this.isReady)
|
|
@@ -45,50 +46,49 @@ class g {
|
|
|
45
46
|
this.eventProcessors.add(t);
|
|
46
47
|
}
|
|
47
48
|
async getLastBlockNumberForEventRequest() {
|
|
48
|
-
const t = await this.contract.
|
|
49
|
+
const t = await m(this.contract).getBlockNumber();
|
|
49
50
|
if (!this.isServer)
|
|
50
51
|
return t;
|
|
51
|
-
const { chainId:
|
|
52
|
-
return Math.max(this.latestBlockNumber, t -
|
|
52
|
+
const { chainId: r } = await m(this.contract).getNetwork();
|
|
53
|
+
return Math.max(this.latestBlockNumber, t - g[Number(r)] + 1);
|
|
53
54
|
}
|
|
54
|
-
async retrieveEvents(t,
|
|
55
|
+
async retrieveEvents(t, r = !1) {
|
|
55
56
|
return this.requireReady(), await this.eventsFetchingMutex.runExclusive(async () => {
|
|
56
57
|
try {
|
|
57
|
-
if (this.inProgress && !
|
|
58
|
+
if (this.inProgress && !r)
|
|
58
59
|
return !1;
|
|
59
60
|
this.inProgress = !0;
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
let s = 0;
|
|
62
|
+
const i = await this.getLastBlockNumberForEventRequest();
|
|
63
|
+
if (i < t)
|
|
62
64
|
return this.inProgress = !1, !1;
|
|
63
|
-
const
|
|
64
|
-
if (await
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
65
|
+
const n = y(t, i, this.maxPageSize), o = [];
|
|
66
|
+
if (await v(
|
|
67
|
+
n.map(({ from: e, to: a }) => async () => {
|
|
68
|
+
const c = (await this.contract.queryFilter("*", e, a)).filter(
|
|
69
|
+
(l) => l instanceof u.EventLog
|
|
70
|
+
);
|
|
71
|
+
o.push(...c);
|
|
68
72
|
})
|
|
69
73
|
), this.depositOnChainUtxosContract) {
|
|
70
|
-
const { depositOnChainUtxosContract:
|
|
71
|
-
await
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
74
|
+
const { depositOnChainUtxosContract: e } = this;
|
|
75
|
+
await v(
|
|
76
|
+
n.map(({ from: a, to: c }) => async () => {
|
|
77
|
+
const l = (await e.queryFilter("*", a, c)).filter((f) => f instanceof u.EventLog);
|
|
78
|
+
o.push(...l);
|
|
75
79
|
})
|
|
76
80
|
);
|
|
77
81
|
}
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
+
const d = await Promise.all(
|
|
83
|
+
[...this.eventProcessors].map((e) => e(o))
|
|
84
|
+
);
|
|
85
|
+
return this._latestBlockNumber = i, s += d.reduce((e, a) => e + a, 0), this.onEventsProcessed?.(s), this.inProgress = !1, !0;
|
|
86
|
+
} catch (s) {
|
|
87
|
+
return console.log("retrieveEvents error:", { err: s }), this.inProgress = !1, !1;
|
|
82
88
|
}
|
|
83
89
|
});
|
|
84
90
|
}
|
|
85
|
-
async processEvents(t) {
|
|
86
|
-
const n = (await Promise.all(
|
|
87
|
-
[...this.eventProcessors].map((e) => e(t))
|
|
88
|
-
)).reduce((e, r) => e + r, 0);
|
|
89
|
-
this.onEventsProcessed?.(n);
|
|
90
|
-
}
|
|
91
91
|
}
|
|
92
92
|
export {
|
|
93
|
-
|
|
93
|
+
b as BlockchainEventEmitter
|
|
94
94
|
};
|
|
@@ -5,11 +5,7 @@ export * from './evm/AbstractNullifierSnapshotService';
|
|
|
5
5
|
export * from './evm/AbstractSnapshotService';
|
|
6
6
|
export * from './evm/AbstractEventService';
|
|
7
7
|
export * from './evm/BlockchainEventEmitter';
|
|
8
|
-
export * from './evm/PollingBlockchainEventEmitter';
|
|
9
|
-
export * from './evm/ClientBlockchainEventEmitter';
|
|
10
8
|
export * from './solana/SolanaBlockchainEventEmitter';
|
|
11
|
-
export * from './solana/ClientSolanaBlockchainEventEmitter';
|
|
12
|
-
export * from './solana/PollingSolanaBlockchainEventEmitter';
|
|
13
9
|
export * from './solana/AbstractSolanaEventService';
|
|
14
10
|
export * from './solana/AbstractSolanaSnapshotService';
|
|
15
11
|
export * from './solana/AbstractSolanaNullifierSnapshotService';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../../constants/protocol.constants.cjs"),c=require("../../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const n=require("../../../functions/utils/amounts.utils.cjs"),o=require("../../merkle-tree/MerkleTree.cjs");require("ethers");require("../../../error-handling/error-codes.constants.cjs");const l=require("./AbstractSolanaSnapshotService.cjs"),i=require("../../../functions/utils/merkleTree.utils.cjs"),u=require("@solana/web3.js");class A extends l.AbstractSolanaSnapshotService{constructor(e){super(e,"NewAccessKeyAdded")}_merkleTree;_senderAddresses;_senderAddressIndexMap;get merkleTree(){return this._merkleTree}get senderAddresses(){return this._senderAddresses}get senderAddressIndexMap(){return this._senderAddressIndexMap}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),senderAddresses:Array.from(e.payload.senderAddresses),latestBlockNumber:e.latestBlockNumber,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;return e.latestBlockNumber&&e.merkleTree?s=i.contructMerkleTreeFromSerialized(e.merkleTree):s=o.MerkleTree.create(c.poseidonFunction,0n),e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:t})=>[d,t])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.access_key,e.index),this._senderAddressIndexMap.set(e.sender_address,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.sender_address)??0)),this._senderAddresses.includes(e.sender_address)||this._senderAddresses.push(e.sender_address),e.access_key===0n&&e.sender_address===a.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../../constants/protocol.constants.cjs"),c=require("../../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const n=require("../../../functions/utils/amounts.utils.cjs"),o=require("../../merkle-tree/MerkleTree.cjs");require("ethers");require("../../../error-handling/error-codes.constants.cjs");const l=require("./AbstractSolanaSnapshotService.cjs"),i=require("../../../functions/utils/merkleTree.utils.cjs"),u=require("@solana/web3.js");class A extends l.AbstractSolanaSnapshotService{constructor(e){super(e,"NewAccessKeyAdded")}_merkleTree;_senderAddresses;_senderAddressIndexMap;get merkleTree(){return this._merkleTree}get senderAddresses(){return this._senderAddresses}get senderAddressIndexMap(){return this._senderAddressIndexMap}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),senderAddresses:Array.from(e.payload.senderAddresses),latestBlockNumber:e.latestBlockNumber,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;return e.latestBlockNumber&&e.merkleTree?s=i.contructMerkleTreeFromSerialized(e.merkleTree):s=o.MerkleTree.create(c.poseidonFunction,0n),e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:t})=>[d,t])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.access_key,e.index),this._senderAddressIndexMap.set(e.sender_address,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.sender_address)??0)),this._senderAddresses.includes(e.sender_address)||this._senderAddresses.push(e.sender_address),e.access_key===0n&&e.sender_address===a.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const{access_key:s,index:r,sender_address:d}=e;return{access_key:n.advancedToBigInt(s),index:n.advancedToBigInt(r),sender_address:new u.PublicKey(d).toBase58()}}getSnapshotPayload(){return{merkleTree:this._merkleTree,senderAddresses:this._senderAddresses,senderAddressIndexMap:this._senderAddressIndexMap}}populateSnapshot({payload:{merkleTree:e,senderAddresses:s,senderAddressIndexMap:r}}){this._merkleTree=e,this._senderAddresses=s,this._senderAddressIndexMap=r}}exports.AbstractSolanaAccessTokenSnapshotService=A;
|
|
@@ -2,7 +2,6 @@ import { MerkleTree, MerkleTreeJson } from '../../merkle-tree';
|
|
|
2
2
|
import { SolanaAccessTokenEvent } from '../../../types';
|
|
3
3
|
import { AbstractSolanaSnapshotService, SolanaSnapshot } from './AbstractSolanaSnapshotService';
|
|
4
4
|
import { SolanaBlockchainEventEmitter } from './SolanaBlockchainEventEmitter';
|
|
5
|
-
import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
|
|
6
5
|
export type SolanaSenderAddressIndexMapJson = {
|
|
7
6
|
address: string;
|
|
8
7
|
index: number;
|
|
@@ -18,7 +17,7 @@ export type SolanaAccessTokenSerializedSnapshot = {
|
|
|
18
17
|
senderAddresses?: string[];
|
|
19
18
|
senderAddressIndexMap?: SolanaSenderAddressIndexMapJson;
|
|
20
19
|
};
|
|
21
|
-
export declare abstract class AbstractSolanaAccessTokenSnapshotService extends AbstractSolanaSnapshotService<SolanaAccessTokenEvent<bigint, string>, SolanaAccessTokenSnapshotPayload, SolanaAccessTokenSerializedSnapshot> {
|
|
20
|
+
export declare abstract class AbstractSolanaAccessTokenSnapshotService extends AbstractSolanaSnapshotService<SolanaAccessTokenEvent<bigint, string>, SolanaAccessTokenEvent<number[], number[]>, SolanaAccessTokenSnapshotPayload, SolanaAccessTokenSerializedSnapshot> {
|
|
22
21
|
constructor(accessTokenEventFetcher: SolanaBlockchainEventEmitter);
|
|
23
22
|
private _merkleTree;
|
|
24
23
|
private _senderAddresses;
|
|
@@ -29,7 +28,7 @@ export declare abstract class AbstractSolanaAccessTokenSnapshotService extends A
|
|
|
29
28
|
protected serializeSnapshot(snapshot: SolanaSnapshot<SolanaAccessTokenSnapshotPayload>): SolanaAccessTokenSerializedSnapshot;
|
|
30
29
|
protected deserializeSnapshot(serializedSnapshot: SolanaAccessTokenSerializedSnapshot): SolanaSnapshot<SolanaAccessTokenSnapshotPayload>;
|
|
31
30
|
protected acceptEvent(event: SolanaAccessTokenEvent<bigint, string>, _slot: number): boolean;
|
|
32
|
-
protected mapEvent(event:
|
|
31
|
+
protected mapEvent(event: SolanaAccessTokenEvent<number[], number[]>): SolanaAccessTokenEvent<bigint, string>;
|
|
33
32
|
protected getSnapshotPayload(): SolanaAccessTokenSnapshotPayload;
|
|
34
33
|
protected populateSnapshot({ payload: { merkleTree, senderAddresses, senderAddressIndexMap }, }: SolanaSnapshot<SolanaAccessTokenSnapshotPayload>): void;
|
|
35
34
|
}
|
|
@@ -8,10 +8,10 @@ import { advancedToBigInt as t } from "../../../functions/utils/amounts.utils.mj
|
|
|
8
8
|
import { MerkleTree as m } from "../../merkle-tree/MerkleTree.mjs";
|
|
9
9
|
import "ethers";
|
|
10
10
|
import "../../../error-handling/error-codes.constants.mjs";
|
|
11
|
-
import { AbstractSolanaSnapshotService as
|
|
12
|
-
import { contructMerkleTreeFromSerialized as
|
|
11
|
+
import { AbstractSolanaSnapshotService as l } from "./AbstractSolanaSnapshotService.mjs";
|
|
12
|
+
import { contructMerkleTreeFromSerialized as c } from "../../../functions/utils/merkleTree.utils.mjs";
|
|
13
13
|
import { PublicKey as p } from "@solana/web3.js";
|
|
14
|
-
class
|
|
14
|
+
class B extends l {
|
|
15
15
|
constructor(e) {
|
|
16
16
|
super(e, "NewAccessKeyAdded");
|
|
17
17
|
}
|
|
@@ -40,7 +40,7 @@ class N extends c {
|
|
|
40
40
|
}
|
|
41
41
|
deserializeSnapshot(e) {
|
|
42
42
|
let s, r;
|
|
43
|
-
return e.latestBlockNumber && e.merkleTree ? s =
|
|
43
|
+
return e.latestBlockNumber && e.merkleTree ? s = c(e.merkleTree) : s = m.create(o, 0n), e.latestBlockNumber && e.senderAddressIndexMap ? r = new Map(
|
|
44
44
|
e.senderAddressIndexMap.map(({ address: d, index: n }) => [d, n])
|
|
45
45
|
) : r = /* @__PURE__ */ new Map(), {
|
|
46
46
|
latestBlockNumber: e.latestBlockNumber ?? 0,
|
|
@@ -62,7 +62,7 @@ class N extends c {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
mapEvent(e) {
|
|
65
|
-
const
|
|
65
|
+
const { access_key: s, index: r, sender_address: d } = e;
|
|
66
66
|
return {
|
|
67
67
|
access_key: t(s),
|
|
68
68
|
index: t(r),
|
|
@@ -83,5 +83,5 @@ class N extends c {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
export {
|
|
86
|
-
|
|
86
|
+
B as AbstractSolanaAccessTokenSnapshotService
|
|
87
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const m=require("../../merkle-tree/MerkleTree.cjs");require("ethers");require("../../../error-handling/error-codes.constants.cjs");const c=require("../../../functions/utils/amounts.utils.cjs"),d=require("./AbstractSolanaSnapshotService.cjs"),y=require("../../../functions/utils/merkleTree.utils.cjs"),o=require("../../crypto-keys/decodeUTXO.cjs");class O extends d.AbstractSolanaSnapshotService{constructor(e){super(e,"NewCommitment")}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive),isBlocked:t.isBlocked??!1}))}}deserializeSnapshot(e){let t;e.latestBlockNumber&&e.merkleTree?t=y.contructMerkleTreeFromSerialized(e.merkleTree):t=m.MerkleTree.create(p.poseidonFunction,0n);const n=e.encryptedOutputs?.map(r=>({value:r.value,isPositive:JSON.parse(r.isPositive),isBlocked:r.isBlocked??!1}));return{latestBlockNumber:e.latestBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:n||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}async mapEvent(e){const{commitment:t,index:n,encrypted_output:r,on_chain_data:s}=e,i=c.advancedToBigInt(t),u=c.advancedToBigInt(n);if(r.length===0){const l=o.encodeSolanaOnChainUtxo(s);return{commitment:i,index:u,encryptedOutput:l}}const a=`0x${Buffer.from(r).toString("hex")}`;return{commitment:i,index:u,encryptedOutput:a}}acceptEvent(e,t,n,r){if(!this.encryptedOutputs.map(s=>s.value).includes(e.encryptedOutput)){if(!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return!1;const i={value:e.encryptedOutput,isPositive:!o.isSolanaOnChainUtxo(e.encryptedOutput),isBlocked:r??!1};return this._encryptedOutputs.push(i),!0}return!1}}exports.AbstractSolanaCommitmentsSnapshotService=O;
|