@hinkal/common 0.2.18 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/API.cjs +1 -1
- package/API/API.d.ts +8 -13
- package/API/API.mjs +86 -94
- package/API/admin-calls.cjs +1 -1
- package/API/admin-calls.d.ts +1 -1
- package/API/admin-calls.mjs +4 -4
- package/API/callLifiAPI.cjs +1 -1
- package/API/callLifiAPI.d.ts +1 -1
- package/API/callLifiAPI.mjs +5 -5
- package/API/callMonitor.cjs +1 -1
- package/API/callMonitor.d.ts +1 -1
- package/API/callMonitor.mjs +7 -7
- package/API/callOdosAPI.cjs +1 -1
- package/API/callOdosAPI.mjs +11 -11
- package/API/callOkxAPI.cjs +1 -1
- package/API/callOkxAPI.d.ts +1 -1
- package/API/callOkxAPI.mjs +5 -5
- package/API/callOneInchAPI.cjs +1 -1
- package/API/callOneInchAPI.mjs +10 -11
- package/API/callRelayer.cjs +1 -1
- package/API/callRelayer.d.ts +6 -3
- package/API/callRelayer.mjs +11 -11
- package/API/checkRisk.cjs +1 -1
- package/API/checkRisk.d.ts +1 -1
- package/API/checkRisk.mjs +4 -4
- package/API/fetchCommitmentsCache.cjs +1 -1
- package/API/fetchCommitmentsCache.mjs +9 -9
- package/API/get-token-data.cjs +1 -1
- package/API/get-token-data.d.ts +1 -1
- package/API/get-token-data.mjs +5 -5
- package/API/get-token-price-chart-data.cjs +1 -0
- package/API/get-token-price-chart-data.d.ts +16 -0
- package/API/get-token-price-chart-data.mjs +13 -0
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.mjs +9 -9
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.d.ts +3 -3
- package/API/getServerURL.mjs +51 -67
- package/API/getTokenPrice.cjs +1 -1
- package/API/getTokenPrice.d.ts +5 -0
- package/API/getTokenPrice.mjs +14 -7
- package/API/index.d.ts +0 -3
- package/API/is-tx-stateless.cjs +1 -1
- package/API/is-tx-stateless.d.ts +1 -1
- package/API/is-tx-stateless.mjs +10 -12
- package/API/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +4 -8
- package/API/kycCalls.mjs +23 -26
- package/API/onrampCalls.cjs +1 -0
- package/API/onrampCalls.d.ts +20 -0
- package/API/onrampCalls.mjs +15 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +2 -2
- package/API/proxyAccountsCalls.mjs +19 -19
- package/API/relayCalls.cjs +1 -1
- package/API/relayCalls.mjs +4 -4
- package/API/scheduled-transactions-calls.cjs +1 -1
- package/API/scheduled-transactions-calls.d.ts +1 -1
- package/API/scheduled-transactions-calls.mjs +4 -4
- package/API/simulate-batch-tx.cjs +1 -1
- package/API/simulate-batch-tx.d.ts +2 -2
- package/API/simulate-batch-tx.mjs +7 -6
- package/API/solana-calls.cjs +1 -1
- package/API/solana-calls.d.ts +6 -3
- package/API/solana-calls.mjs +15 -15
- package/API/token-calls.cjs +1 -1
- package/API/token-calls.mjs +6 -5
- package/API/unspent-utxos-calls.cjs +1 -1
- package/API/unspent-utxos-calls.d.ts +1 -1
- package/API/unspent-utxos-calls.mjs +15 -18
- package/README.md +233 -64
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.d.ts +0 -1
- package/constants/addresses.constants.mjs +7 -8
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +0 -5
- package/constants/chains.constants.mjs +19 -24
- package/constants/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.d.ts +1 -0
- package/constants/coingecko.constants.mjs +11 -10
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +34 -41
- package/constants/function-signatures.constants.cjs +1 -1
- package/constants/function-signatures.constants.d.ts +0 -1
- package/constants/function-signatures.constants.mjs +3 -4
- package/constants/mystery-boxes.constants.d.ts +0 -0
- package/constants/permit2.constants.cjs +1 -1
- package/constants/permit2.constants.d.ts +0 -1
- package/constants/permit2.constants.mjs +10 -11
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +14 -122
- package/constants/server.constants.mjs +44 -152
- package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistry.json.mjs +0 -24
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +0 -24
- package/constants/token-data/index.d.ts +32 -88
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +0 -26
- package/constants/token-data/popularTokens.constants.cjs +1 -1
- package/constants/token-data/popularTokens.constants.mjs +0 -1
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +33 -48
- package/data-structures/Hinkal/Hinkal.mjs +237 -300
- package/data-structures/Hinkal/IHinkal.d.ts +32 -47
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +42 -42
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -23
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +9 -9
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +95 -93
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +111 -115
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +1 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +107 -115
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +36 -34
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +34 -33
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +26 -24
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +8 -9
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +4 -3
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +86 -97
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +146 -146
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +2 -3
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +38 -38
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +57 -56
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +59 -58
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +83 -79
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +49 -48
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +67 -64
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +75 -87
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +55 -58
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +80 -82
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +98 -102
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +105 -53
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.mjs +7 -7
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +8 -8
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +10 -10
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +25 -40
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +10 -11
- package/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
- package/data-structures/TokenDBs/token-visibility-db.mjs +22 -36
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.d.ts +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +14 -14
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +1 -0
- package/data-structures/event-service/evm/AbstractEventService.mjs +7 -4
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +0 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +3 -4
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +3 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +17 -14
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +1 -0
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +9 -6
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +0 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +1 -2
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +3 -2
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +42 -45
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +8 -13
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +3 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +3 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +2 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +3 -4
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +1 -7
- package/data-structures/utxo/Utxo.mjs +26 -36
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +1 -0
- package/error-handling/error-codes.constants.mjs +2 -1
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +21 -27
- package/error-handling/index.d.ts +0 -1
- package/functions/index.d.ts +0 -1
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +18 -17
- package/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/functions/pre-transaction/constructAdminData.d.ts +2 -2
- package/functions/pre-transaction/constructAdminData.mjs +12 -18
- package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/functions/pre-transaction/getExternalSwapAddress.d.ts +1 -2
- package/functions/pre-transaction/getExternalSwapAddress.mjs +8 -8
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +22 -30
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +21 -36
- package/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.d.ts +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +17 -17
- package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +1 -9
- package/functions/pre-transaction/outputApprovalDataProcessing.mjs +19 -34
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +4 -4
- package/functions/pre-transaction/solana-public-signals.cjs +1 -1
- package/functions/pre-transaction/solana-public-signals.d.ts +1 -0
- package/functions/pre-transaction/solana-public-signals.mjs +29 -26
- package/functions/pre-transaction/solana.cjs +1 -1
- package/functions/pre-transaction/solana.d.ts +2 -1
- package/functions/pre-transaction/solana.mjs +60 -51
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +3 -5
- package/functions/private-wallet/emporium.helpers.mjs +95 -135
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.d.ts +1 -4
- package/functions/private-wallet/emporium.swap.helpers.mjs +100 -102
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.d.ts +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +64 -64
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.mjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +1 -2
- package/functions/snarkjs/constructGeneralZkProof.mjs +117 -121
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.d.ts +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +54 -59
- package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
- package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +11 -10
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.d.ts +1 -0
- package/functions/utils/addresses.mjs +13 -12
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +2 -2
- package/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/functions/utils/erc20tokenFunctions.d.ts +0 -1
- package/functions/utils/erc20tokenFunctions.mjs +22 -29
- package/functions/utils/get-hinkal-approvals.cjs +1 -1
- package/functions/utils/get-hinkal-approvals.d.ts +1 -1
- package/functions/utils/get-hinkal-approvals.mjs +16 -16
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +11 -11
- package/functions/utils/involves-permit2-op.cjs +1 -1
- package/functions/utils/involves-permit2-op.d.ts +0 -1
- package/functions/utils/involves-permit2-op.mjs +4 -6
- package/functions/utils/mutexes.utils.cjs +1 -1
- package/functions/utils/mutexes.utils.d.ts +1 -1
- package/functions/utils/mutexes.utils.mjs +3 -3
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +8 -23
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +0 -6
- package/functions/utils/prepareHinkal.mjs +41 -60
- package/functions/utils/token-check.utils.cjs +1 -1
- package/functions/utils/token-check.utils.d.ts +3 -0
- package/functions/utils/token-check.utils.mjs +18 -7
- package/functions/utils/upToDateState.cjs +1 -1
- package/functions/utils/upToDateState.d.ts +1 -1
- package/functions/utils/upToDateState.mjs +4 -4
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +1 -16
- package/functions/utils/walletBalances.utils.mjs +4 -35
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.d.ts +3 -4
- package/functions/web3/events/getApprovedBalance.mjs +39 -44
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.d.ts +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.mjs +114 -121
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.mjs +71 -70
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.mjs +7 -7
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +7 -7
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +1 -6
- package/functions/web3/functionCalls/accessTokenCalls.mjs +12 -21
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +50 -46
- package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.mjs +6 -6
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.d.ts +1 -2
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +10 -10
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +38 -42
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +34 -34
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.d.ts +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +6 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +8 -8
- package/functions/web3/lifiAPI.cjs +1 -1
- package/functions/web3/lifiAPI.d.ts +1 -1
- package/functions/web3/lifiAPI.mjs +12 -12
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -19
- package/functions/web3/okxAPI.cjs +1 -1
- package/functions/web3/okxAPI.mjs +22 -22
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +7 -20
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +38 -56
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +22 -34
- package/index.cjs +1 -1
- package/index.mjs +939 -970
- package/package.json +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +10 -17
- package/providers/EthersProviderAdapter.mjs +48 -76
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +7 -11
- package/providers/SolanaProviderAdapter.mjs +16 -31
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +11 -17
- package/providers/WagmiProviderAdapter.mjs +86 -117
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +6 -7
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +5 -5
- package/types/TransactionSimulator.types.d.ts +2 -9
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +0 -6
- package/types/admin.types.mjs +2 -2
- package/types/balances.types.d.ts +0 -1
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +2 -3
- package/types/cache.types.mjs +1 -1
- package/types/coingecko.types.d.ts +5 -0
- package/types/ethereum-network.types.cjs +1 -1
- package/types/ethereum-network.types.d.ts +1 -8
- package/types/ethereum-network.types.mjs +1 -1
- package/types/external-action.types.cjs +1 -1
- package/types/external-action.types.d.ts +0 -1
- package/types/external-action.types.mjs +1 -1
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +1 -7
- package/types/hinkal.types.mjs +22 -23
- package/types/index.d.ts +1 -3
- package/types/onramp.types.cjs +1 -0
- package/types/onramp.types.d.ts +58 -0
- package/types/onramp.types.mjs +4 -0
- package/types/proxy.types.d.ts +1 -0
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +8 -39
- package/types/sandbox.types.mjs +2 -2
- package/types/session.types.d.ts +2 -0
- package/types/solana.types.d.ts +1 -0
- package/types/token-prices.types.cjs +1 -1
- package/types/token-prices.types.d.ts +7 -0
- package/types/token-prices.types.mjs +4 -2
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -4
- package/types/transactions.types.mjs +3 -3
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +2 -2
- package/API/ai-calls.cjs +0 -1
- package/API/ai-calls.d.ts +0 -17
- package/API/ai-calls.mjs +0 -21
- package/API/duneAPI.cjs +0 -1
- package/API/duneAPI.d.ts +0 -11
- package/API/duneAPI.mjs +0 -25
- package/API/getBridgeProtocols.cjs +0 -1
- package/API/getBridgeProtocols.d.ts +0 -7
- package/API/getBridgeProtocols.mjs +0 -8
- package/API/getLifiStatus.cjs +0 -1
- package/API/getLifiStatus.d.ts +0 -24
- package/API/getLifiStatus.mjs +0 -15
- package/API/getRelayerURL.cjs +0 -1
- package/API/getRelayerURL.d.ts +0 -1
- package/API/getRelayerURL.mjs +0 -10
- package/API/passwordCalls.cjs +0 -1
- package/API/passwordCalls.d.ts +0 -9
- package/API/passwordCalls.mjs +0 -13
- package/API/restoreSnapshots.cjs +0 -1
- package/API/restoreSnapshots.d.ts +0 -1
- package/API/restoreSnapshots.mjs +0 -10
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +0 -1
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +0 -7
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +0 -42
- package/data-structures/Hinkal/hinkalActionStake.d.ts +0 -3
- package/data-structures/Hinkal/hinkalApprove.cjs +0 -1
- package/data-structures/Hinkal/hinkalApprove.d.ts +0 -3
- package/data-structures/Hinkal/hinkalApprove.mjs +0 -115
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +0 -1
- package/data-structures/Hinkal/hinkalInsideTransact.d.ts +0 -4
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +0 -121
- package/error-handling/handleErrorRestore.cjs +0 -1
- package/error-handling/handleErrorRestore.d.ts +0 -2
- package/error-handling/handleErrorRestore.mjs +0 -11
- package/functions/staking/index.cjs +0 -1
- package/functions/staking/index.d.ts +0 -11
- package/functions/staking/index.mjs +0 -42
- package/functions/utils/replaceAddressInCalldata.cjs +0 -1
- package/functions/utils/replaceAddressInCalldata.d.ts +0 -1
- package/functions/utils/replaceAddressInCalldata.mjs +0 -7
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +0 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +0 -5
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +0 -32
- package/types/bridging.types.d.ts +0 -29
- package/types/duneAPI.types.d.ts +0 -9
- package/types/hinkal.stake.types.cjs +0 -1
- package/types/hinkal.stake.types.d.ts +0 -11
- package/types/hinkal.stake.types.mjs +0 -4
|
@@ -1,42 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { caseInsensitiveEqual as l } from "./caseInsensitive.utils.mjs";
|
|
4
|
-
import { getPublicBalancesOfTokens as g } from "./publicBalance.utils.mjs";
|
|
5
|
-
import { getAmountInWei as m } from "../web3/etherFunctions.mjs";
|
|
6
|
-
import { UserKeys as v } from "../../data-structures/crypto-keys/keys.mjs";
|
|
7
|
-
const T = (t, s) => t?.length ? t.reduce(
|
|
8
|
-
(r, { amount: u, token: e }) => {
|
|
9
|
-
if (u >= 0n)
|
|
10
|
-
return r;
|
|
11
|
-
const o = -u, d = s.find(
|
|
12
|
-
(p) => l(p.token.erc20TokenAddress, e.erc20TokenAddress)
|
|
13
|
-
)?.balance ?? 0n;
|
|
14
|
-
return d < o && (r.tokensToFund.push(e), r.fundAmounts.push(o - d)), r;
|
|
15
|
-
},
|
|
16
|
-
{ fundAmounts: [], tokensToFund: [] }
|
|
17
|
-
) : { fundAmounts: [], tokensToFund: [] }, K = async (t, s, n) => {
|
|
18
|
-
if (!n?.length)
|
|
19
|
-
return { fundAmounts: [], tokensToFund: [], approveTokenAddresses: [], approvedTokenAmounts: [] };
|
|
20
|
-
const r = t.getCurrentChainId(), u = v.getSignerAddressFromPrivateKey(r, s.privateKey), e = await g(
|
|
21
|
-
r,
|
|
22
|
-
u,
|
|
23
|
-
n.map(({ token: a }) => a)
|
|
24
|
-
), { fundAmounts: o, tokensToFund: d } = T(n, e), p = n.length ? n.filter(({ amount: a, token: A }) => a < 0n && A.erc20TokenAddress !== f).map(({ token: a }) => a.erc20TokenAddress) : [], i = p.map(() => 2n ** 256n - 1n);
|
|
25
|
-
return { fundAmounts: o, tokensToFund: d, approveTokenAddresses: p, approvedTokenAmounts: i };
|
|
26
|
-
}, N = (t, s, n) => {
|
|
27
|
-
const r = s.map((e) => e.amount < 0n ? t.getMyApprovalAmountForInteraction(n, e.token.erc20TokenAddress) : 0n);
|
|
28
|
-
return { approvalChanges: s.map((e, o) => e.amount < 0n && r[o] > 0n ? c(e.amount) < c(r[o]) ? e.amount : -r[o] : 0n) };
|
|
29
|
-
};
|
|
30
|
-
function k(t, s, n, r, u) {
|
|
1
|
+
import { getAmountInWei as f } from "../web3/etherFunctions.mjs";
|
|
2
|
+
function n(r, t, u, i, e) {
|
|
31
3
|
try {
|
|
32
|
-
return !
|
|
4
|
+
return !u || !r ? !0 : i ? e ? +r * e <= +t : !0 : f(u, r) <= f(u, t);
|
|
33
5
|
} catch {
|
|
34
6
|
return !0;
|
|
35
7
|
}
|
|
36
8
|
}
|
|
37
9
|
export {
|
|
38
|
-
|
|
39
|
-
K as getNecessaryAssetsForFunding,
|
|
40
|
-
T as getNecessaryAssetsForFundingFromBalance,
|
|
41
|
-
k as hasEnoughBalance
|
|
10
|
+
n as hasEnoughBalance
|
|
42
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../utils/caseInsensitive.utils.cjs"),l=require("../../utils/cacheFunctions.cjs"),f=require("async-mutex"),m=require("../../utils/erc20tokenFunctions.cjs"),A=require("../../../data-structures/TokenDBs/PrivateTokensDB.cjs"),g=require("../../../constants/vite.constants.cjs"),y=new f.Mutex,x=(t,e,a)=>(t.forEach(s=>{s.inHinkalAddress===a&&e.push(s)}),e),v=(t,e,a=!1)=>{const{userKeys:s}=t;a&&l.resetInHinkalAddressesCache(t,e,s.getShieldedPublicKey());const{approvalsByChain:i}=t,n=l.getInHinkalAddressesCache(t,e,s.getShieldedPublicKey());let o=[];return i[e].forEach((p,u)=>{const r=n[u];let c;r?c=BigInt(r):(c=s.getInHinkalAddress(u),n[u]=c.toString()),o=x(p.map(d=>({...d,interactionAddress:u,chainId:e})),o,c)}),l.setInHinkalAddressesCache(n,t,e,s.getShieldedPublicKey()),o},T=(t,e,a,s)=>v(t,a,s).filter(n=>k.caseInsensitiveEqual(n.tokenAddress,e)).sort((n,o)=>n.amount===o.amount?0:n.amount>o.amount?-1:1),E=async(t,e,a,s)=>{const i=await t.getEthereumAddress();let n=[];const o=new Map;return await y.runExclusive(async()=>{const p=v(t,e,a);s&&g.isExtension&&await A.privateTokensDB.fetchAndUpdatePrivateTokens(p.map(r=>r.tokenAddress),e,i),n=(g.isExtension?await A.privateTokensDB.getPrivateTokens(e,i):m.getErc20TokensForChain(e)).map(r=>({token:r,balance:p.reduce((c,d)=>k.caseInsensitiveEqual(r.erc20TokenAddress,d.tokenAddress)?c+d.amount:c,0n),timestamp:"0",nfts:[]})),n.forEach(r=>{o.set(r.token.erc20TokenAddress.toLowerCase(),r)})}),o};exports.getApprovedBalance=E;exports.getApprovedUtxos=v;exports.getApprovedUtxosForToken=T;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ApprovedUtxoWithInteractionAddress } from '../../../types/hinkal.types';
|
|
2
2
|
import { type IHinkal } from '../../../data-structures/Hinkal/IHinkal';
|
|
3
3
|
import type { TokenBalance } from '../../../types/token.types';
|
|
4
|
-
export declare const getApprovedUtxos: (hinkal: IHinkal, resetCacheBefore?: boolean) => ApprovedUtxoWithInteractionAddress[];
|
|
5
|
-
export declare const getApprovedUtxosForToken: (hinkal: IHinkal, erc20Address: string, resetCacheBefore: boolean) => ApprovedUtxoWithInteractionAddress[];
|
|
6
|
-
export declare const getApprovedBalance: (hinkal: IHinkal, resetCacheBefore: boolean, updateTokensListBefore: boolean) => Promise<Map<string, TokenBalance>>;
|
|
7
|
-
export declare const getMyApprovalAmountForInteraction: (hinkal: IHinkal, interactionAddress: string, tokenAddress: string) => bigint;
|
|
4
|
+
export declare const getApprovedUtxos: (hinkal: IHinkal, chainId: number, resetCacheBefore?: boolean) => ApprovedUtxoWithInteractionAddress[];
|
|
5
|
+
export declare const getApprovedUtxosForToken: (hinkal: IHinkal, erc20Address: string, chainId: number, resetCacheBefore: boolean) => ApprovedUtxoWithInteractionAddress[];
|
|
6
|
+
export declare const getApprovedBalance: (hinkal: IHinkal, chainId: number, resetCacheBefore: boolean, updateTokensListBefore: boolean) => Promise<Map<string, TokenBalance>>;
|
|
@@ -1,54 +1,49 @@
|
|
|
1
|
-
import { caseInsensitiveEqual as
|
|
1
|
+
import { caseInsensitiveEqual as f } from "../../utils/caseInsensitive.utils.mjs";
|
|
2
2
|
import { resetInHinkalAddressesCache as g, getInHinkalAddressesCache as v, setInHinkalAddressesCache as k } from "../../utils/cacheFunctions.mjs";
|
|
3
|
-
import { Mutex as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
d
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
s ? a = BigInt(s) : (a = r.getInHinkalAddress(p), n[p] = a.toString()), i = H(
|
|
3
|
+
import { Mutex as y } from "async-mutex";
|
|
4
|
+
import { getErc20TokensForChain as x } from "../../utils/erc20tokenFunctions.mjs";
|
|
5
|
+
import { privateTokensDB as m } from "../../../data-structures/TokenDBs/PrivateTokensDB.mjs";
|
|
6
|
+
import { isExtension as u } from "../../../constants/vite.constants.mjs";
|
|
7
|
+
const E = new y(), w = (t, e, a) => (t.forEach((s) => {
|
|
8
|
+
s.inHinkalAddress === a && e.push(s);
|
|
9
|
+
}), e), A = (t, e, a = !1) => {
|
|
10
|
+
const { userKeys: s } = t;
|
|
11
|
+
a && g(t, e, s.getShieldedPublicKey());
|
|
12
|
+
const { approvalsByChain: d } = t, r = v(t, e, s.getShieldedPublicKey());
|
|
13
|
+
let n = [];
|
|
14
|
+
return d[e].forEach((c, i) => {
|
|
15
|
+
const o = r[i];
|
|
16
|
+
let p;
|
|
17
|
+
o ? p = BigInt(o) : (p = s.getInHinkalAddress(i), r[i] = p.toString()), n = w(
|
|
19
18
|
c.map(
|
|
20
|
-
(
|
|
19
|
+
(l) => ({ ...l, interactionAddress: i, chainId: e })
|
|
21
20
|
),
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
n,
|
|
22
|
+
p
|
|
24
23
|
);
|
|
25
|
-
}), k(
|
|
26
|
-
},
|
|
27
|
-
const
|
|
28
|
-
let
|
|
29
|
-
const
|
|
30
|
-
return await
|
|
31
|
-
const c =
|
|
32
|
-
|
|
33
|
-
c.map((
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
),
|
|
37
|
-
token:
|
|
38
|
-
balance: c.reduce((
|
|
24
|
+
}), k(r, t, e, s.getShieldedPublicKey()), n;
|
|
25
|
+
}, K = (t, e, a, s) => A(t, a, s).filter((r) => f(r.tokenAddress, e)).sort((r, n) => r.amount === n.amount ? 0 : r.amount > n.amount ? -1 : 1), M = async (t, e, a, s) => {
|
|
26
|
+
const d = await t.getEthereumAddress();
|
|
27
|
+
let r = [];
|
|
28
|
+
const n = /* @__PURE__ */ new Map();
|
|
29
|
+
return await E.runExclusive(async () => {
|
|
30
|
+
const c = A(t, e, a);
|
|
31
|
+
s && u && await m.fetchAndUpdatePrivateTokens(
|
|
32
|
+
c.map((o) => o.tokenAddress),
|
|
33
|
+
e,
|
|
34
|
+
d
|
|
35
|
+
), r = (u ? await m.getPrivateTokens(e, d) : x(e)).map((o) => ({
|
|
36
|
+
token: o,
|
|
37
|
+
balance: c.reduce((p, l) => f(o.erc20TokenAddress, l.tokenAddress) ? p + l.amount : p, 0n),
|
|
39
38
|
timestamp: "0",
|
|
40
39
|
nfts: []
|
|
41
|
-
})),
|
|
42
|
-
|
|
40
|
+
})), r.forEach((o) => {
|
|
41
|
+
n.set(o.token.erc20TokenAddress.toLowerCase(), o);
|
|
43
42
|
});
|
|
44
|
-
}),
|
|
45
|
-
}, U = (e, d, r) => {
|
|
46
|
-
const { userKeys: t, approvals: o } = e, n = y.utils.getAddress(d), i = o.get(n) ?? [], c = t.getInHinkalAddress(n);
|
|
47
|
-
return i.reduce((s, a) => u(a.tokenAddress, r) && a.inHinkalAddress === c ? s + a.amount : s, 0n);
|
|
43
|
+
}), n;
|
|
48
44
|
};
|
|
49
45
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
U as getMyApprovalAmountForInteraction
|
|
46
|
+
M as getApprovedBalance,
|
|
47
|
+
A as getApprovedUtxos,
|
|
48
|
+
K as getApprovedUtxosForToken
|
|
54
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("../../../data-structures/utxo/Utxo.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("../../../data-structures/utxo/Utxo.cjs"),B=require("../../utils/upToDateState.cjs"),O=require("../../utils/cacheFunctions.cjs"),C=require("../../utils/caseInsensitive.utils.cjs"),k=require("../../utils/encodeTokenWithId.cjs"),N=require("./getInputUtxosEnclave.cjs"),K=require("../../utils/solanaMint.utils.cjs"),L=require("../../../constants/chains.constants.cjs"),R=require("../../utils/addresses.cjs"),M=require("../../../API/unspent-utxos-calls.cjs"),P=async(t,e,s,r,o,u,c,n,d)=>{d+=1;const g=u.slice(d),{lastOutput:w,additionalEncryptedOutputs:f}=await t.utxoUtils.batchProcess(g,n,e,s),p=[...c,...f];return await B.checkAddressNotUpdated(t,r),O.setHinkalCache({lastOutput:w,encryptedOutputs:p},t,s,o),await t.utxoUtils.buildBatchProcess(p,e,s)},S=async(t,e,s,r)=>{const{utxos:o,encryptedOutputs:u,lastOutput:c}=await N.getInputUtxosEnclave(t,s,e);return O.setHinkalCache({encryptedOutputs:u,lastOutput:c},t,s,r),o},b=async(t,e,s,r,o,u,c,n,d)=>{try{return await S(t,e,s,o)}catch{return P(t,e,s,r,o,u,c,n,d)}},z=t=>{if(Array.isArray(t))return t;if(t!==void 0)return[t]},F=async(t,e,s)=>await t.utxoUtils.batchFilterUtxosWithNullifier(e,s),H=(t,e,s,r,o,u,c)=>{for(t.sort((n,d)=>n.amount<=d.amount?1:-1);t.length<e||t.length>e&&t.length<6;)if(t.push(new q.Utxo({amount:0n,erc20TokenAddress:o,mintAddress:c,shieldedPrivateKey:r,tokenId:u})),s)for(;t.length>6;)t.splice(t.length-1)},I=async({hinkal:t,chainId:e,passedShieldedPublicKey:s=void 0,ethAddress:r=void 0,resetCacheBefore:o=!1,allowRemoteDecryption:u=!1})=>{const c=r??await t.getEthereumAddress(),n=s??t.userKeys.getShieldedPublicKey(),{userKeys:d}=t,g=t.encryptedOutputsByChain[e],w=t.nullifiersByChain[e],f=Array.from(g);o&&O.resetCache(t,e,n);let{encryptedOutputs:p,lastOutput:y}=O.getHinkalCache(t,e,n);await B.checkAddressNotUpdated(t,c);const x=y!=="",a=f.findIndex(E=>E.value===y),i=a>-1,l=!x&&a===-1,A=t.areMerkleTreeUpdatesDisabled(),U=!A&&(i||!u&&l),m=!A&&u&&l,T=!U&&!m;let v=[];return U?v=await P(t,d,e,c,n,f,p,y,a):m?v=await b(t,d,e,c,n,f,p,y,a):T&&(v=await t.utxoUtils.buildBatchProcess(p,d,e)),await B.checkAddressNotUpdated(t,c),{inputUtxos:(await F(t,v,w)).filter(E=>!E.isBlocked)}},h=async({hinkal:t,chainId:e,ethAddress:s=void 0})=>{const r=s??await t.getEthereumAddress(),o=R.hashEthereumAddress(r);return{inputUtxos:(await M.getUnspentUtxos(e,o)).utxos.map(({utxo:n})=>new q.Utxo({...n,amount:BigInt(n.amount),randomization:n.randomization?BigInt(n.randomization):void 0}))}},_=async({hinkal:t,tokenWithId:e,minInput:s=2,sliceIfMore6:r=!0,chainId:o,passedShieldedPrivateKey:u=void 0,passedShieldedPublicKey:c=void 0,ethAddress:n=void 0,resetCacheBefore:d=!1,ensuredTokensWithId:g,useBlockedUtxos:w=!1})=>{const f=u??t.userKeys.getShieldedPrivateKey(),{inputUtxos:p}=w?await h({hinkal:t,chainId:o,ethAddress:n}):await I({hinkal:t,tokenWithId:e,minInput:s,sliceIfMore6:r,chainId:o,passedShieldedPrivateKey:u,passedShieldedPublicKey:c,ethAddress:n,resetCacheBefore:d}),y=z(e),x=new Map;p.forEach(a=>{const i=a.getTokenAddress(o);if(y&&!y.some(U=>C.caseInsensitiveEqual(U.erc20TokenAddress,i)&&U.tokenId===a.tokenId))return;const l=k.encodeTokenWithId(o,{erc20TokenAddress:i,tokenId:a.tokenId}),A=x.get(l)??[];x.set(l,[...A,a])}),g?.forEach(a=>{const i=k.encodeTokenWithId(o,{erc20TokenAddress:a.erc20TokenAddress,tokenId:a.tokenId});x.set(i,x.get(i)??[])});for(const[a,i]of x){const l=a.split("-")[0],A=Number(a.split("-")[1]),U=L.isSolanaLike(o),m=U?l:void 0,T=U?K.formatMintAddress(l).compressedAddress.toLowerCase():l.toLowerCase();H(i,s,r,f,T,A,m)}return x};exports.attemptGetInputUtxosRemotely=b;exports.getInputUtxoAndBalance=I;exports.getInputUtxoAndBalanceOfStuckUtxos=h;exports.getInputUtxoAndBalancePerToken=_;exports.getInputUtxosRemotely=S;
|
|
@@ -5,11 +5,11 @@ import { EncryptedOutputWithSign } from '../../../types/commitments.types';
|
|
|
5
5
|
import { type TokenWithId } from '../../../types/token-with-id.types';
|
|
6
6
|
interface IGetInputUtxos {
|
|
7
7
|
hinkal: IHinkal;
|
|
8
|
+
chainId: number;
|
|
8
9
|
tokenWithId?: TokenWithId | TokenWithId[];
|
|
9
10
|
minInput?: number;
|
|
10
11
|
sliceIfMore6?: boolean;
|
|
11
12
|
tokenId?: number;
|
|
12
|
-
chainId?: number;
|
|
13
13
|
passedShieldedPrivateKey?: string;
|
|
14
14
|
passedShieldedPublicKey?: string;
|
|
15
15
|
ethAddress?: string;
|
|
@@ -1,179 +1,172 @@
|
|
|
1
|
-
import { Utxo as
|
|
2
|
-
import {
|
|
3
|
-
import { setHinkalCache as b, resetCache as
|
|
1
|
+
import { Utxo as P } from "../../../data-structures/utxo/Utxo.mjs";
|
|
2
|
+
import { checkAddressNotUpdated as T } from "../../utils/upToDateState.mjs";
|
|
3
|
+
import { setHinkalCache as b, resetCache as S, getHinkalCache as K } from "../../utils/cacheFunctions.mjs";
|
|
4
4
|
import { caseInsensitiveEqual as L } from "../../utils/caseInsensitive.utils.mjs";
|
|
5
|
-
import { encodeTokenWithId as
|
|
6
|
-
import { getInputUtxosEnclave as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { hashEthereumAddress as k } from "../../utils/addresses.mjs";
|
|
5
|
+
import { encodeTokenWithId as B } from "../../utils/encodeTokenWithId.mjs";
|
|
6
|
+
import { getInputUtxosEnclave as k } from "./getInputUtxosEnclave.mjs";
|
|
7
|
+
import { formatMintAddress as N } from "../../utils/solanaMint.utils.mjs";
|
|
8
|
+
import { isSolanaLike as z } from "../../../constants/chains.constants.mjs";
|
|
9
|
+
import { hashEthereumAddress as R } from "../../utils/addresses.mjs";
|
|
11
10
|
import { getUnspentUtxos as F } from "../../../API/unspent-utxos-calls.mjs";
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const w =
|
|
11
|
+
const C = async (t, e, s, n, o, u, c, r, d) => {
|
|
12
|
+
d += 1;
|
|
13
|
+
const w = u.slice(d), { lastOutput: A, additionalEncryptedOutputs: x } = await t.utxoUtils.batchProcess(
|
|
15
14
|
w,
|
|
16
15
|
r,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
),
|
|
20
|
-
return await
|
|
16
|
+
e,
|
|
17
|
+
s
|
|
18
|
+
), l = [...c, ...x];
|
|
19
|
+
return await T(t, n), b(
|
|
21
20
|
{
|
|
22
21
|
lastOutput: A,
|
|
23
|
-
encryptedOutputs:
|
|
22
|
+
encryptedOutputs: l
|
|
24
23
|
},
|
|
25
24
|
t,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
), await t.utxoUtils.buildBatchProcess(
|
|
29
|
-
}, H = async (t,
|
|
25
|
+
s,
|
|
26
|
+
o
|
|
27
|
+
), await t.utxoUtils.buildBatchProcess(l, e, s);
|
|
28
|
+
}, H = async (t, e, s, n) => {
|
|
30
29
|
const {
|
|
31
|
-
utxos:
|
|
32
|
-
encryptedOutputs:
|
|
33
|
-
lastOutput:
|
|
34
|
-
} = await
|
|
30
|
+
utxos: o,
|
|
31
|
+
encryptedOutputs: u,
|
|
32
|
+
lastOutput: c
|
|
33
|
+
} = await k(t, s, e);
|
|
35
34
|
return b(
|
|
36
35
|
{
|
|
37
|
-
encryptedOutputs:
|
|
38
|
-
lastOutput:
|
|
36
|
+
encryptedOutputs: u,
|
|
37
|
+
lastOutput: c
|
|
39
38
|
},
|
|
40
39
|
t,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
),
|
|
44
|
-
}, M = async (t,
|
|
40
|
+
s,
|
|
41
|
+
n
|
|
42
|
+
), o;
|
|
43
|
+
}, M = async (t, e, s, n, o, u, c, r, d) => {
|
|
45
44
|
try {
|
|
46
|
-
return await H(t,
|
|
45
|
+
return await H(t, e, s, o);
|
|
47
46
|
} catch {
|
|
48
|
-
return
|
|
47
|
+
return C(
|
|
49
48
|
t,
|
|
50
|
-
s,
|
|
51
49
|
e,
|
|
52
|
-
|
|
50
|
+
s,
|
|
53
51
|
n,
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
o,
|
|
53
|
+
u,
|
|
54
|
+
c,
|
|
56
55
|
r,
|
|
57
|
-
|
|
56
|
+
d
|
|
58
57
|
);
|
|
59
58
|
}
|
|
60
|
-
},
|
|
59
|
+
}, h = (t) => {
|
|
61
60
|
if (Array.isArray(t))
|
|
62
61
|
return t;
|
|
63
62
|
if (t !== void 0)
|
|
64
63
|
return [t];
|
|
65
|
-
},
|
|
66
|
-
for (t.sort((r,
|
|
67
|
-
if (t.push(new
|
|
64
|
+
}, q = async (t, e, s) => await t.utxoUtils.batchFilterUtxosWithNullifier(e, s), G = (t, e, s, n, o, u, c) => {
|
|
65
|
+
for (t.sort((r, d) => r.amount <= d.amount ? 1 : -1); t.length < e || t.length > e && t.length < 6; )
|
|
66
|
+
if (t.push(new P({ amount: 0n, erc20TokenAddress: o, mintAddress: c, shieldedPrivateKey: n, tokenId: u })), s)
|
|
68
67
|
for (; t.length > 6; )
|
|
69
68
|
t.splice(t.length - 1);
|
|
70
|
-
},
|
|
69
|
+
}, j = async ({
|
|
71
70
|
hinkal: t,
|
|
72
|
-
chainId:
|
|
73
|
-
passedShieldedPublicKey:
|
|
74
|
-
ethAddress:
|
|
75
|
-
resetCacheBefore:
|
|
76
|
-
allowRemoteDecryption:
|
|
71
|
+
chainId: e,
|
|
72
|
+
passedShieldedPublicKey: s = void 0,
|
|
73
|
+
ethAddress: n = void 0,
|
|
74
|
+
resetCacheBefore: o = !1,
|
|
75
|
+
allowRemoteDecryption: u = !1
|
|
77
76
|
}) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
const c = n ?? await t.getEthereumAddress(), r = s ?? t.userKeys.getShieldedPublicKey(), { userKeys: d } = t, w = t.encryptedOutputsByChain[e], A = t.nullifiersByChain[e], x = Array.from(w);
|
|
78
|
+
o && S(t, e, r);
|
|
79
|
+
let { encryptedOutputs: l, lastOutput: m } = K(t, e, r);
|
|
80
|
+
await T(t, c);
|
|
81
|
+
const f = m !== "", a = x.findIndex((E) => E.value === m), i = a > -1, p = !f && a === -1, U = t.areMerkleTreeUpdatesDisabled(), y = !U && (i || !u && p), g = !U && u && p, O = !y && !g;
|
|
82
|
+
let v = [];
|
|
83
|
+
return y ? v = await C(
|
|
83
84
|
t,
|
|
84
|
-
r,
|
|
85
|
-
o
|
|
86
|
-
);
|
|
87
|
-
await C(t, r, d);
|
|
88
|
-
const m = x !== "", u = i.findIndex((E) => E.value === x), p = u > -1, l = !m && u === -1, U = t.areMerkleTreeUpdatesDisabled(), f = !U && (p || !a && l), v = !U && a && l, I = !f && !v;
|
|
89
|
-
let O = [];
|
|
90
|
-
return f ? O = await B(
|
|
91
|
-
t,
|
|
92
|
-
y,
|
|
93
|
-
r,
|
|
94
85
|
d,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
e,
|
|
87
|
+
c,
|
|
88
|
+
r,
|
|
98
89
|
x,
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
l,
|
|
91
|
+
m,
|
|
92
|
+
a
|
|
93
|
+
) : g ? v = await M(
|
|
101
94
|
t,
|
|
102
|
-
y,
|
|
103
|
-
r,
|
|
104
95
|
d,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
e,
|
|
97
|
+
c,
|
|
98
|
+
r,
|
|
108
99
|
x,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
l,
|
|
101
|
+
m,
|
|
102
|
+
a
|
|
103
|
+
) : O && (v = await t.utxoUtils.buildBatchProcess(l, d, e)), await T(t, c), { inputUtxos: (await q(t, v, A)).filter((E) => !E.isBlocked) };
|
|
104
|
+
}, D = async ({
|
|
112
105
|
hinkal: t,
|
|
113
|
-
chainId:
|
|
114
|
-
ethAddress:
|
|
106
|
+
chainId: e,
|
|
107
|
+
ethAddress: s = void 0
|
|
115
108
|
}) => {
|
|
116
|
-
const
|
|
117
|
-
return { inputUtxos: (await F(
|
|
118
|
-
({ utxo:
|
|
119
|
-
...
|
|
120
|
-
amount: BigInt(
|
|
121
|
-
randomization:
|
|
109
|
+
const n = s ?? await t.getEthereumAddress(), o = R(n);
|
|
110
|
+
return { inputUtxos: (await F(e, o)).utxos.map(
|
|
111
|
+
({ utxo: r }) => new P({
|
|
112
|
+
...r,
|
|
113
|
+
amount: BigInt(r.amount),
|
|
114
|
+
randomization: r.randomization ? BigInt(r.randomization) : void 0
|
|
122
115
|
})
|
|
123
116
|
) };
|
|
124
|
-
},
|
|
117
|
+
}, st = async ({
|
|
125
118
|
hinkal: t,
|
|
126
|
-
tokenWithId:
|
|
127
|
-
minInput:
|
|
128
|
-
sliceIfMore6:
|
|
129
|
-
chainId:
|
|
130
|
-
passedShieldedPrivateKey:
|
|
131
|
-
passedShieldedPublicKey:
|
|
119
|
+
tokenWithId: e,
|
|
120
|
+
minInput: s = 2,
|
|
121
|
+
sliceIfMore6: n = !0,
|
|
122
|
+
chainId: o,
|
|
123
|
+
passedShieldedPrivateKey: u = void 0,
|
|
124
|
+
passedShieldedPublicKey: c = void 0,
|
|
132
125
|
ethAddress: r = void 0,
|
|
133
|
-
resetCacheBefore:
|
|
126
|
+
resetCacheBefore: d = !1,
|
|
134
127
|
ensuredTokensWithId: w,
|
|
135
128
|
useBlockedUtxos: A = !1
|
|
136
129
|
}) => {
|
|
137
|
-
const
|
|
130
|
+
const x = u ?? t.userKeys.getShieldedPrivateKey(), { inputUtxos: l } = A ? await D({
|
|
138
131
|
hinkal: t,
|
|
139
|
-
chainId:
|
|
132
|
+
chainId: o,
|
|
140
133
|
ethAddress: r
|
|
141
|
-
}) : await
|
|
134
|
+
}) : await j({
|
|
142
135
|
hinkal: t,
|
|
143
|
-
tokenWithId:
|
|
144
|
-
minInput:
|
|
145
|
-
sliceIfMore6:
|
|
146
|
-
chainId:
|
|
147
|
-
passedShieldedPrivateKey:
|
|
148
|
-
passedShieldedPublicKey:
|
|
136
|
+
tokenWithId: e,
|
|
137
|
+
minInput: s,
|
|
138
|
+
sliceIfMore6: n,
|
|
139
|
+
chainId: o,
|
|
140
|
+
passedShieldedPrivateKey: u,
|
|
141
|
+
passedShieldedPublicKey: c,
|
|
149
142
|
ethAddress: r,
|
|
150
|
-
resetCacheBefore:
|
|
151
|
-
}),
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
(
|
|
143
|
+
resetCacheBefore: d
|
|
144
|
+
}), m = h(e), f = /* @__PURE__ */ new Map();
|
|
145
|
+
l.forEach((a) => {
|
|
146
|
+
const i = a.getTokenAddress(o);
|
|
147
|
+
if (m && !m.some(
|
|
148
|
+
(y) => L(y.erc20TokenAddress, i) && y.tokenId === a.tokenId
|
|
156
149
|
))
|
|
157
150
|
return;
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
}), w?.forEach((
|
|
161
|
-
const
|
|
162
|
-
erc20TokenAddress:
|
|
163
|
-
tokenId:
|
|
151
|
+
const p = B(o, { erc20TokenAddress: i, tokenId: a.tokenId }), U = f.get(p) ?? [];
|
|
152
|
+
f.set(p, [...U, a]);
|
|
153
|
+
}), w?.forEach((a) => {
|
|
154
|
+
const i = B(o, {
|
|
155
|
+
erc20TokenAddress: a.erc20TokenAddress,
|
|
156
|
+
tokenId: a.tokenId
|
|
164
157
|
});
|
|
165
|
-
|
|
158
|
+
f.set(i, f.get(i) ?? []);
|
|
166
159
|
});
|
|
167
|
-
for (const [
|
|
168
|
-
const
|
|
169
|
-
|
|
160
|
+
for (const [a, i] of f) {
|
|
161
|
+
const p = a.split("-")[0], U = Number(a.split("-")[1]), y = z(o), g = y ? p : void 0, O = y ? N(p).compressedAddress.toLowerCase() : p.toLowerCase();
|
|
162
|
+
G(i, s, n, x, O, U, g);
|
|
170
163
|
}
|
|
171
|
-
return
|
|
164
|
+
return f;
|
|
172
165
|
};
|
|
173
166
|
export {
|
|
174
167
|
M as attemptGetInputUtxosRemotely,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
j as getInputUtxoAndBalance,
|
|
169
|
+
D as getInputUtxoAndBalanceOfStuckUtxos,
|
|
170
|
+
st as getInputUtxoAndBalancePerToken,
|
|
178
171
|
H as getInputUtxosRemotely
|
|
179
172
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
Please try again with ${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../utils/erc20tokenFunctions.cjs"),x=require("../../utils/caseInsensitive.utils.cjs"),w=require("../../../data-structures/utxo/Utxo.cjs"),E=require("../etherFunctions.cjs"),P=require("../../../error-handling/customErrors/ErrorWithAmount.cjs");require("../../../error-handling/error-codes.constants.cjs");const y=require("./getInputUtxoAndBalance.cjs"),U=require("../../../data-structures/TokenDBs/PrivateTokensDB.cjs"),q=require("../../../constants/vite.constants.cjs"),B=require("../../utils/encodeTokenWithId.cjs"),S=require("../../utils/mutexes.utils.cjs"),M=require("../../utils/solanaMint.utils.cjs"),b=require("../../../constants/chains.constants.cjs"),W=async(l,n,s,g,i,d=!1,m,T=!1,p=!1)=>S.getChainBalanceFetchingMutex(n).runExclusive(async()=>{const{inputUtxos:r}=p?await y.getInputUtxoAndBalanceOfStuckUtxos({hinkal:l,chainId:n,ethAddress:i}):await y.getInputUtxoAndBalance({hinkal:l,sliceIfMore6:!1,chainId:n,passedShieldedPrivateKey:s,passedShieldedPublicKey:g,ethAddress:i,resetCacheBefore:d,allowRemoteDecryption:m});T&&q.isExtension&&await U.privateTokensDB.fetchAndUpdatePrivateTokens(r.map(e=>e.getTokenAddress(n)).filter(e=>e!==void 0),n,i);const f=(q.isExtension?await U.privateTokensDB.getPrivateTokens(n,i):v.getErc20TokensForChain(n)).map(e=>({token:e,balance:r.reduce((t,c)=>{const a=e.erc20TokenAddress,u=c.getTokenAddress(n);return x.caseInsensitiveEqual(a,u)?t+c.amount:t},0n),timestamp:r.filter(t=>x.caseInsensitiveEqual(t.getTokenAddress(n),e.erc20TokenAddress))[0]?.timeStamp,nfts:r.filter(t=>x.caseInsensitiveEqual(t.getTokenAddress(n),e.erc20TokenAddress)&&t.tokenId!==0).map(t=>({tokenId:t.tokenId,timestamp:t.timeStamp}))})),o=new Map;return f.forEach(e=>{o.set(e.token.erc20TokenAddress.toLowerCase(),e)}),o}),_=async(l,n,s,g,i=6,d=s.map(()=>0),m=!1,T=!1)=>{const{userKeys:p}=l,k=[],r=[],A=await y.getInputUtxoAndBalancePerToken({hinkal:l,sliceIfMore6:!1,ensuredTokensWithId:s.map((o,e)=>({erc20TokenAddress:s[e],tokenId:d[e]})),allowRemoteDecryption:!1,useBlockedUtxos:T,chainId:n});let f=0;for(let o=0;o<s.length;o+=1)if(m===!1){const e=A.get(B.encodeTokenWithId(n,{erc20TokenAddress:s[o],tokenId:d[o]}))??[];if(!e)throw new Error("Missing utxos for token");f=Math.max(e.length,f),r.push(e)}else r.push([]);return f===2?r:(r.forEach((o,e)=>{if(o.length>i){const t=o.slice(0,i),c=t.reduce((a,u)=>a+u.amount,0n);if(g[e]<0n&&c<-g[e]){const a=v.getERC20Token(s[e],n),u=Number(E.getAmountWithPrecision(c,a,2)),h=`Unfortunately your transaction did not go through due to UTXOs limitations.
|
|
2
|
+
Please try again with ${a.symbol}`;throw new P.ErrorWithAmount(u,h)}k.push(t)}else if(o.length<=i){const t=[...o];let c=i-o.length;for(;c>0;){c-=1;const a=b.isSolanaLike(n),u=a?s[e]:void 0,h=a?M.formatMintAddress(s[e]).compressedAddress:s[e];t.push(new w.Utxo({amount:0n,erc20TokenAddress:h,mintAddress:u,shieldedPrivateKey:p.getShieldedPrivateKey(),tokenId:d[e]}))}k.push(t)}}),k)};exports.addPaddingToUtxos=_;exports.getShieldedBalance=W;
|
|
@@ -15,4 +15,4 @@ export declare const getShieldedBalance: (hinkal: IHinkal, chainId: number, pass
|
|
|
15
15
|
* @param maxInput to pad until maxInput number
|
|
16
16
|
* @returns return padded UTXOs for every erc20 token
|
|
17
17
|
*/
|
|
18
|
-
export declare const addPaddingToUtxos: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], maxInput?: number, tokenIds?: number[], forceEmptyUtxos?: boolean, useBlockedUtxos?: boolean) => Promise<Utxo[][]>;
|
|
18
|
+
export declare const addPaddingToUtxos: (hinkal: IHinkal, chainId: number, erc20Addresses: string[], amountChanges: bigint[], maxInput?: number, tokenIds?: number[], forceEmptyUtxos?: boolean, useBlockedUtxos?: boolean) => Promise<Utxo[][]>;
|