Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/components/Modals/Send/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,7 +58,7 @@ export type EstimateFeesInput = {
export const estimateFees = async ({
amountCryptoPrecision,
assetId,
from,
utxoFrom,
memo,
to,
sendMax,
Expand Down Expand Up @@ -100,7 +100,7 @@ export const estimateFees = async ({
const getFeeDataInput: GetFeeDataInput<UtxoChainId> = {
to,
value,
chainSpecific: { from, pubkey: account },
chainSpecific: { from: utxoFrom, pubkey: account },
sendMax,
}
return adapter.getFeeData(getFeeDataInput)
Expand Down Expand Up @@ -134,7 +134,7 @@ export const estimateFees = async ({
value,
sendMax,
chainSpecific: {
from,
from: account,
contractAddress,
memo,
},
Expand Down
10 changes: 5 additions & 5 deletions src/lib/utils/thorchain/hooks/useSendThorTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -235,7 +235,7 @@ export const useSendThorTx = ({
assetId,
feeAssetId: feeAsset.assetId,
to: inboundAddressData.address,
from: fromAddress,
utxoFrom: fromAddress,
sendMax: false,
memo,
accountId,
Expand Down
5 changes: 3 additions & 2 deletions src/react-queries/hooks/useQuoteEstimatedFeesQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -101,7 +102,7 @@ export const useQuoteEstimatedFeesQuery = ({
accountId,
sendMax: false,
contractAddress: undefined,
} as const
}
}, [
depositAmountCryptoPrecision,
repaymentAmountCryptoPrecision,
Expand Down