@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
|
@@ -4,15 +4,15 @@ import { gasErrorCodes as r, transactionErrorCodes as i } from "../../error-hand
|
|
|
4
4
|
import { getAmountInToken as a } from "../../functions/web3/etherFunctions.mjs";
|
|
5
5
|
import { waitLittle as ee } from "../../functions/utils/time.utils.mjs";
|
|
6
6
|
import { ErrorWithRelayerTransaction as o } from "../../error-handling/customErrors/ErrorWithTx.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
7
|
+
import { Logger as s } from "../../error-handling/logger.mjs";
|
|
8
|
+
import { ExternalActionId as c } from "../../types/external-action.types.mjs";
|
|
9
|
+
import { TransactionStatus as l } from "../../types/transactions.types.mjs";
|
|
10
|
+
import { AdminTransactionType as u } from "../../types/admin.types.mjs";
|
|
11
|
+
import { ActivityTypes as d } from "../../types/activities.types.mjs";
|
|
12
|
+
import { TransactionRequestType as f } from "../../types/transaction.types.mjs";
|
|
13
|
+
import { MessagesFromOffscreen as p } from "../../types/offscreen.types.mjs";
|
|
13
14
|
import "../../types/index.mjs";
|
|
14
|
-
import { API as
|
|
15
|
-
import { Logger as m } from "../../error-handling/logger.mjs";
|
|
15
|
+
import { API as m } from "../../API/API.mjs";
|
|
16
16
|
import { getErc20TokenFromAPI as h, getErc20TokensBySymbolsFromAPI as g } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
17
17
|
import { getErrorMessageFromTransactionRequest as _ } from "../../error-handling/get-error.message.mjs";
|
|
18
18
|
import "../../error-handling/index.mjs";
|
|
@@ -37,24 +37,24 @@ var k = 3 * 1e3, ne = 13 * 1e3, A = async (A, j, M, N, P, F, I, L) => {
|
|
|
37
37
|
try {
|
|
38
38
|
let o = v(j);
|
|
39
39
|
await ee(j === e.ethMainnet ? ne : k);
|
|
40
|
-
let
|
|
41
|
-
if (!
|
|
42
|
-
S(
|
|
40
|
+
let s = await w(I, P, M, o);
|
|
41
|
+
if (!s.length) {
|
|
42
|
+
S(p.AutoShieldTxStatus, { message: i.AUTO_SHIELD_SKIPPED });
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
let
|
|
45
|
+
let f = (await g(await C(j), j)).filter((e) => e !== void 0), { prices: _ } = await m.getTokenPrices(j, f.map((e) => e.erc20TokenAddress)), z = new Map(_.map((e, t) => [f[t].erc20TokenAddress.toLowerCase(), e])), B = s.map(({ token: e }) => e), V = s.map(({ balance: e }) => e), H = B.map(({ erc20TokenAddress: e }) => e), U = b(A, j, H, await te(j, B, V, M)), W = await y(j, P, H, c.Emporium, U.map((e) => x(e, M, j))), { flatFee: G } = W ?? {}, K = await h(j, W.feeToken);
|
|
46
46
|
if (!K) return;
|
|
47
|
-
let q = a(K, G), J = (z.get(K.erc20TokenAddress.toLowerCase()) ?? 0) * Number(q), Y = await E(P, J, j, B, U, await T(
|
|
47
|
+
let q = a(K, G), J = (z.get(K.erc20TokenAddress.toLowerCase()) ?? 0) * Number(q), Y = await E(P, J, j, B, U, await T(f, j, A, M, o, z), W, H, M);
|
|
48
48
|
if (!Y) return;
|
|
49
49
|
let { feeToken: X, feeStructure: Z } = Y ?? {};
|
|
50
50
|
if (F && Number(F) < J) {
|
|
51
|
-
S(
|
|
51
|
+
S(p.AutoShieldTxStatus, { message: r.GAS_PRICE_EXCEEDS_AUTOSHIELD_LIMIT });
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
let Q = B.findIndex((e) => n(e.erc20TokenAddress, X));
|
|
55
55
|
Q !== -1 && (V[Q] -= Z?.flatFee ?? 0n);
|
|
56
56
|
let { hinkalAddress: re } = t[j].contractData, $ = {
|
|
57
|
-
activityType:
|
|
57
|
+
activityType: d.AUTO_SHIELD,
|
|
58
58
|
chainId: j,
|
|
59
59
|
from: M,
|
|
60
60
|
to: re,
|
|
@@ -64,15 +64,15 @@ var k = 3 * 1e3, ne = 13 * 1e3, A = async (A, j, M, N, P, F, I, L) => {
|
|
|
64
64
|
token: e
|
|
65
65
|
}))
|
|
66
66
|
};
|
|
67
|
-
if (R = await O.saveTxRequest($), S(
|
|
67
|
+
if (R = await O.saveTxRequest($), S(p.AutoShieldTxStatus, { status: l.Loading }), L) D(j, A, L.inputNullifiers?.flat(), L.outCommitments?.flat(), L.encryptedOutputs?.flat());
|
|
68
68
|
else if (!A.generateProofRemotely) throw Error("Circomdata should be passed if tx is done locally");
|
|
69
69
|
let ie = {
|
|
70
70
|
id: 0,
|
|
71
71
|
success: !0,
|
|
72
|
-
txHash: await A.actionReceive(B, V, X, Z, N,
|
|
72
|
+
txHash: await A.actionReceive(B, V, X, Z, N, u.AutoShield)
|
|
73
73
|
};
|
|
74
|
-
await O.updatePendingTransactions(ie, R), S(
|
|
75
|
-
status:
|
|
74
|
+
await O.updatePendingTransactions(ie, R), S(p.AutoShieldTxStatus, {
|
|
75
|
+
status: l.Confirmed,
|
|
76
76
|
activityRequest: $
|
|
77
77
|
});
|
|
78
78
|
} catch (e) {
|
|
@@ -84,10 +84,10 @@ var k = 3 * 1e3, ne = 13 * 1e3, A = async (A, j, M, N, P, F, I, L) => {
|
|
|
84
84
|
success: !1,
|
|
85
85
|
...t ? { erroredTx: t } : {}
|
|
86
86
|
};
|
|
87
|
-
R && await O.updatePendingTransactions(n, R), S(
|
|
88
|
-
status:
|
|
89
|
-
error: _(e,
|
|
90
|
-
}),
|
|
87
|
+
R && await O.updatePendingTransactions(n, R), S(p.AutoShieldTxStatus, {
|
|
88
|
+
status: l.Failed,
|
|
89
|
+
error: _(e, f.ReceiveFromShieldedAccount)
|
|
90
|
+
}), s.error("Error in auto deposit back:", e);
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../constants/protocol.constants.cjs`);const e=require(`../../types/external-action.types.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),n=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../functions/private-wallet/emporium.helpers.cjs`),o=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),s=require(`../../functions/utils/fees.utils.cjs`);var c=async(c,l,u,d,f,p,m)=>{if(!p)throw Error(`hinkalActionReceive: subAccount should be provided`);if(!d)throw Error(`Fee token is required in hinkalActionReceive`);let h=t.validateAndGetChainId(l),g=r.AccountActions.getAddressFromSubAccount(h,p);if(!g)throw Error(`Public account address is not available`);let _=l.map(e=>e.erc20TokenAddress),v=await n.modifyVolatileTokenAmountChanges(h,l,u,g),y=a.createTransaferEmporiumOpsBatch(c,h,_,v),b=await s.calculateModifiedFeeStructureForTokens(h,l,v,f??await i.getFeeStructure(h,d,_,e.ExternalActionId.Emporium,y.map(e=>o.convertEmporiumOpToCallInfo(e,g,h)),
|
|
1
|
+
require(`../../constants/protocol.constants.cjs`);const e=require(`../../types/external-action.types.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),n=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../functions/private-wallet/emporium.helpers.cjs`),o=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),s=require(`../../functions/utils/fees.utils.cjs`);var c=async(c,l,u,d,f,p,m)=>{if(!p)throw Error(`hinkalActionReceive: subAccount should be provided`);if(!d)throw Error(`Fee token is required in hinkalActionReceive`);let h=t.validateAndGetChainId(l),g=r.AccountActions.getAddressFromSubAccount(h,p);if(!g)throw Error(`Public account address is not available`);let _=l.map(e=>e.erc20TokenAddress),v=await n.modifyVolatileTokenAmountChanges(h,l,u,g),y=a.createTransaferEmporiumOpsBatch(c,h,_,v),b=await s.calculateModifiedFeeStructureForTokens(h,l,v,f??await i.getFeeStructure(h,d,_,e.ExternalActionId.Emporium,y.map(e=>o.convertEmporiumOpToCallInfo(e,g,h)),25n)),x=l.map((e,t)=>({token:e,amount:-1n*v[t]}));return c.actionPrivateWallet(h,l,v,v.map(()=>!1),y,x,p,d,b,void 0,void 0,void 0,m,void 0)};exports.hinkalActionReceive=c;
|
|
@@ -13,7 +13,7 @@ var c = async (c, l, u, d, f, p, m) => {
|
|
|
13
13
|
if (!d) throw Error("Fee token is required in hinkalActionReceive");
|
|
14
14
|
let h = t(l), g = r.getAddressFromSubAccount(h, p);
|
|
15
15
|
if (!g) throw Error("Public account address is not available");
|
|
16
|
-
let _ = l.map((e) => e.erc20TokenAddress), v = await n(h, l, u, g), y = a(c, h, _, v), b = await s(h, l, v, f ?? await i(h, d, _, e.Emporium, y.map((e) => o(e, g, h)),
|
|
16
|
+
let _ = l.map((e) => e.erc20TokenAddress), v = await n(h, l, u, g), y = a(c, h, _, v), b = await s(h, l, v, f ?? await i(h, d, _, e.Emporium, y.map((e) => o(e, g, h)), 25n)), x = l.map((e, t) => ({
|
|
17
17
|
token: e,
|
|
18
18
|
amount: -1n * v[t]
|
|
19
19
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/token.types.cjs`),c=require(`../../API/API.cjs`),l=require(`../../functions/utils/erc20tokenFunctions.cjs`),u=require(`../AccountActions/AccountActions.cjs`),d=require(`../../functions/pre-transaction/getFeeStructure.cjs`),f=require(`../../functions/private-wallet/emporium.helpers.cjs`),p=require(`../../constants/addresses.constants.cjs`),m=require(`../../constants/bridging.constants.cjs`),h=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),g=require(`../../functions/utils/fees.utils.cjs`),_=require(`../../functions/utils/enclave-utxo-storage.cjs`),v=require(`../../functions/utils/bridge-arrival.utils.cjs`),y=require(`../../functions/utils/temp-wallet.utils.cjs`),b=require(`../../API/callNearIntentsAPI.cjs`),x=require(`../../functions/utils/nearIntents.utils.cjs`),S=require(`../../functions/web3/lifiAPI.cjs`),C=require(`../../functions/utils/bridge-claimable-utxo.utils.cjs`);var w=async(e,r,d,m,h,g,_,v)=>{let{chainId:b}=r,x=d.chainId,C=r.erc20TokenAddress,w=p.SWAP_ROUTER_ADDRESSES[o.ExternalActionId.Lifi][b];if(!w)throw Error(`LIFI not configured for chain ${b}`);let T=i.randomBigInt(6),{sourceSubAccount:E,destinationSubAccount:D}=y.deriveBridgeTempWallets(e,b,x,T),O=u.AccountActions.getAddressFromSubAccount(b,E),k=u.AccountActions.getAddressFromSubAccount(x,D);if(!O||!k)throw Error(`Missing temp wallet address for LIFI bridge`);let{lifiDataValue:A,outSwapAmountValue:j,extraNativeTokenFee:M}=await S.getLifiPrice(r,d,m,h,O,k),N={calldata:A,expectedAmount:j,nativeFee:M},P=i.getAmountInWei(r,m),F=Array.from(new Set([b,x])),I=a.hashEthereumAddress(await e.getEthereumAddress());await Promise.all(F.map(e=>c.API.addTemporaryWalletNonce(e,I,Number(T),s.TemporaryWalletRecoveryDestination.Confidential)));let L=n.caseInsensitiveEqual(C,t.zeroAddress),R=N.nativeFee>0n&&!L,z=L?P+N.nativeFee:P,B=[r],V=[-z];if(R){let e=await l.getErc20TokenFromAPI(b,t.zeroAddress);if(!e)throw Error(`Native token not found for bridge fee`);B.push(e),V.push(-N.nativeFee)}let H=f.createLifiBridgeOps(e,b,O,w,C,z,P,N),U=B.map((e,t)=>({token:e,amount:V[t]}));return{tempSubAccount:D,sourceTxHash:await e.actionPrivateWallet(b,B,V,V.map(()=>!1),H,U,E,g??C,_,void 0,!1,void 0,v,void 0),expectedAmount:N.expectedAmount}},T=async(e,t,n,r,o,l,d,f)=>{let p=n.chainId,h=i.randomBigInt(6),g=y.buildTempSubAccountForChain(e,p,h),_=u.AccountActions.getAddressFromSubAccount(p,g);if(!_)throw Error(`Missing temp wallet address for NEAR bridge`);let v=a.hashEthereumAddress(await e.getEthereumAddress());await c.API.addTemporaryWalletNonce(p,v,Number(h),s.TemporaryWalletRecoveryDestination.Confidential);let[S,C]=await Promise.all([x.resolveNearAssetId(t.chainId,t.erc20TokenAddress),x.resolveNearAssetId(p,n.erc20TokenAddress)]),w=i.getAmountInWei(t,r),T=new Date(Date.now()+m.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),{quote:E}=await b.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:Math.round(o*1e4)||100,originAsset:S,depositType:`ORIGIN_CHAIN`,destinationAsset:C,amount:w.toString(),recipient:_,recipientType:`DESTINATION_CHAIN`,refundTo:e.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:T});if(!E.depositAddress)throw Error(`NEAR Intents quote returned no deposit address`);let D=await e.withdraw([t],[-w],E.depositAddress,!1,l??t.erc20TokenAddress,d,void 0,f);return{tempSubAccount:g,sourceTxHash:typeof D==`string`?D:D.hash,expectedAmount:BigInt(E.amountOut)}},E=async(n,i,a,s,c)=>{let l=i.chainId,p=i.erc20TokenAddress,m=u.AccountActions.getAddressFromSubAccount(l,a);if(!m)throw Error(`Missing temp wallet address for bridge shield`);let{recipientInfo:v,claimable:y}=C.resolveBridgeRecipient(n,c);if(y&&await _.storeClaimableKeyInEnclave(await n.getEthereumAddressByChain(l),y.ethAddress,y.keys.getShieldedPrivateKey(),l,y.signature),e.isSolanaLike(l))return C.hinkalSolanaShieldBridged(n,i,a,s,v);let b=f.createTransaferEmporiumOpsBatch(n,l,[p],[s]),x=await g.calculateModifiedFeeStructure(l,i,s,await d.getFeeStructure(l,p,[p],o.ExternalActionId.Emporium,b.map(e=>h.convertEmporiumOpToCallInfo(e,m,l)),t.
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/token.types.cjs`),c=require(`../../API/API.cjs`),l=require(`../../functions/utils/erc20tokenFunctions.cjs`),u=require(`../AccountActions/AccountActions.cjs`),d=require(`../../functions/pre-transaction/getFeeStructure.cjs`),f=require(`../../functions/private-wallet/emporium.helpers.cjs`),p=require(`../../constants/addresses.constants.cjs`),m=require(`../../constants/bridging.constants.cjs`),h=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),g=require(`../../functions/utils/fees.utils.cjs`),_=require(`../../functions/utils/enclave-utxo-storage.cjs`),v=require(`../../functions/utils/bridge-arrival.utils.cjs`),y=require(`../../functions/utils/temp-wallet.utils.cjs`),b=require(`../../API/callNearIntentsAPI.cjs`),x=require(`../../functions/utils/nearIntents.utils.cjs`),S=require(`../../functions/web3/lifiAPI.cjs`),C=require(`../../functions/utils/bridge-claimable-utxo.utils.cjs`);var w=async(e,r,d,m,h,g,_,v)=>{let{chainId:b}=r,x=d.chainId,C=r.erc20TokenAddress,w=p.SWAP_ROUTER_ADDRESSES[o.ExternalActionId.Lifi][b];if(!w)throw Error(`LIFI not configured for chain ${b}`);let T=i.randomBigInt(6),{sourceSubAccount:E,destinationSubAccount:D}=y.deriveBridgeTempWallets(e,b,x,T),O=u.AccountActions.getAddressFromSubAccount(b,E),k=u.AccountActions.getAddressFromSubAccount(x,D);if(!O||!k)throw Error(`Missing temp wallet address for LIFI bridge`);let{lifiDataValue:A,outSwapAmountValue:j,extraNativeTokenFee:M}=await S.getLifiPrice(r,d,m,h,O,k),N={calldata:A,expectedAmount:j,nativeFee:M},P=i.getAmountInWei(r,m),F=Array.from(new Set([b,x])),I=a.hashEthereumAddress(await e.getEthereumAddress());await Promise.all(F.map(e=>c.API.addTemporaryWalletNonce(e,I,Number(T),s.TemporaryWalletRecoveryDestination.Confidential)));let L=n.caseInsensitiveEqual(C,t.zeroAddress),R=N.nativeFee>0n&&!L,z=L?P+N.nativeFee:P,B=[r],V=[-z];if(R){let e=await l.getErc20TokenFromAPI(b,t.zeroAddress);if(!e)throw Error(`Native token not found for bridge fee`);B.push(e),V.push(-N.nativeFee)}let H=f.createLifiBridgeOps(e,b,O,w,C,z,P,N),U=B.map((e,t)=>({token:e,amount:V[t]}));return{tempSubAccount:D,sourceTxHash:await e.actionPrivateWallet(b,B,V,V.map(()=>!1),H,U,E,g??C,_,void 0,!1,void 0,v,void 0),expectedAmount:N.expectedAmount}},T=async(e,t,n,r,o,l,d,f)=>{let p=n.chainId,h=i.randomBigInt(6),g=y.buildTempSubAccountForChain(e,p,h),_=u.AccountActions.getAddressFromSubAccount(p,g);if(!_)throw Error(`Missing temp wallet address for NEAR bridge`);let v=a.hashEthereumAddress(await e.getEthereumAddress());await c.API.addTemporaryWalletNonce(p,v,Number(h),s.TemporaryWalletRecoveryDestination.Confidential);let[S,C]=await Promise.all([x.resolveNearAssetId(t.chainId,t.erc20TokenAddress),x.resolveNearAssetId(p,n.erc20TokenAddress)]),w=i.getAmountInWei(t,r),T=new Date(Date.now()+m.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),{quote:E}=await b.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:Math.round(o*1e4)||100,originAsset:S,depositType:`ORIGIN_CHAIN`,destinationAsset:C,amount:w.toString(),recipient:_,recipientType:`DESTINATION_CHAIN`,refundTo:e.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:T});if(!E.depositAddress)throw Error(`NEAR Intents quote returned no deposit address`);let D=await e.withdraw([t],[-w],E.depositAddress,!1,l??t.erc20TokenAddress,d,void 0,f);return{tempSubAccount:g,sourceTxHash:typeof D==`string`?D:D.hash,expectedAmount:BigInt(E.amountOut)}},E=async(n,i,a,s,c)=>{let l=i.chainId,p=i.erc20TokenAddress,m=u.AccountActions.getAddressFromSubAccount(l,a);if(!m)throw Error(`Missing temp wallet address for bridge shield`);let{recipientInfo:v,claimable:y}=C.resolveBridgeRecipient(n,c);if(y&&await _.storeClaimableKeyInEnclave(await n.getEthereumAddressByChain(l),y.ethAddress,y.keys.getShieldedPrivateKey(),l,y.signature,n.userKeys.getSignature()),e.isSolanaLike(l))return C.hinkalSolanaShieldBridged(n,i,a,s,v,t.HINKAL_SHIELD_VARIABLE_RATE);let b=f.createTransaferEmporiumOpsBatch(n,l,[p],[s]),x=await g.calculateModifiedFeeStructure(l,i,s,await d.getFeeStructure(l,p,[p],o.ExternalActionId.Emporium,b.map(e=>h.convertEmporiumOpToCallInfo(e,m,l)),t.HINKAL_PRIVATE_SEND_VARIABLE_RATE)),S=s-g.calculateTotalFee(s,x);if(S<=0n)throw Error(r.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);return{destTxHash:await n.proxyToPrivate([i],[S],a,v,x.feeToken,x),shieldedAmount:S}},D=async(t,n,r,i,a,o=m.DEFAULT_BRIDGING_SLIPPAGE_DECIMAL,s,c,l)=>{let{tempSubAccount:d,sourceTxHash:f,expectedAmount:p}=e.isNearIntentsBridgeSource(n.chainId)?await T(t,n,r,i,o,s,c,l):await w(t,n,r,i,o,s,c,l),h=u.AccountActions.getAddressFromSubAccount(r.chainId,d);if(!h)throw Error(`Missing temp wallet address for bridge`);let{destTxHash:g,shieldedAmount:_}=await E(t,r,d,await v.waitForBridgeArrival(r.chainId,h,r.erc20TokenAddress,p,o),a);return{sourceTxHash:f,destTxHash:g,destinationTokenAmount:_.toString()}};exports.hinkalBridgePrivateToPrivate=D;
|
|
@@ -1,64 +1,64 @@
|
|
|
1
1
|
import { isNearIntentsBridgeSource as e, isSolanaLike as t } from "../../constants/chains.constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { caseInsensitiveEqual as
|
|
4
|
-
import { transactionErrorCodes as
|
|
5
|
-
import { getAmountInWei as
|
|
6
|
-
import { hashEthereumAddress as
|
|
7
|
-
import { ExternalActionId as
|
|
8
|
-
import { TemporaryWalletRecoveryDestination as
|
|
9
|
-
import { API as
|
|
10
|
-
import { getErc20TokenFromAPI as
|
|
11
|
-
import { AccountActions as
|
|
12
|
-
import { getFeeStructure as
|
|
13
|
-
import { createLifiBridgeOps as
|
|
14
|
-
import { SWAP_ROUTER_ADDRESSES as
|
|
15
|
-
import { DEFAULT_BRIDGING_SLIPPAGE_DECIMAL as
|
|
16
|
-
import { convertEmporiumOpToCallInfo as
|
|
17
|
-
import { calculateModifiedFeeStructure as
|
|
18
|
-
import { storeClaimableKeyInEnclave as
|
|
19
|
-
import { waitForBridgeArrival as
|
|
20
|
-
import { buildTempSubAccountForChain as
|
|
21
|
-
import { getNearIntentsQuote as
|
|
22
|
-
import { resolveNearAssetId as
|
|
23
|
-
import { getLifiPrice as
|
|
24
|
-
import { hinkalSolanaShieldBridged as
|
|
2
|
+
import { HINKAL_PRIVATE_SEND_VARIABLE_RATE as n, HINKAL_SHIELD_VARIABLE_RATE as r, zeroAddress as i } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { caseInsensitiveEqual as a } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
4
|
+
import { transactionErrorCodes as o } from "../../error-handling/error-codes.constants.mjs";
|
|
5
|
+
import { getAmountInWei as s, randomBigInt as c } from "../../functions/web3/etherFunctions.mjs";
|
|
6
|
+
import { hashEthereumAddress as l } from "../../functions/utils/addresses.mjs";
|
|
7
|
+
import { ExternalActionId as u } from "../../types/external-action.types.mjs";
|
|
8
|
+
import { TemporaryWalletRecoveryDestination as d } from "../../types/token.types.mjs";
|
|
9
|
+
import { API as f } from "../../API/API.mjs";
|
|
10
|
+
import { getErc20TokenFromAPI as p } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
11
|
+
import { AccountActions as m } from "../AccountActions/AccountActions.mjs";
|
|
12
|
+
import { getFeeStructure as h } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
13
|
+
import { createLifiBridgeOps as g, createTransaferEmporiumOpsBatch as _ } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
14
|
+
import { SWAP_ROUTER_ADDRESSES as v } from "../../constants/addresses.constants.mjs";
|
|
15
|
+
import { DEFAULT_BRIDGING_SLIPPAGE_DECIMAL as y, NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS as b } from "../../constants/bridging.constants.mjs";
|
|
16
|
+
import { convertEmporiumOpToCallInfo as x } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
17
|
+
import { calculateModifiedFeeStructure as S, calculateTotalFee as C } from "../../functions/utils/fees.utils.mjs";
|
|
18
|
+
import { storeClaimableKeyInEnclave as w } from "../../functions/utils/enclave-utxo-storage.mjs";
|
|
19
|
+
import { waitForBridgeArrival as T } from "../../functions/utils/bridge-arrival.utils.mjs";
|
|
20
|
+
import { buildTempSubAccountForChain as E, deriveBridgeTempWallets as D } from "../../functions/utils/temp-wallet.utils.mjs";
|
|
21
|
+
import { getNearIntentsQuote as O } from "../../API/callNearIntentsAPI.mjs";
|
|
22
|
+
import { resolveNearAssetId as k } from "../../functions/utils/nearIntents.utils.mjs";
|
|
23
|
+
import { getLifiPrice as A } from "../../functions/web3/lifiAPI.mjs";
|
|
24
|
+
import { hinkalSolanaShieldBridged as j, resolveBridgeRecipient as M } from "../../functions/utils/bridge-claimable-utxo.utils.mjs";
|
|
25
25
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.ts
|
|
26
|
-
var
|
|
27
|
-
let { chainId: b } = t, x = n.chainId, S = t.erc20TokenAddress, C =
|
|
26
|
+
var N = async (e, t, n, r, o, h, _, y) => {
|
|
27
|
+
let { chainId: b } = t, x = n.chainId, S = t.erc20TokenAddress, C = v[u.Lifi][b];
|
|
28
28
|
if (!C) throw Error(`LIFI not configured for chain ${b}`);
|
|
29
|
-
let w =
|
|
30
|
-
if (!O || !
|
|
31
|
-
let { lifiDataValue: j, outSwapAmountValue: M, extraNativeTokenFee: N } = await
|
|
29
|
+
let w = c(6), { sourceSubAccount: T, destinationSubAccount: E } = D(e, b, x, w), O = m.getAddressFromSubAccount(b, T), k = m.getAddressFromSubAccount(x, E);
|
|
30
|
+
if (!O || !k) throw Error("Missing temp wallet address for LIFI bridge");
|
|
31
|
+
let { lifiDataValue: j, outSwapAmountValue: M, extraNativeTokenFee: N } = await A(t, n, r, o, O, k), P = {
|
|
32
32
|
calldata: j,
|
|
33
33
|
expectedAmount: M,
|
|
34
34
|
nativeFee: N
|
|
35
|
-
}, F =
|
|
36
|
-
await Promise.all(I.map((e) =>
|
|
37
|
-
let R =
|
|
35
|
+
}, F = s(t, r), I = Array.from(new Set([b, x])), L = l(await e.getEthereumAddress());
|
|
36
|
+
await Promise.all(I.map((e) => f.addTemporaryWalletNonce(e, L, Number(w), d.Confidential)));
|
|
37
|
+
let R = a(S, i), z = P.nativeFee > 0n && !R, B = R ? F + P.nativeFee : F, V = [t], H = [-B];
|
|
38
38
|
if (z) {
|
|
39
|
-
let e = await
|
|
39
|
+
let e = await p(b, i);
|
|
40
40
|
if (!e) throw Error("Native token not found for bridge fee");
|
|
41
41
|
V.push(e), H.push(-P.nativeFee);
|
|
42
42
|
}
|
|
43
|
-
let U =
|
|
43
|
+
let U = g(e, b, O, C, S, B, F, P), W = V.map((e, t) => ({
|
|
44
44
|
token: e,
|
|
45
45
|
amount: H[t]
|
|
46
46
|
}));
|
|
47
47
|
return {
|
|
48
|
-
tempSubAccount:
|
|
49
|
-
sourceTxHash: await e.actionPrivateWallet(b, V, H, H.map(() => !1), U, W, T,
|
|
48
|
+
tempSubAccount: E,
|
|
49
|
+
sourceTxHash: await e.actionPrivateWallet(b, V, H, H.map(() => !1), U, W, T, h ?? S, _, void 0, !1, void 0, y, void 0),
|
|
50
50
|
expectedAmount: P.expectedAmount
|
|
51
51
|
};
|
|
52
|
-
},
|
|
53
|
-
let
|
|
52
|
+
}, P = async (e, t, n, r, i, a, o, u) => {
|
|
53
|
+
let p = n.chainId, h = c(6), g = E(e, p, h), _ = m.getAddressFromSubAccount(p, g);
|
|
54
54
|
if (!_) throw Error("Missing temp wallet address for NEAR bridge");
|
|
55
|
-
let v =
|
|
56
|
-
await
|
|
57
|
-
let [
|
|
55
|
+
let v = l(await e.getEthereumAddress());
|
|
56
|
+
await f.addTemporaryWalletNonce(p, v, Number(h), d.Confidential);
|
|
57
|
+
let [y, x] = await Promise.all([k(t.chainId, t.erc20TokenAddress), k(p, n.erc20TokenAddress)]), S = s(t, r), C = new Date(Date.now() + b).toISOString(), { quote: w } = await O({
|
|
58
58
|
dry: !1,
|
|
59
59
|
swapType: "EXACT_INPUT",
|
|
60
60
|
slippageTolerance: Math.round(i * 1e4) || 100,
|
|
61
|
-
originAsset:
|
|
61
|
+
originAsset: y,
|
|
62
62
|
depositType: "ORIGIN_CHAIN",
|
|
63
63
|
destinationAsset: x,
|
|
64
64
|
amount: S.toString(),
|
|
@@ -69,27 +69,27 @@ var M = async (e, t, n, a, m, g, v, y) => {
|
|
|
69
69
|
deadline: C
|
|
70
70
|
});
|
|
71
71
|
if (!w.depositAddress) throw Error("NEAR Intents quote returned no deposit address");
|
|
72
|
-
let
|
|
72
|
+
let T = await e.withdraw([t], [-S], w.depositAddress, !1, a ?? t.erc20TokenAddress, o, void 0, u);
|
|
73
73
|
return {
|
|
74
74
|
tempSubAccount: g,
|
|
75
|
-
sourceTxHash: typeof
|
|
75
|
+
sourceTxHash: typeof T == "string" ? T : T.hash,
|
|
76
76
|
expectedAmount: BigInt(w.amountOut)
|
|
77
77
|
};
|
|
78
|
-
},
|
|
79
|
-
let
|
|
80
|
-
if (!
|
|
81
|
-
let { recipientInfo:
|
|
82
|
-
if (
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
78
|
+
}, F = async (e, i, a, s, c) => {
|
|
79
|
+
let l = i.chainId, d = i.erc20TokenAddress, f = m.getAddressFromSubAccount(l, a);
|
|
80
|
+
if (!f) throw Error("Missing temp wallet address for bridge shield");
|
|
81
|
+
let { recipientInfo: p, claimable: g } = M(e, c);
|
|
82
|
+
if (g && await w(await e.getEthereumAddressByChain(l), g.ethAddress, g.keys.getShieldedPrivateKey(), l, g.signature, e.userKeys.getSignature()), t(l)) return j(e, i, a, s, p, r);
|
|
83
|
+
let v = _(e, l, [d], [s]), y = await S(l, i, s, await h(l, d, [d], u.Emporium, v.map((e) => x(e, f, l)), n)), b = s - C(s, y);
|
|
84
|
+
if (b <= 0n) throw Error(o.INSUFFICIENT_FUNDS_TO_TRANSACT);
|
|
85
85
|
return {
|
|
86
|
-
destTxHash: await e.proxyToPrivate([
|
|
87
|
-
shieldedAmount:
|
|
86
|
+
destTxHash: await e.proxyToPrivate([i], [b], a, p, y.feeToken, y),
|
|
87
|
+
shieldedAmount: b
|
|
88
88
|
};
|
|
89
|
-
},
|
|
90
|
-
let { tempSubAccount: u, sourceTxHash: d, expectedAmount: f } = e(n.chainId) ? await
|
|
91
|
-
if (!
|
|
92
|
-
let { destTxHash: h, shieldedAmount: g } = await
|
|
89
|
+
}, I = async (t, n, r, i, a, o = y, s, c, l) => {
|
|
90
|
+
let { tempSubAccount: u, sourceTxHash: d, expectedAmount: f } = e(n.chainId) ? await P(t, n, r, i, o, s, c, l) : await N(t, n, r, i, o, s, c, l), p = m.getAddressFromSubAccount(r.chainId, u);
|
|
91
|
+
if (!p) throw Error("Missing temp wallet address for bridge");
|
|
92
|
+
let { destTxHash: h, shieldedAmount: g } = await F(t, r, u, await T(r.chainId, p, r.erc20TokenAddress, f, o), a);
|
|
93
93
|
return {
|
|
94
94
|
sourceTxHash: d,
|
|
95
95
|
destTxHash: h,
|
|
@@ -97,4 +97,4 @@ var M = async (e, t, n, a, m, g, v, y) => {
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
//#endregion
|
|
100
|
-
export {
|
|
100
|
+
export { I as hinkalBridgePrivateToPrivate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/
|
|
1
|
+
const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/tron.utils.cjs`),n=require(`../../functions/utils/addresses.cjs`),r=require(`../../types/transact.types.cjs`),i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../../functions/pre-transaction/constructAdminData.cjs`),o=require(`./hinkalTransact.cjs`),s=require(`../../API/admin-calls.cjs`);var c=async(e,n,a,s=!0,c=!1)=>{let l=i.validateAndGetChainId(n);return o.hinkalTransact(e,{chainId:l,erc20Addresses:n.map(e=>e.erc20TokenAddress),amountChanges:a,externalAddress:t.addressToHexFormat(await e.getEthereumAddressByChain(l)),submit:{mode:r.SubmitMode.Self,erc20Tokens:n,approvalAmounts:a,preEstimateGas:s,returnTxData:c}})},l=async(c,l,u,d,f=!0,p=!1,m)=>{if(d.length===0)throw Error(`recipientInfos must not be empty`);if(u.length!==d.length)throw Error(`amountsByRecipient must have one entry per recipientInfo`);let h=i.validateAndGetChainId(l),g=l.map(e=>e.erc20TokenAddress);d.forEach((t,r)=>{if(!n.isValidPrivateAddress(t))throw Error(e.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);if(u[r].length!==g.length)throw Error(`Each amountsByRecipient entry must have one amount per erc20Token`)});let _=g.map((e,t)=>u.reduce((e,n)=>e+n[t],0n)),v=t.addressToHexFormat(await c.getEthereumAddressByChain(h)),y=await o.hinkalTransact(c,{chainId:h,erc20Addresses:g,amountChanges:_.map(()=>0n),externalAddress:v,recipientAddress:d,recipientAmounts:u,forceEmptyUtxos:!0,submit:{mode:r.SubmitMode.Self,erc20Tokens:l,approvalAmounts:_,preEstimateGas:f,returnTxData:p}});return s.emitTxPublicData(a.constructAdminData(m,h,g,_,await c.getEthereumAddress())),y},u=async(e,t,n,r,i=!0,a=!1,o)=>l(e,t,[n],[r],i,a,o);exports.hinkalDeposit=c,exports.hinkalDepositForOther=u;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { transactionErrorCodes as e } from "../../error-handling/error-codes.constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { addressToHexFormat as t } from "../../functions/utils/tron.utils.mjs";
|
|
3
|
+
import { isValidPrivateAddress as n } from "../../functions/utils/addresses.mjs";
|
|
4
4
|
import { SubmitMode as r } from "../../types/transact.types.mjs";
|
|
5
5
|
import { validateAndGetChainId as i } from "../../functions/utils/token-check.utils.mjs";
|
|
6
6
|
import { constructAdminData as a } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
7
7
|
import { hinkalTransact as o } from "./hinkalTransact.mjs";
|
|
8
8
|
import { emitTxPublicData as s } from "../../API/admin-calls.mjs";
|
|
9
9
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalDeposit.ts
|
|
10
|
-
var c = async (e,
|
|
11
|
-
let l = i(
|
|
10
|
+
var c = async (e, n, a, s = !0, c = !1) => {
|
|
11
|
+
let l = i(n);
|
|
12
12
|
return o(e, {
|
|
13
13
|
chainId: l,
|
|
14
|
-
erc20Addresses:
|
|
14
|
+
erc20Addresses: n.map((e) => e.erc20TokenAddress),
|
|
15
15
|
amountChanges: a,
|
|
16
|
-
externalAddress:
|
|
16
|
+
externalAddress: t(await e.getEthereumAddressByChain(l)),
|
|
17
17
|
submit: {
|
|
18
18
|
mode: r.Self,
|
|
19
|
-
erc20Tokens:
|
|
19
|
+
erc20Tokens: n,
|
|
20
20
|
approvalAmounts: a,
|
|
21
21
|
preEstimateGas: s,
|
|
22
22
|
returnTxData: c
|
|
@@ -26,11 +26,11 @@ var c = async (e, t, a, s = !0, c = !1) => {
|
|
|
26
26
|
if (d.length === 0) throw Error("recipientInfos must not be empty");
|
|
27
27
|
if (u.length !== d.length) throw Error("amountsByRecipient must have one entry per recipientInfo");
|
|
28
28
|
let h = i(l), g = l.map((e) => e.erc20TokenAddress);
|
|
29
|
-
d.forEach((
|
|
30
|
-
if (!t
|
|
29
|
+
d.forEach((t, r) => {
|
|
30
|
+
if (!n(t)) throw Error(e.RECIPIENT_FORMAT_INCORRECT);
|
|
31
31
|
if (u[r].length !== g.length) throw Error("Each amountsByRecipient entry must have one amount per erc20Token");
|
|
32
32
|
});
|
|
33
|
-
let _ = g.map((e, t) => u.reduce((e, n) => e + n[t], 0n)), v =
|
|
33
|
+
let _ = g.map((e, t) => u.reduce((e, n) => e + n[t], 0n)), v = t(await c.getEthereumAddressByChain(h)), y = await o(c, {
|
|
34
34
|
chainId: h,
|
|
35
35
|
erc20Addresses: g,
|
|
36
36
|
amountChanges: _.map(() => 0n),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../utxo/Utxo.cjs`),a=require(`../../functions/utils/
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../utxo/Utxo.cjs`),a=require(`../../functions/utils/tron.utils.cjs`),o=require(`../../functions/utils/addresses.cjs`),s=require(`../../types/external-action.types.cjs`),c=require(`../../types/transact.types.cjs`),l=require(`../../functions/utils/token-check.utils.cjs`),u=require(`../crypto-keys/encryptDecryptUtxo.cjs`),d=require(`../../functions/pre-transaction/constructAdminData.cjs`),f=require(`../../functions/pre-transaction/getFeeStructure.cjs`),p=require(`../../functions/pre-transaction/speculativeUtxo.cjs`),m=require(`../../functions/web3/functionCalls/transactCallDirectTron.cjs`),h=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),g=require(`./hinkalTransact.cjs`);require(`../../functions/index.cjs`);const _=require(`./hinkalDepositOnChainUtxos.cjs`);let v=require(`ethers`);var y=async(e,o,s,l,u,f,m,h)=>{if(l.length===0)throw Error(`userDepositedUtxos must not be empty`);let _=s.erc20TokenAddress,[v,y]=await Promise.all([e.getRandomRelay(o),e.getEthereumAddressByChain(o)]);if(!v)throw Error(r.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let b=e.generateProofRemotely?5:1,x=[],S=a.addressToHexFormat(y);for(let r=0;r<l.length;r+=b){let s=l.slice(r,r+b),y=await Promise.all(s.map(async({recipientAddress:s,utxo:l},y)=>{let b=r+y,x=a.addressToHexFormat(s),C=n.caseInsensitiveEqual(l.erc20TokenAddress,_)?l:i.Utxo.createFrom(l,{erc20TokenAddress:_}),w=d.constructAdminData(f,o,[_],[-l.amount],S),{zkCallData:T,circomData:E,dimData:D,commitmentValidationData:O,tronProofSignature:k}=await g.hinkalTransact(e,{chainId:o,erc20Addresses:[_],amountChanges:[-l.amount],externalAddress:x,feeStructure:u,relay:v??t.zeroAddress,inputUtxos:[[C]],useBlockedUtxos:!0,speculative:h&&{pendingLeaves:h,inputUtxos:[[p.toSpeculativeUtxo(C)]]},submit:{mode:c.SubmitMode.ProofOnly},skipLock:!0});return{zkCallData:T,dimData:D,circomData:E,commitmentValidationData:O,adminData:w,recipientAddress:s,tronProofSignature:k,destinationChainId:m?.chainId,destinationTokenAddress:m?.tokenAddress,destinationTokenAmount:m?.tokenAmounts?.[b]}}));x.push(...y)}return x},b=async(e,t,n,r,i)=>{let{chainId:a,hashedEthereumAddress:o,feeStructure:s,action:c,destination:l}=i,{txCompletionTime:u,ref:d,hashedDashboardAccountId:f,preEstimateGas:p}=i,m=n.map(e=>e+s.flatFee),g=await _.prepareDepositOnChainUtxos(e,a,[t],[m]),{depositedUtxos:v,pendingLeaves:b}=g,x=v[0].map((e,t)=>({recipientAddress:r[t],utxo:e})),[S,C]=await Promise.all([_.submitDepositOnChainUtxos(e,g,p),y(e,a,t,x,s,c,l,b)]);return{depositTxHash:S,scheduleId:await h.transactCallRelayerBatch(a,C,o,u,d,f,S)}},x=async(e,t,n,r,i)=>{let{chainId:o,ethereumAddress:s,hashedEthereumAddress:l,feeStructure:d,action:f,destination:p}=i,{txCompletionTime:_,ref:b,hashedDashboardAccountId:x,preEstimateGas:S}=i,C=n.map(e=>e+d.flatFee),w=C.reduce((e,t)=>e+t,0n),T=await g.hinkalTransact(e,{chainId:o,erc20Addresses:[t.erc20TokenAddress],amountChanges:[w],externalAddress:s,selfOutputAmounts:C,createBlockedUtxos:!0,forceEmptyUtxos:!0,submit:{mode:c.SubmitMode.ProofOnly}}),E=T.circomData.encryptedOutputs?.[0];if(!E||E.length!==C.length)throw Error(`Deposit proof is missing encryptedOutputs for the deposited UTXOs`);let D=E.map((t,n)=>({recipientAddress:r[n],utxo:u.decryptUtxo(v.ethers.getBytes(t),e.userKeys)})),O=T.circomData.outCommitments.flat().map(e=>BigInt(e)).filter(e=>e!==0n).map(e=>e.toString()),[k,A]=await Promise.all([(async()=>{a.swapTronBCoordinate(T.zkCallData);let n=await m.transactCallDirectTron(e,o,w,t,T.zkCallData,T.circomData,T.dimData,void 0,void 0,S,T.tronProofSignature);if(!n)throw Error(`Deposit transaction hash not found`);return n})(),y(e,o,t,D,d,f,p,O)]);return{depositTxHash:k,scheduleId:await h.transactCallRelayerBatch(o,A,l,_,b,x,k)}},S=async(t,n,r,i,c,u,d,p,m,h=!0,g)=>{let _=l.validateAndGetChainId([n]),v=n.erc20TokenAddress,y=a.addressToHexFormat(await t.getEthereumAddressByChain(_)),S={chainId:_,ethereumAddress:y,hashedEthereumAddress:o.hashEthereumAddress(y),feeStructure:u??await f.getFeeStructure(_,v,[v],s.ExternalActionId.Transact,[],25n),txCompletionTime:c,ref:d,action:p,hashedDashboardAccountId:m?o.hashString(m):void 0,preEstimateGas:h,destination:g};if(!e.isTronLike(_))return b(t,n,r,i,S);if(r.length>4)throw Error(`Tron supports at most 4 recipients per deposit - no circuit emits more outputs`);return x(t,n,r,i,S)};exports.hinkalDepositAndWithdraw=S;
|
|
@@ -3,8 +3,8 @@ import { zeroAddress as t } from "../../constants/protocol.constants.mjs";
|
|
|
3
3
|
import { caseInsensitiveEqual as n } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
4
4
|
import { transactionErrorCodes as r } from "../../error-handling/error-codes.constants.mjs";
|
|
5
5
|
import { Utxo as i } from "../utxo/Utxo.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { addressToHexFormat as a, swapTronBCoordinate as o } from "../../functions/utils/tron.utils.mjs";
|
|
7
|
+
import { hashEthereumAddress as s, hashString as c } from "../../functions/utils/addresses.mjs";
|
|
8
8
|
import { ExternalActionId as l } from "../../types/external-action.types.mjs";
|
|
9
9
|
import { SubmitMode as u } from "../../types/transact.types.mjs";
|
|
10
10
|
import { validateAndGetChainId as d } from "../../functions/utils/token-check.utils.mjs";
|
|
@@ -19,15 +19,15 @@ import "../../functions/index.mjs";
|
|
|
19
19
|
import { prepareDepositOnChainUtxos as y, submitDepositOnChainUtxos as b } from "./hinkalDepositOnChainUtxos.mjs";
|
|
20
20
|
import { ethers as x } from "ethers";
|
|
21
21
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.ts
|
|
22
|
-
var S = async (e,
|
|
22
|
+
var S = async (e, o, s, c, l, d, f, m) => {
|
|
23
23
|
if (c.length === 0) throw Error("userDepositedUtxos must not be empty");
|
|
24
|
-
let g =
|
|
24
|
+
let g = s.erc20TokenAddress, [_, y] = await Promise.all([e.getRandomRelay(o), e.getEthereumAddressByChain(o)]);
|
|
25
25
|
if (!_) throw Error(r.RELAYER_NOT_AVAILABLE);
|
|
26
|
-
let b = e.generateProofRemotely ? 5 : 1, x = [], S =
|
|
26
|
+
let b = e.generateProofRemotely ? 5 : 1, x = [], S = a(y);
|
|
27
27
|
for (let r = 0; r < c.length; r += b) {
|
|
28
|
-
let
|
|
29
|
-
let b = r + y, x = s
|
|
30
|
-
chainId:
|
|
28
|
+
let s = c.slice(r, r + b), y = await Promise.all(s.map(async ({ recipientAddress: s, utxo: c }, y) => {
|
|
29
|
+
let b = r + y, x = a(s), C = n(c.erc20TokenAddress, g) ? c : i.createFrom(c, { erc20TokenAddress: g }), w = p(d, o, [g], [-c.amount], S), { zkCallData: T, circomData: E, dimData: D, commitmentValidationData: O, tronProofSignature: k } = await v(e, {
|
|
30
|
+
chainId: o,
|
|
31
31
|
erc20Addresses: [g],
|
|
32
32
|
amountChanges: [-c.amount],
|
|
33
33
|
externalAddress: x,
|
|
@@ -48,7 +48,7 @@ var S = async (e, a, o, c, l, d, f, m) => {
|
|
|
48
48
|
circomData: E,
|
|
49
49
|
commitmentValidationData: O,
|
|
50
50
|
adminData: w,
|
|
51
|
-
recipientAddress:
|
|
51
|
+
recipientAddress: s,
|
|
52
52
|
tronProofSignature: k,
|
|
53
53
|
destinationChainId: f?.chainId,
|
|
54
54
|
destinationTokenAddress: f?.tokenAddress,
|
|
@@ -68,11 +68,11 @@ var S = async (e, a, o, c, l, d, f, m) => {
|
|
|
68
68
|
scheduleId: await _(a, w, o, u, d, f, C)
|
|
69
69
|
};
|
|
70
70
|
}, w = async (e, t, n, r, i) => {
|
|
71
|
-
let { chainId: a, ethereumAddress:
|
|
71
|
+
let { chainId: a, ethereumAddress: s, hashedEthereumAddress: c, feeStructure: l, action: d, destination: p } = i, { txCompletionTime: m, ref: h, hashedDashboardAccountId: y, preEstimateGas: b } = i, C = n.map((e) => e + l.flatFee), w = C.reduce((e, t) => e + t, 0n), T = await v(e, {
|
|
72
72
|
chainId: a,
|
|
73
73
|
erc20Addresses: [t.erc20TokenAddress],
|
|
74
74
|
amountChanges: [w],
|
|
75
|
-
externalAddress:
|
|
75
|
+
externalAddress: s,
|
|
76
76
|
selfOutputAmounts: C,
|
|
77
77
|
createBlockedUtxos: !0,
|
|
78
78
|
forceEmptyUtxos: !0,
|
|
@@ -83,25 +83,25 @@ var S = async (e, a, o, c, l, d, f, m) => {
|
|
|
83
83
|
recipientAddress: r[n],
|
|
84
84
|
utxo: f(x.getBytes(t), e.userKeys)
|
|
85
85
|
})), O = T.circomData.outCommitments.flat().map((e) => BigInt(e)).filter((e) => e !== 0n).map((e) => e.toString()), [k, A] = await Promise.all([(async () => {
|
|
86
|
-
|
|
86
|
+
o(T.zkCallData);
|
|
87
87
|
let n = await g(e, a, w, t, T.zkCallData, T.circomData, T.dimData, void 0, void 0, b, T.tronProofSignature);
|
|
88
88
|
if (!n) throw Error("Deposit transaction hash not found");
|
|
89
89
|
return n;
|
|
90
90
|
})(), S(e, a, t, D, l, d, p, O)]);
|
|
91
91
|
return {
|
|
92
92
|
depositTxHash: k,
|
|
93
|
-
scheduleId: await _(a, A,
|
|
93
|
+
scheduleId: await _(a, A, c, m, h, y, k)
|
|
94
94
|
};
|
|
95
|
-
}, T = async (t, n, r, i,
|
|
96
|
-
let v = d([n]), y = n.erc20TokenAddress, b =
|
|
95
|
+
}, T = async (t, n, r, i, o, u, f, p, h, g = !0, _) => {
|
|
96
|
+
let v = d([n]), y = n.erc20TokenAddress, b = a(await t.getEthereumAddressByChain(v)), x = {
|
|
97
97
|
chainId: v,
|
|
98
98
|
ethereumAddress: b,
|
|
99
|
-
hashedEthereumAddress:
|
|
100
|
-
feeStructure: u ?? await m(v, y, [y], l.Transact, [],
|
|
101
|
-
txCompletionTime:
|
|
99
|
+
hashedEthereumAddress: s(b),
|
|
100
|
+
feeStructure: u ?? await m(v, y, [y], l.Transact, [], 25n),
|
|
101
|
+
txCompletionTime: o,
|
|
102
102
|
ref: f,
|
|
103
103
|
action: p,
|
|
104
|
-
hashedDashboardAccountId: h ?
|
|
104
|
+
hashedDashboardAccountId: h ? c(h) : void 0,
|
|
105
105
|
preEstimateGas: g,
|
|
106
106
|
destination: _
|
|
107
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/time.utils.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../../constants/bridging.constants.cjs`),i=require(`../../API/callNearIntentsAPI.cjs`),a=require(`../../functions/utils/nearIntents.utils.cjs`),o=require(`./hinkalDepositAndWithdraw.cjs`),s=require(`./hinkalSolanaDepositAndWithdraw.cjs`);var c=async(c,l,u,d,f,p,m,h,g,_)=>{if(u.length!==d.length)throw Error(`recipientAmounts and recipientAddresses length mismatch`);if(u.length===0)throw Error(`No recipients to bridge`);let v=n.validateAndGetChainId([l]),y=t.secondsToMs(p),b=new Date(y+r.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),x=await Promise.all(d.map(async(e,t)=>{let n=u[t],{quote:r}=await i.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:f.slippageBps??100,originAsset:f.originAsset,depositType:`ORIGIN_CHAIN`,destinationAsset:f.destinationAsset,amount:n.toString(),recipient:e,recipientType:`DESTINATION_CHAIN`,refundTo:c.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:b});if(!r.depositAddress)throw Error(`NEAR Intents quote returned no deposit address for recipient ${e}`);if(r.deadline&&new Date(r.deadline).getTime()<y)throw Error(`Bridge quote expires before the scheduled execution time. Choose a sooner time.`);return{destinationRecipient:e,amount:n,depositAddress:r.depositAddress,quote:r}})),S=m??await a.buildNearBridgeFeeStructure(v,l,x[0].depositAddress),C=x.map(e=>e.amount),w=x.map(e=>e.depositAddress),T={chainId:f.destinationChainId===v?void 0:f.destinationChainId,tokenAddress:f.destinationTokenAddress,tokenAmounts:x.map(e=>e.quote.amountOut)},E;return e.isSolanaLike(v)?{depositTxHash:E}=await s.hinkalSolanaDepositAndWithdraw(c,l,C,w,p,S,h,g,_,x.map(e=>e.destinationRecipient),T):{depositTxHash:E}=await o.hinkalDepositAndWithdraw(c,l,C,w,p,S,h,g,_,void 0,T),{depositTxHash:E,legs:x}};exports.hinkalNearDepositAndBridge=c;
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/time.utils.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../../constants/bridging.constants.cjs`),i=require(`../../API/callNearIntentsAPI.cjs`),a=require(`../../functions/utils/nearIntents.utils.cjs`),o=require(`./hinkalDepositAndWithdraw.cjs`),s=require(`./hinkalSolanaDepositAndWithdraw.cjs`);var c=async(c,l,u,d,f,p,m,h,g,_)=>{if(u.length!==d.length)throw Error(`recipientAmounts and recipientAddresses length mismatch`);if(u.length===0)throw Error(`No recipients to bridge`);let v=n.validateAndGetChainId([l]),y=t.secondsToMs(p),b=new Date(y+r.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),x=await Promise.all(d.map(async(e,t)=>{let n=u[t],{quote:r}=await i.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:f.slippageBps??100,originAsset:f.originAsset,depositType:`ORIGIN_CHAIN`,destinationAsset:f.destinationAsset,amount:n.toString(),recipient:e,recipientType:`DESTINATION_CHAIN`,refundTo:c.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:b});if(!r.depositAddress)throw Error(`NEAR Intents quote returned no deposit address for recipient ${e}`);if(r.deadline&&new Date(r.deadline).getTime()<y)throw Error(`Bridge quote expires before the scheduled execution time. Choose a sooner time.`);return{destinationRecipient:e,amount:n,depositAddress:r.depositAddress,quote:r}})),S=m??await a.buildNearBridgeFeeStructure(v,l,x[0].depositAddress),C=x.map(e=>e.amount),w=x.map(e=>e.depositAddress),T={chainId:f.destinationChainId===v?void 0:f.destinationChainId,tokenAddress:f.destinationTokenAddress,tokenAmounts:x.map(e=>e.quote.amountOut)},E,D;return e.isSolanaLike(v)?{depositTxHash:E,scheduleId:D}=await s.hinkalSolanaDepositAndWithdraw(c,l,C,w,p,S,h,g,_,x.map(e=>e.destinationRecipient),T):{depositTxHash:E,scheduleId:D}=await o.hinkalDepositAndWithdraw(c,l,C,w,p,S,h,g,_,void 0,T),{depositTxHash:E,scheduleId:D,legs:x}};exports.hinkalNearDepositAndBridge=c;
|
|
@@ -37,9 +37,10 @@ var c = async (c, l, u, d, f, p, m, h, g, _) => {
|
|
|
37
37
|
chainId: f.destinationChainId === v ? void 0 : f.destinationChainId,
|
|
38
38
|
tokenAddress: f.destinationTokenAddress,
|
|
39
39
|
tokenAmounts: x.map((e) => e.quote.amountOut)
|
|
40
|
-
}, E;
|
|
41
|
-
return e(v) ? {depositTxHash: E} = await s(c, l, C, w, p, S, h, g, _, x.map((e) => e.destinationRecipient), T) : {depositTxHash: E} = await o(c, l, C, w, p, S, h, g, _, void 0, T), {
|
|
40
|
+
}, E, D;
|
|
41
|
+
return e(v) ? {depositTxHash: E, scheduleId: D} = await s(c, l, C, w, p, S, h, g, _, x.map((e) => e.destinationRecipient), T) : {depositTxHash: E, scheduleId: D} = await o(c, l, C, w, p, S, h, g, _, void 0, T), {
|
|
42
42
|
depositTxHash: E,
|
|
43
|
+
scheduleId: D,
|
|
43
44
|
legs: x
|
|
44
45
|
};
|
|
45
46
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),n=require(`../../functions/private-wallet/emporium.helpers.cjs`),r=require(`./hinkalSolanaProxySend.cjs`);var i=async(i,a,o,s,c,l,u,d)=>{let f=t.validateAndGetChainId(a);if(e.isSolanaLike(f))return r.hinkalSolanaProxySend(i,a[0],o[0],s,c,d);let p=n.createTransaferEmporiumOpsBatch(i,f,a.map(e=>e.erc20TokenAddress),o,c),m=a.map((e,t)=>({token:e,amount:-1n*o[t]}));return await i.actionPrivateWallet(f,[],[],[],p,m,s,l,u,void 0,void 0,void 0,d,void 0)};exports.hinkalProxySend=i;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FeeStructure } from '../../types/hinkal.types';
|
|
2
|
+
import { ERC20Token } from '../../types/token.types';
|
|
3
|
+
import { SubAccount } from '../../types/proxy.types';
|
|
4
|
+
import { AdminTransactionType } from '../../types/admin.types';
|
|
5
|
+
import { IHinkal } from './IHinkal';
|
|
6
|
+
export declare const hinkalProxySend: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amounts: bigint[], subAccount: SubAccount, recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType) => Promise<string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isSolanaLike as e } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { validateAndGetChainId as t } from "../../functions/utils/token-check.utils.mjs";
|
|
3
|
+
import { createTransaferEmporiumOpsBatch as n } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
4
|
+
import { hinkalSolanaProxySend as r } from "./hinkalSolanaProxySend.mjs";
|
|
5
|
+
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProxySend.ts
|
|
6
|
+
var i = async (i, a, o, s, c, l, u, d) => {
|
|
7
|
+
let f = t(a);
|
|
8
|
+
if (e(f)) return r(i, a[0], o[0], s, c, d);
|
|
9
|
+
let p = n(i, f, a.map((e) => e.erc20TokenAddress), o, c), m = a.map((e, t) => ({
|
|
10
|
+
token: e,
|
|
11
|
+
amount: -1n * o[t]
|
|
12
|
+
}));
|
|
13
|
+
return await i.actionPrivateWallet(f, [], [], [], p, m, s, l, u, void 0, void 0, void 0, d, void 0);
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as hinkalProxySend };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../constants/protocol.constants.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../types/external-action.types.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../constants/addresses.constants.cjs`),o=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),s=require(`../../functions/private-wallet/emporium.swap.helpers.cjs`);var
|
|
1
|
+
require(`../../constants/protocol.constants.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../types/external-action.types.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../constants/addresses.constants.cjs`),o=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),s=require(`../../functions/utils/fees.utils.cjs`),c=require(`../../functions/private-wallet/emporium.swap.helpers.cjs`);var l=async(l,u,d,f,p,m,h,g,_,v=!1,y,b,x,S)=>{if(!g)throw Error(`Fee token is required in hinkalProxySwap`);let C=n.validateAndGetChainId(u),w=r.AccountActions.getAddressFromSubAccount(C,h);if(!w)throw Error(`Public account address is not available`);let T=u.map(e=>e.erc20TokenAddress),E=await l.getRandomRelay(C,!0);if(!E)throw Error(e.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let D=await c.createSwapToEmporiumOps(l,C,f,a.SWAP_ROUTER_ADDRESSES[f][C],p,T[0],d[0],d[1],T[1],m,w,E,!0),O=_??await i.getFeeStructure(C,g,T,t.ExternalActionId.Emporium,D.map(e=>o.convertEmporiumOpToCallInfo(e,w,C)),35n),k=u.map((e,t)=>({token:e,amount:d[t]})),A=x&&S!==void 0?await s.calculateModifiedFeeStructure(C,x,S,O):O;return l.actionPrivateWallet(C,[],[],[],D,k,h,g,A,E,v,y,b,void 0)};exports.hinkalProxySwap=l;
|
|
@@ -4,4 +4,4 @@ import { FeeStructure } from '../../types/hinkal.types';
|
|
|
4
4
|
import { IHinkal } from './IHinkal';
|
|
5
5
|
import { SubAccount } from '../../types/proxy.types';
|
|
6
6
|
import { AdminTransactionType } from '../../types/admin.types';
|
|
7
|
-
export declare const hinkalProxySwap: (hinkal: IHinkal, erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, data: string, isTheSameChainSwap: boolean, subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType) => Promise<string>;
|
|
7
|
+
export declare const hinkalProxySwap: (hinkal: IHinkal, erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, data: string, isTheSameChainSwap: boolean, subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, bridgedToken?: ERC20Token, bridgedTokenAmount?: bigint) => Promise<string>;
|
|
@@ -6,19 +6,20 @@ import { AccountActions as r } from "../AccountActions/AccountActions.mjs";
|
|
|
6
6
|
import { getFeeStructure as i } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
7
7
|
import { SWAP_ROUTER_ADDRESSES as a } from "../../constants/addresses.constants.mjs";
|
|
8
8
|
import { convertEmporiumOpToCallInfo as o } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { calculateModifiedFeeStructure as s } from "../../functions/utils/fees.utils.mjs";
|
|
10
|
+
import { createSwapToEmporiumOps as c } from "../../functions/private-wallet/emporium.swap.helpers.mjs";
|
|
10
11
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProxySwap.ts
|
|
11
|
-
var
|
|
12
|
-
if (!
|
|
13
|
-
let
|
|
14
|
-
if (!
|
|
15
|
-
let
|
|
16
|
-
if (!
|
|
17
|
-
let
|
|
12
|
+
var l = async (l, u, d, f, p, m, h, g, _, v = !1, y, b, x, S) => {
|
|
13
|
+
if (!g) throw Error("Fee token is required in hinkalProxySwap");
|
|
14
|
+
let C = n(u), w = r.getAddressFromSubAccount(C, h);
|
|
15
|
+
if (!w) throw Error("Public account address is not available");
|
|
16
|
+
let T = u.map((e) => e.erc20TokenAddress), E = await l.getRandomRelay(C, !0);
|
|
17
|
+
if (!E) throw Error(e.RELAYER_NOT_AVAILABLE);
|
|
18
|
+
let D = await c(l, C, f, a[f][C], p, T[0], d[0], d[1], T[1], m, w, E, !0), O = _ ?? await i(C, g, T, t.Emporium, D.map((e) => o(e, w, C)), 35n), k = u.map((e, t) => ({
|
|
18
19
|
token: e,
|
|
19
|
-
amount:
|
|
20
|
-
}));
|
|
21
|
-
return
|
|
20
|
+
amount: d[t]
|
|
21
|
+
})), A = x && S !== void 0 ? await s(C, x, S, O) : O;
|
|
22
|
+
return l.actionPrivateWallet(C, [], [], [], D, k, h, g, A, E, v, y, b, void 0);
|
|
22
23
|
};
|
|
23
24
|
//#endregion
|
|
24
|
-
export {
|
|
25
|
+
export { l as hinkalProxySwap };
|