@hinkal/common 0.2.21 → 0.2.22
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 +54 -42
- 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/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 +142 -38
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +13 -36
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +71 -68
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +56 -45
- package/data-structures/Hinkal/Hinkal.mjs +348 -314
- package/data-structures/Hinkal/IHinkal.d.ts +54 -40
- 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 +20 -20
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +84 -88
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +96 -77
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +80 -75
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +150 -138
- 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 +119 -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 -114
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +34 -36
- 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 +182 -155
- 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 +45 -48
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +48 -49
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +68 -71
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +78 -71
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +70 -71
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +79 -81
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +103 -105
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +53 -107
- 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 +75 -91
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +37 -40
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +13 -16
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +40 -25
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +84 -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/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +11 -0
- package/data-structures/crypto-keys/keys.mjs +107 -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 +19 -19
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +3 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +5 -6
- 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 +4 -3
- 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 +35 -39
- 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 +1 -1
- 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/provider-adapter/IProviderAdapter.d.ts +13 -8
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +4 -6
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +4 -6
- 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 -21
- 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 +17 -18
- 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/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +36 -21
- 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 +6 -3
- package/functions/private-wallet/emporium.helpers.mjs +127 -89
- 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 +102 -100
- 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 +20 -18
- 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 +12 -13
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +2 -2
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +1 -1
- package/functions/utils/create-provider.mjs +9 -13
- 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/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/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 -8
- 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.mjs +54 -49
- 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/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/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/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.mjs +38 -38
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +10 -13
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +6 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +21 -12
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +46 -50
- 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 +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 +32 -0
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +40 -36
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +3 -3
- package/functions/web3/functionCalls/transactCallRelayer.mjs +54 -54
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.mjs +22 -17
- 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 +27 -27
- 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 +19 -6
- 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 -7
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +56 -38
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +34 -22
- package/index.cjs +1 -1
- package/index.mjs +922 -920
- package/package.json +2 -3
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +17 -10
- package/providers/EthersProviderAdapter.mjs +76 -45
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +11 -7
- package/providers/SolanaProviderAdapter.mjs +31 -16
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +17 -11
- package/providers/WagmiProviderAdapter.mjs +117 -86
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +9 -14
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +9 -15
- package/types/TransactionSimulator.types.d.ts +9 -2
- package/types/activities.types.d.ts +0 -2
- 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/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 +0 -1
- 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/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/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/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
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
1
|
+
import { utils as o, ethers as d } from "ethers";
|
|
2
|
+
import w from "libsodium-wrappers";
|
|
3
|
+
import { CIRCOM_P as m } from "../../constants/protocol.constants.mjs";
|
|
4
|
+
import { babyJubInstance as b } from "../../crypto/babyJub.mjs";
|
|
5
|
+
import { poseidonHash as c } from "../../crypto/poseidon.mjs";
|
|
6
|
+
import { getCircomSign as y } from "./keyUtils.mjs";
|
|
7
|
+
import { AttachableMemoryCacheDevice as v } from "../cacheDevices/AttachableMemoryCacheDevice.mjs";
|
|
8
|
+
import { ethers as u, hexlify as F } from "ethers-v6h";
|
|
9
|
+
import { isSolanaLike as h, networkRegistry as p } from "../../constants/chains.constants.mjs";
|
|
10
|
+
import { Keypair as g, VersionedTransaction as K } from "@solana/web3.js";
|
|
11
|
+
import k from "tweetnacl";
|
|
12
|
+
import P from "bs58";
|
|
13
|
+
import { createCustomSolanaConnection as A } from "../../functions/utils/create-provider.mjs";
|
|
14
|
+
const E = new v(), R = new v(), L = {
|
|
12
15
|
privateKey: "",
|
|
13
16
|
publicKey: ""
|
|
14
17
|
};
|
|
15
|
-
class
|
|
18
|
+
class l {
|
|
16
19
|
signature;
|
|
17
20
|
constructor(e) {
|
|
18
21
|
this.signature = e;
|
|
@@ -28,76 +31,133 @@ class x {
|
|
|
28
31
|
throw Error("No signature provided");
|
|
29
32
|
}
|
|
30
33
|
verifyMessage(e) {
|
|
31
|
-
return this.requireSignature(),
|
|
34
|
+
return this.requireSignature(), o.verifyMessage(e, this.signature);
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
37
|
* get shielded private key from message signature used to login to the application,
|
|
35
38
|
* this private key is used to generate encryption keypairs as well as public key
|
|
36
39
|
* @retuns 0x-prefixed shielded private key
|
|
37
40
|
*/
|
|
38
|
-
getShieldedPrivateKey = () => (this.requireSignature(),
|
|
41
|
+
getShieldedPrivateKey = () => (this.requireSignature(), d.utils.keccak256(this.signature));
|
|
39
42
|
/**
|
|
40
43
|
* generate shielded public key from private key
|
|
41
44
|
* @param privateKey the key used to generate the shielded public key, this should be the signature
|
|
42
45
|
* that the user provided
|
|
43
46
|
* @retuns shielded public key in hexstring with 0x prefixed
|
|
44
47
|
*/
|
|
45
|
-
getShieldedPublicKey = () => (this.requireSignature(),
|
|
48
|
+
getShieldedPublicKey = () => (this.requireSignature(), c(this.getShieldedPrivateKey()));
|
|
46
49
|
/**
|
|
47
50
|
* deterministically derive an EVM address from the shielded private key
|
|
48
51
|
*/
|
|
49
|
-
getDerivedEthereumAddress = () => (this.requireSignature(), new
|
|
52
|
+
getDerivedEthereumAddress = () => (this.requireSignature(), new u.Wallet(this.getShieldedPrivateKey()).address);
|
|
50
53
|
/**
|
|
51
54
|
* deterministically derive a Solana public key from the shielded private key
|
|
52
55
|
*/
|
|
53
|
-
getDerivedSolanaPublicKey = () => (this.requireSignature(),
|
|
56
|
+
getDerivedSolanaPublicKey = () => (this.requireSignature(), g.fromSeed(o.arrayify(this.getShieldedPrivateKey())).publicKey.toBase58());
|
|
54
57
|
/**
|
|
55
58
|
* generate access token, this accessKey is what should be sent to the server for signing
|
|
56
59
|
* @returns accessKey in hexstring with 0x prefixed
|
|
57
60
|
*/
|
|
58
|
-
getAccessKey = () => (this.requireSignature(),
|
|
61
|
+
getAccessKey = () => (this.requireSignature(), c(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
|
|
59
62
|
getSignerPrivateKeyFromNonce = (e) => {
|
|
60
63
|
this.requireSignature();
|
|
61
|
-
const
|
|
62
|
-
return
|
|
64
|
+
const r = c(e, this.getShieldedPrivateKey(), this.getShieldedPublicKey());
|
|
65
|
+
return o.keccak256(o.toUtf8Bytes(r));
|
|
63
66
|
};
|
|
64
67
|
getSignerSolanaPrivateKeyFromNonce = (e) => {
|
|
65
|
-
const
|
|
66
|
-
return
|
|
68
|
+
const r = this.getSignerPrivateKeyFromNonce(e), t = o.arrayify(r), i = g.fromSeed(t);
|
|
69
|
+
return P.encode(i.secretKey);
|
|
67
70
|
};
|
|
68
|
-
|
|
71
|
+
getEvmPrivateKeyFromSolanaPrivateKey = (e) => {
|
|
72
|
+
const t = P.decode(e).slice(0, 32);
|
|
73
|
+
return F(t);
|
|
74
|
+
};
|
|
75
|
+
static getSignerFromPrivateKey = (e, r) => {
|
|
76
|
+
if (h(e)) {
|
|
77
|
+
const i = o.arrayify(r);
|
|
78
|
+
return g.fromSeed(i);
|
|
79
|
+
}
|
|
80
|
+
return new u.Wallet(r);
|
|
81
|
+
};
|
|
82
|
+
static getSignerAddressFromPrivateKey(e, r) {
|
|
83
|
+
const t = l.getSignerFromPrivateKey(e, r);
|
|
84
|
+
return t instanceof g ? t.publicKey.toString() : t.address;
|
|
85
|
+
}
|
|
86
|
+
static signMessageFromPrivateKey = async (e, r, t) => {
|
|
87
|
+
const i = l.getSignerFromPrivateKey(e, r);
|
|
88
|
+
if (i instanceof g) {
|
|
89
|
+
const a = o.isHexString(t) ? o.arrayify(t) : new TextEncoder().encode(t), s = k.sign.detached(a, i.secretKey);
|
|
90
|
+
return `0x${Buffer.from(s).toString("hex")}`;
|
|
91
|
+
}
|
|
92
|
+
const n = o.isHexString(t) ? o.arrayify(t) : t;
|
|
93
|
+
return i.signMessage(n);
|
|
94
|
+
};
|
|
95
|
+
static signSolanaTransactionFromPrivateKey = (e, r, t) => {
|
|
96
|
+
if (!h(e))
|
|
97
|
+
throw new Error("Solana transaction signing is only available for Solana chains");
|
|
98
|
+
const i = l.getSignerFromPrivateKey(e, r);
|
|
99
|
+
if (!(i instanceof g))
|
|
100
|
+
throw new Error("Unable to derive Solana keypair for signing");
|
|
101
|
+
t.sign([i]);
|
|
102
|
+
};
|
|
103
|
+
static sendAndSignTransactionFromPrivateKey = async (e, r, t) => {
|
|
104
|
+
const i = l.getSignerFromPrivateKey(e, r), { fetchRpcUrl: n } = p[e];
|
|
105
|
+
if (!n)
|
|
106
|
+
throw new Error("No RPC URL found for chainId");
|
|
107
|
+
if (i instanceof g) {
|
|
108
|
+
if (!(t instanceof K))
|
|
109
|
+
throw new Error("Invalid transaction type for Solana");
|
|
110
|
+
return t.sign([i]), await A(n).sendRawTransaction(t.serialize());
|
|
111
|
+
}
|
|
112
|
+
if (t instanceof K)
|
|
113
|
+
throw new Error("Invalid transaction type for EVM");
|
|
114
|
+
const a = new u.JsonRpcProvider(n);
|
|
115
|
+
return (await i.connect(a).sendTransaction(t)).hash;
|
|
116
|
+
};
|
|
117
|
+
static signTypedDataFromPrivateKey = async (e, r, t, i, n) => {
|
|
118
|
+
if (h(e))
|
|
119
|
+
throw new Error("Solana does not support typed data");
|
|
120
|
+
return await l.getSignerFromPrivateKey(e, r).signTypedData(t, i, n);
|
|
121
|
+
};
|
|
122
|
+
static authorizeDelegation = async (e, r, t, i) => {
|
|
123
|
+
if (h(e))
|
|
124
|
+
throw new Error("Solana does not support delegation");
|
|
125
|
+
const n = new u.JsonRpcProvider(p[e].fetchRpcUrl);
|
|
126
|
+
return await l.getSignerFromPrivateKey(e, r).connect(n).authorize({ address: t, ...i !== void 0 && { nonce: i } });
|
|
127
|
+
};
|
|
128
|
+
getWalletSalt = (e) => (this.requireSignature(), c(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), e));
|
|
69
129
|
/**
|
|
70
130
|
* generate inHinkalAddress - a user unique address linking him with a specific app
|
|
71
131
|
* @returns inHinkalAddress in bigint
|
|
72
132
|
*/
|
|
73
133
|
getInHinkalAddress = (e) => {
|
|
74
134
|
this.requireSignature();
|
|
75
|
-
const
|
|
76
|
-
return BigInt(
|
|
135
|
+
const r = c(this.getShieldedPrivateKey(), e);
|
|
136
|
+
return BigInt(r);
|
|
77
137
|
};
|
|
78
138
|
/**
|
|
79
139
|
* generate backend token, which is used for access control on backend
|
|
80
140
|
* @returns accessKey in hexstring with 0x prefixed
|
|
81
141
|
*/
|
|
82
|
-
getBackendToken = () => (this.requireSignature(),
|
|
83
|
-
static getRandomizedStealthPair =
|
|
84
|
-
(e,
|
|
85
|
-
const
|
|
86
|
-
return { H0:
|
|
142
|
+
getBackendToken = () => (this.requireSignature(), c(this.getAccessKey(), this.getShieldedPublicKey()));
|
|
143
|
+
static getRandomizedStealthPair = E.attach(
|
|
144
|
+
(e, r) => {
|
|
145
|
+
const t = b(), i = BigInt(r) % m, n = e * i % m, a = t.mulPointEscalar(t.Base8, e), s = t.mulPointEscalar(t.Base8, n), S = [BigInt(t.F.toString(a[0])), BigInt(t.F.toString(a[1]))], f = [BigInt(t.F.toString(s[0])), BigInt(t.F.toString(s[1]))];
|
|
146
|
+
return { H0: S, H1: f };
|
|
87
147
|
}
|
|
88
148
|
);
|
|
89
|
-
static getStealthAddressCompressedPoints = (e,
|
|
90
|
-
const { H0:
|
|
91
|
-
return { h0: n, h1:
|
|
149
|
+
static getStealthAddressCompressedPoints = (e, r) => {
|
|
150
|
+
const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), [n, a] = [t, i].map((s) => BigInt(s[1]) + 2n ** 255n * y(s[0]));
|
|
151
|
+
return { h0: n, h1: a };
|
|
92
152
|
};
|
|
93
|
-
static getStealthAddress =
|
|
94
|
-
const { H0:
|
|
95
|
-
return
|
|
153
|
+
static getStealthAddress = R.attach((e, r) => {
|
|
154
|
+
const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), a = [2n * y(t[0]) + y(i[0]), t[1], i[1]];
|
|
155
|
+
return c(...a);
|
|
96
156
|
});
|
|
97
|
-
static getStealthAddressWithEKey = (e,
|
|
98
|
-
static checkSignature = (e,
|
|
99
|
-
const { h0: n, h1:
|
|
100
|
-
return
|
|
157
|
+
static getStealthAddressWithEKey = (e, r) => ({ stealthAddress: this.getStealthAddress(e, r), encryptionKey: this.getEncryptionKeyPair(r).publicKey });
|
|
158
|
+
static checkSignature = (e, r, t, i) => {
|
|
159
|
+
const { h0: n, h1: a } = this.getStealthAddressCompressedPoints(e, i);
|
|
160
|
+
return r === n && t === a;
|
|
101
161
|
};
|
|
102
162
|
/**
|
|
103
163
|
* generate private and public keypair
|
|
@@ -105,16 +165,16 @@ class x {
|
|
|
105
165
|
* and must correspond to 32 bytes
|
|
106
166
|
*/
|
|
107
167
|
static getEncryptionKeyPair = (e) => {
|
|
108
|
-
const
|
|
168
|
+
const r = w.crypto_box_seed_keypair(d.utils.arrayify(e));
|
|
109
169
|
return {
|
|
110
|
-
privateKey:
|
|
111
|
-
publicKey:
|
|
170
|
+
privateKey: d.utils.hexlify(r.privateKey),
|
|
171
|
+
publicKey: d.utils.hexlify(r.publicKey)
|
|
112
172
|
};
|
|
113
173
|
};
|
|
114
174
|
}
|
|
115
175
|
export {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
176
|
+
L as EncryptionKeyPairDefaultValue,
|
|
177
|
+
l as UserKeys,
|
|
178
|
+
R as stealthAddressCacheDevice,
|
|
179
|
+
E as stealthPairCacheDevice
|
|
120
180
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../constants/protocol.constants.cjs"),a=require("../../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const t=require("../../../functions/utils/amounts.utils.cjs"),o=require("../../merkle-tree/MerkleTree.cjs");require("ethers");require("../../../error-handling/error-codes.constants.cjs");const l=require("./AbstractSnapshotService.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../constants/protocol.constants.cjs"),a=require("../../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const t=require("../../../functions/utils/amounts.utils.cjs"),o=require("../../merkle-tree/MerkleTree.cjs");require("ethers");require("../../../error-handling/error-codes.constants.cjs");const l=require("./AbstractSnapshotService.cjs"),i=require("../../../functions/utils/merkleTree.utils.cjs");class u extends l.AbstractSnapshotService{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(a.poseidonFunction,0n),e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:n})=>[d,n])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.accessKey,e.index),this._senderAddressIndexMap.set(e.senderAddress,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.senderAddress)??0)),this._senderAddresses.includes(e.senderAddress)||this._senderAddresses.push(e.senderAddress),e.accessKey===0n&&e.senderAddress===c.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const{accessKey:s,index:r,senderAddress:d}=e;return{accessKey:t.toBigInt(s),index:t.toBigInt(r),senderAddress:d}}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.AbstractAccessTokenSnapshotService=u;
|
|
@@ -2,7 +2,6 @@ import { MerkleTree, MerkleTreeJson } from '../../merkle-tree';
|
|
|
2
2
|
import { AccessTokenEvent } 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 SenderAddressIndexMapJson = {
|
|
7
6
|
address: string;
|
|
8
7
|
index: number;
|
|
@@ -18,7 +17,7 @@ export type AccessTokenSerializedSnapshot = {
|
|
|
18
17
|
senderAddresses?: string[];
|
|
19
18
|
senderAddressIndexMap?: SenderAddressIndexMapJson;
|
|
20
19
|
};
|
|
21
|
-
export declare abstract class AbstractAccessTokenSnapshotService extends AbstractSnapshotService<AccessTokenEvent<bigint>, AccessTokenSnapshotPayload, AccessTokenSerializedSnapshot> {
|
|
20
|
+
export declare abstract class AbstractAccessTokenSnapshotService extends AbstractSnapshotService<AccessTokenEvent<bigint>, AccessTokenEvent, AccessTokenSnapshotPayload, AccessTokenSerializedSnapshot> {
|
|
22
21
|
constructor(accessTokenEventFetcher: BlockchainEventEmitter);
|
|
23
22
|
private _merkleTree;
|
|
24
23
|
private _senderAddresses;
|
|
@@ -29,7 +28,7 @@ export declare abstract class AbstractAccessTokenSnapshotService extends Abstrac
|
|
|
29
28
|
protected serializeSnapshot(snapshot: Snapshot<AccessTokenSnapshotPayload>): AccessTokenSerializedSnapshot;
|
|
30
29
|
protected deserializeSnapshot(serializedSnapshot: AccessTokenSerializedSnapshot): Snapshot<AccessTokenSnapshotPayload>;
|
|
31
30
|
protected acceptEvent(event: AccessTokenEvent<bigint>, _blockNumber: number): boolean;
|
|
32
|
-
protected mapEvent(event:
|
|
31
|
+
protected mapEvent(event: AccessTokenEvent): AccessTokenEvent<bigint>;
|
|
33
32
|
protected getSnapshotPayload(): AccessTokenSnapshotPayload;
|
|
34
33
|
protected populateSnapshot({ payload: { merkleTree, senderAddresses, senderAddressIndexMap }, }: Snapshot<AccessTokenSnapshotPayload>): void;
|
|
35
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
2
|
-
import { poseidonFunction as
|
|
1
|
+
import { zeroAddress as m } from "../../../constants/protocol.constants.mjs";
|
|
2
|
+
import { poseidonFunction as o } from "../../../crypto/poseidon.mjs";
|
|
3
3
|
import "circomlibjs-hinkal-fork";
|
|
4
4
|
import "libsodium-wrappers";
|
|
5
5
|
import "process";
|
|
@@ -8,9 +8,9 @@ import { toBigInt as t } from "../../../functions/utils/amounts.utils.mjs";
|
|
|
8
8
|
import { MerkleTree as a } from "../../merkle-tree/MerkleTree.mjs";
|
|
9
9
|
import "ethers";
|
|
10
10
|
import "../../../error-handling/error-codes.constants.mjs";
|
|
11
|
-
import { AbstractSnapshotService as
|
|
12
|
-
import { contructMerkleTreeFromSerialized as
|
|
13
|
-
class
|
|
11
|
+
import { AbstractSnapshotService as l } from "./AbstractSnapshotService.mjs";
|
|
12
|
+
import { contructMerkleTreeFromSerialized as A } from "../../../functions/utils/merkleTree.utils.mjs";
|
|
13
|
+
class b extends l {
|
|
14
14
|
constructor(e) {
|
|
15
15
|
super(e, "NewAccessKeyAdded");
|
|
16
16
|
}
|
|
@@ -39,7 +39,7 @@ class g extends A {
|
|
|
39
39
|
}
|
|
40
40
|
deserializeSnapshot(e) {
|
|
41
41
|
let s, r;
|
|
42
|
-
return e.latestBlockNumber && e.merkleTree ? s =
|
|
42
|
+
return e.latestBlockNumber && e.merkleTree ? s = A(e.merkleTree) : s = a.create(o, 0n), e.latestBlockNumber && e.senderAddressIndexMap ? r = new Map(
|
|
43
43
|
e.senderAddressIndexMap.map(({ address: d, index: n }) => [d, n])
|
|
44
44
|
) : r = /* @__PURE__ */ new Map(), {
|
|
45
45
|
latestBlockNumber: e.latestBlockNumber ?? 0,
|
|
@@ -55,13 +55,13 @@ class g extends A {
|
|
|
55
55
|
return this._merkleTree.insert(e.accessKey, e.index), this._senderAddressIndexMap.set(
|
|
56
56
|
e.senderAddress,
|
|
57
57
|
Math.max(Number(e.index), this._senderAddressIndexMap.get(e.senderAddress) ?? 0)
|
|
58
|
-
), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress ===
|
|
58
|
+
), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress === m && this._merkleTree.remove(e.index), !0;
|
|
59
59
|
} catch (r) {
|
|
60
60
|
return console.error(r), !1;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
mapEvent(e) {
|
|
64
|
-
const
|
|
64
|
+
const { accessKey: s, index: r, senderAddress: d } = e;
|
|
65
65
|
return {
|
|
66
66
|
accessKey: t(s),
|
|
67
67
|
index: t(r),
|
|
@@ -82,5 +82,5 @@ class g extends A {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
export {
|
|
85
|
-
|
|
85
|
+
b as AbstractAccessTokenSnapshotService
|
|
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 c=require("./AbstractSnapshotService.cjs"),v=require("../../../functions/utils/amounts.utils.cjs"),u=require("../../../functions/utils/caseInsensitive.utils.cjs");class A extends c.AbstractSnapshotService{constructor(e){super(e,"NewApprovedUtxo")}_approvals=new Map;events=new Set;get approvals(){return this._approvals}getEventKey(e,t,s){return typeof e!="bigint"||typeof s!="string"||typeof t!="string"?null:`${s}-${t}-${e}`}serializeSnapshot(e){const t=Object.fromEntries(e.payload.approvals),s=Object.entries(t).map(([p,i])=>{const l=i.map(n=>({amount:n.amount.toString(),tokenAddress:n.tokenAddress,inHinkalAddress:n.inHinkalAddress.toString()}));return[p,l]}),r=Object.fromEntries(s);return{latestBlockNumber:e.latestBlockNumber,approvals:r,events:[...this.events]}}deserializeSnapshot(e){const t=e.approvals,s=Object.entries(t).map(([p,i])=>{const l=i.map(n=>({amount:BigInt(n.amount),tokenAddress:n.tokenAddress,inHinkalAddress:BigInt(n.inHinkalAddress)}));return[p,l]}),r=new Map(s);return{latestBlockNumber:e.latestBlockNumber??0,payload:{approvals:r,events:new Set(e.events)}}}getSnapshotPayload(){return{approvals:this._approvals,events:this.events}}populateSnapshot({payload:{approvals:e,events:t}}){this._approvals=e,this.events=t}mapEvent(e){const{approveTo:t,tokenAddress:s,amount:r,inHinkalAddress:p}=e;return{approveTo:t,tokenAddress:s,amount:v.toBigInt(r),inHinkalAddress:v.toBigInt(p)}}acceptEvent(e,t,s){const r=this.getEventKey(e.inHinkalAddress,e.tokenAddress,s);if(r&&!this.events.has(r)){const{amount:p,tokenAddress:i,inHinkalAddress:l}=e,n={amount:p,tokenAddress:i,inHinkalAddress:l};let a=this.approvals.get(e.approveTo)||[],d=!1;for(let o=0;o<a.length;o+=1)u.caseInsensitiveEqual(i,a[o].tokenAddress)&&l===a[o].inHinkalAddress&&(a[o].amount+=p,d=!0);if(a=a.filter(o=>o.amount!==0n),d&&a.length===0)this.approvals.delete(e.approveTo);else{const o=d?a:[...a,n];this.approvals.set(e.approveTo,o)}return s&&this.events.add(r),!0}return!1}}exports.AbstractApprovalsSnapshotService=A;
|
|
@@ -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,t){this.blockchainEventEmitter=e,this.eventName=t,e.addEventProcessorFunction(this.processEventsPage.bind(this))}get latestBlockNumber(){return this.blockchainEventEmitter.latestBlockNumber}intervalClear(){this.blockchainEventEmitter.intervalClear()}async processEventsPage(e){const t=new Set;e.forEach(({event:s,transactionHash:n})=>{s==="BlockedUtxosCreated"&&t.add(n)});const c=[];await v.resolveSync(e.map(s=>async()=>{if(s.event!==this.eventName)return;const{args:n,blockNumber:i,transactionHash:r}=s;if(!n)throw new Error("Wrong event structure");const a=this.mapEvent(n),l=t.has(r);await this.acceptEvent(a,i,r,l)&&c.push(a)}));const o=c.length;return await this.afterEventsAccepted(o),c.length}}exports.AbstractEventService=h;
|
|
@@ -1,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,37 +1,37 @@
|
|
|
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
|
-
constructor(t,
|
|
6
|
-
this.blockchainEventEmitter = t, this.eventName =
|
|
5
|
+
constructor(t, e) {
|
|
6
|
+
this.blockchainEventEmitter = t, this.eventName = e, t.addEventProcessorFunction(this.processEventsPage.bind(this));
|
|
7
7
|
}
|
|
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
|
-
const
|
|
19
|
-
t.forEach(({
|
|
20
|
-
|
|
15
|
+
const e = /* @__PURE__ */ new Set();
|
|
16
|
+
t.forEach(({ event: s, transactionHash: n }) => {
|
|
17
|
+
s === "BlockedUtxosCreated" && e.add(n);
|
|
21
18
|
});
|
|
22
|
-
const
|
|
23
|
-
await
|
|
24
|
-
t.map((
|
|
25
|
-
if (
|
|
19
|
+
const c = [];
|
|
20
|
+
await v(
|
|
21
|
+
t.map((s) => async () => {
|
|
22
|
+
if (s.event !== this.eventName)
|
|
26
23
|
return;
|
|
27
|
-
const { blockNumber:
|
|
28
|
-
|
|
24
|
+
const { args: n, blockNumber: i, transactionHash: a } = s;
|
|
25
|
+
if (!n)
|
|
26
|
+
throw new Error("Wrong event structure");
|
|
27
|
+
const r = this.mapEvent(n), h = e.has(a);
|
|
28
|
+
await this.acceptEvent(r, i, a, h) && c.push(r);
|
|
29
29
|
})
|
|
30
30
|
);
|
|
31
|
-
const
|
|
32
|
-
return await this.afterEventsAccepted(
|
|
31
|
+
const o = c.length;
|
|
32
|
+
return await this.afterEventsAccepted(o), c.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 t=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./AbstractSnapshotService.cjs");class i extends t.AbstractSnapshotService{constructor(e){super(e,"Nullified")}_nullifiers;get nullifiers(){return this._nullifiers}serializeSnapshot(e){return{nullifiers:Array.from(e.payload.nullifiers).map(r=>r.toString()),latestBlockNumber:e.latestBlockNumber}}deserializeSnapshot(e){return{latestBlockNumber:e.latestBlockNumber??0,payload:{nullifiers:new Set(e.nullifiers??[])}}}acceptEvent(e,r){try{return this._nullifiers.has(e.nullifier)?!1:(this._nullifiers.add(e.nullifier),!0)}catch(l){return console.error(l),!1}}mapEvent(e){const{nullifier:r}=e;return{nullifier:r.toHexString()}}getSnapshotPayload(){return{nullifiers:this._nullifiers}}populateSnapshot({payload:{nullifiers:e}}){this._nullifiers=e}}exports.AbstractNullifierSnapshotService=i;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
1
2
|
import { NullifierEvent } from '../../../types/commitments.types';
|
|
2
3
|
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
3
4
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
4
|
-
import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
|
|
5
5
|
export type NullifierSnapshotPayload = {
|
|
6
6
|
readonly nullifiers: Set<string>;
|
|
7
7
|
};
|
|
@@ -9,14 +9,14 @@ export type NullifierSerializedSnapshot = {
|
|
|
9
9
|
latestBlockNumber?: number;
|
|
10
10
|
nullifiers?: string[];
|
|
11
11
|
};
|
|
12
|
-
export declare abstract class AbstractNullifierSnapshotService extends AbstractSnapshotService<NullifierEvent<string>, NullifierSnapshotPayload, NullifierSerializedSnapshot> {
|
|
12
|
+
export declare abstract class AbstractNullifierSnapshotService extends AbstractSnapshotService<NullifierEvent<string>, NullifierEvent<BigNumber>, NullifierSnapshotPayload, NullifierSerializedSnapshot> {
|
|
13
13
|
constructor(hinkalEventEmitter: BlockchainEventEmitter);
|
|
14
14
|
private _nullifiers;
|
|
15
15
|
get nullifiers(): Set<string>;
|
|
16
16
|
protected serializeSnapshot(snapshot: Snapshot<NullifierSnapshotPayload>): NullifierSerializedSnapshot;
|
|
17
17
|
protected deserializeSnapshot(serializedSnapshot: NullifierSerializedSnapshot): Snapshot<NullifierSnapshotPayload>;
|
|
18
18
|
protected acceptEvent(event: NullifierEvent<string>, _blockNumber: number): boolean;
|
|
19
|
-
protected mapEvent(event:
|
|
19
|
+
protected mapEvent(event: NullifierEvent<BigNumber>): NullifierEvent<string>;
|
|
20
20
|
protected getSnapshotPayload(): NullifierSnapshotPayload;
|
|
21
21
|
protected populateSnapshot({ payload: { nullifiers } }: Snapshot<NullifierSnapshotPayload>): void;
|
|
22
22
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
class a extends t {
|
|
1
|
+
import { AbstractSnapshotService as i } from "./AbstractSnapshotService.mjs";
|
|
2
|
+
class n extends i {
|
|
4
3
|
constructor(r) {
|
|
5
4
|
super(r, "Nullified");
|
|
6
5
|
}
|
|
@@ -30,9 +29,9 @@ class a extends t {
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
mapEvent(r) {
|
|
33
|
-
const e = r
|
|
32
|
+
const { nullifier: e } = r;
|
|
34
33
|
return {
|
|
35
|
-
nullifier:
|
|
34
|
+
nullifier: e.toHexString()
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
getSnapshotPayload() {
|
|
@@ -45,5 +44,5 @@ class a extends t {
|
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
export {
|
|
48
|
-
|
|
47
|
+
n as AbstractNullifierSnapshotService
|
|
49
48
|
};
|
|
@@ -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");class i extends a.AbstractEventService{savedLatestBlockNumber=0;chainId=0;constructor(t,e){super(t,e)}async init(){await this.loadSnapshot(),this.chainId=(await this.blockchainEventEmitter.contract.provider.getNetwork()).chainId}async retrieveEventsFromLatestBlock(){await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber)}async loadSnapshot(){const t=await this.fetchSnapshot(),e=this.deserializeSnapshot(t);this.populateSnapshot(e),this.blockchainEventEmitter.syncFromAtMost(e.latestBlockNumber),this.savedLatestBlockNumber=e.latestBlockNumber}saveSnapshot(){return this.savedLatestBlockNumber=this.latestBlockNumber,this.persistSnapshot(this.serializeSnapshot({latestBlockNumber:this.latestBlockNumber,payload:this.getSnapshotPayload()}))}async afterEventsAccepted(t){(t>0||this.savedLatestBlockNumber+s.saveDepths[this.chainId]<this.latestBlockNumber)&&await this.saveSnapshot()}}exports.AbstractSnapshotService=i;
|