@hinkal/common 0.3.9 → 0.3.11
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/README.md +26 -10
- package/common/src/API/API.cjs +1 -1
- package/common/src/API/API.d.ts +4 -5
- package/common/src/API/API.mjs +79 -80
- package/common/src/API/callRelayer.d.ts +1 -0
- package/common/src/API/dashboardTransactionCalls.cjs +1 -1
- package/common/src/API/dashboardTransactionCalls.d.ts +4 -1
- package/common/src/API/dashboardTransactionCalls.mjs +2 -2
- package/common/src/API/enclaveRecipientInfoCalls.d.ts +0 -2
- package/common/src/API/enclaveSignatureCalls.cjs +1 -1
- package/common/src/API/enclaveSignatureCalls.d.ts +2 -1
- package/common/src/API/enclaveSignatureCalls.mjs +5 -8
- package/common/src/API/enclaveUtxoCalls.cjs +1 -1
- package/common/src/API/enclaveUtxoCalls.d.ts +12 -8
- package/common/src/API/enclaveUtxoCalls.mjs +17 -20
- package/common/src/API/privateSendRecipientInfoCalls.cjs +1 -1
- package/common/src/API/privateSendRecipientInfoCalls.d.ts +3 -6
- package/common/src/API/privateSendRecipientInfoCalls.mjs +12 -6
- package/common/src/API/scheduled-transactions-calls.cjs +1 -1
- package/common/src/API/scheduled-transactions-calls.d.ts +1 -5
- package/common/src/API/scheduled-transactions-calls.mjs +2 -6
- package/common/src/constants/bridging.constants.cjs +1 -1
- package/common/src/constants/bridging.constants.d.ts +1 -0
- package/common/src/constants/bridging.constants.mjs +1 -1
- package/common/src/constants/chains.constants.cjs +1 -1
- package/common/src/constants/chains.constants.d.ts +18 -17
- package/common/src/constants/chains.constants.mjs +108 -89
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-base.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-optimism.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-polygon.json.mjs +2 -1
- package/common/src/constants/events.constants.cjs +1 -1
- package/common/src/constants/events.constants.mjs +1 -16
- package/common/src/constants/protocol.constants.cjs +1 -1
- package/common/src/constants/protocol.constants.d.ts +11 -8
- package/common/src/constants/protocol.constants.mjs +1 -1
- package/common/src/constants/server.constants.cjs +1 -1
- package/common/src/constants/server.constants.d.ts +1 -4
- package/common/src/constants/server.constants.mjs +1 -4
- package/common/src/constants/tx-confirmation.constants.cjs +1 -1
- package/common/src/constants/tx-confirmation.constants.d.ts +1 -0
- package/common/src/constants/tx-confirmation.constants.mjs +2 -2
- package/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.d.ts +8 -10
- package/common/src/data-structures/Hinkal/Hinkal.mjs +132 -160
- package/common/src/data-structures/Hinkal/IHinkal.d.ts +7 -10
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +23 -23
- package/common/src/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalActionReceive.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.mjs +57 -57
- package/common/src/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDeposit.mjs +10 -10
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +19 -19
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.mjs +3 -2
- package/common/src/data-structures/Hinkal/hinkalProxySend.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalProxySend.d.ts +6 -0
- package/common/src/data-structures/Hinkal/hinkalProxySend.mjs +16 -0
- package/common/src/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxySwap.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxySwap.mjs +13 -12
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +9 -9
- package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.mjs +15 -14
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.mjs +44 -47
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.mjs +2 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransact.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransact.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransfer.mjs +4 -4
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +101 -94
- package/common/src/data-structures/Hinkal/index.d.ts +0 -1
- package/common/src/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/activity-db.mjs +34 -34
- package/common/src/data-structures/IndexedDB/index.cjs +1 -1
- package/common/src/data-structures/IndexedDB/index.d.ts +1 -0
- package/common/src/data-structures/IndexedDB/index.mjs +1 -0
- package/common/src/data-structures/IndexedDB/scheduled-transactions-db.cjs +1 -0
- package/common/src/data-structures/IndexedDB/scheduled-transactions-db.d.ts +11 -0
- package/common/src/data-structures/IndexedDB/scheduled-transactions-db.mjs +34 -0
- package/common/src/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/signatures-db.mjs +11 -11
- package/common/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs +1 -1
- package/common/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.d.ts +1 -0
- package/common/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs +6 -3
- package/common/src/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/PrivateTokensDB.mjs +18 -19
- package/common/src/data-structures/crypto-keys/keys.cjs +1 -1
- package/common/src/data-structures/crypto-keys/keys.d.ts +1 -0
- package/common/src/data-structures/crypto-keys/keys.mjs +3 -0
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.mjs +11 -11
- package/common/src/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -1
- package/common/src/data-structures/event-service/helpers/ClientEventHelper.mjs +6 -6
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.cjs +1 -1
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.d.ts +1 -0
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.mjs +79 -75
- package/common/src/data-structures/provider-adapter/IProviderAdapter.d.ts +1 -4
- package/common/src/data-structures/token-price-fetcher/TokenChecker.cjs +1 -1
- package/common/src/data-structures/token-price-fetcher/TokenChecker.d.ts +1 -0
- package/common/src/data-structures/token-price-fetcher/TokenChecker.mjs +1 -0
- package/common/src/error-handling/error-codes.constants.cjs +1 -1
- package/common/src/error-handling/error-codes.constants.d.ts +6 -0
- package/common/src/error-handling/error-codes.constants.mjs +10 -4
- package/common/src/functions/auto-deposit-back-helpers/get-gas-token-records.cjs +1 -1
- package/common/src/functions/auto-deposit-back-helpers/get-gas-token-records.mjs +7 -6
- package/common/src/functions/auto-deposit-back-helpers/select-gas-token.cjs +1 -1
- package/common/src/functions/auto-deposit-back-helpers/select-gas-token.mjs +8 -8
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.mjs +1 -2
- package/common/src/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/common/src/functions/pre-transaction/getVolatileTransferAmount.mjs +13 -13
- package/common/src/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.mjs +13 -13
- package/common/src/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.swap.helpers.mjs +13 -13
- package/common/src/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructGeneralZkProof.mjs +4 -4
- package/common/src/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.mjs +5 -5
- package/common/src/functions/snarkjs/constructTxEnclave.cjs +1 -1
- package/common/src/functions/snarkjs/constructTxEnclave.d.ts +1 -1
- package/common/src/functions/snarkjs/constructTxEnclave.mjs +61 -133
- package/common/src/functions/snarkjs/constructTxEnclaveVerify.cjs +1 -0
- package/common/src/functions/snarkjs/constructTxEnclaveVerify.d.ts +5 -0
- package/common/src/functions/snarkjs/constructTxEnclaveVerify.mjs +295 -0
- package/common/src/functions/utils/addresses.cjs +1 -1
- package/common/src/functions/utils/addresses.d.ts +1 -0
- package/common/src/functions/utils/addresses.mjs +13 -12
- package/common/src/functions/utils/bridge-arrival.utils.cjs +1 -1
- package/common/src/functions/utils/bridge-arrival.utils.mjs +12 -11
- package/common/src/functions/utils/bridge-claimable-utxo.utils.cjs +1 -1
- package/common/src/functions/utils/bridge-claimable-utxo.utils.d.ts +1 -1
- package/common/src/functions/utils/bridge-claimable-utxo.utils.mjs +4 -4
- package/common/src/functions/utils/create-provider.cjs +1 -1
- package/common/src/functions/utils/create-provider.mjs +4 -1
- package/common/src/functions/utils/enclave-recipient-info-storage.cjs +1 -1
- package/common/src/functions/utils/enclave-recipient-info-storage.d.ts +4 -1
- package/common/src/functions/utils/enclave-recipient-info-storage.mjs +1 -0
- package/common/src/functions/utils/enclave-signature-storage.cjs +1 -1
- package/common/src/functions/utils/enclave-signature-storage.d.ts +1 -1
- package/common/src/functions/utils/enclave-signature-storage.mjs +3 -3
- package/common/src/functions/utils/enclave-utxo-storage.cjs +1 -1
- package/common/src/functions/utils/enclave-utxo-storage.d.ts +3 -3
- package/common/src/functions/utils/enclave-utxo-storage.mjs +8 -5
- package/common/src/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/common/src/functions/utils/encryptInputForEnclave.d.ts +8 -0
- package/common/src/functions/utils/encryptInputForEnclave.mjs +43 -23
- package/common/src/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/common/src/functions/utils/erc20tokenFunctions.mjs +2 -15
- package/common/src/functions/utils/fees.utils.cjs +1 -1
- package/common/src/functions/utils/fees.utils.mjs +6 -6
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.d.ts +1 -0
- package/common/src/functions/utils/index.mjs +3 -3
- package/common/src/functions/utils/ipfs.d.ts +2 -3
- package/common/src/functions/utils/lifi.utils.d.ts +2 -0
- package/common/src/functions/utils/nearIntents.utils.cjs +1 -1
- package/common/src/functions/utils/nearIntents.utils.mjs +7 -7
- package/common/src/functions/utils/publicBalance.utils.cjs +1 -1
- package/common/src/functions/utils/publicBalance.utils.mjs +10 -10
- package/common/src/functions/utils/temporary-wallet-recovery.utils.cjs +1 -0
- package/common/src/functions/utils/temporary-wallet-recovery.utils.d.ts +7 -0
- package/common/src/functions/utils/temporary-wallet-recovery.utils.mjs +10 -0
- package/common/src/functions/utils/tron.utils.cjs +1 -1
- package/common/src/functions/utils/tron.utils.mjs +16 -29
- package/common/src/functions/utils/tx-confirmation.utils.cjs +1 -1
- package/common/src/functions/utils/tx-confirmation.utils.d.ts +1 -0
- package/common/src/functions/utils/tx-confirmation.utils.mjs +16 -13
- package/common/src/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxoAndBalance.mjs +5 -5
- package/common/src/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxosEnclave.d.ts +1 -1
- package/common/src/functions/web3/events/getInputUtxosEnclave.mjs +19 -11
- package/common/src/functions/web3/events/getShieldedBalance.cjs +1 -1
- package/common/src/functions/web3/events/getShieldedBalance.d.ts +4 -4
- package/common/src/functions/web3/events/getShieldedBalance.mjs +113 -101
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.mjs +16 -16
- package/common/src/providers/SolanaProviderAdapter.cjs +1 -1
- package/common/src/providers/SolanaProviderAdapter.d.ts +1 -4
- package/common/src/providers/SolanaProviderAdapter.mjs +3 -6
- package/common/src/providers/WagmiProviderAdapter.cjs +1 -1
- package/common/src/providers/WagmiProviderAdapter.mjs +5 -5
- package/common/src/types/cache.types.cjs +1 -1
- package/common/src/types/cache.types.d.ts +2 -1
- package/common/src/types/cache.types.mjs +1 -1
- package/common/src/types/enclaveApi.types.d.ts +2 -3
- package/common/src/types/ethereum-network.types.d.ts +1 -0
- package/common/src/types/events.types.d.ts +1 -0
- package/common/src/types/near-intents.types.d.ts +1 -0
- package/common/src/types/remote-proof.types.d.ts +5 -0
- package/common/src/types/remote-tx-build.types.d.ts +37 -4
- package/common/src/types/scheduled-transactions.types.d.ts +18 -0
- package/common/src/types/solana.types.d.ts +0 -3
- package/common/src/webworker/{logError-RKYfeI6h.js → logError-cvFNxc-0.js} +1 -1
- package/common/src/webworker/package.json +1 -2
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorker.types.d.ts +4 -2
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +3 -3
- package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
- package/common/src/webworker/workerProxy-BHzCZ9HT.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/package.json +1 -2
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +1 -0
- package/providers/prepareEthersHinkal.mjs +2 -2
- package/providers/prepareSolanaHinkal.cjs +1 -1
- package/providers/prepareSolanaHinkal.d.ts +1 -0
- package/providers/prepareSolanaHinkal.mjs +2 -2
- package/providers/prepareTronHinkal.cjs +1 -1
- package/providers/prepareTronHinkal.d.ts +1 -0
- package/providers/prepareTronHinkal.mjs +2 -2
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.d.ts +1 -0
- package/providers/prepareWagmiHinkal.mjs +2 -2
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.d.ts +8 -2
- package/services/Hinkal.mjs +15 -4
- package/types/IHinkal.d.ts +8 -2
- package/common/src/API/evm-token-assets.cjs +0 -1
- package/common/src/API/evm-token-assets.mjs +0 -20
- package/common/src/API/getAnyRecipientInfo.d.ts +0 -1
- package/common/src/API/solana-nft-assets.cjs +0 -1
- package/common/src/API/solana-nft-assets.mjs +0 -11
- package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredProxySend.d.ts +0 -5
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +0 -1
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +0 -109
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.cjs +0 -1
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.mjs +0 -94
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.cjs +0 -1
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.mjs +0 -134
- package/common/src/data-structures/TokenDBs/PublicTokensDB.cjs +0 -1
- package/common/src/data-structures/TokenDBs/PublicTokensDB.mjs +0 -32
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.cjs +0 -1
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.mjs +0 -37
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.cjs +0 -1
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.mjs +0 -51
- package/common/src/data-structures/TokenDBs/index.cjs +0 -1
- package/common/src/data-structures/TokenDBs/index.mjs +0 -6
- package/common/src/functions/utils/ipfs.cjs +0 -1
- package/common/src/functions/utils/ipfs.mjs +0 -1
- package/common/src/functions/utils/reloadPage.cjs +0 -1
- package/common/src/functions/utils/reloadPage.mjs +0 -4
- package/common/src/webworker/workerProxy-COB7g4Qc.js +0 -1
|
@@ -1,65 +1,58 @@
|
|
|
1
1
|
import { CustomJSONStringify as e } from "../../functions/utils/serialize.utils.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { poseidonFunction as ee } from "../../crypto/poseidon.mjs";
|
|
2
|
+
import { HINKAL_SUPPORTED_CHAINS as t, WALLET_SUPPORTED_CHAINS as n, chainIds as r, currentSolanaChainId as i, currentTronChainId as a, isSameOnchainNetwork as o, isSolanaLike as s, isTronLike as c, networkRegistry as l, setHinkalTronChainId as u } from "../../constants/chains.constants.mjs";
|
|
3
|
+
import { DAPP_SIGNING_MESSAGE as d, DETERMINISTIC_SOLANA_LEDGER_BLOCKHASH as f, DETERMINISTIC_SOLANA_LEDGER_LAST_VALID_BLOCK_HEIGHT as p, SDK_SIGNING_MESSAGE as m } from "../../constants/protocol.constants.mjs";
|
|
4
|
+
import { EventType as ee, LoginMessageMode as h, zeroProoflessFeeStructure as g } from "../../types/hinkal.types.mjs";
|
|
5
|
+
import { poseidonFunction as _ } from "../../crypto/poseidon.mjs";
|
|
7
6
|
import { transactionErrorCodes as te } from "../../error-handling/error-codes.constants.mjs";
|
|
8
|
-
import { UserKeys as
|
|
9
|
-
import { getScheduledTransactionById as
|
|
10
|
-
import { API as
|
|
11
|
-
import { validateAndGetChainId as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import "
|
|
25
|
-
import { hinkalDepositAndWithdraw as I } from "./hinkalDepositAndWithdraw.mjs";
|
|
26
|
-
import { hinkalSolanaDeposit as L, hinkalSolanaDepositForOther as R } from "./hinkalSolanaDeposit.mjs";
|
|
27
|
-
import { hinkalSwap as z } from "./hinkalSwap.mjs";
|
|
28
|
-
import { hinkalWithdraw as B } from "./hinkalWithdraw.mjs";
|
|
29
|
-
import { MerkleTree as V } from "../merkle-tree/MerkleTree.mjs";
|
|
7
|
+
import { UserKeys as v } from "../crypto-keys/keys.mjs";
|
|
8
|
+
import { getScheduledTransactionById as y } from "../../API/scheduled-transactions-calls.mjs";
|
|
9
|
+
import { API as b } from "../../API/API.mjs";
|
|
10
|
+
import { validateAndGetChainId as x } from "../../functions/utils/token-check.utils.mjs";
|
|
11
|
+
import { getShieldedBalances as S } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
12
|
+
import { getContractWithFetcherByChainId as C } from "../../functions/web3/getContractMetadata.mjs";
|
|
13
|
+
import { fetchOnChainRootHashes as w } from "../../functions/snarkjs/fetchOnChainRootHashes.mjs";
|
|
14
|
+
import { hinkalDeposit as T, hinkalDepositForOther as E } from "./hinkalDeposit.mjs";
|
|
15
|
+
import { createCacheDevice as D } from "../../functions/utils/cacheDevice.utils.mjs";
|
|
16
|
+
import { SolanaProviderAdapter as O } from "../../providers/SolanaProviderAdapter.mjs";
|
|
17
|
+
import { storeAndGetSignatureFromEnclave as k } from "../../functions/utils/enclave-signature-storage.mjs";
|
|
18
|
+
import { generateHashFromSeedPhrases as A } from "../../functions/utils/mnemonics.mjs";
|
|
19
|
+
import { hinkalDepositAndWithdraw as j } from "./hinkalDepositAndWithdraw.mjs";
|
|
20
|
+
import { hinkalSolanaDeposit as M, hinkalSolanaDepositForOther as N } from "./hinkalSolanaDeposit.mjs";
|
|
21
|
+
import { hinkalSwap as P } from "./hinkalSwap.mjs";
|
|
22
|
+
import { hinkalWithdraw as F } from "./hinkalWithdraw.mjs";
|
|
23
|
+
import { MerkleTree as I } from "../merkle-tree/MerkleTree.mjs";
|
|
30
24
|
import "../merkle-tree/index.mjs";
|
|
31
|
-
import { resetMerkleTrees as
|
|
25
|
+
import { resetMerkleTrees as L } from "./resetMerkleTrees.mjs";
|
|
32
26
|
import "../../API/index.mjs";
|
|
33
|
-
import { MultiThreadedUtxoUtils as
|
|
34
|
-
import { hinkalPrivateWallet as
|
|
35
|
-
import { getRecipientInfo as
|
|
36
|
-
import { hinkalSignSubAccount as
|
|
37
|
-
import { hinkalActionReceive as
|
|
38
|
-
import "
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import { hinkalSolanaProxySend as se } from "./hinkalSolanaProxySend.mjs";
|
|
49
|
-
import { hinkalSolanaProxySwap as ce } from "./hinkalSolanaProxySwap.mjs";
|
|
27
|
+
import { MultiThreadedUtxoUtils as R } from "../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs";
|
|
28
|
+
import { hinkalPrivateWallet as ne } from "./hinkalPrivateWallet.mjs";
|
|
29
|
+
import { getRecipientInfo as z } from "./hinkalGetRecipientInfo.mjs";
|
|
30
|
+
import { hinkalSignSubAccount as B } from "./hinkalSignSubAccount.mjs";
|
|
31
|
+
import { hinkalActionReceive as V } from "./hinkalActionReceive.mjs";
|
|
32
|
+
import { hinkalProoflessDeposit as H } from "./hinkalProoflessDeposit.mjs";
|
|
33
|
+
import { hinkalProxySwap as U } from "./hinkalProxySwap.mjs";
|
|
34
|
+
import { hinkalTransfer as W } from "./hinkalTransfer.mjs";
|
|
35
|
+
import { hinkalProxyToPrivate as G } from "./hinkalProxyToPrivate.mjs";
|
|
36
|
+
import { TronProviderAdapter as K } from "../../providers/TronProviderAdapter.mjs";
|
|
37
|
+
import { hinkalSolanaDepositAndWithdraw as q } from "./hinkalSolanaDepositAndWithdraw.mjs";
|
|
38
|
+
import { hinkalSolanaWithdraw as J } from "./hinkalSolanaWithdraw.mjs";
|
|
39
|
+
import { hinkalSolanaTransfer as Y } from "./hinkalSolanaTransfer.mjs";
|
|
40
|
+
import { hinkalSolanaSwap as X } from "./hinkalSolanaSwap.mjs";
|
|
41
|
+
import { hinkalSolanaProxySwap as Z } from "./hinkalSolanaProxySwap.mjs";
|
|
50
42
|
import { hinkalSolanaProxyShield as Q } from "./hinkalSolanaProxyShield.mjs";
|
|
51
|
-
import { hinkalDepositAndBridge as
|
|
52
|
-
import { hinkalBridgePrivateToPrivate as
|
|
53
|
-
import { hinkalNearDepositAndBridge as
|
|
54
|
-
import { hinkalClaimUtxo as
|
|
55
|
-
import { hinkalSolanaProoflessDeposit as
|
|
56
|
-
import { hinkalSolanaClaimUtxo as
|
|
57
|
-
import { hinkalWithdrawStuckUtxos as
|
|
58
|
-
import { HinkalPrivateBalanceController as
|
|
43
|
+
import { hinkalDepositAndBridge as re } from "./hinkalDepositAndBridge.mjs";
|
|
44
|
+
import { hinkalBridgePrivateToPrivate as ie } from "./hinkalBridgePrivateToPrivate.mjs";
|
|
45
|
+
import { hinkalNearDepositAndBridge as ae } from "./hinkalNearDepositAndBridge.mjs";
|
|
46
|
+
import { hinkalClaimUtxo as oe } from "./hinkalClaimUtxo.mjs";
|
|
47
|
+
import { hinkalSolanaProoflessDeposit as $ } from "./hinkalSolanaProoflessDeposit.mjs";
|
|
48
|
+
import { hinkalSolanaClaimUtxo as se } from "./hinkalSolanaClaimUtxo.mjs";
|
|
49
|
+
import { hinkalWithdrawStuckUtxos as ce } from "./hinkalWithdrawStuckUtxos.mjs";
|
|
50
|
+
import { HinkalPrivateBalanceController as le } from "../private-balances/HinkalPrivateBalanceController.mjs";
|
|
59
51
|
import "../private-balances/index.mjs";
|
|
60
|
-
import {
|
|
52
|
+
import { hinkalProxySend as ue } from "./hinkalProxySend.mjs";
|
|
53
|
+
import { Transaction as de } from "@solana/web3.js";
|
|
61
54
|
//#region libs/shared/common/src/data-structures/Hinkal/Hinkal.ts
|
|
62
|
-
var
|
|
55
|
+
var fe = class {
|
|
63
56
|
ethereumProviderAdapter;
|
|
64
57
|
solanaProviderAdapter;
|
|
65
58
|
tronProviderAdapter;
|
|
@@ -70,7 +63,7 @@ var _e = class {
|
|
|
70
63
|
encryptedOutputsByChain = {};
|
|
71
64
|
commitmentsSnapshotServiceByChain = {};
|
|
72
65
|
nullifierSnapshotServiceByChain = {};
|
|
73
|
-
privateBalances = new
|
|
66
|
+
privateBalances = new le(this);
|
|
74
67
|
utxoUtils;
|
|
75
68
|
lastCallState = /* @__PURE__ */ new Map();
|
|
76
69
|
cacheDevice;
|
|
@@ -79,9 +72,9 @@ var _e = class {
|
|
|
79
72
|
disableMerkleTreeUpdates;
|
|
80
73
|
allowParallelBalanceLocalDecryption;
|
|
81
74
|
constructor(e) {
|
|
82
|
-
this.userKeys = new
|
|
83
|
-
this.merkleTreeHinkalByChain[e] =
|
|
84
|
-
}), this.generateProofRemotely = e?.generateProofRemotely ?? !0, this.utxoUtils = new
|
|
75
|
+
this.userKeys = new v(void 0), e?.tronChainOverride && u(e.tronChainOverride), t.forEach((e) => {
|
|
76
|
+
this.merkleTreeHinkalByChain[e] = I.create(_, 0n), this.nullifiersByChain[e] = /* @__PURE__ */ new Set(), this.encryptedOutputsByChain[e] = [];
|
|
77
|
+
}), this.generateProofRemotely = e?.generateProofRemotely ?? !0, this.utxoUtils = new R(), this.cacheDevice = D(e), this.disableMerkleTreeUpdates = e?.disableMerkleTreeUpdates ?? !1, this.allowParallelBalanceLocalDecryption = e?.allowParallelBalanceLocalDecryption ?? !1;
|
|
85
78
|
}
|
|
86
79
|
enforceRateLimit(t, n, r = 1e3) {
|
|
87
80
|
let i = Date.now(), a = e(n), o = this.lastCallState.get(t);
|
|
@@ -93,78 +86,73 @@ var _e = class {
|
|
|
93
86
|
}
|
|
94
87
|
getProviderAdapter(e) {
|
|
95
88
|
let t = e;
|
|
96
|
-
t ||= this.ethereumProviderAdapter ?
|
|
89
|
+
t ||= this.ethereumProviderAdapter ? r.ethMainnet : this.solanaProviderAdapter ? i : r.tronMainnet;
|
|
97
90
|
let n;
|
|
98
|
-
if (n =
|
|
91
|
+
if (n = s(t) ? this.solanaProviderAdapter : c(t) ? this.tronProviderAdapter : this.ethereumProviderAdapter, !n) throw Error("ProviderAdapter is not initialized");
|
|
99
92
|
return n;
|
|
100
93
|
}
|
|
101
94
|
async initProviderAdapter(e, t) {
|
|
102
|
-
let n =
|
|
103
|
-
t instanceof
|
|
104
|
-
let
|
|
105
|
-
await t.init(
|
|
95
|
+
let n = r.ethMainnet;
|
|
96
|
+
t instanceof O ? n = i : t instanceof K && (n = a), await this.updateProviderAdapter(n, t), t.initConnector(e);
|
|
97
|
+
let o = await t.connectAndPatchProvider(e);
|
|
98
|
+
await t.init(o), await this.setListeners();
|
|
106
99
|
}
|
|
107
|
-
getSigningMessage(e =
|
|
100
|
+
getSigningMessage(e = h.SDK) {
|
|
108
101
|
switch (e) {
|
|
109
|
-
case
|
|
110
|
-
case
|
|
111
|
-
default: return
|
|
102
|
+
case h.SDK: return m;
|
|
103
|
+
case h.HINKAL_DAPP:
|
|
104
|
+
default: return d;
|
|
112
105
|
}
|
|
113
106
|
}
|
|
114
|
-
async signHinkalMessage(e =
|
|
107
|
+
async signHinkalMessage(e = h.SDK) {
|
|
115
108
|
let t = this.getSigningMessage(e);
|
|
116
109
|
return this.getProviderAdapter().signMessage(t);
|
|
117
110
|
}
|
|
118
111
|
async signSolanaLedgerMessage() {
|
|
119
|
-
let e = new
|
|
120
|
-
blockhash:
|
|
121
|
-
lastValidBlockHeight:
|
|
112
|
+
let e = new de({
|
|
113
|
+
blockhash: f,
|
|
114
|
+
lastValidBlockHeight: p,
|
|
122
115
|
feePayer: this.getSolanaPublicKey()
|
|
123
116
|
}), t = await this.getProviderAdapter().signTransactionWithoutBroadcast?.(e);
|
|
124
117
|
if (!t) throw Error("Failed to sign transaction without broadcast");
|
|
125
|
-
return
|
|
126
|
-
signature: t.signature,
|
|
127
|
-
txMessageForSolanaLedger: t.transactionMessageB64
|
|
128
|
-
};
|
|
118
|
+
return t;
|
|
129
119
|
}
|
|
130
|
-
async initUserKeys(e =
|
|
131
|
-
this.userKeys = new
|
|
120
|
+
async initUserKeys(e = h.SDK) {
|
|
121
|
+
this.userKeys = new v(await this.signHinkalMessage(e));
|
|
132
122
|
}
|
|
133
123
|
initUserKeysWithSignature(e) {
|
|
134
|
-
this.userKeys = new
|
|
124
|
+
this.userKeys = new v(e);
|
|
125
|
+
}
|
|
126
|
+
initUserKeysWithNullifyingKey(e) {
|
|
127
|
+
this.userKeys = new v(void 0, e);
|
|
135
128
|
}
|
|
136
129
|
async initUserKeysFromSeedPhrases(e) {
|
|
137
|
-
let t =
|
|
138
|
-
this.userKeys = new
|
|
130
|
+
let t = A(e);
|
|
131
|
+
this.userKeys = new v(t);
|
|
139
132
|
}
|
|
140
|
-
async initUserKeysWithEnclaveSignature(e =
|
|
133
|
+
async initUserKeysWithEnclaveSignature(e = h.SDK) {
|
|
141
134
|
if (!await this.getEthereumAddress()) throw Error("Connected address not found");
|
|
142
|
-
let t = this.getProviderAdapter().isSolanaLedger?.()
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
}
|
|
150
|
-
async storeAndGetInitialSignature(e, t = !1, n) {
|
|
151
|
-
let r = await this.getEthereumAddress();
|
|
152
|
-
if (!r) throw Error("Connected address not found");
|
|
153
|
-
return await P(r, e, t, n);
|
|
135
|
+
let t = this.getProviderAdapter().isSolanaLedger?.() ? await this.signSolanaLedgerMessage() : await this.getProviderAdapter().signMessage(this.getSigningMessage(e)), n = await this.storeAndGetInitialSignature(t);
|
|
136
|
+
this.initUserKeysWithSignature(n ?? t);
|
|
137
|
+
}
|
|
138
|
+
async storeAndGetInitialSignature(e) {
|
|
139
|
+
let t = await this.getEthereumAddress();
|
|
140
|
+
if (!t) throw Error("Connected address not found");
|
|
141
|
+
return k(t, e);
|
|
154
142
|
}
|
|
155
143
|
async resetMerkle(e) {
|
|
156
|
-
this.disableMerkleTreeUpdates || (e?.every((e) => this.isSelectedNetworkSupported(e)) ?? !0) && await
|
|
144
|
+
this.disableMerkleTreeUpdates || (e?.every((e) => this.isSelectedNetworkSupported(e)) ?? !0) && await L(this, e);
|
|
157
145
|
}
|
|
158
146
|
getTronWeb() {
|
|
159
147
|
let e = this.tronProviderAdapter;
|
|
160
148
|
if (!e) throw Error("Tron provider adapter not initialized");
|
|
161
|
-
if (!(e instanceof
|
|
149
|
+
if (!(e instanceof K)) throw Error("Tron provider adapter is not a TronProviderAdapter");
|
|
162
150
|
let t = e.getTronWeb();
|
|
163
151
|
if (!t) throw Error("TronWeb not available");
|
|
164
152
|
return t;
|
|
165
153
|
}
|
|
166
154
|
getSupportedChains() {
|
|
167
|
-
return this.ethereumProviderAdapter && this.solanaProviderAdapter ?
|
|
155
|
+
return this.ethereumProviderAdapter && this.solanaProviderAdapter ? n : this.ethereumProviderAdapter ? t.filter((e) => !s(e) && !c(e)) : this.solanaProviderAdapter ? t.filter((e) => s(e)) : this.tronProviderAdapter ? [a] : [];
|
|
168
156
|
}
|
|
169
157
|
async waitForTransaction(e, t, n = 1) {
|
|
170
158
|
return !!await this.getProviderAdapter(e).waitForTransaction(e, t, n);
|
|
@@ -173,7 +161,7 @@ var _e = class {
|
|
|
173
161
|
return this.getProviderAdapter(e).getContract(e, t, n);
|
|
174
162
|
}
|
|
175
163
|
getContractWithFetcherByChainId(e, t, n = void 0) {
|
|
176
|
-
return
|
|
164
|
+
return C(e, t, n);
|
|
177
165
|
}
|
|
178
166
|
async signMessage(e) {
|
|
179
167
|
return await this.getProviderAdapter().signMessage(e);
|
|
@@ -182,7 +170,7 @@ var _e = class {
|
|
|
182
170
|
return await this.getProviderAdapter().signTypedData(e, t, n);
|
|
183
171
|
}
|
|
184
172
|
async signWithSubAccount(e, t, n, r) {
|
|
185
|
-
return
|
|
173
|
+
return B(e, t, n, r);
|
|
186
174
|
}
|
|
187
175
|
getContractWithSigner(e, t, n = "") {
|
|
188
176
|
return this.getProviderAdapter(e).getContractWithSigner(e, t, n);
|
|
@@ -191,10 +179,10 @@ var _e = class {
|
|
|
191
179
|
return this.getProviderAdapter(e).getContractWithFetcher(e, t, n);
|
|
192
180
|
}
|
|
193
181
|
isSelectedNetworkSupported(e) {
|
|
194
|
-
return !!
|
|
182
|
+
return !!l[e];
|
|
195
183
|
}
|
|
196
184
|
async switchNetwork(e) {
|
|
197
|
-
let t = this.getProviderAdapter(), n = t.getChainId(), r = n !== void 0 &&
|
|
185
|
+
let t = this.getProviderAdapter(), n = t.getChainId(), r = n !== void 0 && o(e.chainId, n);
|
|
198
186
|
if (!(e.chainId === n || r)) try {
|
|
199
187
|
await t.switchNetwork(e);
|
|
200
188
|
} catch {
|
|
@@ -209,7 +197,7 @@ var _e = class {
|
|
|
209
197
|
}
|
|
210
198
|
async updateProviderAdapter(e, t) {
|
|
211
199
|
try {
|
|
212
|
-
|
|
200
|
+
s(e) ? (this.solanaProviderAdapter && this.solanaProviderAdapter.release(), this.solanaProviderAdapter = t) : c(e) ? (this.tronProviderAdapter && this.tronProviderAdapter.release(), this.tronProviderAdapter = t) : (this.ethereumProviderAdapter && this.ethereumProviderAdapter.release(), this.ethereumProviderAdapter = t);
|
|
213
201
|
} catch (e) {
|
|
214
202
|
throw console.error(e), Error("updateProviderAdapter failed, please try again.");
|
|
215
203
|
}
|
|
@@ -240,32 +228,22 @@ var _e = class {
|
|
|
240
228
|
}
|
|
241
229
|
async onAccountChanged() {
|
|
242
230
|
await this.ethereumProviderAdapter?.onAccountChanged(), await this.solanaProviderAdapter?.onAccountChanged(), await this.tronProviderAdapter?.onAccountChanged();
|
|
243
|
-
let e =
|
|
231
|
+
let e = ee.AccountChanged;
|
|
244
232
|
typeof document < "u" ? document?.dispatchEvent(new Event(e)) : process?.emit("message", e, void 0);
|
|
245
233
|
}
|
|
246
234
|
async onChainChanged(e) {
|
|
247
|
-
e ? await this.getProviderAdapter(e).onChainChanged(e) :
|
|
235
|
+
e ? await this.getProviderAdapter(e).onChainChanged(e) : await this.disconnectFromConnector();
|
|
248
236
|
}
|
|
249
237
|
async monitorConnectedAddress(e) {
|
|
250
|
-
await
|
|
251
|
-
}
|
|
252
|
-
async
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
async getTotalBalance(e, n, r, i = !1, a, o = !1) {
|
|
256
|
-
let s = r ?? await this.getEthereumAddressByChain(e), c = n ?? this.userKeys, l = await this.getBalances(e, c.getShieldedPrivateKey(), c.getShieldedPublicKey(), s, i, a, o), u = t ? await C.getPrivateTokens(e, s) : await w(e), d = [];
|
|
257
|
-
return u.forEach((e) => {
|
|
258
|
-
let t = e.erc20TokenAddress.toLowerCase(), n = l.get(t), r = {
|
|
259
|
-
token: e,
|
|
260
|
-
balance: n?.balance ?? 0n,
|
|
261
|
-
timestamp: n?.timestamp || "0",
|
|
262
|
-
nfts: n?.nfts || []
|
|
263
|
-
};
|
|
264
|
-
d.push(r);
|
|
265
|
-
}), d;
|
|
238
|
+
await b.monitor(await this.getEthereumAddressByChain(e));
|
|
239
|
+
}
|
|
240
|
+
async getTotalBalances(e, t, n, r = !1, i, a = !1) {
|
|
241
|
+
let o = t ?? this.userKeys, s = new Map(await Promise.all(e.map(async (e) => [e, n ?? await this.getEthereumAddressByChain(e)])));
|
|
242
|
+
return S(this, s, o.getShieldedPrivateKey(), o.getShieldedPublicKey(), r, i, a);
|
|
266
243
|
}
|
|
267
244
|
async getStuckShieldedBalances(e, t, n, r = !1, i = !1) {
|
|
268
|
-
|
|
245
|
+
let a = await this.getTotalBalances(e, t, n, r, i, !0);
|
|
246
|
+
return new Map([...a].map(([e, t]) => [e, t.filter((e) => e.balance > 0n)]));
|
|
269
247
|
}
|
|
270
248
|
get privateBalancesWithUSD() {
|
|
271
249
|
return this.privateBalances.getSnapshot();
|
|
@@ -274,7 +252,7 @@ var _e = class {
|
|
|
274
252
|
return this.privateBalances.onPrivateBalancesWithUSDChange(e);
|
|
275
253
|
}
|
|
276
254
|
async getHinkalTreeRootHash(e) {
|
|
277
|
-
return (await
|
|
255
|
+
return (await w(e)).hinkalRootHash;
|
|
278
256
|
}
|
|
279
257
|
async resetMerkleTreesIfNecessary(e) {
|
|
280
258
|
let t = (await Promise.all((e ?? this.getSupportedChains()).map(async (e) => {
|
|
@@ -299,7 +277,7 @@ var _e = class {
|
|
|
299
277
|
return this.getProviderAdapter(e).getAddress();
|
|
300
278
|
}
|
|
301
279
|
async getRandomRelay(e, t = !1) {
|
|
302
|
-
return (await
|
|
280
|
+
return (await b.getIdleRelay(e, t)).relay;
|
|
303
281
|
}
|
|
304
282
|
getGasPrice(e) {
|
|
305
283
|
let t = this.getProviderAdapter(e);
|
|
@@ -307,7 +285,7 @@ var _e = class {
|
|
|
307
285
|
return t.getGasPrice(e);
|
|
308
286
|
}
|
|
309
287
|
getAPI() {
|
|
310
|
-
return
|
|
288
|
+
return b;
|
|
311
289
|
}
|
|
312
290
|
snapshotsClearInterval() {
|
|
313
291
|
this.getSupportedChains().forEach((e) => {
|
|
@@ -318,46 +296,46 @@ var _e = class {
|
|
|
318
296
|
this.snapshotsClearInterval(), this.privateBalances.dispose(), await this.resetProviderAdapters();
|
|
319
297
|
}
|
|
320
298
|
getRecipientInfo() {
|
|
321
|
-
return
|
|
299
|
+
return z(this);
|
|
322
300
|
}
|
|
323
301
|
async deposit(e, t, n = !0, r = !1) {
|
|
324
|
-
return
|
|
302
|
+
return T(this, e, t, n, r);
|
|
325
303
|
}
|
|
326
304
|
async depositSolana(e, t, n = !1) {
|
|
327
|
-
return
|
|
305
|
+
return M(this, e, t, n);
|
|
328
306
|
}
|
|
329
307
|
async depositForOther(e, t, n, r = !0, i = !1, a) {
|
|
330
308
|
return this.enforceRateLimit(this.depositForOther.name, [
|
|
331
309
|
e,
|
|
332
310
|
t,
|
|
333
311
|
n
|
|
334
|
-
]),
|
|
312
|
+
]), E(this, e, t, n, r, i, a);
|
|
335
313
|
}
|
|
336
314
|
async depositSolanaForOther(e, t, n, r = !1, i) {
|
|
337
315
|
return this.enforceRateLimit(this.depositSolanaForOther.name, [
|
|
338
316
|
e,
|
|
339
317
|
t,
|
|
340
318
|
n
|
|
341
|
-
]),
|
|
319
|
+
]), N(this, e, t, n, r, i);
|
|
342
320
|
}
|
|
343
|
-
async depositAndWithdraw(e, t, n, r, i, a, o,
|
|
344
|
-
return
|
|
321
|
+
async depositAndWithdraw(e, t, n, r, i, a, o, c, l = !0) {
|
|
322
|
+
return s(x([e])) ? q(this, e, t, n, r, i, a, o, c) : j(this, e, t, n, r, i, a, o, c, l);
|
|
345
323
|
}
|
|
346
324
|
async claimUtxo(e, t, n, r) {
|
|
347
|
-
return
|
|
325
|
+
return s(x([e])) ? se(this, e, t, n, r) : oe(this, e, t, n, r);
|
|
348
326
|
}
|
|
349
327
|
async depositAndBridge(e, t, n, r, i, a, o, s = !0) {
|
|
350
|
-
return
|
|
328
|
+
return re(this, e, t, n, r, i, a, o, s);
|
|
351
329
|
}
|
|
352
330
|
async bridgePrivateToPrivate(e, t, n, r, i, a, o, s) {
|
|
353
331
|
return this.enforceRateLimit(this.bridgePrivateToPrivate.name, [
|
|
354
332
|
e,
|
|
355
333
|
t,
|
|
356
334
|
n
|
|
357
|
-
]),
|
|
335
|
+
]), ie(this, e, t, n, r, i, a, o, s);
|
|
358
336
|
}
|
|
359
337
|
async checkSendTransactionStatus(e) {
|
|
360
|
-
return
|
|
338
|
+
return y(e);
|
|
361
339
|
}
|
|
362
340
|
async nearDepositAndBridge(e, t, n, r, i, a, o, s, c) {
|
|
363
341
|
return this.enforceRateLimit(this.nearDepositAndBridge.name, [
|
|
@@ -365,10 +343,10 @@ var _e = class {
|
|
|
365
343
|
t,
|
|
366
344
|
n,
|
|
367
345
|
r
|
|
368
|
-
]),
|
|
346
|
+
]), ae(this, e, t, n, r, i, a, o, s, c);
|
|
369
347
|
}
|
|
370
|
-
async prooflessDeposit(e, t, n, r, i = !1, a =
|
|
371
|
-
return
|
|
348
|
+
async prooflessDeposit(e, t, n, r, i = !1, a = g, o = "", c, l = !1) {
|
|
349
|
+
return s(x(e)) ? $(this, e, t, n, r, i, c, l) : H(this, e, t, n, r, i, a, o, c, l);
|
|
372
350
|
}
|
|
373
351
|
getSolanaProgram(e) {
|
|
374
352
|
if (!this.solanaProviderAdapter) throw Error("No provider adapter initialized");
|
|
@@ -385,24 +363,24 @@ var _e = class {
|
|
|
385
363
|
e,
|
|
386
364
|
t,
|
|
387
365
|
n
|
|
388
|
-
]),
|
|
366
|
+
]), s(x(e)) ? Y(this, e, t, n, r, i, a) : W(this, e, t, n, r, i, a);
|
|
389
367
|
}
|
|
390
|
-
async withdraw(e, t, n, r, i, a, o,
|
|
391
|
-
return
|
|
368
|
+
async withdraw(e, t, n, r, i, a, o, c) {
|
|
369
|
+
return s(x(e)) ? J(this, e, t, n, i, a, o, c) : F(this, e, t, n, r, i, a, o, c);
|
|
392
370
|
}
|
|
393
371
|
async withdrawStuckUtxos(e, t) {
|
|
394
|
-
return
|
|
372
|
+
return ce(this, e, t);
|
|
395
373
|
}
|
|
396
|
-
async swap(e, t, n, r, i, a, o,
|
|
397
|
-
return
|
|
374
|
+
async swap(e, t, n, r, i, a, o, c) {
|
|
375
|
+
return s(x(e)) ? this.swapSolana(e, t, r, i, a, c) : P(this, e, t, n, r, i, a, o, c);
|
|
398
376
|
}
|
|
399
377
|
async swapSolana(e, t, n, r, i, a) {
|
|
400
378
|
let o = JSON.parse(n), s = BigInt(o.swapperAccountSalt), { instructionLists: c, addressLookupTableAccount: l } = o.data;
|
|
401
|
-
return
|
|
379
|
+
return X(this, e, t, s, c, l, r, i, a);
|
|
402
380
|
}
|
|
403
381
|
async actionReceive(e, t, n, r, i, a) {
|
|
404
382
|
if (!i) throw Error("subAccount is required");
|
|
405
|
-
return
|
|
383
|
+
return s(x(e)) ? Q(this, e[0], t[0], i, void 0, !1, r?.variableRate, a) : V(this, e, t, n, r, i, a);
|
|
406
384
|
}
|
|
407
385
|
async actionPrivateWallet(e, t, n, r, i, a, o, s, c, l, u = !1, d, f, p) {
|
|
408
386
|
return this.enforceRateLimit(this.actionPrivateWallet.name, [
|
|
@@ -416,27 +394,21 @@ var _e = class {
|
|
|
416
394
|
s,
|
|
417
395
|
c,
|
|
418
396
|
p
|
|
419
|
-
]),
|
|
397
|
+
]), ne(this, e, t, n, r, i, a, o, s, c, l, u, d, f, p);
|
|
420
398
|
}
|
|
421
|
-
async proxySwap(e, t, n, r, i, a, o,
|
|
422
|
-
return
|
|
399
|
+
async proxySwap(e, t, n, r, i, a, o, c, l = !1, u, d, f, p) {
|
|
400
|
+
return s(x(e)) ? Z(this, e, t, r, a, n, i, o, c, p) : U(this, e, t, n, r, i, a, o, c, l, u, p, d, f);
|
|
423
401
|
}
|
|
424
402
|
async proxyToPrivate(e, t, n, r, i, a, o) {
|
|
425
|
-
return
|
|
403
|
+
return s(x(e)) ? (this.enforceRateLimit(this.proxyToPrivate.name, [
|
|
426
404
|
e[0],
|
|
427
405
|
t[0],
|
|
428
406
|
n,
|
|
429
407
|
r
|
|
430
|
-
]), Q(this, e[0], t[0], n, r, !1, a?.variableRate, o)) :
|
|
408
|
+
]), Q(this, e[0], t[0], n, r, !1, a?.variableRate, o)) : G(this, e, t, r, i, a, n, o);
|
|
431
409
|
}
|
|
432
410
|
async proxySend(e, t, n, r, i, a, o) {
|
|
433
|
-
|
|
434
|
-
if (c(s)) return se(this, e[0], t[0], n, r, o);
|
|
435
|
-
let l = O(this, s, e.map((e) => e.erc20TokenAddress), t, r), u = e.map((e, n) => ({
|
|
436
|
-
token: e,
|
|
437
|
-
amount: -1n * t[n]
|
|
438
|
-
}));
|
|
439
|
-
return await this.actionPrivateWallet(s, [], [], [], l, u, n, i, a, void 0, void 0, void 0, o, void 0);
|
|
411
|
+
return ue(this, e, t, n, r, i, a, o);
|
|
440
412
|
}
|
|
441
413
|
areMerkleTreeUpdatesDisabled() {
|
|
442
414
|
return this.disableMerkleTreeUpdates;
|
|
@@ -446,4 +418,4 @@ var _e = class {
|
|
|
446
418
|
}
|
|
447
419
|
};
|
|
448
420
|
//#endregion
|
|
449
|
-
export {
|
|
421
|
+
export { fe as Hinkal };
|
|
@@ -37,9 +37,8 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
37
37
|
generateProofRemotely: boolean;
|
|
38
38
|
balanceFetchingMutexByChain: Map<number, Mutex>;
|
|
39
39
|
readonly allowParallelBalanceLocalDecryption: boolean;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
getStuckShieldedBalances(chainId: number, userKeys?: UserKeys, ethAddress?: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<TokenBalance[]>;
|
|
40
|
+
getTotalBalances(chainIds: number[], userKeys?: UserKeys, ethAddress?: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean, useBlockedUtxos?: boolean): Promise<Map<number, TokenBalance[]>>;
|
|
41
|
+
getStuckShieldedBalances(chainIds: number[], userKeys?: UserKeys, ethAddress?: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<Map<number, TokenBalance[]>>;
|
|
43
42
|
privateBalancesWithUSD: PrivateBalancesState;
|
|
44
43
|
onPrivateBalancesWithUSDChange(callback: (state: PrivateBalancesState) => void): () => void;
|
|
45
44
|
getSupportedChains(): number[];
|
|
@@ -75,15 +74,13 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
75
74
|
getTronWeb(): TronWeb;
|
|
76
75
|
getSigningMessage(mode?: LoginMessageMode): string;
|
|
77
76
|
signHinkalMessage(mode?: LoginMessageMode): Promise<string>;
|
|
78
|
-
signSolanaLedgerMessage(): Promise<
|
|
79
|
-
signature: string;
|
|
80
|
-
txMessageForSolanaLedger: string;
|
|
81
|
-
}>;
|
|
77
|
+
signSolanaLedgerMessage(): Promise<string>;
|
|
82
78
|
initUserKeys(mode?: LoginMessageMode): Promise<void>;
|
|
83
79
|
initUserKeysWithSignature(signature: string): void;
|
|
80
|
+
initUserKeysWithNullifyingKey(nullifyingKey: string): void;
|
|
84
81
|
initUserKeysFromSeedPhrases(seedPhrases: string[]): Promise<void>;
|
|
85
|
-
initUserKeysWithEnclaveSignature(signInMode?: LoginMessageMode): Promise<
|
|
86
|
-
storeAndGetInitialSignature(authSignature: string
|
|
82
|
+
initUserKeysWithEnclaveSignature(signInMode?: LoginMessageMode): Promise<void>;
|
|
83
|
+
storeAndGetInitialSignature(authSignature: string): Promise<string>;
|
|
87
84
|
initProviderAdapter(connector: ConnectorType, providerAdapter: IProviderAdapter<ConnectorType>): Promise<void>;
|
|
88
85
|
disconnectFromConnector(): Promise<void>;
|
|
89
86
|
resetProviderAdapters(): Promise<void>;
|
|
@@ -101,7 +98,7 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
101
98
|
signWithSubAccount(chainId: number, messageToSign: string | undefined, typedData: TypedData | undefined, subAccount: SubAccount): Promise<string>;
|
|
102
99
|
actionPrivateWallet(chainId: number, erc20Tokens: ERC20Token[], deltaAmounts: bigint[], onChainCreation: boolean[], ops: string[], emporiumTokenChanges: TokenChanges<bigint>[], subAccount?: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, relayOverride?: string, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, privateRecipientInfo?: PrivateRecipientInfo): Promise<string>;
|
|
103
100
|
actionReceive(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], feeTokens?: string, feeStructureOverride?: FeeStructure, subAccount?: SubAccount, action?: AdminTransactionType): Promise<string>;
|
|
104
|
-
proxySwap(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, swapData: string, isTheSameChainSwap: boolean, subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType): Promise<string>;
|
|
101
|
+
proxySwap(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, swapData: string, isTheSameChainSwap: boolean, subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, autoDepositBack?: boolean, maxGasInDollar?: string, bridgedToken?: ERC20Token, bridgedTokenAmount?: bigint, action?: AdminTransactionType): Promise<string>;
|
|
105
102
|
proxyToPrivate(erc20Tokens: ERC20Token[], deltaAmountsBase: bigint[], subAccount: SubAccount, recipientInfo: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType): Promise<string>;
|
|
106
103
|
proxySend(erc20Tokens: ERC20Token[], amounts: bigint[], subAccount: SubAccount, recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType): Promise<string>;
|
|
107
104
|
areMerkleTreeUpdatesDisabled(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../../functions/web3/etherFunctions.cjs`),
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../../functions/web3/etherFunctions.cjs`),i=require(`../../functions/utils/time.utils.cjs`),a=require(`../../error-handling/customErrors/ErrorWithTx.cjs`),o=require(`../../error-handling/logger.cjs`),s=require(`../../types/external-action.types.cjs`),c=require(`../../types/transactions.types.cjs`),l=require(`../../types/admin.types.cjs`),u=require(`../../types/activities.types.cjs`),d=require(`../../types/transaction.types.cjs`),f=require(`../../types/offscreen.types.cjs`);require(`../../types/index.cjs`);const ee=require(`../../API/API.cjs`),p=require(`../../functions/utils/erc20tokenFunctions.cjs`),m=require(`../../error-handling/get-error.message.cjs`);require(`../../error-handling/index.cjs`);const h=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),g=require(`../../functions/utils/create-provider.cjs`),_=require(`../../functions/pre-transaction/getFeeStructure.cjs`),v=require(`../../functions/private-wallet/emporium.helpers.cjs`),y=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),b=require(`../../functions/utils/postToOffscreen.cjs`),x=require(`../../functions/utils/fees.utils.cjs`),S=require(`../../functions/auto-deposit-back-helpers/get-tokens-to-deposit-back.cjs`),C=require(`../../functions/auto-deposit-back-helpers/get-gas-token-records.cjs`),w=require(`../../functions/auto-deposit-back-helpers/select-gas-token.cjs`),T=require(`../../functions/auto-deposit-back-helpers/update-hinkal.cjs`);require(`../../functions/index.cjs`);const E=require(`../IndexedDB/activity-db.cjs`);require(`../IndexedDB/index.cjs`);var D=3*1e3,O=13*1e3,k=async(k,A,j,M,N,P,F,I)=>{if(!j||F.length===0)return;let L;try{let a=g.createJsonRpcProvider(A);await i.waitLittle(A===e.chainIds.ethMainnet?O:D);let o=await S.getTokensToDepositBack(F,N,j,a);if(!o.length){b.postToOffscreen(f.MessagesFromOffscreen.AutoShieldTxStatus,{message:n.transactionErrorCodes.AUTO_SHIELD_SKIPPED});return}let d=(await p.getErc20TokensBySymbolsFromAPI(await x.getGasTokenSymbols(A),A)).filter(e=>e!==void 0),{prices:m}=await ee.API.getTokenPrices(A,d.map(e=>e.erc20TokenAddress)),R=new Map(m.map((e,t)=>[d[t].erc20TokenAddress.toLowerCase(),e])),z=o.map(({token:e})=>e),B=o.map(({balance:e})=>e),V=z.map(({erc20TokenAddress:e})=>e),H=v.createTransaferEmporiumOpsBatch(k,A,V,await h.modifyVolatileTokenAmountChanges(A,z,B,j)),U=await _.getFeeStructure(A,N,V,s.ExternalActionId.Emporium,H.map(e=>y.convertEmporiumOpToCallInfo(e,j,A))),{flatFee:W}=U??{},G=await p.getErc20TokenFromAPI(A,U.feeToken);if(!G)return;let K=r.getAmountInToken(G,W),q=(R.get(G.erc20TokenAddress.toLowerCase())??0)*Number(K),J=await w.selectGasToken(N,q,A,z,H,await C.getGasTokenRecords(d,A,k,j,a,R),U,V,j);if(!J)return;let{feeToken:Y,feeStructure:X}=J??{};if(P&&Number(P)<q){b.postToOffscreen(f.MessagesFromOffscreen.AutoShieldTxStatus,{message:n.gasErrorCodes.GAS_PRICE_EXCEEDS_AUTOSHIELD_LIMIT});return}let Z=z.findIndex(e=>t.caseInsensitiveEqual(e.erc20TokenAddress,Y));Z!==-1&&(B[Z]-=X?.flatFee??0n);let{hinkalAddress:Q}=e.networkRegistry[A].contractData,$={activityType:u.ActivityTypes.AUTO_SHIELD,chainId:A,from:j,to:Q,gasInDollar:q.toString(),tokensReceive:z.map((e,t)=>({amount:r.getAmountInToken(e,B[t]),token:e}))};if(L=await E.activityStorage.saveTxRequest($),b.postToOffscreen(f.MessagesFromOffscreen.AutoShieldTxStatus,{status:c.TransactionStatus.Loading}),I)T.updateHinkal(A,k,I.inputNullifiers?.flat(),I.outCommitments?.flat(),I.encryptedOutputs?.flat());else if(!k.generateProofRemotely)throw Error(`Circomdata should be passed if tx is done locally`);let te={id:0,success:!0,txHash:await k.actionReceive(z,B,Y,X,M,l.AdminTransactionType.AutoShield)};await E.activityStorage.updatePendingTransactions(te,L),b.postToOffscreen(f.MessagesFromOffscreen.AutoShieldTxStatus,{status:c.TransactionStatus.Confirmed,activityRequest:$})}catch(e){let t;e instanceof a.ErrorWithRelayerTransaction&&(t=e.txHash);let n={error:e,id:0,success:!1,...t?{erroredTx:t}:{}};L&&await E.activityStorage.updatePendingTransactions(n,L),b.postToOffscreen(f.MessagesFromOffscreen.AutoShieldTxStatus,{status:c.TransactionStatus.Failed,error:m.getErrorMessageFromTransactionRequest(e,d.TransactionRequestType.ReceiveFromShieldedAccount)}),o.Logger.error(`Error in auto deposit back:`,e)}};exports.handleAutoDepositBack=k;
|