@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,19 +1,19 @@
|
|
|
1
1
|
import { ethers as k } from "ethers";
|
|
2
2
|
import { get as P, update as I } from "idb-keyval";
|
|
3
3
|
import { Mutex as b } from "async-mutex";
|
|
4
|
-
import { chainIds as f, ALCHEMY_API_KEY as T
|
|
4
|
+
import { chainIds as f, ALCHEMY_API_KEY as T } from "../../constants/chains.constants.mjs";
|
|
5
5
|
import { Logger as C } from "../../error-handling/logger.mjs";
|
|
6
|
-
import { getStateKey as
|
|
7
|
-
import { StorageKeys as
|
|
8
|
-
import { httpClient as
|
|
6
|
+
import { getStateKey as S } from "../../functions/utils/string.utils.mjs";
|
|
7
|
+
import { StorageKeys as y } from "../../types/cache.types.mjs";
|
|
8
|
+
import { httpClient as M } from "../http/HttpClient.mjs";
|
|
9
9
|
import { API as $ } from "../../API/API.mjs";
|
|
10
10
|
import { RevokeType as w } from "../../types/approvals.types.mjs";
|
|
11
|
-
import { isNFTToken as
|
|
11
|
+
import { isNFTToken as R } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
12
12
|
import { createCustomRpcProvider as F } from "../../functions/utils/create-provider.mjs";
|
|
13
|
-
import { EVENTS_INITIAL_BLOCKS as
|
|
14
|
-
import { caseInsensitiveEqual as
|
|
13
|
+
import { EVENTS_INITIAL_BLOCKS as U } from "../../constants/events.constants.mjs";
|
|
14
|
+
import { caseInsensitiveEqual as E } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
15
15
|
import { zeroAddress as B } from "../../constants/protocol.constants.mjs";
|
|
16
|
-
class
|
|
16
|
+
class O {
|
|
17
17
|
updateMutexes = {};
|
|
18
18
|
approvalTopic = k.utils.id("Approval(address,address,uint256)");
|
|
19
19
|
approvalForAllTopic = k.utils.id("ApprovalForAll(address,address,bool)");
|
|
@@ -38,88 +38,85 @@ class N {
|
|
|
38
38
|
return `https://${s}.g.alchemy.com/v2/${T}`;
|
|
39
39
|
}
|
|
40
40
|
async getApprovals(e, s) {
|
|
41
|
-
const r =
|
|
42
|
-
return (await P(
|
|
41
|
+
const r = S(s, e);
|
|
42
|
+
return (await P(y.EVENTS_PUBLIC_APPROVALS))?.[r] || [];
|
|
43
43
|
}
|
|
44
44
|
async getLastProcessedBlock(e, s) {
|
|
45
|
-
const r = await P(
|
|
46
|
-
return r[
|
|
45
|
+
const r = await P(y.PUBLIC_APPROVALS_LAST_PROCESSED_BLOCKS) || {}, c = S(s, e);
|
|
46
|
+
return r[c] || U[e];
|
|
47
47
|
}
|
|
48
48
|
async updateLastProcessedBlock(e, s, r) {
|
|
49
|
-
await I(
|
|
50
|
-
const
|
|
49
|
+
await I(y.PUBLIC_APPROVALS_LAST_PROCESSED_BLOCKS, (c = {}) => {
|
|
50
|
+
const p = S(s, e);
|
|
51
51
|
return {
|
|
52
|
-
...
|
|
53
|
-
[
|
|
52
|
+
...c,
|
|
53
|
+
[p]: r
|
|
54
54
|
};
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
async getApprovalEvents(e, s) {
|
|
58
58
|
try {
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
topics: [[this.approvalTopic, this.approvalForAllTopic], E],
|
|
67
|
-
fromBlock: i,
|
|
68
|
-
toBlock: l
|
|
59
|
+
const r = F(s), c = await this.getLastProcessedBlock(s, e) + 1, p = await r.getBlockNumber();
|
|
60
|
+
if (c > p)
|
|
61
|
+
return { approvalEvents: [], latestBlock: p };
|
|
62
|
+
const m = k.utils.hexZeroPad(e.toLowerCase(), 32), L = {
|
|
63
|
+
topics: [[this.approvalTopic, this.approvalForAllTopic], m],
|
|
64
|
+
fromBlock: c,
|
|
65
|
+
toBlock: p
|
|
69
66
|
};
|
|
70
|
-
return { approvalEvents: await
|
|
67
|
+
return { approvalEvents: await r.getLogs(L), latestBlock: p };
|
|
71
68
|
} catch (r) {
|
|
72
69
|
return C.error("Failed to fetch approval events", r), { approvalEvents: [], latestBlock: void 0 };
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
72
|
async checkCurrentAllowances(e, s, r) {
|
|
76
|
-
const
|
|
73
|
+
const c = this.getAlchemyUrl(e), p = `0x${s.substring(2).padStart(64, "0")}`, m = [...new Set(r.map((t) => t.contractAddress))], L = (await $.tokensInfoCall(e, m)).filter((t) => !!t), d = new Map(L.map((t) => [t.erc20TokenAddress.toLowerCase(), t])), i = [], v = [];
|
|
77
74
|
if (r.forEach((t, o) => {
|
|
78
|
-
const a =
|
|
75
|
+
const a = d.get(t.contractAddress.toLowerCase());
|
|
79
76
|
if (a)
|
|
80
|
-
if (!
|
|
81
|
-
|
|
77
|
+
if (!R(a))
|
|
78
|
+
i.push({
|
|
82
79
|
jsonrpc: "2.0",
|
|
83
|
-
id:
|
|
80
|
+
id: i.length,
|
|
84
81
|
method: "alchemy_getTokenAllowance",
|
|
85
82
|
params: [{ contract: t.contractAddress, owner: s, spender: t.spenderAddress }]
|
|
86
83
|
}), v.push({ pairIndex: o, type: w.ERC20 });
|
|
87
84
|
else {
|
|
88
|
-
const
|
|
89
|
-
|
|
85
|
+
const A = `0x${t.spenderAddress.substring(2).padStart(64, "0")}`, g = `${this.isApprovedForAllSelector}${p.substring(2)}${A.substring(2)}`;
|
|
86
|
+
i.push({
|
|
90
87
|
jsonrpc: "2.0",
|
|
91
|
-
id:
|
|
88
|
+
id: i.length,
|
|
92
89
|
method: "eth_call",
|
|
93
90
|
params: [{ to: t.contractAddress, data: g }, "latest"]
|
|
94
91
|
}), v.push({ pairIndex: o, type: w.approvedForAll }), t.tokenIds && t.tokenIds.size > 0 && t.tokenIds.forEach((h) => {
|
|
95
92
|
const _ = k.BigNumber.from(h).toHexString().substring(2).padStart(64, "0"), x = `${this.getApprovedSelector}${_}`;
|
|
96
|
-
|
|
93
|
+
i.push({
|
|
97
94
|
jsonrpc: "2.0",
|
|
98
|
-
id:
|
|
95
|
+
id: i.length,
|
|
99
96
|
method: "eth_call",
|
|
100
97
|
params: [{ to: t.contractAddress, data: x }, "latest"]
|
|
101
98
|
}), v.push({ pairIndex: o, type: w.tokenId, tokenId: h });
|
|
102
99
|
});
|
|
103
100
|
}
|
|
104
|
-
}),
|
|
101
|
+
}), i.length === 0)
|
|
105
102
|
return [];
|
|
106
|
-
const n = await
|
|
103
|
+
const n = await M.post(c, i), l = [], u = /* @__PURE__ */ new Set();
|
|
107
104
|
return n.forEach((t, o) => {
|
|
108
105
|
const a = v[o];
|
|
109
106
|
if (!a)
|
|
110
107
|
return;
|
|
111
|
-
const
|
|
112
|
-
if (!(!g ||
|
|
108
|
+
const A = r[a.pairIndex], g = d.get(A.contractAddress.toLowerCase());
|
|
109
|
+
if (!(!g || E(A.spenderAddress, B)) && !t?.error && t?.result && t.result !== "0x")
|
|
113
110
|
try {
|
|
114
111
|
if (a.type === w.ERC20 && BigInt(t.result) > 0n)
|
|
115
|
-
|
|
112
|
+
l.push({ token: g, spenderAddress: A.spenderAddress, allowance: BigInt(t.result) });
|
|
116
113
|
else if (a.type === w.approvedForAll && BigInt(t.result) === 1n)
|
|
117
|
-
|
|
118
|
-
else if (a.type === w.tokenId && !
|
|
114
|
+
u.add(a.pairIndex), l.push({ token: g, spenderAddress: A.spenderAddress, allowance: 1n });
|
|
115
|
+
else if (a.type === w.tokenId && !u.has(a.pairIndex)) {
|
|
119
116
|
const h = `0x${t.result.substring(26)}`.toLowerCase();
|
|
120
|
-
!
|
|
117
|
+
!E(h, B) && E(h, A.spenderAddress) && l.push({
|
|
121
118
|
token: g,
|
|
122
|
-
spenderAddress:
|
|
119
|
+
spenderAddress: A.spenderAddress,
|
|
123
120
|
allowance: 1n,
|
|
124
121
|
tokenId: a.tokenId
|
|
125
122
|
});
|
|
@@ -127,49 +124,49 @@ class N {
|
|
|
127
124
|
} catch (h) {
|
|
128
125
|
C.error("Error processing approval response", h);
|
|
129
126
|
}
|
|
130
|
-
}),
|
|
127
|
+
}), l;
|
|
131
128
|
}
|
|
132
129
|
async fetchAndUpdatePublicApprovals(e, s) {
|
|
133
|
-
const r =
|
|
130
|
+
const r = S(e, s);
|
|
134
131
|
await this.getMutex(r).runExclusive(async () => {
|
|
135
132
|
try {
|
|
136
|
-
const { approvalEvents:
|
|
137
|
-
if (!
|
|
133
|
+
const { approvalEvents: p, latestBlock: m } = await this.getApprovalEvents(e, s);
|
|
134
|
+
if (!m)
|
|
138
135
|
return;
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
142
|
-
let o =
|
|
143
|
-
o || (o = { contractAddress:
|
|
144
|
-
}),
|
|
136
|
+
const L = await this.getApprovals(s, e), d = /* @__PURE__ */ new Map();
|
|
137
|
+
if (L.forEach((n) => {
|
|
138
|
+
const l = n.token.erc20TokenAddress.toLowerCase(), u = n.spenderAddress.toLowerCase(), t = `${l}_${u}`;
|
|
139
|
+
let o = d.get(t);
|
|
140
|
+
o || (o = { contractAddress: l, spenderAddress: u, tokenIds: /* @__PURE__ */ new Set() }, d.set(t, o)), n.tokenId && o.tokenIds && o.tokenIds.add(n.tokenId);
|
|
141
|
+
}), p.forEach((n) => {
|
|
145
142
|
if (!n.topics[2])
|
|
146
143
|
return;
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
144
|
+
const l = n.address.toLowerCase(), u = `0x${n.topics[2].substring(26)}`.toLowerCase();
|
|
145
|
+
if (E(u, B))
|
|
149
146
|
return;
|
|
150
|
-
const t = `${
|
|
151
|
-
let o =
|
|
152
|
-
if (o || (o = { contractAddress:
|
|
147
|
+
const t = `${l}_${u}`;
|
|
148
|
+
let o = d.get(t);
|
|
149
|
+
if (o || (o = { contractAddress: l, spenderAddress: u, tokenIds: /* @__PURE__ */ new Set() }, d.set(t, o)), n.topics.length === 4 && o.tokenIds) {
|
|
153
150
|
const a = BigInt(n.topics[3]).toString();
|
|
154
151
|
o.tokenIds.add(a);
|
|
155
152
|
}
|
|
156
|
-
}),
|
|
157
|
-
await this.updateLastProcessedBlock(s, e,
|
|
153
|
+
}), d.size === 0) {
|
|
154
|
+
await this.updateLastProcessedBlock(s, e, m);
|
|
158
155
|
return;
|
|
159
156
|
}
|
|
160
|
-
const
|
|
161
|
-
await I(
|
|
157
|
+
const i = Array.from(d.values()), v = await this.checkCurrentAllowances(s, e, i);
|
|
158
|
+
await I(y.EVENTS_PUBLIC_APPROVALS, (n = {}) => ({
|
|
162
159
|
...n,
|
|
163
160
|
[r]: v
|
|
164
|
-
})), await this.updateLastProcessedBlock(s, e,
|
|
165
|
-
} catch (
|
|
166
|
-
C.error("Failed to sync approvals",
|
|
161
|
+
})), await this.updateLastProcessedBlock(s, e, m);
|
|
162
|
+
} catch (p) {
|
|
163
|
+
C.error("Failed to sync approvals", p);
|
|
167
164
|
}
|
|
168
165
|
});
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
|
-
const
|
|
168
|
+
const et = new O();
|
|
172
169
|
export {
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
O as EventsPublicApprovalsDB,
|
|
171
|
+
et as eventsPublicApprovalsDB
|
|
175
172
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("ethers");class i{eventName;transactionHash;blockNumber;args;constructor(e,r,s,n){this.eventName=e,this.transactionHash=r,this.blockNumber=s,this.args=n}static fromSerialized(e){const{eventName:r,transactionHash:s,blockNumber:n,args:a}=JSON.parse(e);return new i(r,s,n,a)}static fromEthers(e){const{event:r,transactionHash:s,blockNumber:n,args:a={}}=e,o=Object.fromEntries(Object.entries(a).map(([t,c])=>[t,b.ethers.BigNumber.isBigNumber(c)?c.toString():c])),m=JSON.stringify(o);return new i(r??"",s,n,m)}static fromSolanaEvent(e){const{eventName:r,signature:s,slot:n,data:a={}}=e,o=JSON.stringify(a,(m,t)=>typeof t=="object"&&t!==null&&"type"in t&&"data"in t&&t.type==="Buffer"&&Array.isArray(t.data)?t.data:t);return new i(r,s,n,o)}getArg(e){return JSON.parse(this.args)[e]}serialize(){return JSON.stringify({eventName:this.eventName,transactionHash:this.transactionHash,blockNumber:this.blockNumber,args:this.args})}}exports.BlockchainEvent=i;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SolanaEvent } from '../../types/solana.types';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
export declare class BlockchainEvent {
|
|
4
|
+
eventName: string;
|
|
5
|
+
transactionHash: string;
|
|
6
|
+
blockNumber: number;
|
|
7
|
+
private args;
|
|
8
|
+
constructor(eventName: string, transactionHash: string, blockNumber: number, args: string);
|
|
9
|
+
static fromSerialized(serialized: string): BlockchainEvent;
|
|
10
|
+
static fromEthers(event: ethers.Event): BlockchainEvent;
|
|
11
|
+
static fromSolanaEvent(event: SolanaEvent): BlockchainEvent;
|
|
12
|
+
getArg<T>(key: string): T;
|
|
13
|
+
serialize(): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ethers as N } from "ethers";
|
|
2
|
+
class i {
|
|
3
|
+
eventName;
|
|
4
|
+
transactionHash;
|
|
5
|
+
blockNumber;
|
|
6
|
+
args;
|
|
7
|
+
constructor(r, e, s, n) {
|
|
8
|
+
this.eventName = r, this.transactionHash = e, this.blockNumber = s, this.args = n;
|
|
9
|
+
}
|
|
10
|
+
static fromSerialized(r) {
|
|
11
|
+
const { eventName: e, transactionHash: s, blockNumber: n, args: a } = JSON.parse(r);
|
|
12
|
+
return new i(e, s, n, a);
|
|
13
|
+
}
|
|
14
|
+
static fromEthers(r) {
|
|
15
|
+
const { event: e, transactionHash: s, blockNumber: n, args: a = {} } = r, o = Object.fromEntries(
|
|
16
|
+
Object.entries(a).map(([t, c]) => [t, N.BigNumber.isBigNumber(c) ? c.toString() : c])
|
|
17
|
+
), m = JSON.stringify(o);
|
|
18
|
+
return new i(e ?? "", s, n, m);
|
|
19
|
+
}
|
|
20
|
+
static fromSolanaEvent(r) {
|
|
21
|
+
const { eventName: e, signature: s, slot: n, data: a = {} } = r, o = JSON.stringify(
|
|
22
|
+
a,
|
|
23
|
+
(m, t) => typeof t == "object" && t !== null && "type" in t && "data" in t && t.type === "Buffer" && Array.isArray(t.data) ? t.data : t
|
|
24
|
+
);
|
|
25
|
+
return new i(e, s, n, o);
|
|
26
|
+
}
|
|
27
|
+
getArg(r) {
|
|
28
|
+
return JSON.parse(this.args)[r];
|
|
29
|
+
}
|
|
30
|
+
serialize() {
|
|
31
|
+
return JSON.stringify({
|
|
32
|
+
eventName: this.eventName,
|
|
33
|
+
transactionHash: this.transactionHash,
|
|
34
|
+
blockNumber: this.blockNumber,
|
|
35
|
+
args: this.args
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
i as BlockchainEvent
|
|
41
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../types/hinkal.types.cjs"),S=require("../../types/ethereum-network.types.cjs"),x=require("./hinkalCheckSolanaTokenRegistry.cjs"),m=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),w=require("../crypto-keys/keys.cjs"),I=require("./hinkalDeposit.cjs"),K=require("./hinkalDepositAndWithdraw.cjs"),A=require("./hinkalSolanaDeposit.cjs"),U=require("./hinkalSwap.cjs"),L=require("./hinkalWithdraw.cjs"),B=require("./hinkalWithdrawStuckUtxos.cjs"),N=require("./resetMerkleTrees.cjs"),M=require("../merkle-tree/MerkleTree.cjs");require("ethers");const R=require("../../error-handling/error-codes.constants.cjs"),F=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../constants/chains.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const _=require("../../constants/vite.constants.cjs"),P=require("../../API/API.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const O=require("../../constants/kyc.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../API/tenderly.api.cjs");const j=require("../../functions/utils/reloadPage.cjs"),z=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),$=require("./hinkalPrivateWallet.cjs"),J=require("../../functions/utils/cacheFunctions.cjs"),Q=require("../../functions/utils/cacheDevice.utils.cjs"),V=require("../../functions/web3/getContractMetadata.cjs"),X=require("./hinkalGetRecipientInfo.cjs"),Y=require("./hinkalApprove.cjs"),Z=require("./hinkalInsideTransact.cjs"),v=require("../../functions/web3/events/getApprovedBalance.cjs"),C=require("../../functions/web3/functionCalls/inHinkalApprovalCalls.cjs"),G=require("./hinkalSignSubAccount.cjs"),ee=require("./hinkalCheckTokenRegistry.cjs"),te=require("./hinkalActionReceive.cjs"),re=require("./hinkalActionFundApproveAndTransact.cjs"),ie=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ae=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const g=require("@solana/web3.js");require("@solana/spl-token");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const E=require("../../functions/pre-transaction/solana.cjs");require("@coral-xyz/anchor");require("../../functions/utils/userAgent.cjs");require("../../functions/utils/mutexes.utils.cjs");require("node-forge");require("../../functions/web3/getTokenHolder.cjs");const ne=require("../../functions/private-wallet/emporium.helpers.cjs"),se=require("./hinkalProoflessDeposit.cjs"),oe=require("./hinkalProxySwap.cjs"),ce=require("./hinkalMultiSend.cjs"),he=require("./hinkalTransfer.cjs"),le=require("./hinkalProxyToPrivate.cjs"),de=require("./hinkalSolanaDepositAndWithdraw.cjs"),pe=require("./hinkalSolanaWithdraw.cjs"),ue=require("./hinkalSolanaTransfer.cjs"),ge=require("./hinkalSolanaSwap.cjs"),ke=require("./hinkalSolanaProxySend.cjs"),ve=require("./hinkalSolanaProxySwap.cjs"),D=require("./hinkalSolanaProxyShield.cjs"),H=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs");class ye{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;approvals;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;approvalsSnapshotService;utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new w.UserKeys(void 0),this.merkleTreeHinkal=M.MerkleTree.create(F.poseidonFunction,0n),this.merkleTreeAccessToken=M.MerkleTree.create(F.poseidonFunction,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.approvals=new Map,this.generateProofRemotely=e?.generateProofRemotely??!1,this.utxoUtils=new z.MultiThreadedUtxoUtils,this.cacheDevice=Q.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(e=!1){const t=e?this.privateTransferSigningMessage:this.signingMessage;this.userKeys=new w.UserKeys(await this.getProviderAdapter().signMessage(t))}async initUserKeysWithPassword(e){this.userKeys=new w.UserKeys(e)}async resetMerkle(){this.disableMerkleTreeUpdates||this.isSelectedNetworkSupported()&&await N.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}getContractWithFetcherByChainId(e,t,r=void 0){return V.getContractWithFetcherByChainId(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}async signWithSubAccount(e,t,r){return G.hinkalSignSubAccount(this,e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!h.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(R.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}async switchAccount(e){await this.getProviderAdapter().switchAccount(e)}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=T.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=T.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),j.reloadPage()}async monitorConnectedAddress(){const e=this.getCurrentChainId();h.isSolanaLike(e)||await P.API.monitor(await this.getEthereumAddress(),e)}async getBalances(e,t,r,i,a=!1,s,n=!1){return W.getShieldedBalance(this,e,t,r,i,a,this.generateProofRemotely,s,n)}async getApprovedBalances(e=!1,t=!1){return v.getApprovedBalance(this,e,t)}async getTotalBalance(e,t,r,i=!1,a,s=!1){const n=e??this.getCurrentChainId(),o=r??await this.getEthereumAddress(),c=t??this.userKeys,d=await this.getBalances(n,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),o,i,a,s),p=!h.isSolanaLike(n)&&!s?await this.getApprovedBalances(i,a):new Map,l=_.isExtension?await ie.privateTokensDB.getPrivateTokens(n,o):ae.getErc20TokensForChain(n),u=[];return l.forEach(k=>{const f=k.erc20TokenAddress.toLowerCase(),y=d.get(f),q=p.get(f),b={token:k,balance:(y?.balance??0n)+(q?.balance??0n),timestamp:y?.timestamp||q?.timestamp||"0",nfts:y?.nfts||[]};u.push(b)}),u}async getStuckShieldedBalances(e,t){return(await this.getTotalBalance(e,void 0,t,!1,!1,!0)).filter(i=>i.balance>0n)}getSupportedPassportLinks(){return O.supportedPassportLinks}checkAccessToken(){return m.checkHinkalAccessToken(this)}async mintHinkalAccessToken(e,t){return m.mintAccessToken(this,e,t)}async getHinkalTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:a}=h.networkRegistry[e].contractData;if(!r||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const s=new g.PublicKey(a),n=new g.PublicKey(i),o=E.getMerkleAccountPublicKey(n,s),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:a}=h.networkRegistry[e].contractData;if(!r||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const s=new g.PublicKey(a),n=new g.PublicKey(i),o=E.getAccessTokenMerkleAccountPublicKey(n,s),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(R.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(e.toBigInt()!==this.merkleTreeHinkal.getRootHash()||t.toBigInt()!==this.merkleTreeAccessToken.getRootHash())&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary"),await this.resetMerkle())}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock(),this.approvalsSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(e=!1){const t=this.getCurrentChainId();return(await P.API.getIdleRelay(t,e)).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return P.API}resetCache(){J.resetCache(this,this.getCurrentChainId(),this.userKeys.getShieldedPublicKey())}snapshotsClearInterval(){this.commitmentsSnapshotService?.intervalClear(),this.accessTokenSnapshotService?.intervalClear(),this.nullifierSnapshotService?.intervalClear(),this.approvalsSnapshotService?.intervalClear()}checkTokenRegistry(e,t){const r=this.getCurrentChainId();if(h.isSolanaLike(r)){const{hinkalIdl:a,hinkalAddress:s,originalDeployer:n}=h.networkRegistry[r].contractData;if(!a||!s||!n)throw new Error("missing solana data");const o=this.getSolanaProgram(a),c=new g.PublicKey(n);return x.hinkalCheckSolanaTokenRegistry(o,c,e,t)}const i=this.getContractWithFetcher(S.ContractType.HinkalHelperContract);return ee.hinkalCheckTokenRegistry(i,e,t)}getRecipientInfo(){return X.getRecipientInfo(this)}async getInteractionApprovals(e){return await C.getInteractionApprovals(this,e)}getApprovedUtxos(e=!1){return v.getApprovedUtxos(this,e)}getApprovedUtxosForToken(e,t=!1){return v.getApprovedUtxosForToken(this,e,t)}getMyApprovalAmountForInteraction(e,t){return v.getMyApprovalAmountForInteraction(this,e,t)}async checkExistingApprovalFromHinkal(e,t){return await C.checkExistingApprovalFromHinkal(this,e,t)}async getBufferEntry(e,t,r){return C.getBufferEntry(this,e,t,r)}async deposit(e,t){return I.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return I.hinkalDepositForOther(this,e,t,r)}async depositAndWithdraw(e,t,r,i,a){return h.isSolanaLike(this.getCurrentChainId())?de.hinkalSolanaDepositAndWithdraw(this,e.erc20TokenAddress,t,r,i,a):K.hinkalDepositAndWithdraw(this,e,t,r,i,a)}async prooflessDeposit(e,t,r){return se.hinkalProoflessDeposit(this,e,t,r)}getSolanaProgram(e){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaPublicKey()}async depositSolana(e,t){return A.hinkalSolanaDeposit(this,e,t)}async depositSolanaForOther(e,t,r){return A.hinkalSolanaDepositForOther(this,e,t,r)}async solanaMultiPaymentDeposit(e,t){return A.hinkalSolanaMultiPaymentDeposit(this,e,t)}async transfer(e,t,r,i,a,s,n=!1){return h.isSolanaLike(this.getCurrentChainId())?ue.hinkalSolanaTransfer(this,e,t,r,i,a,n):he.hinkalTransfer(this,e,t,r,i,a,s,n)}async withdraw(e,t,r,i,a,s,n,o=!1){return h.isSolanaLike(this.getCurrentChainId())?pe.hinkalSolanaWithdraw(this,e.map(c=>c.erc20TokenAddress),t,r,a,s,o):L.hinkalWithdraw(this,e,t,r,i,a,s,n,o)}async withdrawStuckUtxos(e,t){return B.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,r,i,a,s,n,o=!1,c=!1){return h.isSolanaLike(this.getCurrentChainId())?this.swapSolana(e,t,i,a,s,o):U.hinkalSwap(this,e,t,r,i,a,s,n,o,c)}async swapSolana(e,t,r,i,a,s=!1){const n=JSON.parse(r),{instructionLists:o,addressLookupTableAccount:c}=n.data;return ge.hinkalSolanaSwap(this,e,t,o,c,i,a,s)}async actionReceive(e,t,r,i,a,s,n=!1){if(!a)throw new Error("subAccount is required");return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],a,void 0,n):te.hinkalActionReceive(this,e,t,r,i,a,s,n)}async actionFundApproveAndTransact(e,t,r,i,a,s,n,o,c=!1,d,p,l){return re.hinkalActionFundApproveAndTransact(this,e,t,r,i,a,s,n,o,c,d,p,l)}async actionPrivateWallet(e,t,r,i,a,s,n,o,c,d=!1,p,l,u,k=!1){return $.hinkalPrivateWallet(this,e,t,r,i,a,s,n,o,c,d,p,l,u,k)}async approve(e,t,r,i,a,s=!1){return Y.hinkalApprove(this,e,t,r,i,a,s)}async hinkalInsideTransact(e,t,r,i,a,s,n,o,c,d=!1){return Z.hinkalInsideTransact(this,e,t,r,i,a,s,n,o,c,d)}async proxySwap(e,t,r,i,a,s,n,o,c=!1,d,p,l=!1){return h.isSolanaLike(this.getCurrentChainId())?ve.hinkalSolanaProxySwap(this,e,t,i,s,n,o,l):oe.hinkalProxySwap(this,e,t,r,i,a,s,n,o,c,d,p,l)}async proxyToPrivate(e,t,r,i,a,s,n,o=!1){return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],r,i,o):le.hinkalProxyToPrivate(this,e,t,i,a,s,r,n,o)}async proxySend(e,t,r,i,a,s,n,o=!1){if(h.isSolanaLike(this.getCurrentChainId()))return ke.hinkalSolanaProxySend(this,e[0],t[0],r,i,o);const c=ne.createTransaferEmporiumOpsBatch(this,e.map(l=>l.erc20TokenAddress),t,i),d=e.map((l,u)=>({token:l,amount:-1n*t[u]}));return await this.actionPrivateWallet([],[],[],c,d,r,a,s,void 0,void 0,void 0,n,void 0,o)}async multiSendPrivateRecipients(e,t,r){return ce.hinkalMultiSendPrivateRecipients(this,e,t,r)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=ye;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("ethers"),L=require("../../types/hinkal.types.cjs"),P=require("../../types/ethereum-network.types.cjs"),H=require("./hinkalCheckSolanaTokenRegistry.cjs"),b=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),U=require("../../functions/web3/events/getShieldedBalance.cjs"),S=require("../crypto-keys/keys.cjs"),m=require("./hinkalDeposit.cjs"),W=require("./hinkalDepositAndWithdraw.cjs"),A=require("./hinkalSolanaDeposit.cjs"),F=require("./hinkalSwap.cjs"),K=require("./hinkalWithdraw.cjs"),x=require("./hinkalWithdrawStuckUtxos.cjs"),I=require("./resetMerkleTrees.cjs"),T=require("../merkle-tree/MerkleTree.cjs"),_=require("../../error-handling/error-codes.constants.cjs"),B=require("../../crypto/poseidon.cjs"),l=require("../../constants/chains.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const w=require("../../API/API.cjs");require("../../API/tenderly.api.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const N=require("../../constants/kyc.constants.cjs"),O=require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");const j=require("../../functions/utils/reloadPage.cjs"),z=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),G=require("./hinkalPrivateWallet.cjs"),$=require("../../functions/utils/cacheDevice.utils.cjs"),J=require("../../functions/web3/getContractMetadata.cjs"),Q=require("./hinkalGetRecipientInfo.cjs"),C=require("../../functions/web3/events/getApprovedBalance.cjs"),V=require("./hinkalSignSubAccount.cjs"),X=require("./hinkalCheckTokenRegistry.cjs"),Y=require("./hinkalActionReceive.cjs"),Z=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ee=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const v=require("@solana/web3.js");require("@solana/spl-token");const p=require("../../functions/utils/token-check.utils.cjs");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const M=require("../../functions/pre-transaction/solana.cjs");require("ethers-v6h");require("tweetnacl");require("bs58");require("@coral-xyz/anchor");require("buffer");require("../../functions/utils/userAgent.cjs");require("libsodium-wrappers");require("circomlibjs-hinkal-fork");require("process");require("../../providers/EthersProviderAdapter.cjs");const re=require("../../providers/SolanaProviderAdapter.cjs");require("../../functions/web3/events/getInputUtxoAndBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");require("node-forge");const te=require("../../functions/private-wallet/emporium.helpers.cjs"),ae=require("./hinkalProoflessDeposit.cjs"),ie=require("./hinkalProxySwap.cjs"),ne=require("./hinkalMultiSend.cjs"),se=require("./hinkalTransfer.cjs"),oe=require("./hinkalProxyToPrivate.cjs"),le=require("./hinkalSolanaDepositAndWithdraw.cjs"),he=require("./hinkalSolanaWithdraw.cjs"),ce=require("./hinkalSolanaTransfer.cjs"),de=require("./hinkalSolanaSwap.cjs"),ue=require("./hinkalSolanaProxySend.cjs"),pe=require("./hinkalSolanaProxySwap.cjs"),R=require("./hinkalSolanaProxyShield.cjs"),D=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs"),ge=require("./hinkalDepostAndBridge.cjs");class ke{ethereumProviderAdapter;solanaProviderAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkalByChain={};merkleTreeAccessTokenByChain={};nullifiersByChain={};encryptedOutputsByChain={};approvalsByChain={};commitmentsSnapshotServiceByChain={};nullifierSnapshotServiceByChain={};accessTokenSnapshotServiceByChain={};approvalsSnapshotServiceByChain={};utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new S.UserKeys(void 0),l.WALLET_SUPPORTED_CHAINS.forEach(r=>{this.merkleTreeHinkalByChain[r]=T.MerkleTree.create(B.poseidonFunction,0n),this.merkleTreeAccessTokenByChain[r]=T.MerkleTree.create(B.poseidonFunction,0n),this.nullifiersByChain[r]=new Set,this.encryptedOutputsByChain[r]=[],this.approvalsByChain[r]=new Map}),this.generateProofRemotely=e?.generateProofRemotely??!1,this.utxoUtils=new z.MultiThreadedUtxoUtils,this.cacheDevice=$.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,r){const t=r instanceof re.SolanaProviderAdapter;await this.updateProviderAdapter(t?l.chainIds.solanaMainnet:l.chainIds.ethMainnet,r),t?this.solanaProviderAdapter?.initConnector(e):this.ethereumProviderAdapter?.initConnector(e);const a=await this.connectAndPatchProvider(t,e);await r.init(a),await this.setListeners()}async initUserKeys(e=!1){const r=e?this.privateTransferSigningMessage:this.signingMessage;this.userKeys=new S.UserKeys(await this.getProviderAdapter().signMessage(r))}async initUserKeysWithPassword(e){this.userKeys=new S.UserKeys(e)}async initUserKeysFromSeedPhrases(e){const r=e.join(" "),t=q.ethers.utils.toUtf8Bytes(r),a=q.ethers.utils.keccak256(t);this.userKeys=new S.UserKeys(a)}async resetMerkle(e){if(this.disableMerkleTreeUpdates)return;(e?.every(t=>this.isSelectedNetworkSupported(t))??!0)&&await I.resetMerkleTrees(this,e)}getProviderAdapter(e){const r=e??(this.ethereumProviderAdapter?l.chainIds.ethMainnet:l.chainIds.solanaMainnet),t=l.isSolanaLike(r)?this.solanaProviderAdapter:this.ethereumProviderAdapter;if(!t)throw new Error("ProviderAdapter is not initialized");return t}getSupportedChains(){return this.ethereumProviderAdapter&&this.solanaProviderAdapter?l.WALLET_SUPPORTED_CHAINS:this.ethereumProviderAdapter?l.WALLET_SUPPORTED_CHAINS.filter(e=>!l.isSolanaLike(e)):this.solanaProviderAdapter?l.WALLET_SUPPORTED_CHAINS.filter(e=>l.isSolanaLike(e)):[]}async waitForTransaction(e,r,t=1){return!!await this.getProviderAdapter(e).waitForTransaction(e,r,t)}getContract(e,r,t=void 0){return this.getProviderAdapter(e).getContract(e,r,t)}getContractWithFetcherByChainId(e,r,t=void 0){return J.getContractWithFetcherByChainId(e,r,t)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,r,t){return await this.getProviderAdapter().signTypedData(e,r,t)}async signWithSubAccount(e,r,t,a){return V.hinkalSignSubAccount(e,r,t,a)}getContractWithSigner(e,r,t=""){return this.getProviderAdapter(e).getContractWithSigner(e,r,t)}getContractWithFetcher(e,r,t=""){return this.getProviderAdapter(e).getContractWithFetcher(e,r,t)}isSelectedNetworkSupported(e){return!!l.networkRegistry[e]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(_.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}isPermitterAvailable(e){return this.getProviderAdapter(e).isPermitterAvailable()}async connectAndPatchProvider(e,r){return await this.getProviderAdapter(e?l.chainIds.solanaMainnet:l.chainIds.ethMainnet).connectAndPatchProvider(r)}async disconnectFromConnector(){await this.ethereumProviderAdapter?.disconnectFromConnector(),await this.solanaProviderAdapter?.disconnectFromConnector()}async updateProviderAdapter(e,r){try{l.isSolanaLike(e)?(this.solanaProviderAdapter&&this.solanaProviderAdapter.release(),this.solanaProviderAdapter=r):(this.ethereumProviderAdapter&&this.ethereumProviderAdapter.release(),this.ethereumProviderAdapter=r)}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.ethereumProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}}),this.solanaProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.ethereumProviderAdapter?.onAccountChanged(),await this.solanaProviderAdapter?.onAccountChanged();const e=L.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){e?await this.getProviderAdapter(e).onChainChanged(e):(await this.disconnectFromConnector(),j.reloadPage())}async monitorConnectedAddress(e){await w.API.monitor(await this.getEthereumAddressByChain(e))}async getBalances(e,r,t,a,i=!1,n,s=!1){return U.getShieldedBalance(this,e,r,t,a,i,this.generateProofRemotely,n,s)}async getApprovedBalances(e,r=!1,t=!1){return C.getApprovedBalance(this,e,r,t)}async getTotalBalance(e,r,t,a=!1,i,n=!1){const s=t??await this.getEthereumAddressByChain(e),o=r??this.userKeys,h=await this.getBalances(e,o.getShieldedPrivateKey(),o.getShieldedPublicKey(),s,a,i,n),c=!l.isSolanaLike(e)&&!n?await this.getApprovedBalances(e,a,i):new Map,g=O.isExtension?await Z.privateTokensDB.getPrivateTokens(e,s):ee.getErc20TokensForChain(e),u=[];return g.forEach(d=>{const k=d.erc20TokenAddress.toLowerCase(),y=h.get(k),f=c.get(k),E={token:d,balance:(y?.balance??0n)+(f?.balance??0n),timestamp:y?.timestamp||f?.timestamp||"0",nfts:y?.nfts||[]};u.push(E)}),u}async getStuckShieldedBalances(e,r){return(await this.getTotalBalance(e,void 0,r,!1,!1,!0)).filter(a=>a.balance>0n)}getSupportedPassportLinks(){return N.supportedPassportLinks}checkAccessToken(e){return b.checkHinkalAccessToken(this,e)}async getHinkalTreeRootHash(e){if(l.isSolanaLike(e)){const{hinkalIdl:t,hinkalAddress:a,originalDeployer:i}=l.networkRegistry[e].contractData;if(!t||!a||!i)throw new Error(`Missing Solana configuration for chain ${e}`);const n=new v.PublicKey(i),s=new v.PublicKey(a),o=M.getMerkleAccountPublicKey(s,n),h=this.getSolanaProgram(t);return D.fetchSolanaMerkleTreeRootHash(h,o)}return this.getContractWithFetcherByChainId(e,P.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(e){if(l.isSolanaLike(e)){const{hinkalIdl:t,hinkalAddress:a,originalDeployer:i}=l.networkRegistry[e].contractData;if(!t||!a||!i)throw new Error(`Missing Solana configuration for chain ${e}`);const n=new v.PublicKey(i),s=new v.PublicKey(a),o=M.getAccessTokenMerkleAccountPublicKey(s,n),h=this.getSolanaProgram(t);return D.fetchSolanaMerkleTreeRootHash(h,o)}return this.getContractWithFetcherByChainId(e,P.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){const r=(await Promise.all(this.getSupportedChains().map(async t=>{const[a,i]=await Promise.all([this.getHinkalTreeRootHash(t),this.getAccessTokenTreeRootHash(t)]),n=a.toBigInt()!==this.merkleTreeHinkalByChain[t].getRootHash()||i.toBigInt()!==this.merkleTreeAccessTokenByChain[t].getRootHash();return{chainId:t,needsReset:n}}))).filter(t=>t.needsReset).map(t=>t.chainId);r.length>0&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary for chains:",r),await this.resetMerkle(r))}async getEventsFromHinkal(){const e=this.getSupportedChains().flatMap(r=>[this.accessTokenSnapshotServiceByChain[r]?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotServiceByChain[r]?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotServiceByChain[r]?.retrieveEventsFromLatestBlock(),this.approvalsSnapshotServiceByChain[r]?.retrieveEventsFromLatestBlock()]);await Promise.all(e)}async getEthereumAddress(){const e=this.ethereumProviderAdapter??this.solanaProviderAdapter;if(!e)throw new Error("No provider adapter initialized");return e.getAddress()}getEthereumAddressByChain(e){return this.getProviderAdapter(e).getAddress()}async getRandomRelay(e,r=!1){return(await w.API.getIdleRelay(e,r)).relay}getGasPrice(e){const r=this.getProviderAdapter(e);if(!r)throw new Error("Illegal State of providerAdapter in Hinkal: no providerAdapter initialized");return r.getGasPrice(e)}getAPI(){return w.API}snapshotsClearInterval(){this.getSupportedChains().forEach(e=>{this.commitmentsSnapshotServiceByChain[e]?.intervalClear(),this.accessTokenSnapshotServiceByChain[e]?.intervalClear(),this.nullifierSnapshotServiceByChain[e]?.intervalClear(),this.approvalsSnapshotServiceByChain[e]?.intervalClear()})}checkTokenRegistry(e,r,t){if(l.isSolanaLike(e)){const{hinkalIdl:i,hinkalAddress:n,originalDeployer:s}=l.networkRegistry[e].contractData;if(!i||!n||!s)throw new Error("missing solana data");const o=this.getSolanaProgram(i),h=new v.PublicKey(s);return H.hinkalCheckSolanaTokenRegistry(o,h,r,t)}const a=this.getContractWithFetcher(e,P.ContractType.HinkalHelperContract);return X.hinkalCheckTokenRegistry(a,r,t)}getRecipientInfo(){return Q.getRecipientInfo(this)}getApprovedUtxos(e,r=!1){return C.getApprovedUtxos(this,e,r)}getApprovedUtxosForToken(e,r,t=!1){return C.getApprovedUtxosForToken(this,e,r,t)}async deposit(e,r){return m.hinkalDeposit(this,e,r)}async depositForOther(e,r,t){return m.hinkalDepositForOther(this,e,r,t)}async depositAndWithdraw(e,r,t,a,i){const n=p.validateAndGetChainId([e]);return l.isSolanaLike(n)?le.hinkalSolanaDepositAndWithdraw(this,e,r,t,a,i):W.hinkalDepositAndWithdraw(this,e,r,t,a,i)}async depositAndBridge(e,r,t,a){return ge.hinkalDepositAndBridge(this,e,r,t,a)}async prooflessDeposit(e,r,t){return ae.hinkalProoflessDeposit(this,e,r,t)}getSolanaProgram(e){if(!this.solanaProviderAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.solanaProviderAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.solanaProviderAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.solanaProviderAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.solanaProviderAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.solanaProviderAdapter.getSolanaPublicKey()}async depositSolana(e,r){return A.hinkalSolanaDeposit(this,e,r)}async depositSolanaForOther(e,r,t){return A.hinkalSolanaDepositForOther(this,e,r,t)}async solanaMultiPaymentDeposit(e,r){return A.hinkalSolanaMultiPaymentDeposit(this,e,r)}async transfer(e,r,t,a,i,n,s=!1){const o=p.validateAndGetChainId(e);return l.isSolanaLike(o)?ce.hinkalSolanaTransfer(this,e,r,t,a,i,s):se.hinkalTransfer(this,e,r,t,a,i,n,s)}async withdraw(e,r,t,a,i,n,s,o=!1){const h=p.validateAndGetChainId(e);return l.isSolanaLike(h)?he.hinkalSolanaWithdraw(this,e,r,t,i,n,o):K.hinkalWithdraw(this,e,r,t,a,i,n,s,o)}async withdrawStuckUtxos(e,r){return x.hinkalWithdrawStuckUtxos(this,e,r)}async swap(e,r,t,a,i,n,s,o=!1,h=!1){const c=p.validateAndGetChainId(e);return l.isSolanaLike(c)?this.swapSolana(e,r,a,i,n,o):F.hinkalSwap(this,e,r,t,a,i,n,s,o,h)}async swapSolana(e,r,t,a,i,n=!1){const s=JSON.parse(t),o=BigInt(s.swapperAccountSalt),{instructionLists:h,addressLookupTableAccount:c}=s.data;return de.hinkalSolanaSwap(this,e,r,o,h,c,a,i,n)}async actionReceive(e,r,t,a,i,n,s=!1){if(!i)throw new Error("subAccount is required");const o=p.validateAndGetChainId(e);return l.isSolanaLike(o)?R.hinkalSolanaProxyShield(this,e[0],r[0],i,void 0,s):Y.hinkalActionReceive(this,e,r,t,a,i,n,s)}async actionPrivateWallet(e,r,t,a,i,n,s,o,h,c,g=!1,u,d,k,y=!1){return G.hinkalPrivateWallet(this,e,r,t,a,i,n,s,o,h,c,g,u,d,k,y)}async proxySwap(e,r,t,a,i,n,s,o,h=!1,c,g,u=!1){const d=p.validateAndGetChainId(e);return l.isSolanaLike(d)?pe.hinkalSolanaProxySwap(this,e,r,a,n,s,o,u):ie.hinkalProxySwap(this,e,r,t,a,i,n,s,o,h,c,g,u)}async proxyToPrivate(e,r,t,a,i,n,s,o=!1){const h=p.validateAndGetChainId(e);return l.isSolanaLike(h)?R.hinkalSolanaProxyShield(this,e[0],r[0],t,a,o):oe.hinkalProxyToPrivate(this,e,r,a,i,n,t,s,o)}async proxySend(e,r,t,a,i,n,s,o=!1){const h=p.validateAndGetChainId(e);if(l.isSolanaLike(h))return ue.hinkalSolanaProxySend(e[0],r[0],t,a,o);const c=te.createTransaferEmporiumOpsBatch(this,h,e.map(d=>d.erc20TokenAddress),r,a),g=e.map((d,k)=>({token:d,amount:-1n*r[k]}));return await this.actionPrivateWallet(h,[],[],[],c,g,t,i,n,void 0,void 0,void 0,s,void 0,o)}async multiSendPrivateRecipients(e,r,t){return ne.hinkalMultiSendPrivateRecipients(this,e,r,t)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=ke;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
import { type ApprovedUtxo, ApprovedUtxoWithInteractionAddress, FeeStructure, HinkalConfig
|
|
3
|
-
import {
|
|
2
|
+
import { type ApprovedUtxo, ApprovedUtxoWithInteractionAddress, FeeStructure, HinkalConfig } from '../../types/hinkal.types';
|
|
3
|
+
import { ContractType, EthereumNetwork } from '../../types/ethereum-network.types';
|
|
4
4
|
import type { EncryptedOutputWithSign } from '../../types/commitments.types';
|
|
5
5
|
import { ExternalActionId } from '../../types/external-action.types';
|
|
6
6
|
import { type IMultiThreadedUtxoUtils } from '../../types/IMultiThreadedUtxoUtils';
|
|
7
7
|
import { type RelayerTransaction } from '../../types/relayer.types';
|
|
8
|
-
import { type SignatureData } from '../../types/crypto.types';
|
|
9
8
|
import type { ERC20Token, PrivateRecipientInfo, TokenBalance, TokenChanges } from '../../types/token.types';
|
|
10
9
|
import { UserKeys } from '../crypto-keys/keys';
|
|
11
10
|
import { type IProviderAdapter } from '../provider-adapter/IProviderAdapter';
|
|
@@ -19,20 +18,22 @@ import { AdminTransactionType } from '../../types/admin.types';
|
|
|
19
18
|
import { ClientAccessTokenSnapshotService, ClientApprovalsSnapshotService, ClientCommitmentsSnapshotService, ClientNullifierSnapshotService, ClientSolanaAccessTokenSnapshotService, ClientSolanaCommitmentsSnapshotService, ClientSolanaNullifierSnapshotService } from '../snapshot';
|
|
20
19
|
import { Idl, Program } from '@coral-xyz/anchor';
|
|
21
20
|
import { PublicKey } from '@solana/web3.js';
|
|
21
|
+
import { BridgeRecipient } from '../../types/bridging-tx.types';
|
|
22
22
|
export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
23
|
-
private
|
|
23
|
+
private ethereumProviderAdapter?;
|
|
24
|
+
private solanaProviderAdapter?;
|
|
24
25
|
userKeys: UserKeys;
|
|
25
26
|
readonly signingMessage: string;
|
|
26
27
|
readonly privateTransferSigningMessage: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
merkleTreeHinkalByChain: Record<number, MerkleTree<bigint>>;
|
|
29
|
+
merkleTreeAccessTokenByChain: Record<number, MerkleTree<bigint>>;
|
|
30
|
+
nullifiersByChain: Record<number, Set<string>>;
|
|
31
|
+
encryptedOutputsByChain: Record<number, EncryptedOutputWithSign[]>;
|
|
32
|
+
approvalsByChain: Record<number, Map<string, ApprovedUtxo[]>>;
|
|
33
|
+
commitmentsSnapshotServiceByChain: Record<number, ClientCommitmentsSnapshotService | ClientSolanaCommitmentsSnapshotService | undefined>;
|
|
34
|
+
nullifierSnapshotServiceByChain: Record<number, ClientNullifierSnapshotService | ClientSolanaNullifierSnapshotService | undefined>;
|
|
35
|
+
accessTokenSnapshotServiceByChain: Record<number, ClientAccessTokenSnapshotService | ClientSolanaAccessTokenSnapshotService | undefined>;
|
|
36
|
+
approvalsSnapshotServiceByChain: Record<number, ClientApprovalsSnapshotService | undefined>;
|
|
36
37
|
utxoUtils: IMultiThreadedUtxoUtils;
|
|
37
38
|
cacheDevice: ICacheDevice;
|
|
38
39
|
generateProofRemotely: boolean;
|
|
@@ -41,75 +42,65 @@ export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
|
41
42
|
initProviderAdapter(connector: ConnectorType, providerAdapter: IProviderAdapter<ConnectorType>): Promise<void>;
|
|
42
43
|
initUserKeys(isPrivateTransfer?: boolean): Promise<void>;
|
|
43
44
|
initUserKeysWithPassword(password: string): Promise<void>;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
initUserKeysFromSeedPhrases(seedPhrases: string[]): Promise<void>;
|
|
46
|
+
resetMerkle(chains?: number[]): Promise<void>;
|
|
47
|
+
getProviderAdapter(chainId?: number): IProviderAdapter<ConnectorType>;
|
|
48
|
+
getSupportedChains(): number[];
|
|
49
|
+
waitForTransaction(chainId: number, transactionHash: string, confirmations?: number): Promise<boolean>;
|
|
50
|
+
getContract(chainId: number, contractType: ContractType, contractAddress?: undefined): ethers.Contract;
|
|
49
51
|
getContractWithFetcherByChainId(chainId: number, contractType: ContractType, contractAddress?: undefined): ethers.Contract;
|
|
50
52
|
signMessage(message: string): Promise<string>;
|
|
51
53
|
signTypedData(domain: ethers.TypedDataDomain, types: Record<string, ethers.TypedDataField[]>, value: Record<string, unknown>): Promise<string>;
|
|
52
|
-
signWithSubAccount(messageToSign: string | undefined, typedData: TypedData | undefined, subAccount: SubAccount): Promise<string>;
|
|
53
|
-
getContractWithSigner(
|
|
54
|
-
getContractWithFetcher(
|
|
55
|
-
|
|
56
|
-
isSelectedNetworkSupported(): boolean;
|
|
54
|
+
signWithSubAccount(chainId: number, messageToSign: string | undefined, typedData: TypedData | undefined, subAccount: SubAccount): Promise<string>;
|
|
55
|
+
getContractWithSigner(chainId: number, contractType: ContractType, contractAddress?: string): ethers.Contract;
|
|
56
|
+
getContractWithFetcher(chainId: number, contractType: ContractType, contractAddress?: string): ethers.Contract;
|
|
57
|
+
isSelectedNetworkSupported(chainId: number): boolean;
|
|
57
58
|
switchNetwork(network: EthereumNetwork): Promise<void>;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
getSelectedNetwork(): EthereumNetwork | undefined;
|
|
61
|
-
isPermitterAvailable(): boolean;
|
|
62
|
-
connectAndPatchProvider(connector: ConnectorType): Promise<number>;
|
|
59
|
+
isPermitterAvailable(chainId: number): boolean;
|
|
60
|
+
private connectAndPatchProvider;
|
|
63
61
|
disconnectFromConnector(): Promise<void>;
|
|
64
|
-
updateProviderAdapter
|
|
62
|
+
private updateProviderAdapter;
|
|
65
63
|
setListeners(): Promise<void>;
|
|
66
64
|
private onAccountChanged;
|
|
67
65
|
private onChainChanged;
|
|
68
|
-
monitorConnectedAddress(): Promise<void>;
|
|
66
|
+
monitorConnectedAddress(chainId: number): Promise<void>;
|
|
69
67
|
getBalances(chainId: number, passedShieldedPrivateKey: string, passedShieldedPublicKey: string, ethAddress: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean, useBlockedUtxos?: boolean): Promise<Map<string, TokenBalance>>;
|
|
70
|
-
getApprovedBalances(resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<Map<string, TokenBalance>>;
|
|
71
|
-
getTotalBalance(
|
|
72
|
-
getStuckShieldedBalances(
|
|
68
|
+
getApprovedBalances(chainId: number, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<Map<string, TokenBalance>>;
|
|
69
|
+
getTotalBalance(chainId: number, _userKeys?: UserKeys, _ethAddress?: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean, useBlockedUtxos?: boolean): Promise<TokenBalance[]>;
|
|
70
|
+
getStuckShieldedBalances(chainId: number, _ethAddress?: string): Promise<TokenBalance[]>;
|
|
73
71
|
getSupportedPassportLinks(): string[];
|
|
74
|
-
checkAccessToken(): Promise<boolean>;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
getAccessTokenTreeRootHash(): Promise<any>;
|
|
72
|
+
checkAccessToken(chainId: number): Promise<boolean>;
|
|
73
|
+
getHinkalTreeRootHash(chainId: number): Promise<any>;
|
|
74
|
+
getAccessTokenTreeRootHash(chainId: number): Promise<any>;
|
|
78
75
|
resetMerkleTreesIfNecessary(): Promise<void>;
|
|
79
76
|
getEventsFromHinkal(): Promise<void>;
|
|
80
77
|
getEthereumAddress(): Promise<string>;
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
getEthereumAddressByChain(chainId: number): Promise<string>;
|
|
79
|
+
getRandomRelay(chainId: number, markAsPending?: boolean): Promise<string | undefined>;
|
|
80
|
+
getGasPrice(chainId: number): Promise<bigint>;
|
|
83
81
|
getAPI(): IAPI;
|
|
84
|
-
resetCache(): void;
|
|
85
82
|
snapshotsClearInterval(): void;
|
|
86
|
-
checkTokenRegistry(erc20Addresses: string[], amountChanges: bigint[]): Promise<boolean>;
|
|
83
|
+
checkTokenRegistry(chainId: number, erc20Addresses: string[], amountChanges: bigint[]): Promise<boolean>;
|
|
87
84
|
getRecipientInfo(): string;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
getApprovedUtxosForToken(erc20Address: string, resetCacheBefore?: boolean): ApprovedUtxoWithInteractionAddress[];
|
|
91
|
-
getMyApprovalAmountForInteraction(interactionAddress: string, tokenAddress: string): bigint;
|
|
92
|
-
checkExistingApprovalFromHinkal(erc20Address: string, interactionAddress: string): Promise<bigint>;
|
|
93
|
-
getBufferEntry(approveTo: string, tokenAddress: string, inHinkalAddress: bigint): Promise<bigint>;
|
|
85
|
+
getApprovedUtxos(chainId: number, resetCacheBefore?: boolean): ApprovedUtxoWithInteractionAddress[];
|
|
86
|
+
getApprovedUtxosForToken(erc20Address: string, chainId: number, resetCacheBefore?: boolean): ApprovedUtxoWithInteractionAddress[];
|
|
94
87
|
deposit(erc20Tokens: ERC20Token[], amountChanges: bigint[]): Promise<ethers.ContractTransaction>;
|
|
95
88
|
depositForOther(erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientInfo: string): Promise<ethers.ContractTransaction>;
|
|
96
89
|
depositAndWithdraw(erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure): Promise<string>;
|
|
90
|
+
depositAndBridge(erc20Token: ERC20Token, recipientBridges: BridgeRecipient[], txCompletionTime?: number, feeStructureOverride?: FeeStructure): Promise<string>;
|
|
97
91
|
prooflessDeposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructures?: StealthAddressStructure[]): Promise<ethers.ContractTransaction>;
|
|
98
92
|
getSolanaProgram(idl: Idl): Program;
|
|
99
93
|
getSolanaPublicKey(): PublicKey;
|
|
100
|
-
depositSolana(amount: bigint,
|
|
101
|
-
depositSolanaForOther(amount: bigint,
|
|
102
|
-
solanaMultiPaymentDeposit(amounts: bigint[],
|
|
94
|
+
depositSolana(amount: bigint, token: ERC20Token): Promise<string>;
|
|
95
|
+
depositSolanaForOther(amount: bigint, token: ERC20Token, recipientInfo: string): Promise<string>;
|
|
96
|
+
solanaMultiPaymentDeposit(amounts: bigint[], token: ERC20Token): Promise<string>;
|
|
103
97
|
transfer(erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
104
98
|
withdraw(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], recipientAddress: string, isRelayerOff: boolean, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<ethers.ContractTransaction | RelayerTransaction | bigint>;
|
|
105
99
|
withdrawStuckUtxos(erc20Token: ERC20Token, recipientAddress: string): Promise<RelayerTransaction[]>;
|
|
106
100
|
swap(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, swapData: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean, withPrivateMempool?: boolean): Promise<RelayerTransaction | bigint>;
|
|
107
101
|
swapSolana(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], swapData: string, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean): Promise<RelayerTransaction>;
|
|
108
102
|
actionReceive(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], feeToken?: string, feeStructureOverride?: FeeStructure, subAccount?: SubAccount, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
109
|
-
|
|
110
|
-
actionPrivateWallet(erc20Addresses: string[], deltaAmounts: bigint[], onChainCreation: boolean[], ops: string[], emporiumTokenChanges: TokenChanges<bigint>[], subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, relayOverride?: string, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, privateRecipientInfo?: PrivateRecipientInfo, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
111
|
-
approve(erc20Addresses: string[], amount: bigint, approveTo: string, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
112
|
-
hinkalInsideTransact(erc20Addresses: string[], deltaChanges: bigint[], approvalChanges: bigint[], externalAddress: string, externalActionMetadata: string, parsedInLogicMetadata: ParsedInLogicMetadata, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
103
|
+
actionPrivateWallet(chainId: number, erc20Tokens: ERC20Token[], deltaAmounts: bigint[], onChainCreation: boolean[], ops: string[], emporiumTokenChanges: TokenChanges<bigint>[], subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, relayOverride?: string, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, privateRecipientInfo?: PrivateRecipientInfo, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
113
104
|
proxySwap(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, swapData: string, isTheSameChainSwap: boolean, subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
114
105
|
proxyToPrivate(erc20Tokens: ERC20Token[], deltaAmountsBase: bigint[], subAccount: SubAccount, recipientInfo: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
115
106
|
proxySend(erc20Tokens: ERC20Token[], amounts: bigint[], subAccount: SubAccount, recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|