diff --git a/src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx b/src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx index 30536072fed..235471d397c 100644 --- a/src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx +++ b/src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx @@ -1,5 +1,5 @@ import type { ChainId } from '@shapeshiftoss/caip' -import { fromAccountId, solAssetId } from '@shapeshiftoss/caip' +import { solAssetId } from '@shapeshiftoss/caip' import type { FeeDataEstimate } from '@shapeshiftoss/chain-adapters' import { ChainAdapterError, solana } from '@shapeshiftoss/chain-adapters' import { contractAddressOrUndefined } from '@shapeshiftoss/utils' @@ -108,12 +108,9 @@ export const useSendDetails = (): UseSendDetailsReturnType => { if (!accountId) throw new Error('No accountId found') if (!wallet) throw new Error('No wallet connected') - const { account: from } = fromAccountId(accountId) - return estimateFees({ amountCryptoPrecision, assetId, - from, to, sendMax, accountId, diff --git a/src/components/Modals/Send/utils.ts b/src/components/Modals/Send/utils.ts index ee3f9729dbf..ac557f15ba6 100644 --- a/src/components/Modals/Send/utils.ts +++ b/src/components/Modals/Send/utils.ts @@ -48,7 +48,7 @@ export type EstimateFeesInput = { // Optional hex-encoded calldata // for ERC-20s, use me in place of `data` memo?: string - from?: string + utxoFrom?: string to: string sendMax: boolean accountId: AccountId @@ -58,7 +58,7 @@ export type EstimateFeesInput = { export const estimateFees = async ({ amountCryptoPrecision, assetId, - from, + utxoFrom, memo, to, sendMax, @@ -100,7 +100,7 @@ export const estimateFees = async ({ const getFeeDataInput: GetFeeDataInput = { to, value, - chainSpecific: { from, pubkey: account }, + chainSpecific: { from: utxoFrom, pubkey: account }, sendMax, } return adapter.getFeeData(getFeeDataInput) @@ -134,7 +134,7 @@ export const estimateFees = async ({ value, sendMax, chainSpecific: { - from, + from: account, contractAddress, memo, }, diff --git a/src/lib/utils/thorchain/hooks/useSendThorTx.tsx b/src/lib/utils/thorchain/hooks/useSendThorTx.tsx index d4b4a317b62..b1e0d87781b 100644 --- a/src/lib/utils/thorchain/hooks/useSendThorTx.tsx +++ b/src/lib/utils/thorchain/hooks/useSendThorTx.tsx @@ -14,6 +14,7 @@ import { getAddress, zeroAddress } from 'viem' import { fromThorBaseUnit, getThorchainMsgDepositCoin, getThorchainTransactionType } from '..' import type { SendInput } from '@/components/Modals/Send/Form' +import type { EstimateFeesInput } from '@/components/Modals/Send/utils' import { estimateFees, handleSend } from '@/components/Modals/Send/utils' import { useWallet } from '@/hooks/useWallet/useWallet' import { bn, bnOrZero } from '@/lib/bignumber/bignumber' @@ -186,12 +187,12 @@ export const useSendThorTx = ({ transactionType, ]) - const estimateFeesArgs = useMemo(() => { + const estimateFeesArgs = useMemo((): + | (EstimateFeesInput & { feeAssetId: AssetId }) + | undefined => { if (!accountId || !asset || !assetId || !feeAsset || !memo || !transactionType || !wallet) return - const { account } = fromAccountId(accountId) - switch (transactionType) { case 'MsgDeposit': { return { @@ -217,7 +218,6 @@ export const useSendThorTx = ({ assetId: shouldUseDustAmount ? feeAsset.assetId : asset.assetId, feeAssetId: feeAsset.assetId, to: inboundAddressData.router, - from: account, sendMax: false, memo: depositWithExpiryInputData, accountId, @@ -235,7 +235,7 @@ export const useSendThorTx = ({ assetId, feeAssetId: feeAsset.assetId, to: inboundAddressData.address, - from: fromAddress, + utxoFrom: fromAddress, sendMax: false, memo, accountId, diff --git a/src/react-queries/hooks/useQuoteEstimatedFeesQuery.ts b/src/react-queries/hooks/useQuoteEstimatedFeesQuery.ts index 0003280fabd..9ccc789099c 100644 --- a/src/react-queries/hooks/useQuoteEstimatedFeesQuery.ts +++ b/src/react-queries/hooks/useQuoteEstimatedFeesQuery.ts @@ -5,6 +5,7 @@ import { skipToken, useQuery } from '@tanstack/react-query' import { useMemo } from 'react' import { toHex } from 'viem' +import type { EstimateFeesInput } from '@/components/Modals/Send/utils' import { estimateFees } from '@/components/Modals/Send/utils' import { bn, bnOrZero } from '@/lib/bignumber/bignumber' import { getSupportedEvmChainIds } from '@/lib/utils/evm' @@ -76,7 +77,7 @@ export const useQuoteEstimatedFeesQuery = ({ const feeAssetMarketData = useAppSelector(state => selectMarketDataByAssetIdUserCurrency(state, collateralAssetId), ) - const estimateFeesArgs = useMemo(() => { + const estimateFeesArgs = useMemo((): EstimateFeesInput => { const supportedEvmChainIds = getSupportedEvmChainIds() const amountCryptoPrecision = depositAmountCryptoPrecision ?? repaymentAmountCryptoPrecision ?? '0' @@ -101,7 +102,7 @@ export const useQuoteEstimatedFeesQuery = ({ accountId, sendMax: false, contractAddress: undefined, - } as const + } }, [ depositAmountCryptoPrecision, repaymentAmountCryptoPrecision,