@hinkal/common 0.2.21 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/API.cjs +1 -1
- package/API/API.d.ts +14 -14
- package/API/API.mjs +88 -87
- package/API/admin-calls.cjs +1 -1
- package/API/admin-calls.d.ts +1 -1
- package/API/admin-calls.mjs +4 -4
- package/API/ai-calls.cjs +1 -0
- package/API/ai-calls.d.ts +17 -0
- package/API/ai-calls.mjs +21 -0
- package/API/callLifiAPI.cjs +1 -1
- package/API/callLifiAPI.d.ts +1 -1
- package/API/callLifiAPI.mjs +5 -5
- package/API/callMonitor.cjs +1 -1
- package/API/callMonitor.d.ts +1 -1
- package/API/callMonitor.mjs +7 -7
- package/API/callOdosAPI.cjs +1 -1
- package/API/callOdosAPI.mjs +11 -11
- package/API/callOkxAPI.cjs +1 -1
- package/API/callOkxAPI.d.ts +1 -1
- package/API/callOkxAPI.mjs +5 -5
- package/API/callOneInchAPI.cjs +1 -1
- package/API/callOneInchAPI.mjs +11 -10
- package/API/callRelayer.cjs +1 -1
- package/API/callRelayer.d.ts +5 -6
- package/API/callRelayer.mjs +11 -11
- package/API/checkRisk.cjs +1 -1
- package/API/checkRisk.d.ts +1 -1
- package/API/checkRisk.mjs +4 -4
- package/API/deposit-and-withdraw-status-calls.cjs +1 -0
- package/API/deposit-and-withdraw-status-calls.d.ts +20 -0
- package/API/deposit-and-withdraw-status-calls.mjs +18 -0
- package/API/duneAPI.cjs +1 -0
- package/API/duneAPI.d.ts +11 -0
- package/API/duneAPI.mjs +25 -0
- package/API/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +4 -5
- package/API/fetchCommitmentsCache.cjs +1 -1
- package/API/fetchCommitmentsCache.mjs +9 -9
- package/API/get-token-data.cjs +1 -1
- package/API/get-token-data.d.ts +1 -1
- package/API/get-token-data.mjs +5 -5
- package/API/getBridgeProtocols.cjs +1 -0
- package/API/getBridgeProtocols.d.ts +7 -0
- package/API/getBridgeProtocols.mjs +8 -0
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.mjs +9 -9
- package/API/getLifiStatus.cjs +1 -0
- package/API/getLifiStatus.d.ts +24 -0
- package/API/getLifiStatus.mjs +15 -0
- package/API/getRelayerURL.cjs +1 -0
- package/API/getRelayerURL.d.ts +1 -0
- package/API/getRelayerURL.mjs +10 -0
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.d.ts +3 -3
- package/API/getServerURL.mjs +67 -51
- package/API/getTokenPrice.cjs +1 -1
- package/API/getTokenPrice.d.ts +0 -5
- package/API/getTokenPrice.mjs +7 -14
- package/API/index.d.ts +3 -1
- package/API/is-tx-stateless.cjs +1 -1
- package/API/is-tx-stateless.d.ts +1 -1
- package/API/is-tx-stateless.mjs +12 -10
- package/API/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +8 -4
- package/API/kycCalls.mjs +26 -23
- package/API/passwordCalls.cjs +1 -0
- package/API/passwordCalls.d.ts +9 -0
- package/API/passwordCalls.mjs +13 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +2 -7
- package/API/proxyAccountsCalls.mjs +21 -27
- package/API/relayCalls.cjs +1 -1
- package/API/relayCalls.mjs +4 -4
- package/API/restoreSnapshots.cjs +1 -0
- package/API/restoreSnapshots.d.ts +1 -0
- package/API/restoreSnapshots.mjs +10 -0
- package/API/scheduled-transactions-calls.cjs +1 -1
- package/API/scheduled-transactions-calls.d.ts +9 -1
- package/API/scheduled-transactions-calls.mjs +9 -5
- package/API/simulate-batch-tx.cjs +1 -1
- package/API/simulate-batch-tx.d.ts +2 -2
- package/API/simulate-batch-tx.mjs +6 -7
- package/API/solana-calls.cjs +1 -1
- package/API/solana-calls.d.ts +3 -6
- package/API/solana-calls.mjs +15 -15
- package/API/temporaryWalletCalls.cjs +1 -1
- package/API/temporaryWalletCalls.mjs +19 -13
- package/API/token-calls.cjs +1 -1
- package/API/token-calls.mjs +5 -6
- package/README.md +64 -256
- package/constants/activity.constants.cjs +1 -1
- package/constants/activity.constants.mjs +0 -1
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.mjs +9 -10
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +6 -0
- package/constants/chains.constants.mjs +52 -58
- package/constants/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.d.ts +0 -1
- package/constants/coingecko.constants.mjs +10 -11
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.d.ts +3 -3
- package/constants/contracts.constants.mjs +29 -29
- package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-solana.json.mjs +2 -28
- package/constants/function-signatures.constants.cjs +1 -1
- package/constants/function-signatures.constants.d.ts +1 -0
- package/constants/function-signatures.constants.mjs +4 -3
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +40 -39
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +0 -1
- package/constants/mediaUrls.constants.mjs +1 -2
- package/constants/permit2.constants.cjs +1 -1
- package/constants/permit2.constants.d.ts +1 -0
- package/constants/permit2.constants.mjs +11 -10
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +123 -19
- package/constants/server.constants.mjs +138 -35
- package/constants/tasks.constants.cjs +1 -1
- package/constants/tasks.constants.mjs +4 -5
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +13 -36
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +10 -10
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +86 -83
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +56 -45
- package/data-structures/Hinkal/Hinkal.mjs +348 -315
- package/data-structures/Hinkal/IHinkal.d.ts +56 -42
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +49 -48
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +7 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +42 -0
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +24 -29
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -0
- package/data-structures/Hinkal/hinkalApprove.d.ts +3 -0
- package/data-structures/Hinkal/hinkalApprove.mjs +114 -0
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +19 -20
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +84 -89
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +96 -78
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +79 -75
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +151 -140
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +5 -4
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalInsideTransact.d.ts +4 -0
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +120 -0
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +118 -115
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +29 -30
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +36 -40
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +32 -37
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +15 -17
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +3 -4
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +95 -84
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +180 -154
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +3 -2
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +40 -43
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +67 -71
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +59 -63
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +46 -50
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +50 -52
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +65 -69
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +77 -71
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +70 -72
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +78 -81
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +103 -106
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +54 -108
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.d.ts +0 -1
- package/data-structures/IndexedDB/activity-db.mjs +79 -97
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +39 -43
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +31 -36
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +40 -26
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +82 -82
- package/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
- package/data-structures/TokenDBs/token-visibility-db.mjs +36 -22
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +10 -0
- package/data-structures/crypto-keys/keys.mjs +106 -47
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +6 -6
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +2 -4
- package/data-structures/event-service/evm/AbstractEventService.mjs +13 -13
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +3 -3
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +2 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +6 -2
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +5 -10
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +40 -40
- package/data-structures/event-service/index.d.ts +0 -4
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +2 -3
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +3 -4
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +8 -8
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +10 -4
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +7 -10
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +2 -2
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +2 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +2 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +16 -11
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +66 -64
- package/data-structures/index.d.ts +0 -3
- package/data-structures/presale/PresaleContractWrapper.cjs +1 -1
- package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
- package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +16 -11
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +18 -18
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +9 -9
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +4 -6
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +4 -6
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +4 -6
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +4 -5
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +4 -6
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +0 -1
- package/error-handling/error-codes.constants.mjs +3 -4
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +27 -22
- package/error-handling/handleErrorRestore.cjs +1 -0
- package/error-handling/handleErrorRestore.d.ts +2 -0
- package/error-handling/handleErrorRestore.mjs +11 -0
- package/error-handling/index.d.ts +1 -0
- package/functions/kyc/authentoHelper.cjs +1 -0
- package/functions/kyc/authentoHelper.d.ts +12 -0
- package/functions/kyc/authentoHelper.mjs +30 -0
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +16 -17
- package/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/functions/pre-transaction/constructAdminData.d.ts +2 -2
- package/functions/pre-transaction/constructAdminData.mjs +18 -12
- package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/functions/pre-transaction/getExternalSwapAddress.d.ts +2 -1
- package/functions/pre-transaction/getExternalSwapAddress.mjs +8 -8
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +2 -3
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +36 -22
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +2 -3
- package/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.d.ts +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +17 -17
- package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +9 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.mjs +34 -19
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.mjs +50 -53
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +4 -4
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +12 -10
- package/functions/private-wallet/emporium.helpers.mjs +139 -102
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.d.ts +4 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +106 -103
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +21 -18
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.mjs +49 -49
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +11 -10
- package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
- package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +10 -11
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.d.ts +0 -1
- package/functions/utils/addresses.mjs +11 -12
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +1 -1
- package/functions/utils/cacheFunctions.mjs +55 -54
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +2 -2
- package/functions/utils/create-provider.mjs +7 -11
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +9 -9
- package/functions/utils/ethers-formatter.utils.d.ts +1 -1
- package/functions/utils/external-action.utils.cjs +1 -1
- package/functions/utils/external-action.utils.mjs +2 -2
- package/functions/utils/get-hinkal-approvals.cjs +1 -0
- package/functions/utils/get-hinkal-approvals.d.ts +3 -0
- package/functions/utils/get-hinkal-approvals.mjs +38 -0
- package/functions/utils/getContractAddress.cjs +1 -0
- package/functions/utils/getContractAddress.d.ts +2 -0
- package/functions/utils/getContractAddress.mjs +9 -0
- package/functions/utils/getDataFromTransaction.cjs +1 -1
- package/functions/utils/getDataFromTransaction.d.ts +0 -11
- package/functions/utils/getDataFromTransaction.mjs +26 -50
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
- package/functions/utils/getSignerFromContract.cjs +1 -0
- package/functions/utils/getSignerFromContract.d.ts +3 -0
- package/functions/utils/getSignerFromContract.mjs +16 -0
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +14 -15
- package/functions/utils/inLogicMetadata.cjs +1 -1
- package/functions/utils/inLogicMetadata.mjs +2 -2
- package/functions/utils/index.d.ts +1 -0
- package/functions/utils/involves-permit2-op.cjs +1 -1
- package/functions/utils/involves-permit2-op.d.ts +1 -0
- package/functions/utils/involves-permit2-op.mjs +6 -4
- package/functions/utils/mutexes.utils.cjs +1 -1
- package/functions/utils/mutexes.utils.d.ts +1 -1
- package/functions/utils/mutexes.utils.mjs +3 -3
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +23 -9
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +13 -6
- package/functions/utils/prepareHinkal.mjs +72 -45
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.d.ts +1 -1
- package/functions/utils/publicBalance.utils.mjs +62 -57
- package/functions/utils/replaceAddressInCalldata.cjs +1 -0
- package/functions/utils/replaceAddressInCalldata.d.ts +1 -0
- package/functions/utils/replaceAddressInCalldata.mjs +7 -0
- package/functions/utils/rpc-int-encode.cjs +1 -1
- package/functions/utils/rpc-int-encode.d.ts +1 -2
- package/functions/utils/rpc-int-encode.mjs +3 -6
- package/functions/utils/solanaMint.utils.cjs +1 -1
- package/functions/utils/solanaMint.utils.mjs +6 -6
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +0 -1
- package/functions/utils/string.utils.mjs +14 -18
- package/functions/utils/token-check.utils.cjs +1 -1
- package/functions/utils/token-check.utils.d.ts +0 -3
- package/functions/utils/token-check.utils.mjs +7 -18
- package/functions/utils/upToDateState.cjs +1 -1
- package/functions/utils/upToDateState.d.ts +1 -1
- package/functions/utils/upToDateState.mjs +4 -4
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +17 -2
- package/functions/utils/walletBalances.utils.mjs +36 -5
- package/functions/web3/EIP-712.cjs +1 -1
- package/functions/web3/EIP-712.d.ts +4 -4
- package/functions/web3/EIP-712.mjs +1 -1
- package/functions/web3/etherFunctions.cjs +1 -1
- package/functions/web3/etherFunctions.mjs +32 -29
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +2 -3
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.d.ts +4 -3
- package/functions/web3/events/getApprovedBalance.mjs +44 -39
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.d.ts +3 -3
- package/functions/web3/events/getInputUtxoAndBalance.mjs +150 -129
- package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.mjs +75 -73
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.d.ts +3 -3
- package/functions/web3/events/getTransactionLogEvents.mjs +41 -40
- package/functions/web3/events/index.d.ts +0 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +12 -16
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +6 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +20 -12
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +68 -69
- package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.mjs +6 -6
- package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
- package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
- package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.d.ts +2 -1
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +10 -10
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +5 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +29 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +47 -39
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +3 -3
- package/functions/web3/functionCalls/transactCallRelayer.mjs +54 -56
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.d.ts +1 -1
- package/functions/web3/getContractMetadata.mjs +21 -16
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.d.ts +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +7 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +32 -31
- package/functions/web3/index.d.ts +0 -1
- package/functions/web3/lifiAPI.cjs +1 -1
- package/functions/web3/lifiAPI.d.ts +1 -1
- package/functions/web3/lifiAPI.mjs +12 -12
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +15 -3
- package/functions/web3/okxAPI.cjs +1 -1
- package/functions/web3/okxAPI.mjs +13 -13
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +20 -8
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.d.ts +6 -5
- package/functions/web3/runContractFunction.mjs +60 -46
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +2 -2
- package/functions/web3/uniswapAPI.mjs +49 -38
- package/index.cjs +1 -1
- package/index.mjs +912 -914
- package/package.json +4 -6
- package/providers/CustomEthersProvider.d.ts +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +21 -14
- package/providers/EthersProviderAdapter.mjs +86 -53
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +12 -8
- package/providers/SolanaProviderAdapter.mjs +31 -16
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +20 -14
- package/providers/WagmiProviderAdapter.mjs +126 -91
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +2 -2
- package/providers/prepareEthersHinkal.mjs +9 -16
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +9 -17
- package/types/TransactionSimulator.types.d.ts +9 -2
- package/types/activities.types.d.ts +2 -5
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +6 -0
- package/types/admin.types.mjs +2 -2
- package/types/balances.types.d.ts +1 -0
- package/types/big-intable.types.d.ts +3 -2
- package/types/bridging.types.d.ts +29 -0
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +3 -6
- package/types/cache.types.mjs +1 -1
- package/types/coingecko.types.d.ts +0 -5
- package/types/duneAPI.types.d.ts +9 -0
- package/types/ethereum-network.types.d.ts +10 -11
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +1 -1
- package/types/hinkal.types.mjs +18 -18
- package/types/index.d.ts +2 -2
- package/types/proxy.types.d.ts +3 -6
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +39 -10
- package/types/sandbox.types.mjs +2 -2
- package/types/scheduled-transactions.types.cjs +1 -1
- package/types/scheduled-transactions.types.d.ts +6 -0
- package/types/scheduled-transactions.types.mjs +3 -2
- package/types/session.types.d.ts +0 -2
- package/types/solana.types.d.ts +0 -9
- package/types/token-prices.types.cjs +1 -1
- package/types/token-prices.types.d.ts +0 -7
- package/types/token-prices.types.mjs +2 -4
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -3
- package/types/transactions.types.mjs +6 -7
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +1 -1
- package/webworker/viteWorkerURL.constant.cjs +3 -3
- package/webworker/viteWorkerURL.constant.mjs +3 -3
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/API/get-token-price-chart-data.cjs +0 -1
- package/API/get-token-price-chart-data.d.ts +0 -16
- package/API/get-token-price-chart-data.mjs +0 -13
- package/API/onrampCalls.cjs +0 -1
- package/API/onrampCalls.d.ts +0 -20
- package/API/onrampCalls.mjs +0 -15
- package/API/unspent-utxos-calls.cjs +0 -1
- package/API/unspent-utxos-calls.d.ts +0 -26
- package/API/unspent-utxos-calls.mjs +0 -26
- package/data-structures/AccountActions/AccountActions.cjs +0 -1
- package/data-structures/AccountActions/AccountActions.d.ts +0 -18
- package/data-structures/AccountActions/AccountActions.mjs +0 -78
- package/data-structures/AccountActions/index.d.ts +0 -1
- package/data-structures/BlockchainEvent/BlockchainEvent.cjs +0 -1
- package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +0 -14
- package/data-structures/BlockchainEvent/BlockchainEvent.mjs +0 -41
- package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +0 -1
- package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +0 -20
- package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +0 -124
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +0 -1
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +0 -15
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +0 -64
- package/data-structures/PublicBalance/index.d.ts +0 -2
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +0 -11
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +0 -21
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +0 -6
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +0 -16
- package/data-structures/event-service/helpers/ClientEventHelper.cjs +0 -1
- package/data-structures/event-service/helpers/ClientEventHelper.d.ts +0 -11
- package/data-structures/event-service/helpers/ClientEventHelper.mjs +0 -26
- package/data-structures/event-service/helpers/PollingEventHelper.cjs +0 -1
- package/data-structures/event-service/helpers/PollingEventHelper.d.ts +0 -5
- package/data-structures/event-service/helpers/PollingEventHelper.mjs +0 -14
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +0 -11
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +0 -22
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +0 -6
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +0 -16
- package/functions/utils/enum.utils.cjs +0 -1
- package/functions/utils/enum.utils.mjs +0 -14
- package/functions/utils/socket.utils.cjs +0 -1
- package/functions/utils/socket.utils.d.ts +0 -1
- package/functions/utils/socket.utils.mjs +0 -12
- package/functions/web3/crypto.cjs +0 -1
- package/functions/web3/crypto.d.ts +0 -1
- package/functions/web3/crypto.mjs +0 -7
- package/functions/web3/events/web3RetrieveEvents.cjs +0 -1
- package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
- package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
- package/types/events.types.cjs +0 -1
- package/types/events.types.d.ts +0 -9
- package/types/events.types.mjs +0 -5
- package/types/onramp.types.cjs +0 -1
- package/types/onramp.types.d.ts +0 -58
- package/types/onramp.types.mjs +0 -4
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { ethers as
|
|
1
|
+
import { ethers as E } from "ethers";
|
|
2
2
|
import { get as P, update as I } from "idb-keyval";
|
|
3
|
-
import { Mutex as
|
|
4
|
-
import { chainIds as f, ALCHEMY_API_KEY as T } from "../../constants/chains.constants.mjs";
|
|
3
|
+
import { Mutex as x } from "async-mutex";
|
|
4
|
+
import { chainIds as f, ALCHEMY_API_KEY as T, networkRegistry as M } 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 L } from "../../functions/utils/string.utils.mjs";
|
|
7
|
+
import { StorageKeys as S } from "../../types/cache.types.mjs";
|
|
8
|
+
import { httpClient as R } from "../http/HttpClient.mjs";
|
|
9
9
|
import { API as $ } from "../../API/API.mjs";
|
|
10
|
-
import { RevokeType as
|
|
11
|
-
import { isNFTToken as
|
|
10
|
+
import { RevokeType as k } from "../../types/approvals.types.mjs";
|
|
11
|
+
import { isNFTToken as U } 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 O } from "../../constants/events.constants.mjs";
|
|
14
|
+
import { caseInsensitiveEqual as y } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
15
15
|
import { zeroAddress as B } from "../../constants/protocol.constants.mjs";
|
|
16
|
-
class
|
|
16
|
+
class V {
|
|
17
17
|
updateMutexes = {};
|
|
18
|
-
approvalTopic =
|
|
19
|
-
approvalForAllTopic =
|
|
20
|
-
getApprovedSelector =
|
|
21
|
-
isApprovedForAllSelector =
|
|
18
|
+
approvalTopic = E.id("Approval(address,address,uint256)");
|
|
19
|
+
approvalForAllTopic = E.id("ApprovalForAll(address,address,bool)");
|
|
20
|
+
getApprovedSelector = E.id("getApproved(uint256)").substring(0, 10);
|
|
21
|
+
isApprovedForAllSelector = E.id("isApprovedForAll(address,address)").substring(0, 10);
|
|
22
22
|
ALCHEMY_URLS = {
|
|
23
23
|
[f.ethMainnet]: "eth-mainnet",
|
|
24
24
|
[f.polygon]: "polygon-mainnet",
|
|
@@ -29,7 +29,7 @@ class O {
|
|
|
29
29
|
[f.avalanche]: "avax-mainnet"
|
|
30
30
|
};
|
|
31
31
|
getMutex(e) {
|
|
32
|
-
return this.updateMutexes[e] || (this.updateMutexes[e] = new
|
|
32
|
+
return this.updateMutexes[e] || (this.updateMutexes[e] = new x()), this.updateMutexes[e];
|
|
33
33
|
}
|
|
34
34
|
getAlchemyUrl(e) {
|
|
35
35
|
const s = this.ALCHEMY_URLS[e];
|
|
@@ -38,85 +38,88 @@ class O {
|
|
|
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 = L(s, e);
|
|
42
|
+
return (await P(S.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(S.PUBLIC_APPROVALS_LAST_PROCESSED_BLOCKS) || {}, d = L(s, e);
|
|
46
|
+
return r[d] || O[e];
|
|
47
47
|
}
|
|
48
48
|
async updateLastProcessedBlock(e, s, r) {
|
|
49
|
-
await I(
|
|
50
|
-
const
|
|
49
|
+
await I(S.PUBLIC_APPROVALS_LAST_PROCESSED_BLOCKS, (d = {}) => {
|
|
50
|
+
const i = L(s, e);
|
|
51
51
|
return {
|
|
52
|
-
...
|
|
53
|
-
[
|
|
52
|
+
...d,
|
|
53
|
+
[i]: 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
|
-
|
|
59
|
+
const { fetchRpcUrl: r } = M[s];
|
|
60
|
+
if (!r)
|
|
61
|
+
throw Error("No fetchRpcUrl in EventsPublicApprovalsDB");
|
|
62
|
+
const d = F(r), i = await this.getLastProcessedBlock(s, e) + 1, l = await d.getBlockNumber();
|
|
63
|
+
if (i > l)
|
|
64
|
+
return { approvalEvents: [], latestBlock: l };
|
|
65
|
+
const w = E.zeroPadValue(e.toLowerCase(), 32), p = {
|
|
66
|
+
topics: [[this.approvalTopic, this.approvalForAllTopic], w],
|
|
67
|
+
fromBlock: i,
|
|
68
|
+
toBlock: l
|
|
66
69
|
};
|
|
67
|
-
return { approvalEvents: await
|
|
70
|
+
return { approvalEvents: await d.getLogs(p), latestBlock: l };
|
|
68
71
|
} catch (r) {
|
|
69
72
|
return C.error("Failed to fetch approval events", r), { approvalEvents: [], latestBlock: void 0 };
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
async checkCurrentAllowances(e, s, r) {
|
|
73
|
-
const
|
|
76
|
+
const d = this.getAlchemyUrl(e), i = `0x${s.substring(2).padStart(64, "0")}`, l = [...new Set(r.map((t) => t.contractAddress))], w = (await $.tokensInfoCall(e, l)).filter((t) => !!t), p = new Map(w.map((t) => [t.erc20TokenAddress.toLowerCase(), t])), c = [], v = [];
|
|
74
77
|
if (r.forEach((t, o) => {
|
|
75
|
-
const a =
|
|
78
|
+
const a = p.get(t.contractAddress.toLowerCase());
|
|
76
79
|
if (a)
|
|
77
|
-
if (!
|
|
78
|
-
|
|
80
|
+
if (!U(a))
|
|
81
|
+
c.push({
|
|
79
82
|
jsonrpc: "2.0",
|
|
80
|
-
id:
|
|
83
|
+
id: c.length,
|
|
81
84
|
method: "alchemy_getTokenAllowance",
|
|
82
85
|
params: [{ contract: t.contractAddress, owner: s, spender: t.spenderAddress }]
|
|
83
|
-
}), v.push({ pairIndex: o, type:
|
|
86
|
+
}), v.push({ pairIndex: o, type: k.ERC20 });
|
|
84
87
|
else {
|
|
85
|
-
const
|
|
86
|
-
|
|
88
|
+
const m = `0x${t.spenderAddress.substring(2).padStart(64, "0")}`, g = `${this.isApprovedForAllSelector}${i.substring(2)}${m.substring(2)}`;
|
|
89
|
+
c.push({
|
|
87
90
|
jsonrpc: "2.0",
|
|
88
|
-
id:
|
|
91
|
+
id: c.length,
|
|
89
92
|
method: "eth_call",
|
|
90
93
|
params: [{ to: t.contractAddress, data: g }, "latest"]
|
|
91
|
-
}), v.push({ pairIndex: o, type:
|
|
92
|
-
const _ =
|
|
93
|
-
|
|
94
|
+
}), v.push({ pairIndex: o, type: k.approvedForAll }), t.tokenIds && t.tokenIds.size > 0 && t.tokenIds.forEach((h) => {
|
|
95
|
+
const _ = BigInt(h).toString(16).substring(2).padStart(64, "0"), b = `${this.getApprovedSelector}${_}`;
|
|
96
|
+
c.push({
|
|
94
97
|
jsonrpc: "2.0",
|
|
95
|
-
id:
|
|
98
|
+
id: c.length,
|
|
96
99
|
method: "eth_call",
|
|
97
|
-
params: [{ to: t.contractAddress, data:
|
|
98
|
-
}), v.push({ pairIndex: o, type:
|
|
100
|
+
params: [{ to: t.contractAddress, data: b }, "latest"]
|
|
101
|
+
}), v.push({ pairIndex: o, type: k.tokenId, tokenId: h });
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
|
-
}),
|
|
104
|
+
}), c.length === 0)
|
|
102
105
|
return [];
|
|
103
|
-
const n = await
|
|
106
|
+
const n = await R.post(d, c), u = [], A = /* @__PURE__ */ new Set();
|
|
104
107
|
return n.forEach((t, o) => {
|
|
105
108
|
const a = v[o];
|
|
106
109
|
if (!a)
|
|
107
110
|
return;
|
|
108
|
-
const
|
|
109
|
-
if (!(!g ||
|
|
111
|
+
const m = r[a.pairIndex], g = p.get(m.contractAddress.toLowerCase());
|
|
112
|
+
if (!(!g || y(m.spenderAddress, B)) && !t?.error && t?.result && t.result !== "0x")
|
|
110
113
|
try {
|
|
111
|
-
if (a.type ===
|
|
112
|
-
|
|
113
|
-
else if (a.type ===
|
|
114
|
-
|
|
115
|
-
else if (a.type ===
|
|
114
|
+
if (a.type === k.ERC20 && BigInt(t.result) > 0n)
|
|
115
|
+
u.push({ token: g, spenderAddress: m.spenderAddress, allowance: BigInt(t.result) });
|
|
116
|
+
else if (a.type === k.approvedForAll && BigInt(t.result) === 1n)
|
|
117
|
+
A.add(a.pairIndex), u.push({ token: g, spenderAddress: m.spenderAddress, allowance: 1n });
|
|
118
|
+
else if (a.type === k.tokenId && !A.has(a.pairIndex)) {
|
|
116
119
|
const h = `0x${t.result.substring(26)}`.toLowerCase();
|
|
117
|
-
!
|
|
120
|
+
!y(h, B) && y(h, m.spenderAddress) && u.push({
|
|
118
121
|
token: g,
|
|
119
|
-
spenderAddress:
|
|
122
|
+
spenderAddress: m.spenderAddress,
|
|
120
123
|
allowance: 1n,
|
|
121
124
|
tokenId: a.tokenId
|
|
122
125
|
});
|
|
@@ -124,49 +127,49 @@ class O {
|
|
|
124
127
|
} catch (h) {
|
|
125
128
|
C.error("Error processing approval response", h);
|
|
126
129
|
}
|
|
127
|
-
}),
|
|
130
|
+
}), u;
|
|
128
131
|
}
|
|
129
132
|
async fetchAndUpdatePublicApprovals(e, s) {
|
|
130
|
-
const r =
|
|
133
|
+
const r = L(e, s);
|
|
131
134
|
await this.getMutex(r).runExclusive(async () => {
|
|
132
135
|
try {
|
|
133
|
-
const { approvalEvents:
|
|
134
|
-
if (!
|
|
136
|
+
const { approvalEvents: i, latestBlock: l } = await this.getApprovalEvents(e, s);
|
|
137
|
+
if (!l)
|
|
135
138
|
return;
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
const
|
|
139
|
-
let o =
|
|
140
|
-
o || (o = { contractAddress:
|
|
141
|
-
}),
|
|
139
|
+
const w = await this.getApprovals(s, e), p = /* @__PURE__ */ new Map();
|
|
140
|
+
if (w.forEach((n) => {
|
|
141
|
+
const u = n.token.erc20TokenAddress.toLowerCase(), A = n.spenderAddress.toLowerCase(), t = `${u}_${A}`;
|
|
142
|
+
let o = p.get(t);
|
|
143
|
+
o || (o = { contractAddress: u, spenderAddress: A, tokenIds: /* @__PURE__ */ new Set() }, p.set(t, o)), n.tokenId && o.tokenIds && o.tokenIds.add(n.tokenId);
|
|
144
|
+
}), i.forEach((n) => {
|
|
142
145
|
if (!n.topics[2])
|
|
143
146
|
return;
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
147
|
+
const u = n.address.toLowerCase(), A = `0x${n.topics[2].substring(26)}`.toLowerCase();
|
|
148
|
+
if (y(A, B))
|
|
146
149
|
return;
|
|
147
|
-
const t = `${
|
|
148
|
-
let o =
|
|
149
|
-
if (o || (o = { contractAddress:
|
|
150
|
+
const t = `${u}_${A}`;
|
|
151
|
+
let o = p.get(t);
|
|
152
|
+
if (o || (o = { contractAddress: u, spenderAddress: A, tokenIds: /* @__PURE__ */ new Set() }, p.set(t, o)), n.topics.length === 4 && o.tokenIds) {
|
|
150
153
|
const a = BigInt(n.topics[3]).toString();
|
|
151
154
|
o.tokenIds.add(a);
|
|
152
155
|
}
|
|
153
|
-
}),
|
|
154
|
-
await this.updateLastProcessedBlock(s, e,
|
|
156
|
+
}), p.size === 0) {
|
|
157
|
+
await this.updateLastProcessedBlock(s, e, l);
|
|
155
158
|
return;
|
|
156
159
|
}
|
|
157
|
-
const
|
|
158
|
-
await I(
|
|
160
|
+
const c = Array.from(p.values()), v = await this.checkCurrentAllowances(s, e, c);
|
|
161
|
+
await I(S.EVENTS_PUBLIC_APPROVALS, (n = {}) => ({
|
|
159
162
|
...n,
|
|
160
163
|
[r]: v
|
|
161
|
-
})), await this.updateLastProcessedBlock(s, e,
|
|
162
|
-
} catch (
|
|
163
|
-
C.error("Failed to sync approvals",
|
|
164
|
+
})), await this.updateLastProcessedBlock(s, e, l);
|
|
165
|
+
} catch (i) {
|
|
166
|
+
C.error("Failed to sync approvals", i);
|
|
164
167
|
}
|
|
165
168
|
});
|
|
166
169
|
}
|
|
167
170
|
}
|
|
168
|
-
const
|
|
171
|
+
const st = new V();
|
|
169
172
|
export {
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
V as EventsPublicApprovalsDB,
|
|
174
|
+
st as eventsPublicApprovalsDB
|
|
172
175
|
};
|
|
@@ -1 +1 @@
|
|
|
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
|
+
"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"),A=require("../crypto-keys/keys.cjs"),I=require("./hinkalDeposit.cjs"),B=require("./hinkalDepositAndWithdraw.cjs"),w=require("./hinkalSolanaDeposit.cjs"),K=require("./hinkalSwap.cjs"),U=require("./hinkalWithdraw.cjs"),L=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 ne=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/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 ae=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"),ye=require("./hinkalDepostAndBridge.cjs");class Se{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 A.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??!0,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 A.UserKeys(await this.getProviderAdapter().signMessage(t))}async initUserKeysWithPassword(e){this.userKeys=new A.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,n=!1,a,s=!1){return W.getShieldedBalance(this,e,t,r,i,n,this.generateProofRemotely,a,s)}async getApprovedBalances(e=!1,t=!1){return v.getApprovedBalance(this,e,t)}async getTotalBalance(e,t,r,i=!1,n,a=!1){const s=e??this.getCurrentChainId(),o=r??await this.getEthereumAddress(),c=t??this.userKeys,l=await this.getBalances(s,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),o,i,n,a),p=!h.isSolanaLike(s)&&!a?await this.getApprovedBalances(i,n):new Map,d=_.isExtension?await ie.privateTokensDB.getPrivateTokens(s,o):ne.getErc20TokensForChain(s),u=[];return d.forEach(k=>{const f=k.erc20TokenAddress.toLowerCase(),y=l.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,r){return(await this.getTotalBalance(e,t,r,!1,!1,!0)).filter(n=>n.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:n}=h.networkRegistry[e].contractData;if(!r||!i||!n)throw new Error(`Missing Solana configuration for chain ${e}`);const a=new g.PublicKey(n),s=new g.PublicKey(i),o=E.getMerkleAccountPublicKey(s,a),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:n}=h.networkRegistry[e].contractData;if(!r||!i||!n)throw new Error(`Missing Solana configuration for chain ${e}`);const a=new g.PublicKey(n),s=new g.PublicKey(i),o=E.getAccessTokenMerkleAccountPublicKey(s,a),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()]);(BigInt(e)!==this.merkleTreeHinkal.getRootHash()||BigInt(t)!==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:n,hinkalAddress:a,originalDeployer:s}=h.networkRegistry[r].contractData;if(!n||!a||!s)throw new Error("missing solana data");const o=this.getSolanaProgram(n),c=new g.PublicKey(s);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,n,a){return h.isSolanaLike(this.getCurrentChainId())?de.hinkalSolanaDepositAndWithdraw(this,e.erc20TokenAddress,t,r,i,n,a):B.hinkalDepositAndWithdraw(this,e,t,r,i,n,a)}async depositAndBridge(e,t,r,i,n){return ye.hinkalDepositAndBridge(this,e,t,r,i,n)}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 w.hinkalSolanaDeposit(this,e,t)}async depositSolanaForOther(e,t,r){return w.hinkalSolanaDepositForOther(this,e,t,r)}async solanaMultiPaymentDeposit(e,t){return w.hinkalSolanaMultiPaymentDeposit(this,e,t)}async transfer(e,t,r,i,n,a,s=!1){return h.isSolanaLike(this.getCurrentChainId())?ue.hinkalSolanaTransfer(this,e,t,r,i,n,s):he.hinkalTransfer(this,e,t,r,i,n,a,s)}async withdraw(e,t,r,i,n,a,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?pe.hinkalSolanaWithdraw(this,e.map(c=>c.erc20TokenAddress),t,r,n,a,o):U.hinkalWithdraw(this,e,t,r,i,n,a,s,o)}async withdrawStuckUtxos(e,t){return L.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,r,i,n,a,s,o=!1,c=!1){return h.isSolanaLike(this.getCurrentChainId())?this.swapSolana(e,t,i,n,a,o):K.hinkalSwap(this,e,t,r,i,n,a,s,o,c)}async swapSolana(e,t,r,i,n,a=!1){const s=JSON.parse(r),o=BigInt(s.swapperAccountSalt),{instructionLists:c,addressLookupTableAccount:l}=s.data;return ge.hinkalSolanaSwap(this,e,t,o,c,l,i,n,a)}async actionReceive(e,t,r,i,n,a,s=!1){if(!n)throw new Error("subAccount is required");return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],n,void 0,s):te.hinkalActionReceive(this,e,t,r,i,n,a,s)}async actionFundApproveAndTransact(e,t,r,i,n,a,s,o,c=!1,l,p,d){return re.hinkalActionFundApproveAndTransact(this,e,t,r,i,n,a,s,o,c,l,p,d)}async actionPrivateWallet(e,t,r,i,n,a,s,o,c,l=!1,p,d,u,k=!1){return $.hinkalPrivateWallet(this,e,t,r,i,n,a,s,o,c,l,p,d,u,k)}async approve(e,t,r,i,n,a=!1){return Y.hinkalApprove(this,e,t,r,i,n,a)}async hinkalInsideTransact(e,t,r,i,n,a,s,o,c,l=!1){return Z.hinkalInsideTransact(this,e,t,r,i,n,a,s,o,c,l)}async proxySwap(e,t,r,i,n,a,s,o,c=!1,l,p,d=!1){return h.isSolanaLike(this.getCurrentChainId())?ve.hinkalSolanaProxySwap(this,e,t,i,a,s,o,d):oe.hinkalProxySwap(this,e,t,r,i,n,a,s,o,c,l,p,d)}async proxyToPrivate(e,t,r,i,n,a,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],r,i,o):le.hinkalProxyToPrivate(this,e,t,i,n,a,r,s,o)}async proxySend(e,t,r,i,n,a,s,o=!1){if(h.isSolanaLike(this.getCurrentChainId()))return ke.hinkalSolanaProxySend(this,e[0],t[0],r,i,o);const c=ae.createTransaferEmporiumOpsBatch(this,e.map(d=>d.erc20TokenAddress),t,i),l=e.map((d,u)=>({token:d,amount:-1n*t[u]}));return await this.actionPrivateWallet([],[],[],c,l,r,n,a,void 0,void 0,void 0,s,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=Se;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
import { type ApprovedUtxo, ApprovedUtxoWithInteractionAddress, FeeStructure, HinkalConfig } from '../../types/hinkal.types';
|
|
3
|
-
import { ContractType, EthereumNetwork } from '../../types/ethereum-network.types';
|
|
2
|
+
import { type ApprovedUtxo, ApprovedUtxoWithInteractionAddress, FeeStructure, HinkalConfig, type ParsedInLogicMetadata } from '../../types/hinkal.types';
|
|
3
|
+
import { type ContractMetadata, 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';
|
|
8
9
|
import type { ERC20Token, PrivateRecipientInfo, TokenBalance, TokenChanges } from '../../types/token.types';
|
|
9
10
|
import { UserKeys } from '../crypto-keys/keys';
|
|
10
11
|
import { type IProviderAdapter } from '../provider-adapter/IProviderAdapter';
|
|
@@ -20,20 +21,19 @@ import { Idl, Program } from '@coral-xyz/anchor';
|
|
|
20
21
|
import { PublicKey } from '@solana/web3.js';
|
|
21
22
|
import { BridgeRecipient } from '../../types/bridging-tx.types';
|
|
22
23
|
export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
23
|
-
private
|
|
24
|
-
private solanaProviderAdapter?;
|
|
24
|
+
private providerAdapter?;
|
|
25
25
|
userKeys: UserKeys;
|
|
26
26
|
readonly signingMessage: string;
|
|
27
27
|
readonly privateTransferSigningMessage: string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
merkleTreeHinkal: MerkleTree<bigint>;
|
|
29
|
+
merkleTreeAccessToken: MerkleTree<bigint>;
|
|
30
|
+
nullifiers: Set<string>;
|
|
31
|
+
encryptedOutputs: EncryptedOutputWithSign[];
|
|
32
|
+
approvals: Map<string, ApprovedUtxo[]>;
|
|
33
|
+
commitmentsSnapshotService?: ClientCommitmentsSnapshotService | ClientSolanaCommitmentsSnapshotService;
|
|
34
|
+
nullifierSnapshotService?: ClientNullifierSnapshotService | ClientSolanaNullifierSnapshotService;
|
|
35
|
+
accessTokenSnapshotService?: ClientAccessTokenSnapshotService | ClientSolanaAccessTokenSnapshotService;
|
|
36
|
+
approvalsSnapshotService?: ClientApprovalsSnapshotService;
|
|
37
37
|
utxoUtils: IMultiThreadedUtxoUtils;
|
|
38
38
|
cacheDevice: ICacheDevice;
|
|
39
39
|
generateProofRemotely: boolean;
|
|
@@ -42,65 +42,76 @@ export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
|
42
42
|
initProviderAdapter(connector: ConnectorType, providerAdapter: IProviderAdapter<ConnectorType>): Promise<void>;
|
|
43
43
|
initUserKeys(isPrivateTransfer?: boolean): Promise<void>;
|
|
44
44
|
initUserKeysWithPassword(password: string): Promise<void>;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
getContract(chainId: number, contractType: ContractType, contractAddress?: undefined): ethers.Contract;
|
|
45
|
+
resetMerkle(): Promise<void>;
|
|
46
|
+
getProviderAdapter(): IProviderAdapter<ConnectorType>;
|
|
47
|
+
waitForTransaction(transactionHash: string, confirmations?: number): Promise<boolean>;
|
|
48
|
+
getContractMetadata(contractType: ContractType, chainId?: number): ContractMetadata;
|
|
49
|
+
getContract(contractType: ContractType, contractAddress?: undefined, chainId?: number): ethers.Contract;
|
|
51
50
|
getContractWithFetcherByChainId(chainId: number, contractType: ContractType, contractAddress?: undefined): ethers.Contract;
|
|
52
51
|
signMessage(message: string): Promise<string>;
|
|
53
52
|
signTypedData(domain: ethers.TypedDataDomain, types: Record<string, ethers.TypedDataField[]>, value: Record<string, unknown>): Promise<string>;
|
|
54
|
-
signWithSubAccount(
|
|
55
|
-
getContractWithSigner(
|
|
56
|
-
getContractWithFetcher(
|
|
57
|
-
|
|
53
|
+
signWithSubAccount(messageToSign: string | undefined, typedData: TypedData | undefined, subAccount: SubAccount): Promise<string>;
|
|
54
|
+
getContractWithSigner(contract: ContractType, contractAddress?: string): ethers.Contract;
|
|
55
|
+
getContractWithFetcher(contract: ContractType, contractAddress?: string): ethers.Contract;
|
|
56
|
+
getContractWithFetcherForEthereum(contract: ContractType, address: string): ethers.Contract;
|
|
57
|
+
isSelectedNetworkSupported(): boolean;
|
|
58
58
|
switchNetwork(network: EthereumNetwork): Promise<void>;
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
switchAccount(signer: ethers.Signer): Promise<void>;
|
|
60
|
+
getCurrentChainId(): number;
|
|
61
|
+
getSelectedNetwork(): EthereumNetwork | undefined;
|
|
62
|
+
isPermitterAvailable(): boolean;
|
|
63
|
+
connectAndPatchProvider(connector: ConnectorType): Promise<number>;
|
|
61
64
|
disconnectFromConnector(): Promise<void>;
|
|
62
|
-
|
|
65
|
+
updateProviderAdapter(providerAdapter: IProviderAdapter): Promise<void>;
|
|
63
66
|
setListeners(): Promise<void>;
|
|
64
67
|
private onAccountChanged;
|
|
65
68
|
private onChainChanged;
|
|
66
|
-
monitorConnectedAddress(
|
|
69
|
+
monitorConnectedAddress(): Promise<void>;
|
|
67
70
|
getBalances(chainId: number, passedShieldedPrivateKey: string, passedShieldedPublicKey: string, ethAddress: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean, useBlockedUtxos?: boolean): Promise<Map<string, TokenBalance>>;
|
|
68
|
-
getApprovedBalances(
|
|
69
|
-
getTotalBalance(
|
|
70
|
-
getStuckShieldedBalances(
|
|
71
|
+
getApprovedBalances(resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<Map<string, TokenBalance>>;
|
|
72
|
+
getTotalBalance(_chainId?: number, _userKeys?: UserKeys, _ethAddress?: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean, useBlockedUtxos?: boolean): Promise<TokenBalance[]>;
|
|
73
|
+
getStuckShieldedBalances(_chainId?: number, _userKeys?: UserKeys, _ethAddress?: string): Promise<TokenBalance[]>;
|
|
71
74
|
getSupportedPassportLinks(): string[];
|
|
72
|
-
checkAccessToken(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
checkAccessToken(): Promise<boolean>;
|
|
76
|
+
mintHinkalAccessToken(signatureData: SignatureData, fromWallet?: boolean): Promise<ethers.ContractTransaction>;
|
|
77
|
+
getHinkalTreeRootHash(): Promise<any>;
|
|
78
|
+
getAccessTokenTreeRootHash(): Promise<any>;
|
|
75
79
|
resetMerkleTreesIfNecessary(): Promise<void>;
|
|
76
80
|
getEventsFromHinkal(): Promise<void>;
|
|
77
81
|
getEthereumAddress(): Promise<string>;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
getGasPrice(chainId: number): Promise<bigint>;
|
|
82
|
+
getRandomRelay(markAsPending?: boolean): Promise<string | undefined>;
|
|
83
|
+
getGasPrice(): Promise<bigint>;
|
|
81
84
|
getAPI(): IAPI;
|
|
85
|
+
resetCache(): void;
|
|
82
86
|
snapshotsClearInterval(): void;
|
|
83
|
-
checkTokenRegistry(
|
|
87
|
+
checkTokenRegistry(erc20Addresses: string[], amountChanges: bigint[]): Promise<boolean>;
|
|
84
88
|
getRecipientInfo(): string;
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
getInteractionApprovals(interactionAddress: string): Promise<ApprovedUtxo[]>;
|
|
90
|
+
getApprovedUtxos(resetCacheBefore?: boolean): ApprovedUtxoWithInteractionAddress[];
|
|
91
|
+
getApprovedUtxosForToken(erc20Address: string, resetCacheBefore?: boolean): ApprovedUtxoWithInteractionAddress[];
|
|
92
|
+
getMyApprovalAmountForInteraction(interactionAddress: string, tokenAddress: string): bigint;
|
|
93
|
+
checkExistingApprovalFromHinkal(erc20Address: string, interactionAddress: string): Promise<bigint>;
|
|
94
|
+
getBufferEntry(approveTo: string, tokenAddress: string, inHinkalAddress: bigint): Promise<bigint>;
|
|
87
95
|
deposit(erc20Tokens: ERC20Token[], amountChanges: bigint[]): Promise<ethers.ContractTransaction>;
|
|
88
96
|
depositForOther(erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientInfo: string): Promise<ethers.ContractTransaction>;
|
|
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
|
+
depositAndWithdraw(erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string): Promise<string>;
|
|
98
|
+
depositAndBridge(erc20Token: ERC20Token, recipientBridges: BridgeRecipient[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string): Promise<string>;
|
|
91
99
|
prooflessDeposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructures?: StealthAddressStructure[]): Promise<ethers.ContractTransaction>;
|
|
92
100
|
getSolanaProgram(idl: Idl): Program;
|
|
93
101
|
getSolanaPublicKey(): PublicKey;
|
|
94
|
-
depositSolana(amount: bigint,
|
|
95
|
-
depositSolanaForOther(amount: bigint,
|
|
96
|
-
solanaMultiPaymentDeposit(amounts: bigint[],
|
|
102
|
+
depositSolana(amount: bigint, mintAddress: string): Promise<string>;
|
|
103
|
+
depositSolanaForOther(amount: bigint, mintAddress: string, recipientInfo: string): Promise<string>;
|
|
104
|
+
solanaMultiPaymentDeposit(amounts: bigint[], mintAddress: string): Promise<string>;
|
|
97
105
|
transfer(erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
98
106
|
withdraw(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], recipientAddress: string, isRelayerOff: boolean, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<ethers.ContractTransaction | RelayerTransaction | bigint>;
|
|
99
107
|
withdrawStuckUtxos(erc20Token: ERC20Token, recipientAddress: string): Promise<RelayerTransaction[]>;
|
|
100
108
|
swap(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, swapData: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean, withPrivateMempool?: boolean): Promise<RelayerTransaction | bigint>;
|
|
101
109
|
swapSolana(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], swapData: string, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean): Promise<RelayerTransaction>;
|
|
102
110
|
actionReceive(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], feeToken?: string, feeStructureOverride?: FeeStructure, subAccount?: SubAccount, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
103
|
-
|
|
111
|
+
actionFundApproveAndTransact(tokenChanges: TokenChanges<bigint>[], subAccount: SubAccount, spenderAddress?: string, to?: string, callDataString?: string, value?: bigint, feeToken?: string, feeStructureOverride?: FeeStructure, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
112
|
+
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>;
|
|
113
|
+
approve(erc20Addresses: string[], amount: bigint, approveTo: string, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
114
|
+
hinkalInsideTransact(erc20Addresses: string[], deltaChanges: bigint[], approvalChanges: bigint[], externalAddress: string, externalActionMetadata: string, parsedInLogicMetadata: ParsedInLogicMetadata, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
104
115
|
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>;
|
|
105
116
|
proxyToPrivate(erc20Tokens: ERC20Token[], deltaAmountsBase: bigint[], subAccount: SubAccount, recipientInfo: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
106
117
|
proxySend(erc20Tokens: ERC20Token[], amounts: bigint[], subAccount: SubAccount, recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|