@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,9 +1,9 @@
|
|
|
1
|
-
import { utils as
|
|
2
|
-
import { zeroAddress as
|
|
3
|
-
import { ContractType as
|
|
1
|
+
import { utils as p, BigNumber as w, ethers as C } from "ethers";
|
|
2
|
+
import { zeroAddress as d } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { ContractType as g } from "../../types/ethereum-network.types.mjs";
|
|
4
4
|
import "idb-keyval";
|
|
5
|
-
import {
|
|
6
|
-
import { createCustomRpcProvider as
|
|
5
|
+
import { chainIds as F, networkRegistry as W } from "../../constants/chains.constants.mjs";
|
|
6
|
+
import { createCustomRpcProvider as O } from "../utils/create-provider.mjs";
|
|
7
7
|
import "../../constants/token-data/index.mjs";
|
|
8
8
|
import "../../error-handling/error-codes.constants.mjs";
|
|
9
9
|
import "../utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
@@ -11,17 +11,19 @@ import "../../types/circom-data.types.mjs";
|
|
|
11
11
|
import "../../types/transactions.types.mjs";
|
|
12
12
|
import "../../types/activities.types.mjs";
|
|
13
13
|
import "circomlibjs-hinkal-fork";
|
|
14
|
-
import
|
|
14
|
+
import "../../data-structures/crypto-keys/keys.mjs";
|
|
15
15
|
import "../../constants/server.constants.mjs";
|
|
16
16
|
import "../../API/getServerURL.mjs";
|
|
17
17
|
import "../../data-structures/http/HttpClient.mjs";
|
|
18
18
|
import "axios";
|
|
19
19
|
import "../../constants/vite.constants.mjs";
|
|
20
|
-
import { caseInsensitiveEqual as
|
|
21
|
-
import { Logger as
|
|
20
|
+
import { caseInsensitiveEqual as l } from "../utils/caseInsensitive.utils.mjs";
|
|
21
|
+
import { Logger as B } from "../../error-handling/logger.mjs";
|
|
22
22
|
import "@solana/web3.js";
|
|
23
23
|
import "@coral-xyz/anchor";
|
|
24
24
|
import "@solana/spl-token";
|
|
25
|
+
import { AccountActions as y } from "../../data-structures/AccountActions/AccountActions.mjs";
|
|
26
|
+
import "buffer";
|
|
25
27
|
import "../../constants/contracts.constants.mjs";
|
|
26
28
|
import "../../constants/kyc.constants.mjs";
|
|
27
29
|
import "../../constants/coingecko.constants.mjs";
|
|
@@ -33,130 +35,153 @@ import "../../constants/activity.constants.mjs";
|
|
|
33
35
|
import "../../constants/tasks.constants.mjs";
|
|
34
36
|
import "../../constants/events.constants.mjs";
|
|
35
37
|
import "../utils/userAgent.mjs";
|
|
36
|
-
import { replaceAllInstances as C } from "../utils/string.utils.mjs";
|
|
37
38
|
import "libsodium-wrappers";
|
|
38
39
|
import "multiformats";
|
|
40
|
+
import "../../API/enclaveCalls.mjs";
|
|
39
41
|
import "async-mutex";
|
|
40
|
-
import "../../API/tenderly.api.mjs";
|
|
41
42
|
import "process";
|
|
42
|
-
import "buffer";
|
|
43
43
|
import "../../providers/EthersProviderAdapter.mjs";
|
|
44
|
-
import { ethers as
|
|
45
|
-
const
|
|
44
|
+
import { ethers as k } from "ethers-v6h";
|
|
45
|
+
const h = ({
|
|
46
46
|
contract: t,
|
|
47
47
|
func: r,
|
|
48
|
-
args:
|
|
49
|
-
callDataString:
|
|
50
|
-
invokeWallet:
|
|
51
|
-
value:
|
|
48
|
+
args: o,
|
|
49
|
+
callDataString: e,
|
|
50
|
+
invokeWallet: i,
|
|
51
|
+
value: a
|
|
52
52
|
}) => {
|
|
53
|
-
let
|
|
53
|
+
let n = new Uint8Array(), s = e ? p.arrayify(e) : new Uint8Array();
|
|
54
54
|
if (typeof t == "object" && "address" in t) {
|
|
55
|
-
if (
|
|
55
|
+
if (n = p.arrayify(t.address), e?.length && e?.length > 0)
|
|
56
56
|
throw Error("If function and args are providedm no calldata is needed");
|
|
57
|
-
r &&
|
|
57
|
+
r && o && !e && (s = p.arrayify(t.interface.encodeFunctionData(r, o)));
|
|
58
58
|
} else
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
return
|
|
62
|
-
},
|
|
63
|
-
const
|
|
59
|
+
n = p.arrayify(t);
|
|
60
|
+
const m = p.arrayify([i ? 1 : 0]), c = p.zeroPad(p.arrayify(w.from(a ?? 0n)), 16), u = p.concat([n, m, c, s]);
|
|
61
|
+
return p.hexlify(u);
|
|
62
|
+
}, Ft = async (t, r, o, e, i, a) => {
|
|
63
|
+
const n = o ? await y.signTypedDataFromPrivateKey(
|
|
64
64
|
t,
|
|
65
|
-
|
|
65
|
+
o,
|
|
66
66
|
{ name: "Emporium", version: "1.0.0", chainId: t, verifyingContract: r },
|
|
67
67
|
{ EmporiumSignature: [{ name: "message", type: "uint256" }] },
|
|
68
|
-
{ message:
|
|
69
|
-
) : void 0, { v:
|
|
70
|
-
return
|
|
68
|
+
{ message: i }
|
|
69
|
+
) : void 0, { v: s, r: m, s: c } = n ? p.splitSignature(n) : { v: 0, r: C.constants.HashZero, s: C.constants.HashZero };
|
|
70
|
+
return p.defaultAbiCoder.encode(
|
|
71
71
|
["tuple(uint8 v,bytes32 r, bytes32 s, uint256 message, address signerAddress, bytes[] ops)"],
|
|
72
72
|
[
|
|
73
73
|
{
|
|
74
|
-
v:
|
|
75
|
-
r:
|
|
76
|
-
s:
|
|
77
|
-
message:
|
|
78
|
-
signerAddress:
|
|
79
|
-
ops:
|
|
74
|
+
v: s,
|
|
75
|
+
r: m,
|
|
76
|
+
s: c,
|
|
77
|
+
message: i ?? 0n,
|
|
78
|
+
signerAddress: a ?? d,
|
|
79
|
+
ops: e
|
|
80
80
|
}
|
|
81
81
|
]
|
|
82
82
|
);
|
|
83
|
-
},
|
|
83
|
+
}, A = (t, r, o, e) => h(t ? {
|
|
84
84
|
contract: t,
|
|
85
85
|
func: "transfer",
|
|
86
|
-
args: [r,
|
|
87
|
-
invokeWallet:
|
|
88
|
-
} : { contract: r, value:
|
|
89
|
-
const
|
|
90
|
-
return
|
|
91
|
-
const
|
|
92
|
-
return
|
|
86
|
+
args: [r, o],
|
|
87
|
+
invokeWallet: e
|
|
88
|
+
} : { contract: r, value: o, invokeWallet: e }), Wt = (t, r, o, e, i) => {
|
|
89
|
+
const a = t.getContractWithFetcher(r, g.HinkalContract);
|
|
90
|
+
return o.map((n, s) => {
|
|
91
|
+
const m = l(n, d) ? void 0 : t.getContractWithFetcher(r, g.ERC20Contract, n);
|
|
92
|
+
return A(m, i ?? a.address, e[s], !0);
|
|
93
93
|
});
|
|
94
|
-
},
|
|
94
|
+
}, D = (t, r, o, e) => h({
|
|
95
95
|
contract: t,
|
|
96
96
|
func: "approve",
|
|
97
|
-
args: [r,
|
|
98
|
-
invokeWallet:
|
|
99
|
-
}),
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
args: [r, o],
|
|
98
|
+
invokeWallet: e
|
|
99
|
+
}), I = (t, r, o, e, i, a, n, s) => {
|
|
100
|
+
const m = [];
|
|
101
|
+
for (let c = 0; c < o.length; c += 1) {
|
|
102
|
+
const u = o[c], f = l(u, d) ? void 0 : t.getContractWithFetcher(r, g.ERC20Contract, u);
|
|
103
|
+
m.push(A(f, n, e[c], !1));
|
|
104
|
+
}
|
|
105
|
+
if (s)
|
|
106
|
+
for (let c = 0; c < i.length; c += 1) {
|
|
107
|
+
const u = i[c];
|
|
108
|
+
if (!l(u, d)) {
|
|
109
|
+
const f = t.getContractWithFetcher(r, g.ERC20Contract, u);
|
|
110
|
+
m.push(D(f, s, a[c], !0));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return m;
|
|
114
|
+
}, Ot = (t, r, o, e, i, a, n, s) => {
|
|
115
|
+
const m = [], c = [i], u = [a];
|
|
116
|
+
s.nativeFee > 0n && !l(i, d) && (c.push(d), u.push(s.nativeFee));
|
|
117
|
+
const E = I(
|
|
118
|
+
t,
|
|
119
|
+
r,
|
|
120
|
+
c,
|
|
121
|
+
u,
|
|
122
|
+
[i],
|
|
123
|
+
[n],
|
|
124
|
+
o,
|
|
125
|
+
e
|
|
126
|
+
);
|
|
127
|
+
m.push(...E);
|
|
128
|
+
let v = s.nativeFee;
|
|
129
|
+
return l(i, d) && (v += n), m.push(
|
|
130
|
+
h({
|
|
131
|
+
contract: e,
|
|
132
|
+
callDataString: s.calldata,
|
|
133
|
+
value: v > 0n ? v : void 0,
|
|
134
|
+
invokeWallet: !0
|
|
135
|
+
})
|
|
136
|
+
), m;
|
|
137
|
+
}, b = "0xef0100", x = async (t, r) => {
|
|
110
138
|
try {
|
|
111
|
-
const
|
|
112
|
-
if (!e)
|
|
113
|
-
throw new Error("RPC URL not found for the specified chain ID");
|
|
114
|
-
const o = E(e), n = await o.getCode(r);
|
|
115
|
-
if (n === "0x" || !n)
|
|
139
|
+
const o = O(t), e = await o.getCode(r);
|
|
140
|
+
if (e === "0x" || !e)
|
|
116
141
|
return { delegated: !1, implementation: void 0, nonce: void 0 };
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
return { delegated: !0, implementation:
|
|
142
|
+
if (e.toLowerCase().startsWith(b) && e.length === 48) {
|
|
143
|
+
const i = `0x${e.slice(8)}`, a = await o.getTransactionCount(r);
|
|
144
|
+
return { delegated: !0, implementation: p.getAddress(i), nonce: a };
|
|
120
145
|
} else
|
|
121
146
|
throw Error("checkEOAWithDelegation: It is a contract");
|
|
122
|
-
} catch (
|
|
123
|
-
throw
|
|
147
|
+
} catch (o) {
|
|
148
|
+
throw B.error("checkEOAWithDelegation error", { error: o }), o;
|
|
124
149
|
}
|
|
125
|
-
},
|
|
126
|
-
const { hinkalWalletAddress: r } =
|
|
127
|
-
if (!r ||
|
|
150
|
+
}, H = (t) => {
|
|
151
|
+
const { hinkalWalletAddress: r } = W[t].contractData;
|
|
152
|
+
if (!r || l(r, d))
|
|
128
153
|
throw Error("Hinkal Wallet Address is not set");
|
|
129
154
|
return r;
|
|
130
|
-
},
|
|
131
|
-
if (t ===
|
|
155
|
+
}, Bt = async (t, r) => {
|
|
156
|
+
if (t === F.localhost || !r)
|
|
132
157
|
return;
|
|
133
|
-
const
|
|
134
|
-
if (!
|
|
135
|
-
const
|
|
158
|
+
const o = y.getSignerAddressFromPrivateKey(t, r), { delegated: e, implementation: i } = await x(t, o), a = H(t);
|
|
159
|
+
if (!e || !l(i, a)) {
|
|
160
|
+
const n = await y.authorizeDelegation(t, r, a);
|
|
136
161
|
return {
|
|
137
|
-
v:
|
|
138
|
-
r:
|
|
139
|
-
s:
|
|
140
|
-
nonce:
|
|
141
|
-
address:
|
|
162
|
+
v: n.signature.v.toString(),
|
|
163
|
+
r: n.signature.r,
|
|
164
|
+
s: n.signature.s,
|
|
165
|
+
nonce: n.nonce.toString(),
|
|
166
|
+
address: a,
|
|
142
167
|
chainId: String(t)
|
|
143
168
|
};
|
|
144
169
|
}
|
|
145
|
-
},
|
|
170
|
+
}, kt = (t) => {
|
|
146
171
|
if (!t)
|
|
147
172
|
return;
|
|
148
|
-
const { v: r, r:
|
|
149
|
-
return { signature:
|
|
173
|
+
const { v: r, r: o, s: e, nonce: i, chainId: a, address: n } = t;
|
|
174
|
+
return { signature: k.Signature.from({ v: r, r: o, s: e }), nonce: BigInt(i), chainId: BigInt(a), address: n };
|
|
150
175
|
};
|
|
151
176
|
export {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
177
|
+
x as checkEOAWithDelegation,
|
|
178
|
+
D as createApproveEmporiumOp,
|
|
179
|
+
Ot as createLifiBridgeOps,
|
|
180
|
+
Wt as createTransaferEmporiumOpsBatch,
|
|
181
|
+
A as createTransferToEmporiumOp,
|
|
182
|
+
h as emporiumOp,
|
|
183
|
+
Ft as encodeEmporiumMetadata,
|
|
184
|
+
I as generateFundAndApproveOps,
|
|
185
|
+
Bt as getAuthorizationDataIfNeeded,
|
|
186
|
+
kt as recoverAuthorizationData
|
|
162
187
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("../../data-structures/utxo/Utxo.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("../../data-structures/utxo/Utxo.cjs"),d=require("../../constants/protocol.constants.cjs"),le=require("../../constants/chains.constants.cjs"),ue=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),ge=require("../../webworker/performTaskWithWorker.cjs"),pe=require("../../webworker/worker.registry.cjs"),o=require("./common.snarkjs.cjs"),Z=require("../web3/etherFunctions.cjs"),$=require("../private-wallet/emporium.helpers.cjs"),Ae=require("../../types/external-action.types.cjs"),Se=require("../../types/circom-data.types.cjs"),he=require("./generateCircomData.cjs"),fe=require("./generateZkProof.cjs"),j=require("../utils/time.utils.cjs"),qe=require("../../types/hinkal.types.cjs"),ke=require("../utils/fees.utils.cjs"),G=require("../../data-structures/Hinkal/hinkalCheckTokenRegistry.cjs"),He=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const Ce=require("./getMerkleTreeSiblingsAndRootHashes.cjs"),Te=require("../../data-structures/AccountActions/AccountActions.cjs"),we=async(s,J,Q,l,f,t,e,m,T,X,w,Y,K,y=d.zeroAddress,c=le.chainIds.localhost,u=t.map(()=>!1),q=t.map(()=>0n),g,r=void 0,L=!1,p,A=void 0,V,M=d.defaultSignatureData,x,U=!0)=>{const z=o.calcAmountChanges(t,e),k=o.calcEncryptedOutputs(e),S=m.getShieldedPrivateKey(),D=de.Utxo.findCorrectRandomization(Z.randomBigInt(31),S),ee=await G.hinkalCheckTokenRegistry(V??G.createHinkalHelperFromData(c),l,o.calcAmountChanges(t,e,!0)),_=t.map(a=>a.map(i=>i.getConstructableParams())),{inCommitmentSiblings:te,inCommitmentSiblingSides:ae,accessTokenSiblings:W,accessTokenSiblingSides:b,rootHashHinkal:P,rootHashAccessToken:H}=await Ce.getMerkleTreeSiblingsAndRootHashes(c,m,_,L,ee,J,Q,U),E=await ge.performTaskWithWorker({type:pe.WorkerVariant.ZKProof,payload:{type:ue.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:_,onChainCreation:u,proverVersion:s}}}),I=o.buildOutCommitments(s,e,u),C=x??Z.randomBigInt(31),ne=He.poseidonFunction(C),n={rootHashHinkal:P,erc20TokenAddresses:l,tokenIds:f,inNullifiers:E,outTimeStamp:e.length>0?BigInt(e[0][0].timeStamp):j.getCurrentTimeInSeconds(),extraRandomization:D,amountChanges:z,outCommitments:I,rootHashAccessToken:H,calldataHash:0n,shieldedPrivateKey:S,accessTokenSiblings:W,accessTokenSiblingSides:b,outAmounts:e.map(a=>a.map(i=>i.amount)),outPublicKeys:e.map(a=>a.map(i=>i.getStealthAddress())),inAmounts:t.map(a=>a.map(i=>i.amount.toString())),inTimeStamps:t.map(a=>a.map(i=>i.timeStamp)),inRandomizations:t.map(a=>a.map(i=>i.randomization)),inCommitmentSiblings:te,inCommitmentSiblingSides:ae,messageSeed:C},re=g?Te.AccountActions.getSignerAddressFromPrivateKey(c,g):void 0,R=w,F=Ae.ExternalActionId.Emporium,N=await $.encodeEmporiumMetadata(c,w,g,Y,ne,re),h=e.length===0?"swapperMWMin0":`swapperMW${T}x${X}x${e[0].length}`,B=o.calcPublicSignalCount(h,n.erc20TokenAddresses,n.amountChanges,n.inNullifiers,n.outCommitments,f.length);if(r||(r=qe.defaultHinkalLogicArgs(z.length,m),r.interactionAddress="0x032f580aFFE7a5f17025fAF83c13B4277A880532",r.inHinkalAddress=m.getInHinkalAddress(r.interactionAddress)),s==="v1x1"){if(n.interactionAddress=r.interactionAddress,m.getInHinkalAddress(n.interactionAddress)!==r.inHinkalAddress)throw new Error("inHinkalAddress mismatch");n.externalApprovalAddresses=r?.useApprovalUtxoData?.map(({externalApprovalAddresses:a})=>a)??Array(T).fill([d.zeroAddress,d.zeroAddress,d.zeroAddress])}A||(A=ke.generateFeeStructure(q,l));const v=o.calcAmountChanges(t,e,!0);p||(p=o.getSlippageValues(v,r)),n.calldataHash=o.createCallDataHash(s,B,y,R,F,N,k,q,void 0,p,u,r,A,M);const O={outTimeStamp:j.getCurrentTimeInSeconds(),rootHashAccessToken:H,calldataHash:n.calldataHash,shieldedPrivateKey:S,accessTokenSiblings:W,accessTokenSiblingSides:b,messageSeed:C},{zkCallData:ie}=await fe.generateZkProof(s,c,h,h==="swapperMWMin0"?O:n,K),oe=o.calcStealthAddressStructure(D,S),se=await he.generateCircomData(s,I,E,P,H,v,l,t,e,k,q,B,F,R,N,y,n.calldataHash,f,oe,u,Se.defaultHookData,h==="swapperMWMin0"?O.outTimeStamp:n.outTimeStamp,r,p,A,M),ce={tokenNumber:t.length,nullifierAmount:t.length>0?t[0].length:0,outputAmount:e.length>0?e[0].length:0},me=await $.getAuthorizationDataIfNeeded(c,g);return{zkCallData:ie,circomData:se,dimData:ce,encryptedOutputs:k,authorizationData:me}};exports.constructEmporiumProof=we;
|
|
@@ -4,8 +4,7 @@ import { UserKeys } from '../../data-structures/crypto-keys/keys';
|
|
|
4
4
|
import { CircomDataV1x1, DimDataType } from '../../types/circom-data.types';
|
|
5
5
|
import { ethers } from 'ethers';
|
|
6
6
|
import { AuthorizationData, FeeStructure, HinkalLogicArgs, type ProverVersion } from '../../types/hinkal.types';
|
|
7
|
-
|
|
8
|
-
export declare const constructEmporiumProof: <T = CircomDataV1x1>(proverVersion: ProverVersion, merkleTree: MerkleTree<bigint>, merkleTreeAccessToken: MerkleTree<bigint>, erc20TokenAddresses: string[], tokenIds: number[], inputUtxos: Utxo[][], outputUtxos: Utxo[][], userKeys: UserKeys, tokenCount: number, inputCount: number, emporiumAddress: string, operations: string[], generateProofRemotely: boolean, relay?: string, chainId?: number, onChainCreation?: boolean[], flatFees?: bigint[], subAccount?: SubAccount, hinkalLogicArgs?: HinkalLogicArgs | undefined, patchAccessTokenMerkleTree?: boolean, slippageValues?: bigint[], feeStructure?: FeeStructure | undefined, hinkalHelper?: ethers.Contract, signatureData?: import('../../index.ts').SignatureData, messageSeedOverride?: bigint, hasLocalTrees?: boolean) => Promise<{
|
|
7
|
+
export declare const constructEmporiumProof: <T = CircomDataV1x1>(proverVersion: ProverVersion, merkleTree: MerkleTree<bigint>, merkleTreeAccessToken: MerkleTree<bigint>, erc20TokenAddresses: string[], tokenIds: number[], inputUtxos: Utxo[][], outputUtxos: Utxo[][], userKeys: UserKeys, tokenCount: number, inputCount: number, emporiumAddress: string, operations: string[], generateProofRemotely: boolean, relay?: string, chainId?: number, onChainCreation?: boolean[], flatFees?: bigint[], subAccountPrivateKey?: string, hinkalLogicArgs?: HinkalLogicArgs | undefined, patchAccessTokenMerkleTree?: boolean, slippageValues?: bigint[], feeStructure?: FeeStructure | undefined, hinkalHelper?: ethers.Contract, signatureData?: import('../../index.ts').SignatureData, messageSeedOverride?: bigint, hasLocalTrees?: boolean) => Promise<{
|
|
9
8
|
zkCallData: import('../../index.ts').NewZkCallDataType;
|
|
10
9
|
circomData: T;
|
|
11
10
|
dimData: DimDataType;
|
|
@@ -1,84 +1,84 @@
|
|
|
1
1
|
import { Utxo as da } from "../../data-structures/utxo/Utxo.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { randomBigInt as $ } from "../web3/etherFunctions.mjs";
|
|
2
|
+
import { zeroAddress as A, defaultSignatureData as la } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { chainIds as sa } from "../../constants/chains.constants.mjs";
|
|
4
|
+
import { ZKProofWorkerActionType as ca } from "../../webworker/zkProofWorker/zkProofWorker.types.mjs";
|
|
5
|
+
import { performTaskWithWorker as pa } from "../../webworker/performTaskWithWorker.mjs";
|
|
6
|
+
import { WorkerVariant as fa } from "../../webworker/worker.registry.mjs";
|
|
7
|
+
import { calcAmountChanges as D, calcEncryptedOutputs as Sa, buildOutCommitments as ga, calcPublicSignalCount as Aa, getSlippageValues as ha, createCallDataHash as Ha, calcStealthAddressStructure as wa } from "./common.snarkjs.mjs";
|
|
8
|
+
import { randomBigInt as _ } from "../web3/etherFunctions.mjs";
|
|
10
9
|
import { encodeEmporiumMetadata as Ma, getAuthorizationDataIfNeeded as Ca } from "../private-wallet/emporium.helpers.mjs";
|
|
11
10
|
import { ExternalActionId as Da } from "../../types/external-action.types.mjs";
|
|
12
11
|
import { defaultHookData as Ta } from "../../types/circom-data.types.mjs";
|
|
13
|
-
import { generateCircomData as
|
|
14
|
-
import { generateZkProof as
|
|
15
|
-
import { getCurrentTimeInSeconds as
|
|
16
|
-
import { defaultHinkalLogicArgs as
|
|
17
|
-
import { generateFeeStructure as
|
|
18
|
-
import { hinkalCheckTokenRegistry as
|
|
19
|
-
import { poseidonFunction as
|
|
12
|
+
import { generateCircomData as ka } from "./generateCircomData.mjs";
|
|
13
|
+
import { generateZkProof as za } from "./generateZkProof.mjs";
|
|
14
|
+
import { getCurrentTimeInSeconds as q } from "../utils/time.utils.mjs";
|
|
15
|
+
import { defaultHinkalLogicArgs as Wa } from "../../types/hinkal.types.mjs";
|
|
16
|
+
import { generateFeeStructure as ba } from "../utils/fees.utils.mjs";
|
|
17
|
+
import { hinkalCheckTokenRegistry as Ea, createHinkalHelperFromData as Ia } from "../../data-structures/Hinkal/hinkalCheckTokenRegistry.mjs";
|
|
18
|
+
import { poseidonFunction as Na } from "../../crypto/poseidon.mjs";
|
|
20
19
|
import "circomlibjs-hinkal-fork";
|
|
21
20
|
import "libsodium-wrappers";
|
|
22
21
|
import "process";
|
|
23
22
|
import "buffer";
|
|
24
|
-
import { getMerkleTreeSiblingsAndRootHashes as
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
import { getMerkleTreeSiblingsAndRootHashes as Pa } from "./getMerkleTreeSiblingsAndRootHashes.mjs";
|
|
24
|
+
import { AccountActions as Ra } from "../../data-structures/AccountActions/AccountActions.mjs";
|
|
25
|
+
const mt = async (i, j, G, l, h, t, a, d, T, J, k, Q, X, z = A, o = sa.localhost, s = t.map(() => !1), H = t.map(() => 0n), c, r = void 0, Y = !1, p, f = void 0, K, W = la, L, V = !0) => {
|
|
26
|
+
const b = D(t, a), w = Sa(a), S = d.getShieldedPrivateKey(), E = da.findCorrectRandomization(_(31), S), x = await Ea(
|
|
27
|
+
K ?? Ia(o),
|
|
28
28
|
l,
|
|
29
|
-
|
|
30
|
-
),
|
|
29
|
+
D(t, a, !0)
|
|
30
|
+
), I = t.map((e) => e.map((n) => n.getConstructableParams())), {
|
|
31
31
|
inCommitmentSiblings: U,
|
|
32
32
|
inCommitmentSiblingSides: aa,
|
|
33
|
-
accessTokenSiblings:
|
|
34
|
-
accessTokenSiblingSides:
|
|
35
|
-
rootHashHinkal:
|
|
36
|
-
rootHashAccessToken:
|
|
37
|
-
} = await
|
|
33
|
+
accessTokenSiblings: N,
|
|
34
|
+
accessTokenSiblingSides: P,
|
|
35
|
+
rootHashHinkal: R,
|
|
36
|
+
rootHashAccessToken: M
|
|
37
|
+
} = await Pa(
|
|
38
38
|
o,
|
|
39
39
|
d,
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
I,
|
|
41
|
+
Y,
|
|
42
42
|
x,
|
|
43
|
-
q,
|
|
44
43
|
j,
|
|
44
|
+
G,
|
|
45
45
|
V
|
|
46
|
-
),
|
|
47
|
-
type:
|
|
46
|
+
), y = await pa({
|
|
47
|
+
type: fa.ZKProof,
|
|
48
48
|
payload: {
|
|
49
|
-
type:
|
|
50
|
-
data: { inputUtxosSerialized:
|
|
49
|
+
type: ca.BUILD_IN_NULLIFIERS,
|
|
50
|
+
data: { inputUtxosSerialized: I, onChainCreation: s, proverVersion: i }
|
|
51
51
|
}
|
|
52
|
-
}),
|
|
53
|
-
rootHashHinkal:
|
|
52
|
+
}), F = ga(i, a, s), C = L ?? _(31), ta = Na(C), m = {
|
|
53
|
+
rootHashHinkal: R,
|
|
54
54
|
erc20TokenAddresses: l,
|
|
55
55
|
tokenIds: h,
|
|
56
|
-
inNullifiers:
|
|
57
|
-
outTimeStamp: a.length > 0 ? BigInt(a[0][0].timeStamp) :
|
|
58
|
-
extraRandomization:
|
|
59
|
-
amountChanges:
|
|
60
|
-
outCommitments:
|
|
61
|
-
rootHashAccessToken:
|
|
56
|
+
inNullifiers: y,
|
|
57
|
+
outTimeStamp: a.length > 0 ? BigInt(a[0][0].timeStamp) : q(),
|
|
58
|
+
extraRandomization: E,
|
|
59
|
+
amountChanges: b,
|
|
60
|
+
outCommitments: F,
|
|
61
|
+
rootHashAccessToken: M,
|
|
62
62
|
calldataHash: 0n,
|
|
63
63
|
shieldedPrivateKey: S,
|
|
64
|
-
accessTokenSiblings:
|
|
65
|
-
accessTokenSiblingSides:
|
|
66
|
-
outAmounts: a.map((e) => e.map((
|
|
67
|
-
outPublicKeys: a.map((e) => e.map((
|
|
68
|
-
inAmounts: t.map((e) => e.map((
|
|
69
|
-
inTimeStamps: t.map((e) => e.map((
|
|
70
|
-
inRandomizations: t.map((e) => e.map((
|
|
64
|
+
accessTokenSiblings: N,
|
|
65
|
+
accessTokenSiblingSides: P,
|
|
66
|
+
outAmounts: a.map((e) => e.map((n) => n.amount)),
|
|
67
|
+
outPublicKeys: a.map((e) => e.map((n) => n.getStealthAddress())),
|
|
68
|
+
inAmounts: t.map((e) => e.map((n) => n.amount.toString())),
|
|
69
|
+
inTimeStamps: t.map((e) => e.map((n) => n.timeStamp)),
|
|
70
|
+
inRandomizations: t.map((e) => e.map((n) => n.randomization)),
|
|
71
71
|
inCommitmentSiblings: U,
|
|
72
72
|
inCommitmentSiblingSides: aa,
|
|
73
|
-
messageSeed:
|
|
74
|
-
}, ea = c ?
|
|
73
|
+
messageSeed: C
|
|
74
|
+
}, ea = c ? Ra.getSignerAddressFromPrivateKey(o, c) : void 0, u = k, B = Da.Emporium, v = await Ma(
|
|
75
75
|
o,
|
|
76
|
-
|
|
77
|
-
c
|
|
78
|
-
|
|
76
|
+
k,
|
|
77
|
+
c,
|
|
78
|
+
Q,
|
|
79
79
|
ta,
|
|
80
80
|
ea
|
|
81
|
-
), g = a.length === 0 ? "swapperMWMin0" : `swapperMW${
|
|
81
|
+
), g = a.length === 0 ? "swapperMWMin0" : `swapperMW${T}x${J}x${a[0].length}`, O = Aa(
|
|
82
82
|
g,
|
|
83
83
|
m.erc20TokenAddresses,
|
|
84
84
|
m.amountChanges,
|
|
@@ -86,20 +86,20 @@ const mt = async (n, q, j, l, h, t, a, d, D, G, T, J, Q, P = A, o = ca.localhost
|
|
|
86
86
|
m.outCommitments,
|
|
87
87
|
h.length
|
|
88
88
|
);
|
|
89
|
-
if (r || (r =
|
|
89
|
+
if (r || (r = Wa(b.length, d), r.interactionAddress = "0x032f580aFFE7a5f17025fAF83c13B4277A880532", r.inHinkalAddress = d.getInHinkalAddress(r.interactionAddress)), i === "v1x1") {
|
|
90
90
|
if (m.interactionAddress = r.interactionAddress, d.getInHinkalAddress(m.interactionAddress) !== r.inHinkalAddress)
|
|
91
91
|
throw new Error("inHinkalAddress mismatch");
|
|
92
|
-
m.externalApprovalAddresses = r?.useApprovalUtxoData?.map(({ externalApprovalAddresses: e }) => e) ?? Array(
|
|
92
|
+
m.externalApprovalAddresses = r?.useApprovalUtxoData?.map(({ externalApprovalAddresses: e }) => e) ?? Array(T).fill([A, A, A]);
|
|
93
93
|
}
|
|
94
|
-
f || (f =
|
|
95
|
-
const
|
|
96
|
-
p || (p =
|
|
97
|
-
|
|
94
|
+
f || (f = ba(H, l));
|
|
95
|
+
const Z = D(t, a, !0);
|
|
96
|
+
p || (p = ha(Z, r)), m.calldataHash = Ha(
|
|
97
|
+
i,
|
|
98
|
+
O,
|
|
99
|
+
z,
|
|
98
100
|
u,
|
|
99
|
-
P,
|
|
100
|
-
F,
|
|
101
|
-
K,
|
|
102
101
|
B,
|
|
102
|
+
v,
|
|
103
103
|
w,
|
|
104
104
|
H,
|
|
105
105
|
void 0,
|
|
@@ -107,59 +107,59 @@ const mt = async (n, q, j, l, h, t, a, d, D, G, T, J, Q, P = A, o = ca.localhost
|
|
|
107
107
|
s,
|
|
108
108
|
r,
|
|
109
109
|
f,
|
|
110
|
-
|
|
110
|
+
W
|
|
111
111
|
);
|
|
112
|
-
const
|
|
113
|
-
outTimeStamp:
|
|
114
|
-
rootHashAccessToken:
|
|
112
|
+
const $ = {
|
|
113
|
+
outTimeStamp: q(),
|
|
114
|
+
rootHashAccessToken: M,
|
|
115
115
|
calldataHash: m.calldataHash,
|
|
116
116
|
shieldedPrivateKey: S,
|
|
117
|
-
accessTokenSiblings:
|
|
118
|
-
accessTokenSiblingSides:
|
|
119
|
-
messageSeed:
|
|
120
|
-
}, { zkCallData: ma } = await
|
|
121
|
-
|
|
117
|
+
accessTokenSiblings: N,
|
|
118
|
+
accessTokenSiblingSides: P,
|
|
119
|
+
messageSeed: C
|
|
120
|
+
}, { zkCallData: ma } = await za(
|
|
121
|
+
i,
|
|
122
122
|
o,
|
|
123
123
|
g,
|
|
124
|
-
g === "swapperMWMin0" ?
|
|
125
|
-
|
|
126
|
-
), ra =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
N,
|
|
130
|
-
I,
|
|
124
|
+
g === "swapperMWMin0" ? $ : m,
|
|
125
|
+
X
|
|
126
|
+
), ra = wa(E, S), na = await ka(
|
|
127
|
+
i,
|
|
128
|
+
F,
|
|
131
129
|
y,
|
|
132
|
-
|
|
130
|
+
R,
|
|
131
|
+
M,
|
|
132
|
+
Z,
|
|
133
133
|
l,
|
|
134
134
|
t,
|
|
135
135
|
a,
|
|
136
136
|
w,
|
|
137
137
|
H,
|
|
138
|
-
|
|
139
|
-
K,
|
|
140
|
-
F,
|
|
138
|
+
O,
|
|
141
139
|
B,
|
|
142
|
-
|
|
140
|
+
u,
|
|
141
|
+
v,
|
|
142
|
+
z,
|
|
143
143
|
m.calldataHash,
|
|
144
144
|
h,
|
|
145
145
|
ra,
|
|
146
146
|
s,
|
|
147
147
|
Ta,
|
|
148
|
-
g === "swapperMWMin0" ?
|
|
148
|
+
g === "swapperMWMin0" ? $.outTimeStamp : m.outTimeStamp,
|
|
149
149
|
// although these variables seem to contain the same value, there can actually be a single second difference if the timing is unlucky
|
|
150
150
|
r,
|
|
151
151
|
p,
|
|
152
152
|
f,
|
|
153
|
-
|
|
154
|
-
),
|
|
153
|
+
W
|
|
154
|
+
), ia = {
|
|
155
155
|
tokenNumber: t.length,
|
|
156
156
|
nullifierAmount: t.length > 0 ? t[0].length : 0,
|
|
157
157
|
outputAmount: a.length > 0 ? a[0].length : 0
|
|
158
158
|
}, oa = await Ca(
|
|
159
159
|
o,
|
|
160
|
-
c
|
|
160
|
+
c
|
|
161
161
|
);
|
|
162
|
-
return { zkCallData: ma, circomData:
|
|
162
|
+
return { zkCallData: ma, circomData: na, dimData: ia, encryptedOutputs: w, authorizationData: oa };
|
|
163
163
|
};
|
|
164
164
|
export {
|
|
165
165
|
mt as constructEmporiumProof
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("../../error-handling/error-codes.constants.cjs");require("../../data-structures/crypto-keys/keys.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("../../error-handling/error-codes.constants.cjs");require("../../data-structures/crypto-keys/keys.cjs");const re=require("../../constants/chains.constants.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../../data-structures/http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");require("../../constants/token-data/index.cjs");const i=require("@solana/web3.js"),o=require("../pre-transaction/solana.cjs");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("@coral-xyz/anchor");require("buffer");const ne=require("../utils/solanaMint.utils.cjs"),ae=require("./common.snarkjs.cjs"),oe=require("../../data-structures/Hinkal/hinkalCheckSolanaTokenRegistry.cjs"),ie=require("./generateZkProof.cjs"),ce=require("../../webworker/worker.registry.cjs"),se=require("../../webworker/performTaskWithWorker.cjs"),me=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),ue=require("../pre-transaction/getSolanaCalldataHash.cjs"),le=require("./getMerkleTreeSiblingsAndRootHashes.cjs"),pe=async(q,k,S,d,c,f,s,r,n,P,b,h,y,T,a,A,m=re.chainIds.solanaLocalnet,C=!1,B=r.map(()=>!1),I=0n,w=[],K=[],H=!0)=>{const u="v1x1",_=new i.PublicKey(y),R=new i.PublicKey(T),W=c.getShieldedPrivateKey(),l=s.map(e=>ne.formatMintAddress(e)),Z=l.map(e=>e.mintAccountPart1),v=l.map(e=>e.mintAccountPart2),z=ue.getSolanaCalldataHash(a,_,R,A,b,h,w,K),M=`${a.tokenNumber}x${a.nullifierAmount}x${a.outputAmount}`,p=ae.calcAmountChanges(r,n),L=await oe.hinkalCheckSolanaTokenRegistry(f,new i.PublicKey(k),s,p),g=r.map(e=>e.map(t=>t.getConstructableParams())),{inCommitmentSiblings:N,inCommitmentSiblingSides:$,accessTokenSiblings:j,accessTokenSiblingSides:D,rootHashHinkal:V,rootHashAccessToken:E}=await le.getMerkleTreeSiblingsAndRootHashes(m,c,g,C,L,S,d,H),F=await se.performTaskWithWorker({type:ce.WorkerVariant.ZKProof,payload:{type:me.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:g,onChainCreation:B,proverVersion:u}}}),O={rootHashHinkal:V,shieldedPrivateKey:W,rootHashAccessToken:E,accessTokenSiblings:j,accessTokenSiblingSides:D,mintAccountPart1:Z,mintAccountPart2:v,inAmounts:r.map(e=>e.map(t=>t.amount)),inTimeStamps:r.map(e=>e.map(t=>t.timeStamp)),inRandomizations:r.map(e=>e.map(t=>t.randomization)),inNullifiers:F,inCommitmentSiblings:N,inCommitmentSiblingSides:$,outAmounts:n.map(e=>e.map(t=>t.amount.toString())),outTimeStamp:BigInt(n[0][0].timeStamp),outPublicKeys:n.map(e=>e.map(t=>t.getStealthAddress())),extraRandomization:P,amountChanges:p,outCommitments:n.map(e=>e.map(t=>t.amount===0n?0n:t.getCommitment())),calldataHash:z,swapperAccountSalt:I},{publicSignals:G,zkCallData:J}=await ie.generateZkProof(u,m,`basicSolana${M}`,O,q),[Q,X,Y]=J,x=Q.map(BigInt).map(o.encodeToByte32Array).flat(),U=X.flat().map(BigInt).map(o.encodeToByte32Array).flat(),ee=Y.map(BigInt).map(o.encodeToByte32Array).flat(),te=G.map(BigInt).map(o.encodeToByte32Array);return{proofAArr:x,proofBArr:U,proofCArr:ee,publicInputsArr:te}};exports.constructSolanaZkProof=pe;
|
|
@@ -15,7 +15,11 @@ import "../../constants/token-data/index.mjs";
|
|
|
15
15
|
import { PublicKey as r } from "@solana/web3.js";
|
|
16
16
|
import { encodeToByte32Array as n } from "../pre-transaction/solana.mjs";
|
|
17
17
|
import "@solana/spl-token";
|
|
18
|
+
import "ethers-v6h";
|
|
19
|
+
import "tweetnacl";
|
|
20
|
+
import "bs58";
|
|
18
21
|
import "@coral-xyz/anchor";
|
|
22
|
+
import "buffer";
|
|
19
23
|
import { formatMintAddress as at } from "../utils/solanaMint.utils.mjs";
|
|
20
24
|
import { calcAmountChanges as it } from "./common.snarkjs.mjs";
|
|
21
25
|
import { hinkalCheckSolanaTokenRegistry as nt } from "../../data-structures/Hinkal/hinkalCheckSolanaTokenRegistry.mjs";
|
|
@@ -25,7 +29,7 @@ import { performTaskWithWorker as pt } from "../../webworker/performTaskWithWork
|
|
|
25
29
|
import { ZKProofWorkerActionType as ct } from "../../webworker/zkProofWorker/zkProofWorker.types.mjs";
|
|
26
30
|
import { getSolanaCalldataHash as st } from "../pre-transaction/getSolanaCalldataHash.mjs";
|
|
27
31
|
import { getMerkleTreeSiblingsAndRootHashes as lt } from "./getMerkleTreeSiblingsAndRootHashes.mjs";
|
|
28
|
-
const
|
|
32
|
+
const Et = async (u, S, k, d, e, P, p, m, a, b, h, A, C, I, i, T, c = mt.solanaLocalnet, B = !1, w = m.map(() => !1), K = 0n, H = [], y = [], R = !0) => {
|
|
29
33
|
const s = "v1x1", v = new r(C), z = new r(I), L = e.getShieldedPrivateKey(), l = p.map((t) => at(t)), N = l.map((t) => t.mintAccountPart1), W = l.map((t) => t.mintAccountPart2), Z = st(
|
|
30
34
|
i,
|
|
31
35
|
v,
|
|
@@ -96,5 +100,5 @@ const Mt = async (u, S, k, d, e, P, p, m, a, b, h, A, C, I, i, T, c = mt.solanaL
|
|
|
96
100
|
return { proofAArr: x, proofBArr: U, proofCArr: tt, publicInputsArr: ot };
|
|
97
101
|
};
|
|
98
102
|
export {
|
|
99
|
-
|
|
103
|
+
Et as constructSolanaZkProof
|
|
100
104
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@coral-xyz/anchor"),o=require("buffer"),i=e=>{if(e.length!==32||e.some(r=>!Number.isInteger(r)||r<0||r>=256))throw new Error("invalid bytes32 value");return e.reduce((r,t)=>r*256n+BigInt(t),0n)},c=e=>[...new n.BN(e.toString()).toArrayLike(o.Buffer,"be",32)];exports.convertBigIntToBytes32=c;exports.convertBytes32ToBigInt=i;
|