@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
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import { zeroAddress as P } from "../../constants/protocol.constants.mjs";
|
|
2
|
-
import { outputUtxoProcessing as
|
|
3
|
-
import { constructZkProof as
|
|
4
|
-
import { addPaddingToUtxos as
|
|
5
|
-
import { transactCallDirect as
|
|
2
|
+
import { outputUtxoProcessing as R } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
3
|
+
import { constructZkProof as C } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
4
|
+
import { addPaddingToUtxos as H } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
5
|
+
import { transactCallDirect as K } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
6
6
|
import { Utxo as D } from "../utxo/Utxo.mjs";
|
|
7
|
-
import { transactionErrorCodes as
|
|
7
|
+
import { transactionErrorCodes as z } from "../../error-handling/error-codes.constants.mjs";
|
|
8
8
|
import "../../types/circom-data.types.mjs";
|
|
9
|
-
import { ContractType as
|
|
9
|
+
import { ContractType as M } from "../../types/ethereum-network.types.mjs";
|
|
10
10
|
import "../../types/transactions.types.mjs";
|
|
11
|
-
import { AdminTransactionType as
|
|
11
|
+
import { AdminTransactionType as B } from "../../types/admin.types.mjs";
|
|
12
12
|
import "../../types/activities.types.mjs";
|
|
13
13
|
import { getSignatureDataForTransact as F } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
14
14
|
import { isValidPrivateAddress as N } from "../../functions/utils/addresses.mjs";
|
|
15
15
|
import { shouldPatchAccessTokenMerkleTree as O } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
16
16
|
import { getCurrentTimeInSeconds as $ } from "../../functions/utils/time.utils.mjs";
|
|
17
|
-
import { emitTxPublicData as
|
|
18
|
-
import { constructAdminData as
|
|
19
|
-
import { validateAndGetChainId as
|
|
20
|
-
const
|
|
21
|
-
const { patchAccessTokenMerkleTree:
|
|
17
|
+
import { emitTxPublicData as E } from "../../API/admin-calls.mjs";
|
|
18
|
+
import { constructAdminData as h } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
19
|
+
import { validateAndGetChainId as S } from "../../functions/utils/token-check.utils.mjs";
|
|
20
|
+
const U = async (t, a, r, o) => {
|
|
21
|
+
const { patchAccessTokenMerkleTree: e, kycRequired: s, hasAccessToken: A } = await O(
|
|
22
22
|
t,
|
|
23
23
|
a,
|
|
24
|
-
|
|
24
|
+
r,
|
|
25
25
|
o
|
|
26
|
-
),
|
|
26
|
+
), c = void 0, y = await t.getEthereumAddressByChain(a), d = await F(
|
|
27
27
|
a,
|
|
28
|
-
|
|
28
|
+
y,
|
|
29
29
|
t.userKeys,
|
|
30
30
|
s,
|
|
31
31
|
A
|
|
32
|
-
),
|
|
32
|
+
), n = {
|
|
33
33
|
externalActionId: 0n,
|
|
34
|
-
externalAddress: await t.
|
|
34
|
+
externalAddress: await t.getEthereumAddressByChain(a),
|
|
35
35
|
externalActionMetadata: "0x00"
|
|
36
36
|
};
|
|
37
37
|
return {
|
|
38
38
|
signatureData: d,
|
|
39
|
-
externalActionData:
|
|
40
|
-
contractTransaction:
|
|
41
|
-
contractToApprove:
|
|
42
|
-
patchAccessTokenMerkleTree:
|
|
39
|
+
externalActionData: n,
|
|
40
|
+
contractTransaction: c,
|
|
41
|
+
contractToApprove: c,
|
|
42
|
+
patchAccessTokenMerkleTree: e
|
|
43
43
|
};
|
|
44
|
-
}, st = async (t, a,
|
|
45
|
-
const o =
|
|
46
|
-
for (let i = 0; i <
|
|
47
|
-
const { outputUtxos: w } =
|
|
44
|
+
}, st = async (t, a, r) => {
|
|
45
|
+
const o = S(a), e = a.map((i) => i.erc20TokenAddress), { externalActionData: s, contractTransaction: A, contractToApprove: c, patchAccessTokenMerkleTree: y, signatureData: d } = await U(t, o, e, r), n = [...await H(t, o, e, r)], l = `swapperM${r.length.toString()}x${n[0].length}x1`, m = [], x = $().toString();
|
|
46
|
+
for (let i = 0; i < e.length; i += 1) {
|
|
47
|
+
const { outputUtxos: w } = R(t.userKeys, n[i], r[i], x);
|
|
48
48
|
m.push(w);
|
|
49
49
|
}
|
|
50
|
-
const { zkCallData:
|
|
50
|
+
const { zkCallData: u, circomData: T, dimData: v } = await C(
|
|
51
51
|
"v1x1",
|
|
52
52
|
t.merkleTreeHinkalByChain[o],
|
|
53
53
|
t.merkleTreeAccessTokenByChain[o],
|
|
54
|
-
|
|
54
|
+
n,
|
|
55
55
|
m,
|
|
56
56
|
t.userKeys,
|
|
57
|
-
|
|
57
|
+
l,
|
|
58
58
|
s.externalActionId,
|
|
59
59
|
s.externalAddress,
|
|
60
60
|
s.externalActionMetadata,
|
|
@@ -64,60 +64,60 @@ const R = async (t, a, e, o) => {
|
|
|
64
64
|
void 0,
|
|
65
65
|
void 0,
|
|
66
66
|
void 0,
|
|
67
|
-
|
|
67
|
+
y,
|
|
68
68
|
void 0,
|
|
69
69
|
void 0,
|
|
70
70
|
void 0,
|
|
71
|
-
t.getContractWithFetcher(o,
|
|
71
|
+
t.getContractWithFetcher(o, M.HinkalHelperContract),
|
|
72
72
|
d
|
|
73
|
-
), f = await
|
|
73
|
+
), f = await K(
|
|
74
74
|
t,
|
|
75
75
|
o,
|
|
76
|
-
|
|
76
|
+
r,
|
|
77
77
|
// for volotile tokens: amountChanges != amountOfTokenToApprove
|
|
78
78
|
a,
|
|
79
|
-
|
|
79
|
+
u,
|
|
80
80
|
T,
|
|
81
81
|
v,
|
|
82
|
-
|
|
82
|
+
c,
|
|
83
83
|
A
|
|
84
|
-
), g =
|
|
85
|
-
|
|
84
|
+
), g = h(
|
|
85
|
+
B.Onboarding,
|
|
86
86
|
o,
|
|
87
|
-
r,
|
|
88
87
|
e,
|
|
89
|
-
|
|
88
|
+
r,
|
|
89
|
+
await t.getEthereumAddressByChain(o)
|
|
90
90
|
);
|
|
91
|
-
return
|
|
92
|
-
}, it = async (t, a,
|
|
93
|
-
const
|
|
91
|
+
return E(g), f;
|
|
92
|
+
}, it = async (t, a, r, o) => {
|
|
93
|
+
const e = S(a), s = a.map((p) => p.erc20TokenAddress), [A, c, y] = o.split(",");
|
|
94
94
|
if (!N(o))
|
|
95
|
-
throw Error(
|
|
95
|
+
throw Error(z.RECIPIENT_FORMAT_INCORRECT);
|
|
96
96
|
const d = s.map((p) => [
|
|
97
97
|
new D({ amount: 0n, erc20TokenAddress: p, shieldedPrivateKey: t.userKeys.getShieldedPrivateKey() }),
|
|
98
98
|
new D({ amount: 0n, erc20TokenAddress: p, shieldedPrivateKey: t.userKeys.getShieldedPrivateKey() })
|
|
99
|
-
]),
|
|
99
|
+
]), n = `swapperM${r.length.toString()}x${d[0].length}x1`, l = s.map((p, I) => [
|
|
100
100
|
new D({
|
|
101
|
-
amount:
|
|
101
|
+
amount: r[I],
|
|
102
102
|
erc20TokenAddress: p,
|
|
103
103
|
randomization: BigInt(A),
|
|
104
|
-
stealthAddress:
|
|
105
|
-
encryptionKey:
|
|
104
|
+
stealthAddress: c,
|
|
105
|
+
encryptionKey: y
|
|
106
106
|
})
|
|
107
|
-
]), { externalActionData: m, contractTransaction:
|
|
107
|
+
]), { externalActionData: m, contractTransaction: x, contractToApprove: u, patchAccessTokenMerkleTree: T } = await U(t, e, s, r), { zkCallData: v, circomData: f, dimData: g } = await C(
|
|
108
108
|
"v1x1",
|
|
109
|
-
t.merkleTreeHinkalByChain[
|
|
110
|
-
t.merkleTreeAccessTokenByChain[
|
|
109
|
+
t.merkleTreeHinkalByChain[e],
|
|
110
|
+
t.merkleTreeAccessTokenByChain[e],
|
|
111
111
|
d,
|
|
112
|
-
|
|
112
|
+
l,
|
|
113
113
|
t.userKeys,
|
|
114
|
-
|
|
114
|
+
n,
|
|
115
115
|
m.externalActionId,
|
|
116
116
|
m.externalAddress,
|
|
117
117
|
m.externalActionMetadata,
|
|
118
118
|
t.generateProofRemotely,
|
|
119
119
|
P,
|
|
120
|
-
|
|
120
|
+
e,
|
|
121
121
|
void 0,
|
|
122
122
|
void 0,
|
|
123
123
|
void 0,
|
|
@@ -125,25 +125,25 @@ const R = async (t, a, e, o) => {
|
|
|
125
125
|
void 0,
|
|
126
126
|
void 0,
|
|
127
127
|
void 0,
|
|
128
|
-
t.getContractWithFetcher(
|
|
129
|
-
), i = await
|
|
128
|
+
t.getContractWithFetcher(e, M.HinkalHelperContract)
|
|
129
|
+
), i = await K(
|
|
130
130
|
t,
|
|
131
|
-
r,
|
|
132
131
|
e,
|
|
132
|
+
r,
|
|
133
133
|
a,
|
|
134
134
|
v,
|
|
135
135
|
f,
|
|
136
136
|
g,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
), w =
|
|
140
|
-
|
|
141
|
-
r,
|
|
142
|
-
s,
|
|
137
|
+
u,
|
|
138
|
+
x
|
|
139
|
+
), w = h(
|
|
140
|
+
B.PaymentLink,
|
|
143
141
|
e,
|
|
144
|
-
|
|
142
|
+
s,
|
|
143
|
+
r,
|
|
144
|
+
await t.getEthereumAddressByChain(e)
|
|
145
145
|
);
|
|
146
|
-
return
|
|
146
|
+
return E(w), i;
|
|
147
147
|
};
|
|
148
148
|
export {
|
|
149
149
|
st as hinkalDeposit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("../../constants/protocol.constants.cjs"),U=require("../../error-handling/error-codes.constants.cjs"),b=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),B=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),K=require("../../types/external-action.types.cjs"),O=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const F=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");const z=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const H=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),L=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),N=require("../../functions/utils/time.utils.cjs"),W=require("../../functions/pre-transaction/getFeeStructure.cjs"),G=require("../../functions/utils/addresses.cjs"),Z=require("./hinkalDepositOnChainUtxos.cjs"),j=require("../../functions/pre-transaction/constructAdminData.cjs"),V=require("../../functions/utils/token-check.utils.cjs"),Y=async(e,t,i,s,d,u,o)=>{if(s.length===0)throw new Error("userDepositedUtxos must not be empty");const r=i.erc20TokenAddress,a=await e.getRandomRelay(t);if(!a)throw Error(U.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const n=await e.getEthereumAddressByChain(t),l=N.getCurrentTimeInSeconds().toString(),w=e.generateProofRemotely?5:1,m=[];for(let c=0;c<s.length;c+=w){const p=s.slice(c,c+w),T=await Promise.all(p.map(async({recipientAddress:q,utxo:h})=>{const x=[-h.amount],y=new O.Utxo({amount:0n,erc20TokenAddress:r,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:l,tokenId:0}),g=[[h,y]],C=[[y]],k=`swapperM1x${g[0].length}x1`,A={externalActionId:0n,externalAddress:q,externalActionMetadata:"0x00"},{patchAccessTokenMerkleTree:D,kycRequired:S,hasAccessToken:E}=await L.shouldPatchAccessTokenMerkleTree(e,t,[r],x),v=await H.getSignatureDataForTransact(t,n,e.userKeys,S,E),P=j.constructAdminData(z.AdminTransactionType.WithdrawOnChainUtxos,t,[r],[-h.amount],n),{zkCallData:R,circomData:f,dimData:_}=await b.constructZkProof("v1x1",e.merkleTreeHinkalByChain[t],e.merkleTreeAccessTokenByChain[t],g,C,e.userKeys,k,A.externalActionId,A.externalAddress,A.externalActionMetadata,e.generateProofRemotely,a??M.zeroAddress,t,void 0,void 0,void 0,D,void 0,void 0,d,e.getContractWithFetcher(t,F.ContractType.HinkalHelperContract),v,void 0,!1);return{zkCallData:R,dimData:_,circomData:f,adminData:P}}));m.push(...T)}return B.transactCallRelayerBatch(t,m,u,o)},$=async(e,t,i,s,d,u)=>{const o=t.erc20TokenAddress,r=V.validateAndGetChainId([t]),a=G.hashEthereumAddress(await e.getEthereumAddressByChain(r)),n=u??await W.getFeeStructure(r,o,[o],K.ExternalActionId.Transact),l=await Z.hinkalDepositOnChainUtxos(e,r,t,i,s,n,a);return Y(e,r,t,l,n,a,d)};exports.hinkalDepositAndWithdraw=$;
|
|
@@ -1,158 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { transactCallDirect as j } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
8
|
-
import { transactCallRelayerBatch as J } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
9
|
-
import { ExternalActionId as z } from "../../types/external-action.types.mjs";
|
|
10
|
-
import { Utxo as Q } from "../utxo/Utxo.mjs";
|
|
1
|
+
import { zeroAddress as M } from "../../constants/protocol.constants.mjs";
|
|
2
|
+
import { transactionErrorCodes as U } from "../../error-handling/error-codes.constants.mjs";
|
|
3
|
+
import { constructZkProof as b } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
4
|
+
import { transactCallRelayerBatch as z } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
5
|
+
import { ExternalActionId as H } from "../../types/external-action.types.mjs";
|
|
6
|
+
import { Utxo as O } from "../utxo/Utxo.mjs";
|
|
11
7
|
import "../../types/circom-data.types.mjs";
|
|
12
|
-
import { ContractType as
|
|
8
|
+
import { ContractType as F } from "../../types/ethereum-network.types.mjs";
|
|
13
9
|
import "../../types/transactions.types.mjs";
|
|
14
|
-
import { AdminTransactionType as
|
|
10
|
+
import { AdminTransactionType as L } from "../../types/admin.types.mjs";
|
|
15
11
|
import "../../types/activities.types.mjs";
|
|
16
12
|
import { getSignatureDataForTransact as q } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
17
|
-
import { shouldPatchAccessTokenMerkleTree as
|
|
18
|
-
import { getCurrentTimeInSeconds as
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import { validateAndGetChainId as nt } from "../../functions/utils/token-check.utils.mjs";
|
|
27
|
-
const it = async (t, e, m, i, A, l, d) => {
|
|
28
|
-
const r = m.erc20TokenAddress, a = await t.getEthereumAddress(), s = i.map((o) => o + ot(o, l)), c = [r], p = [0n], C = [!0], { patchAccessTokenMerkleTree: u, kycRequired: R, hasAccessToken: P } = await L(
|
|
29
|
-
t,
|
|
30
|
-
e,
|
|
31
|
-
c,
|
|
32
|
-
p
|
|
33
|
-
), S = await q(
|
|
34
|
-
e,
|
|
35
|
-
a,
|
|
36
|
-
t.userKeys,
|
|
37
|
-
R,
|
|
38
|
-
P
|
|
39
|
-
), n = [...await Y(t, e, c, p)], g = [];
|
|
40
|
-
for (let o = 0; o < n.length; o += 1) {
|
|
41
|
-
const { outputUtxos: y } = X(t.userKeys, n[o], p[o]);
|
|
42
|
-
g.push(y);
|
|
43
|
-
}
|
|
44
|
-
const w = s.reduce((o, y) => o + y, 0n), h = G.utils.defaultAbiCoder.encode(["uint256[]"], [s]), T = t.getContractWithSigner(e, E.HinkalWrapper), D = t.getContractWithSigner(e, E.DepositOnChainUtxos), {
|
|
45
|
-
zkCallData: x,
|
|
46
|
-
circomData: k,
|
|
47
|
-
dimData: O
|
|
48
|
-
} = await F(
|
|
49
|
-
"v1x1",
|
|
50
|
-
t.merkleTreeHinkalByChain[e],
|
|
51
|
-
t.merkleTreeAccessTokenByChain[e],
|
|
52
|
-
n,
|
|
53
|
-
g,
|
|
54
|
-
t.userKeys,
|
|
55
|
-
`swapperM1x${n[0].length}x1`,
|
|
56
|
-
z.DepositOnChainUtxos,
|
|
57
|
-
D.address,
|
|
58
|
-
h,
|
|
59
|
-
t.generateProofRemotely,
|
|
60
|
-
W,
|
|
61
|
-
e,
|
|
62
|
-
C,
|
|
63
|
-
void 0,
|
|
64
|
-
void 0,
|
|
65
|
-
u,
|
|
66
|
-
void 0,
|
|
67
|
-
void 0,
|
|
68
|
-
void 0,
|
|
69
|
-
t.getContractWithFetcher(e, E.HinkalHelperContract),
|
|
70
|
-
S,
|
|
71
|
-
T.address,
|
|
72
|
-
!1
|
|
73
|
-
), K = await (await j(
|
|
74
|
-
t,
|
|
75
|
-
e,
|
|
76
|
-
w,
|
|
77
|
-
m,
|
|
78
|
-
x,
|
|
79
|
-
k,
|
|
80
|
-
O,
|
|
81
|
-
D,
|
|
82
|
-
T
|
|
83
|
-
)).wait(), U = tt(K, t, e, r), v = [], f = [...U];
|
|
84
|
-
A.forEach((o, y) => {
|
|
85
|
-
const B = s[y], H = f.find((_) => _.amount === B);
|
|
86
|
-
if (!H)
|
|
87
|
-
throw new Error(`Could not find newly created UTXO with amount ${B} for recipient ${o}.`);
|
|
88
|
-
v.push({
|
|
89
|
-
recipientAddress: o,
|
|
90
|
-
utxo: H
|
|
91
|
-
});
|
|
92
|
-
const Z = f.indexOf(H);
|
|
93
|
-
f.splice(Z, 1);
|
|
94
|
-
}), await rt({
|
|
95
|
-
hashedEthereumAddress: d,
|
|
96
|
-
chainId: e,
|
|
97
|
-
utxos: U
|
|
98
|
-
});
|
|
99
|
-
const b = N(
|
|
100
|
-
$.DepositOnChainUtxos,
|
|
101
|
-
e,
|
|
102
|
-
c,
|
|
103
|
-
[w],
|
|
104
|
-
a
|
|
105
|
-
);
|
|
106
|
-
return at(b), v;
|
|
107
|
-
}, ct = async (t, e, m, i, A, l, d) => {
|
|
108
|
-
if (i.length === 0)
|
|
13
|
+
import { shouldPatchAccessTokenMerkleTree as N } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
14
|
+
import { getCurrentTimeInSeconds as W } from "../../functions/utils/time.utils.mjs";
|
|
15
|
+
import { getFeeStructure as _ } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
16
|
+
import { hashEthereumAddress as G } from "../../functions/utils/addresses.mjs";
|
|
17
|
+
import { hinkalDepositOnChainUtxos as V } from "./hinkalDepositOnChainUtxos.mjs";
|
|
18
|
+
import { constructAdminData as Y } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
19
|
+
import { validateAndGetChainId as Z } from "../../functions/utils/token-check.utils.mjs";
|
|
20
|
+
const $ = async (t, e, c, o, m, d, n) => {
|
|
21
|
+
if (o.length === 0)
|
|
109
22
|
throw new Error("userDepositedUtxos must not be empty");
|
|
110
|
-
const r =
|
|
23
|
+
const r = c.erc20TokenAddress, a = await t.getRandomRelay(e);
|
|
111
24
|
if (!a)
|
|
112
|
-
throw Error(
|
|
113
|
-
const s = await t.
|
|
114
|
-
for (let
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
const g = [-
|
|
25
|
+
throw Error(U.RELAYER_NOT_AVAILABLE);
|
|
26
|
+
const s = await t.getEthereumAddressByChain(e), p = W().toString(), w = t.generateProofRemotely ? 5 : 1, h = [];
|
|
27
|
+
for (let i = 0; i < o.length; i += w) {
|
|
28
|
+
const y = o.slice(i, i + w), x = await Promise.all(
|
|
29
|
+
y.map(async ({ recipientAddress: T, utxo: A }) => {
|
|
30
|
+
const g = [-A.amount], l = new O({
|
|
118
31
|
amount: 0n,
|
|
119
32
|
erc20TokenAddress: r,
|
|
120
33
|
shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
|
|
121
|
-
timeStamp:
|
|
34
|
+
timeStamp: p,
|
|
122
35
|
tokenId: 0
|
|
123
|
-
}),
|
|
36
|
+
}), f = [[A, l]], C = [[l]], E = `swapperM1x${f[0].length}x1`, u = {
|
|
124
37
|
externalActionId: 0n,
|
|
125
|
-
externalAddress:
|
|
38
|
+
externalAddress: T,
|
|
126
39
|
externalActionMetadata: "0x00"
|
|
127
40
|
}, {
|
|
128
41
|
patchAccessTokenMerkleTree: k,
|
|
129
|
-
kycRequired:
|
|
130
|
-
hasAccessToken:
|
|
131
|
-
} = await
|
|
42
|
+
kycRequired: v,
|
|
43
|
+
hasAccessToken: D
|
|
44
|
+
} = await N(t, e, [r], g), R = await q(
|
|
132
45
|
e,
|
|
133
46
|
s,
|
|
134
47
|
t.userKeys,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
),
|
|
138
|
-
|
|
48
|
+
v,
|
|
49
|
+
D
|
|
50
|
+
), S = Y(
|
|
51
|
+
L.WithdrawOnChainUtxos,
|
|
139
52
|
e,
|
|
140
53
|
[r],
|
|
141
|
-
[-
|
|
54
|
+
[-A.amount],
|
|
142
55
|
s
|
|
143
|
-
), { zkCallData:
|
|
56
|
+
), { zkCallData: P, circomData: B, dimData: K } = await b(
|
|
144
57
|
"v1x1",
|
|
145
58
|
t.merkleTreeHinkalByChain[e],
|
|
146
59
|
t.merkleTreeAccessTokenByChain[e],
|
|
147
|
-
|
|
148
|
-
|
|
60
|
+
f,
|
|
61
|
+
C,
|
|
149
62
|
t.userKeys,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
63
|
+
E,
|
|
64
|
+
u.externalActionId,
|
|
65
|
+
u.externalAddress,
|
|
66
|
+
u.externalActionMetadata,
|
|
154
67
|
t.generateProofRemotely,
|
|
155
|
-
a ??
|
|
68
|
+
a ?? M,
|
|
156
69
|
e,
|
|
157
70
|
void 0,
|
|
158
71
|
void 0,
|
|
@@ -160,43 +73,43 @@ const it = async (t, e, m, i, A, l, d) => {
|
|
|
160
73
|
k,
|
|
161
74
|
void 0,
|
|
162
75
|
void 0,
|
|
163
|
-
|
|
164
|
-
t.getContractWithFetcher(e,
|
|
165
|
-
|
|
76
|
+
m,
|
|
77
|
+
t.getContractWithFetcher(e, F.HinkalHelperContract),
|
|
78
|
+
R,
|
|
166
79
|
void 0,
|
|
167
80
|
!1
|
|
168
81
|
);
|
|
169
82
|
return {
|
|
170
|
-
zkCallData:
|
|
171
|
-
dimData:
|
|
172
|
-
circomData:
|
|
173
|
-
adminData:
|
|
83
|
+
zkCallData: P,
|
|
84
|
+
dimData: K,
|
|
85
|
+
circomData: B,
|
|
86
|
+
adminData: S
|
|
174
87
|
};
|
|
175
88
|
})
|
|
176
89
|
);
|
|
177
|
-
|
|
90
|
+
h.push(...x);
|
|
178
91
|
}
|
|
179
|
-
return
|
|
180
|
-
},
|
|
181
|
-
const
|
|
92
|
+
return z(e, h, d, n);
|
|
93
|
+
}, wt = async (t, e, c, o, m, d) => {
|
|
94
|
+
const n = e.erc20TokenAddress, r = Z([e]), a = G(await t.getEthereumAddressByChain(r)), s = d ?? await _(r, n, [n], H.Transact), p = await V(
|
|
182
95
|
t,
|
|
183
96
|
r,
|
|
184
97
|
e,
|
|
185
|
-
|
|
186
|
-
|
|
98
|
+
c,
|
|
99
|
+
o,
|
|
187
100
|
s,
|
|
188
101
|
a
|
|
189
102
|
);
|
|
190
|
-
return
|
|
103
|
+
return $(
|
|
191
104
|
t,
|
|
192
105
|
r,
|
|
193
106
|
e,
|
|
194
|
-
|
|
107
|
+
p,
|
|
195
108
|
s,
|
|
196
109
|
a,
|
|
197
|
-
|
|
110
|
+
m
|
|
198
111
|
);
|
|
199
112
|
};
|
|
200
113
|
export {
|
|
201
|
-
|
|
114
|
+
wt as hinkalDepositAndWithdraw
|
|
202
115
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("ethers"),R=require("../../constants/protocol.constants.cjs"),K=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),Z=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),$=require("../../functions/web3/events/getShieldedBalance.cjs"),z=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),j=require("../../types/external-action.types.cjs");require("../../types/circom-data.types.cjs");const d=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");const G=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const N=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),X=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),J=require("../../functions/utils/getUtxosFromReceipt.utils.cjs"),L=require("../../functions/utils/fees.utils.cjs"),Q=require("../../API/unspent-utxos-calls.cjs"),V=require("../../functions/pre-transaction/constructAdminData.cjs"),Y=require("../../API/admin-calls.cjs"),I=async(t,e,p,y,q,w,f)=>{const l=p.erc20TokenAddress,x=await t.getEthereumAddressByChain(e),n=y.map(o=>o+L.calculateTotalFee(o,w)),a=[l],c=[0n],h=[!0],{patchAccessTokenMerkleTree:k,kycRequired:P,hasAccessToken:O}=await X.shouldPatchAccessTokenMerkleTree(t,e,a,c),v=await N.getSignatureDataForTransact(e,x,t.userKeys,P,O),r=[...await $.addPaddingToUtxos(t,e,a,c)],C=[];for(let o=0;o<r.length;o+=1){const{outputUtxos:s}=K.outputUtxoProcessing(t.userKeys,r[o],c[o]);C.push(s)}const m=n.reduce((o,s)=>o+s,0n),S=H.ethers.utils.defaultAbiCoder.encode(["uint256[]"],[n]),T=t.getContractWithSigner(e,d.ContractType.HinkalWrapper),g=t.getContractWithSigner(e,d.ContractType.DepositOnChainUtxos),{zkCallData:F,circomData:_,dimData:b}=await Z.constructZkProof("v1x1",t.merkleTreeHinkalByChain[e],t.merkleTreeAccessTokenByChain[e],r,C,t.userKeys,`swapperM1x${r[0].length}x1`,j.ExternalActionId.DepositOnChainUtxos,g.address,S,t.generateProofRemotely,R.zeroAddress,e,h,void 0,void 0,k,void 0,void 0,void 0,t.getContractWithFetcher(e,d.ContractType.HinkalHelperContract),v,T.address,!1),E=await(await z.transactCallDirect(t,e,m,p,F,_,b,g,T)).wait(),A=J.getUtxosFromReceipt(E,t,e,l),D=[],i=[...A];q.forEach((o,s)=>{const U=n[s],u=i.find(B=>B.amount===U);if(!u)throw new Error(`Could not find newly created UTXO with amount ${U} for recipient ${o}.`);D.push({recipientAddress:o,utxo:u});const W=i.indexOf(u);i.splice(W,1)}),await Q.storeUnspentUtxos({hashedEthereumAddress:f,chainId:e,utxos:A});const M=V.constructAdminData(G.AdminTransactionType.DepositOnChainUtxos,e,a,[m],x);return Y.emitTxPublicData(M),D};exports.hinkalDepositOnChainUtxos=I;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IHinkal } from './IHinkal';
|
|
2
|
+
import { ERC20Token, RecipientUtxo } from '../../types';
|
|
3
|
+
import { FeeStructure } from '../../types/hinkal.types';
|
|
4
|
+
export declare const hinkalDepositOnChainUtxos: (hinkal: IHinkal, chainId: number, erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], feeStructure: FeeStructure, hashedEthereumAddress: string) => Promise<RecipientUtxo[]>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ethers as S } from "ethers";
|
|
2
|
+
import { zeroAddress as $ } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { outputUtxoProcessing as z } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
4
|
+
import { constructZkProof as Z } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
5
|
+
import { addPaddingToUtxos as q } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
6
|
+
import { transactCallDirect as X } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
7
|
+
import { ExternalActionId as j } from "../../types/external-action.types.mjs";
|
|
8
|
+
import "../../types/circom-data.types.mjs";
|
|
9
|
+
import { ContractType as p } from "../../types/ethereum-network.types.mjs";
|
|
10
|
+
import "../../types/transactions.types.mjs";
|
|
11
|
+
import { AdminTransactionType as G } from "../../types/admin.types.mjs";
|
|
12
|
+
import "../../types/activities.types.mjs";
|
|
13
|
+
import { getSignatureDataForTransact as J } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
14
|
+
import { shouldPatchAccessTokenMerkleTree as L } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
15
|
+
import { getUtxosFromReceipt as N } from "../../functions/utils/getUtxosFromReceipt.utils.mjs";
|
|
16
|
+
import { calculateTotalFee as Q } from "../../functions/utils/fees.utils.mjs";
|
|
17
|
+
import { storeUnspentUtxos as V } from "../../API/unspent-utxos-calls.mjs";
|
|
18
|
+
import { constructAdminData as Y } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
19
|
+
import { emitTxPublicData as _ } from "../../API/admin-calls.mjs";
|
|
20
|
+
const Tt = async (t, o, d, g, w, y, v) => {
|
|
21
|
+
const u = d.erc20TokenAddress, x = await t.getEthereumAddressByChain(o), a = g.map((e) => e + Q(e, y)), n = [u], i = [0n], O = [!0], { patchAccessTokenMerkleTree: P, kycRequired: k, hasAccessToken: E } = await L(
|
|
22
|
+
t,
|
|
23
|
+
o,
|
|
24
|
+
n,
|
|
25
|
+
i
|
|
26
|
+
), W = await J(
|
|
27
|
+
o,
|
|
28
|
+
x,
|
|
29
|
+
t.userKeys,
|
|
30
|
+
k,
|
|
31
|
+
E
|
|
32
|
+
), s = [...await q(t, o, n, i)], f = [];
|
|
33
|
+
for (let e = 0; e < s.length; e += 1) {
|
|
34
|
+
const { outputUtxos: r } = z(t.userKeys, s[e], i[e]);
|
|
35
|
+
f.push(r);
|
|
36
|
+
}
|
|
37
|
+
const l = a.reduce((e, r) => e + r, 0n), h = S.utils.defaultAbiCoder.encode(["uint256[]"], [a]), C = t.getContractWithSigner(o, p.HinkalWrapper), A = t.getContractWithSigner(o, p.DepositOnChainUtxos), {
|
|
38
|
+
zkCallData: F,
|
|
39
|
+
circomData: H,
|
|
40
|
+
dimData: b
|
|
41
|
+
} = await Z(
|
|
42
|
+
"v1x1",
|
|
43
|
+
t.merkleTreeHinkalByChain[o],
|
|
44
|
+
t.merkleTreeAccessTokenByChain[o],
|
|
45
|
+
s,
|
|
46
|
+
f,
|
|
47
|
+
t.userKeys,
|
|
48
|
+
`swapperM1x${s[0].length}x1`,
|
|
49
|
+
j.DepositOnChainUtxos,
|
|
50
|
+
A.address,
|
|
51
|
+
h,
|
|
52
|
+
t.generateProofRemotely,
|
|
53
|
+
$,
|
|
54
|
+
o,
|
|
55
|
+
O,
|
|
56
|
+
void 0,
|
|
57
|
+
void 0,
|
|
58
|
+
P,
|
|
59
|
+
void 0,
|
|
60
|
+
void 0,
|
|
61
|
+
void 0,
|
|
62
|
+
t.getContractWithFetcher(o, p.HinkalHelperContract),
|
|
63
|
+
W,
|
|
64
|
+
C.address,
|
|
65
|
+
!1
|
|
66
|
+
), B = await (await X(
|
|
67
|
+
t,
|
|
68
|
+
o,
|
|
69
|
+
l,
|
|
70
|
+
d,
|
|
71
|
+
F,
|
|
72
|
+
H,
|
|
73
|
+
b,
|
|
74
|
+
A,
|
|
75
|
+
C
|
|
76
|
+
)).wait(), D = N(B, t, o, u), T = [], c = [...D];
|
|
77
|
+
w.forEach((e, r) => {
|
|
78
|
+
const U = a[r], m = c.find((R) => R.amount === U);
|
|
79
|
+
if (!m)
|
|
80
|
+
throw new Error(`Could not find newly created UTXO with amount ${U} for recipient ${e}.`);
|
|
81
|
+
T.push({
|
|
82
|
+
recipientAddress: e,
|
|
83
|
+
utxo: m
|
|
84
|
+
});
|
|
85
|
+
const M = c.indexOf(m);
|
|
86
|
+
c.splice(M, 1);
|
|
87
|
+
}), await V({
|
|
88
|
+
hashedEthereumAddress: v,
|
|
89
|
+
chainId: o,
|
|
90
|
+
utxos: D
|
|
91
|
+
});
|
|
92
|
+
const K = Y(
|
|
93
|
+
G.DepositOnChainUtxos,
|
|
94
|
+
o,
|
|
95
|
+
n,
|
|
96
|
+
[l],
|
|
97
|
+
x
|
|
98
|
+
);
|
|
99
|
+
return _(K), T;
|
|
100
|
+
};
|
|
101
|
+
export {
|
|
102
|
+
Tt as hinkalDepositOnChainUtxos
|
|
103
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../constants/protocol.constants.cjs"),Y=require("../../error-handling/error-codes.constants.cjs"),Z=require("../../functions/snarkjs/constructEmporiumProof.cjs"),$=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),R=require("../../types/external-action.types.cjs"),U=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const J=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const Q=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),X=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),ee=require("../../functions/utils/time.utils.cjs"),re=require("../../functions/pre-transaction/getFeeStructure.cjs"),te=require("../../functions/utils/addresses.cjs"),se=require("../../constants/chains.constants.cjs"),b=require("../../constants/addresses.constants.cjs");require("ethers");require("idb-keyval");require("@solana/web3.js");require("../http/HttpClient.cjs");require("../../constants/vite.constants.cjs");const oe=require("../../functions/utils/erc20tokenFunctions.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("axios");const z=require("../../functions/utils/caseInsensitive.utils.cjs");require("@coral-xyz/anchor");require("circomlibjs-hinkal-fork");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("buffer");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");const ne=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs");require("../crypto-keys/keys.cjs");require("libsodium-wrappers");require("multiformats");const ie=require("../../functions/utils/token-check.utils.cjs");require("async-mutex");require("process");require("../../providers/EthersProviderAdapter.cjs");const O=require("./hinkalDepositOnChainUtxos.cjs"),B=require("../../functions/private-wallet/emporium.helpers.cjs"),ae=require("../../API/API.cjs"),ue=async(e,r,n,q,p,u,s)=>{if(q.length===0)throw new Error("No recipients to bridge");const i=n.erc20TokenAddress,{contractData:h}=se.networkRegistry[r],{emporiumAddress:a}=h;if(!a)throw Error("No Emporium Address");const g=b.SWAP_ROUTER_ADDRESSES[R.ExternalActionId.Lifi][r];if(!g)throw new Error(`LIFI not configured for chain ${r}`);const T=await e.getRandomRelay(r);if(!T)throw Error(Y.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const f=await e.getEthereumAddressByChain(r),y=ee.getCurrentTimeInSeconds().toString(),m=e.generateProofRemotely?5:1,E=[];for(let c=0;c<q.length;c+=m){const v=q.slice(c,c+m),t=await Promise.all(v.map(async({utxo:o,nativeUtxo:d,bridgeAmount:C,quote:S,temporarySubAccount:w})=>{await ae.API.addTemporaryWalletNonce(r,u,w.index);const N=S.nativeFee>0n&&!z.caseInsensitiveEqual(i,l.zeroAddress),A=[i],x=[-o.amount],D=[!1],F=new U.Utxo({amount:0n,erc20TokenAddress:i,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:y,tokenId:0}),k=[[o,F]],P=[[F]];if(N&&d){const _=new U.Utxo({amount:0n,erc20TokenAddress:l.zeroAddress,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:y,tokenId:0});A.push(l.zeroAddress),x.push(-d.amount),D.push(!1),k.push([d,_]),P.push([_])}const K=B.createLifiBridgeOps(e,r,w.ethAddress,g,i,o.amount,C,S),{patchAccessTokenMerkleTree:L,kycRequired:I,hasAccessToken:M}=await X.shouldPatchAccessTokenMerkleTree(e,r,A,x),W=await Q.getSignatureDataForTransact(r,f,e.userKeys,I,M),{zkCallData:H,circomData:j,dimData:G,authorizationData:V}=await Z.constructEmporiumProof("v1x1",e.merkleTreeHinkalByChain[r],e.merkleTreeAccessTokenByChain[r],A,A.map(()=>0),k,P,e.userKeys,A.length,k[0].length,a,K,e.generateProofRemotely,T??l.zeroAddress,r,D,void 0,w.privateKey,void 0,L,void 0,p,e.getContractWithFetcher(r,J.ContractType.HinkalHelperContract),W,void 0,!1);return{zkCallData:H,dimData:G,circomData:j,authorizationData:V}}));E.push(...t)}return $.transactCallRelayerBatch(r,E,u,s)},ce=async(e,r,n,q,p)=>{const u=r.erc20TokenAddress,s=ie.validateAndGetChainId([r]),i=te.hashEthereumAddress(await e.getEthereumAddressByChain(s)),h=b.SWAP_ROUTER_ADDRESSES[R.ExternalActionId.Lifi][s];if(!h)throw Error("LIFI router not configured");let a;if(p)a=p;else{const t=n[0],d=B.createLifiBridgeOps(e,s,t.temporarySubAccount.ethAddress,h,u,t.bridgeAmount,t.bridgeAmount,t.quote).map(C=>ne.convertEmporiumOpToCallInfo(C,t.temporarySubAccount.ethAddress,s));a=await re.getFeeStructure(s,u,[u],R.ExternalActionId.Emporium,d)}const g={feeToken:a.feeToken,flatFee:0n,variableRate:0n},f=n.reduce((t,o)=>t+o.quote.nativeFee,0n)>0n&&!z.caseInsensitiveEqual(u,l.zeroAddress),y=n.map(t=>t.bridgeAmount),m=n.map(t=>t.recipientAddress),E=await O.hinkalDepositOnChainUtxos(e,s,r,y,m,a,i);let c=[];if(f){const t=oe.getERC20Token(l.zeroAddress,s);if(!t)throw Error("No native token");const o=n.map(d=>d.quote.nativeFee);c=await O.hinkalDepositOnChainUtxos(e,s,t,o,m,g,i)}const v=n.map((t,o)=>({...t,utxo:E[o].utxo,nativeUtxo:f?c[o]?.utxo:void 0}));return ue(e,s,r,v,a,i,q)};exports.hinkalDepositAndBridge=ce;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IHinkal } from './IHinkal';
|
|
2
|
+
import { BridgeRecipient, ERC20Token } from '../../types';
|
|
3
|
+
import { FeeStructure } from '../../types/hinkal.types';
|
|
4
|
+
export declare const hinkalDepositAndBridge: (hinkal: IHinkal, erc20Token: ERC20Token, recipients: BridgeRecipient[], txCompletionTime?: number, feeStructureOverride?: FeeStructure) => Promise<string>;
|