@hinkal/common 0.2.21 → 0.2.22
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 +14 -14
- package/API/API.mjs +88 -87
- package/API/admin-calls.cjs +1 -1
- package/API/admin-calls.d.ts +1 -1
- package/API/admin-calls.mjs +4 -4
- package/API/ai-calls.cjs +1 -0
- package/API/ai-calls.d.ts +17 -0
- package/API/ai-calls.mjs +21 -0
- 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 +11 -10
- package/API/callRelayer.cjs +1 -1
- package/API/callRelayer.d.ts +5 -6
- 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/deposit-and-withdraw-status-calls.cjs +1 -0
- package/API/deposit-and-withdraw-status-calls.d.ts +20 -0
- package/API/deposit-and-withdraw-status-calls.mjs +18 -0
- package/API/duneAPI.cjs +1 -0
- package/API/duneAPI.d.ts +11 -0
- package/API/duneAPI.mjs +25 -0
- package/API/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +4 -5
- 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/getBridgeProtocols.cjs +1 -0
- package/API/getBridgeProtocols.d.ts +7 -0
- package/API/getBridgeProtocols.mjs +8 -0
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.mjs +9 -9
- package/API/getLifiStatus.cjs +1 -0
- package/API/getLifiStatus.d.ts +24 -0
- package/API/getLifiStatus.mjs +15 -0
- package/API/getRelayerURL.cjs +1 -0
- package/API/getRelayerURL.d.ts +1 -0
- package/API/getRelayerURL.mjs +10 -0
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.d.ts +3 -3
- package/API/getServerURL.mjs +67 -51
- package/API/getTokenPrice.cjs +1 -1
- package/API/getTokenPrice.d.ts +0 -5
- package/API/getTokenPrice.mjs +7 -14
- package/API/index.d.ts +3 -1
- package/API/is-tx-stateless.cjs +1 -1
- package/API/is-tx-stateless.d.ts +1 -1
- package/API/is-tx-stateless.mjs +12 -10
- package/API/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +8 -4
- package/API/kycCalls.mjs +26 -23
- package/API/passwordCalls.cjs +1 -0
- package/API/passwordCalls.d.ts +9 -0
- package/API/passwordCalls.mjs +13 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +2 -7
- package/API/proxyAccountsCalls.mjs +21 -27
- package/API/relayCalls.cjs +1 -1
- package/API/relayCalls.mjs +4 -4
- package/API/restoreSnapshots.cjs +1 -0
- package/API/restoreSnapshots.d.ts +1 -0
- package/API/restoreSnapshots.mjs +10 -0
- package/API/scheduled-transactions-calls.cjs +1 -1
- package/API/scheduled-transactions-calls.d.ts +9 -1
- package/API/scheduled-transactions-calls.mjs +9 -5
- package/API/simulate-batch-tx.cjs +1 -1
- package/API/simulate-batch-tx.d.ts +2 -2
- package/API/simulate-batch-tx.mjs +6 -7
- package/API/solana-calls.cjs +1 -1
- package/API/solana-calls.d.ts +3 -6
- package/API/solana-calls.mjs +15 -15
- package/API/temporaryWalletCalls.cjs +1 -1
- package/API/temporaryWalletCalls.mjs +19 -13
- package/API/token-calls.cjs +1 -1
- package/API/token-calls.mjs +5 -6
- package/README.md +54 -42
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +6 -0
- package/constants/chains.constants.mjs +52 -58
- package/constants/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.d.ts +0 -1
- package/constants/coingecko.constants.mjs +10 -11
- package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-solana.json.mjs +2 -28
- package/constants/function-signatures.constants.cjs +1 -1
- package/constants/function-signatures.constants.d.ts +1 -0
- package/constants/function-signatures.constants.mjs +4 -3
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +40 -39
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +0 -1
- package/constants/mediaUrls.constants.mjs +1 -2
- package/constants/permit2.constants.cjs +1 -1
- package/constants/permit2.constants.d.ts +1 -0
- package/constants/permit2.constants.mjs +11 -10
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +123 -19
- package/constants/server.constants.mjs +142 -38
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +13 -36
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +71 -68
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +56 -45
- package/data-structures/Hinkal/Hinkal.mjs +348 -314
- package/data-structures/Hinkal/IHinkal.d.ts +54 -40
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +49 -48
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +7 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +42 -0
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +24 -29
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -0
- package/data-structures/Hinkal/hinkalApprove.d.ts +3 -0
- package/data-structures/Hinkal/hinkalApprove.mjs +114 -0
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +20 -20
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +84 -88
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +96 -77
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +80 -75
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +150 -138
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +5 -4
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalInsideTransact.d.ts +4 -0
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +119 -0
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +118 -114
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +34 -36
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +36 -40
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +32 -37
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +15 -17
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +3 -4
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +95 -84
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +182 -155
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +3 -2
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +40 -43
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +67 -71
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +59 -63
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +45 -48
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +48 -49
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +68 -71
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +78 -71
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +70 -71
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +79 -81
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +103 -105
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +53 -107
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.d.ts +0 -1
- package/data-structures/IndexedDB/activity-db.mjs +75 -91
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +37 -40
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +13 -16
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +40 -25
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +84 -82
- package/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
- package/data-structures/TokenDBs/token-visibility-db.mjs +36 -22
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +11 -0
- package/data-structures/crypto-keys/keys.mjs +107 -47
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +2 -3
- 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 +2 -3
- 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 +2 -3
- 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 +2 -4
- package/data-structures/event-service/evm/AbstractEventService.mjs +19 -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 +5 -6
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +2 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +4 -3
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +5 -10
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +35 -39
- package/data-structures/event-service/index.d.ts +0 -4
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +2 -3
- 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 +3 -4
- 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 +10 -4
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +7 -10
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +2 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +2 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +16 -11
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +66 -64
- package/data-structures/index.d.ts +0 -3
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +13 -8
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +4 -6
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +4 -6
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +4 -6
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +4 -6
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +4 -6
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +4 -5
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +4 -6
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +0 -1
- package/error-handling/error-codes.constants.mjs +3 -4
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +27 -21
- package/error-handling/handleErrorRestore.cjs +1 -0
- package/error-handling/handleErrorRestore.d.ts +2 -0
- package/error-handling/handleErrorRestore.mjs +11 -0
- package/error-handling/index.d.ts +1 -0
- package/functions/kyc/authentoHelper.cjs +1 -0
- package/functions/kyc/authentoHelper.d.ts +12 -0
- package/functions/kyc/authentoHelper.mjs +30 -0
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +17 -18
- package/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/functions/pre-transaction/constructAdminData.d.ts +2 -2
- package/functions/pre-transaction/constructAdminData.mjs +18 -12
- package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/functions/pre-transaction/getExternalSwapAddress.d.ts +2 -1
- package/functions/pre-transaction/getExternalSwapAddress.mjs +8 -8
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +36 -21
- 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 +9 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.mjs +34 -19
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.mjs +50 -53
- 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/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +6 -3
- package/functions/private-wallet/emporium.helpers.mjs +127 -89
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.d.ts +4 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +102 -100
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.mjs +49 -49
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +20 -18
- package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
- package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +10 -11
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.d.ts +0 -1
- package/functions/utils/addresses.mjs +12 -13
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +2 -2
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +1 -1
- package/functions/utils/create-provider.mjs +9 -13
- package/functions/utils/get-hinkal-approvals.cjs +1 -0
- package/functions/utils/get-hinkal-approvals.d.ts +3 -0
- package/functions/utils/get-hinkal-approvals.mjs +38 -0
- 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/index.d.ts +1 -0
- package/functions/utils/involves-permit2-op.cjs +1 -1
- package/functions/utils/involves-permit2-op.d.ts +1 -0
- package/functions/utils/involves-permit2-op.mjs +6 -4
- 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 +23 -8
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +13 -6
- package/functions/utils/prepareHinkal.mjs +72 -45
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.mjs +54 -49
- package/functions/utils/replaceAddressInCalldata.cjs +1 -0
- package/functions/utils/replaceAddressInCalldata.d.ts +1 -0
- package/functions/utils/replaceAddressInCalldata.mjs +7 -0
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +0 -1
- package/functions/utils/string.utils.mjs +14 -18
- package/functions/utils/token-check.utils.cjs +1 -1
- package/functions/utils/token-check.utils.d.ts +0 -3
- package/functions/utils/token-check.utils.mjs +7 -18
- 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 +17 -2
- package/functions/utils/walletBalances.utils.mjs +36 -5
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.d.ts +4 -3
- package/functions/web3/events/getApprovedBalance.mjs +44 -39
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.d.ts +3 -3
- package/functions/web3/events/getInputUtxoAndBalance.mjs +150 -129
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.mjs +75 -73
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.mjs +38 -38
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +10 -13
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +6 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +21 -12
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +46 -50
- 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 +2 -1
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +10 -10
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +5 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +32 -0
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +40 -36
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +3 -3
- package/functions/web3/functionCalls/transactCallRelayer.mjs +54 -54
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.mjs +22 -17
- 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 +27 -27
- package/functions/web3/index.d.ts +0 -1
- 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 +19 -6
- package/functions/web3/okxAPI.cjs +1 -1
- package/functions/web3/okxAPI.mjs +13 -13
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +20 -7
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +56 -38
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +34 -22
- package/index.cjs +1 -1
- package/index.mjs +922 -920
- package/package.json +2 -3
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +17 -10
- package/providers/EthersProviderAdapter.mjs +76 -45
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +11 -7
- package/providers/SolanaProviderAdapter.mjs +31 -16
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +17 -11
- package/providers/WagmiProviderAdapter.mjs +117 -86
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +9 -14
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +9 -15
- package/types/TransactionSimulator.types.d.ts +9 -2
- package/types/activities.types.d.ts +0 -2
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +6 -0
- package/types/admin.types.mjs +2 -2
- package/types/balances.types.d.ts +1 -0
- package/types/bridging.types.d.ts +29 -0
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +3 -6
- package/types/cache.types.mjs +1 -1
- package/types/coingecko.types.d.ts +0 -5
- package/types/duneAPI.types.d.ts +9 -0
- package/types/ethereum-network.types.d.ts +0 -1
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +1 -1
- package/types/hinkal.types.mjs +18 -18
- package/types/index.d.ts +2 -2
- package/types/proxy.types.d.ts +3 -6
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +39 -10
- package/types/sandbox.types.mjs +2 -2
- package/types/scheduled-transactions.types.cjs +1 -1
- package/types/scheduled-transactions.types.d.ts +6 -0
- package/types/scheduled-transactions.types.mjs +3 -2
- package/types/session.types.d.ts +0 -2
- package/types/solana.types.d.ts +0 -9
- package/types/token-prices.types.cjs +1 -1
- package/types/token-prices.types.d.ts +0 -7
- package/types/token-prices.types.mjs +2 -4
- 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/viteWorkerURL.constant.cjs +3 -3
- package/webworker/viteWorkerURL.constant.mjs +3 -3
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/API/get-token-price-chart-data.cjs +0 -1
- package/API/get-token-price-chart-data.d.ts +0 -16
- package/API/get-token-price-chart-data.mjs +0 -13
- package/API/onrampCalls.cjs +0 -1
- package/API/onrampCalls.d.ts +0 -20
- package/API/onrampCalls.mjs +0 -15
- package/API/unspent-utxos-calls.cjs +0 -1
- package/API/unspent-utxos-calls.d.ts +0 -26
- package/API/unspent-utxos-calls.mjs +0 -26
- package/data-structures/AccountActions/AccountActions.cjs +0 -1
- package/data-structures/AccountActions/AccountActions.d.ts +0 -18
- package/data-structures/AccountActions/AccountActions.mjs +0 -78
- package/data-structures/AccountActions/index.d.ts +0 -1
- package/data-structures/BlockchainEvent/BlockchainEvent.cjs +0 -1
- package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +0 -14
- package/data-structures/BlockchainEvent/BlockchainEvent.mjs +0 -41
- package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +0 -1
- package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +0 -20
- package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +0 -124
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +0 -1
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +0 -15
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +0 -64
- package/data-structures/PublicBalance/index.d.ts +0 -2
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +0 -11
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +0 -21
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +0 -6
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +0 -16
- package/data-structures/event-service/helpers/ClientEventHelper.cjs +0 -1
- package/data-structures/event-service/helpers/ClientEventHelper.d.ts +0 -11
- package/data-structures/event-service/helpers/ClientEventHelper.mjs +0 -26
- package/data-structures/event-service/helpers/PollingEventHelper.cjs +0 -1
- package/data-structures/event-service/helpers/PollingEventHelper.d.ts +0 -5
- package/data-structures/event-service/helpers/PollingEventHelper.mjs +0 -14
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +0 -11
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +0 -22
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +0 -6
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +0 -16
- package/functions/utils/enum.utils.cjs +0 -1
- package/functions/utils/enum.utils.mjs +0 -14
- package/functions/utils/socket.utils.cjs +0 -1
- package/functions/utils/socket.utils.d.ts +0 -1
- package/functions/utils/socket.utils.mjs +0 -12
- package/functions/web3/crypto.cjs +0 -1
- package/functions/web3/crypto.d.ts +0 -1
- package/functions/web3/crypto.mjs +0 -7
- package/types/events.types.cjs +0 -1
- package/types/events.types.d.ts +0 -9
- package/types/events.types.mjs +0 -5
- package/types/onramp.types.cjs +0 -1
- package/types/onramp.types.d.ts +0 -58
- package/types/onramp.types.mjs +0 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { utils as p, BigNumber as w, ethers as C } from "ethers";
|
|
2
|
-
import { zeroAddress as
|
|
3
|
-
import { ContractType as
|
|
2
|
+
import { zeroAddress as u } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { ContractType as h } from "../../types/ethereum-network.types.mjs";
|
|
4
4
|
import "idb-keyval";
|
|
5
|
-
import {
|
|
6
|
-
import { createCustomRpcProvider as
|
|
5
|
+
import { networkRegistry as A, chainIds as W } from "../../constants/chains.constants.mjs";
|
|
6
|
+
import { createCustomRpcProvider as k } 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,23 +11,26 @@ 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 "../../data-structures/crypto-keys/keys.mjs";
|
|
14
|
+
import { UserKeys as y } from "../../data-structures/crypto-keys/keys.mjs";
|
|
15
15
|
import "../../constants/server.constants.mjs";
|
|
16
|
-
import "../../
|
|
16
|
+
import "../../constants/vite.constants.mjs";
|
|
17
17
|
import "../../data-structures/http/HttpClient.mjs";
|
|
18
18
|
import "axios";
|
|
19
|
-
import "
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import "
|
|
19
|
+
import { caseInsensitiveEqual as f } from "../utils/caseInsensitive.utils.mjs";
|
|
20
|
+
import "../../API/getServerURL.mjs";
|
|
21
|
+
import "libsodium-wrappers";
|
|
22
|
+
import "process";
|
|
23
|
+
import "buffer";
|
|
24
|
+
import "../../constants/save-depths.mjs";
|
|
25
|
+
import "../../constants/reorg-depths.constants.mjs";
|
|
26
|
+
import "../utils/mutexes.utils.mjs";
|
|
23
27
|
import "@coral-xyz/anchor";
|
|
28
|
+
import { Logger as D } from "../../error-handling/logger.mjs";
|
|
29
|
+
import "@solana/web3.js";
|
|
24
30
|
import "@solana/spl-token";
|
|
25
|
-
import { AccountActions as y } from "../../data-structures/AccountActions/AccountActions.mjs";
|
|
26
|
-
import "buffer";
|
|
27
31
|
import "../../constants/contracts.constants.mjs";
|
|
28
32
|
import "../../constants/kyc.constants.mjs";
|
|
29
33
|
import "../../constants/coingecko.constants.mjs";
|
|
30
|
-
import "../../constants/reorg-depths.constants.mjs";
|
|
31
34
|
import "../../constants/addresses.constants.mjs";
|
|
32
35
|
import "../../constants/token.limits.constants.mjs";
|
|
33
36
|
import "../../constants/presale.constants.mjs";
|
|
@@ -35,14 +38,12 @@ import "../../constants/activity.constants.mjs";
|
|
|
35
38
|
import "../../constants/tasks.constants.mjs";
|
|
36
39
|
import "../../constants/events.constants.mjs";
|
|
37
40
|
import "../utils/userAgent.mjs";
|
|
38
|
-
import "
|
|
41
|
+
import { replaceAllInstances as O } from "../utils/string.utils.mjs";
|
|
39
42
|
import "multiformats";
|
|
40
|
-
import "../../API/
|
|
41
|
-
import "
|
|
42
|
-
import "
|
|
43
|
-
|
|
44
|
-
import { ethers as k } from "ethers-v6h";
|
|
45
|
-
const h = ({
|
|
43
|
+
import "../../API/tenderly.api.mjs";
|
|
44
|
+
import { replaceAddressesInCalldata as P } from "../utils/replaceAddressInCalldata.mjs";
|
|
45
|
+
import { ethers as I } from "ethers-v6h";
|
|
46
|
+
const g = ({
|
|
46
47
|
contract: t,
|
|
47
48
|
func: r,
|
|
48
49
|
args: o,
|
|
@@ -57,106 +58,140 @@ const h = ({
|
|
|
57
58
|
r && o && !e && (s = p.arrayify(t.interface.encodeFunctionData(r, o)));
|
|
58
59
|
} else
|
|
59
60
|
n = p.arrayify(t);
|
|
60
|
-
const
|
|
61
|
-
return p.hexlify(
|
|
62
|
-
},
|
|
61
|
+
const c = p.arrayify([i ? 1 : 0]), m = p.zeroPad(p.arrayify(w.from(a ?? 0n)), 16), d = p.concat([n, c, m, s]);
|
|
62
|
+
return p.hexlify(d);
|
|
63
|
+
}, Dt = async (t, r, o, e, i, a) => {
|
|
63
64
|
const n = o ? await y.signTypedDataFromPrivateKey(
|
|
64
65
|
t,
|
|
65
66
|
o,
|
|
66
67
|
{ name: "Emporium", version: "1.0.0", chainId: t, verifyingContract: r },
|
|
67
68
|
{ EmporiumSignature: [{ name: "message", type: "uint256" }] },
|
|
68
69
|
{ message: i }
|
|
69
|
-
) : void 0, { v: s, r:
|
|
70
|
+
) : void 0, { v: s, r: c, s: m } = n ? p.splitSignature(n) : { v: 0, r: C.constants.HashZero, s: C.constants.HashZero };
|
|
70
71
|
return p.defaultAbiCoder.encode(
|
|
71
72
|
["tuple(uint8 v,bytes32 r, bytes32 s, uint256 message, address signerAddress, bytes[] ops)"],
|
|
72
73
|
[
|
|
73
74
|
{
|
|
74
75
|
v: s,
|
|
75
|
-
r:
|
|
76
|
-
s:
|
|
76
|
+
r: c,
|
|
77
|
+
s: m,
|
|
77
78
|
message: i ?? 0n,
|
|
78
|
-
signerAddress: a ??
|
|
79
|
+
signerAddress: a ?? u,
|
|
79
80
|
ops: e
|
|
80
81
|
}
|
|
81
82
|
]
|
|
82
83
|
);
|
|
83
|
-
},
|
|
84
|
+
}, E = (t, r, o, e) => g(t ? {
|
|
84
85
|
contract: t,
|
|
85
86
|
func: "transfer",
|
|
86
87
|
args: [r, o],
|
|
87
88
|
invokeWallet: e
|
|
88
|
-
} : { contract: r, value: o, invokeWallet: e }),
|
|
89
|
-
const
|
|
90
|
-
return
|
|
91
|
-
const
|
|
92
|
-
return
|
|
89
|
+
} : { contract: r, value: o, invokeWallet: e }), Ot = (t, r, o, e) => {
|
|
90
|
+
const i = t.getContractWithFetcher(h.HinkalContract);
|
|
91
|
+
return r.map((a, n) => {
|
|
92
|
+
const s = f(a, u) ? void 0 : t.getContractWithFetcher(h.ERC20Contract, a);
|
|
93
|
+
return E(s, e ?? i.address, o[n], !0);
|
|
93
94
|
});
|
|
94
|
-
},
|
|
95
|
+
}, B = (t, r, o, e) => g({
|
|
95
96
|
contract: t,
|
|
96
97
|
func: "approve",
|
|
97
98
|
args: [r, o],
|
|
98
99
|
invokeWallet: e
|
|
99
|
-
}),
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
}), x = (t, r, o) => {
|
|
101
|
+
const e = t.getSelectedNetwork()?.contractData.hinkalAddress;
|
|
102
|
+
if (!e)
|
|
103
|
+
throw Error("No Hinkal Address Provided to modifyDataForProxy");
|
|
104
|
+
return O(o, e.slice(2), r.slice(2));
|
|
105
|
+
}, Pt = (t, r, o) => {
|
|
106
|
+
if (!r)
|
|
107
|
+
throw Error("No private key provided to modifyDataForProxy");
|
|
108
|
+
const e = y.getSignerAddressFromPrivateKey(t.getCurrentChainId(), r);
|
|
109
|
+
return x(t, e, o);
|
|
110
|
+
}, F = (t, r, o, e, i, a, n) => {
|
|
111
|
+
const s = [];
|
|
112
|
+
for (let c = 0; c < r.length; c += 1) {
|
|
113
|
+
const m = r[c], d = f(m, u) ? void 0 : t.getContractWithFetcher(h.ERC20Contract, m);
|
|
114
|
+
s.push(E(d, a, o[c], !1));
|
|
104
115
|
}
|
|
105
|
-
if (
|
|
106
|
-
for (let c = 0; c <
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
109
|
-
const
|
|
110
|
-
|
|
116
|
+
if (n)
|
|
117
|
+
for (let c = 0; c < e.length; c += 1) {
|
|
118
|
+
const m = e[c];
|
|
119
|
+
if (!f(m, u)) {
|
|
120
|
+
const d = t.getContractWithFetcher(h.ERC20Contract, m);
|
|
121
|
+
s.push(B(d, n, i[c], !0));
|
|
111
122
|
}
|
|
112
123
|
}
|
|
113
|
-
return
|
|
114
|
-
},
|
|
115
|
-
const
|
|
116
|
-
s.nativeFee > 0n && !l(i, d) && (c.push(d), u.push(s.nativeFee));
|
|
117
|
-
const E = I(
|
|
124
|
+
return s;
|
|
125
|
+
}, It = (t, r, o, e, i, a, n, s, c, m) => {
|
|
126
|
+
const d = F(
|
|
118
127
|
t,
|
|
119
128
|
r,
|
|
120
|
-
c,
|
|
121
|
-
u,
|
|
122
|
-
[i],
|
|
123
|
-
[n],
|
|
124
129
|
o,
|
|
125
|
-
e
|
|
130
|
+
e,
|
|
131
|
+
i,
|
|
132
|
+
a,
|
|
133
|
+
n
|
|
134
|
+
);
|
|
135
|
+
if (!!s && !!c) {
|
|
136
|
+
const l = t.getContractWithFetcher(h.HinkalContract);
|
|
137
|
+
d.push(
|
|
138
|
+
g({
|
|
139
|
+
contract: s,
|
|
140
|
+
callDataString: P(c, l.address, a),
|
|
141
|
+
value: m,
|
|
142
|
+
invokeWallet: !0
|
|
143
|
+
})
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
return d;
|
|
147
|
+
}, Bt = (t, r, o, e, i, a, n) => {
|
|
148
|
+
const s = [], c = [e], m = [i];
|
|
149
|
+
n.nativeFee > 0n && !f(e, u) && (c.push(u), m.push(n.nativeFee));
|
|
150
|
+
const v = F(
|
|
151
|
+
t,
|
|
152
|
+
c,
|
|
153
|
+
m,
|
|
154
|
+
[e],
|
|
155
|
+
[a],
|
|
156
|
+
r,
|
|
157
|
+
o
|
|
126
158
|
);
|
|
127
|
-
|
|
128
|
-
let
|
|
129
|
-
return
|
|
130
|
-
|
|
131
|
-
contract:
|
|
132
|
-
callDataString:
|
|
133
|
-
value:
|
|
159
|
+
s.push(...v);
|
|
160
|
+
let l = n.nativeFee;
|
|
161
|
+
return f(e, u) && (l += a), s.push(
|
|
162
|
+
g({
|
|
163
|
+
contract: o,
|
|
164
|
+
callDataString: n.calldata,
|
|
165
|
+
value: l > 0n ? l : void 0,
|
|
134
166
|
invokeWallet: !0
|
|
135
167
|
})
|
|
136
|
-
),
|
|
137
|
-
},
|
|
168
|
+
), s;
|
|
169
|
+
}, T = "0xef0100", H = async (t, r) => {
|
|
138
170
|
try {
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
171
|
+
const { fetchRpcUrl: o } = A[t];
|
|
172
|
+
if (!o)
|
|
173
|
+
throw new Error("RPC URL not found for the specified chain ID");
|
|
174
|
+
const e = k(o), i = await e.getCode(r);
|
|
175
|
+
if (i === "0x" || !i)
|
|
141
176
|
return { delegated: !1, implementation: void 0, nonce: void 0 };
|
|
142
|
-
if (
|
|
143
|
-
const
|
|
144
|
-
return { delegated: !0, implementation: p.getAddress(
|
|
177
|
+
if (i.toLowerCase().startsWith(T) && i.length === 48) {
|
|
178
|
+
const a = `0x${i.slice(8)}`, n = await e.getTransactionCount(r);
|
|
179
|
+
return { delegated: !0, implementation: p.getAddress(a), nonce: n };
|
|
145
180
|
} else
|
|
146
181
|
throw Error("checkEOAWithDelegation: It is a contract");
|
|
147
182
|
} catch (o) {
|
|
148
|
-
throw
|
|
183
|
+
throw D.error("checkEOAWithDelegation error", { error: o }), o;
|
|
149
184
|
}
|
|
150
|
-
},
|
|
151
|
-
const { hinkalWalletAddress: r } =
|
|
152
|
-
if (!r ||
|
|
185
|
+
}, N = (t) => {
|
|
186
|
+
const { hinkalWalletAddress: r } = A[t].contractData;
|
|
187
|
+
if (!r || f(r, u))
|
|
153
188
|
throw Error("Hinkal Wallet Address is not set");
|
|
154
189
|
return r;
|
|
155
|
-
},
|
|
156
|
-
if (t ===
|
|
190
|
+
}, xt = async (t, r) => {
|
|
191
|
+
if (t === W.localhost || !r)
|
|
157
192
|
return;
|
|
158
|
-
const o = y.getSignerAddressFromPrivateKey(t, r), { delegated: e, implementation: i } = await
|
|
159
|
-
if (!e || !
|
|
193
|
+
const o = y.getSignerAddressFromPrivateKey(t, r), { delegated: e, implementation: i } = await H(t, o), a = N(t);
|
|
194
|
+
if (!e || !f(i, a)) {
|
|
160
195
|
const n = await y.authorizeDelegation(t, r, a);
|
|
161
196
|
return {
|
|
162
197
|
v: n.signature.v.toString(),
|
|
@@ -167,21 +202,24 @@ const h = ({
|
|
|
167
202
|
chainId: String(t)
|
|
168
203
|
};
|
|
169
204
|
}
|
|
170
|
-
},
|
|
205
|
+
}, Tt = (t) => {
|
|
171
206
|
if (!t)
|
|
172
207
|
return;
|
|
173
208
|
const { v: r, r: o, s: e, nonce: i, chainId: a, address: n } = t;
|
|
174
|
-
return { signature:
|
|
209
|
+
return { signature: I.Signature.from({ v: r, r: o, s: e }), nonce: BigInt(i), chainId: BigInt(a), address: n };
|
|
175
210
|
};
|
|
176
211
|
export {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
212
|
+
H as checkEOAWithDelegation,
|
|
213
|
+
B as createApproveEmporiumOp,
|
|
214
|
+
Bt as createLifiBridgeOps,
|
|
215
|
+
Ot as createTransaferEmporiumOpsBatch,
|
|
216
|
+
E as createTransferToEmporiumOp,
|
|
217
|
+
g as emporiumOp,
|
|
218
|
+
Dt as encodeEmporiumMetadata,
|
|
219
|
+
F as generateFundAndApproveOps,
|
|
220
|
+
It as generateFundApproveAndTransactOps,
|
|
221
|
+
xt as getAuthorizationDataIfNeeded,
|
|
222
|
+
x as modifyDataForProxy,
|
|
223
|
+
Pt as modifyDataForProxyWithPrivateKey,
|
|
224
|
+
Tt as recoverAuthorizationData
|
|
187
225
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("ethers"),E=require("./emporium.helpers.cjs"),l=require("../../constants/addresses.constants.cjs"),I=require("../../types/external-action.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),P=require("../pre-transaction/getExternalSwapAddress.cjs"),x=require("../utils/string.utils.cjs"),C=require("../../constants/protocol.constants.cjs");require("../../constants/token-data/index.cjs");const U=require("../utils/caseInsensitive.utils.cjs"),A=require("../../error-handling/logger.cjs"),L=require("../../constants/token-data/ERC20Registry.cjs"),B=(e,n,c,a,t,i,o=!1)=>{const r=R.BigNumber.from(i).toBigInt(),m={tokenIn:n,tokenOut:a,fee:r,recipient:t,amountIn:c,amountOutMinimum:0,sqrtPriceLimitX96:0},f=["function exactInputSingle(tuple(address tokenIn,address tokenOut,uint24 fee,address recipient,uint256 amountIn,uint256 amountOutMinimum,uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)"],g=new R.ethers.Contract(e,f);return E.emporiumOp({contract:g,func:"exactInputSingle",args:[m],invokeWallet:o})},F=(e,n,c,a,t,i,o=!1)=>{const r=P.getExternalSwapAddress(e,n),m=x.replaceAllInstances(a,r.slice(2),t.slice(2));return E.emporiumOp({contract:c,callDataString:m,value:i,invokeWallet:o})},v=(e,n)=>{const a=L.getERC20Registry(n).find(t=>t.symbol==="USDT");return a?U.caseInsensitiveEqual(e,a.erc20TokenAddress):!1},b=async(e,n,c,a,t,i)=>{const o=c.address;if(v(o,e.getCurrentChainId()))try{(await c.allowance(a,t)).toBigInt()>0n&&n.push(E.createApproveEmporiumOp(c,t,0n,i))}catch(r){A.Logger.error("Error in nullifyUsdtApprovalIfNeeded",r)}},d=async(e,n,c,a,t,i,o)=>{if(n!==C.zeroAddress){const r=l.SWAP_FEE_TAKER_ADDRESSES[e.getCurrentChainId()],m=e.getContractWithFetcher(h.ContractType.ERC20Contract,n),f=await m.balanceOf(c);await b(e,t,m,c,r,i),t.push(E.createApproveEmporiumOp(m,r,2n**256n-1n,i));const g=["function takeSwapFee(address token, uint256 beforeBalance, uint256 variableRate, address relay) external payable"],s=new R.ethers.Contract(r,g),w=a;t.push(E.emporiumOp({contract:s,func:"takeSwapFee",args:[n,f,C.HINKAL_SWAP_VARIABLE_RATE,w],invokeWallet:i}))}else{const r=a;t.push(E.emporiumOp({contract:r,value:o*C.HINKAL_SWAP_VARIABLE_RATE/10000n,invokeWallet:i}))}},z=async(e,n,c,a,t,i,o,r,m,f,g,s=!1)=>{const w=i<0n?-1n*i:i,q=e.getCurrentChainId(),u=[],O=l.NATIVE_TOKEN_WRAPPER_ADDRESSES[q];let D=!1,S;if(n===I.ExternalActionId.OneInch||n===I.ExternalActionId.Lifi){if(t!==C.zeroAddress){const _=e.getContractWithFetcher(h.ContractType.ERC20Contract,t);u.push(E.createApproveEmporiumOp(_,c,w,s))}let p=0n;t===C.zeroAddress&&(p+=w),o&&r===C.zeroAddress&&o<0n&&(p+=-1n*o);const y=p>0n?p:void 0;return S=F(e,n,c,a,f,y,s),u.push(S),(n===I.ExternalActionId.OneInch||m&&n===I.ExternalActionId.Lifi)&&r&&o!==void 0&&await d(e,r,f,g,u,s,o),u}if(!r||!o)throw Error("There should be output token for UniSwap and Odos");if(t===C.zeroAddress){const p=e.getContractWithFetcher(h.ContractType.ERC20Contract,O);u.push(E.emporiumOp({contract:p,func:"deposit",value:w,invokeWallet:s})),t=O}let T=0n;if(r===C.zeroAddress&&(r=O,D=!0,T=await e.getContractWithFetcher(h.ContractType.ERC20Contract,O).balanceOf(f)),t!==C.zeroAddress){const p=e.getContractWithFetcher(h.ContractType.ERC20Contract,t);await b(e,u,p,f,c,s),u.push(E.createApproveEmporiumOp(p,c,w,s))}if(n===I.ExternalActionId.Uniswap?S=B(c,t,w,r,f,a,s):S=F(e,n,c,a,f,void 0,s),u.push(S),await d(e,r,f,g,u,s,o),D){const p=l.WRAPPER_TOKEN_EXCHANGE_ADDRESSES[q],y=e.getContractWithFetcher(h.ContractType.ERC20Contract,O);u.push(E.createApproveEmporiumOp(y,p,2n**256n-1n,s));const _=["function withdrawBalanceDifference(uint256 beforeBalance) external"],N=new R.ethers.Contract(p,_);u.push(E.emporiumOp({contract:N,func:"withdrawBalanceDifference",args:[T],invokeWallet:s}))}return u};exports.createSwapToEmporiumOpForUniswap=B;exports.createSwapToEmporiumOpFromData=F;exports.createSwapToEmporiumOps=z;exports.nullifyUsdtApprovalIfNeeded=b;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
1
2
|
import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
|
|
2
3
|
import { ExternalActionId } from '../../types/external-action.types';
|
|
3
4
|
export declare const createSwapToEmporiumOpForUniswap: (routerAddress: string, inputTokenAddress: string, positiveAmountInput: bigint, outputTokenAddress: string, recipient: string, data: string, invokeWallet?: boolean) => string;
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const createSwapToEmporiumOpFromData: (hinkal: IHinkal, externalActionId: ExternalActionId, routerAddress: string, data: string, walletAddress: string, value?: bigint, invokeWallet?: boolean) => string;
|
|
6
|
+
export declare const nullifyUsdtApprovalIfNeeded: (hinkal: IHinkal, ops: string[], tokenContract: ethers.Contract, walletAddress: string, spenderAddress: string, invokeWallet: boolean) => Promise<void>;
|
|
7
|
+
export declare const createSwapToEmporiumOps: (hinkal: IHinkal, externalActionId: ExternalActionId, routerAddress: string, data: string, inputTokenAddress: string, inputAmount: bigint, outputAmount: bigint | undefined, outputTokenAddress: string | undefined, isTheSameChainSwap: boolean, walletAddress: string, relay: string, invokeWallet?: boolean) => Promise<string[]>;
|
|
@@ -1,155 +1,157 @@
|
|
|
1
|
-
import { BigNumber as K, ethers as
|
|
2
|
-
import { emporiumOp as u, createApproveEmporiumOp as
|
|
1
|
+
import { BigNumber as K, ethers as D } from "ethers";
|
|
2
|
+
import { emporiumOp as u, createApproveEmporiumOp as I } 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 O } 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 w, HINKAL_SWAP_VARIABLE_RATE as P } 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 l } from "../../error-handling/logger.mjs";
|
|
12
|
+
import { getERC20Registry as v } from "../../constants/token-data/ERC20Registry.mjs";
|
|
13
|
+
const z = (t, a, c, e, n, i, o = !1) => {
|
|
14
|
+
const r = K.from(i).toBigInt(), C = {
|
|
15
|
+
tokenIn: a,
|
|
16
|
+
tokenOut: e,
|
|
17
|
+
fee: r,
|
|
18
|
+
recipient: n,
|
|
19
|
+
amountIn: c,
|
|
20
20
|
amountOutMinimum: 0,
|
|
21
21
|
sqrtPriceLimitX96: 0
|
|
22
|
-
},
|
|
22
|
+
}, m = [
|
|
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
|
+
], h = new D.Contract(t, m);
|
|
25
25
|
return u({
|
|
26
|
-
contract:
|
|
26
|
+
contract: h,
|
|
27
27
|
func: "exactInputSingle",
|
|
28
|
-
args: [
|
|
29
|
-
invokeWallet:
|
|
28
|
+
args: [C],
|
|
29
|
+
invokeWallet: o
|
|
30
30
|
});
|
|
31
|
-
},
|
|
32
|
-
const
|
|
31
|
+
}, N = (t, a, c, e, n, i, o = !1) => {
|
|
32
|
+
const r = X(t, a), C = H(e, r.slice(2), n.slice(2));
|
|
33
33
|
return u({
|
|
34
|
-
contract:
|
|
35
|
-
callDataString:
|
|
36
|
-
value:
|
|
37
|
-
invokeWallet:
|
|
34
|
+
contract: c,
|
|
35
|
+
callDataString: C,
|
|
36
|
+
value: i,
|
|
37
|
+
invokeWallet: o
|
|
38
38
|
});
|
|
39
|
-
},
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
}, L = async (
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
39
|
+
}, G = (t, a) => {
|
|
40
|
+
const e = v(a).find((n) => n.symbol === "USDT");
|
|
41
|
+
return e ? M(t, e.erc20TokenAddress) : !1;
|
|
42
|
+
}, L = async (t, a, c, e, n, i) => {
|
|
43
|
+
const o = c.address;
|
|
44
|
+
if (G(o, t.getCurrentChainId()))
|
|
45
45
|
try {
|
|
46
|
-
(await
|
|
47
|
-
} catch (
|
|
48
|
-
|
|
46
|
+
(await c.allowance(e, n)).toBigInt() > 0n && a.push(I(c, n, 0n, i));
|
|
47
|
+
} catch (r) {
|
|
48
|
+
l.error("Error in nullifyUsdtApprovalIfNeeded", r);
|
|
49
49
|
}
|
|
50
|
-
},
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
50
|
+
}, U = async (t, a, c, e, n, i, o) => {
|
|
51
|
+
if (a !== w) {
|
|
52
|
+
const r = V[t.getCurrentChainId()], C = t.getContractWithFetcher(g.ERC20Contract, a), m = await C.balanceOf(c);
|
|
53
53
|
await L(
|
|
54
54
|
t,
|
|
55
55
|
n,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
), n.push(
|
|
61
|
-
const
|
|
56
|
+
C,
|
|
57
|
+
c,
|
|
58
|
+
r,
|
|
59
|
+
i
|
|
60
|
+
), n.push(I(C, r, 2n ** 256n - 1n, i));
|
|
61
|
+
const h = [
|
|
62
62
|
"function takeSwapFee(address token, uint256 beforeBalance, uint256 variableRate, address relay) external payable"
|
|
63
|
-
],
|
|
63
|
+
], f = new D.Contract(r, h), E = e;
|
|
64
64
|
n.push(
|
|
65
65
|
u({
|
|
66
|
-
contract:
|
|
66
|
+
contract: f,
|
|
67
67
|
func: "takeSwapFee",
|
|
68
|
-
args: [
|
|
69
|
-
invokeWallet:
|
|
68
|
+
args: [a, m, P, E],
|
|
69
|
+
invokeWallet: i
|
|
70
70
|
})
|
|
71
71
|
);
|
|
72
72
|
} else {
|
|
73
|
-
const
|
|
73
|
+
const r = e;
|
|
74
74
|
n.push(
|
|
75
75
|
u({
|
|
76
|
-
contract:
|
|
77
|
-
value: o *
|
|
78
|
-
invokeWallet:
|
|
76
|
+
contract: r,
|
|
77
|
+
value: o * P / 10000n,
|
|
78
|
+
invokeWallet: i
|
|
79
79
|
})
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
|
-
},
|
|
83
|
-
const
|
|
84
|
-
let
|
|
85
|
-
if (
|
|
86
|
-
if (n !==
|
|
87
|
-
const
|
|
88
|
-
|
|
82
|
+
}, rt = async (t, a, c, e, n, i, o, r, C, m, h, f = !1) => {
|
|
83
|
+
const E = i < 0n ? -1n * i : i, y = t.getCurrentChainId(), p = [], S = T[y];
|
|
84
|
+
let _ = !1, R;
|
|
85
|
+
if (a === O.OneInch || a === O.Lifi) {
|
|
86
|
+
if (n !== w) {
|
|
87
|
+
const b = t.getContractWithFetcher(g.ERC20Contract, n);
|
|
88
|
+
p.push(I(b, c, E, f));
|
|
89
89
|
}
|
|
90
|
-
let
|
|
91
|
-
n ===
|
|
92
|
-
const
|
|
93
|
-
return
|
|
90
|
+
let s = 0n;
|
|
91
|
+
n === w && (s += E), o && r === w && o < 0n && (s += -1n * o);
|
|
92
|
+
const F = s > 0n ? s : void 0;
|
|
93
|
+
return R = N(
|
|
94
94
|
t,
|
|
95
|
-
r,
|
|
96
95
|
a,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
c,
|
|
97
|
+
e,
|
|
98
|
+
m,
|
|
99
|
+
F,
|
|
100
|
+
f
|
|
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;
|
|
102
102
|
}
|
|
103
|
-
if (!
|
|
103
|
+
if (!r || !o)
|
|
104
104
|
throw Error("There should be output token for UniSwap and Odos");
|
|
105
|
-
if (n ===
|
|
106
|
-
const
|
|
107
|
-
|
|
105
|
+
if (n === w) {
|
|
106
|
+
const s = t.getContractWithFetcher(g.ERC20Contract, S);
|
|
107
|
+
p.push(
|
|
108
108
|
u({
|
|
109
|
-
contract:
|
|
109
|
+
contract: s,
|
|
110
110
|
func: "deposit",
|
|
111
|
-
value:
|
|
112
|
-
invokeWallet:
|
|
111
|
+
value: E,
|
|
112
|
+
invokeWallet: f
|
|
113
113
|
})
|
|
114
|
-
), n =
|
|
114
|
+
), n = S;
|
|
115
115
|
}
|
|
116
|
-
let
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
await L(t,
|
|
116
|
+
let B = 0n;
|
|
117
|
+
if (r === w && (r = S, _ = !0, B = await t.getContractWithFetcher(g.ERC20Contract, S).balanceOf(m)), n !== w) {
|
|
118
|
+
const s = t.getContractWithFetcher(g.ERC20Contract, n);
|
|
119
|
+
await L(t, p, s, m, c, f), p.push(I(s, c, E, f));
|
|
120
120
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
121
|
+
if (a === O.Uniswap ? R = z(
|
|
122
|
+
c,
|
|
123
123
|
n,
|
|
124
|
-
C,
|
|
125
|
-
e,
|
|
126
124
|
E,
|
|
127
|
-
i,
|
|
128
|
-
s
|
|
129
|
-
) : O = U(
|
|
130
|
-
t,
|
|
131
125
|
r,
|
|
126
|
+
m,
|
|
127
|
+
e,
|
|
128
|
+
f
|
|
129
|
+
) : R = N(
|
|
130
|
+
t,
|
|
132
131
|
a,
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
c,
|
|
133
|
+
e,
|
|
134
|
+
m,
|
|
135
135
|
void 0,
|
|
136
|
-
|
|
137
|
-
),
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
136
|
+
f
|
|
137
|
+
), p.push(R), await U(t, r, m, h, p, f, o), _) {
|
|
138
|
+
const s = q[y], F = t.getContractWithFetcher(g.ERC20Contract, S);
|
|
139
|
+
p.push(I(F, s, 2n ** 256n - 1n, f));
|
|
140
|
+
const b = ["function withdrawBalanceDifference(uint256 beforeBalance) external"], x = new D.Contract(s, b);
|
|
141
|
+
p.push(
|
|
142
142
|
u({
|
|
143
143
|
contract: x,
|
|
144
144
|
func: "withdrawBalanceDifference",
|
|
145
|
-
args: [
|
|
146
|
-
invokeWallet:
|
|
145
|
+
args: [B],
|
|
146
|
+
invokeWallet: f
|
|
147
147
|
})
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
|
-
return
|
|
150
|
+
return p;
|
|
151
151
|
};
|
|
152
152
|
export {
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
z as createSwapToEmporiumOpForUniswap,
|
|
154
|
+
N as createSwapToEmporiumOpFromData,
|
|
155
|
+
rt as createSwapToEmporiumOps,
|
|
156
|
+
L as nullifyUsdtApprovalIfNeeded
|
|
155
157
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=require("../../data-structures/utxo/Utxo.cjs"),d=require("../../constants/protocol.constants.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"),Z=require("../web3/etherFunctions.cjs"),$=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"),j=require("../utils/time.utils.cjs"),ke=require("../../types/hinkal.types.cjs"),He=require("../utils/fees.utils.cjs"),G=require("../../data-structures/Hinkal/hinkalCheckTokenRegistry.cjs"),ye=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const Ce=require("./getMerkleTreeSiblingsAndRootHashes.cjs"),Te=async(s,J,K,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,r=void 0,L=!1,p,S=void 0,V,M=d.defaultSignatureData,x,U=!0)=>{const z=o.calcAmountChanges(t,e),k=o.calcEncryptedOutputs(e),h=m.getShieldedPrivateKey(),D=de.Utxo.findCorrectRandomization(Z.randomBigInt(31),h),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,K,U),E=await pe.performTaskWithWorker({type:Se.WorkerVariant.ZKProof,payload:{type:ge.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:_,onChainCreation:u,proverVersion:s}}}),I=o.buildOutCommitments(s,e,u),y=x??Z.randomBigInt(31),ne=ye.poseidonFunction(y),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:h,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:y},re=g?le.UserKeys.getSignerAddressFromPrivateKey(c,g):void 0,R=T,F=he.ExternalActionId.Emporium,N=await $.encodeEmporiumMetadata(c,T,g,X,ne,re),A=e.length===0?"swapperMWMin0":`swapperMW${C}x${Q}x${e[0].length}`,B=o.calcPublicSignalCount(A,n.erc20TokenAddresses,n.amountChanges,n.inNullifiers,n.outCommitments,f.length);if(r||(r=ke.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(C).fill([d.zeroAddress,d.zeroAddress,d.zeroAddress])}S||(S=He.generateFeeStructure(q,l));const v=o.calcAmountChanges(t,e,!0);p||(p=o.getSlippageValues(v,r)),n.calldataHash=o.createCallDataHash(s,B,w,R,F,N,k,q,void 0,p,u,r,S,M);const O={outTimeStamp:j.getCurrentTimeInSeconds(),rootHashAccessToken:H,calldataHash:n.calldataHash,shieldedPrivateKey:h,accessTokenSiblings:W,accessTokenSiblingSides:b,messageSeed:y},{zkCallData:ie}=await qe.generateZkProof(s,c,A,A==="swapperMWMin0"?O:n,Y),oe=o.calcStealthAddressStructure(D,h),se=await fe.generateCircomData(s,I,E,P,H,v,l,t,e,k,q,B,F,R,N,w,n.calldataHash,f,oe,u,Ae.defaultHookData,A==="swapperMWMin0"?O.outTimeStamp:n.outTimeStamp,r,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 $.getAuthorizationDataIfNeeded(c,g);return{zkCallData:ie,circomData:se,dimData:ce,encryptedOutputs:k,authorizationData:me}};exports.constructEmporiumProof=Te;
|