@hinkal/common 0.2.17 → 0.2.19
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 +8 -13
- package/API/API.mjs +86 -94
- package/API/admin-calls.cjs +1 -1
- package/API/admin-calls.d.ts +1 -1
- package/API/admin-calls.mjs +4 -4
- package/API/callLifiAPI.cjs +1 -1
- package/API/callLifiAPI.d.ts +1 -1
- package/API/callLifiAPI.mjs +5 -5
- package/API/callMonitor.cjs +1 -1
- package/API/callMonitor.d.ts +1 -1
- package/API/callMonitor.mjs +7 -7
- package/API/callOdosAPI.cjs +1 -1
- package/API/callOdosAPI.mjs +11 -11
- package/API/callOkxAPI.cjs +1 -1
- package/API/callOkxAPI.d.ts +1 -1
- package/API/callOkxAPI.mjs +5 -5
- package/API/callOneInchAPI.cjs +1 -1
- package/API/callOneInchAPI.mjs +10 -11
- package/API/callRelayer.cjs +1 -1
- package/API/callRelayer.d.ts +6 -3
- package/API/callRelayer.mjs +11 -11
- package/API/checkRisk.cjs +1 -1
- package/API/checkRisk.d.ts +1 -1
- package/API/checkRisk.mjs +4 -4
- package/API/fetchCommitmentsCache.cjs +1 -1
- package/API/fetchCommitmentsCache.mjs +9 -9
- package/API/get-token-data.cjs +1 -1
- package/API/get-token-data.d.ts +1 -1
- package/API/get-token-data.mjs +5 -5
- package/API/get-token-price-chart-data.cjs +1 -0
- package/API/get-token-price-chart-data.d.ts +16 -0
- package/API/get-token-price-chart-data.mjs +13 -0
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.mjs +9 -9
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.d.ts +3 -3
- package/API/getServerURL.mjs +51 -67
- package/API/getTokenPrice.cjs +1 -1
- package/API/getTokenPrice.d.ts +5 -0
- package/API/getTokenPrice.mjs +14 -7
- package/API/getWebsiteURL.d.ts +1 -1
- package/API/index.d.ts +0 -3
- package/API/is-tx-stateless.cjs +1 -1
- package/API/is-tx-stateless.d.ts +1 -1
- package/API/is-tx-stateless.mjs +10 -12
- package/API/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +4 -8
- package/API/kycCalls.mjs +23 -26
- package/API/onrampCalls.cjs +1 -0
- package/API/onrampCalls.d.ts +20 -0
- package/API/onrampCalls.mjs +15 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +2 -2
- package/API/proxyAccountsCalls.mjs +19 -19
- package/API/relayCalls.cjs +1 -1
- package/API/relayCalls.mjs +4 -4
- package/API/scheduled-transactions-calls.cjs +1 -1
- package/API/scheduled-transactions-calls.d.ts +1 -1
- package/API/scheduled-transactions-calls.mjs +4 -4
- package/API/simulate-batch-tx.cjs +1 -1
- package/API/simulate-batch-tx.d.ts +2 -2
- package/API/simulate-batch-tx.mjs +7 -6
- package/API/solana-calls.cjs +1 -1
- package/API/solana-calls.d.ts +6 -3
- package/API/solana-calls.mjs +15 -15
- package/API/token-calls.cjs +1 -1
- package/API/token-calls.mjs +6 -5
- package/API/unspent-utxos-calls.cjs +1 -1
- package/API/unspent-utxos-calls.d.ts +1 -1
- package/API/unspent-utxos-calls.mjs +15 -18
- package/README.md +237 -61
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.d.ts +0 -1
- package/constants/addresses.constants.mjs +7 -8
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +0 -5
- package/constants/chains.constants.mjs +21 -26
- package/constants/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.d.ts +1 -0
- package/constants/coingecko.constants.mjs +11 -10
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +34 -41
- package/constants/function-signatures.constants.cjs +1 -1
- package/constants/function-signatures.constants.d.ts +0 -1
- package/constants/function-signatures.constants.mjs +3 -4
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +2 -0
- package/constants/mediaUrls.constants.mjs +3 -1
- package/constants/mystery-boxes.constants.d.ts +0 -0
- package/constants/permit2.constants.cjs +1 -1
- package/constants/permit2.constants.d.ts +0 -1
- package/constants/permit2.constants.mjs +10 -11
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +14 -122
- package/constants/server.constants.mjs +44 -152
- package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistry.json.mjs +0 -24
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +0 -24
- package/constants/token-data/index.d.ts +32 -88
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +0 -26
- package/constants/token-data/popularTokens.constants.cjs +1 -1
- package/constants/token-data/popularTokens.constants.mjs +0 -1
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +36 -13
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +34 -49
- package/data-structures/Hinkal/Hinkal.mjs +238 -301
- package/data-structures/Hinkal/IHinkal.d.ts +33 -48
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +42 -42
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -23
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +9 -9
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +95 -93
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +147 -133
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +1 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +107 -115
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +36 -34
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +34 -33
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.d.ts +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +26 -24
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +8 -9
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +4 -3
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +86 -97
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +146 -146
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +2 -3
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +38 -38
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +57 -56
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +59 -58
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +83 -79
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +49 -48
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +67 -64
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +75 -87
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.d.ts +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +55 -58
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +80 -82
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.d.ts +2 -2
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +87 -90
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +105 -53
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.mjs +7 -7
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +8 -8
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +10 -10
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +25 -40
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +10 -11
- package/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
- package/data-structures/TokenDBs/token-visibility-db.mjs +22 -36
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.d.ts +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +14 -14
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +1 -0
- package/data-structures/event-service/evm/AbstractEventService.mjs +7 -4
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +0 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +3 -4
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +3 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +17 -14
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +1 -0
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +9 -6
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +0 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +1 -2
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +3 -2
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +42 -45
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +8 -13
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +3 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +3 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +2 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +3 -4
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +1 -7
- package/data-structures/utxo/Utxo.mjs +26 -36
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +3 -0
- package/error-handling/error-codes.constants.mjs +5 -2
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +21 -27
- package/error-handling/index.d.ts +0 -1
- package/functions/index.d.ts +0 -1
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +18 -17
- package/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/functions/pre-transaction/constructAdminData.d.ts +2 -2
- package/functions/pre-transaction/constructAdminData.mjs +12 -18
- package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/functions/pre-transaction/getExternalSwapAddress.d.ts +1 -2
- package/functions/pre-transaction/getExternalSwapAddress.mjs +8 -8
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +22 -30
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +21 -36
- package/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.d.ts +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +17 -17
- package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +1 -9
- package/functions/pre-transaction/outputApprovalDataProcessing.mjs +19 -34
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +4 -4
- package/functions/pre-transaction/solana-public-signals.cjs +1 -1
- package/functions/pre-transaction/solana-public-signals.d.ts +1 -0
- package/functions/pre-transaction/solana-public-signals.mjs +29 -26
- package/functions/pre-transaction/solana.cjs +1 -1
- package/functions/pre-transaction/solana.d.ts +2 -1
- package/functions/pre-transaction/solana.mjs +60 -51
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +3 -5
- package/functions/private-wallet/emporium.helpers.mjs +95 -135
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.d.ts +1 -4
- package/functions/private-wallet/emporium.swap.helpers.mjs +100 -102
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.d.ts +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +64 -64
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +2 -2
- package/functions/snarkjs/constructEmporiumProof.mjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +2 -3
- package/functions/snarkjs/constructGeneralZkProof.mjs +117 -121
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.d.ts +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +54 -59
- package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
- package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +11 -10
- package/functions/snarkjs/generateCircomData.d.ts +1 -1
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.d.ts +1 -0
- package/functions/utils/addresses.mjs +13 -12
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +2 -2
- package/functions/utils/enum.utils.cjs +1 -0
- package/functions/utils/enum.utils.mjs +14 -0
- package/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/functions/utils/erc20tokenFunctions.d.ts +0 -1
- package/functions/utils/erc20tokenFunctions.mjs +22 -29
- package/functions/utils/get-hinkal-approvals.cjs +1 -1
- package/functions/utils/get-hinkal-approvals.d.ts +1 -1
- package/functions/utils/get-hinkal-approvals.mjs +16 -16
- package/functions/utils/getDataFromTransaction.d.ts +3 -3
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +11 -11
- package/functions/utils/involves-permit2-op.cjs +1 -1
- package/functions/utils/involves-permit2-op.d.ts +0 -1
- package/functions/utils/involves-permit2-op.mjs +4 -6
- package/functions/utils/mutexes.utils.cjs +1 -1
- package/functions/utils/mutexes.utils.d.ts +1 -1
- package/functions/utils/mutexes.utils.mjs +3 -3
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +8 -23
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +0 -6
- package/functions/utils/prepareHinkal.mjs +41 -60
- package/functions/utils/token-check.utils.cjs +1 -1
- package/functions/utils/token-check.utils.d.ts +3 -0
- package/functions/utils/token-check.utils.mjs +18 -7
- package/functions/utils/upToDateState.cjs +1 -1
- package/functions/utils/upToDateState.d.ts +1 -1
- package/functions/utils/upToDateState.mjs +4 -4
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +1 -16
- package/functions/utils/walletBalances.utils.mjs +4 -35
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.d.ts +3 -4
- package/functions/web3/events/getApprovedBalance.mjs +39 -44
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.d.ts +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.mjs +114 -121
- package/functions/web3/events/getInputUtxosEnclave.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.mjs +71 -70
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.mjs +7 -7
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +7 -7
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +1 -6
- package/functions/web3/functionCalls/accessTokenCalls.mjs +12 -21
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +71 -63
- package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.mjs +6 -6
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.d.ts +1 -2
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +10 -10
- package/functions/web3/functionCalls/recoverTransactionFromError.cjs +1 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +2 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.mjs +23 -0
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +45 -36
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +44 -43
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.d.ts +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +6 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +8 -8
- package/functions/web3/lifiAPI.cjs +1 -1
- package/functions/web3/lifiAPI.d.ts +1 -1
- package/functions/web3/lifiAPI.mjs +12 -12
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -19
- package/functions/web3/okxAPI.cjs +1 -1
- package/functions/web3/okxAPI.mjs +22 -22
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +7 -20
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +38 -56
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +22 -34
- package/index.cjs +1 -1
- package/index.mjs +937 -967
- package/package.json +2 -2
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +10 -17
- package/providers/EthersProviderAdapter.mjs +48 -76
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +7 -11
- package/providers/SolanaProviderAdapter.mjs +16 -31
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +11 -17
- package/providers/WagmiProviderAdapter.mjs +86 -117
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +6 -7
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +5 -5
- package/types/TransactionSimulator.types.d.ts +2 -9
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +3 -7
- package/types/admin.types.mjs +2 -2
- package/types/balances.types.d.ts +0 -1
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +2 -3
- package/types/cache.types.mjs +1 -1
- package/types/coingecko.types.d.ts +5 -0
- package/types/ethereum-network.types.cjs +1 -1
- package/types/ethereum-network.types.d.ts +1 -8
- package/types/ethereum-network.types.mjs +1 -1
- package/types/external-action.types.cjs +1 -1
- package/types/external-action.types.d.ts +0 -1
- package/types/external-action.types.mjs +1 -1
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +1 -7
- package/types/hinkal.types.mjs +22 -23
- package/types/index.d.ts +1 -3
- package/types/onramp.types.cjs +1 -0
- package/types/onramp.types.d.ts +58 -0
- package/types/onramp.types.mjs +4 -0
- package/types/proxy.types.d.ts +1 -0
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +8 -39
- package/types/sandbox.types.mjs +2 -2
- package/types/session.types.d.ts +2 -0
- package/types/solana.types.d.ts +3 -0
- package/types/token-prices.types.cjs +1 -1
- package/types/token-prices.types.d.ts +7 -0
- package/types/token-prices.types.mjs +4 -2
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +6 -4
- package/types/transactions.types.mjs +4 -3
- 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/API/ai-calls.cjs +0 -1
- package/API/ai-calls.d.ts +0 -17
- package/API/ai-calls.mjs +0 -21
- package/API/duneAPI.cjs +0 -1
- package/API/duneAPI.d.ts +0 -11
- package/API/duneAPI.mjs +0 -25
- package/API/getBridgeProtocols.cjs +0 -1
- package/API/getBridgeProtocols.d.ts +0 -7
- package/API/getBridgeProtocols.mjs +0 -8
- package/API/getLifiStatus.cjs +0 -1
- package/API/getLifiStatus.d.ts +0 -24
- package/API/getLifiStatus.mjs +0 -15
- package/API/getRelayerURL.cjs +0 -1
- package/API/getRelayerURL.d.ts +0 -1
- package/API/getRelayerURL.mjs +0 -10
- package/API/passwordCalls.cjs +0 -1
- package/API/passwordCalls.d.ts +0 -9
- package/API/passwordCalls.mjs +0 -13
- package/API/restoreSnapshots.cjs +0 -1
- package/API/restoreSnapshots.d.ts +0 -1
- package/API/restoreSnapshots.mjs +0 -10
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +0 -1
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +0 -7
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +0 -42
- package/data-structures/Hinkal/hinkalActionStake.d.ts +0 -3
- package/data-structures/Hinkal/hinkalApprove.cjs +0 -1
- package/data-structures/Hinkal/hinkalApprove.d.ts +0 -3
- package/data-structures/Hinkal/hinkalApprove.mjs +0 -115
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +0 -1
- package/data-structures/Hinkal/hinkalInsideTransact.d.ts +0 -4
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +0 -121
- package/error-handling/handleErrorRestore.cjs +0 -1
- package/error-handling/handleErrorRestore.d.ts +0 -2
- package/error-handling/handleErrorRestore.mjs +0 -11
- package/functions/staking/index.cjs +0 -1
- package/functions/staking/index.d.ts +0 -11
- package/functions/staking/index.mjs +0 -42
- package/functions/utils/replaceAddressInCalldata.cjs +0 -1
- package/functions/utils/replaceAddressInCalldata.d.ts +0 -1
- package/functions/utils/replaceAddressInCalldata.mjs +0 -7
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +0 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +0 -5
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +0 -32
- package/types/bridging.types.d.ts +0 -29
- package/types/duneAPI.types.d.ts +0 -9
- package/types/hinkal.stake.types.cjs +0 -1
- package/types/hinkal.stake.types.d.ts +0 -11
- package/types/hinkal.stake.types.mjs +0 -4
|
@@ -1,157 +1,155 @@
|
|
|
1
|
-
import { BigNumber as K, ethers as
|
|
2
|
-
import { emporiumOp as u, createApproveEmporiumOp as
|
|
1
|
+
import { BigNumber as K, ethers as _ } from "ethers";
|
|
2
|
+
import { emporiumOp as u, createApproveEmporiumOp as F } from "./emporium.helpers.mjs";
|
|
3
3
|
import { NATIVE_TOKEN_WRAPPER_ADDRESSES as T, WRAPPER_TOKEN_EXCHANGE_ADDRESSES as q, SWAP_FEE_TAKER_ADDRESSES as V } from "../../constants/addresses.constants.mjs";
|
|
4
|
-
import { ExternalActionId as
|
|
4
|
+
import { ExternalActionId as h } from "../../types/external-action.types.mjs";
|
|
5
5
|
import { ContractType as g } from "../../types/ethereum-network.types.mjs";
|
|
6
6
|
import { getExternalSwapAddress as X } from "../pre-transaction/getExternalSwapAddress.mjs";
|
|
7
7
|
import { replaceAllInstances as H } from "../utils/string.utils.mjs";
|
|
8
|
-
import { zeroAddress as
|
|
8
|
+
import { zeroAddress as S, HINKAL_SWAP_VARIABLE_RATE as N } from "../../constants/protocol.constants.mjs";
|
|
9
9
|
import "../../constants/token-data/index.mjs";
|
|
10
10
|
import { caseInsensitiveEqual as M } from "../utils/caseInsensitive.utils.mjs";
|
|
11
|
-
import { Logger as
|
|
12
|
-
import { getERC20Registry as
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
tokenIn:
|
|
16
|
-
tokenOut:
|
|
17
|
-
fee:
|
|
18
|
-
recipient:
|
|
19
|
-
amountIn:
|
|
11
|
+
import { Logger as v } from "../../error-handling/logger.mjs";
|
|
12
|
+
import { getERC20Registry as z } from "../../constants/token-data/ERC20Registry.mjs";
|
|
13
|
+
const G = (c, t, r, a, i, n, f = !1) => {
|
|
14
|
+
const o = K.from(n).toBigInt(), e = {
|
|
15
|
+
tokenIn: t,
|
|
16
|
+
tokenOut: a,
|
|
17
|
+
fee: o,
|
|
18
|
+
recipient: i,
|
|
19
|
+
amountIn: r,
|
|
20
20
|
amountOutMinimum: 0,
|
|
21
21
|
sqrtPriceLimitX96: 0
|
|
22
|
-
},
|
|
22
|
+
}, w = [
|
|
23
23
|
"function exactInputSingle(tuple(address tokenIn,address tokenOut,uint24 fee,address recipient,uint256 amountIn,uint256 amountOutMinimum,uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)"
|
|
24
|
-
],
|
|
24
|
+
], E = new _.Contract(c, w);
|
|
25
25
|
return u({
|
|
26
|
-
contract:
|
|
26
|
+
contract: E,
|
|
27
27
|
func: "exactInputSingle",
|
|
28
|
-
args: [
|
|
29
|
-
invokeWallet:
|
|
28
|
+
args: [e],
|
|
29
|
+
invokeWallet: f
|
|
30
30
|
});
|
|
31
|
-
},
|
|
32
|
-
const
|
|
31
|
+
}, U = (c, t, r, a, i, n, f = !1) => {
|
|
32
|
+
const o = X(c, t), e = H(a, o.slice(2), i.slice(2));
|
|
33
33
|
return u({
|
|
34
|
-
contract:
|
|
35
|
-
callDataString:
|
|
36
|
-
value:
|
|
37
|
-
invokeWallet:
|
|
34
|
+
contract: r,
|
|
35
|
+
callDataString: e,
|
|
36
|
+
value: n,
|
|
37
|
+
invokeWallet: f
|
|
38
38
|
});
|
|
39
|
-
},
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
}, L = async (t,
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
39
|
+
}, I = (c, t) => {
|
|
40
|
+
const a = z(t).find((i) => i.symbol === "USDT");
|
|
41
|
+
return a ? M(c, a.erc20TokenAddress) : !1;
|
|
42
|
+
}, L = async (c, t, r, a, i, n) => {
|
|
43
|
+
const f = r.address;
|
|
44
|
+
if (I(f, c))
|
|
45
45
|
try {
|
|
46
|
-
(await
|
|
47
|
-
} catch (
|
|
48
|
-
|
|
46
|
+
(await r.allowance(a, i)).toBigInt() > 0n && t.push(F(r, i, 0n, n));
|
|
47
|
+
} catch (o) {
|
|
48
|
+
v.error("Error in nullifyUsdtApprovalIfNeeded", o);
|
|
49
49
|
}
|
|
50
|
-
},
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
50
|
+
}, l = async (c, t, r, a, i, n, f, o) => {
|
|
51
|
+
if (r !== S) {
|
|
52
|
+
const e = V[t], w = c.getContractWithFetcher(t, g.ERC20Contract, r), E = await w.balanceOf(a);
|
|
53
53
|
await L(
|
|
54
54
|
t,
|
|
55
55
|
n,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
), n.push(
|
|
61
|
-
const
|
|
56
|
+
w,
|
|
57
|
+
a,
|
|
58
|
+
e,
|
|
59
|
+
f
|
|
60
|
+
), n.push(F(w, e, 2n ** 256n - 1n, f));
|
|
61
|
+
const b = [
|
|
62
62
|
"function takeSwapFee(address token, uint256 beforeBalance, uint256 variableRate, address relay) external payable"
|
|
63
|
-
],
|
|
63
|
+
], s = new _.Contract(e, b), C = i;
|
|
64
64
|
n.push(
|
|
65
65
|
u({
|
|
66
|
-
contract:
|
|
66
|
+
contract: s,
|
|
67
67
|
func: "takeSwapFee",
|
|
68
|
-
args: [
|
|
69
|
-
invokeWallet:
|
|
68
|
+
args: [r, E, N, C],
|
|
69
|
+
invokeWallet: f
|
|
70
70
|
})
|
|
71
71
|
);
|
|
72
72
|
} else {
|
|
73
|
-
const
|
|
73
|
+
const e = i;
|
|
74
74
|
n.push(
|
|
75
75
|
u({
|
|
76
|
-
contract:
|
|
77
|
-
value: o *
|
|
78
|
-
invokeWallet:
|
|
76
|
+
contract: e,
|
|
77
|
+
value: o * N / 10000n,
|
|
78
|
+
invokeWallet: f
|
|
79
79
|
})
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
|
-
},
|
|
83
|
-
const
|
|
84
|
-
let
|
|
85
|
-
if (
|
|
86
|
-
if (n !==
|
|
87
|
-
const
|
|
88
|
-
|
|
82
|
+
}, nt = async (c, t, r, a, i, n, f, o, e, w, E, b, s = !1) => {
|
|
83
|
+
const C = f < 0n ? -1n * f : f, m = [], R = T[t];
|
|
84
|
+
let B = !1, O;
|
|
85
|
+
if (r === h.OneInch || r === h.Lifi) {
|
|
86
|
+
if (n !== S) {
|
|
87
|
+
const y = c.getContractWithFetcher(t, g.ERC20Contract, n);
|
|
88
|
+
m.push(F(y, a, C, s));
|
|
89
89
|
}
|
|
90
|
-
let
|
|
91
|
-
n ===
|
|
92
|
-
const
|
|
93
|
-
return
|
|
90
|
+
let p = 0n;
|
|
91
|
+
n === S && (p += C), o && e === S && o < 0n && (p += -1n * o);
|
|
92
|
+
const D = p > 0n ? p : void 0;
|
|
93
|
+
return O = U(
|
|
94
94
|
t,
|
|
95
|
+
r,
|
|
95
96
|
a,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
), p.push(R), (a === O.OneInch || C && a === O.Lifi) && r && o !== void 0 && await U(t, r, m, h, p, f, o), p;
|
|
97
|
+
i,
|
|
98
|
+
E,
|
|
99
|
+
D,
|
|
100
|
+
s
|
|
101
|
+
), m.push(O), (r === h.OneInch || w && r === h.Lifi) && e && o !== void 0 && await l(c, t, e, E, b, m, s, o), m;
|
|
102
102
|
}
|
|
103
|
-
if (!
|
|
103
|
+
if (!e || !o)
|
|
104
104
|
throw Error("There should be output token for UniSwap and Odos");
|
|
105
|
-
if (n ===
|
|
106
|
-
const
|
|
107
|
-
|
|
105
|
+
if (n === S) {
|
|
106
|
+
const p = c.getContractWithFetcher(t, g.ERC20Contract, R);
|
|
107
|
+
m.push(
|
|
108
108
|
u({
|
|
109
|
-
contract:
|
|
109
|
+
contract: p,
|
|
110
110
|
func: "deposit",
|
|
111
|
-
value:
|
|
112
|
-
invokeWallet:
|
|
111
|
+
value: C,
|
|
112
|
+
invokeWallet: s
|
|
113
113
|
})
|
|
114
|
-
), n =
|
|
114
|
+
), n = R;
|
|
115
115
|
}
|
|
116
|
-
let
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
await L(t,
|
|
116
|
+
let P = 0n;
|
|
117
|
+
if (e === S && (e = R, B = !0, P = await c.getContractWithFetcher(t, g.ERC20Contract, R).balanceOf(E)), n !== S) {
|
|
118
|
+
const p = c.getContractWithFetcher(t, g.ERC20Contract, n);
|
|
119
|
+
await L(t, m, p, E, a, s), m.push(F(p, a, C, s));
|
|
120
120
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
121
|
+
if (r === h.Uniswap ? O = G(
|
|
122
|
+
a,
|
|
123
123
|
n,
|
|
124
|
-
|
|
125
|
-
r,
|
|
126
|
-
m,
|
|
124
|
+
C,
|
|
127
125
|
e,
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
E,
|
|
127
|
+
i,
|
|
128
|
+
s
|
|
129
|
+
) : O = U(
|
|
130
130
|
t,
|
|
131
|
+
r,
|
|
131
132
|
a,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
m,
|
|
133
|
+
i,
|
|
134
|
+
E,
|
|
135
135
|
void 0,
|
|
136
|
-
|
|
137
|
-
),
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
136
|
+
s
|
|
137
|
+
), m.push(O), await l(c, t, e, E, b, m, s, o), B) {
|
|
138
|
+
const p = q[t], D = c.getContractWithFetcher(t, g.ERC20Contract, R);
|
|
139
|
+
m.push(F(D, p, 2n ** 256n - 1n, s));
|
|
140
|
+
const y = ["function withdrawBalanceDifference(uint256 beforeBalance) external"], x = new _.Contract(p, y);
|
|
141
|
+
m.push(
|
|
142
142
|
u({
|
|
143
143
|
contract: x,
|
|
144
144
|
func: "withdrawBalanceDifference",
|
|
145
|
-
args: [
|
|
146
|
-
invokeWallet:
|
|
145
|
+
args: [P],
|
|
146
|
+
invokeWallet: s
|
|
147
147
|
})
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
|
-
return
|
|
150
|
+
return m;
|
|
151
151
|
};
|
|
152
152
|
export {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
rt as createSwapToEmporiumOps,
|
|
156
|
-
L as nullifyUsdtApprovalIfNeeded
|
|
153
|
+
G as createSwapToEmporiumOpForUniswap,
|
|
154
|
+
nt as createSwapToEmporiumOps
|
|
157
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),d=require("../../constants/protocol.constants.cjs"),V=require("../../constants/conversion.constants.cjs"),S=require("../../data-structures/crypto-keys/keys.cjs"),E=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),F=require("../../types/circom-data.types.cjs"),f=require("../utils/external-action.utils.cjs"),u=require("../../types/hinkal.types.cjs"),T=require("../utils/amounts.utils.cjs"),P=require("./getOriginalSender.cjs"),L=(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),d=require("../../constants/protocol.constants.cjs"),V=require("../../constants/conversion.constants.cjs"),S=require("../../data-structures/crypto-keys/keys.cjs"),E=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),F=require("../../types/circom-data.types.cjs"),f=require("../utils/external-action.utils.cjs"),u=require("../../types/hinkal.types.cjs"),T=require("../utils/amounts.utils.cjs"),P=require("./getOriginalSender.cjs"),L=(e,s)=>e.map((t,a)=>t.map(n=>s[a]?"0":n.getNullifier())),R=(e,s,t)=>{let a=[];return e==="v1x0"?a=s.map((n,r)=>n.map(l=>t[r]?"0":l.getCommitment())):a=s.map(n=>n.map(r=>r.amount===0n?"0":r.getCommitment())),a},_=(e,s,t=!1)=>{const a=[];for(let n=0;n<e.length;n+=1){let r=0n,l=0n;for(let i=0;i<e[n].length;i+=1)r+=e[n][i].amount;for(let i=0;i<s[n].length;i+=1)l+=s[n][i].amount;l-r<0?t?a.push(l-r):a.push(d.CIRCOM_P+(l-r)):a.push(l-r)}return a},q=e=>e.useApprovalUtxoData.reduce((s,t)=>[...s,T.calculateBigIntSum(t.approvalChanges)],[]),x=(e,s)=>{const t=q(s),a=s.hinkalLogicAction,n=e.map((r,l)=>a===u.HinkalLogicAction.NONE||a===u.HinkalLogicAction.APPROVE?r+t[l]>=0n?0n:r+t[l]:r>=0n?0n:r);return a===u.HinkalLogicAction.RELEASE_BUFFER?e.forEach((r,l)=>{n[l]=r>0n?-r:r}):a===u.HinkalLogicAction.EXECUTE&&s.executeApprovalChanges.forEach((r,l)=>{n[l]=r+e[l]<0n?r+e[l]:0n}),n},M=e=>{if(e.length===0)return[];const s=[[""]];for(let t=0;t<e.length;t+=1)t>0&&s.push([""]),e[t].forEach((a,n)=>{s[t][n]=`0x${Buffer.from(E.encryptUtxo(a)).toString("hex")}`});return s},z=(e,s)=>{const t=[];for(let n=0;n<e.length;n+=1){t.push([]);for(let r=0;r<e[n].length;r+=1)t[n][r]=s.getSiblingHashesForVerification(BigInt(e[n][r].getCommitment())).map(l=>l.toString())}const a=[];for(let n=0;n<e.length;n+=1){a.push([]);for(let r=0;r<e[n].length;r+=1)a[n][r]=s.getSiblingSides(BigInt(e[n][r].getCommitment())).map(l=>l.toString())}return{inCommitmentSiblings:t,inCommitmentSiblingSides:a}},C=(e,s)=>{const t=s.getSiblingHashesForVerification(BigInt(e)).map(n=>n.toString()),a=s.getSiblingSides(BigInt(e)).map(n=>n.toString());return{accessTokenSiblings:t,accessTokenSiblingSides:a}},W=(e,s)=>C(e.getAccessKey(),s),j=e=>{const s={...e};if(s.amountChanges=e.amountChanges.map(t=>t.toString()),s.calldataHash=e.calldataHash.toString(),s.rootHashAccessToken=e.rootHashAccessToken?.toString(),s.stealthAddressStructure.extraRandomization=e.stealthAddressStructure.extraRandomization.toString(),s.stealthAddressStructure.stealthAddress=e.stealthAddressStructure.stealthAddress.toString(),s.stealthAddressStructure.H0=e.stealthAddressStructure.H0.toString(),s.stealthAddressStructure.H1=e.stealthAddressStructure.H1.toString(),s.rootHashHinkal=e.rootHashHinkal?.toString(),s.externalActionId=e.externalActionId?.toString(),"flatFees"in e){const t=s;return t.flatFees=e.flatFees.map(a=>a.toString()),t}else{const t=s;return t.slippageValues=e.slippageValues.map(a=>a.toString()),t.hinkalLogicArgs.inHinkalAddress=e.hinkalLogicArgs.inHinkalAddress.toString(),t.hinkalLogicArgs.executeApprovalChanges=e.hinkalLogicArgs.executeApprovalChanges.map(a=>a.toString()),t.hinkalLogicArgs.useApprovalUtxoData=e.hinkalLogicArgs.useApprovalUtxoData.map(a=>({approvalChanges:a.approvalChanges.map(n=>n.toString()),externalApprovalAddresses:a.externalApprovalAddresses,conversionInHinkalAddress:a.conversionInHinkalAddress.map(n=>n.toString())})),t.feeStructure.flatFee=e.feeStructure.flatFee.toString(),t.feeStructure.variableRate=e.feeStructure.variableRate.toString(),t}},w=e=>{const s={...e};if(s.amountChanges=e.amountChanges.map(t=>BigInt(t)),s.calldataHash=BigInt(e.calldataHash),s.rootHashAccessToken=BigInt(e.rootHashAccessToken),s.rootHashHinkal=BigInt(e.rootHashHinkal),s.externalActionId=BigInt(e.externalActionId),"flatFees"in e){const t=s;return t.flatFees=e.flatFees.map(a=>BigInt(a)),t}else{const t=s;return t.feeStructure.flatFee=BigInt(e.feeStructure.flatFee),t.feeStructure.variableRate=BigInt(e.feeStructure.variableRate),t.slippageValues=e.slippageValues.map(a=>BigInt(a)),t.hinkalLogicArgs.executeApprovalChanges=e.hinkalLogicArgs.executeApprovalChanges.map(a=>BigInt(a)),t.hinkalLogicArgs.inHinkalAddress=BigInt(e.hinkalLogicArgs.inHinkalAddress),t.hinkalLogicArgs.useApprovalUtxoData=e.hinkalLogicArgs.useApprovalUtxoData.map(a=>({approvalChanges:a.approvalChanges.map(n=>BigInt(n)),externalApprovalAddresses:a.externalApprovalAddresses,conversionInHinkalAddress:a.conversionInHinkalAddress.map(n=>BigInt(n))})),t}},K=(e,s,t,a,n,r,l,i,H,k,b,c,g,m,v)=>{const h=Object.values(H||F.defaultHookData),I=v??P.getOriginalSender(a??d.zeroAddress,t);if(e==="v1x0"){const p=o.ethers.utils.defaultAbiCoder.encode(["uint16","address","address","uint256","bytes","tuple(address, address, bytes, bytes)","bytes[][]","uint256[]"],[s,t,a,typeof n=="bigint"?n:f.getExternalActionIdHash(n),r,h,l,i]);return BigInt(o.ethers.utils.keccak256(p))%d.CIRCOM_P}else{const p=o.ethers.utils.defaultAbiCoder.encode(["uint16","address","address","uint256","bytes"],[s,t,a,typeof n=="bigint"?n:f.getExternalActionIdHash(n),r]),A=o.ethers.utils.defaultAbiCoder.encode(["tuple(address, address, bytes, bytes)","bytes[][]","tuple(address, uint256, uint256)","int256[]","bool[]","tuple(uint256, uint256,int256[],bool, tuple(int256[] approvalChanges, address[] externalApprovalAddresses, uint256[] conversionInHinkalAddress)[])","tuple(uint8 v, bytes32 r, bytes32 s, uint256 accessKey, uint256 nonce, address ethereumAddress)","address"],[h,l,[g.feeToken,g.flatFee,g.variableRate],k,b,[c.hinkalLogicAction,c.inHinkalAddress,c.executeApprovalChanges,c.doPreTxApproval,c.useApprovalUtxoData],m,I]),y=BigInt(o.ethers.utils.keccak256(p)),B=BigInt(o.ethers.utils.keccak256(A)),O=o.ethers.utils.defaultAbiCoder.encode(["uint256","uint256"],[y,B]);return BigInt(o.ethers.utils.keccak256(O))%d.CIRCOM_P}},N=e=>e.startsWith("swapperMO")||e.startsWith("swapperME")?2:e.startsWith("swapperMW")?1:(e.startsWith("swapperMHA"),0),J=(e,s,t,a,n,r)=>{if(e.startsWith("swapperMWMin0"))return 4;const l=N(e);return 10+s.length+t.length+a.flat().length+n.flat().length+l+r+V.APPROVED_UTXO_CONVERSION_COUNT*s.length},U=(e,s)=>{const{h0:t,h1:a}=S.UserKeys.getStealthAddressCompressedPoints(e,s),n=BigInt(S.UserKeys.getStealthAddress(e,s));return{extraRandomization:e,H0:t,H1:a,stealthAddress:n}};exports.buildInNullifiers=L;exports.buildOutCommitments=R;exports.calcAccessTokenSiblingAndSidesFromAccessKey=C;exports.calcAccessTokenSiblingsAndSides=W;exports.calcAmountChanges=_;exports.calcCommitmentsSiblingAndSides=z;exports.calcEncryptedOutputs=M;exports.calcPublicSignalCount=J;exports.calcStealthAddressStructure=U;exports.createCallDataHash=K;exports.deserializeCircomData=w;exports.getSlippageValues=x;exports.serializeCircomData=j;
|
|
@@ -9,7 +9,7 @@ export declare const buildInNullifiers: (inputUtxos: Utxo[][], onChainCreation:
|
|
|
9
9
|
export declare const buildOutCommitments: (proverVersion: ProverVersion, outputUtxos: Utxo[][], onChainCreation: boolean[]) => string[][];
|
|
10
10
|
export declare const calcAmountChanges: (inputUtxos: Utxo[][], outputUtxos: Utxo[][], forCircomData?: boolean) => bigint[];
|
|
11
11
|
export declare const getSlippageValues: (amountChanges: bigint[], hinkalLogicArgs: HinkalLogicArgs) => bigint[];
|
|
12
|
-
export declare const calcEncryptedOutputs: (outputUtxos: Utxo[][]
|
|
12
|
+
export declare const calcEncryptedOutputs: (outputUtxos: Utxo[][]) => string[][];
|
|
13
13
|
export declare const calcCommitmentsSiblingAndSides: (inputUtxos: Utxo[][], merkleTree: MerkleTree<bigint>) => {
|
|
14
14
|
inCommitmentSiblings: string[][][];
|
|
15
15
|
inCommitmentSiblingSides: string[][][];
|
|
@@ -8,89 +8,89 @@ import { getExternalActionIdHash as f } from "../utils/external-action.utils.mjs
|
|
|
8
8
|
import { HinkalLogicAction as d } from "../../types/hinkal.types.mjs";
|
|
9
9
|
import { calculateBigIntSum as T } from "../utils/amounts.utils.mjs";
|
|
10
10
|
import { getOriginalSender as R } from "./getOriginalSender.mjs";
|
|
11
|
-
const $ = (e,
|
|
12
|
-
let
|
|
13
|
-
return e === "v1x0" ?
|
|
14
|
-
(n, a) => n.map((l) =>
|
|
15
|
-
) :
|
|
16
|
-
}, G = (e,
|
|
17
|
-
const
|
|
11
|
+
const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier())), q = (e, s, t) => {
|
|
12
|
+
let r = [];
|
|
13
|
+
return e === "v1x0" ? r = s.map(
|
|
14
|
+
(n, a) => n.map((l) => t[a] ? "0" : l.getCommitment())
|
|
15
|
+
) : r = s.map((n) => n.map((a) => a.amount === 0n ? "0" : a.getCommitment())), r;
|
|
16
|
+
}, G = (e, s, t = !1) => {
|
|
17
|
+
const r = [];
|
|
18
18
|
for (let n = 0; n < e.length; n += 1) {
|
|
19
19
|
let a = 0n, l = 0n;
|
|
20
20
|
for (let i = 0; i < e[n].length; i += 1)
|
|
21
21
|
a += e[n][i].amount;
|
|
22
|
-
for (let i = 0; i <
|
|
23
|
-
l +=
|
|
24
|
-
l - a < 0 ?
|
|
22
|
+
for (let i = 0; i < s[n].length; i += 1)
|
|
23
|
+
l += s[n][i].amount;
|
|
24
|
+
l - a < 0 ? t ? r.push(l - a) : r.push(c + (l - a)) : r.push(l - a);
|
|
25
25
|
}
|
|
26
|
-
return
|
|
27
|
-
}, L = (e) => e.useApprovalUtxoData.reduce((
|
|
28
|
-
const
|
|
29
|
-
return
|
|
26
|
+
return r;
|
|
27
|
+
}, L = (e) => e.useApprovalUtxoData.reduce((s, t) => [...s, T(t.approvalChanges)], []), Q = (e, s) => {
|
|
28
|
+
const t = L(s), r = s.hinkalLogicAction, n = e.map((a, l) => r === d.NONE || r === d.APPROVE ? a + t[l] >= 0n ? 0n : a + t[l] : a >= 0n ? 0n : a);
|
|
29
|
+
return r === d.RELEASE_BUFFER ? e.forEach((a, l) => {
|
|
30
30
|
n[l] = a > 0n ? -a : a;
|
|
31
|
-
}) :
|
|
31
|
+
}) : r === d.EXECUTE && s.executeApprovalChanges.forEach((a, l) => {
|
|
32
32
|
n[l] = a + e[l] < 0n ? a + e[l] : 0n;
|
|
33
33
|
}), n;
|
|
34
|
-
}, Y = (e
|
|
34
|
+
}, Y = (e) => {
|
|
35
35
|
if (e.length === 0)
|
|
36
36
|
return [];
|
|
37
37
|
const s = [[""]];
|
|
38
38
|
for (let t = 0; t < e.length; t += 1)
|
|
39
|
-
t > 0 && s.push([""]), e[t].forEach((
|
|
40
|
-
s[t][
|
|
39
|
+
t > 0 && s.push([""]), e[t].forEach((r, n) => {
|
|
40
|
+
s[t][n] = `0x${Buffer.from(y(r)).toString("hex")}`;
|
|
41
41
|
});
|
|
42
42
|
return s;
|
|
43
|
-
}, Z = (e,
|
|
44
|
-
const
|
|
43
|
+
}, Z = (e, s) => {
|
|
44
|
+
const t = [];
|
|
45
45
|
for (let n = 0; n < e.length; n += 1) {
|
|
46
|
-
|
|
46
|
+
t.push([]);
|
|
47
47
|
for (let a = 0; a < e[n].length; a += 1)
|
|
48
|
-
|
|
48
|
+
t[n][a] = s.getSiblingHashesForVerification(BigInt(e[n][a].getCommitment())).map((l) => l.toString());
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const r = [];
|
|
51
51
|
for (let n = 0; n < e.length; n += 1) {
|
|
52
|
-
|
|
52
|
+
r.push([]);
|
|
53
53
|
for (let a = 0; a < e[n].length; a += 1)
|
|
54
|
-
|
|
54
|
+
r[n][a] = s.getSiblingSides(BigInt(e[n][a].getCommitment())).map((l) => l.toString());
|
|
55
55
|
}
|
|
56
|
-
return { inCommitmentSiblings:
|
|
57
|
-
}, P = (e,
|
|
58
|
-
const
|
|
59
|
-
return { accessTokenSiblings:
|
|
60
|
-
}, D = (e,
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
64
|
-
return
|
|
56
|
+
return { inCommitmentSiblings: t, inCommitmentSiblingSides: r };
|
|
57
|
+
}, P = (e, s) => {
|
|
58
|
+
const t = s.getSiblingHashesForVerification(BigInt(e)).map((n) => n.toString()), r = s.getSiblingSides(BigInt(e)).map((n) => n.toString());
|
|
59
|
+
return { accessTokenSiblings: t, accessTokenSiblingSides: r };
|
|
60
|
+
}, D = (e, s) => P(e.getAccessKey(), s), ee = (e) => {
|
|
61
|
+
const s = { ...e };
|
|
62
|
+
if (s.amountChanges = e.amountChanges.map((t) => t.toString()), s.calldataHash = e.calldataHash.toString(), s.rootHashAccessToken = e.rootHashAccessToken?.toString(), s.stealthAddressStructure.extraRandomization = e.stealthAddressStructure.extraRandomization.toString(), s.stealthAddressStructure.stealthAddress = e.stealthAddressStructure.stealthAddress.toString(), s.stealthAddressStructure.H0 = e.stealthAddressStructure.H0.toString(), s.stealthAddressStructure.H1 = e.stealthAddressStructure.H1.toString(), s.rootHashHinkal = e.rootHashHinkal?.toString(), s.externalActionId = e.externalActionId?.toString(), "flatFees" in e) {
|
|
63
|
+
const t = s;
|
|
64
|
+
return t.flatFees = e.flatFees.map((r) => r.toString()), t;
|
|
65
65
|
} else {
|
|
66
|
-
const
|
|
67
|
-
return
|
|
68
|
-
(
|
|
69
|
-
),
|
|
70
|
-
(
|
|
71
|
-
approvalChanges:
|
|
72
|
-
externalApprovalAddresses:
|
|
73
|
-
conversionInHinkalAddress:
|
|
66
|
+
const t = s;
|
|
67
|
+
return t.slippageValues = e.slippageValues.map((r) => r.toString()), t.hinkalLogicArgs.inHinkalAddress = e.hinkalLogicArgs.inHinkalAddress.toString(), t.hinkalLogicArgs.executeApprovalChanges = e.hinkalLogicArgs.executeApprovalChanges.map(
|
|
68
|
+
(r) => r.toString()
|
|
69
|
+
), t.hinkalLogicArgs.useApprovalUtxoData = e.hinkalLogicArgs.useApprovalUtxoData.map(
|
|
70
|
+
(r) => ({
|
|
71
|
+
approvalChanges: r.approvalChanges.map((n) => n.toString()),
|
|
72
|
+
externalApprovalAddresses: r.externalApprovalAddresses,
|
|
73
|
+
conversionInHinkalAddress: r.conversionInHinkalAddress.map((n) => n.toString())
|
|
74
74
|
})
|
|
75
|
-
),
|
|
75
|
+
), t.feeStructure.flatFee = e.feeStructure.flatFee.toString(), t.feeStructure.variableRate = e.feeStructure.variableRate.toString(), t;
|
|
76
76
|
}
|
|
77
77
|
}, te = (e) => {
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
return
|
|
78
|
+
const s = { ...e };
|
|
79
|
+
if (s.amountChanges = e.amountChanges.map((t) => BigInt(t)), s.calldataHash = BigInt(e.calldataHash), s.rootHashAccessToken = BigInt(e.rootHashAccessToken), s.rootHashHinkal = BigInt(e.rootHashHinkal), s.externalActionId = BigInt(e.externalActionId), "flatFees" in e) {
|
|
80
|
+
const t = s;
|
|
81
|
+
return t.flatFees = e.flatFees.map((r) => BigInt(r)), t;
|
|
82
82
|
} else {
|
|
83
|
-
const
|
|
84
|
-
return
|
|
85
|
-
(
|
|
86
|
-
approvalChanges:
|
|
87
|
-
externalApprovalAddresses:
|
|
88
|
-
conversionInHinkalAddress:
|
|
83
|
+
const t = s;
|
|
84
|
+
return t.feeStructure.flatFee = BigInt(e.feeStructure.flatFee), t.feeStructure.variableRate = BigInt(e.feeStructure.variableRate), t.slippageValues = e.slippageValues.map((r) => BigInt(r)), t.hinkalLogicArgs.executeApprovalChanges = e.hinkalLogicArgs.executeApprovalChanges.map((r) => BigInt(r)), t.hinkalLogicArgs.inHinkalAddress = BigInt(e.hinkalLogicArgs.inHinkalAddress), t.hinkalLogicArgs.useApprovalUtxoData = e.hinkalLogicArgs.useApprovalUtxoData.map(
|
|
85
|
+
(r) => ({
|
|
86
|
+
approvalChanges: r.approvalChanges.map((n) => BigInt(n)),
|
|
87
|
+
externalApprovalAddresses: r.externalApprovalAddresses,
|
|
88
|
+
conversionInHinkalAddress: r.conversionInHinkalAddress.map((n) => BigInt(n))
|
|
89
89
|
})
|
|
90
|
-
),
|
|
90
|
+
), t;
|
|
91
91
|
}
|
|
92
|
-
}, se = (e,
|
|
93
|
-
const h = Object.values(m || O), v = b ?? R(
|
|
92
|
+
}, se = (e, s, t, r, n, a, l, i, m, H, C, u, g, k, b) => {
|
|
93
|
+
const h = Object.values(m || O), v = b ?? R(r ?? E, t);
|
|
94
94
|
if (e === "v1x0") {
|
|
95
95
|
const p = o.utils.defaultAbiCoder.encode(
|
|
96
96
|
[
|
|
@@ -104,9 +104,9 @@ const $ = (e, r) => e.map((s, t) => s.map((n) => r[t] ? "0" : n.getNullifier()))
|
|
|
104
104
|
"uint256[]"
|
|
105
105
|
],
|
|
106
106
|
[
|
|
107
|
-
r,
|
|
108
107
|
s,
|
|
109
108
|
t,
|
|
109
|
+
r,
|
|
110
110
|
typeof n == "bigint" ? n : f(n),
|
|
111
111
|
a,
|
|
112
112
|
h,
|
|
@@ -119,9 +119,9 @@ const $ = (e, r) => e.map((s, t) => s.map((n) => r[t] ? "0" : n.getNullifier()))
|
|
|
119
119
|
const p = o.utils.defaultAbiCoder.encode(
|
|
120
120
|
["uint16", "address", "address", "uint256", "bytes"],
|
|
121
121
|
[
|
|
122
|
-
r,
|
|
123
122
|
s,
|
|
124
123
|
t,
|
|
124
|
+
r,
|
|
125
125
|
typeof n == "bigint" ? n : f(n),
|
|
126
126
|
a
|
|
127
127
|
]
|
|
@@ -155,18 +155,18 @@ const $ = (e, r) => e.map((s, t) => s.map((n) => r[t] ? "0" : n.getNullifier()))
|
|
|
155
155
|
), I = BigInt(o.utils.keccak256(p)), B = BigInt(o.utils.keccak256(A)), V = o.utils.defaultAbiCoder.encode(["uint256", "uint256"], [I, B]);
|
|
156
156
|
return BigInt(o.utils.keccak256(V)) % c;
|
|
157
157
|
}
|
|
158
|
-
}, x = (e) => e.startsWith("swapperMO") || e.startsWith("swapperME") ? 2 : e.startsWith("swapperMW") ? 1 : (e.startsWith("swapperMHA"), 0), ne = (e,
|
|
158
|
+
}, x = (e) => e.startsWith("swapperMO") || e.startsWith("swapperME") ? 2 : e.startsWith("swapperMW") ? 1 : (e.startsWith("swapperMHA"), 0), ne = (e, s, t, r, n, a) => {
|
|
159
159
|
if (e.startsWith("swapperMWMin0"))
|
|
160
160
|
return 4;
|
|
161
161
|
const l = x(e);
|
|
162
162
|
return 10 + // stealthAddressStructure.H1
|
|
163
|
-
|
|
164
|
-
}, re = (e,
|
|
165
|
-
const { h0:
|
|
163
|
+
s.length + t.length + r.flat().length + n.flat().length + l + a + F * s.length;
|
|
164
|
+
}, re = (e, s) => {
|
|
165
|
+
const { h0: t, h1: r } = S.getStealthAddressCompressedPoints(e, s), n = BigInt(S.getStealthAddress(e, s));
|
|
166
166
|
return {
|
|
167
167
|
extraRandomization: e,
|
|
168
|
-
H0:
|
|
169
|
-
H1:
|
|
168
|
+
H0: t,
|
|
169
|
+
H1: r,
|
|
170
170
|
stealthAddress: n
|
|
171
171
|
};
|
|
172
172
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("../../data-structures/utxo/Utxo.cjs"),le=require("../../data-structures/crypto-keys/keys.cjs"),d=require("../../constants/protocol.constants.cjs"),ue=require("../../constants/chains.constants.cjs"),ge=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),pe=require("../../webworker/performTaskWithWorker.cjs"),Se=require("../../webworker/worker.registry.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("../../data-structures/utxo/Utxo.cjs"),le=require("../../data-structures/crypto-keys/keys.cjs"),d=require("../../constants/protocol.constants.cjs"),ue=require("../../constants/chains.constants.cjs"),ge=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),pe=require("../../webworker/performTaskWithWorker.cjs"),Se=require("../../webworker/worker.registry.cjs"),o=require("./common.snarkjs.cjs"),O=require("../web3/etherFunctions.cjs"),Z=require("../private-wallet/emporium.helpers.cjs"),he=require("../../types/external-action.types.cjs"),Ae=require("../../types/circom-data.types.cjs"),fe=require("./generateCircomData.cjs"),qe=require("./generateZkProof.cjs"),$=require("../utils/time.utils.cjs"),ke=require("../../types/hinkal.types.cjs"),ye=require("../utils/fees.utils.cjs"),j=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=async(s,G,J,l,f,t,e,m,C,Q,T,X,Y,w=d.zeroAddress,c=ue.chainIds.localhost,u=t.map(()=>!1),q=t.map(()=>0n),g,n=void 0,L=!1,p,S=void 0,V,M=d.defaultSignatureData,x,U=!0)=>{const P=o.calcAmountChanges(t,e),k=o.calcEncryptedOutputs(e),h=m.getShieldedPrivateKey(),z=de.Utxo.findCorrectRandomization(O.randomBigInt(31),h),ee=await j.hinkalCheckTokenRegistry(V??j.createHinkalHelperFromData(c),l,o.calcAmountChanges(t,e,!0)),D=t.map(a=>a.map(i=>i.getConstructableParams())),{inCommitmentSiblings:te,inCommitmentSiblingSides:ae,accessTokenSiblings:_,accessTokenSiblingSides:W,rootHashHinkal:b,rootHashAccessToken:y}=await Ce.getMerkleTreeSiblingsAndRootHashes(c,m,D,L,ee,G,J,U),v=await pe.performTaskWithWorker({type:Se.WorkerVariant.ZKProof,payload:{type:ge.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:D,onChainCreation:u,proverVersion:s}}}),E=o.buildOutCommitments(s,e,u),H=x??O.randomBigInt(31),re=He.poseidonFunction(H),r={rootHashHinkal:b,erc20TokenAddresses:l,tokenIds:f,inNullifiers:v,outTimeStamp:e.length>0?BigInt(e[0][0].timeStamp):$.getCurrentTimeInSeconds(),extraRandomization:z,amountChanges:P,outCommitments:E,rootHashAccessToken:y,calldataHash:0n,shieldedPrivateKey:h,accessTokenSiblings:_,accessTokenSiblingSides:W,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:H},ne=g?le.UserKeys.getSignerAddressFromPrivateKey(c,g.privateKey):void 0,I=T,R=he.ExternalActionId.Emporium,F=await Z.encodeEmporiumMetadata(c,T,g?.privateKey,X,re,ne),A=e.length===0?"swapperMWMin0":`swapperMW${C}x${Q}x${e[0].length}`,N=o.calcPublicSignalCount(A,r.erc20TokenAddresses,r.amountChanges,r.inNullifiers,r.outCommitments,f.length);if(n||(n=ke.defaultHinkalLogicArgs(P.length,m),n.interactionAddress="0x032f580aFFE7a5f17025fAF83c13B4277A880532",n.inHinkalAddress=m.getInHinkalAddress(n.interactionAddress)),s==="v1x1"){if(r.interactionAddress=n.interactionAddress,m.getInHinkalAddress(r.interactionAddress)!==n.inHinkalAddress)throw new Error("inHinkalAddress mismatch");r.externalApprovalAddresses=n?.useApprovalUtxoData?.map(({externalApprovalAddresses:a})=>a)??Array(C).fill([d.zeroAddress,d.zeroAddress,d.zeroAddress])}S||(S=ye.generateFeeStructure(q,l));const B=o.calcAmountChanges(t,e,!0);p||(p=o.getSlippageValues(B,n)),r.calldataHash=o.createCallDataHash(s,N,w,I,R,F,k,q,void 0,p,u,n,S,M);const K={outTimeStamp:$.getCurrentTimeInSeconds(),rootHashAccessToken:y,calldataHash:r.calldataHash,shieldedPrivateKey:h,accessTokenSiblings:_,accessTokenSiblingSides:W,messageSeed:H},{zkCallData:ie}=await qe.generateZkProof(s,c,A,A==="swapperMWMin0"?K:r,Y),oe=o.calcStealthAddressStructure(z,h),se=await fe.generateCircomData(s,E,v,b,y,B,l,t,e,k,q,N,R,I,F,w,r.calldataHash,f,oe,u,Ae.defaultHookData,A==="swapperMWMin0"?K.outTimeStamp:r.outTimeStamp,n,p,S,M),ce={tokenNumber:t.length,nullifierAmount:t.length>0?t[0].length:0,outputAmount:e.length>0?e[0].length:0},me=await Z.getAuthorizationDataIfNeeded(c,g?.privateKey);return{zkCallData:ie,circomData:se,dimData:ce,encryptedOutputs:k,authorizationData:me}};exports.constructEmporiumProof=Te;
|
|
@@ -5,8 +5,8 @@ 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
7
|
import { SubAccount } from '../../types/proxy.types';
|
|
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(
|
|
9
|
-
zkCallData: import(
|
|
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<{
|
|
9
|
+
zkCallData: import('../../index.ts').NewZkCallDataType;
|
|
10
10
|
circomData: T;
|
|
11
11
|
dimData: DimDataType;
|
|
12
12
|
encryptedOutputs: string[][];
|
|
@@ -23,7 +23,7 @@ import "process";
|
|
|
23
23
|
import "buffer";
|
|
24
24
|
import { getMerkleTreeSiblingsAndRootHashes as Ia } from "./getMerkleTreeSiblingsAndRootHashes.mjs";
|
|
25
25
|
const mt = async (n, q, j, l, h, t, a, d, D, G, T, J, Q, P = A, o = ca.localhost, s = t.map(() => !1), H = t.map(() => 0n), c, r = void 0, X = !1, p, f = void 0, Y, k = sa, L, V = !0) => {
|
|
26
|
-
const v = C(t, a), w = ga(a
|
|
26
|
+
const v = C(t, a), w = ga(a), S = d.getShieldedPrivateKey(), z = da.findCorrectRandomization($(31), S), x = await Wa(
|
|
27
27
|
Y ?? ba(o),
|
|
28
28
|
l,
|
|
29
29
|
C(t, a, !0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("../../constants/chains.constants.cjs"),i=require("../../constants/protocol.constants.cjs"),ne=require("../../data-structures/utxo/Utxo.cjs"),ae=require("../../webworker/performTaskWithWorker.cjs"),re=require("../../webworker/worker.registry.cjs"),oe=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),se=require("../web3/etherFunctions.cjs"),s=require("./common.snarkjs.cjs"),ie=require("./generateCircomData.cjs"),ce=require("./generateZkProof.cjs"),de=require("../../types/hinkal.types.cjs"),me=require("../utils/fees.utils.cjs"),E=require("../../data-structures/Hinkal/hinkalCheckTokenRegistry.cjs"),q=require("../../error-handling/logger.cjs"),le=require("./getMerkleTreeSiblingsAndRootHashes.cjs"),ke=async(c,j,F,t,o,d,b,C,m,p,M,P=i.zeroAddress,S=te.chainIds.localhost,l=t.map(()=>!1),A=t.map(()=>0n),y=void 0,K=!1,a=void 0,k,g=void 0,G,z=i.defaultSignatureData,I,J=!0)=>{const R=s.calcAmountChanges(t,o),h=t.map(e=>e[0].erc20TokenAddress),f=s.calcEncryptedOutputs(o),H=d.getShieldedPrivateKey(),_=ne.Utxo.findCorrectRandomization(se.randomBigInt(31),H),Q=await E.hinkalCheckTokenRegistry(G??E.createHinkalHelperFromData(S),h,s.calcAmountChanges(t,o,!0)),w=t.map(e=>e.map(n=>n.getConstructableParams())),{inCommitmentSiblings:X,inCommitmentSiblingSides:Y,accessTokenSiblings:$,accessTokenSiblingSides:L,rootHashHinkal:D,rootHashAccessToken:W}=await le.getMerkleTreeSiblingsAndRootHashes(S,d,w,K,Q,j,F,J),Z=await ae.performTaskWithWorker({type:re.WorkerVariant.ZKProof,payload:{type:oe.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:w,onChainCreation:l,proverVersion:c}}}),v=s.buildOutCommitments(c,o,l),r={rootHashHinkal:D,shieldedPrivateKey:H,erc20TokenAddresses:h,inAmounts:t.map(e=>e.map(n=>n.amount.toString())),inTimeStamps:t.map(e=>e.map(n=>n.timeStamp)),inRandomizations:t.map(e=>e.map(n=>n.randomization)),inNullifiers:Z,inCommitmentSiblings:X,inCommitmentSiblingSides:Y,outAmounts:o.map(e=>e.map(n=>n.amount.toString())),outTimeStamp:BigInt(o[0][0].timeStamp),outPublicKeys:o.map(e=>e.map(n=>n.getStealthAddress())),extraRandomization:_,amountChanges:R,outCommitments:v,rootHashAccessToken:W,accessTokenSiblings:$,accessTokenSiblingSides:L,calldataHash:0n},u=t.map(e=>e[0].tokenId??0),B=u.reduce((e,n)=>e+n,0)>0?u.length:0;B>0&&(r.tokenIds=u);const T=s.calcPublicSignalCount(b,r.erc20TokenAddresses,r.amountChanges,r.inNullifiers,r.outCommitments,B);if(!a){a=de.defaultHinkalLogicArgs(R.length,d),a.interactionAddress=m??i.zeroAddress;const e=d.getInHinkalAddress(a.interactionAddress);a.inHinkalAddress=e}if(c==="v1x1"){if(r.interactionAddress=a?.interactionAddress??m??i.zeroAddress,d.getInHinkalAddress(r.interactionAddress)!==a.inHinkalAddress)throw new Error("inHinkalAddress mismatch");r.externalApprovalAddresses=a.useApprovalUtxoData?.map(({externalApprovalAddresses:e})=>e)??[i.zeroAddress,i.zeroAddress,i.zeroAddress]}g||(g=me.generateFeeStructure(A,t.map(e=>e[0].erc20TokenAddress)));const N=s.calcAmountChanges(t,o,!0);k||(k=s.getSlippageValues(N,a)),q.Logger.log({publicSignalCount:T}),r.calldataHash=s.createCallDataHash(c,T,P,m,C,p,f,A,y,k,l,a,g,z,I);const{zkCallData:V,publicSignals:U}=await ce.generateZkProof(c,S,b,r,M);q.Logger.log({publicSignals:U});const x=s.calcStealthAddressStructure(_,H),O=await ie.generateCircomData(c,v,Z,D,W,N,h,t,o,f,A,T,C,m,p,P,r.calldataHash,u,x,l,y,void 0,a,k,g,z,I);q.Logger.log({circomData:O});const ee={tokenNumber:t.length,nullifierAmount:t[0].length,outputAmount:o[0].length};return{zkCallData:V,circomData:O,dimData:ee,encryptedOutputs:f}};exports.constructZkProof=ke;
|
|
@@ -3,11 +3,10 @@ import { UserKeys } from '../../data-structures/crypto-keys/keys';
|
|
|
3
3
|
import { Utxo } from '../../data-structures/utxo/Utxo';
|
|
4
4
|
import { CircomDataV1x1, DimDataType, HookDataType } from '../../types/circom-data.types';
|
|
5
5
|
import { ExternalActionId } from '../../types/external-action.types';
|
|
6
|
-
import { StakeArgs } from '../../types/hinkal.stake.types';
|
|
7
6
|
import { FeeStructure, HinkalLogicArgs, ProverVersion } from '../../types/hinkal.types';
|
|
8
7
|
import { ethers } from 'ethers';
|
|
9
|
-
export declare const constructZkProof: <T = CircomDataV1x1>(proverVersion: ProverVersion, merkleTree: MerkleTree<bigint>, merkleTreeAccessToken: MerkleTree<bigint>, inputUtxos: Utxo[][], outputUtxos: Utxo[][], userKeys: UserKeys, verifierName: string, externalActionId: ExternalActionId | 0n, externalAddress: string | undefined, externalActionMetadata: string, generateProofRemotely: boolean, relay?: string, chainId?: number, onChainCreation?: boolean[], flatFees?: bigint[], hookData?: HookDataType | undefined,
|
|
10
|
-
zkCallData: import(
|
|
8
|
+
export declare const constructZkProof: <T = CircomDataV1x1>(proverVersion: ProverVersion, merkleTree: MerkleTree<bigint>, merkleTreeAccessToken: MerkleTree<bigint>, inputUtxos: Utxo[][], outputUtxos: Utxo[][], userKeys: UserKeys, verifierName: string, externalActionId: ExternalActionId | 0n, externalAddress: string | undefined, externalActionMetadata: string, generateProofRemotely: boolean, relay?: string, chainId?: number, onChainCreation?: boolean[], flatFees?: bigint[], hookData?: HookDataType | undefined, patchAccessTokenMerkleTree?: boolean, hinkalLogicArgs?: HinkalLogicArgs | undefined, slippageValues?: bigint[], feeStructure?: FeeStructure | undefined, hinkalHelper?: ethers.Contract, signatureData?: import('../../index.ts').SignatureData, originalSender?: string, hasLocalTrees?: boolean) => Promise<{
|
|
9
|
+
zkCallData: import('../../index.ts').NewZkCallDataType;
|
|
11
10
|
circomData: T;
|
|
12
11
|
dimData: DimDataType;
|
|
13
12
|
encryptedOutputs: string[][];
|