@hinkal/common 0.2.17 → 0.2.19
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 +8 -13
- package/API/API.mjs +86 -94
- package/API/admin-calls.cjs +1 -1
- package/API/admin-calls.d.ts +1 -1
- package/API/admin-calls.mjs +4 -4
- 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 +10 -11
- package/API/callRelayer.cjs +1 -1
- package/API/callRelayer.d.ts +6 -3
- 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/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/get-token-price-chart-data.cjs +1 -0
- package/API/get-token-price-chart-data.d.ts +16 -0
- package/API/get-token-price-chart-data.mjs +13 -0
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.mjs +9 -9
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.d.ts +3 -3
- package/API/getServerURL.mjs +51 -67
- package/API/getTokenPrice.cjs +1 -1
- package/API/getTokenPrice.d.ts +5 -0
- package/API/getTokenPrice.mjs +14 -7
- package/API/getWebsiteURL.d.ts +1 -1
- package/API/index.d.ts +0 -3
- package/API/is-tx-stateless.cjs +1 -1
- package/API/is-tx-stateless.d.ts +1 -1
- package/API/is-tx-stateless.mjs +10 -12
- package/API/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +4 -8
- package/API/kycCalls.mjs +23 -26
- package/API/onrampCalls.cjs +1 -0
- package/API/onrampCalls.d.ts +20 -0
- package/API/onrampCalls.mjs +15 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +2 -2
- package/API/proxyAccountsCalls.mjs +19 -19
- package/API/relayCalls.cjs +1 -1
- package/API/relayCalls.mjs +4 -4
- package/API/scheduled-transactions-calls.cjs +1 -1
- package/API/scheduled-transactions-calls.d.ts +1 -1
- package/API/scheduled-transactions-calls.mjs +4 -4
- package/API/simulate-batch-tx.cjs +1 -1
- package/API/simulate-batch-tx.d.ts +2 -2
- package/API/simulate-batch-tx.mjs +7 -6
- package/API/solana-calls.cjs +1 -1
- package/API/solana-calls.d.ts +6 -3
- package/API/solana-calls.mjs +15 -15
- package/API/token-calls.cjs +1 -1
- package/API/token-calls.mjs +6 -5
- package/API/unspent-utxos-calls.cjs +1 -1
- package/API/unspent-utxos-calls.d.ts +1 -1
- package/API/unspent-utxos-calls.mjs +15 -18
- package/README.md +237 -61
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.d.ts +0 -1
- package/constants/addresses.constants.mjs +7 -8
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +0 -5
- package/constants/chains.constants.mjs +21 -26
- package/constants/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.d.ts +1 -0
- package/constants/coingecko.constants.mjs +11 -10
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +34 -41
- package/constants/function-signatures.constants.cjs +1 -1
- package/constants/function-signatures.constants.d.ts +0 -1
- package/constants/function-signatures.constants.mjs +3 -4
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +2 -0
- package/constants/mediaUrls.constants.mjs +3 -1
- package/constants/mystery-boxes.constants.d.ts +0 -0
- package/constants/permit2.constants.cjs +1 -1
- package/constants/permit2.constants.d.ts +0 -1
- package/constants/permit2.constants.mjs +10 -11
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +14 -122
- package/constants/server.constants.mjs +44 -152
- package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistry.json.mjs +0 -24
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +0 -24
- package/constants/token-data/index.d.ts +32 -88
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +0 -26
- package/constants/token-data/popularTokens.constants.cjs +1 -1
- package/constants/token-data/popularTokens.constants.mjs +0 -1
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +36 -13
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +34 -49
- package/data-structures/Hinkal/Hinkal.mjs +238 -301
- package/data-structures/Hinkal/IHinkal.d.ts +33 -48
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +42 -42
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -23
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +9 -9
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +95 -93
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +147 -133
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +1 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +107 -115
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +36 -34
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +34 -33
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.d.ts +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +26 -24
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +8 -9
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +4 -3
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +86 -97
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +146 -146
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +2 -3
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +38 -38
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +57 -56
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +59 -58
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +83 -79
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +49 -48
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +67 -64
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +75 -87
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.d.ts +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +55 -58
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +80 -82
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.d.ts +2 -2
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +87 -90
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +105 -53
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.mjs +7 -7
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +8 -8
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +10 -10
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +25 -40
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +10 -11
- package/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
- package/data-structures/TokenDBs/token-visibility-db.mjs +22 -36
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.d.ts +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +14 -14
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +1 -0
- package/data-structures/event-service/evm/AbstractEventService.mjs +7 -4
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +0 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +3 -4
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +3 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +17 -14
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +1 -0
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +9 -6
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +0 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +1 -2
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +3 -2
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +42 -45
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +8 -13
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +3 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +3 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +2 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +3 -4
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +1 -7
- package/data-structures/utxo/Utxo.mjs +26 -36
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +3 -0
- package/error-handling/error-codes.constants.mjs +5 -2
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +21 -27
- package/error-handling/index.d.ts +0 -1
- package/functions/index.d.ts +0 -1
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +18 -17
- package/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/functions/pre-transaction/constructAdminData.d.ts +2 -2
- package/functions/pre-transaction/constructAdminData.mjs +12 -18
- package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/functions/pre-transaction/getExternalSwapAddress.d.ts +1 -2
- package/functions/pre-transaction/getExternalSwapAddress.mjs +8 -8
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +22 -30
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +21 -36
- 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 +1 -9
- package/functions/pre-transaction/outputApprovalDataProcessing.mjs +19 -34
- 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/pre-transaction/solana-public-signals.cjs +1 -1
- package/functions/pre-transaction/solana-public-signals.d.ts +1 -0
- package/functions/pre-transaction/solana-public-signals.mjs +29 -26
- package/functions/pre-transaction/solana.cjs +1 -1
- package/functions/pre-transaction/solana.d.ts +2 -1
- package/functions/pre-transaction/solana.mjs +60 -51
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +3 -5
- package/functions/private-wallet/emporium.helpers.mjs +95 -135
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.d.ts +1 -4
- package/functions/private-wallet/emporium.swap.helpers.mjs +100 -102
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.d.ts +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +64 -64
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +2 -2
- package/functions/snarkjs/constructEmporiumProof.mjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +2 -3
- package/functions/snarkjs/constructGeneralZkProof.mjs +117 -121
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.d.ts +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +54 -59
- package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
- package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +11 -10
- package/functions/snarkjs/generateCircomData.d.ts +1 -1
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.d.ts +1 -0
- package/functions/utils/addresses.mjs +13 -12
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +2 -2
- package/functions/utils/enum.utils.cjs +1 -0
- package/functions/utils/enum.utils.mjs +14 -0
- package/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/functions/utils/erc20tokenFunctions.d.ts +0 -1
- package/functions/utils/erc20tokenFunctions.mjs +22 -29
- package/functions/utils/get-hinkal-approvals.cjs +1 -1
- package/functions/utils/get-hinkal-approvals.d.ts +1 -1
- package/functions/utils/get-hinkal-approvals.mjs +16 -16
- package/functions/utils/getDataFromTransaction.d.ts +3 -3
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +11 -11
- package/functions/utils/involves-permit2-op.cjs +1 -1
- package/functions/utils/involves-permit2-op.d.ts +0 -1
- package/functions/utils/involves-permit2-op.mjs +4 -6
- 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 +8 -23
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +0 -6
- package/functions/utils/prepareHinkal.mjs +41 -60
- package/functions/utils/token-check.utils.cjs +1 -1
- package/functions/utils/token-check.utils.d.ts +3 -0
- package/functions/utils/token-check.utils.mjs +18 -7
- 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 +1 -16
- package/functions/utils/walletBalances.utils.mjs +4 -35
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.d.ts +3 -4
- package/functions/web3/events/getApprovedBalance.mjs +39 -44
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.d.ts +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.mjs +114 -121
- package/functions/web3/events/getInputUtxosEnclave.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.mjs +71 -70
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.mjs +7 -7
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +7 -7
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +1 -6
- package/functions/web3/functionCalls/accessTokenCalls.mjs +12 -21
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +71 -63
- 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/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.d.ts +1 -2
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +10 -10
- package/functions/web3/functionCalls/recoverTransactionFromError.cjs +1 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +2 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.mjs +23 -0
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +45 -36
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +44 -43
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.d.ts +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +6 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +8 -8
- 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 +6 -19
- package/functions/web3/okxAPI.cjs +1 -1
- package/functions/web3/okxAPI.mjs +22 -22
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +7 -20
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +38 -56
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +22 -34
- package/index.cjs +1 -1
- package/index.mjs +937 -967
- package/package.json +2 -2
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +10 -17
- package/providers/EthersProviderAdapter.mjs +48 -76
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +7 -11
- package/providers/SolanaProviderAdapter.mjs +16 -31
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +11 -17
- package/providers/WagmiProviderAdapter.mjs +86 -117
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +6 -7
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +5 -5
- package/types/TransactionSimulator.types.d.ts +2 -9
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +3 -7
- package/types/admin.types.mjs +2 -2
- package/types/balances.types.d.ts +0 -1
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +2 -3
- package/types/cache.types.mjs +1 -1
- package/types/coingecko.types.d.ts +5 -0
- package/types/ethereum-network.types.cjs +1 -1
- package/types/ethereum-network.types.d.ts +1 -8
- package/types/ethereum-network.types.mjs +1 -1
- package/types/external-action.types.cjs +1 -1
- package/types/external-action.types.d.ts +0 -1
- package/types/external-action.types.mjs +1 -1
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +1 -7
- package/types/hinkal.types.mjs +22 -23
- package/types/index.d.ts +1 -3
- package/types/onramp.types.cjs +1 -0
- package/types/onramp.types.d.ts +58 -0
- package/types/onramp.types.mjs +4 -0
- package/types/proxy.types.d.ts +1 -0
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +8 -39
- package/types/sandbox.types.mjs +2 -2
- package/types/session.types.d.ts +2 -0
- package/types/solana.types.d.ts +3 -0
- package/types/token-prices.types.cjs +1 -1
- package/types/token-prices.types.d.ts +7 -0
- package/types/token-prices.types.mjs +4 -2
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +6 -4
- package/types/transactions.types.mjs +4 -3
- 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/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/API/ai-calls.cjs +0 -1
- package/API/ai-calls.d.ts +0 -17
- package/API/ai-calls.mjs +0 -21
- package/API/duneAPI.cjs +0 -1
- package/API/duneAPI.d.ts +0 -11
- package/API/duneAPI.mjs +0 -25
- package/API/getBridgeProtocols.cjs +0 -1
- package/API/getBridgeProtocols.d.ts +0 -7
- package/API/getBridgeProtocols.mjs +0 -8
- package/API/getLifiStatus.cjs +0 -1
- package/API/getLifiStatus.d.ts +0 -24
- package/API/getLifiStatus.mjs +0 -15
- package/API/getRelayerURL.cjs +0 -1
- package/API/getRelayerURL.d.ts +0 -1
- package/API/getRelayerURL.mjs +0 -10
- package/API/passwordCalls.cjs +0 -1
- package/API/passwordCalls.d.ts +0 -9
- package/API/passwordCalls.mjs +0 -13
- package/API/restoreSnapshots.cjs +0 -1
- package/API/restoreSnapshots.d.ts +0 -1
- package/API/restoreSnapshots.mjs +0 -10
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +0 -1
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +0 -7
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +0 -42
- package/data-structures/Hinkal/hinkalActionStake.d.ts +0 -3
- package/data-structures/Hinkal/hinkalApprove.cjs +0 -1
- package/data-structures/Hinkal/hinkalApprove.d.ts +0 -3
- package/data-structures/Hinkal/hinkalApprove.mjs +0 -115
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +0 -1
- package/data-structures/Hinkal/hinkalInsideTransact.d.ts +0 -4
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +0 -121
- package/error-handling/handleErrorRestore.cjs +0 -1
- package/error-handling/handleErrorRestore.d.ts +0 -2
- package/error-handling/handleErrorRestore.mjs +0 -11
- package/functions/staking/index.cjs +0 -1
- package/functions/staking/index.d.ts +0 -11
- package/functions/staking/index.mjs +0 -42
- package/functions/utils/replaceAddressInCalldata.cjs +0 -1
- package/functions/utils/replaceAddressInCalldata.d.ts +0 -1
- package/functions/utils/replaceAddressInCalldata.mjs +0 -7
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +0 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +0 -5
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +0 -32
- package/types/bridging.types.d.ts +0 -29
- package/types/duneAPI.types.d.ts +0 -9
- package/types/hinkal.stake.types.cjs +0 -1
- package/types/hinkal.stake.types.d.ts +0 -11
- package/types/hinkal.stake.types.mjs +0 -4
|
@@ -6,28 +6,23 @@ import "../../types/activities.types.mjs";
|
|
|
6
6
|
import "../../constants/chains.constants.mjs";
|
|
7
7
|
import "@coral-xyz/anchor";
|
|
8
8
|
import "@solana/web3.js";
|
|
9
|
-
import "../../constants/kyc.constants.mjs";
|
|
10
9
|
import "ethers";
|
|
10
|
+
import "circomlibjs-hinkal-fork";
|
|
11
|
+
import "../../constants/kyc.constants.mjs";
|
|
11
12
|
import "../http/HttpClient.mjs";
|
|
12
13
|
import "../../constants/token-data/index.mjs";
|
|
13
14
|
import "../../error-handling/error-codes.constants.mjs";
|
|
14
15
|
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
15
|
-
import "circomlibjs-hinkal-fork";
|
|
16
16
|
import "../crypto-keys/keys.mjs";
|
|
17
17
|
import "../../constants/server.constants.mjs";
|
|
18
|
-
import "../../
|
|
18
|
+
import "../../API/getServerURL.mjs";
|
|
19
19
|
import "axios";
|
|
20
|
+
import "../../constants/vite.constants.mjs";
|
|
20
21
|
import { caseInsensitiveEqual as l } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
21
|
-
import "../../API/getServerURL.mjs";
|
|
22
|
-
import "libsodium-wrappers";
|
|
23
|
-
import "process";
|
|
24
|
-
import "buffer";
|
|
25
|
-
import "../../constants/save-depths.mjs";
|
|
26
|
-
import "../../constants/reorg-depths.constants.mjs";
|
|
27
|
-
import "../../functions/utils/mutexes.utils.mjs";
|
|
28
22
|
import "@solana/spl-token";
|
|
29
23
|
import "../../constants/contracts.constants.mjs";
|
|
30
24
|
import "../../constants/coingecko.constants.mjs";
|
|
25
|
+
import "../../constants/reorg-depths.constants.mjs";
|
|
31
26
|
import "../../constants/addresses.constants.mjs";
|
|
32
27
|
import "../../constants/token.limits.constants.mjs";
|
|
33
28
|
import "../../constants/presale.constants.mjs";
|
|
@@ -35,8 +30,13 @@ import "../../constants/activity.constants.mjs";
|
|
|
35
30
|
import "../../constants/tasks.constants.mjs";
|
|
36
31
|
import "../../constants/events.constants.mjs";
|
|
37
32
|
import "../../functions/utils/userAgent.mjs";
|
|
33
|
+
import "libsodium-wrappers";
|
|
38
34
|
import "multiformats";
|
|
35
|
+
import "async-mutex";
|
|
39
36
|
import "../../API/tenderly.api.mjs";
|
|
37
|
+
import "process";
|
|
38
|
+
import "buffer";
|
|
39
|
+
import "../../providers/EthersProviderAdapter.mjs";
|
|
40
40
|
import "node-forge";
|
|
41
41
|
import "../../functions/web3/events/getApprovedBalance.mjs";
|
|
42
42
|
import "../../functions/web3/getTokenHolder.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("idb-keyval");require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const g=require("../../types/cache.types.cjs");require("../../constants/vite.constants.cjs");const o=require("../../error-handling/logger.cjs");class m{generateMessageId(){const e=new Date().getTime(),t=Math.random().toString(36).substring(2,15);return`msg_${e}_${t}`}async saveSignedMessage(e,t,r,n,S,c){try{const s=this.generateMessageId(),i=await a.get(g.StorageKeys.SIGNED_MESSAGES)||{},d={chainId:e,messageText:t,messageType:r,subAccountAddress:n,signature:S,appMetaData:c};i[s]={timestamp:new Date().toISOString(),...d},await a.set(g.StorageKeys.SIGNED_MESSAGES,i)}catch(s){o.Logger.error("Failed to save signed message:",s,{chainId:e,messageType:r})}}async getAllSignedMessages(){try{const e=await a.get(g.StorageKeys.SIGNED_MESSAGES)||{};return Object.values(e).sort((t,r)=>new Date(r.timestamp).getTime()-new Date(t.timestamp).getTime())}catch(e){return o.Logger.error("Failed to retrieve signed messages:",e),[]}}}const u=new m;exports.signedMessagesStorage=u;
|
|
@@ -1,63 +1,48 @@
|
|
|
1
|
-
import { get as
|
|
1
|
+
import { get as i, set as d } from "idb-keyval";
|
|
2
2
|
import "../../error-handling/error-codes.constants.mjs";
|
|
3
3
|
import "ethers";
|
|
4
4
|
import "../../types/circom-data.types.mjs";
|
|
5
5
|
import "../../types/transactions.types.mjs";
|
|
6
6
|
import "../../types/activities.types.mjs";
|
|
7
|
-
import { StorageKeys as
|
|
8
|
-
import "../../constants/server.constants.mjs";
|
|
9
|
-
import "../../API/getServerURL.mjs";
|
|
10
|
-
import "../http/HttpClient.mjs";
|
|
11
|
-
import "axios";
|
|
12
|
-
import "../../constants/chains.constants.mjs";
|
|
13
|
-
import "circomlibjs-hinkal-fork";
|
|
14
|
-
import "libsodium-wrappers";
|
|
15
|
-
import "process";
|
|
16
|
-
import "buffer";
|
|
7
|
+
import { StorageKeys as a } from "../../types/cache.types.mjs";
|
|
17
8
|
import "../../constants/vite.constants.mjs";
|
|
18
|
-
import "../../
|
|
19
|
-
|
|
20
|
-
import "../../functions/utils/mutexes.utils.mjs";
|
|
21
|
-
import "@coral-xyz/anchor";
|
|
22
|
-
import { Logger as a } from "../../error-handling/logger.mjs";
|
|
23
|
-
import "@solana/web3.js";
|
|
24
|
-
import "../crypto-keys/keys.mjs";
|
|
25
|
-
class d {
|
|
9
|
+
import { Logger as g } from "../../error-handling/logger.mjs";
|
|
10
|
+
class p {
|
|
26
11
|
generateMessageId() {
|
|
27
|
-
const
|
|
28
|
-
return `msg_${
|
|
12
|
+
const e = (/* @__PURE__ */ new Date()).getTime(), t = Math.random().toString(36).substring(2, 15);
|
|
13
|
+
return `msg_${e}_${t}`;
|
|
29
14
|
}
|
|
30
|
-
async saveSignedMessage(
|
|
15
|
+
async saveSignedMessage(e, t, r, n, m, S) {
|
|
31
16
|
try {
|
|
32
|
-
const
|
|
33
|
-
chainId:
|
|
34
|
-
messageText:
|
|
17
|
+
const s = this.generateMessageId(), o = await i(a.SIGNED_MESSAGES) || {}, c = {
|
|
18
|
+
chainId: e,
|
|
19
|
+
messageText: t,
|
|
35
20
|
messageType: r,
|
|
36
|
-
subAccountAddress:
|
|
37
|
-
signature:
|
|
38
|
-
appMetaData:
|
|
21
|
+
subAccountAddress: n,
|
|
22
|
+
signature: m,
|
|
23
|
+
appMetaData: S
|
|
39
24
|
};
|
|
40
|
-
|
|
25
|
+
o[s] = {
|
|
41
26
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
42
|
-
...
|
|
43
|
-
}, await
|
|
44
|
-
} catch (
|
|
45
|
-
|
|
46
|
-
chainId:
|
|
27
|
+
...c
|
|
28
|
+
}, await d(a.SIGNED_MESSAGES, o);
|
|
29
|
+
} catch (s) {
|
|
30
|
+
g.error("Failed to save signed message:", s, {
|
|
31
|
+
chainId: e,
|
|
47
32
|
messageType: r
|
|
48
33
|
});
|
|
49
34
|
}
|
|
50
35
|
}
|
|
51
36
|
async getAllSignedMessages() {
|
|
52
37
|
try {
|
|
53
|
-
const
|
|
54
|
-
return Object.values(
|
|
55
|
-
} catch (
|
|
56
|
-
return
|
|
38
|
+
const e = await i(a.SIGNED_MESSAGES) || {};
|
|
39
|
+
return Object.values(e).sort((t, r) => new Date(r.timestamp).getTime() - new Date(t.timestamp).getTime());
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return g.error("Failed to retrieve signed messages:", e), [];
|
|
57
42
|
}
|
|
58
43
|
}
|
|
59
44
|
}
|
|
60
|
-
const
|
|
45
|
+
const y = new p();
|
|
61
46
|
export {
|
|
62
|
-
|
|
47
|
+
y as signedMessagesStorage
|
|
63
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("ethers"),T=require("idb-keyval"),_=require("../../API/API.cjs"),m=require("../../constants/chains.constants.cjs"),p=require("../../error-handling/logger.cjs"),E=require("../../functions/utils/caseInsensitive.utils.cjs"),g=require("../../types/cache.types.cjs"),d=require("../../functions/utils/string.utils.cjs"),A=require("../../constants/protocol.constants.cjs"),C=require("async-mutex"),S=require("../../functions/utils/erc20tokenFunctions.cjs"),I=require("./token-visibility-db.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("../../constants/kyc.constants.cjs");const K=require("../../functions/utils/create-provider.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("ethers"),T=require("idb-keyval"),_=require("../../API/API.cjs"),m=require("../../constants/chains.constants.cjs"),p=require("../../error-handling/logger.cjs"),E=require("../../functions/utils/caseInsensitive.utils.cjs"),g=require("../../types/cache.types.cjs"),d=require("../../functions/utils/string.utils.cjs"),A=require("../../constants/protocol.constants.cjs"),C=require("async-mutex"),S=require("../../functions/utils/erc20tokenFunctions.cjs"),I=require("./token-visibility-db.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("../../constants/kyc.constants.cjs");const K=require("../../functions/utils/create-provider.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../error-handling/error-codes.constants.cjs");require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");require("@solana/spl-token");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");const x=require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");require("libsodium-wrappers");require("multiformats");require("../../API/tenderly.api.cjs");require("process");require("buffer");require("../../providers/EthersProviderAdapter.cjs");require("node-forge");require("../../functions/web3/events/getApprovedBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");require("ethers-v6h");class P{fetchedTokens={};updateMutexes={};transferEventTopic=k.ethers.utils.id("Transfer(address,address,uint256)");getMutex(r){return this.updateMutexes[r]||(this.updateMutexes[r]=new C.Mutex),this.updateMutexes[r]}async getPublicTokens(r,o){const t=d.getStateKey(o,r);return(await T.get(g.StorageKeys.EVENTS_PUBLIC_TOKENS))?.[t]||[]}getFetchedTokens(r,o){const t=d.getStateKey(o,r);return this.fetchedTokens[t]||[]}async fetchAndUpdatePublicTokens(r,o){const t=d.getStateKey(r,o);await this.getMutex(t).runExclusive(async()=>{try{const s=(await this.getPublicTokens(o,r)).map(a=>a.erc20TokenAddress),{toEvents:i,fromEvents:u,latestBlock:c}=await this.getEvents(r,o),q=[...i,...u],{erc20Tokens:l}=await this.fetchPublicTokens(q,o,s),b=await I.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(o,l),B=l.filter(a=>!E.lowerCaseIncludes(b,a.erc20TokenAddress));await T.update(g.StorageKeys.EVENTS_PUBLIC_TOKENS,(a={})=>{const h=a[t]||[],w=h.map(f=>f.erc20TokenAddress),L=B.filter(f=>!E.lowerCaseIncludes(w,f.erc20TokenAddress));h.push(...L);const v=this.updateTokenIds(u,i,h),y={...a,[t]:v};return this.fetchedTokens=y,y}),c&&await this.updateLastProcessedBlock(o,r,c)}catch(e){p.Logger.error("public tokens db error",e)}})}async getLastProcessedBlock(r,o){const t=await T.get(g.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS)||{},n=d.getStateKey(o,r);return t[n]||x.EVENTS_INITIAL_BLOCKS[r]}async updateLastProcessedBlock(r,o,t){await T.update(g.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS,(n={})=>{const e=d.getStateKey(o,r);return{...n,[e]:t}})}async getEvents(r,o){try{const{fetchRpcUrl:t}=m.networkRegistry[o];if(!t)throw Error("No fetchRpcUrl in PublicTokensDB");const n=K.createCustomRpcProvider(t),e=await this.getLastProcessedBlock(o,r)+1,s=await n.getBlockNumber(),i=k.ethers.utils.hexZeroPad(r.toLowerCase(),32),u={topics:[this.transferEventTopic,null,i],fromBlock:e,toBlock:s},c={topics:[this.transferEventTopic,i,null],fromBlock:e,toBlock:s},[q,l]=await Promise.all([n.getLogs(u),n.getLogs(c)]);return{toEvents:q,fromEvents:l,latestBlock:s}}catch(t){return p.Logger.error("Error fetching events:",t),{toEvents:[],fromEvents:[],latestBlock:void 0}}}updateTokenIds(r,o,t){const n=new Map;return t.forEach(e=>{if(S.isNFTToken(e)&&e.tokenIds){const s=e.erc20TokenAddress.toLowerCase();n.set(s,[...e.tokenIds])}}),o.forEach(e=>{if(e.topics.length<=3)return;const s=e.address.toLowerCase(),i=k.ethers.BigNumber.from(e.topics[3]).toString();n.has(s)||n.set(s,[]),n.get(s)?.push(i)}),r.forEach(e=>{if(e.topics.length<=3)return;const s=e.address.toLowerCase(),i=n.get(s);if(i?.length){const u=k.ethers.BigNumber.from(e.topics[3]).toString(),c=i.indexOf(u);c!==-1&&i.splice(c,1)}}),t.forEach(e=>{if(S.isNFTToken(e)){const s=e.erc20TokenAddress.toLowerCase(),i=n.get(s);e.tokenIds=i?.length&&i.length>0?i:void 0}}),t}async fetchPublicTokens(r,o,t){try{const n=[A.zeroAddress,...new Set(r.map(s=>s.address))].filter(s=>s&&!E.lowerCaseIncludes(t,s));return n.length?{erc20Tokens:(await _.API.tokensInfoCall(o,n)).filter(s=>!!s)}:{erc20Tokens:[]}}catch(n){return p.Logger.error("Error fetching public tokens:",n),{erc20Tokens:[]}}}}const N=new P;exports.EventsPublicTokensDB=P;exports.eventsPublicTokensDB=N;
|
|
@@ -15,27 +15,22 @@ import "../../types/transactions.types.mjs";
|
|
|
15
15
|
import "../../types/activities.types.mjs";
|
|
16
16
|
import "@coral-xyz/anchor";
|
|
17
17
|
import "@solana/web3.js";
|
|
18
|
+
import "circomlibjs-hinkal-fork";
|
|
18
19
|
import "../../constants/kyc.constants.mjs";
|
|
19
20
|
import { createCustomRpcProvider as I } from "../../functions/utils/create-provider.mjs";
|
|
20
21
|
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
21
|
-
import "circomlibjs-hinkal-fork";
|
|
22
22
|
import "../../error-handling/error-codes.constants.mjs";
|
|
23
23
|
import "../crypto-keys/keys.mjs";
|
|
24
24
|
import "../../constants/server.constants.mjs";
|
|
25
|
-
import "../../
|
|
25
|
+
import "../../API/getServerURL.mjs";
|
|
26
26
|
import "../http/HttpClient.mjs";
|
|
27
27
|
import "axios";
|
|
28
|
-
import "../../
|
|
29
|
-
import "libsodium-wrappers";
|
|
30
|
-
import "process";
|
|
31
|
-
import "buffer";
|
|
32
|
-
import "../../constants/save-depths.mjs";
|
|
33
|
-
import "../../constants/reorg-depths.constants.mjs";
|
|
34
|
-
import "../../functions/utils/mutexes.utils.mjs";
|
|
28
|
+
import "../../constants/vite.constants.mjs";
|
|
35
29
|
import "@solana/spl-token";
|
|
36
30
|
import "../../constants/token-data/index.mjs";
|
|
37
31
|
import "../../constants/contracts.constants.mjs";
|
|
38
32
|
import "../../constants/coingecko.constants.mjs";
|
|
33
|
+
import "../../constants/reorg-depths.constants.mjs";
|
|
39
34
|
import "../../constants/addresses.constants.mjs";
|
|
40
35
|
import "../../constants/token.limits.constants.mjs";
|
|
41
36
|
import "../../constants/presale.constants.mjs";
|
|
@@ -43,8 +38,12 @@ import "../../constants/activity.constants.mjs";
|
|
|
43
38
|
import "../../constants/tasks.constants.mjs";
|
|
44
39
|
import { EVENTS_INITIAL_BLOCKS as O } from "../../constants/events.constants.mjs";
|
|
45
40
|
import "../../functions/utils/userAgent.mjs";
|
|
41
|
+
import "libsodium-wrappers";
|
|
46
42
|
import "multiformats";
|
|
47
43
|
import "../../API/tenderly.api.mjs";
|
|
44
|
+
import "process";
|
|
45
|
+
import "buffer";
|
|
46
|
+
import "../../providers/EthersProviderAdapter.mjs";
|
|
48
47
|
import "node-forge";
|
|
49
48
|
import "../../functions/web3/events/getApprovedBalance.mjs";
|
|
50
49
|
import "../../functions/web3/getTokenHolder.mjs";
|
|
@@ -166,8 +165,8 @@ class K {
|
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
167
|
}
|
|
169
|
-
const
|
|
168
|
+
const It = new K();
|
|
170
169
|
export {
|
|
171
170
|
K as EventsPublicTokensDB,
|
|
172
|
-
|
|
171
|
+
It as eventsPublicTokensDB
|
|
173
172
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("idb-keyval"),a=require("../../error-handling/logger.cjs"),d=require("../../functions/utils/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("idb-keyval"),a=require("../../error-handling/logger.cjs"),d=require("../../functions/utils/token-check.utils.cjs");class c{STORAGE_KEY="hiddenTokenAddresses";UNHIDDEN_SPAM_KEY="unhiddenSpamTokens";async getHiddenTokens(e){try{return(await i.get(this.STORAGE_KEY))?.[e]||[]}catch(r){return a.Logger.error("Error retrieving hidden tokens",r),[]}}async getHiddenTokenAddresses(e){try{return(await this.getHiddenTokens(e)).map(({erc20TokenAddress:t})=>t.toLowerCase())}catch(r){return a.Logger.error("Error retrieving hidden tokens",r),[]}}async filterOutHiddenTokens(e,r){const t=await this.getHiddenTokens(e);return r.filter(n=>!t.some(s=>d.isSameERC20Token(s,n)))}async hideToken(e){try{await i.update(this.STORAGE_KEY,r=>{const t=r??{},{chainId:n}=e;return t[n]||(t[n]=[]),t[n].some(o=>d.isSameERC20Token(o,e))||t[n].push(e),t}),e.isSpam&&await this.deleteUnhiddenSpamToken(e)}catch(r){a.Logger.error("Error hiding token",r)}}async showToken(e){try{await i.update(this.STORAGE_KEY,r=>{const{chainId:t}=e,n=r??{};return n[t]||(n[t]=[]),n[t]=n[t].filter(s=>!d.isSameERC20Token(s,e)),n}),e.isSpam&&await this.storeUnhiddenSpamToken(e)}catch(r){a.Logger.error("Error showing token",r)}}async storeUnhiddenSpamToken(e){const{chainId:r}=e;try{await i.update(this.UNHIDDEN_SPAM_KEY,t=>{const n=t??{};return n[r]||(n[r]=[]),n[r].some(o=>d.isSameERC20Token(o,e))||n[r].push(e),n})}catch(t){a.Logger.error("Error storing unhidden spam token",t)}}async deleteUnhiddenSpamToken(e){await i.update(this.UNHIDDEN_SPAM_KEY,r=>{const{chainId:t}=e,n=r??{};return n[t]=n[t]?.filter(s=>!d.isSameERC20Token(s,e)),n})}async getUnhiddenSpamTokens(e){try{return(await i.get(this.UNHIDDEN_SPAM_KEY))?.[e]||[]}catch(r){return a.Logger.error("Error retrieving unhidden spam tokens",r),[]}}async hideUnnecessarySpamTokens(e,r){const t=await this.getUnhiddenSpamTokens(e),n=r.filter(s=>s.isSpam?!t.some(o=>d.isSameERC20Token(o,s)):!1);await Promise.all(n.map(s=>this.hideToken(s)))}async hideSpamsAndFetchHiddenTokensAddresses(e,r){return await this.hideUnnecessarySpamTokens(e,r),this.getHiddenTokenAddresses(e)}}const h=new c;exports.tokenVisibilityStorage=h;
|
|
@@ -1,38 +1,32 @@
|
|
|
1
|
-
import { get as
|
|
1
|
+
import { get as h, update as o } from "idb-keyval";
|
|
2
2
|
import { Logger as a } from "../../error-handling/logger.mjs";
|
|
3
|
-
import {
|
|
4
|
-
class
|
|
3
|
+
import { isSameERC20Token as i } from "../../functions/utils/token-check.utils.mjs";
|
|
4
|
+
class c {
|
|
5
5
|
STORAGE_KEY = "hiddenTokenAddresses";
|
|
6
6
|
UNHIDDEN_SPAM_KEY = "unhiddenSpamTokens";
|
|
7
7
|
async getHiddenTokens(e) {
|
|
8
8
|
try {
|
|
9
|
-
return (await
|
|
9
|
+
return (await h(this.STORAGE_KEY))?.[e] || [];
|
|
10
10
|
} catch (r) {
|
|
11
11
|
return a.error("Error retrieving hidden tokens", r), [];
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
async getHiddenTokenAddresses(e) {
|
|
15
15
|
try {
|
|
16
|
-
return (await this.getHiddenTokens(e)).map(({ erc20TokenAddress:
|
|
16
|
+
return (await this.getHiddenTokens(e)).map(({ erc20TokenAddress: t }) => t.toLowerCase());
|
|
17
17
|
} catch (r) {
|
|
18
18
|
return a.error("Error retrieving hidden tokens", r), [];
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
async filterOutHiddenTokens(e, r) {
|
|
22
|
-
const
|
|
23
|
-
return r.filter(
|
|
24
|
-
(n) => !s.some(
|
|
25
|
-
(t) => d(t.erc20TokenAddress, n.erc20TokenAddress)
|
|
26
|
-
)
|
|
27
|
-
);
|
|
22
|
+
const t = await this.getHiddenTokens(e);
|
|
23
|
+
return r.filter((n) => !t.some((s) => i(s, n)));
|
|
28
24
|
}
|
|
29
25
|
async hideToken(e) {
|
|
30
26
|
try {
|
|
31
27
|
await o(this.STORAGE_KEY, (r) => {
|
|
32
|
-
const
|
|
33
|
-
return
|
|
34
|
-
({ erc20TokenAddress: i }) => d(i, e.erc20TokenAddress)
|
|
35
|
-
) || s[n].push(e), s;
|
|
28
|
+
const t = r ?? {}, { chainId: n } = e;
|
|
29
|
+
return t[n] || (t[n] = []), t[n].some((d) => i(d, e)) || t[n].push(e), t;
|
|
36
30
|
}), e.isSpam && await this.deleteUnhiddenSpamToken(e);
|
|
37
31
|
} catch (r) {
|
|
38
32
|
a.error("Error hiding token", r);
|
|
@@ -41,10 +35,8 @@ class T {
|
|
|
41
35
|
async showToken(e) {
|
|
42
36
|
try {
|
|
43
37
|
await o(this.STORAGE_KEY, (r) => {
|
|
44
|
-
const { chainId:
|
|
45
|
-
return n[
|
|
46
|
-
({ erc20TokenAddress: t }) => !d(t, e.erc20TokenAddress)
|
|
47
|
-
), n;
|
|
38
|
+
const { chainId: t } = e, n = r ?? {};
|
|
39
|
+
return n[t] || (n[t] = []), n[t] = n[t].filter((s) => !i(s, e)), n;
|
|
48
40
|
}), e.isSpam && await this.storeUnhiddenSpamToken(e);
|
|
49
41
|
} catch (r) {
|
|
50
42
|
a.error("Error showing token", r);
|
|
@@ -53,44 +45,38 @@ class T {
|
|
|
53
45
|
async storeUnhiddenSpamToken(e) {
|
|
54
46
|
const { chainId: r } = e;
|
|
55
47
|
try {
|
|
56
|
-
await o(this.UNHIDDEN_SPAM_KEY, (
|
|
57
|
-
const n =
|
|
58
|
-
return n[r] || (n[r] = []), n[r].some(
|
|
59
|
-
({ erc20TokenAddress: i }) => d(i, e.erc20TokenAddress)
|
|
60
|
-
) || n[r].push(e), n;
|
|
48
|
+
await o(this.UNHIDDEN_SPAM_KEY, (t) => {
|
|
49
|
+
const n = t ?? {};
|
|
50
|
+
return n[r] || (n[r] = []), n[r].some((d) => i(d, e)) || n[r].push(e), n;
|
|
61
51
|
});
|
|
62
|
-
} catch (
|
|
63
|
-
a.error("Error storing unhidden spam token",
|
|
52
|
+
} catch (t) {
|
|
53
|
+
a.error("Error storing unhidden spam token", t);
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
56
|
async deleteUnhiddenSpamToken(e) {
|
|
67
57
|
await o(this.UNHIDDEN_SPAM_KEY, (r) => {
|
|
68
|
-
const { chainId:
|
|
69
|
-
return n[
|
|
70
|
-
({ erc20TokenAddress: t }) => !d(t, e.erc20TokenAddress)
|
|
71
|
-
), n;
|
|
58
|
+
const { chainId: t } = e, n = r ?? {};
|
|
59
|
+
return n[t] = n[t]?.filter((s) => !i(s, e)), n;
|
|
72
60
|
});
|
|
73
61
|
}
|
|
74
62
|
async getUnhiddenSpamTokens(e) {
|
|
75
63
|
try {
|
|
76
|
-
return (await
|
|
64
|
+
return (await h(this.UNHIDDEN_SPAM_KEY))?.[e] || [];
|
|
77
65
|
} catch (r) {
|
|
78
66
|
return a.error("Error retrieving unhidden spam tokens", r), [];
|
|
79
67
|
}
|
|
80
68
|
}
|
|
81
69
|
// From the list of tokens, hide the spam tokens that are not in the unhidden spam tokens list
|
|
82
70
|
async hideUnnecessarySpamTokens(e, r) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
) : !1);
|
|
86
|
-
await Promise.all(n.map((t) => this.hideToken(t)));
|
|
71
|
+
const t = await this.getUnhiddenSpamTokens(e), n = r.filter((s) => s.isSpam ? !t.some((d) => i(d, s)) : !1);
|
|
72
|
+
await Promise.all(n.map((s) => this.hideToken(s)));
|
|
87
73
|
}
|
|
88
74
|
// First hide spam tokens from the list, then fetch the all hidden tokens addresses
|
|
89
75
|
async hideSpamsAndFetchHiddenTokensAddresses(e, r) {
|
|
90
76
|
return await this.hideUnnecessarySpamTokens(e, r), this.getHiddenTokenAddresses(e);
|
|
91
77
|
}
|
|
92
78
|
}
|
|
93
|
-
const y = new
|
|
79
|
+
const y = new c();
|
|
94
80
|
export {
|
|
95
81
|
y as tokenVisibilityStorage
|
|
96
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("ethers"),a=require("libsodium-wrappers"),p=require("../utxo/Utxo.cjs"),l=require("@solana/web3.js"),h=require("./keys.cjs"),g=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("ethers"),a=require("libsodium-wrappers"),p=require("../utxo/Utxo.cjs"),l=require("@solana/web3.js"),h=require("./keys.cjs"),g=e=>{const s=[Buffer.from(r.ethers.utils.hexlify(e.amount)),Buffer.from(r.ethers.utils.hexlify(e.erc20TokenAddress)),Buffer.from(r.ethers.utils.hexlify(e.randomization)),Buffer.from(e.getStealthAddress()),Buffer.from(r.ethers.utils.hexlify(BigInt(e.timeStamp))),Buffer.from(r.ethers.utils.hexlify(e.tokenId??0))];if(e.mintAddress){const o=new l.PublicKey(e.mintAddress),t=r.ethers.utils.hexlify(o.toBytes());s.push(Buffer.from(t))}const n=Buffer.concat(s);return a.crypto_box_seal(n,r.ethers.utils.arrayify(e.getEncryptionKey()))},u=(e,s)=>{const{publicKey:n,privateKey:c}=h.UserKeys.getEncryptionKeyPair(s.getShieldedPrivateKey()),o=a.crypto_box_seal_open(e,r.ethers.utils.arrayify(n),r.ethers.utils.arrayify(c)),t=Buffer.from(o).toString("utf-8").split("0x").filter(i=>i.length!==0).map((i,d)=>{let f;return[0,2,4,5].includes(d)?f=BigInt(`0x${i}`):[1,3,6].includes(d)&&(f=`0x${i}`),f}),y=typeof t[6]=="string"?t[6]:void 0,m=y?new l.PublicKey(Buffer.from(y.slice(2),"hex")).toString():void 0;return{amount:t[0],erc20TokenAddress:t[1],randomization:t[2],stealthAddress:t[3],shieldedPrivateKey:s.getShieldedPrivateKey(),timeStamp:t[4].toString(),tokenId:t[5]?Number(t[5]):0,mintAddress:m}},x=(e,s)=>new p.Utxo(u(e,s));exports.decryptUtxo=x;exports.decryptUtxoConstructorArgs=u;exports.encryptUtxo=g;
|
|
@@ -7,7 +7,7 @@ import { UserKeys } from './keys';
|
|
|
7
7
|
* @param publicKey sender's encryption public key
|
|
8
8
|
* @returns returns encrypted data {Uint8Array}
|
|
9
9
|
*/
|
|
10
|
-
export declare const encryptUtxo: (utxo: Utxo
|
|
10
|
+
export declare const encryptUtxo: (utxo: Utxo) => Uint8Array;
|
|
11
11
|
export declare const decryptUtxoConstructorArgs: (encryptedData: Uint8Array, userKeys: UserKeys) => IUtxoConstructor;
|
|
12
12
|
/**
|
|
13
13
|
* decrypt UTXO data from events
|
|
@@ -3,9 +3,9 @@ import m from "libsodium-wrappers";
|
|
|
3
3
|
import { Utxo as p } from "../utxo/Utxo.mjs";
|
|
4
4
|
import { PublicKey as c } from "@solana/web3.js";
|
|
5
5
|
import { UserKeys as u } from "./keys.mjs";
|
|
6
|
-
const K = (e
|
|
7
|
-
const
|
|
8
|
-
Buffer.from(r.utils.hexlify(
|
|
6
|
+
const K = (e) => {
|
|
7
|
+
const i = [
|
|
8
|
+
Buffer.from(r.utils.hexlify(e.amount)),
|
|
9
9
|
Buffer.from(r.utils.hexlify(e.erc20TokenAddress)),
|
|
10
10
|
Buffer.from(r.utils.hexlify(e.randomization)),
|
|
11
11
|
Buffer.from(e.getStealthAddress()),
|
|
@@ -13,20 +13,20 @@ const K = (e, i) => {
|
|
|
13
13
|
Buffer.from(r.utils.hexlify(e.tokenId ?? 0))
|
|
14
14
|
];
|
|
15
15
|
if (e.mintAddress) {
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const s = new c(e.mintAddress), t = r.utils.hexlify(s.toBytes());
|
|
17
|
+
i.push(Buffer.from(t));
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
return m.crypto_box_seal(
|
|
19
|
+
const n = Buffer.concat(i);
|
|
20
|
+
return m.crypto_box_seal(n, r.utils.arrayify(e.getEncryptionKey()));
|
|
21
21
|
}, h = (e, i) => {
|
|
22
|
-
const { publicKey:
|
|
22
|
+
const { publicKey: n, privateKey: a } = u.getEncryptionKeyPair(i.getShieldedPrivateKey()), s = m.crypto_box_seal_open(
|
|
23
23
|
e,
|
|
24
|
-
r.utils.arrayify(
|
|
25
|
-
r.utils.arrayify(
|
|
26
|
-
), t = Buffer.from(
|
|
27
|
-
let
|
|
28
|
-
return [0, 2, 4, 5].includes(d) ?
|
|
29
|
-
}),
|
|
24
|
+
r.utils.arrayify(n),
|
|
25
|
+
r.utils.arrayify(a)
|
|
26
|
+
), t = Buffer.from(s).toString("utf-8").split("0x").filter((o) => o.length !== 0).map((o, d) => {
|
|
27
|
+
let f;
|
|
28
|
+
return [0, 2, 4, 5].includes(d) ? f = BigInt(`0x${o}`) : [1, 3, 6].includes(d) && (f = `0x${o}`), f;
|
|
29
|
+
}), y = typeof t[6] == "string" ? t[6] : void 0, l = y ? new c(Buffer.from(y.slice(2), "hex")).toString() : void 0;
|
|
30
30
|
return {
|
|
31
31
|
amount: t[0],
|
|
32
32
|
erc20TokenAddress: t[1],
|
|
@@ -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("../../../functions/utils/resolve-sync.utils.cjs");class v{blockchainEventEmitter;eventName;constructor(t,e){this.blockchainEventEmitter=t,this.eventName=e,t.addEventProcessorFunction(this.processEventsPage.bind(this))}get latestBlockNumber(){return this.blockchainEventEmitter.latestBlockNumber}get chainId(){return this.blockchainEventEmitter.chainId}intervalClear(){this.blockchainEventEmitter.intervalClear()}async processEventsPage(t){const e=new Set;t.forEach(({event:s,transactionHash:n})=>{s==="BlockedUtxosCreated"&&e.add(n)});const c=[];await l.resolveSync(t.map(s=>async()=>{if(s.event!==this.eventName)return;const{args:n,blockNumber:o,transactionHash:r}=s;if(!n)throw new Error("Wrong event structure");const a=this.mapEvent(n),h=e.has(r);await this.acceptEvent(a,o,r,h)&&c.push(a)}));const i=c.length;return await this.afterEventsAccepted(i),c.length}}exports.AbstractEventService=v;
|
|
@@ -4,6 +4,7 @@ export declare abstract class AbstractEventService<EventType, SerializedEventTyp
|
|
|
4
4
|
protected readonly eventName: string;
|
|
5
5
|
protected constructor(blockchainEventEmitter: BlockchainEventEmitter, eventName: string);
|
|
6
6
|
get latestBlockNumber(): number;
|
|
7
|
+
get chainId(): number;
|
|
7
8
|
intervalClear(): void;
|
|
8
9
|
private processEventsPage;
|
|
9
10
|
protected abstract acceptEvent(event: EventType, blockNumber: number, txHash?: string, isBlocked?: boolean): boolean | Promise<boolean>;
|
|
@@ -8,6 +8,9 @@ class u {
|
|
|
8
8
|
get latestBlockNumber() {
|
|
9
9
|
return this.blockchainEventEmitter.latestBlockNumber;
|
|
10
10
|
}
|
|
11
|
+
get chainId() {
|
|
12
|
+
return this.blockchainEventEmitter.chainId;
|
|
13
|
+
}
|
|
11
14
|
intervalClear() {
|
|
12
15
|
this.blockchainEventEmitter.intervalClear();
|
|
13
16
|
}
|
|
@@ -21,15 +24,15 @@ class u {
|
|
|
21
24
|
t.map((s) => async () => {
|
|
22
25
|
if (s.event !== this.eventName)
|
|
23
26
|
return;
|
|
24
|
-
const { args: n, blockNumber:
|
|
27
|
+
const { args: n, blockNumber: o, transactionHash: a } = s;
|
|
25
28
|
if (!n)
|
|
26
29
|
throw new Error("Wrong event structure");
|
|
27
30
|
const r = this.mapEvent(n), h = e.has(a);
|
|
28
|
-
await this.acceptEvent(r,
|
|
31
|
+
await this.acceptEvent(r, o, a, h) && c.push(r);
|
|
29
32
|
})
|
|
30
33
|
);
|
|
31
|
-
const
|
|
32
|
-
return await this.afterEventsAccepted(
|
|
34
|
+
const i = c.length;
|
|
35
|
+
return await this.afterEventsAccepted(i), c.length;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
export {
|
|
@@ -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;
|
|
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;
|
|
@@ -6,7 +6,6 @@ export interface Snapshot<SnapshotPayloadType> {
|
|
|
6
6
|
}
|
|
7
7
|
export declare abstract class AbstractSnapshotService<EventType, SerializedEventType, SnapshotPayloadType, SerializedSnapshotType> extends AbstractEventService<EventType, SerializedEventType> {
|
|
8
8
|
private savedLatestBlockNumber;
|
|
9
|
-
private chainId;
|
|
10
9
|
protected constructor(blockchainEventEmitter: BlockchainEventEmitter, eventName: string);
|
|
11
10
|
init(): Promise<void>;
|
|
12
11
|
retrieveEventsFromLatestBlock(): Promise<void>;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { saveDepths as e } from "../../../constants/save-depths.mjs";
|
|
2
2
|
import { AbstractEventService as a } from "./AbstractEventService.mjs";
|
|
3
|
-
class
|
|
3
|
+
class r extends a {
|
|
4
4
|
savedLatestBlockNumber = 0;
|
|
5
|
-
chainId = 0;
|
|
6
5
|
constructor(t, s) {
|
|
7
6
|
super(t, s);
|
|
8
7
|
}
|
|
9
8
|
async init() {
|
|
10
|
-
await this.loadSnapshot()
|
|
9
|
+
await this.loadSnapshot();
|
|
11
10
|
}
|
|
12
11
|
async retrieveEventsFromLatestBlock() {
|
|
13
12
|
await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber);
|
|
@@ -29,5 +28,5 @@ class c extends a {
|
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
export {
|
|
32
|
-
|
|
31
|
+
r as AbstractSnapshotService
|
|
33
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../../constants/reorg-depths.constants.cjs"),l=require("../../../functions/utils/resolve-sync.utils.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../../constants/reorg-depths.constants.cjs"),l=require("../../../functions/utils/resolve-sync.utils.cjs");class m{_chainId;contract;depositOnChainUtxosContract;_latestBlockNumber;_initialBlockNumber;onEventsProcessed;eventProcessors=new Set;maxPageSize;isReady=!1;isServer;intervalId;inProgress;eventsFetchingMutex;constructor(e,r,h,s,i,o,n){this.contract=r,this.depositOnChainUtxosContract=n,this._chainId=e,this._initialBlockNumber=h,this.maxPageSize=o,this.isServer=s,this.inProgress=!1,this.eventsFetchingMutex=i}get latestBlockNumber(){return this._latestBlockNumber??this._initialBlockNumber}get chainId(){return this._chainId}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 this.contract.provider.getBlockNumber();if(!this.isServer)return e;const{chainId:r}=await this.contract.provider.getNetwork();return Math.max(this.latestBlockNumber,e-d.blockReorgDepth[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 o=l.getSequence(e,i,this.maxPageSize),n=[];if(await l.resolveSync(o.map(({from:t,to:a})=>async()=>{const c=await this.contract.queryFilter("*",t,a);n.push(...c)})),this.depositOnChainUtxosContract){const{depositOnChainUtxosContract:t}=this;await l.resolveSync(o.map(({from:a,to:c})=>async()=>{const v=await t.queryFilter("*",a,c);n.push(...v)}))}const u=await Promise.all([...this.eventProcessors].map(t=>t(n)));return this._latestBlockNumber=i,s+=u.reduce((t,a)=>t+a,0),this.onEventsProcessed?.(s),this.inProgress=!1,!0}catch(s){return console.log("retrieveEvents error:",{err:s}),this.inProgress=!1,!1}})}}exports.BlockchainEventEmitter=m;
|
|
@@ -2,6 +2,7 @@ import { ethers } from 'ethers';
|
|
|
2
2
|
import { Mutex } from 'async-mutex';
|
|
3
3
|
export type EventProcessorFunction = (events: ethers.Event[]) => Promise<number> | number;
|
|
4
4
|
export declare class BlockchainEventEmitter {
|
|
5
|
+
private readonly _chainId;
|
|
5
6
|
readonly contract: ethers.Contract;
|
|
6
7
|
readonly depositOnChainUtxosContract?: ethers.Contract;
|
|
7
8
|
private _latestBlockNumber;
|
|
@@ -14,8 +15,9 @@ export declare class BlockchainEventEmitter {
|
|
|
14
15
|
private intervalId?;
|
|
15
16
|
private inProgress;
|
|
16
17
|
private eventsFetchingMutex;
|
|
17
|
-
constructor(contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, maxPageSize?: number, depositOnChainUtxosContract?: ethers.Contract
|
|
18
|
+
constructor(chainId: number, contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, eventsFetchingMutex: Mutex, maxPageSize?: number, depositOnChainUtxosContract?: ethers.Contract);
|
|
18
19
|
get latestBlockNumber(): number;
|
|
20
|
+
get chainId(): number;
|
|
19
21
|
syncFromAtMost(blockNumber: number): void;
|
|
20
22
|
intervalClear(): void;
|
|
21
23
|
init(): Promise<void>;
|