@hinkal/common 0.2.21 → 0.2.23
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 +64 -256
- package/constants/activity.constants.cjs +1 -1
- package/constants/activity.constants.mjs +0 -1
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.mjs +9 -10
- 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/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.d.ts +3 -3
- package/constants/contracts.constants.mjs +29 -29
- 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 +138 -35
- package/constants/tasks.constants.cjs +1 -1
- package/constants/tasks.constants.mjs +4 -5
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +13 -36
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +10 -10
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +86 -83
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +56 -45
- package/data-structures/Hinkal/Hinkal.mjs +348 -315
- package/data-structures/Hinkal/IHinkal.d.ts +56 -42
- 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 +19 -20
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +84 -89
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +96 -78
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +79 -75
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +151 -140
- 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 +120 -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 -115
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +29 -30
- 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 +180 -154
- 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 +46 -50
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +50 -52
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +65 -69
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +77 -71
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +70 -72
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +78 -81
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +103 -106
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +54 -108
- 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 +79 -97
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +39 -43
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +31 -36
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +40 -26
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +82 -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/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +10 -0
- package/data-structures/crypto-keys/keys.mjs +106 -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 +13 -13
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +3 -3
- 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 +6 -2
- 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 +40 -40
- 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 +2 -2
- 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/presale/PresaleContractWrapper.cjs +1 -1
- package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
- package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +16 -11
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +18 -18
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +9 -9
- 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 -22
- 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 +16 -17
- 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/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +2 -3
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +36 -22
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +2 -3
- 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 +12 -10
- package/functions/private-wallet/emporium.helpers.mjs +139 -102
- 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 +106 -103
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +21 -18
- 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 +11 -10
- 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 +11 -12
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +1 -1
- package/functions/utils/cacheFunctions.mjs +55 -54
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +2 -2
- package/functions/utils/create-provider.mjs +7 -11
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +9 -9
- package/functions/utils/ethers-formatter.utils.d.ts +1 -1
- package/functions/utils/external-action.utils.cjs +1 -1
- package/functions/utils/external-action.utils.mjs +2 -2
- 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/getContractAddress.cjs +1 -0
- package/functions/utils/getContractAddress.d.ts +2 -0
- package/functions/utils/getContractAddress.mjs +9 -0
- package/functions/utils/getDataFromTransaction.cjs +1 -1
- package/functions/utils/getDataFromTransaction.d.ts +0 -11
- package/functions/utils/getDataFromTransaction.mjs +26 -50
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
- package/functions/utils/getSignerFromContract.cjs +1 -0
- package/functions/utils/getSignerFromContract.d.ts +3 -0
- package/functions/utils/getSignerFromContract.mjs +16 -0
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +14 -15
- package/functions/utils/inLogicMetadata.cjs +1 -1
- package/functions/utils/inLogicMetadata.mjs +2 -2
- 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 -9
- 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.d.ts +1 -1
- package/functions/utils/publicBalance.utils.mjs +62 -57
- 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/rpc-int-encode.cjs +1 -1
- package/functions/utils/rpc-int-encode.d.ts +1 -2
- package/functions/utils/rpc-int-encode.mjs +3 -6
- package/functions/utils/solanaMint.utils.cjs +1 -1
- package/functions/utils/solanaMint.utils.mjs +6 -6
- 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/EIP-712.cjs +1 -1
- package/functions/web3/EIP-712.d.ts +4 -4
- package/functions/web3/EIP-712.mjs +1 -1
- package/functions/web3/etherFunctions.cjs +1 -1
- package/functions/web3/etherFunctions.mjs +32 -29
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +2 -3
- 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/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
- 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.d.ts +3 -3
- package/functions/web3/events/getTransactionLogEvents.mjs +41 -40
- package/functions/web3/events/index.d.ts +0 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +12 -16
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +6 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +20 -12
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +68 -69
- 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/constructBatchCall.cjs +1 -1
- package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
- package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
- 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 +29 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +47 -39
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +3 -3
- package/functions/web3/functionCalls/transactCallRelayer.mjs +54 -56
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.d.ts +1 -1
- package/functions/web3/getContractMetadata.mjs +21 -16
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.d.ts +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +7 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +32 -31
- 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 +15 -3
- 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 -8
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.d.ts +6 -5
- package/functions/web3/runContractFunction.mjs +60 -46
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +2 -2
- package/functions/web3/uniswapAPI.mjs +49 -38
- package/index.cjs +1 -1
- package/index.mjs +912 -914
- package/package.json +4 -6
- package/providers/CustomEthersProvider.d.ts +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +21 -14
- package/providers/EthersProviderAdapter.mjs +86 -53
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +12 -8
- package/providers/SolanaProviderAdapter.mjs +31 -16
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +20 -14
- package/providers/WagmiProviderAdapter.mjs +126 -91
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +2 -2
- package/providers/prepareEthersHinkal.mjs +9 -16
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +9 -17
- package/types/TransactionSimulator.types.d.ts +9 -2
- package/types/activities.types.d.ts +2 -5
- 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/big-intable.types.d.ts +3 -2
- 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 +10 -11
- 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/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -3
- package/types/transactions.types.mjs +6 -7
- 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/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.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/functions/web3/events/web3RetrieveEvents.cjs +0 -1
- package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
- package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
- 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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("ethers"),E=require("./emporium.helpers.cjs"),_=require("../../constants/addresses.constants.cjs"),I=require("../../types/external-action.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),x=require("../pre-transaction/getExternalSwapAddress.cjs"),B=require("../utils/string.utils.cjs"),C=require("../../constants/protocol.constants.cjs");require("../../constants/token-data/index.cjs");const N=require("../utils/caseInsensitive.utils.cjs"),U=require("../../error-handling/logger.cjs"),L=require("../utils/getContractAddress.cjs"),v=require("../../constants/token-data/ERC20Registry.cjs"),A=(e,n,c,a,t,s,o=!1)=>{const r=BigInt(s),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 F.ethers.Contract(e,f);return E.emporiumOp({contract:g,func:"exactInputSingle",args:[m],invokeWallet:o})},l=(e,n,c,a,t,s,o=!1)=>{const r=x.getExternalSwapAddress(e,n),m=B.replaceAllInstances(a,r.slice(2),t.slice(2));return E.emporiumOp({contract:c,callDataString:m,value:s,invokeWallet:o})},z=(e,n)=>{const a=v.getERC20Registry(n).find(t=>t.symbol==="USDT");return a?N.caseInsensitiveEqual(e,a.erc20TokenAddress):!1},q=async(e,n,c,a,t,s)=>{const o=L.getContractAddress(c);if(z(o,e.getCurrentChainId()))try{await c.allowance(a,t)>0n&&n.push(E.createApproveEmporiumOp(c,t,0n,s))}catch(r){U.Logger.error("Error in nullifyUsdtApprovalIfNeeded",r)}},T=async(e,n,c,a,t,s,o)=>{if(n!==C.zeroAddress){const r=_.SWAP_FEE_TAKER_ADDRESSES[e.getCurrentChainId()],m=e.getContractWithFetcher(h.ContractType.ERC20Contract,n),f=await m.balanceOf(c);await q(e,t,m,c,r,s),t.push(E.createApproveEmporiumOp(m,r,2n**256n-1n,s));const g=["function takeSwapFee(address token, uint256 beforeBalance, uint256 variableRate, address relay) external payable"],i=new F.ethers.Contract(r,g),w=a;t.push(E.emporiumOp({contract:i,func:"takeSwapFee",args:[n,f,C.HINKAL_SWAP_VARIABLE_RATE,w],invokeWallet:s}))}else{const r=a;t.push(E.emporiumOp({contract:r,value:o*C.HINKAL_SWAP_VARIABLE_RATE/10000n,invokeWallet:s}))}},K=async(e,n,c,a,t,s,o,r,m,f,g,i=!1)=>{const w=s<0n?-1n*s:s,b=e.getCurrentChainId(),u=[],O=_.NATIVE_TOKEN_WRAPPER_ADDRESSES[b];let d=!1,S;if(n===I.ExternalActionId.OneInch||n===I.ExternalActionId.Lifi){if(t!==C.zeroAddress){const y=e.getContractWithFetcher(h.ContractType.ERC20Contract,t);u.push(E.createApproveEmporiumOp(y,c,w,i))}let p=0n;t===C.zeroAddress&&(p+=w),o&&r===C.zeroAddress&&o<0n&&(p+=-1n*o);const R=p>0n?p:void 0;return S=l(e,n,c,a,f,R,i),u.push(S),(n===I.ExternalActionId.OneInch||m&&n===I.ExternalActionId.Lifi)&&r&&o!==void 0&&await T(e,r,f,g,u,i,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:i})),t=O}let D=0n;if(r===C.zeroAddress&&(r=O,d=!0,D=await e.getContractWithFetcher(h.ContractType.ERC20Contract,O).balanceOf(f)),t!==C.zeroAddress){const p=e.getContractWithFetcher(h.ContractType.ERC20Contract,t);await q(e,u,p,f,c,i),u.push(E.createApproveEmporiumOp(p,c,w,i))}if(n===I.ExternalActionId.Uniswap?S=A(c,t,w,r,f,a,i):S=l(e,n,c,a,f,void 0,i),u.push(S),await T(e,r,f,g,u,i,o),d){const p=_.WRAPPER_TOKEN_EXCHANGE_ADDRESSES[b],R=e.getContractWithFetcher(h.ContractType.ERC20Contract,O);u.push(E.createApproveEmporiumOp(R,p,2n**256n-1n,i));const y=["function withdrawBalanceDifference(uint256 beforeBalance) external"],P=new F.ethers.Contract(p,y);u.push(E.emporiumOp({contract:P,func:"withdrawBalanceDifference",args:[D],invokeWallet:i}))}return u};exports.createSwapToEmporiumOpForUniswap=A;exports.createSwapToEmporiumOpFromData=l;exports.createSwapToEmporiumOps=K;exports.nullifyUsdtApprovalIfNeeded=q;
|
|
@@ -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,158 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { emporiumOp as u, createApproveEmporiumOp as
|
|
3
|
-
import { NATIVE_TOKEN_WRAPPER_ADDRESSES as
|
|
4
|
-
import { ExternalActionId as
|
|
1
|
+
import { ethers as D } from "ethers";
|
|
2
|
+
import { emporiumOp as u, createApproveEmporiumOp as I } from "./emporium.helpers.mjs";
|
|
3
|
+
import { NATIVE_TOKEN_WRAPPER_ADDRESSES as K, WRAPPER_TOKEN_EXCHANGE_ADDRESSES as T, SWAP_FEE_TAKER_ADDRESSES as q } from "../../constants/addresses.constants.mjs";
|
|
4
|
+
import { ExternalActionId as O } from "../../types/external-action.types.mjs";
|
|
5
5
|
import { ContractType as g } from "../../types/ethereum-network.types.mjs";
|
|
6
|
-
import { getExternalSwapAddress as
|
|
7
|
-
import { replaceAllInstances as
|
|
8
|
-
import { zeroAddress as
|
|
6
|
+
import { getExternalSwapAddress as V } from "../pre-transaction/getExternalSwapAddress.mjs";
|
|
7
|
+
import { replaceAllInstances as X } from "../utils/string.utils.mjs";
|
|
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
|
-
import { caseInsensitiveEqual as
|
|
11
|
-
import { Logger as
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
import { caseInsensitiveEqual as H } from "../utils/caseInsensitive.utils.mjs";
|
|
11
|
+
import { Logger as M } from "../../error-handling/logger.mjs";
|
|
12
|
+
import { getContractAddress as l } from "../utils/getContractAddress.mjs";
|
|
13
|
+
import { getERC20Registry as v } from "../../constants/token-data/ERC20Registry.mjs";
|
|
14
|
+
const z = (t, c, a, e, n, i, o = !1) => {
|
|
15
|
+
const r = BigInt(i), C = {
|
|
16
|
+
tokenIn: c,
|
|
17
|
+
tokenOut: e,
|
|
18
|
+
fee: r,
|
|
19
|
+
recipient: n,
|
|
20
|
+
amountIn: a,
|
|
20
21
|
amountOutMinimum: 0,
|
|
21
22
|
sqrtPriceLimitX96: 0
|
|
22
|
-
},
|
|
23
|
+
}, m = [
|
|
23
24
|
"function exactInputSingle(tuple(address tokenIn,address tokenOut,uint24 fee,address recipient,uint256 amountIn,uint256 amountOutMinimum,uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)"
|
|
24
|
-
],
|
|
25
|
+
], h = new D.Contract(t, m);
|
|
25
26
|
return u({
|
|
26
|
-
contract:
|
|
27
|
+
contract: h,
|
|
27
28
|
func: "exactInputSingle",
|
|
28
|
-
args: [
|
|
29
|
-
invokeWallet:
|
|
29
|
+
args: [C],
|
|
30
|
+
invokeWallet: o
|
|
30
31
|
});
|
|
31
|
-
}, U = (
|
|
32
|
-
const
|
|
32
|
+
}, U = (t, c, a, e, n, i, o = !1) => {
|
|
33
|
+
const r = V(t, c), C = X(e, r.slice(2), n.slice(2));
|
|
33
34
|
return u({
|
|
34
|
-
contract:
|
|
35
|
-
callDataString:
|
|
36
|
-
value:
|
|
37
|
-
invokeWallet:
|
|
35
|
+
contract: a,
|
|
36
|
+
callDataString: C,
|
|
37
|
+
value: i,
|
|
38
|
+
invokeWallet: o
|
|
38
39
|
});
|
|
39
|
-
},
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
},
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
40
|
+
}, G = (t, c) => {
|
|
41
|
+
const e = v(c).find((n) => n.symbol === "USDT");
|
|
42
|
+
return e ? H(t, e.erc20TokenAddress) : !1;
|
|
43
|
+
}, N = async (t, c, a, e, n, i) => {
|
|
44
|
+
const o = l(a);
|
|
45
|
+
if (G(o, t.getCurrentChainId()))
|
|
45
46
|
try {
|
|
46
|
-
|
|
47
|
-
} catch (
|
|
48
|
-
|
|
47
|
+
await a.allowance(e, n) > 0n && c.push(I(a, n, 0n, i));
|
|
48
|
+
} catch (r) {
|
|
49
|
+
M.error("Error in nullifyUsdtApprovalIfNeeded", r);
|
|
49
50
|
}
|
|
50
|
-
},
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
53
|
-
await
|
|
51
|
+
}, L = async (t, c, a, e, n, i, o) => {
|
|
52
|
+
if (c !== w) {
|
|
53
|
+
const r = q[t.getCurrentChainId()], C = t.getContractWithFetcher(g.ERC20Contract, c), m = await C.balanceOf(a);
|
|
54
|
+
await N(
|
|
54
55
|
t,
|
|
55
56
|
n,
|
|
56
|
-
|
|
57
|
+
C,
|
|
57
58
|
a,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
), n.push(
|
|
61
|
-
const
|
|
59
|
+
r,
|
|
60
|
+
i
|
|
61
|
+
), n.push(I(C, r, 2n ** 256n - 1n, i));
|
|
62
|
+
const h = [
|
|
62
63
|
"function takeSwapFee(address token, uint256 beforeBalance, uint256 variableRate, address relay) external payable"
|
|
63
|
-
],
|
|
64
|
+
], f = new D.Contract(r, h), E = e;
|
|
64
65
|
n.push(
|
|
65
66
|
u({
|
|
66
|
-
contract:
|
|
67
|
+
contract: f,
|
|
67
68
|
func: "takeSwapFee",
|
|
68
|
-
args: [
|
|
69
|
-
invokeWallet:
|
|
69
|
+
args: [c, m, P, E],
|
|
70
|
+
invokeWallet: i
|
|
70
71
|
})
|
|
71
72
|
);
|
|
72
73
|
} else {
|
|
73
|
-
const
|
|
74
|
+
const r = e;
|
|
74
75
|
n.push(
|
|
75
76
|
u({
|
|
76
|
-
contract:
|
|
77
|
-
value: o *
|
|
78
|
-
invokeWallet:
|
|
77
|
+
contract: r,
|
|
78
|
+
value: o * P / 10000n,
|
|
79
|
+
invokeWallet: i
|
|
79
80
|
})
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
|
-
},
|
|
83
|
-
const
|
|
84
|
-
let
|
|
85
|
-
if (
|
|
86
|
-
if (n !==
|
|
87
|
-
const
|
|
88
|
-
|
|
83
|
+
}, ct = async (t, c, a, e, n, i, o, r, C, m, h, f = !1) => {
|
|
84
|
+
const E = i < 0n ? -1n * i : i, y = t.getCurrentChainId(), p = [], S = K[y];
|
|
85
|
+
let _ = !1, R;
|
|
86
|
+
if (c === O.OneInch || c === O.Lifi) {
|
|
87
|
+
if (n !== w) {
|
|
88
|
+
const b = t.getContractWithFetcher(g.ERC20Contract, n);
|
|
89
|
+
p.push(I(b, a, E, f));
|
|
89
90
|
}
|
|
90
|
-
let
|
|
91
|
-
n ===
|
|
92
|
-
const
|
|
93
|
-
return
|
|
91
|
+
let s = 0n;
|
|
92
|
+
n === w && (s += E), o && r === w && o < 0n && (s += -1n * o);
|
|
93
|
+
const F = s > 0n ? s : void 0;
|
|
94
|
+
return R = U(
|
|
94
95
|
t,
|
|
95
|
-
|
|
96
|
+
c,
|
|
96
97
|
a,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
),
|
|
98
|
+
e,
|
|
99
|
+
m,
|
|
100
|
+
F,
|
|
101
|
+
f
|
|
102
|
+
), p.push(R), (c === O.OneInch || C && c === O.Lifi) && r && o !== void 0 && await L(t, r, m, h, p, f, o), p;
|
|
102
103
|
}
|
|
103
|
-
if (!
|
|
104
|
+
if (!r || !o)
|
|
104
105
|
throw Error("There should be output token for UniSwap and Odos");
|
|
105
|
-
if (n ===
|
|
106
|
-
const
|
|
107
|
-
|
|
106
|
+
if (n === w) {
|
|
107
|
+
const s = t.getContractWithFetcher(g.ERC20Contract, S);
|
|
108
|
+
p.push(
|
|
108
109
|
u({
|
|
109
|
-
contract:
|
|
110
|
+
contract: s,
|
|
110
111
|
func: "deposit",
|
|
111
|
-
value:
|
|
112
|
-
invokeWallet:
|
|
112
|
+
value: E,
|
|
113
|
+
invokeWallet: f
|
|
113
114
|
})
|
|
114
|
-
), n =
|
|
115
|
+
), n = S;
|
|
115
116
|
}
|
|
116
|
-
let
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
await
|
|
117
|
+
let B = 0n;
|
|
118
|
+
if (r === w && (r = S, _ = !0, B = await t.getContractWithFetcher(g.ERC20Contract, S).balanceOf(m)), n !== w) {
|
|
119
|
+
const s = t.getContractWithFetcher(g.ERC20Contract, n);
|
|
120
|
+
await N(t, p, s, m, a, f), p.push(I(s, a, E, f));
|
|
120
121
|
}
|
|
121
|
-
if (
|
|
122
|
+
if (c === O.Uniswap ? R = z(
|
|
122
123
|
a,
|
|
123
124
|
n,
|
|
124
|
-
C,
|
|
125
|
-
e,
|
|
126
125
|
E,
|
|
127
|
-
i,
|
|
128
|
-
s
|
|
129
|
-
) : O = U(
|
|
130
|
-
t,
|
|
131
126
|
r,
|
|
127
|
+
m,
|
|
128
|
+
e,
|
|
129
|
+
f
|
|
130
|
+
) : R = U(
|
|
131
|
+
t,
|
|
132
|
+
c,
|
|
132
133
|
a,
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
e,
|
|
135
|
+
m,
|
|
135
136
|
void 0,
|
|
136
|
-
|
|
137
|
-
),
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
137
|
+
f
|
|
138
|
+
), p.push(R), await L(t, r, m, h, p, f, o), _) {
|
|
139
|
+
const s = T[y], F = t.getContractWithFetcher(g.ERC20Contract, S);
|
|
140
|
+
p.push(I(F, s, 2n ** 256n - 1n, f));
|
|
141
|
+
const b = ["function withdrawBalanceDifference(uint256 beforeBalance) external"], x = new D.Contract(s, b);
|
|
142
|
+
p.push(
|
|
142
143
|
u({
|
|
143
144
|
contract: x,
|
|
144
145
|
func: "withdrawBalanceDifference",
|
|
145
|
-
args: [
|
|
146
|
-
invokeWallet:
|
|
146
|
+
args: [B],
|
|
147
|
+
invokeWallet: f
|
|
147
148
|
})
|
|
148
149
|
);
|
|
149
150
|
}
|
|
150
|
-
return
|
|
151
|
+
return p;
|
|
151
152
|
};
|
|
152
153
|
export {
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
z as createSwapToEmporiumOpForUniswap,
|
|
155
|
+
U as createSwapToEmporiumOpFromData,
|
|
156
|
+
ct as createSwapToEmporiumOps,
|
|
157
|
+
N as nullifyUsdtApprovalIfNeeded
|
|
155
158
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../externalABIs/index.cjs"),p=require("ethers"),d=require("./emporium.helpers.cjs");var o=(e=>(e[e.Erc20Token=0]="Erc20Token",e[e.Uniswap=1]="Uniswap",e))(o||{});const h=(e,c,n,i,s,a)=>{let r=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../externalABIs/index.cjs"),p=require("ethers"),d=require("./emporium.helpers.cjs");var o=(e=>(e[e.Erc20Token=0]="Erc20Token",e[e.Uniswap=1]="Uniswap",e))(o||{});const h=(e,c,n,i,s,a)=>{let r=[];switch(e){case 0:r=t.ERC20ABI;break;case 1:r=t.ISwapRouterABI;break}if(!r)throw Error("No ABI match in produceOp");const u=new p.ethers.Contract(c,r);return d.emporiumOp({contract:u,func:n,args:i,invokeWallet:s,value:a})};exports.OpType=o;exports.produceOp=h;
|
|
@@ -3,7 +3,7 @@ import { ethers as p } from "ethers";
|
|
|
3
3
|
import { emporiumOp as u } from "./emporium.helpers.mjs";
|
|
4
4
|
var w = /* @__PURE__ */ ((r) => (r[r.Erc20Token = 0] = "Erc20Token", r[r.Uniswap = 1] = "Uniswap", r))(w || {});
|
|
5
5
|
const E = (r, t, e, c, a, n) => {
|
|
6
|
-
let o =
|
|
6
|
+
let o = [];
|
|
7
7
|
switch (r) {
|
|
8
8
|
case 0:
|
|
9
9
|
o = s;
|
|
@@ -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,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(
|
|
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(i=>t[r]?"0":i.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,i=0n;for(let l=0;l<e[n].length;l+=1)r+=e[n][l].amount;for(let l=0;l<s[n].length;l+=1)i+=s[n][l].amount;i-r<0?t?a.push(i-r):a.push(d.CIRCOM_P+(i-r)):a.push(i-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,i)=>a===u.HinkalLogicAction.NONE||a===u.HinkalLogicAction.APPROVE?r+t[i]>=0n?0n:r+t[i]:r>=0n?0n:r);return a===u.HinkalLogicAction.RELEASE_BUFFER?e.forEach((r,i)=>{n[i]=r>0n?-r:r}):a===u.HinkalLogicAction.EXECUTE&&s.executeApprovalChanges.forEach((r,i)=>{n[i]=r+e[i]<0n?r+e[i]: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(i=>i.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(i=>i.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,i,l,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.AbiCoder.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,i,l]);return BigInt(o.ethers.keccak256(p))%d.CIRCOM_P}else{const p=o.ethers.AbiCoder.defaultAbiCoder().encode(["uint16","address","address","uint256","bytes"],[s,t,a,typeof n=="bigint"?n:f.getExternalActionIdHash(n),r]),A=o.ethers.AbiCoder.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,i,[g.feeToken,g.flatFee,g.variableRate],k,b,[c.hinkalLogicAction,c.inHinkalAddress,c.executeApprovalChanges,c.doPreTxApproval,c.useApprovalUtxoData],m,I]),y=BigInt(o.ethers.keccak256(p)),B=BigInt(o.ethers.keccak256(A)),O=o.ethers.AbiCoder.defaultAbiCoder().encode(["uint256","uint256"],[y,B]);return BigInt(o.ethers.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 i=N(e);return 10+s.length+t.length+a.flat().length+n.flat().length+i+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;
|
|
@@ -5,7 +5,7 @@ import { UserKeys as S } from "../../data-structures/crypto-keys/keys.mjs";
|
|
|
5
5
|
import { encryptUtxo as y } from "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
|
|
6
6
|
import { defaultHookData as O } from "../../types/circom-data.types.mjs";
|
|
7
7
|
import { getExternalActionIdHash as f } from "../utils/external-action.utils.mjs";
|
|
8
|
-
import { HinkalLogicAction as
|
|
8
|
+
import { HinkalLogicAction as g } 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
11
|
const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier())), q = (e, s, t) => {
|
|
@@ -25,10 +25,10 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
25
25
|
}
|
|
26
26
|
return r;
|
|
27
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 ===
|
|
29
|
-
return r ===
|
|
28
|
+
const t = L(s), r = s.hinkalLogicAction, n = e.map((a, l) => r === g.NONE || r === g.APPROVE ? a + t[l] >= 0n ? 0n : a + t[l] : a >= 0n ? 0n : a);
|
|
29
|
+
return r === g.RELEASE_BUFFER ? e.forEach((a, l) => {
|
|
30
30
|
n[l] = a > 0n ? -a : a;
|
|
31
|
-
}) : r ===
|
|
31
|
+
}) : r === g.EXECUTE && s.executeApprovalChanges.forEach((a, l) => {
|
|
32
32
|
n[l] = a + e[l] < 0n ? a + e[l] : 0n;
|
|
33
33
|
}), n;
|
|
34
34
|
}, Y = (e) => {
|
|
@@ -89,10 +89,10 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
89
89
|
})
|
|
90
90
|
), t;
|
|
91
91
|
}
|
|
92
|
-
}, se = (e, s, t, r, n, a, l, i, m, H,
|
|
92
|
+
}, se = (e, s, t, r, n, a, l, i, m, C, H, d, u, k, b) => {
|
|
93
93
|
const h = Object.values(m || O), v = b ?? R(r ?? E, t);
|
|
94
94
|
if (e === "v1x0") {
|
|
95
|
-
const p = o.
|
|
95
|
+
const p = o.AbiCoder.defaultAbiCoder().encode(
|
|
96
96
|
[
|
|
97
97
|
"uint16",
|
|
98
98
|
"address",
|
|
@@ -114,9 +114,9 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
114
114
|
i
|
|
115
115
|
]
|
|
116
116
|
);
|
|
117
|
-
return BigInt(o.
|
|
117
|
+
return BigInt(o.keccak256(p)) % c;
|
|
118
118
|
} else {
|
|
119
|
-
const p = o.
|
|
119
|
+
const p = o.AbiCoder.defaultAbiCoder().encode(
|
|
120
120
|
["uint16", "address", "address", "uint256", "bytes"],
|
|
121
121
|
[
|
|
122
122
|
s,
|
|
@@ -125,7 +125,7 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
125
125
|
typeof n == "bigint" ? n : f(n),
|
|
126
126
|
a
|
|
127
127
|
]
|
|
128
|
-
), A = o.
|
|
128
|
+
), A = o.AbiCoder.defaultAbiCoder().encode(
|
|
129
129
|
[
|
|
130
130
|
"tuple(address, address, bytes, bytes)",
|
|
131
131
|
"bytes[][]",
|
|
@@ -139,21 +139,24 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
139
139
|
[
|
|
140
140
|
h,
|
|
141
141
|
l,
|
|
142
|
-
[
|
|
143
|
-
H,
|
|
142
|
+
[u.feeToken, u.flatFee, u.variableRate],
|
|
144
143
|
C,
|
|
144
|
+
H,
|
|
145
145
|
[
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
d.hinkalLogicAction,
|
|
147
|
+
d.inHinkalAddress,
|
|
148
|
+
d.executeApprovalChanges,
|
|
149
|
+
d.doPreTxApproval,
|
|
150
|
+
d.useApprovalUtxoData
|
|
151
151
|
],
|
|
152
152
|
k,
|
|
153
153
|
v
|
|
154
154
|
]
|
|
155
|
-
), I = BigInt(o.
|
|
156
|
-
|
|
155
|
+
), I = BigInt(o.keccak256(p)), B = BigInt(o.keccak256(A)), V = o.AbiCoder.defaultAbiCoder().encode(
|
|
156
|
+
["uint256", "uint256"],
|
|
157
|
+
[I, B]
|
|
158
|
+
);
|
|
159
|
+
return BigInt(o.keccak256(V)) % c;
|
|
157
160
|
}
|
|
158
161
|
}, 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
162
|
if (e.startsWith("swapperMWMin0"))
|
|
@@ -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;
|