@hinkal/common 0.2.17 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/API.cjs +1 -1
- package/API/API.d.ts +8 -13
- package/API/API.mjs +86 -94
- package/API/admin-calls.cjs +1 -1
- package/API/admin-calls.d.ts +1 -1
- package/API/admin-calls.mjs +4 -4
- package/API/callLifiAPI.cjs +1 -1
- package/API/callLifiAPI.d.ts +1 -1
- package/API/callLifiAPI.mjs +5 -5
- package/API/callMonitor.cjs +1 -1
- package/API/callMonitor.d.ts +1 -1
- package/API/callMonitor.mjs +7 -7
- package/API/callOdosAPI.cjs +1 -1
- package/API/callOdosAPI.mjs +11 -11
- package/API/callOkxAPI.cjs +1 -1
- package/API/callOkxAPI.d.ts +1 -1
- package/API/callOkxAPI.mjs +5 -5
- package/API/callOneInchAPI.cjs +1 -1
- package/API/callOneInchAPI.mjs +10 -11
- package/API/callRelayer.cjs +1 -1
- package/API/callRelayer.d.ts +6 -3
- package/API/callRelayer.mjs +11 -11
- package/API/checkRisk.cjs +1 -1
- package/API/checkRisk.d.ts +1 -1
- package/API/checkRisk.mjs +4 -4
- package/API/fetchCommitmentsCache.cjs +1 -1
- package/API/fetchCommitmentsCache.mjs +9 -9
- package/API/get-token-data.cjs +1 -1
- package/API/get-token-data.d.ts +1 -1
- package/API/get-token-data.mjs +5 -5
- package/API/get-token-price-chart-data.cjs +1 -0
- package/API/get-token-price-chart-data.d.ts +16 -0
- package/API/get-token-price-chart-data.mjs +13 -0
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.mjs +9 -9
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.d.ts +3 -3
- package/API/getServerURL.mjs +51 -67
- package/API/getTokenPrice.cjs +1 -1
- package/API/getTokenPrice.d.ts +5 -0
- package/API/getTokenPrice.mjs +14 -7
- package/API/getWebsiteURL.d.ts +1 -1
- package/API/index.d.ts +0 -3
- package/API/is-tx-stateless.cjs +1 -1
- package/API/is-tx-stateless.d.ts +1 -1
- package/API/is-tx-stateless.mjs +10 -12
- package/API/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +4 -8
- package/API/kycCalls.mjs +23 -26
- package/API/onrampCalls.cjs +1 -0
- package/API/onrampCalls.d.ts +20 -0
- package/API/onrampCalls.mjs +15 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +2 -2
- package/API/proxyAccountsCalls.mjs +19 -19
- package/API/relayCalls.cjs +1 -1
- package/API/relayCalls.mjs +4 -4
- package/API/scheduled-transactions-calls.cjs +1 -1
- package/API/scheduled-transactions-calls.d.ts +1 -1
- package/API/scheduled-transactions-calls.mjs +4 -4
- package/API/simulate-batch-tx.cjs +1 -1
- package/API/simulate-batch-tx.d.ts +2 -2
- package/API/simulate-batch-tx.mjs +7 -6
- package/API/solana-calls.cjs +1 -1
- package/API/solana-calls.d.ts +6 -3
- package/API/solana-calls.mjs +15 -15
- package/API/token-calls.cjs +1 -1
- package/API/token-calls.mjs +6 -5
- package/API/unspent-utxos-calls.cjs +1 -1
- package/API/unspent-utxos-calls.d.ts +1 -1
- package/API/unspent-utxos-calls.mjs +15 -18
- package/README.md +237 -61
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.d.ts +0 -1
- package/constants/addresses.constants.mjs +7 -8
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +0 -5
- package/constants/chains.constants.mjs +21 -26
- package/constants/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.d.ts +1 -0
- package/constants/coingecko.constants.mjs +11 -10
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +34 -41
- package/constants/function-signatures.constants.cjs +1 -1
- package/constants/function-signatures.constants.d.ts +0 -1
- package/constants/function-signatures.constants.mjs +3 -4
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +2 -0
- package/constants/mediaUrls.constants.mjs +3 -1
- package/constants/mystery-boxes.constants.d.ts +0 -0
- package/constants/permit2.constants.cjs +1 -1
- package/constants/permit2.constants.d.ts +0 -1
- package/constants/permit2.constants.mjs +10 -11
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +14 -122
- package/constants/server.constants.mjs +44 -152
- package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistry.json.mjs +0 -24
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +0 -24
- package/constants/token-data/index.d.ts +32 -88
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +0 -26
- package/constants/token-data/popularTokens.constants.cjs +1 -1
- package/constants/token-data/popularTokens.constants.mjs +0 -1
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +36 -13
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +34 -49
- package/data-structures/Hinkal/Hinkal.mjs +238 -301
- package/data-structures/Hinkal/IHinkal.d.ts +33 -48
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +42 -42
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -23
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +9 -9
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +95 -93
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +147 -133
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +1 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +107 -115
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +36 -34
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +34 -33
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.d.ts +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +26 -24
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +8 -9
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +4 -3
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +86 -97
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +146 -146
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +2 -3
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +38 -38
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +57 -56
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +59 -58
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +83 -79
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +49 -48
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +67 -64
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +75 -87
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.d.ts +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +55 -58
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +80 -82
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.d.ts +2 -2
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +87 -90
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +105 -53
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.mjs +7 -7
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +8 -8
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +10 -10
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +25 -40
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +10 -11
- package/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
- package/data-structures/TokenDBs/token-visibility-db.mjs +22 -36
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.d.ts +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +14 -14
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +1 -0
- package/data-structures/event-service/evm/AbstractEventService.mjs +7 -4
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +0 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +3 -4
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +3 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +17 -14
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +1 -0
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +9 -6
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +0 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +1 -2
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +3 -2
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +42 -45
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +8 -13
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +3 -4
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +3 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +3 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +2 -4
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +3 -4
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +1 -7
- package/data-structures/utxo/Utxo.mjs +26 -36
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +3 -0
- package/error-handling/error-codes.constants.mjs +5 -2
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +21 -27
- package/error-handling/index.d.ts +0 -1
- package/functions/index.d.ts +0 -1
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +18 -17
- package/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/functions/pre-transaction/constructAdminData.d.ts +2 -2
- package/functions/pre-transaction/constructAdminData.mjs +12 -18
- package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/functions/pre-transaction/getExternalSwapAddress.d.ts +1 -2
- package/functions/pre-transaction/getExternalSwapAddress.mjs +8 -8
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +22 -30
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +21 -36
- package/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.d.ts +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +17 -17
- package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +1 -9
- package/functions/pre-transaction/outputApprovalDataProcessing.mjs +19 -34
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +4 -4
- package/functions/pre-transaction/solana-public-signals.cjs +1 -1
- package/functions/pre-transaction/solana-public-signals.d.ts +1 -0
- package/functions/pre-transaction/solana-public-signals.mjs +29 -26
- package/functions/pre-transaction/solana.cjs +1 -1
- package/functions/pre-transaction/solana.d.ts +2 -1
- package/functions/pre-transaction/solana.mjs +60 -51
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +3 -5
- package/functions/private-wallet/emporium.helpers.mjs +95 -135
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.d.ts +1 -4
- package/functions/private-wallet/emporium.swap.helpers.mjs +100 -102
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.d.ts +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +64 -64
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +2 -2
- package/functions/snarkjs/constructEmporiumProof.mjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +2 -3
- package/functions/snarkjs/constructGeneralZkProof.mjs +117 -121
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.d.ts +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +54 -59
- package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
- package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +11 -10
- package/functions/snarkjs/generateCircomData.d.ts +1 -1
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.d.ts +1 -0
- package/functions/utils/addresses.mjs +13 -12
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +2 -2
- package/functions/utils/enum.utils.cjs +1 -0
- package/functions/utils/enum.utils.mjs +14 -0
- package/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/functions/utils/erc20tokenFunctions.d.ts +0 -1
- package/functions/utils/erc20tokenFunctions.mjs +22 -29
- package/functions/utils/get-hinkal-approvals.cjs +1 -1
- package/functions/utils/get-hinkal-approvals.d.ts +1 -1
- package/functions/utils/get-hinkal-approvals.mjs +16 -16
- package/functions/utils/getDataFromTransaction.d.ts +3 -3
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +11 -11
- package/functions/utils/involves-permit2-op.cjs +1 -1
- package/functions/utils/involves-permit2-op.d.ts +0 -1
- package/functions/utils/involves-permit2-op.mjs +4 -6
- package/functions/utils/mutexes.utils.cjs +1 -1
- package/functions/utils/mutexes.utils.d.ts +1 -1
- package/functions/utils/mutexes.utils.mjs +3 -3
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +8 -23
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +0 -6
- package/functions/utils/prepareHinkal.mjs +41 -60
- package/functions/utils/token-check.utils.cjs +1 -1
- package/functions/utils/token-check.utils.d.ts +3 -0
- package/functions/utils/token-check.utils.mjs +18 -7
- package/functions/utils/upToDateState.cjs +1 -1
- package/functions/utils/upToDateState.d.ts +1 -1
- package/functions/utils/upToDateState.mjs +4 -4
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +1 -16
- package/functions/utils/walletBalances.utils.mjs +4 -35
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.d.ts +3 -4
- package/functions/web3/events/getApprovedBalance.mjs +39 -44
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.d.ts +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.mjs +114 -121
- package/functions/web3/events/getInputUtxosEnclave.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.mjs +71 -70
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.mjs +7 -7
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +7 -7
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +1 -6
- package/functions/web3/functionCalls/accessTokenCalls.mjs +12 -21
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +71 -63
- package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.mjs +6 -6
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.d.ts +1 -2
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +10 -10
- package/functions/web3/functionCalls/recoverTransactionFromError.cjs +1 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +2 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.mjs +23 -0
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +45 -36
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +44 -43
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.d.ts +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +6 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +8 -8
- package/functions/web3/lifiAPI.cjs +1 -1
- package/functions/web3/lifiAPI.d.ts +1 -1
- package/functions/web3/lifiAPI.mjs +12 -12
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -19
- package/functions/web3/okxAPI.cjs +1 -1
- package/functions/web3/okxAPI.mjs +22 -22
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +7 -20
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +38 -56
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +22 -34
- package/index.cjs +1 -1
- package/index.mjs +937 -967
- package/package.json +2 -2
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +10 -17
- package/providers/EthersProviderAdapter.mjs +48 -76
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +7 -11
- package/providers/SolanaProviderAdapter.mjs +16 -31
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +11 -17
- package/providers/WagmiProviderAdapter.mjs +86 -117
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +6 -7
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +5 -5
- package/types/TransactionSimulator.types.d.ts +2 -9
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +3 -7
- package/types/admin.types.mjs +2 -2
- package/types/balances.types.d.ts +0 -1
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +2 -3
- package/types/cache.types.mjs +1 -1
- package/types/coingecko.types.d.ts +5 -0
- package/types/ethereum-network.types.cjs +1 -1
- package/types/ethereum-network.types.d.ts +1 -8
- package/types/ethereum-network.types.mjs +1 -1
- package/types/external-action.types.cjs +1 -1
- package/types/external-action.types.d.ts +0 -1
- package/types/external-action.types.mjs +1 -1
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +1 -7
- package/types/hinkal.types.mjs +22 -23
- package/types/index.d.ts +1 -3
- package/types/onramp.types.cjs +1 -0
- package/types/onramp.types.d.ts +58 -0
- package/types/onramp.types.mjs +4 -0
- package/types/proxy.types.d.ts +1 -0
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +8 -39
- package/types/sandbox.types.mjs +2 -2
- package/types/session.types.d.ts +2 -0
- package/types/solana.types.d.ts +3 -0
- package/types/token-prices.types.cjs +1 -1
- package/types/token-prices.types.d.ts +7 -0
- package/types/token-prices.types.mjs +4 -2
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +6 -4
- package/types/transactions.types.mjs +4 -3
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/API/ai-calls.cjs +0 -1
- package/API/ai-calls.d.ts +0 -17
- package/API/ai-calls.mjs +0 -21
- package/API/duneAPI.cjs +0 -1
- package/API/duneAPI.d.ts +0 -11
- package/API/duneAPI.mjs +0 -25
- package/API/getBridgeProtocols.cjs +0 -1
- package/API/getBridgeProtocols.d.ts +0 -7
- package/API/getBridgeProtocols.mjs +0 -8
- package/API/getLifiStatus.cjs +0 -1
- package/API/getLifiStatus.d.ts +0 -24
- package/API/getLifiStatus.mjs +0 -15
- package/API/getRelayerURL.cjs +0 -1
- package/API/getRelayerURL.d.ts +0 -1
- package/API/getRelayerURL.mjs +0 -10
- package/API/passwordCalls.cjs +0 -1
- package/API/passwordCalls.d.ts +0 -9
- package/API/passwordCalls.mjs +0 -13
- package/API/restoreSnapshots.cjs +0 -1
- package/API/restoreSnapshots.d.ts +0 -1
- package/API/restoreSnapshots.mjs +0 -10
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +0 -1
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +0 -7
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +0 -42
- package/data-structures/Hinkal/hinkalActionStake.d.ts +0 -3
- package/data-structures/Hinkal/hinkalApprove.cjs +0 -1
- package/data-structures/Hinkal/hinkalApprove.d.ts +0 -3
- package/data-structures/Hinkal/hinkalApprove.mjs +0 -115
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +0 -1
- package/data-structures/Hinkal/hinkalInsideTransact.d.ts +0 -4
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +0 -121
- package/error-handling/handleErrorRestore.cjs +0 -1
- package/error-handling/handleErrorRestore.d.ts +0 -2
- package/error-handling/handleErrorRestore.mjs +0 -11
- package/functions/staking/index.cjs +0 -1
- package/functions/staking/index.d.ts +0 -11
- package/functions/staking/index.mjs +0 -42
- package/functions/utils/replaceAddressInCalldata.cjs +0 -1
- package/functions/utils/replaceAddressInCalldata.d.ts +0 -1
- package/functions/utils/replaceAddressInCalldata.mjs +0 -7
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +0 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +0 -5
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +0 -32
- package/types/bridging.types.d.ts +0 -29
- package/types/duneAPI.types.d.ts +0 -9
- package/types/hinkal.stake.types.cjs +0 -1
- package/types/hinkal.stake.types.d.ts +0 -11
- package/types/hinkal.stake.types.mjs +0 -4
|
@@ -1,99 +1,100 @@
|
|
|
1
|
-
import { TOKEN_2022_PROGRAM_ID as
|
|
1
|
+
import { TOKEN_2022_PROGRAM_ID as x, TOKEN_PROGRAM_ID as v } from "@solana/spl-token";
|
|
2
2
|
import { PublicKey as p } from "@solana/web3.js";
|
|
3
|
-
import { networkRegistry as
|
|
3
|
+
import { networkRegistry as h } from "../../constants/chains.constants.mjs";
|
|
4
4
|
import { solanaNativeAddress as P } from "../../constants/protocol.constants.mjs";
|
|
5
5
|
import { formatMintAddress as N } from "../../functions/utils/solanaMint.utils.mjs";
|
|
6
6
|
import { isValidPrivateAddress as O, constructStealthAddressStructure as V } from "../../functions/utils/addresses.mjs";
|
|
7
7
|
import { transactionErrorCodes as _ } from "../../error-handling/error-codes.constants.mjs";
|
|
8
|
-
import { getStorageAccountPublicKey as
|
|
9
|
-
import { BN as
|
|
10
|
-
import { sendProxyV0Transaction as
|
|
11
|
-
import { UserKeys as
|
|
12
|
-
import { createCustomSolanaConnection as
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
import { getStorageAccountPublicKey as G, getStorageVaultPublicKey as L, buildAnchorStealthAddressStructure as M, getTokenLimitStorageAccountPublicKey as U } from "../../functions/pre-transaction/solana.mjs";
|
|
9
|
+
import { BN as z } from "@coral-xyz/anchor";
|
|
10
|
+
import { sendProxyV0Transaction as F, serializeProxyV0Transaction as q } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
11
|
+
import { UserKeys as B } from "../crypto-keys/keys.mjs";
|
|
12
|
+
import { createCustomSolanaConnection as j } from "../../functions/utils/create-provider.mjs";
|
|
13
|
+
import { validateAndGetChainId as w } from "../../functions/utils/token-check.utils.mjs";
|
|
14
|
+
const H = async ({
|
|
15
|
+
program: t,
|
|
16
|
+
mintPublicKey: r,
|
|
17
|
+
mintAddressString: n,
|
|
18
|
+
tokenAmount: e,
|
|
18
19
|
anchorStealthStructure: s,
|
|
19
|
-
senderPublickey:
|
|
20
|
-
originalDeployer:
|
|
21
|
-
storageAccount:
|
|
22
|
-
storageVault:
|
|
20
|
+
senderPublickey: d,
|
|
21
|
+
originalDeployer: o,
|
|
22
|
+
storageAccount: i,
|
|
23
|
+
storageVault: a
|
|
23
24
|
}) => {
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
mint:
|
|
27
|
-
signer:
|
|
25
|
+
const m = new z(e.toString()), l = U(t.programId, o, r), u = n === P ? null : r, c = n === P ? null : void 0;
|
|
26
|
+
return t.methods.prooflessDeposit(m, s).accounts({
|
|
27
|
+
mint: u,
|
|
28
|
+
signer: d,
|
|
28
29
|
signerAta: c,
|
|
29
|
-
originalDeployer:
|
|
30
|
-
storageAccount:
|
|
31
|
-
storageVault:
|
|
30
|
+
originalDeployer: o,
|
|
31
|
+
storageAccount: i,
|
|
32
|
+
storageVault: a,
|
|
32
33
|
tokenLimitStorage: l,
|
|
33
34
|
storageVaultAta: c,
|
|
34
35
|
accessTokenOwner: null
|
|
35
36
|
}).instruction();
|
|
36
|
-
},
|
|
37
|
-
const
|
|
38
|
-
if (!O(
|
|
37
|
+
}, E = async (t, r, n, e, s, d) => {
|
|
38
|
+
const o = d ?? t.getRecipientInfo();
|
|
39
|
+
if (!O(o))
|
|
39
40
|
throw Error(_.RECIPIENT_FORMAT_INCORRECT);
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
41
|
+
const i = B.getSignerAddressFromPrivateKey(r, s.privateKey), { hinkalIdl: a, hinkalAddress: m, originalDeployer: l } = h[r].contractData;
|
|
42
|
+
if (!a)
|
|
42
43
|
throw new Error("No IDL configured for Solana program on this network");
|
|
43
44
|
if (!l)
|
|
44
45
|
throw new Error("missing original deployer");
|
|
45
|
-
const
|
|
46
|
+
const u = t.getSolanaProgram(a), c = new p(l), g = new p(m), f = new p(i), { erc20TokenAddress: I } = n, { fetchRpcUrl: S } = h[r];
|
|
46
47
|
if (!S)
|
|
47
48
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
48
|
-
const
|
|
49
|
-
program:
|
|
49
|
+
const R = j(S), { mintPublicKey: y } = N(I), T = y.toString(), A = G(g, c), b = L(g, c), K = V(o), k = M(K), C = await H({
|
|
50
|
+
program: u,
|
|
50
51
|
mintPublicKey: y,
|
|
51
|
-
mintAddressString:
|
|
52
|
+
mintAddressString: T,
|
|
52
53
|
tokenAmount: e,
|
|
53
54
|
anchorStealthStructure: k,
|
|
54
55
|
senderPublickey: f,
|
|
55
56
|
originalDeployer: c,
|
|
56
|
-
storageAccount:
|
|
57
|
-
storageVault:
|
|
58
|
-
}),
|
|
57
|
+
storageAccount: A,
|
|
58
|
+
storageVault: b
|
|
59
|
+
}), D = n.is2022Program ? x : v;
|
|
59
60
|
return {
|
|
60
|
-
connection:
|
|
61
|
-
|
|
62
|
-
senderAddress: a,
|
|
61
|
+
connection: R,
|
|
62
|
+
senderAddress: i,
|
|
63
63
|
senderPublickey: f,
|
|
64
64
|
instructions: [C],
|
|
65
|
-
storageAccount:
|
|
66
|
-
programId:
|
|
65
|
+
storageAccount: A,
|
|
66
|
+
programId: D
|
|
67
67
|
};
|
|
68
|
-
},
|
|
69
|
-
if (
|
|
68
|
+
}, ir = async (t, r, n, e, s, d = !1) => {
|
|
69
|
+
if (d)
|
|
70
70
|
throw new Error("onlyGasEstimate is not supported for Solana proxy shield");
|
|
71
|
-
if (!
|
|
71
|
+
if (!e)
|
|
72
72
|
throw new Error("subAccount is required");
|
|
73
|
-
const { connection:
|
|
74
|
-
return
|
|
75
|
-
connection:
|
|
76
|
-
chainId:
|
|
77
|
-
subAccount:
|
|
73
|
+
const o = w([r]), { connection: i, senderPublickey: a, instructions: m, senderAddress: l, storageAccount: u, programId: c } = await E(t, o, r, n, e, s), g = s || u.toString();
|
|
74
|
+
return F({
|
|
75
|
+
connection: i,
|
|
76
|
+
chainId: o,
|
|
77
|
+
subAccount: e,
|
|
78
78
|
payerPublicKey: a,
|
|
79
|
-
instructions:
|
|
79
|
+
instructions: m,
|
|
80
80
|
convertParams: {
|
|
81
81
|
fromAddress: l,
|
|
82
82
|
toAddress: g,
|
|
83
83
|
programAddress: c.toString()
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
|
-
},
|
|
87
|
-
const { connection:
|
|
88
|
-
o,
|
|
86
|
+
}, ar = async (t, r, n, e, s) => {
|
|
87
|
+
const d = w([r]), { connection: o, senderPublickey: i, instructions: a } = await E(
|
|
89
88
|
t,
|
|
90
|
-
|
|
89
|
+
d,
|
|
90
|
+
r,
|
|
91
91
|
n,
|
|
92
|
+
e,
|
|
92
93
|
s
|
|
93
94
|
);
|
|
94
|
-
return
|
|
95
|
+
return q(o, i, a);
|
|
95
96
|
};
|
|
96
97
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
ar as getSolanaProxyShieldSerializedTransaction,
|
|
99
|
+
ir as hinkalSolanaProxyShield
|
|
99
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@solana/web3.js");require("../../constants/token-data/index.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@solana/web3.js");require("../../constants/token-data/index.cjs");const T=require("../../constants/chains.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");const f=require("../../functions/pre-transaction/sendV0Transaction.cjs"),x=require("../../functions/pre-transaction/getFeeStructure.cjs"),E=require("../../types/external-action.types.cjs"),K=require("../../error-handling/error-codes.constants.cjs"),I=require("../../functions/pre-transaction/solanaTransfer.utils.cjs"),v=require("../crypto-keys/keys.cjs"),R=require("../../functions/utils/create-provider.cjs"),C=require("../../functions/utils/token-check.utils.cjs"),P=async(a,n,u)=>{const s=v.UserKeys.getSignerAddressFromPrivateKey(a,u.privateKey),{fetchRpcUrl:o}=T.networkRegistry[a];if(!o)throw new Error("RPC URL not found for the specified chain ID");const i=R.createCustomSolanaConnection(o),l=JSON.parse(n),{addressLookupTableAccount:d,instructionLists:e}=l.data,y=await Promise.all(d.map(async r=>{const t=await i.getAddressLookupTable(new c.PublicKey(r));if(!t.value)throw new Error(`Failed to fetch lookup table: ${r}`);return t.value}));if(e.length===0)throw new Error("No instructions found");const w=e.map(r=>new c.TransactionInstruction({keys:r.accounts.map(t=>({pubkey:new c.PublicKey(t.pubkey),isSigner:t.isSigner,isWritable:t.isWritable})),programId:new c.PublicKey(r.programId),data:Buffer.from(r.data,"base64")}));return{connection:i,walletAddress:s,walletPublicKey:new c.PublicKey(s),lookupTableAccounts:y,instructions:w,instructionLists:e}},L=async(a,n,u,s,o,i,l,d=!1)=>{if(d)throw new Error("onlyGasEstimate is not supported for Solana proxy swap");const e=C.validateAndGetChainId(n),y=n[1],w=u[1],r=l??await x.getFeeStructure(e,i,n.map(h=>h.erc20TokenAddress),E.ExternalActionId.Emporium),t=w*r.variableRate/10000n,{connection:p,walletAddress:b,walletPublicKey:S,instructions:m,lookupTableAccounts:A,instructionLists:g}=await P(e,s,o),q=await a.getRandomRelay(e);if(!q)throw Error(K.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{instructions:k}=await I.buildSolanaTransferInstructions(p,S,new c.PublicKey(q),y,t);return f.sendProxyV0Transaction({connection:p,chainId:e,subAccount:o,payerPublicKey:S,instructions:[...m,...k],lookupTableAccounts:A,convertParams:{fromAddress:b,toAddress:b,programAddress:g[0].programId}})},_=async(a,n,u)=>{const{connection:s,walletPublicKey:o,instructions:i,lookupTableAccounts:l}=await P(a,n,u);return f.serializeProxyV0Transaction(s,o,i,l)};exports.getSolanaProxySwapSerializedTransaction=_;exports.hinkalSolanaProxySwap=L;
|
|
@@ -2,4 +2,4 @@ import { ERC20Token, RelayerTransaction, SubAccount } from '../../types';
|
|
|
2
2
|
import { IHinkal } from './IHinkal';
|
|
3
3
|
import { FeeStructure } from '../../types/hinkal.types';
|
|
4
4
|
export declare const hinkalSolanaProxySwap: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], data: string, subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean) => Promise<RelayerTransaction>;
|
|
5
|
-
export declare const getSolanaProxySwapSerializedTransaction: (
|
|
5
|
+
export declare const getSolanaProxySwapSerializedTransaction: (chainId: number, data: string, subAccount: SubAccount) => Promise<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PublicKey as
|
|
1
|
+
import { PublicKey as p, TransactionInstruction as E } from "@solana/web3.js";
|
|
2
2
|
import "../../constants/token-data/index.mjs";
|
|
3
|
-
import { networkRegistry as
|
|
3
|
+
import { networkRegistry as T } from "../../constants/chains.constants.mjs";
|
|
4
4
|
import "../../constants/contracts.constants.mjs";
|
|
5
5
|
import "../../constants/kyc.constants.mjs";
|
|
6
6
|
import "../../constants/server.constants.mjs";
|
|
@@ -13,84 +13,85 @@ import "../../constants/presale.constants.mjs";
|
|
|
13
13
|
import "../../constants/activity.constants.mjs";
|
|
14
14
|
import "../../constants/tasks.constants.mjs";
|
|
15
15
|
import "../../constants/events.constants.mjs";
|
|
16
|
-
import { sendProxyV0Transaction as
|
|
17
|
-
import { getFeeStructure as
|
|
18
|
-
import { ExternalActionId as
|
|
19
|
-
import { transactionErrorCodes as
|
|
20
|
-
import { buildSolanaTransferInstructions as
|
|
21
|
-
import { UserKeys as
|
|
16
|
+
import { sendProxyV0Transaction as x, serializeProxyV0Transaction as I } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
17
|
+
import { getFeeStructure as R } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
18
|
+
import { ExternalActionId as K } from "../../types/external-action.types.mjs";
|
|
19
|
+
import { transactionErrorCodes as L } from "../../error-handling/error-codes.constants.mjs";
|
|
20
|
+
import { buildSolanaTransferInstructions as v } from "../../functions/pre-transaction/solanaTransfer.utils.mjs";
|
|
21
|
+
import { UserKeys as C } from "../crypto-keys/keys.mjs";
|
|
22
22
|
import { createCustomSolanaConnection as F } from "../../functions/utils/create-provider.mjs";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
import { validateAndGetChainId as N } from "../../functions/utils/token-check.utils.mjs";
|
|
24
|
+
const A = async (a, n, c) => {
|
|
25
|
+
const i = C.getSignerAddressFromPrivateKey(a, c.privateKey), { fetchRpcUrl: e } = T[a];
|
|
26
|
+
if (!e)
|
|
26
27
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
27
|
-
const s = F(
|
|
28
|
-
m.map(async (
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
31
|
-
throw new Error(`Failed to fetch lookup table: ${
|
|
32
|
-
return
|
|
28
|
+
const s = F(e), l = JSON.parse(n), { addressLookupTableAccount: m, instructionLists: o } = l.data, u = await Promise.all(
|
|
29
|
+
m.map(async (t) => {
|
|
30
|
+
const r = await s.getAddressLookupTable(new p(t));
|
|
31
|
+
if (!r.value)
|
|
32
|
+
throw new Error(`Failed to fetch lookup table: ${t}`);
|
|
33
|
+
return r.value;
|
|
33
34
|
})
|
|
34
35
|
);
|
|
35
|
-
if (
|
|
36
|
+
if (o.length === 0)
|
|
36
37
|
throw new Error("No instructions found");
|
|
37
|
-
const
|
|
38
|
-
keys:
|
|
39
|
-
pubkey: new
|
|
40
|
-
isSigner:
|
|
41
|
-
isWritable:
|
|
38
|
+
const d = o.map((t) => new E({
|
|
39
|
+
keys: t.accounts.map((r) => ({
|
|
40
|
+
pubkey: new p(r.pubkey),
|
|
41
|
+
isSigner: r.isSigner,
|
|
42
|
+
isWritable: r.isWritable
|
|
42
43
|
})),
|
|
43
|
-
programId: new
|
|
44
|
-
data: Buffer.from(
|
|
44
|
+
programId: new p(t.programId),
|
|
45
|
+
data: Buffer.from(t.data, "base64")
|
|
45
46
|
}));
|
|
46
47
|
return {
|
|
47
48
|
connection: s,
|
|
48
|
-
walletAddress:
|
|
49
|
-
walletPublicKey: new
|
|
50
|
-
lookupTableAccounts:
|
|
51
|
-
instructions:
|
|
52
|
-
instructionLists:
|
|
49
|
+
walletAddress: i,
|
|
50
|
+
walletPublicKey: new p(i),
|
|
51
|
+
lookupTableAccounts: u,
|
|
52
|
+
instructions: d,
|
|
53
|
+
instructionLists: o
|
|
53
54
|
};
|
|
54
|
-
},
|
|
55
|
-
if (
|
|
55
|
+
}, eo = async (a, n, c, i, e, s, l, m = !1) => {
|
|
56
|
+
if (m)
|
|
56
57
|
throw new Error("onlyGasEstimate is not supported for Solana proxy swap");
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
),
|
|
58
|
+
const o = N(n), u = n[1], d = c[1], t = l ?? await R(
|
|
59
|
+
o,
|
|
60
|
+
s,
|
|
61
|
+
n.map((k) => k.erc20TokenAddress),
|
|
62
|
+
K.Emporium
|
|
63
|
+
), r = d * t.variableRate / 10000n, { connection: w, walletAddress: f, walletPublicKey: y, instructions: S, lookupTableAccounts: g, instructionLists: P } = await A(o, i, e), b = await a.getRandomRelay(o);
|
|
63
64
|
if (!b)
|
|
64
|
-
throw Error(
|
|
65
|
-
const { instructions:
|
|
66
|
-
|
|
65
|
+
throw Error(L.RELAYER_NOT_AVAILABLE);
|
|
66
|
+
const { instructions: h } = await v(
|
|
67
|
+
w,
|
|
67
68
|
y,
|
|
68
|
-
new
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
new p(b),
|
|
70
|
+
u,
|
|
71
|
+
r
|
|
71
72
|
);
|
|
72
|
-
return
|
|
73
|
-
connection:
|
|
74
|
-
chainId:
|
|
75
|
-
subAccount:
|
|
73
|
+
return x({
|
|
74
|
+
connection: w,
|
|
75
|
+
chainId: o,
|
|
76
|
+
subAccount: e,
|
|
76
77
|
payerPublicKey: y,
|
|
77
|
-
instructions: [...
|
|
78
|
-
lookupTableAccounts:
|
|
78
|
+
instructions: [...S, ...h],
|
|
79
|
+
lookupTableAccounts: g,
|
|
79
80
|
convertParams: {
|
|
80
81
|
fromAddress: f,
|
|
81
82
|
toAddress: f,
|
|
82
|
-
programAddress:
|
|
83
|
+
programAddress: P[0].programId
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
|
-
},
|
|
86
|
-
const { connection:
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
}, ao = async (a, n, c) => {
|
|
87
|
+
const { connection: i, walletPublicKey: e, instructions: s, lookupTableAccounts: l } = await A(
|
|
88
|
+
a,
|
|
89
|
+
n,
|
|
89
90
|
c
|
|
90
91
|
);
|
|
91
|
-
return
|
|
92
|
+
return I(i, e, s, l);
|
|
92
93
|
};
|
|
93
94
|
export {
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
ao as getSolanaProxySwapSerializedTransaction,
|
|
96
|
+
eo as hinkalSolanaProxySwap
|
|
96
97
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const ne=require("../../types/external-action.types.cjs"),y=require("../../constants/protocol.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const se=require("../../types/cache.types.cjs"),ce=require("../../functions/web3/events/getShieldedBalance.cjs"),ae=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),ie=require("../../functions/utils/time.utils.cjs"),ue=require("../../functions/pre-transaction/getFeeStructure.cjs"),le=require("../../functions/snarkjs/common.snarkjs.cjs"),de=require("../../constants/chains.constants.cjs"),a=require("@solana/web3.js"),m=require("../../functions/pre-transaction/solana.cjs"),pe=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),ge=require("../utxo/Utxo.cjs"),S=require("../../functions/web3/etherFunctions.cjs"),Ae=require("../../functions/pre-transaction/convert-okx-instructions.cjs"),ye=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),me=require("../../error-handling/error-codes.constants.cjs"),Se=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),we=require("ethers"),fe=require("../../functions/utils/token-check.utils.cjs"),Pe=async(t,o,n,w,K,x,v,E,R=!1)=>{if(R)throw new Error("onlyGasEstimate is not supported for Solana swap");const r=fe.validateAndGetChainId(o),f=new a.PublicKey(y.solanaNativeAddress),{hinkalAddress:_,originalDeployer:i,hinkalIdl:P}=de.networkRegistry[r].contractData;if(!i||!P)throw new Error("No IDL configured for Solana program on this network");const u=new a.PublicKey(i),l=new a.PublicKey(_),s=o.map(e=>e.erc20TokenAddress),{userKeys:k,merkleTreeAccessTokenByChain:F,merkleTreeHinkalByChain:N}=t,O=t.getSolanaProgram(P),c=E??await ue.getFeeStructure(r,v,s,ne.ExternalActionId.Transact),{patchAccessTokenMerkleTree:C,kycRequired:U,hasAccessToken:B}=await Se.shouldPatchAccessTokenMerkleTree(t,r,s,n);n[1]-=c.flatFee;const D=c.variableRate.toString(),L=Number(t.cacheDevice.get(se.StorageKeys.SLIPPAGE_PERCENTAGE)??0),d=o[1],G=S.getAmountInToken(d,n[1]),M=Number(G)*L/100;n[1]-=S.getAmountInWei(d,M.toFixed(d.decimals));const p=[...await ce.addPaddingToUtxos(t,r,s,n,6)],V=ie.getCurrentTimeInSeconds().toString(),j=t.userKeys.getShieldedPrivateKey(),g=[];for(let e=0;e<s.length;e+=1){const{outputUtxos:oe}=ae.outputUtxoProcessing(t.userKeys,p[e],n[e],V,void 0,!1);g.push([oe[0]])}const W=ge.Utxo.findCorrectRandomization(S.randomBigInt(31),j),q={tokenNumber:2,nullifierAmount:p[0].length,outputAmount:1},z=[!1,!0].slice(0,n.length),A=await t.getRandomRelay(r,!0);if(!A)throw Error(me.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const b=le.calcEncryptedOutputs(g).map(e=>[...we.ethers.utils.arrayify(e[0])]),h=m.getSwapperAccountPublicKeyFromSalt(l,u,w),{remainingAccounts:T,hinkalInstructions:I}=Ae.convertOKXToHinkalInstructions(K,h),{proofAArr:H,proofBArr:Z,proofCArr:X,publicInputsArr:Y}=await pe.constructSolanaZkProof(t.generateProofRemotely,i,N[r],F[r],k,O,s,p,g,W,c.flatFee,c.variableRate,f.toString(),A,q,b,r,C,z,w,I,T),J=m.getStorageAccountPublicKey(l,u),Q=m.getStorageVaultPublicKey(l,u),$=o[0].erc20TokenAddress!==y.solanaNativeAddress?new a.PublicKey(o[0].erc20TokenAddress):null,ee=o[1].erc20TokenAddress!==y.solanaNativeAddress?new a.PublicKey(o[1].erc20TokenAddress):null,te={recipient:f.toString(),storageAccount:J.toString(),storageVault:Q.toString(),swapperAccount:h.toString(),mintFrom:$?.toString()??null,mintTo:ee?.toString()??null,remainingAccounts:T.map(e=>({pubkey:e.pubkey.toString(),isSigner:e.isSigner,isWritable:e.isWritable})),addressLookupTableAccount:x},re={encryptedOutputs:b,proofAArr:H,proofBArr:Z,proofCArr:X,publicInputsArr:Y,relayerFee:c.flatFee.toString(),variableRate:D,dimensions:q,hinkalInstructions:I.map(e=>({accountIndexes:[...e.accountIndexes],data:[...e.data],programIndex:e.programIndex}))};return ye.solanaTransactCallRelayer({chainId:r,relayAddress:A,functionName:"swap",args:re,accounts:te,solanaAccessTokenData:!B&&U?{ethereumAddress:await t.getEthereumAddress(),accessKey:k.getAccessKey()}:void 0})};exports.hinkalSolanaSwap=Pe;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FeeStructure, OKXSwapResponseInstruction } from '../../types';
|
|
2
2
|
import { IHinkal } from './IHinkal';
|
|
3
3
|
import { ERC20Token } from '../../types/token.types';
|
|
4
|
-
export declare const hinkalSolanaSwap: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], instructionLists: OKXSwapResponseInstruction[], addressLookupTableAccount: string[], feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean) => Promise<import(
|
|
4
|
+
export declare const hinkalSolanaSwap: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], swapperAccountSalt: bigint, instructionLists: OKXSwapResponseInstruction[], addressLookupTableAccount: string[], feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean) => Promise<import('../../types/relayer.types').RelayerTransaction>;
|
|
@@ -1,119 +1,123 @@
|
|
|
1
1
|
import "../../types/circom-data.types.mjs";
|
|
2
|
-
import { ExternalActionId as
|
|
2
|
+
import { ExternalActionId as rt } from "../../types/external-action.types.mjs";
|
|
3
3
|
import { solanaNativeAddress as A } from "../../constants/protocol.constants.mjs";
|
|
4
4
|
import "../../types/transactions.types.mjs";
|
|
5
5
|
import "../../types/activities.types.mjs";
|
|
6
|
-
import { StorageKeys as
|
|
7
|
-
import { addPaddingToUtxos as
|
|
8
|
-
import { outputUtxoProcessing as
|
|
9
|
-
import { getCurrentTimeInSeconds as
|
|
10
|
-
import { getFeeStructure as
|
|
11
|
-
import { calcEncryptedOutputs as
|
|
12
|
-
import { networkRegistry as
|
|
13
|
-
import { PublicKey as
|
|
14
|
-
import {
|
|
15
|
-
import { constructSolanaZkProof as
|
|
16
|
-
import { Utxo as
|
|
17
|
-
import { getAmountInToken as
|
|
18
|
-
import { convertOKXToHinkalInstructions as
|
|
19
|
-
import { solanaTransactCallRelayer as
|
|
20
|
-
import { transactionErrorCodes as
|
|
6
|
+
import { StorageKeys as et } from "../../types/cache.types.mjs";
|
|
7
|
+
import { addPaddingToUtxos as nt } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
8
|
+
import { outputUtxoProcessing as st } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
9
|
+
import { getCurrentTimeInSeconds as at } from "../../functions/utils/time.utils.mjs";
|
|
10
|
+
import { getFeeStructure as it } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
11
|
+
import { calcEncryptedOutputs as ct } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
12
|
+
import { networkRegistry as mt } from "../../constants/chains.constants.mjs";
|
|
13
|
+
import { PublicKey as i } from "@solana/web3.js";
|
|
14
|
+
import { getSwapperAccountPublicKeyFromSalt as pt, getStorageAccountPublicKey as ut, getStorageVaultPublicKey as lt } from "../../functions/pre-transaction/solana.mjs";
|
|
15
|
+
import { constructSolanaZkProof as dt } from "../../functions/snarkjs/constructSolanaZkProof.mjs";
|
|
16
|
+
import { Utxo as gt } from "../utxo/Utxo.mjs";
|
|
17
|
+
import { getAmountInToken as At, getAmountInWei as ft, randomBigInt as yt } from "../../functions/web3/etherFunctions.mjs";
|
|
18
|
+
import { convertOKXToHinkalInstructions as St } from "../../functions/pre-transaction/convert-okx-instructions.mjs";
|
|
19
|
+
import { solanaTransactCallRelayer as wt } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
20
|
+
import { transactionErrorCodes as It } from "../../error-handling/error-codes.constants.mjs";
|
|
21
21
|
import { shouldPatchAccessTokenMerkleTree as Tt } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
22
|
-
import { ethers as
|
|
23
|
-
|
|
22
|
+
import { ethers as Pt } from "ethers";
|
|
23
|
+
import { validateAndGetChainId as bt } from "../../functions/utils/token-check.utils.mjs";
|
|
24
|
+
const Yt = async (o, e, n, f, E, h, x, K, R = !1) => {
|
|
24
25
|
if (R)
|
|
25
26
|
throw new Error("onlyGasEstimate is not supported for Solana swap");
|
|
26
|
-
const
|
|
27
|
-
if (!c || !
|
|
27
|
+
const r = bt(e), y = new i(A), { hinkalAddress: v, originalDeployer: c, hinkalIdl: S } = mt[r].contractData;
|
|
28
|
+
if (!c || !S)
|
|
28
29
|
throw new Error("No IDL configured for Solana program on this network");
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const m = new i(c), p = new i(v), s = e.map((t) => t.erc20TokenAddress), { userKeys: w, merkleTreeAccessTokenByChain: F, merkleTreeHinkalByChain: N } = o, D = o.getSolanaProgram(S), a = K ?? await it(r, x, s, rt.Transact), { patchAccessTokenMerkleTree: O, kycRequired: B, hasAccessToken: U } = await Tt(
|
|
31
|
+
o,
|
|
32
|
+
r,
|
|
33
|
+
s,
|
|
34
|
+
n
|
|
33
35
|
);
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const l = [...await
|
|
38
|
-
for (let t = 0; t <
|
|
39
|
-
const { outputUtxos:
|
|
40
|
-
|
|
36
|
+
n[1] -= a.flatFee;
|
|
37
|
+
const C = a.variableRate.toString(), L = Number(o.cacheDevice.get(et.SLIPPAGE_PERCENTAGE) ?? 0), u = e[1], G = At(u, n[1]), V = Number(G) * L / 100;
|
|
38
|
+
n[1] -= ft(u, V.toFixed(u.decimals));
|
|
39
|
+
const l = [...await nt(o, r, s, n, 6)], W = at().toString(), _ = o.userKeys.getShieldedPrivateKey(), d = [];
|
|
40
|
+
for (let t = 0; t < s.length; t += 1) {
|
|
41
|
+
const { outputUtxos: ot } = st(
|
|
42
|
+
o.userKeys,
|
|
41
43
|
l[t],
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
n[t],
|
|
45
|
+
W,
|
|
44
46
|
void 0,
|
|
45
47
|
!1
|
|
46
48
|
);
|
|
47
|
-
d.push([
|
|
49
|
+
d.push([ot[0]]);
|
|
48
50
|
}
|
|
49
|
-
const
|
|
51
|
+
const z = gt.findCorrectRandomization(yt(31), _), I = {
|
|
50
52
|
tokenNumber: 2,
|
|
51
53
|
nullifierAmount: l[0].length,
|
|
52
54
|
outputAmount: 1
|
|
53
|
-
},
|
|
55
|
+
}, H = [!1, !0].slice(0, n.length), g = await o.getRandomRelay(r, !0);
|
|
54
56
|
if (!g)
|
|
55
|
-
throw Error(
|
|
56
|
-
const T =
|
|
57
|
-
|
|
57
|
+
throw Error(It.RELAYER_NOT_AVAILABLE);
|
|
58
|
+
const T = ct(d).map((t) => [...Pt.utils.arrayify(t[0])]), P = pt(p, m, f), { remainingAccounts: b, hinkalInstructions: k } = St(E, P), { proofAArr: M, proofBArr: q, proofCArr: X, publicInputsArr: Y } = await dt(
|
|
59
|
+
o.generateProofRemotely,
|
|
58
60
|
c,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
N[r],
|
|
62
|
+
F[r],
|
|
63
|
+
w,
|
|
64
|
+
D,
|
|
65
|
+
s,
|
|
64
66
|
l,
|
|
65
67
|
d,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
z,
|
|
69
|
+
a.flatFee,
|
|
70
|
+
a.variableRate,
|
|
71
|
+
y.toString(),
|
|
70
72
|
g,
|
|
71
|
-
|
|
73
|
+
I,
|
|
72
74
|
T,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
r,
|
|
76
|
+
O,
|
|
77
|
+
H,
|
|
78
|
+
f,
|
|
79
|
+
k,
|
|
80
|
+
b
|
|
81
|
+
), Z = ut(p, m), j = lt(p, m), J = e[0].erc20TokenAddress !== A ? new i(e[0].erc20TokenAddress) : null, Q = e[1].erc20TokenAddress !== A ? new i(e[1].erc20TokenAddress) : null, $ = {
|
|
82
|
+
recipient: y.toString(),
|
|
83
|
+
storageAccount: Z.toString(),
|
|
84
|
+
storageVault: j.toString(),
|
|
85
|
+
swapperAccount: P.toString(),
|
|
86
|
+
mintFrom: J?.toString() ?? null,
|
|
87
|
+
mintTo: Q?.toString() ?? null,
|
|
88
|
+
remainingAccounts: b.map((t) => ({
|
|
86
89
|
pubkey: t.pubkey.toString(),
|
|
87
90
|
isSigner: t.isSigner,
|
|
88
91
|
isWritable: t.isWritable
|
|
89
92
|
})),
|
|
90
|
-
addressLookupTableAccount:
|
|
91
|
-
},
|
|
93
|
+
addressLookupTableAccount: h
|
|
94
|
+
}, tt = {
|
|
92
95
|
encryptedOutputs: T,
|
|
93
|
-
proofAArr:
|
|
94
|
-
proofBArr:
|
|
95
|
-
proofCArr:
|
|
96
|
-
publicInputsArr:
|
|
97
|
-
relayerFee:
|
|
98
|
-
variableRate:
|
|
99
|
-
dimensions:
|
|
100
|
-
hinkalInstructions:
|
|
96
|
+
proofAArr: M,
|
|
97
|
+
proofBArr: q,
|
|
98
|
+
proofCArr: X,
|
|
99
|
+
publicInputsArr: Y,
|
|
100
|
+
relayerFee: a.flatFee.toString(),
|
|
101
|
+
variableRate: C,
|
|
102
|
+
dimensions: I,
|
|
103
|
+
hinkalInstructions: k.map((t) => ({
|
|
101
104
|
accountIndexes: [...t.accountIndexes],
|
|
102
105
|
data: [...t.data],
|
|
103
106
|
programIndex: t.programIndex
|
|
104
107
|
}))
|
|
105
108
|
};
|
|
106
|
-
return
|
|
109
|
+
return wt({
|
|
110
|
+
chainId: r,
|
|
107
111
|
relayAddress: g,
|
|
108
112
|
functionName: "swap",
|
|
109
|
-
args:
|
|
110
|
-
accounts:
|
|
111
|
-
solanaAccessTokenData: !U &&
|
|
112
|
-
ethereumAddress: await
|
|
113
|
-
accessKey:
|
|
113
|
+
args: tt,
|
|
114
|
+
accounts: $,
|
|
115
|
+
solanaAccessTokenData: !U && B ? {
|
|
116
|
+
ethereumAddress: await o.getEthereumAddress(),
|
|
117
|
+
accessKey: w.getAccessKey()
|
|
114
118
|
} : void 0
|
|
115
119
|
});
|
|
116
120
|
};
|
|
117
121
|
export {
|
|
118
|
-
|
|
122
|
+
Yt as hinkalSolanaSwap
|
|
119
123
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const z=require("../../types/external-action.types.cjs"),c=require("../../constants/protocol.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const D=require("../../functions/web3/events/getShieldedBalance.cjs"),M=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),j=require("../../functions/utils/time.utils.cjs"),u=require("../../error-handling/error-codes.constants.cjs"),H=require("../../functions/pre-transaction/getFeeStructure.cjs"),Z=require("../../functions/snarkjs/common.snarkjs.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const z=require("../../types/external-action.types.cjs"),c=require("../../constants/protocol.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const D=require("../../functions/web3/events/getShieldedBalance.cjs"),M=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),j=require("../../functions/utils/time.utils.cjs"),u=require("../../error-handling/error-codes.constants.cjs"),H=require("../../functions/pre-transaction/getFeeStructure.cjs"),Z=require("../../functions/snarkjs/common.snarkjs.cjs"),G=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),I=require("../utxo/Utxo.cjs"),Y=require("../../functions/web3/etherFunctions.cjs"),J=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),Q=require("../../functions/utils/addresses.cjs"),W=require("../../constants/chains.constants.cjs"),X=require("ethers"),$=require("../../functions/utils/token-check.utils.cjs"),ee=async(t,d,o,l,R,S,p=!1)=>{if(p)throw new Error("onlyGasEstimate is not supported for Solana transfer");if(!Q.isValidPrivateAddress(l))throw Error(u.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const e=$.validateAndGetChainId(d),{originalDeployer:A,hinkalIdl:m}=W.networkRegistry[e].contractData;if(!A||!m)throw new Error("missing data");const{userKeys:_,merkleTreeAccessTokenByChain:h,merkleTreeHinkalByChain:w}=t,r=d.map(i=>i.erc20TokenAddress);if(r.length>1)throw new Error("Solana Transfer: Only one mint address is supported");const x=S??await H.getFeeStructure(e,R,r,z.ExternalActionId.Transact),a=-o[0]*(10000n-c.HINKAL_PRIVATE_SEND_VARIABLE_RATE)/10000n;if(o[0]-=x.flatFee,a<=0n)throw Error(u.transactionErrorCodes.RECIPIENT_AMOUNT_INVALID);const y=-o[0]-a,n=(await D.addPaddingToUtxos(t,e,r,o,6))[0],f=j.getCurrentTimeInSeconds().toString(),{outputUtxos:C}=M.outputUtxoProcessing(t.userKeys,n,o[0],f,void 0,!1),g=C[0],[N,P,O]=l.split(","),E=new I.Utxo({amount:a,erc20TokenAddress:n[0].erc20TokenAddress,mintAddress:n[0].mintAddress,timeStamp:f,randomization:BigInt(N),stealthAddress:P,encryptionKey:O}),s=await t.getRandomRelay(e,!p);if(!s)throw Error(u.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const U=I.Utxo.findCorrectRandomization(Y.randomBigInt(31),t.userKeys.getShieldedPrivateKey()),T={tokenNumber:r.length,nullifierAmount:n.length,outputAmount:2},k=t.getSolanaProgram(m),q=Z.calcEncryptedOutputs([[g,E]])[0].map(i=>Array.from(X.ethers.utils.arrayify(i))),{proofAArr:v,proofBArr:B,proofCArr:F,publicInputsArr:K}=await G.constructSolanaZkProof(t.generateProofRemotely,A,w[e],h[e],_,k,[r[0]],[n],[[g,E]],U,y,0n,c.solanaNativeAddress,s,T,q,e),L=r[0]===c.solanaNativeAddress,V={recipient:s,mint:L?void 0:r[0]},b={proofAArr:v,proofBArr:B,proofCArr:F,publicInputsArr:K,encryptedOutputs:q,relayerFee:y.toString(),dimensions:T};return J.solanaTransactCallRelayer({chainId:e,relayAddress:s,functionName:"transfer",args:b,accounts:V})};exports.hinkalSolanaTransfer=ee;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ERC20Token, FeeStructure } from '../../types';
|
|
2
2
|
import { IHinkal } from './IHinkal';
|
|
3
|
-
export declare const hinkalSolanaTransfer: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean) => Promise<import(
|
|
3
|
+
export declare const hinkalSolanaTransfer: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean) => Promise<import('../../types/relayer.types').RelayerTransaction>;
|