@hinkal/common 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/API.cjs +1 -1
- package/API/API.d.ts +6 -1
- package/API/API.mjs +48 -41
- package/API/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +5 -4
- package/API/index.d.ts +1 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +7 -2
- package/API/proxyAccountsCalls.mjs +26 -20
- package/API/temporaryWalletCalls.cjs +1 -0
- package/API/temporaryWalletCalls.d.ts +13 -0
- package/API/temporaryWalletCalls.mjs +20 -0
- package/API/unspent-utxos-calls.cjs +1 -1
- package/API/unspent-utxos-calls.d.ts +1 -1
- package/API/unspent-utxos-calls.mjs +16 -14
- package/README.md +36 -13
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +1 -1
- package/constants/chains.constants.mjs +69 -51
- package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-solana.json.mjs +28 -2
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +39 -40
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +1 -0
- package/constants/mediaUrls.constants.mjs +2 -1
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +6 -1
- package/constants/server.constants.mjs +37 -32
- package/constants/token-data/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +4 -4
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +4 -4
- package/data-structures/AccountActions/AccountActions.cjs +1 -0
- package/data-structures/AccountActions/AccountActions.d.ts +18 -0
- package/data-structures/AccountActions/AccountActions.mjs +78 -0
- package/data-structures/AccountActions/index.d.ts +1 -0
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +68 -71
- package/data-structures/BlockchainEvent/BlockchainEvent.cjs +1 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +14 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.mjs +41 -0
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +14 -8
- package/data-structures/Hinkal/Hinkal.mjs +215 -179
- package/data-structures/Hinkal/IHinkal.d.ts +9 -6
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +47 -48
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -22
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -12
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +63 -63
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +60 -147
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +103 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +214 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +4 -4
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +103 -99
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +44 -41
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +31 -28
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +16 -13
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +34 -34
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +67 -65
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +35 -32
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +59 -56
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +35 -32
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +10 -10
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +25 -25
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +34 -30
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +43 -39
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +47 -43
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +50 -46
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +36 -34
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.d.ts +1 -0
- package/data-structures/IndexedDB/activity-db.mjs +86 -70
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +33 -30
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +9 -6
- package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +1 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +20 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +124 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +1 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +15 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +64 -0
- package/data-structures/PublicBalance/index.d.ts +2 -0
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +77 -78
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +0 -11
- package/data-structures/crypto-keys/keys.mjs +47 -107
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +6 -6
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractEventService.mjs +16 -19
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +3 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +6 -5
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +7 -4
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +35 -34
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +21 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/ClientEventHelper.d.ts +11 -0
- package/data-structures/event-service/helpers/ClientEventHelper.mjs +26 -0
- package/data-structures/event-service/helpers/PollingEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/PollingEventHelper.d.ts +5 -0
- package/data-structures/event-service/helpers/PollingEventHelper.mjs +14 -0
- package/data-structures/event-service/index.d.ts +4 -0
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +3 -2
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +4 -3
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +8 -8
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +3 -10
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +5 -5
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +3 -2
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +1 -1
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +22 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +8 -14
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +68 -67
- package/data-structures/index.d.ts +3 -0
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +5 -2
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +1 -0
- package/data-structures/utxo/Utxo.mjs +18 -4
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.mjs +2 -2
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +22 -22
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.mjs +53 -50
- package/functions/pre-transaction/solana.cjs +1 -1
- package/functions/pre-transaction/solana.mjs +93 -93
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +3 -2
- package/functions/private-wallet/emporium.helpers.mjs +118 -93
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +1 -2
- package/functions/snarkjs/constructEmporiumProof.mjs +89 -89
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +6 -2
- package/functions/utils/bytes32.utils.cjs +1 -1
- package/functions/utils/bytes32.utils.mjs +8 -7
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +1 -1
- package/functions/utils/create-provider.mjs +13 -9
- package/functions/utils/index.d.ts +0 -1
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +6 -7
- package/functions/utils/prepareHinkal.mjs +45 -53
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.mjs +49 -54
- package/functions/utils/socket.utils.cjs +1 -0
- package/functions/utils/socket.utils.d.ts +1 -0
- package/functions/utils/socket.utils.mjs +12 -0
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +1 -0
- package/functions/utils/string.utils.mjs +18 -14
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +1 -1
- package/functions/utils/walletBalances.utils.mjs +4 -4
- package/functions/web3/crypto.cjs +1 -0
- package/functions/web3/crypto.d.ts +1 -0
- package/functions/web3/crypto.mjs +7 -0
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.mjs +14 -14
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.mjs +61 -59
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.mjs +32 -32
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +6 -3
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +17 -17
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +16 -16
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +13 -11
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.mjs +17 -22
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +20 -20
- package/functions/web3/index.d.ts +1 -0
- package/index.cjs +1 -1
- package/index.mjs +913 -890
- package/package.json +3 -2
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.mjs +2 -5
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +11 -4
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +11 -4
- package/types/activities.types.d.ts +2 -0
- package/types/bridging-tx.types.d.ts +17 -0
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +5 -1
- package/types/cache.types.mjs +1 -1
- package/types/ethereum-network.types.d.ts +1 -0
- package/types/events.types.cjs +1 -0
- package/types/events.types.d.ts +9 -0
- package/types/events.types.mjs +5 -0
- package/types/index.d.ts +2 -0
- package/types/proxy.types.d.ts +11 -4
- package/types/sandbox.types.d.ts +2 -0
- package/types/solana.types.d.ts +8 -0
- package/types/token.types.d.ts +5 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/functions/kyc/authentoHelper.cjs +0 -1
- package/functions/kyc/authentoHelper.d.ts +0 -12
- package/functions/kyc/authentoHelper.mjs +0 -30
- package/functions/utils/get-hinkal-approvals.cjs +0 -1
- package/functions/utils/get-hinkal-approvals.d.ts +0 -3
- package/functions/utils/get-hinkal-approvals.mjs +0 -38
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { zeroAddress as d } from "../../constants/protocol.constants.mjs";
|
|
2
|
+
import { transactionErrorCodes as Z } from "../../error-handling/error-codes.constants.mjs";
|
|
3
|
+
import { constructEmporiumProof as $ } from "../../functions/snarkjs/constructEmporiumProof.mjs";
|
|
4
|
+
import { transactCallRelayerBatch as j } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
5
|
+
import { ExternalActionId as k } from "../../types/external-action.types.mjs";
|
|
6
|
+
import { Utxo as K } from "../utxo/Utxo.mjs";
|
|
7
|
+
import "../../types/circom-data.types.mjs";
|
|
8
|
+
import { ContractType as J } from "../../types/ethereum-network.types.mjs";
|
|
9
|
+
import "../../types/transactions.types.mjs";
|
|
10
|
+
import "../../types/activities.types.mjs";
|
|
11
|
+
import { getSignatureDataForTransact as Q } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
12
|
+
import { shouldPatchAccessTokenMerkleTree as X } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
13
|
+
import { getCurrentTimeInSeconds as tt } from "../../functions/utils/time.utils.mjs";
|
|
14
|
+
import { getFeeStructure as et } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
15
|
+
import { hashEthereumAddress as ot } from "../../functions/utils/addresses.mjs";
|
|
16
|
+
import { networkRegistry as rt } from "../../constants/chains.constants.mjs";
|
|
17
|
+
import { SWAP_ROUTER_ADDRESSES as U } from "../../constants/addresses.constants.mjs";
|
|
18
|
+
import "ethers";
|
|
19
|
+
import "idb-keyval";
|
|
20
|
+
import "@solana/web3.js";
|
|
21
|
+
import "../http/HttpClient.mjs";
|
|
22
|
+
import "../../constants/vite.constants.mjs";
|
|
23
|
+
import { getERC20Token as st } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
24
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
25
|
+
import "../../constants/server.constants.mjs";
|
|
26
|
+
import "../../API/getServerURL.mjs";
|
|
27
|
+
import "axios";
|
|
28
|
+
import { caseInsensitiveEqual as L } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
29
|
+
import "@coral-xyz/anchor";
|
|
30
|
+
import "circomlibjs-hinkal-fork";
|
|
31
|
+
import "@solana/spl-token";
|
|
32
|
+
import "ethers-v6h";
|
|
33
|
+
import "tweetnacl";
|
|
34
|
+
import "bs58";
|
|
35
|
+
import "buffer";
|
|
36
|
+
import "../../constants/token-data/index.mjs";
|
|
37
|
+
import "../../constants/contracts.constants.mjs";
|
|
38
|
+
import "../../constants/kyc.constants.mjs";
|
|
39
|
+
import "../../constants/coingecko.constants.mjs";
|
|
40
|
+
import "../../constants/reorg-depths.constants.mjs";
|
|
41
|
+
import "../../constants/token.limits.constants.mjs";
|
|
42
|
+
import "../../constants/presale.constants.mjs";
|
|
43
|
+
import "../../constants/activity.constants.mjs";
|
|
44
|
+
import "../../constants/tasks.constants.mjs";
|
|
45
|
+
import "../../constants/events.constants.mjs";
|
|
46
|
+
import "../../functions/utils/userAgent.mjs";
|
|
47
|
+
import { convertEmporiumOpToCallInfo as it } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
48
|
+
import "../crypto-keys/keys.mjs";
|
|
49
|
+
import "libsodium-wrappers";
|
|
50
|
+
import "multiformats";
|
|
51
|
+
import { validateAndGetChainId as mt } from "../../functions/utils/token-check.utils.mjs";
|
|
52
|
+
import "async-mutex";
|
|
53
|
+
import "process";
|
|
54
|
+
import "../../providers/EthersProviderAdapter.mjs";
|
|
55
|
+
import { hinkalDepositOnChainUtxos as N } from "./hinkalDepositOnChainUtxos.mjs";
|
|
56
|
+
import { createLifiBridgeOps as z } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
57
|
+
import { API as nt } from "../../API/API.mjs";
|
|
58
|
+
const at = async (t, e, i, u, A, a, r) => {
|
|
59
|
+
if (u.length === 0)
|
|
60
|
+
throw new Error("No recipients to bridge");
|
|
61
|
+
const m = i.erc20TokenAddress, { contractData: g } = rt[e], { emporiumAddress: n } = g;
|
|
62
|
+
if (!n)
|
|
63
|
+
throw Error("No Emporium Address");
|
|
64
|
+
const y = U[k.Lifi][e];
|
|
65
|
+
if (!y)
|
|
66
|
+
throw new Error(`LIFI not configured for chain ${e}`);
|
|
67
|
+
const E = await t.getRandomRelay(e);
|
|
68
|
+
if (!E)
|
|
69
|
+
throw Error(Z.RELAYER_NOT_AVAILABLE);
|
|
70
|
+
const h = await t.getEthereumAddressByChain(e), v = tt().toString(), f = t.generateProofRemotely ? 5 : 1, T = [];
|
|
71
|
+
for (let p = 0; p < u.length; p += f) {
|
|
72
|
+
const w = u.slice(p, p + f), o = await Promise.all(
|
|
73
|
+
w.map(async ({ utxo: s, nativeUtxo: c, bridgeAmount: C, quote: x, temporarySubAccount: R }) => {
|
|
74
|
+
await nt.addTemporaryWalletNonce(e, a, R.index);
|
|
75
|
+
const O = x.nativeFee > 0n && !L(m, d), l = [m], S = [-s.amount], D = [!1], P = new K({
|
|
76
|
+
amount: 0n,
|
|
77
|
+
erc20TokenAddress: m,
|
|
78
|
+
shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
|
|
79
|
+
timeStamp: v,
|
|
80
|
+
tokenId: 0
|
|
81
|
+
}), F = [[s, P]], b = [[P]];
|
|
82
|
+
if (O && c) {
|
|
83
|
+
const B = new K({
|
|
84
|
+
amount: 0n,
|
|
85
|
+
erc20TokenAddress: d,
|
|
86
|
+
shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
|
|
87
|
+
timeStamp: v,
|
|
88
|
+
tokenId: 0
|
|
89
|
+
});
|
|
90
|
+
l.push(d), S.push(-c.amount), D.push(!1), F.push([c, B]), b.push([B]);
|
|
91
|
+
}
|
|
92
|
+
const q = z(
|
|
93
|
+
t,
|
|
94
|
+
e,
|
|
95
|
+
R.ethAddress,
|
|
96
|
+
y,
|
|
97
|
+
m,
|
|
98
|
+
s.amount,
|
|
99
|
+
C,
|
|
100
|
+
x
|
|
101
|
+
), { patchAccessTokenMerkleTree: _, kycRequired: H, hasAccessToken: W } = await X(
|
|
102
|
+
t,
|
|
103
|
+
e,
|
|
104
|
+
l,
|
|
105
|
+
S
|
|
106
|
+
), M = await Q(
|
|
107
|
+
e,
|
|
108
|
+
h,
|
|
109
|
+
t.userKeys,
|
|
110
|
+
H,
|
|
111
|
+
W
|
|
112
|
+
), { zkCallData: G, circomData: I, dimData: V, authorizationData: Y } = await $(
|
|
113
|
+
"v1x1",
|
|
114
|
+
t.merkleTreeHinkalByChain[e],
|
|
115
|
+
t.merkleTreeAccessTokenByChain[e],
|
|
116
|
+
l,
|
|
117
|
+
l.map(() => 0),
|
|
118
|
+
F,
|
|
119
|
+
b,
|
|
120
|
+
t.userKeys,
|
|
121
|
+
l.length,
|
|
122
|
+
F[0].length,
|
|
123
|
+
n,
|
|
124
|
+
q,
|
|
125
|
+
t.generateProofRemotely,
|
|
126
|
+
E ?? d,
|
|
127
|
+
e,
|
|
128
|
+
D,
|
|
129
|
+
void 0,
|
|
130
|
+
R.privateKey,
|
|
131
|
+
void 0,
|
|
132
|
+
_,
|
|
133
|
+
void 0,
|
|
134
|
+
A,
|
|
135
|
+
t.getContractWithFetcher(e, J.HinkalHelperContract),
|
|
136
|
+
M,
|
|
137
|
+
void 0,
|
|
138
|
+
!1
|
|
139
|
+
);
|
|
140
|
+
return { zkCallData: G, dimData: V, circomData: I, authorizationData: Y };
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
T.push(...o);
|
|
144
|
+
}
|
|
145
|
+
return j(e, T, a, r);
|
|
146
|
+
}, ue = async (t, e, i, u, A) => {
|
|
147
|
+
const a = e.erc20TokenAddress, r = mt([e]), m = ot(await t.getEthereumAddressByChain(r)), g = U[k.Lifi][r];
|
|
148
|
+
if (!g)
|
|
149
|
+
throw Error("LIFI router not configured");
|
|
150
|
+
let n;
|
|
151
|
+
if (A)
|
|
152
|
+
n = A;
|
|
153
|
+
else {
|
|
154
|
+
const o = i[0], c = z(
|
|
155
|
+
t,
|
|
156
|
+
r,
|
|
157
|
+
o.temporarySubAccount.ethAddress,
|
|
158
|
+
g,
|
|
159
|
+
a,
|
|
160
|
+
o.bridgeAmount,
|
|
161
|
+
o.bridgeAmount,
|
|
162
|
+
o.quote
|
|
163
|
+
).map(
|
|
164
|
+
(C) => it(C, o.temporarySubAccount.ethAddress, r)
|
|
165
|
+
);
|
|
166
|
+
n = await et(r, a, [a], k.Emporium, c);
|
|
167
|
+
}
|
|
168
|
+
const y = {
|
|
169
|
+
feeToken: n.feeToken,
|
|
170
|
+
flatFee: 0n,
|
|
171
|
+
variableRate: 0n
|
|
172
|
+
}, h = i.reduce((o, s) => o + s.quote.nativeFee, 0n) > 0n && !L(a, d), v = i.map((o) => o.bridgeAmount), f = i.map((o) => o.recipientAddress), T = await N(
|
|
173
|
+
t,
|
|
174
|
+
r,
|
|
175
|
+
e,
|
|
176
|
+
v,
|
|
177
|
+
f,
|
|
178
|
+
n,
|
|
179
|
+
m
|
|
180
|
+
);
|
|
181
|
+
let p = [];
|
|
182
|
+
if (h) {
|
|
183
|
+
const o = st(d, r);
|
|
184
|
+
if (!o)
|
|
185
|
+
throw Error("No native token");
|
|
186
|
+
const s = i.map((c) => c.quote.nativeFee);
|
|
187
|
+
p = await N(
|
|
188
|
+
t,
|
|
189
|
+
r,
|
|
190
|
+
o,
|
|
191
|
+
s,
|
|
192
|
+
f,
|
|
193
|
+
y,
|
|
194
|
+
m
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
const w = i.map((o, s) => ({
|
|
198
|
+
...o,
|
|
199
|
+
utxo: T[s].utxo,
|
|
200
|
+
nativeUtxo: h ? p[s]?.utxo : void 0
|
|
201
|
+
}));
|
|
202
|
+
return at(
|
|
203
|
+
t,
|
|
204
|
+
r,
|
|
205
|
+
e,
|
|
206
|
+
w,
|
|
207
|
+
n,
|
|
208
|
+
m,
|
|
209
|
+
u
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
export {
|
|
213
|
+
ue as hinkalDepositAndBridge
|
|
214
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../API/API.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../API/API.cjs"),n=r=>({async getAccessToken(){return a.API.getZkMeAccessToken()},async getUserAccounts(){return[await r.getEthereumAddress()]},async delegateTransaction(e){const s=r.getProviderAdapter(Number(e.chainId)),t={...e,chainId:Number(e.chainId),type:e.type?e.type:void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?e.maxPriorityFeePerGas:void 0,maxFeePerGas:e.maxFeePerGas?e.maxFeePerGas:void 0};return(await s.sendTransaction(t)).hash}});exports.getHinkalZkMeProvider=n;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { API as
|
|
1
|
+
import { API as t } from "../../API/API.mjs";
|
|
2
2
|
const d = (r) => ({
|
|
3
3
|
async getAccessToken() {
|
|
4
|
-
return
|
|
4
|
+
return t.getZkMeAccessToken();
|
|
5
5
|
},
|
|
6
6
|
async getUserAccounts() {
|
|
7
7
|
return [await r.getEthereumAddress()];
|
|
8
8
|
},
|
|
9
9
|
async delegateTransaction(e) {
|
|
10
|
-
const s =
|
|
10
|
+
const s = r.getProviderAdapter(Number(e.chainId)), a = {
|
|
11
11
|
...e,
|
|
12
12
|
chainId: Number(e.chainId),
|
|
13
13
|
type: e.type ? e.type : void 0,
|
|
14
14
|
maxPriorityFeePerGas: e.maxPriorityFeePerGas ? e.maxPriorityFeePerGas : void 0,
|
|
15
15
|
maxFeePerGas: e.maxFeePerGas ? e.maxFeePerGas : void 0
|
|
16
16
|
};
|
|
17
|
-
return (await s.sendTransaction(
|
|
17
|
+
return (await s.sendTransaction(a)).hash;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../../constants/chains.constants.cjs"),S=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");const j=require("../../types/ethereum-network.types.cjs"),G=require("../../types/external-action.types.cjs"),Y=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const J=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");require("../../constants/vite.constants.cjs");const Q=require("../../functions/snarkjs/constructEmporiumProof.cjs"),X=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),Z=require("../../functions/web3/events/getShieldedBalance.cjs"),$=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),h=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),I=require("../../functions/utils/involves-permit2-op.cjs"),ee=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),re=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),te=require("../../functions/pre-transaction/getFeeStructure.cjs"),oe=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),se=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),ie=require("../../functions/pre-transaction/merge-with-fee-structure-emporium.cjs"),ue=require("../../functions/utils/caseInsensitive.utils.cjs"),ae=require("../../functions/utils/time.utils.cjs"),ce=require("./handleAutoDepositBack.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/token-data/index.cjs");const ne=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");const k=require("../AccountActions/AccountActions.cjs");require("buffer");const le=require("../../functions/pre-transaction/recipientUtxoProcessing.cjs"),Ae=require("../../functions/utils/addresses.cjs"),me=async(t,e,x,o,d,n,i,p,R,_,U,F=!1,B,y,l,T=!1)=>{if(l&&!Ae.isValidPrivateAddress(l.recipientInfo))throw Error(S.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const s=x.map(r=>r.erc20TokenAddress),u=k.AccountActions.getAddressFromSubAccount(e,p);if(!u)throw Error("Public account address is not available");const{contractData:O}=V.networkRegistry[e],{emporiumAddress:A}=O;if(!A)throw Error("No Emporium Address Provided");const m=_??await te.getFeeStructure(e,R,s,G.ExternalActionId.Emporium,n.map(r=>re.convertEmporiumOpToCallInfo(r,u??"",e))),W=i.find(r=>ue.caseInsensitiveEqual(r.token.erc20TokenAddress,m.feeToken))?.amount??0n;for(u&&await ie.mergeWithFeeStructureEmporium(t,e,u,n,s,o,m,W);d.length<s.length;)d.push(!1);const a=[...await Z.addPaddingToUtxos(t,e,s,o)],q=[],c=Y.defaultHinkalLogicArgs(o.length,t.userKeys),f=ae.getCurrentTimeInSeconds().toString();for(let r=0;r<s.length;r+=1){const{outputUtxos:z}=X.outputUtxoProcessing(t.userKeys,a[r],o[r],f,void 0,!1);q.push(z);const{useApprovalUtxoData:D}=ee.outputApprovalDataProcessing(t,e,a[r],o[r]);D&&(c.doPreTxApproval=!0,c.useApprovalUtxoData[r]=D,c.interactionAddress=A,c.inHinkalAddress=t.userKeys.getInHinkalAddress(A))}l&&le.recipientUtxoProcessing(l,q,o,f);const E=U??await t.getRandomRelay(e,!T);if(!E)throw Error(S.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:H,kycRequired:K,hasAccessToken:b}=await oe.shouldPatchAccessTokenMerkleTree(t,e,s,o),C=await se.getSignatureDataForTransact(e,await t.getEthereumAddressByChain(e),t.userKeys,K,b),{zkCallData:w,circomData:g,dimData:P,authorizationData:v}=await Q.constructEmporiumProof("v1x1",t.merkleTreeHinkalByChain[e],t.merkleTreeAccessTokenByChain[e],s,s.map(()=>0),a,q,t.userKeys,o.length,a.length>0?a[0].length:0,A,n,t.generateProofRemotely,E,e,d,void 0,k.AccountActions.getPrivateKeyFromSubAccount(e,p),c,H,void 0,m,t.getContractWithFetcher(e,j.ContractType.HinkalHelperContract),C),L=I.uniswapWorkaround(n);if(T)return await $.estimateGasRelayer(e,w,P,g,v);const M=ne.constructAdminData(y,e,i.map(r=>r.token.erc20TokenAddress),i.map(r=>r.amount),await t.getEthereumAddressByChain(e),y===J.AdminTransactionType.PublicSwap?i.map(({token:r})=>r):void 0),N=await h.transactCallRelayer(e,w,P,g,!1,L,v,M);return F&&ce.handleAutoDepositBack(t,e,u,p,m.feeToken,B,i,g),N};exports.hinkalPrivateWallet=me;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IHinkal } from './IHinkal';
|
|
2
2
|
import { FeeStructure } from '../../types/hinkal.types';
|
|
3
|
-
import { PrivateRecipientInfo, TokenChanges } from '../../types/token.types';
|
|
3
|
+
import { ERC20Token, PrivateRecipientInfo, TokenChanges } from '../../types/token.types';
|
|
4
4
|
import { SubAccount } from '../../types/proxy.types';
|
|
5
5
|
import { AdminTransactionType } from '../../types/admin.types';
|
|
6
|
-
export declare const hinkalPrivateWallet: (hinkal: IHinkal, chainId: number,
|
|
6
|
+
export declare const hinkalPrivateWallet: (hinkal: IHinkal, chainId: number, erc20Tokens: ERC20Token[], deltaChanges: bigint[], onChainCreation: boolean[], ops: string[], emporiumTokenChanges: TokenChanges<bigint>[], subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, relayOverride?: string, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, privateRecipientInfo?: PrivateRecipientInfo, onlyGasEstimate?: boolean) => Promise<bigint | import('../../index.ts').RelayerTransaction>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { networkRegistry as
|
|
1
|
+
import { networkRegistry as C } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import { transactionErrorCodes as R } from "../../error-handling/error-codes.constants.mjs";
|
|
3
3
|
import "ethers";
|
|
4
4
|
import "../../types/circom-data.types.mjs";
|
|
@@ -13,141 +13,145 @@ import { constructEmporiumProof as Q } from "../../functions/snarkjs/constructEm
|
|
|
13
13
|
import { outputUtxoProcessing as X } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
14
14
|
import { addPaddingToUtxos as Z } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
15
15
|
import { estimateGasRelayer as $ } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
16
|
-
import { transactCallRelayer as
|
|
17
|
-
import { uniswapWorkaround as
|
|
18
|
-
import { outputApprovalDataProcessing as
|
|
19
|
-
import { convertEmporiumOpToCallInfo as
|
|
20
|
-
import { getFeeStructure as
|
|
21
|
-
import { shouldPatchAccessTokenMerkleTree as
|
|
22
|
-
import { getSignatureDataForTransact as
|
|
23
|
-
import { mergeWithFeeStructureEmporium as
|
|
24
|
-
import { caseInsensitiveEqual as
|
|
25
|
-
import { getCurrentTimeInSeconds as
|
|
26
|
-
import { handleAutoDepositBack as
|
|
27
|
-
import { UserKeys as at } from "../crypto-keys/keys.mjs";
|
|
16
|
+
import { transactCallRelayer as I } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
17
|
+
import { uniswapWorkaround as h } from "../../functions/utils/involves-permit2-op.mjs";
|
|
18
|
+
import { outputApprovalDataProcessing as rr } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
|
|
19
|
+
import { convertEmporiumOpToCallInfo as tr } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
20
|
+
import { getFeeStructure as or } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
21
|
+
import { shouldPatchAccessTokenMerkleTree as er } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
22
|
+
import { getSignatureDataForTransact as sr } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
23
|
+
import { mergeWithFeeStructureEmporium as mr } from "../../functions/pre-transaction/merge-with-fee-structure-emporium.mjs";
|
|
24
|
+
import { caseInsensitiveEqual as ir } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
25
|
+
import { getCurrentTimeInSeconds as ar } from "../../functions/utils/time.utils.mjs";
|
|
26
|
+
import { handleAutoDepositBack as pr } from "./handleAutoDepositBack.mjs";
|
|
28
27
|
import "../../constants/server.constants.mjs";
|
|
29
28
|
import "../../API/getServerURL.mjs";
|
|
30
29
|
import "../http/HttpClient.mjs";
|
|
31
30
|
import "axios";
|
|
32
31
|
import "../../constants/token-data/index.mjs";
|
|
33
|
-
import { constructAdminData as
|
|
32
|
+
import { constructAdminData as cr } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
34
33
|
import "@coral-xyz/anchor";
|
|
35
34
|
import "@solana/web3.js";
|
|
36
35
|
import "circomlibjs-hinkal-fork";
|
|
37
36
|
import "@solana/spl-token";
|
|
38
|
-
import {
|
|
39
|
-
import
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
import { AccountActions as S } from "../AccountActions/AccountActions.mjs";
|
|
38
|
+
import "buffer";
|
|
39
|
+
import { recipientUtxoProcessing as ur } from "../../functions/pre-transaction/recipientUtxoProcessing.mjs";
|
|
40
|
+
import { isValidPrivateAddress as fr } from "../../functions/utils/addresses.mjs";
|
|
41
|
+
const Ir = async (o, r, k, e, A, c, m, l, U, F, B, H = !1, K, w, u, T = !1) => {
|
|
42
|
+
if (u && !fr(u.recipientInfo))
|
|
42
43
|
throw Error(R.RECIPIENT_FORMAT_INCORRECT);
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
44
|
+
const s = k.map((t) => t.erc20TokenAddress), i = S.getAddressFromSubAccount(r, l);
|
|
45
|
+
if (!i)
|
|
46
|
+
throw Error("Public account address is not available");
|
|
47
|
+
const { contractData: L } = C[r], { emporiumAddress: f } = L;
|
|
48
|
+
if (!f)
|
|
45
49
|
throw Error("No Emporium Address Provided");
|
|
46
|
-
const
|
|
47
|
-
|
|
50
|
+
const n = F ?? await or(
|
|
51
|
+
r,
|
|
48
52
|
U,
|
|
49
|
-
|
|
53
|
+
s,
|
|
50
54
|
j.Emporium,
|
|
51
|
-
|
|
52
|
-
),
|
|
53
|
-
(
|
|
55
|
+
c.map((t) => tr(t, i ?? "", r))
|
|
56
|
+
), W = m.find(
|
|
57
|
+
(t) => ir(t.token.erc20TokenAddress, n.feeToken)
|
|
54
58
|
)?.amount ?? 0n;
|
|
55
|
-
for (
|
|
59
|
+
for (i && await mr(
|
|
56
60
|
o,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
p,
|
|
60
|
-
e,
|
|
61
|
-
m,
|
|
61
|
+
r,
|
|
62
|
+
i,
|
|
62
63
|
c,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
s,
|
|
65
|
+
e,
|
|
66
|
+
n,
|
|
67
|
+
W
|
|
68
|
+
); A.length < s.length; )
|
|
69
|
+
A.push(!1);
|
|
70
|
+
const a = [...await Z(o, r, s, e)], d = [], p = G(e.length, o.userKeys), y = ar().toString();
|
|
71
|
+
for (let t = 0; t < s.length; t += 1) {
|
|
72
|
+
const { outputUtxos: V } = X(
|
|
69
73
|
o.userKeys,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
a[t],
|
|
75
|
+
e[t],
|
|
76
|
+
y,
|
|
73
77
|
void 0,
|
|
74
78
|
!1
|
|
75
79
|
);
|
|
76
|
-
|
|
77
|
-
const { useApprovalUtxoData: D } =
|
|
78
|
-
D && (
|
|
80
|
+
d.push(V);
|
|
81
|
+
const { useApprovalUtxoData: D } = rr(o, r, a[t], e[t]);
|
|
82
|
+
D && (p.doPreTxApproval = !0, p.useApprovalUtxoData[t] = D, p.interactionAddress = f, p.inHinkalAddress = o.userKeys.getInHinkalAddress(f));
|
|
79
83
|
}
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
84
|
+
u && ur(u, d, e, y);
|
|
85
|
+
const E = B ?? await o.getRandomRelay(r, !T);
|
|
86
|
+
if (!E)
|
|
83
87
|
throw Error(R.RELAYER_NOT_AVAILABLE);
|
|
84
|
-
const { patchAccessTokenMerkleTree:
|
|
88
|
+
const { patchAccessTokenMerkleTree: N, kycRequired: O, hasAccessToken: _ } = await er(
|
|
85
89
|
o,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
),
|
|
90
|
-
|
|
91
|
-
await o.
|
|
90
|
+
r,
|
|
91
|
+
s,
|
|
92
|
+
e
|
|
93
|
+
), b = await sr(
|
|
94
|
+
r,
|
|
95
|
+
await o.getEthereumAddressByChain(r),
|
|
92
96
|
o.userKeys,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
), { zkCallData:
|
|
97
|
+
O,
|
|
98
|
+
_
|
|
99
|
+
), { zkCallData: P, circomData: g, dimData: v, authorizationData: x } = await Q(
|
|
96
100
|
"v1x1",
|
|
97
|
-
o.merkleTreeHinkalByChain[
|
|
98
|
-
o.merkleTreeAccessTokenByChain[
|
|
99
|
-
e,
|
|
100
|
-
e.map(() => 0),
|
|
101
|
+
o.merkleTreeHinkalByChain[r],
|
|
102
|
+
o.merkleTreeAccessTokenByChain[r],
|
|
101
103
|
s,
|
|
102
|
-
|
|
104
|
+
s.map(() => 0),
|
|
105
|
+
a,
|
|
106
|
+
d,
|
|
103
107
|
o.userKeys,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
e.length,
|
|
109
|
+
a.length > 0 ? a[0].length : 0,
|
|
110
|
+
f,
|
|
111
|
+
c,
|
|
108
112
|
o.generateProofRemotely,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
l,
|
|
112
|
-
void 0,
|
|
113
|
+
E,
|
|
114
|
+
r,
|
|
113
115
|
A,
|
|
114
|
-
a,
|
|
115
|
-
W,
|
|
116
116
|
void 0,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
S.getPrivateKeyFromSubAccount(r, l),
|
|
118
|
+
p,
|
|
119
|
+
N,
|
|
120
|
+
void 0,
|
|
121
|
+
n,
|
|
122
|
+
o.getContractWithFetcher(r, Y.HinkalHelperContract),
|
|
123
|
+
b
|
|
124
|
+
), M = h(c);
|
|
121
125
|
if (T)
|
|
122
|
-
return await $(
|
|
123
|
-
const
|
|
124
|
-
y,
|
|
125
|
-
t,
|
|
126
|
-
i.map((r) => r.token.erc20TokenAddress),
|
|
127
|
-
i.map((r) => r.amount),
|
|
128
|
-
await o.getEthereumAddress(),
|
|
129
|
-
y === J.PublicSwap ? i.map(({ token: r }) => r) : void 0
|
|
130
|
-
), q = await b(
|
|
131
|
-
t,
|
|
132
|
-
d,
|
|
133
|
-
v,
|
|
126
|
+
return await $(r, P, v, g, x);
|
|
127
|
+
const q = cr(
|
|
134
128
|
w,
|
|
129
|
+
r,
|
|
130
|
+
m.map((t) => t.token.erc20TokenAddress),
|
|
131
|
+
m.map((t) => t.amount),
|
|
132
|
+
await o.getEthereumAddressByChain(r),
|
|
133
|
+
w === J.PublicSwap ? m.map(({ token: t }) => t) : void 0
|
|
134
|
+
), z = await I(
|
|
135
|
+
r,
|
|
136
|
+
P,
|
|
137
|
+
v,
|
|
138
|
+
g,
|
|
135
139
|
!1,
|
|
136
|
-
|
|
140
|
+
M,
|
|
137
141
|
x,
|
|
138
|
-
|
|
142
|
+
q
|
|
139
143
|
);
|
|
140
|
-
return
|
|
144
|
+
return H && pr(
|
|
141
145
|
o,
|
|
142
|
-
|
|
143
|
-
u,
|
|
144
|
-
A,
|
|
145
|
-
c.feeToken,
|
|
146
|
-
F,
|
|
146
|
+
r,
|
|
147
147
|
i,
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
l,
|
|
149
|
+
n.feeToken,
|
|
150
|
+
K,
|
|
151
|
+
m,
|
|
152
|
+
g
|
|
153
|
+
), z;
|
|
150
154
|
};
|
|
151
155
|
export {
|
|
152
|
-
|
|
156
|
+
Ir as hinkalPrivateWallet
|
|
153
157
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/addresses.constants.cjs"),y=require("../../functions/pre-transaction/getFeeStructure.cjs"),P=require("../../functions/private-wallet/emporium.swap.helpers.cjs"),g=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),v=require("../../types/external-action.types.cjs"),C=require("../../error-handling/error-codes.constants.cjs"),I=require("../../constants/protocol.constants.cjs"),O=require("../../functions/utils/token-check.utils.cjs"),L=require("../AccountActions/AccountActions.cjs"),T=async(t,o,s,u,A,m,p,n,E,S=!1,_,w,d=!1)=>{if(!n)throw new Error("Fee token is required in hinkalProxySwap");const r=O.validateAndGetChainId(o),a=L.AccountActions.getAddressFromSubAccount(r,p);if(!a)throw Error("Public account address is not available");const c=o.map(e=>e.erc20TokenAddress),i=await t.getRandomRelay(r,!d);if(!i)throw Error(C.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const l=await P.createSwapToEmporiumOps(t,r,u,f.SWAP_ROUTER_ADDRESSES[u][r],A,c[0],s[0],s[1],c[1],m,a,i,!0),q=E??await y.getFeeStructure(r,n,c,v.ExternalActionId.Emporium,l.map(e=>g.convertEmporiumOpToCallInfo(e,a,r)),I.HINKAL_SWAP_VARIABLE_RATE),h=o.map((e,R)=>({token:e,amount:s[R]}));return t.actionPrivateWallet(r,[],[],[],l,h,p,n,q,i,S,_,w,void 0,d)};exports.hinkalProxySwap=T;
|
|
@@ -1,61 +1,64 @@
|
|
|
1
|
-
import { SWAP_ROUTER_ADDRESSES as
|
|
2
|
-
import { getFeeStructure as
|
|
3
|
-
import { createSwapToEmporiumOps as
|
|
4
|
-
import { convertEmporiumOpToCallInfo as
|
|
5
|
-
import { ExternalActionId as
|
|
6
|
-
import { transactionErrorCodes as
|
|
7
|
-
import { HINKAL_SWAP_VARIABLE_RATE as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
1
|
+
import { SWAP_ROUTER_ADDRESSES as I } from "../../constants/addresses.constants.mjs";
|
|
2
|
+
import { getFeeStructure as P } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
3
|
+
import { createSwapToEmporiumOps as v } from "../../functions/private-wallet/emporium.swap.helpers.mjs";
|
|
4
|
+
import { convertEmporiumOpToCallInfo as L } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
5
|
+
import { ExternalActionId as O } from "../../types/external-action.types.mjs";
|
|
6
|
+
import { transactionErrorCodes as g } from "../../error-handling/error-codes.constants.mjs";
|
|
7
|
+
import { HINKAL_SWAP_VARIABLE_RATE as y } from "../../constants/protocol.constants.mjs";
|
|
8
|
+
import { validateAndGetChainId as C } from "../../functions/utils/token-check.utils.mjs";
|
|
9
|
+
import { AccountActions as x } from "../AccountActions/AccountActions.mjs";
|
|
10
|
+
const H = async (t, a, i, p, f, E, c, e, u, l = !1, w, S, d = !1) => {
|
|
11
|
+
if (!e)
|
|
12
12
|
throw new Error("Fee token is required in hinkalProxySwap");
|
|
13
|
-
const r =
|
|
14
|
-
if (!
|
|
15
|
-
throw Error(
|
|
16
|
-
const
|
|
13
|
+
const r = C(a), m = x.getAddressFromSubAccount(r, c);
|
|
14
|
+
if (!m)
|
|
15
|
+
throw Error("Public account address is not available");
|
|
16
|
+
const n = a.map((o) => o.erc20TokenAddress), s = await t.getRandomRelay(r, !d);
|
|
17
|
+
if (!s)
|
|
18
|
+
throw Error(g.RELAYER_NOT_AVAILABLE);
|
|
19
|
+
const A = await v(
|
|
17
20
|
t,
|
|
18
21
|
r,
|
|
19
|
-
s,
|
|
20
|
-
v[s][r],
|
|
21
|
-
E,
|
|
22
|
-
m[0],
|
|
23
|
-
a[0],
|
|
24
|
-
a[1],
|
|
25
|
-
m[1],
|
|
26
|
-
A,
|
|
27
|
-
d,
|
|
28
22
|
p,
|
|
23
|
+
I[p][r],
|
|
24
|
+
f,
|
|
25
|
+
n[0],
|
|
26
|
+
i[0],
|
|
27
|
+
i[1],
|
|
28
|
+
n[1],
|
|
29
|
+
E,
|
|
30
|
+
m,
|
|
31
|
+
s,
|
|
29
32
|
!0
|
|
30
|
-
),
|
|
33
|
+
), R = u ?? await P(
|
|
31
34
|
r,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
),
|
|
35
|
+
e,
|
|
36
|
+
n,
|
|
37
|
+
O.Emporium,
|
|
38
|
+
A.map((o) => L(o, m, r)),
|
|
39
|
+
y
|
|
40
|
+
), _ = a.map((o, h) => ({
|
|
38
41
|
token: o,
|
|
39
|
-
amount:
|
|
42
|
+
amount: i[h]
|
|
40
43
|
}));
|
|
41
44
|
return t.actionPrivateWallet(
|
|
42
45
|
r,
|
|
43
46
|
[],
|
|
44
47
|
[],
|
|
45
48
|
[],
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
u,
|
|
51
|
-
p,
|
|
52
|
-
w,
|
|
49
|
+
A,
|
|
50
|
+
_,
|
|
51
|
+
c,
|
|
52
|
+
e,
|
|
53
53
|
R,
|
|
54
|
+
s,
|
|
54
55
|
l,
|
|
56
|
+
w,
|
|
57
|
+
S,
|
|
55
58
|
void 0,
|
|
56
|
-
|
|
59
|
+
d
|
|
57
60
|
);
|
|
58
61
|
};
|
|
59
62
|
export {
|
|
60
|
-
|
|
63
|
+
H as hinkalProxySwap
|
|
61
64
|
};
|