@hinkal/common 0.2.18 → 0.2.20
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 +92 -93
- 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/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +5 -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/index.d.ts +1 -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 +7 -2
- package/API/proxyAccountsCalls.mjs +27 -21
- 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/temporaryWalletCalls.cjs +1 -0
- package/API/temporaryWalletCalls.d.ts +13 -0
- package/API/temporaryWalletCalls.mjs +20 -0
- 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 +2 -2
- package/API/unspent-utxos-calls.mjs +17 -18
- package/README.md +239 -64
- 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 +1 -6
- package/constants/chains.constants.mjs +63 -50
- 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/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-solana.json.mjs +28 -2
- 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/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +39 -40
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +1 -0
- package/constants/mediaUrls.constants.mjs +2 -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 +20 -123
- package/constants/server.constants.mjs +39 -142
- 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/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +4 -4
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +4 -4
- package/constants/token-data/popularTokens.constants.cjs +1 -1
- package/constants/token-data/popularTokens.constants.mjs +0 -1
- package/data-structures/AccountActions/AccountActions.cjs +1 -0
- package/data-structures/AccountActions/AccountActions.d.ts +18 -0
- package/data-structures/AccountActions/AccountActions.mjs +78 -0
- package/data-structures/AccountActions/index.d.ts +1 -0
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +68 -71
- package/data-structures/BlockchainEvent/BlockchainEvent.cjs +1 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +14 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.mjs +41 -0
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +45 -54
- package/data-structures/Hinkal/Hinkal.mjs +314 -341
- package/data-structures/Hinkal/IHinkal.d.ts +40 -52
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +49 -50
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +29 -24
- 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 +87 -85
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +78 -169
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +103 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +214 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +4 -5
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +113 -117
- 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 +40 -36
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +37 -32
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +17 -15
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +4 -3
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +84 -95
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +157 -155
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +2 -3
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +43 -40
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +71 -67
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +63 -59
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +81 -77
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +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 +71 -68
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +71 -79
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +72 -71
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +81 -79
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +108 -108
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +107 -53
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.d.ts +1 -0
- package/data-structures/IndexedDB/activity-db.mjs +92 -76
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +40 -37
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +18 -15
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +25 -40
- package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +1 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +20 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +124 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +1 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +15 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +64 -0
- package/data-structures/PublicBalance/index.d.ts +2 -0
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +83 -85
- 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/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +0 -11
- package/data-structures/crypto-keys/keys.mjs +47 -107
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +3 -2
- 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 +3 -2
- 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 +3 -2
- 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 +4 -2
- 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 +6 -5
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +1 -2
- 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 +10 -5
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +39 -35
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +21 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/ClientEventHelper.d.ts +11 -0
- package/data-structures/event-service/helpers/ClientEventHelper.mjs +26 -0
- package/data-structures/event-service/helpers/PollingEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/PollingEventHelper.d.ts +5 -0
- package/data-structures/event-service/helpers/PollingEventHelper.mjs +14 -0
- package/data-structures/event-service/index.d.ts +4 -0
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +3 -2
- 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 +4 -3
- 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 +4 -10
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +10 -7
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +3 -2
- 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 +1 -2
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +1 -2
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +22 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +11 -16
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +64 -66
- package/data-structures/index.d.ts +3 -0
- 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 +6 -4
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +6 -4
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +6 -4
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +6 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +6 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +5 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +6 -4
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +2 -7
- package/data-structures/utxo/Utxo.mjs +40 -36
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +1 -0
- package/error-handling/error-codes.constants.mjs +4 -3
- 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/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +22 -22
- 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/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.mjs +53 -50
- 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 +89 -80
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +4 -5
- package/functions/private-wallet/emporium.helpers.mjs +94 -109
- 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 +1 -2
- package/functions/snarkjs/constructEmporiumProof.mjs +89 -89
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +1 -2
- 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 +58 -59
- package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
- package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +11 -10
- 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/bytes32.utils.cjs +1 -1
- package/functions/utils/bytes32.utils.mjs +8 -7
- 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 +13 -9
- 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/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 +0 -1
- 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 +6 -13
- package/functions/utils/prepareHinkal.mjs +45 -72
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.mjs +49 -54
- package/functions/utils/socket.utils.cjs +1 -0
- package/functions/utils/socket.utils.d.ts +1 -0
- package/functions/utils/socket.utils.mjs +12 -0
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +1 -0
- package/functions/utils/string.utils.mjs +18 -14
- 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 +2 -17
- package/functions/utils/walletBalances.utils.mjs +5 -36
- package/functions/web3/crypto.cjs +1 -0
- package/functions/web3/crypto.d.ts +1 -0
- package/functions/web3/crypto.mjs +7 -0
- 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 +107 -112
- 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 +38 -38
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +13 -10
- 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 +50 -46
- 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/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +36 -40
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +36 -34
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.mjs +17 -22
- 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 +1 -0
- 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 +941 -949
- package/package.json +3 -2
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +10 -17
- package/providers/EthersProviderAdapter.mjs +45 -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 +15 -9
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +16 -9
- package/types/TransactionSimulator.types.d.ts +2 -9
- package/types/activities.types.d.ts +2 -0
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +0 -6
- package/types/admin.types.mjs +2 -2
- package/types/balances.types.d.ts +0 -1
- package/types/bridging-tx.types.d.ts +17 -0
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +6 -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 +2 -8
- package/types/ethereum-network.types.mjs +1 -1
- package/types/events.types.cjs +1 -0
- package/types/events.types.d.ts +9 -0
- package/types/events.types.mjs +5 -0
- 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 +3 -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 +11 -3
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +10 -39
- package/types/sandbox.types.mjs +2 -2
- package/types/session.types.d.ts +2 -0
- package/types/solana.types.d.ts +9 -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/token.types.d.ts +5 -0
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -4
- package/types/transactions.types.mjs +3 -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 +2 -2
- 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/kyc/authentoHelper.cjs +0 -1
- package/functions/kyc/authentoHelper.d.ts +0 -12
- package/functions/kyc/authentoHelper.mjs +0 -30
- 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/get-hinkal-approvals.cjs +0 -1
- package/functions/utils/get-hinkal-approvals.d.ts +0 -3
- package/functions/utils/get-hinkal-approvals.mjs +0 -38
- 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
|
@@ -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 u=require("@solana/web3.js"),p=require("bs58"),s=require("ethers"),P=require("ethers-v6h"),b=require("libsodium-wrappers"),d=require("../../constants/protocol.constants.cjs"),v=require("../../crypto/babyJub.cjs"),n=require("../../crypto/poseidon.cjs"),g=require("../cacheDevices/AttachableMemoryCacheDevice.cjs"),h=require("./keyUtils.cjs"),l=new g.AttachableMemoryCacheDevice,y=new g.AttachableMemoryCacheDevice,m={privateKey:"",publicKey:""};class q{signature;constructor(e){this.signature=e}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error("No signature provided")}verifyMessage(e){return this.requireSignature(),s.utils.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),s.ethers.utils.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),n.poseidonHash(this.getShieldedPrivateKey()));getDerivedEthereumAddress=()=>(this.requireSignature(),new P.ethers.Wallet(this.getShieldedPrivateKey()).address);getDerivedSolanaPublicKey=()=>(this.requireSignature(),u.Keypair.fromSeed(s.utils.arrayify(this.getShieldedPrivateKey())).publicKey.toBase58());getAccessKey=()=>(this.requireSignature(),n.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getSignerPrivateKeyFromNonce=e=>{this.requireSignature();const t=n.poseidonHash(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return s.utils.keccak256(s.utils.toUtf8Bytes(t))};getSignerSolanaPrivateKeyFromNonce=e=>{const t=this.getSignerPrivateKeyFromNonce(e),i=s.utils.arrayify(t),r=u.Keypair.fromSeed(i);return p.encode(r.secretKey)};getWalletSalt=e=>(this.requireSignature(),n.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getInHinkalAddress=e=>{this.requireSignature();const t=n.poseidonHash(this.getShieldedPrivateKey(),e);return BigInt(t)};getBackendToken=()=>(this.requireSignature(),n.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=l.attach((e,t)=>{const i=v.babyJubInstance(),r=BigInt(t)%d.CIRCOM_P,c=e*r%d.CIRCOM_P,a=i.mulPointEscalar(i.Base8,e),o=i.mulPointEscalar(i.Base8,c),S=[BigInt(i.F.toString(a[0])),BigInt(i.F.toString(a[1]))],K=[BigInt(i.F.toString(o[0])),BigInt(i.F.toString(o[1]))];return{H0:S,H1:K}});static getStealthAddressCompressedPoints=(e,t)=>{const{H0:i,H1:r}=this.getRandomizedStealthPair(e,t),[c,a]=[i,r].map(o=>BigInt(o[1])+2n**255n*h.getCircomSign(o[0]));return{h0:c,h1:a}};static getStealthAddress=y.attach((e,t)=>{const{H0:i,H1:r}=this.getRandomizedStealthPair(e,t),a=[2n*h.getCircomSign(i[0])+h.getCircomSign(r[0]),i[1],r[1]];return n.poseidonHash(...a)});static getStealthAddressWithEKey=(e,t)=>({stealthAddress:this.getStealthAddress(e,t),encryptionKey:this.getEncryptionKeyPair(t).publicKey});static checkSignature=(e,t,i,r)=>{const{h0:c,h1:a}=this.getStealthAddressCompressedPoints(e,r);return t===c&&i===a};static getEncryptionKeyPair=e=>{const t=b.crypto_box_seed_keypair(s.ethers.utils.arrayify(e));return{privateKey:s.ethers.utils.hexlify(t.privateKey),publicKey:s.ethers.utils.hexlify(t.publicKey)}}}exports.EncryptionKeyPairDefaultValue=m;exports.UserKeys=q;exports.stealthAddressCacheDevice=y;exports.stealthPairCacheDevice=l;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
1
|
import { AttachableMemoryCacheDevice } from '../cacheDevices/AttachableMemoryCacheDevice';
|
|
3
|
-
import { ethers as ethersV6 } from 'ethers-v6h';
|
|
4
|
-
import { VersionedTransaction } from '@solana/web3.js';
|
|
5
2
|
export declare const stealthPairCacheDevice: AttachableMemoryCacheDevice<{
|
|
6
3
|
H0: [bigint, bigint];
|
|
7
4
|
H1: [bigint, bigint];
|
|
@@ -47,14 +44,6 @@ export declare class UserKeys {
|
|
|
47
44
|
getAccessKey: () => string;
|
|
48
45
|
getSignerPrivateKeyFromNonce: (walletNonce: bigint) => string;
|
|
49
46
|
getSignerSolanaPrivateKeyFromNonce: (walletNonce: bigint) => string;
|
|
50
|
-
getEvmPrivateKeyFromSolanaPrivateKey: (solanaPrivateKey: string) => string;
|
|
51
|
-
private static getSignerFromPrivateKey;
|
|
52
|
-
static getSignerAddressFromPrivateKey(chainId: number, privateKey: string): string;
|
|
53
|
-
static signMessageFromPrivateKey: (chainId: number, privateKey: string, message: string) => Promise<string>;
|
|
54
|
-
static signSolanaTransactionFromPrivateKey: (chainId: number, privateKey: string, transaction: VersionedTransaction) => void;
|
|
55
|
-
static sendAndSignTransactionFromPrivateKey: (chainId: number, privateKey: string, transaction: ethersV6.TransactionRequest | VersionedTransaction) => Promise<string>;
|
|
56
|
-
static signTypedDataFromPrivateKey: (chainId: number, privateKey: string, domain: ethers.TypedDataDomain, types: Record<string, Array<ethers.TypedDataField>>, value: Record<string, any>) => Promise<string>;
|
|
57
|
-
static authorizeDelegation: (chainId: number, privateKey: string, implementation: string, nonce?: number) => Promise<ethersV6.Authorization>;
|
|
58
47
|
getWalletSalt: (walletNonce: bigint) => string;
|
|
59
48
|
/**
|
|
60
49
|
* generate inHinkalAddress - a user unique address linking him with a specific app
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
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 = {
|
|
1
|
+
import { Keypair as u } from "@solana/web3.js";
|
|
2
|
+
import m from "bs58";
|
|
3
|
+
import { utils as h, ethers as c } from "ethers";
|
|
4
|
+
import { ethers as K } from "ethers-v6h";
|
|
5
|
+
import p from "libsodium-wrappers";
|
|
6
|
+
import { CIRCOM_P as d } from "../../constants/protocol.constants.mjs";
|
|
7
|
+
import { babyJubInstance as P } from "../../crypto/babyJub.mjs";
|
|
8
|
+
import { poseidonHash as a } from "../../crypto/poseidon.mjs";
|
|
9
|
+
import { AttachableMemoryCacheDevice as l } from "../cacheDevices/AttachableMemoryCacheDevice.mjs";
|
|
10
|
+
import { getCircomSign as g } from "./keyUtils.mjs";
|
|
11
|
+
const v = new l(), f = new l(), D = {
|
|
15
12
|
privateKey: "",
|
|
16
13
|
publicKey: ""
|
|
17
14
|
};
|
|
18
|
-
class
|
|
15
|
+
class x {
|
|
19
16
|
signature;
|
|
20
17
|
constructor(e) {
|
|
21
18
|
this.signature = e;
|
|
@@ -31,133 +28,76 @@ class l {
|
|
|
31
28
|
throw Error("No signature provided");
|
|
32
29
|
}
|
|
33
30
|
verifyMessage(e) {
|
|
34
|
-
return this.requireSignature(),
|
|
31
|
+
return this.requireSignature(), h.verifyMessage(e, this.signature);
|
|
35
32
|
}
|
|
36
33
|
/**
|
|
37
34
|
* get shielded private key from message signature used to login to the application,
|
|
38
35
|
* this private key is used to generate encryption keypairs as well as public key
|
|
39
36
|
* @retuns 0x-prefixed shielded private key
|
|
40
37
|
*/
|
|
41
|
-
getShieldedPrivateKey = () => (this.requireSignature(),
|
|
38
|
+
getShieldedPrivateKey = () => (this.requireSignature(), c.utils.keccak256(this.signature));
|
|
42
39
|
/**
|
|
43
40
|
* generate shielded public key from private key
|
|
44
41
|
* @param privateKey the key used to generate the shielded public key, this should be the signature
|
|
45
42
|
* that the user provided
|
|
46
43
|
* @retuns shielded public key in hexstring with 0x prefixed
|
|
47
44
|
*/
|
|
48
|
-
getShieldedPublicKey = () => (this.requireSignature(),
|
|
45
|
+
getShieldedPublicKey = () => (this.requireSignature(), a(this.getShieldedPrivateKey()));
|
|
49
46
|
/**
|
|
50
47
|
* deterministically derive an EVM address from the shielded private key
|
|
51
48
|
*/
|
|
52
|
-
getDerivedEthereumAddress = () => (this.requireSignature(), new
|
|
49
|
+
getDerivedEthereumAddress = () => (this.requireSignature(), new K.Wallet(this.getShieldedPrivateKey()).address);
|
|
53
50
|
/**
|
|
54
51
|
* deterministically derive a Solana public key from the shielded private key
|
|
55
52
|
*/
|
|
56
|
-
getDerivedSolanaPublicKey = () => (this.requireSignature(),
|
|
53
|
+
getDerivedSolanaPublicKey = () => (this.requireSignature(), u.fromSeed(h.arrayify(this.getShieldedPrivateKey())).publicKey.toBase58());
|
|
57
54
|
/**
|
|
58
55
|
* generate access token, this accessKey is what should be sent to the server for signing
|
|
59
56
|
* @returns accessKey in hexstring with 0x prefixed
|
|
60
57
|
*/
|
|
61
|
-
getAccessKey = () => (this.requireSignature(),
|
|
58
|
+
getAccessKey = () => (this.requireSignature(), a(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
|
|
62
59
|
getSignerPrivateKeyFromNonce = (e) => {
|
|
63
60
|
this.requireSignature();
|
|
64
|
-
const
|
|
65
|
-
return
|
|
61
|
+
const t = a(e, this.getShieldedPrivateKey(), this.getShieldedPublicKey());
|
|
62
|
+
return h.keccak256(h.toUtf8Bytes(t));
|
|
66
63
|
};
|
|
67
64
|
getSignerSolanaPrivateKeyFromNonce = (e) => {
|
|
68
|
-
const
|
|
69
|
-
return
|
|
65
|
+
const t = this.getSignerPrivateKeyFromNonce(e), r = h.arrayify(t), i = u.fromSeed(r);
|
|
66
|
+
return m.encode(i.secretKey);
|
|
70
67
|
};
|
|
71
|
-
|
|
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));
|
|
68
|
+
getWalletSalt = (e) => (this.requireSignature(), a(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), e));
|
|
129
69
|
/**
|
|
130
70
|
* generate inHinkalAddress - a user unique address linking him with a specific app
|
|
131
71
|
* @returns inHinkalAddress in bigint
|
|
132
72
|
*/
|
|
133
73
|
getInHinkalAddress = (e) => {
|
|
134
74
|
this.requireSignature();
|
|
135
|
-
const
|
|
136
|
-
return BigInt(
|
|
75
|
+
const t = a(this.getShieldedPrivateKey(), e);
|
|
76
|
+
return BigInt(t);
|
|
137
77
|
};
|
|
138
78
|
/**
|
|
139
79
|
* generate backend token, which is used for access control on backend
|
|
140
80
|
* @returns accessKey in hexstring with 0x prefixed
|
|
141
81
|
*/
|
|
142
|
-
getBackendToken = () => (this.requireSignature(),
|
|
143
|
-
static getRandomizedStealthPair =
|
|
144
|
-
(e,
|
|
145
|
-
const
|
|
146
|
-
return { H0:
|
|
82
|
+
getBackendToken = () => (this.requireSignature(), a(this.getAccessKey(), this.getShieldedPublicKey()));
|
|
83
|
+
static getRandomizedStealthPair = v.attach(
|
|
84
|
+
(e, t) => {
|
|
85
|
+
const r = P(), i = BigInt(t) % d, n = e * i % d, s = r.mulPointEscalar(r.Base8, e), o = r.mulPointEscalar(r.Base8, n), y = [BigInt(r.F.toString(s[0])), BigInt(r.F.toString(s[1]))], S = [BigInt(r.F.toString(o[0])), BigInt(r.F.toString(o[1]))];
|
|
86
|
+
return { H0: y, H1: S };
|
|
147
87
|
}
|
|
148
88
|
);
|
|
149
|
-
static getStealthAddressCompressedPoints = (e,
|
|
150
|
-
const { H0:
|
|
151
|
-
return { h0: n, h1:
|
|
89
|
+
static getStealthAddressCompressedPoints = (e, t) => {
|
|
90
|
+
const { H0: r, H1: i } = this.getRandomizedStealthPair(e, t), [n, s] = [r, i].map((o) => BigInt(o[1]) + 2n ** 255n * g(o[0]));
|
|
91
|
+
return { h0: n, h1: s };
|
|
152
92
|
};
|
|
153
|
-
static getStealthAddress =
|
|
154
|
-
const { H0:
|
|
155
|
-
return
|
|
93
|
+
static getStealthAddress = f.attach((e, t) => {
|
|
94
|
+
const { H0: r, H1: i } = this.getRandomizedStealthPair(e, t), s = [2n * g(r[0]) + g(i[0]), r[1], i[1]];
|
|
95
|
+
return a(...s);
|
|
156
96
|
});
|
|
157
|
-
static getStealthAddressWithEKey = (e,
|
|
158
|
-
static checkSignature = (e,
|
|
159
|
-
const { h0: n, h1:
|
|
160
|
-
return
|
|
97
|
+
static getStealthAddressWithEKey = (e, t) => ({ stealthAddress: this.getStealthAddress(e, t), encryptionKey: this.getEncryptionKeyPair(t).publicKey });
|
|
98
|
+
static checkSignature = (e, t, r, i) => {
|
|
99
|
+
const { h0: n, h1: s } = this.getStealthAddressCompressedPoints(e, i);
|
|
100
|
+
return t === n && r === s;
|
|
161
101
|
};
|
|
162
102
|
/**
|
|
163
103
|
* generate private and public keypair
|
|
@@ -165,16 +105,16 @@ class l {
|
|
|
165
105
|
* and must correspond to 32 bytes
|
|
166
106
|
*/
|
|
167
107
|
static getEncryptionKeyPair = (e) => {
|
|
168
|
-
const
|
|
108
|
+
const t = p.crypto_box_seed_keypair(c.utils.arrayify(e));
|
|
169
109
|
return {
|
|
170
|
-
privateKey:
|
|
171
|
-
publicKey:
|
|
110
|
+
privateKey: c.utils.hexlify(t.privateKey),
|
|
111
|
+
publicKey: c.utils.hexlify(t.publicKey)
|
|
172
112
|
};
|
|
173
113
|
};
|
|
174
114
|
}
|
|
175
115
|
export {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
116
|
+
D as EncryptionKeyPairDefaultValue,
|
|
117
|
+
x as UserKeys,
|
|
118
|
+
f as stealthAddressCacheDevice,
|
|
119
|
+
v as stealthPairCacheDevice
|
|
180
120
|
};
|
|
@@ -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"),A=require("../../../functions/utils/merkleTree.utils.cjs");class i 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=A.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 s=e.getArg("accessKey"),r=e.getArg("index"),d=e.getArg("senderAddress");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=i;
|
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
export type SenderAddressIndexMapJson = {
|
|
6
7
|
address: string;
|
|
7
8
|
index: number;
|
|
@@ -17,7 +18,7 @@ export type AccessTokenSerializedSnapshot = {
|
|
|
17
18
|
senderAddresses?: string[];
|
|
18
19
|
senderAddressIndexMap?: SenderAddressIndexMapJson;
|
|
19
20
|
};
|
|
20
|
-
export declare abstract class AbstractAccessTokenSnapshotService extends AbstractSnapshotService<AccessTokenEvent<bigint>,
|
|
21
|
+
export declare abstract class AbstractAccessTokenSnapshotService extends AbstractSnapshotService<AccessTokenEvent<bigint>, AccessTokenSnapshotPayload, AccessTokenSerializedSnapshot> {
|
|
21
22
|
constructor(accessTokenEventFetcher: BlockchainEventEmitter);
|
|
22
23
|
private _merkleTree;
|
|
23
24
|
private _senderAddresses;
|
|
@@ -28,7 +29,7 @@ export declare abstract class AbstractAccessTokenSnapshotService extends Abstrac
|
|
|
28
29
|
protected serializeSnapshot(snapshot: Snapshot<AccessTokenSnapshotPayload>): AccessTokenSerializedSnapshot;
|
|
29
30
|
protected deserializeSnapshot(serializedSnapshot: AccessTokenSerializedSnapshot): Snapshot<AccessTokenSnapshotPayload>;
|
|
30
31
|
protected acceptEvent(event: AccessTokenEvent<bigint>, _blockNumber: number): boolean;
|
|
31
|
-
protected mapEvent(event:
|
|
32
|
+
protected mapEvent(event: BlockchainEvent): AccessTokenEvent<bigint>;
|
|
32
33
|
protected getSnapshotPayload(): AccessTokenSnapshotPayload;
|
|
33
34
|
protected populateSnapshot({ payload: { merkleTree, senderAddresses, senderAddressIndexMap }, }: Snapshot<AccessTokenSnapshotPayload>): void;
|
|
34
35
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
2
|
-
import { poseidonFunction as
|
|
1
|
+
import { zeroAddress as o } from "../../../constants/protocol.constants.mjs";
|
|
2
|
+
import { poseidonFunction as m } 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 A } from "./AbstractSnapshotService.mjs";
|
|
12
|
+
import { contructMerkleTreeFromSerialized as c } from "../../../functions/utils/merkleTree.utils.mjs";
|
|
13
|
+
class g extends A {
|
|
14
14
|
constructor(e) {
|
|
15
15
|
super(e, "NewAccessKeyAdded");
|
|
16
16
|
}
|
|
@@ -39,7 +39,7 @@ class b extends l {
|
|
|
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 = c(e.merkleTree) : s = a.create(m, 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 b extends l {
|
|
|
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 === o && 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 s = e.getArg("accessKey"), r = e.getArg("index"), d = e.getArg("senderAddress");
|
|
65
65
|
return {
|
|
66
66
|
accessKey: t(s),
|
|
67
67
|
index: t(r),
|
|
@@ -82,5 +82,5 @@ class b extends l {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
export {
|
|
85
|
-
|
|
85
|
+
g 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 v=require("./AbstractSnapshotService.cjs"),c=require("../../../functions/utils/amounts.utils.cjs"),u=require("../../../functions/utils/caseInsensitive.utils.cjs");class A extends v.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 t=e.getArg("approveTo"),s=e.getArg("tokenAddress"),r=e.getArg("amount"),p=e.getArg("inHinkalAddress");return{approveTo:t,tokenAddress:s,amount:c.toBigInt(r),inHinkalAddress:c.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,6 +2,7 @@ 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';
|
|
5
6
|
export type ApprovalsSnapshotPayload = {
|
|
6
7
|
readonly approvals: Map<string, ApprovedUtxo[]>;
|
|
7
8
|
readonly events: Set<string>;
|
|
@@ -11,7 +12,7 @@ export type ApprovalsSerializedSnapshot = {
|
|
|
11
12
|
approvals: Record<string, ApprovedUtxo<string>[]>;
|
|
12
13
|
events: string[];
|
|
13
14
|
};
|
|
14
|
-
export declare abstract class AbstractApprovalsSnapshotService extends AbstractSnapshotService<NewApprovedUtxoEvent,
|
|
15
|
+
export declare abstract class AbstractApprovalsSnapshotService extends AbstractSnapshotService<NewApprovedUtxoEvent, ApprovalsSnapshotPayload, ApprovalsSerializedSnapshot> {
|
|
15
16
|
constructor(hinkalEventEmitter: BlockchainEventEmitter);
|
|
16
17
|
private _approvals;
|
|
17
18
|
events: Set<string>;
|
|
@@ -24,6 +25,6 @@ export declare abstract class AbstractApprovalsSnapshotService extends AbstractS
|
|
|
24
25
|
events: Set<string>;
|
|
25
26
|
};
|
|
26
27
|
protected populateSnapshot({ payload: { approvals, events } }: Snapshot<ApprovalsSnapshotPayload>): void;
|
|
27
|
-
protected mapEvent(event:
|
|
28
|
+
protected mapEvent(event: BlockchainEvent): NewApprovedUtxoEvent;
|
|
28
29
|
protected acceptEvent(event: NewApprovedUtxoEvent, _blockNumber: number, txHash: string): boolean;
|
|
29
30
|
}
|
|
@@ -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 A } from "../../../functions/utils/caseInsensitive.utils.mjs";
|
|
4
|
+
class f extends c {
|
|
5
5
|
constructor(e) {
|
|
6
6
|
super(e, "NewApprovedUtxo");
|
|
7
7
|
}
|
|
@@ -57,7 +57,7 @@ class g extends c {
|
|
|
57
57
|
this._approvals = e, this.events = t;
|
|
58
58
|
}
|
|
59
59
|
mapEvent(e) {
|
|
60
|
-
const
|
|
60
|
+
const t = e.getArg("approveTo"), s = e.getArg("tokenAddress"), r = e.getArg("amount"), p = e.getArg("inHinkalAddress");
|
|
61
61
|
return {
|
|
62
62
|
approveTo: t,
|
|
63
63
|
tokenAddress: s,
|
|
@@ -75,7 +75,7 @@ class g 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
|
+
A(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 g extends c {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
export {
|
|
91
|
-
|
|
91
|
+
f 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 n=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 m 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(n.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 t=e.getArg("commitment"),s=e.getArg("index"),r=e.getArg("encryptedOutput");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 c={value:e.encryptedOutput,isPositive:e.index>=0n,isBlocked:r??!1};return this._encryptedOutputs.push(c),!0}return!1}}exports.AbstractCommitmentsSnapshotService=m;
|
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
export type CommitmentsSnapshotPayload = {
|
|
6
7
|
readonly merkleTree: MerkleTree<bigint>;
|
|
7
8
|
readonly encryptedOutputs: EncryptedOutputWithSign[];
|
|
@@ -11,7 +12,7 @@ export type CommitmentsSerializedSnapshot = {
|
|
|
11
12
|
merkleTree?: MerkleTreeJson;
|
|
12
13
|
encryptedOutputs?: EncryptedOutputWithSign<string>[];
|
|
13
14
|
};
|
|
14
|
-
export declare abstract class AbstractCommitmentsSnapshotService extends AbstractSnapshotService<CommitmentEvent<bigint>,
|
|
15
|
+
export declare abstract class AbstractCommitmentsSnapshotService extends AbstractSnapshotService<CommitmentEvent<bigint>, CommitmentsSnapshotPayload, CommitmentsSerializedSnapshot> {
|
|
15
16
|
constructor(hinkalEventEmitter: BlockchainEventEmitter);
|
|
16
17
|
private _merkleTree;
|
|
17
18
|
private _encryptedOutputs;
|
|
@@ -24,6 +25,6 @@ export declare abstract class AbstractCommitmentsSnapshotService extends Abstrac
|
|
|
24
25
|
encryptedOutputs: EncryptedOutputWithSign<boolean>[];
|
|
25
26
|
};
|
|
26
27
|
protected populateSnapshot({ payload: { merkleTree, encryptedOutputs }, }: Snapshot<CommitmentsSnapshotPayload>): void;
|
|
27
|
-
protected mapEvent(event:
|
|
28
|
+
protected mapEvent(event: BlockchainEvent): CommitmentEvent<bigint>;
|
|
28
29
|
protected acceptEvent(event: CommitmentEvent<bigint>, _blockNumber: number, _txHash?: string, isBlocked?: boolean): boolean;
|
|
29
30
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { poseidonFunction as
|
|
1
|
+
import { poseidonFunction as c } 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 m } 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 x extends o {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super(e, "NewCommitment");
|
|
15
15
|
}
|
|
@@ -34,7 +34,7 @@ class b 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 = m.create(c, 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 b extends o {
|
|
|
60
60
|
this._merkleTree = e, this._encryptedOutputs = t;
|
|
61
61
|
}
|
|
62
62
|
mapEvent(e) {
|
|
63
|
-
const
|
|
63
|
+
const t = e.getArg("commitment"), s = e.getArg("index"), r = e.getArg("encryptedOutput");
|
|
64
64
|
return {
|
|
65
65
|
commitment: p(t),
|
|
66
66
|
index: p(s),
|
|
@@ -82,5 +82,5 @@ class b extends o {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
export {
|
|
85
|
-
|
|
85
|
+
x 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 l=require("../../../functions/utils/resolve-sync.utils.cjs");class h{blockchainEventEmitter;eventName;constructor(t,s){this.blockchainEventEmitter=t,this.eventName=s,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 s=new Set;t.forEach(({eventName:e,transactionHash:c})=>{e==="BlockedUtxosCreated"&&s.add(c)});const n=[];await l.resolveSync(t.map(e=>async()=>{if(e.eventName!==this.eventName)return;const{blockNumber:c,transactionHash:a}=e,r=this.mapEvent(e),o=s.has(a);await this.acceptEvent(r,c,a,o)&&n.push(r)}));const i=n.length;return await this.afterEventsAccepted(i),n.length}}exports.AbstractEventService=h;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
|
|
1
2
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
2
|
-
export declare abstract class AbstractEventService<EventType
|
|
3
|
+
export declare abstract class AbstractEventService<EventType> {
|
|
3
4
|
protected blockchainEventEmitter: BlockchainEventEmitter;
|
|
4
5
|
protected readonly eventName: string;
|
|
5
6
|
protected constructor(blockchainEventEmitter: BlockchainEventEmitter, eventName: string);
|
|
6
7
|
get latestBlockNumber(): number;
|
|
8
|
+
get chainId(): number;
|
|
7
9
|
intervalClear(): void;
|
|
8
10
|
private processEventsPage;
|
|
9
11
|
protected abstract acceptEvent(event: EventType, blockNumber: number, txHash?: string, isBlocked?: boolean): boolean | Promise<boolean>;
|
|
10
|
-
protected abstract mapEvent(event:
|
|
12
|
+
protected abstract mapEvent(event: BlockchainEvent): EventType;
|
|
11
13
|
protected abstract afterEventsAccepted(eventsCount: number): Promise<void>;
|
|
12
14
|
}
|