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
1 change: 0 additions & 1 deletion .env.app
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ REACT_APP_POLYGON_NODE_URL=https://daemon.polygon.shapeshift.com
REACT_APP_GNOSIS_NODE_URL=https://daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://daemon.arbitrum.shapeshift.com
REACT_APP_ARBITRUM_NOVA_NODE_URL=https://daemon.arbitrum-nova.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://daemon.thorchain.shapeshift.com

# thorchain
Expand Down
9 changes: 4 additions & 5 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ REACT_APP_UNCHAINED_THORCHAIN_HTTP_URL=https://dev-api.thorchain.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_WS_URL=wss://dev-api.thorchain.shapeshift.com

# nodes
REACT_APP_ETHEREUM_NODE_URL=https://dev-daemon.ethereum.shapeshift.com
REACT_APP_ETHEREUM_NODE_URL=https://dev-nownodes.shapeshift.com/ethereum
REACT_APP_AVALANCHE_NODE_URL=https://dev-daemon.avalanche.shapeshift.com/ext/bc/C/rpc
REACT_APP_OPTIMISM_NODE_URL=https://dev-daemon.optimism.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://dev-daemon.bnbsmartchain.shapeshift.com
REACT_APP_POLYGON_NODE_URL=https://dev-daemon.polygon.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://dev-nownodes.shapeshift.com/bnbsmartchain
REACT_APP_POLYGON_NODE_URL=https://dev-nownodes.shapeshift.com/polygon
REACT_APP_GNOSIS_NODE_URL=https://dev-daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://dev-daemon.arbitrum.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://dev-nownodes.shapeshift.com/arbitrum
REACT_APP_ARBITRUM_NOVA_NODE_URL=https://dev-daemon.arbitrum-nova.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://dev-daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://dev-daemon.thorchain.shapeshift.com

# thorchain
Expand Down
9 changes: 4 additions & 5 deletions .env.develop
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ REACT_APP_UNCHAINED_THORCHAIN_HTTP_URL=https://dev-api.thorchain.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_WS_URL=wss://dev-api.thorchain.shapeshift.com

# nodes
REACT_APP_ETHEREUM_NODE_URL=https://dev-daemon.ethereum.shapeshift.com
REACT_APP_ETHEREUM_NODE_URL=https://dev-nownodes.shapeshift.com/ethereum
REACT_APP_AVALANCHE_NODE_URL=https://dev-daemon.avalanche.shapeshift.com/ext/bc/C/rpc
REACT_APP_OPTIMISM_NODE_URL=https://dev-daemon.optimism.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://dev-daemon.bnbsmartchain.shapeshift.com
REACT_APP_POLYGON_NODE_URL=https://dev-daemon.polygon.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://dev-nownodes.shapeshift.com/bnbsmartchain
REACT_APP_POLYGON_NODE_URL=https://dev-nownodes.shapeshift.com/polygon
REACT_APP_GNOSIS_NODE_URL=https://dev-daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://dev-daemon.arbitrum.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://dev-nownodes.shapeshift.com/arbitrum
REACT_APP_ARBITRUM_NOVA_NODE_URL=https://dev-daemon.arbitrum-nova.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://dev-daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://dev-daemon.thorchain.shapeshift.com

# thorchain
Expand Down
11 changes: 5 additions & 6 deletions .env.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@ REACT_APP_UNCHAINED_THORCHAIN_HTTP_URL=https://dev-api.thorchain.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_WS_URL=wss://dev-api.thorchain.shapeshift.com

# nodes
REACT_APP_ETHEREUM_NODE_URL=http://localhost:8080
REACT_APP_ETHEREUM_NODE_URL=https://dev-nownodes.shapeshift.com/ethereum
REACT_APP_AVALANCHE_NODE_URL=https://dev-daemon.avalanche.shapeshift.com/ext/bc/C/rpc
REACT_APP_OPTIMISM_NODE_URL=https://dev-daemon.optimism.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://dev-daemon.bnbsmartchain.shapeshift.com
REACT_APP_POLYGON_NODE_URL=https://dev-daemon.polygon.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://dev-nownodes.shapeshift.com/bnbsmartchain
REACT_APP_POLYGON_NODE_URL=https://dev-nownodes.shapeshift.com/polygon
REACT_APP_GNOSIS_NODE_URL=https://dev-daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://dev-daemon.arbitrum.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://dev-nownodes.shapeshift.com/arbitrum
REACT_APP_ARBITRUM_NOVA_NODE_URL=https://dev-daemon.arbitrum-nova.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://dev-daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://dev-daemon.thorchain.shapeshift.com/lcd
REACT_APP_THORCHAIN_NODE_URL=https://dev-daemon.thorchain.shapeshift.com

# thorchain
REACT_APP_MIDGARD_URL=https://dev-indexer.thorchain.shapeshift.com/v2
1 change: 0 additions & 1 deletion .env.private
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ REACT_APP_POLYGON_NODE_URL=https://daemon.polygon.shapeshift.com
REACT_APP_GNOSIS_NODE_URL=https://daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://daemon.arbitrum.shapeshift.com
REACT_APP_ARBITRUM_NOVA_NODE_URL=https://daemon.arbitrum-nova.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://daemon.thorchain.shapeshift.com

# thorchain
Expand Down
1 change: 0 additions & 1 deletion react-app-rewired/headers/csps/chains/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const csp: Csp = {
'connect-src': [
process.env.REACT_APP_UNCHAINED_COSMOS_HTTP_URL!,
process.env.REACT_APP_UNCHAINED_COSMOS_WS_URL!,
process.env.REACT_APP_COSMOS_NODE_URL!,
],
'img-src': [
'https://raw.githubusercontent.com/cosmostation/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ describe.each([
wallet: {
supportsOfflineSigning: vi.fn().mockReturnValue(true),
ethSupportsEIP1559: vi.fn().mockReturnValue(walletSupportsEIP1559),
getVendor: vi.fn().mockReturnValue('Native'),
},
},
}) as unknown as IWalletContext,
Expand Down Expand Up @@ -230,6 +231,7 @@ describe.each([
wallet: {
supportsOfflineSigning: vi.fn().mockReturnValue(true),
ethSupportsEIP1559: vi.fn().mockReturnValue(walletSupportsEIP1559),
getVendor: vi.fn().mockReturnValue('Native'),
},
},
}) as unknown as IWalletContext,
Expand Down Expand Up @@ -296,6 +298,7 @@ describe.each([
supportsOfflineSigning: vi.fn().mockReturnValue(false),
supportsBroadcast: vi.fn().mockReturnValue(true),
ethSupportsEIP1559: vi.fn().mockReturnValue(walletSupportsEIP1559),
getVendor: vi.fn().mockReturnValue('Native'),
},
},
}) as unknown as IWalletContext,
Expand Down Expand Up @@ -351,6 +354,7 @@ describe.each([
supportsOfflineSigning: vi.fn().mockReturnValue(false),
supportsBroadcast: vi.fn().mockReturnValue(true),
ethSupportsEIP1559: vi.fn().mockReturnValue(walletSupportsEIP1559),
getVendor: vi.fn().mockReturnValue('Native'),
} as unknown as HDWallet
const toaster = vi.fn() as unknown as CreateToastFnReturn
const signAndBroadcastTransaction = vi.fn().mockResolvedValue('txid')
Expand Down
3 changes: 2 additions & 1 deletion src/components/Modals/Send/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
checkIsSnapInstalled,
} from 'hooks/useIsSnapInstalled/useIsSnapInstalled'
import { bn, bnOrZero } from 'lib/bignumber/bignumber'
import { assertGetChainAdapter, tokenOrUndefined } from 'lib/utils'
import { assertGetChainAdapter, isKeepKeyHDWallet, tokenOrUndefined } from 'lib/utils'
import { assertGetCosmosSdkChainAdapter } from 'lib/utils/cosmosSdk'
import { assertGetEvmChainAdapter, getSupportedEvmChainIds } from 'lib/utils/evm'
import { assertGetUtxoChainAdapter } from 'lib/utils/utxo'
Expand Down Expand Up @@ -141,6 +141,7 @@ export const handleSend = async ({
chainSpecific: { gasPrice, gasLimit, maxFeePerGas, maxPriorityFeePerGas },
} = fees
const shouldUseEIP1559Fees =
!isKeepKeyHDWallet(wallet) &&
(await wallet.ethSupportsEIP1559()) &&
maxFeePerGas !== undefined &&
maxPriorityFeePerGas !== undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { TradeQuoteStep } from '@shapeshiftoss/swapper'
import { useEffect, useState } from 'react'
import { usePoll } from 'hooks/usePoll/usePoll'
import { useWallet } from 'hooks/useWallet/useWallet'
import { isKeepKeyHDWallet } from 'lib/utils'
import { assertGetEvmChainAdapter } from 'lib/utils/evm'
import { selectHopSellAccountId } from 'state/slices/tradeQuoteSlice/selectors'
import { useAppSelector } from 'state/store'
Expand Down Expand Up @@ -38,7 +39,7 @@ export const useApprovalTx = (
// This accidentally works since all EVM chains share the same address, so there's no need
// to call adapter.getAddress() later down the call stack
const from = fromAccountId(sellAssetAccountId).account
const supportsEIP1559 = await wallet.ethSupportsEIP1559()
const supportsEIP1559 = !isKeepKeyHDWallet(wallet) && (await wallet.ethSupportsEIP1559())

const { buildCustomTxInput, networkFeeCryptoBaseUnit } = await getApprovalTxData({
tradeQuoteStep,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useErrorHandler } from 'hooks/useErrorToast/useErrorToast'
import { useWallet } from 'hooks/useWallet/useWallet'
import { MixPanelEvent } from 'lib/mixpanel/types'
import { TradeExecution } from 'lib/swapper/tradeExecution'
import { assertUnreachable } from 'lib/utils'
import { assertUnreachable, isKeepKeyHDWallet } from 'lib/utils'
import { assertGetCosmosSdkChainAdapter } from 'lib/utils/cosmosSdk'
import { assertGetEvmChainAdapter, signAndBroadcast } from 'lib/utils/evm'
import { assertGetUtxoChainAdapter } from 'lib/utils/utxo'
Expand Down Expand Up @@ -203,7 +203,8 @@ export const useTradeExecution = (hopIndex: number) => {
case CHAIN_NAMESPACE.Evm: {
const adapter = assertGetEvmChainAdapter(stepSellAssetChainId)
const from = await adapter.getAddress({ accountNumber, wallet })
const supportsEIP1559 = supportsETH(wallet) && (await wallet.ethSupportsEIP1559())
const supportsEIP1559 =
!isKeepKeyHDWallet(wallet) && supportsETH(wallet) && (await wallet.ethSupportsEIP1559())

const output = await execution.execEvmTransaction({
swapperName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ export const TradeQuoteLoaded: FC<TradeQuoteProps> = ({
const sellAsset = useAppSelector(selectInputSellAsset)
const { isTradingActive: isTradingActiveOnBuyPool } = useIsTradingActive({
assetId: buyAsset.assetId,
enabled: true,
})
const { isTradingActive: isTradingActiveOnSellPool } = useIsTradingActive({
assetId: sellAsset.assetId,
enabled: true,
})

const isTradingActive = Boolean(isTradingActiveOnBuyPool && isTradingActiveOnSellPool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { GetTradeQuoteInput } from '@shapeshiftoss/swapper'
import type { Asset, UtxoAccountType } from '@shapeshiftoss/types'
import type { TradeQuoteInputCommonArgs } from 'components/MultiHopTrade/types'
import { toBaseUnit } from 'lib/math'
import { assertUnreachable } from 'lib/utils'
import { assertUnreachable, isKeepKeyHDWallet } from 'lib/utils'
import { assertGetCosmosSdkChainAdapter } from 'lib/utils/cosmosSdk'
import { assertGetEvmChainAdapter } from 'lib/utils/evm'
import { assertGetUtxoChainAdapter } from 'lib/utils/utxo'
Expand Down Expand Up @@ -65,7 +65,8 @@ export const getTradeQuoteArgs = async ({

switch (chainNamespace) {
case CHAIN_NAMESPACE.Evm: {
const supportsEIP1559 = supportsETH(wallet) && (await wallet.ethSupportsEIP1559())
const supportsEIP1559 =
!isKeepKeyHDWallet(wallet) && supportsETH(wallet) && (await wallet.ethSupportsEIP1559())
const sellAssetChainAdapter = assertGetEvmChainAdapter(sellAsset.chainId)
const sendAddress = await sellAssetChainAdapter.getAddress({
accountNumber: sellAccountNumber,
Expand Down
3 changes: 0 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ const validators = {
REACT_APP_COWSWAP_BASE_URL: url({
default: 'https://api.cow.fi',
}),
REACT_APP_COSMOS_NODE_URL: url({
default: 'https://dev-daemon.cosmos.shapeshift.com',
}),
REACT_APP_ONRAMPER_WIDGET_URL: url(),
REACT_APP_ONRAMPER_API_URL: url(),
REACT_APP_ONRAMPER_API_KEY: str(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { encodeFunctionData, getAddress } from 'viem'
import { useFoxEth } from 'context/FoxEthProvider/FoxEthProvider'
import { useWallet } from 'hooks/useWallet/useWallet'
import { toBaseUnit } from 'lib/math'
import { isValidAccountNumber } from 'lib/utils'
import { isKeepKeyHDWallet, isValidAccountNumber } from 'lib/utils'
import {
assertGetEvmChainAdapter,
buildAndBroadcast,
Expand Down Expand Up @@ -220,7 +220,8 @@ export const useFoxFarming = (
from: userAddress,
to: contractAddress,
value: '0',
supportsEIP1559: supportsETH(wallet) && (await wallet.ethSupportsEIP1559()),
supportsEIP1559:
!isKeepKeyHDWallet(wallet) && supportsETH(wallet) && (await wallet.ethSupportsEIP1559()),
})
},
[adapter, contractAddress, foxFarmingContract, wallet],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ export const Confirm: React.FC<ConfirmProps> = ({ accountId, onNext }) => {

const { isTradingActive, refetch: refetchIsTradingActive } = useIsTradingActive({
assetId,
enabled: !!assetId,
})

const handleDeposit = useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const ThorchainSaversOverview: React.FC<OverviewProps> = ({

const { isTradingActive, isLoading: isTradingActiveLoading } = useIsTradingActive({
assetId,
enabled: !!assetId,
})

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ export const Confirm: React.FC<ConfirmProps> = ({ accountId, onNext }) => {

const { isTradingActive, refetch: refetchIsTradingActive } = useIsTradingActive({
assetId,
enabled: !!assetId,
})

const handleConfirm = useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery } from '@tanstack/react-query'
import { useMemo } from 'react'
import { isAddress } from 'viem'
import { isSmartContractAddress } from 'lib/address/utils'

export const useIsSmartContractAddress = (address: string) => {
Expand All @@ -13,7 +14,7 @@ export const useIsSmartContractAddress = (address: string) => {
},
],
queryFn: () => isSmartContractAddress(userAddress),
enabled: Boolean(userAddress.length),
enabled: Boolean(userAddress.length && isAddress(address)),
})

return query
Expand Down
2 changes: 2 additions & 0 deletions src/lib/investor/investor-foxy/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ethers } from 'ethers'
import { toLower } from 'lodash'
import { bn, bnOrZero } from 'lib/bignumber/bignumber'
import { MAX_ALLOWANCE } from 'lib/investor/constants'
import { isKeepKeyHDWallet } from 'lib/utils'
import { DefiType } from 'state/slices/opportunitiesSlice/types'

import { erc20Abi } from '../abi/erc20-abi'
Expand Down Expand Up @@ -128,6 +129,7 @@ export class FoxyApi {
chainSpecific: { gasPrice, gasLimit, maxFeePerGas, maxPriorityFeePerGas },
} = payload.estimatedFees.fast
const shouldUseEIP1559Fees =
!isKeepKeyHDWallet(wallet) &&
(await wallet.ethSupportsEIP1559()) &&
maxFeePerGas !== undefined &&
maxPriorityFeePerGas !== undefined
Expand Down
5 changes: 3 additions & 2 deletions src/lib/utils/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { encodeFunctionData, getAddress } from 'viem'
import { getChainAdapterManager } from 'context/PluginProvider/chainAdapterSingleton'
import { bn, bnOrZero } from 'lib/bignumber/bignumber'

import { getSupportedChainIdsByChainNamespace } from '.'
import { getSupportedChainIdsByChainNamespace, isKeepKeyHDWallet } from '.'

type GetApproveContractDataArgs = {
approvalAmountCryptoBaseUnit: string
Expand Down Expand Up @@ -96,7 +96,8 @@ export const getFeesWithWallet = async (args: GetFeesWithWalletArgs): Promise<Fe
const { accountNumber, adapter, wallet, ...rest } = args

const from = await adapter.getAddress({ accountNumber, wallet })
const supportsEIP1559 = supportsETH(wallet) && (await wallet.ethSupportsEIP1559())
const supportsEIP1559 =
!isKeepKeyHDWallet(wallet) && supportsETH(wallet) && (await wallet.ethSupportsEIP1559())

return getFees({ ...rest, adapter, from, supportsEIP1559 })
}
Expand Down
12 changes: 8 additions & 4 deletions src/pages/Lending/hooks/useGetEstimatedFeesQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const queryFn = async ({ queryKey }: { queryKey: EstimatedFeesQueryKey })
export const useGetEstimatedFeesQuery = ({
enabled,
...estimateFeesInput
}: EstimateFeesInput & { enabled: boolean }) => {
}: EstimateFeesInput & { enabled: boolean; disableRefetch?: boolean }) => {
const asset = useAppSelector(state => selectAssetById(state, estimateFeesInput.assetId))
const assetMarketData = useAppSelector(state =>
selectMarketDataById(state, estimateFeesInput.assetId),
Expand All @@ -49,9 +49,13 @@ export const useGetEstimatedFeesQuery = ({
staleTime: 30_000,
queryFn,
enabled: enabled && Boolean(estimateFeesInput.to && estimateFeesInput.accountId && asset),
// Ensures fees are refetched at an interval, including when the app is in the background
refetchIntervalInBackground: true,
refetchInterval: 5000,
...(enabled
? {
// Ensures fees are refetched at an interval, including when the app is in the background
refetchIntervalInBackground: true,
refetchInterval: 5000,
}
: {}),
})

return getEstimatedFeesQuery
Expand Down
1 change: 1 addition & 0 deletions src/pages/ThorChainLP/AvailablePools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const PoolButton = ({ pool }: PoolButtonProps) => {

const { isTradingActive, isLoading: isTradingActiveLoading } = useIsTradingActive({
assetId: pool?.assetId,
enabled: !!pool,
})

const handlePoolClick = useCallback(() => {
Expand Down
13 changes: 12 additions & 1 deletion src/pages/ThorChainLP/Pool/Pool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const Pool = () => {

const { isTradingActive, isLoading: isTradingActiveLoading } = useIsTradingActive({
assetId: foundPool?.assetId,
enabled: !!foundPool,
})

const poolAssetIds = useMemo(() => {
Expand All @@ -125,6 +126,11 @@ export const Pool = () => {
)
}, [foundPool?.opportunityId, history])

const handleTradeClick = useCallback(() => {
if (!foundPool) return
history.push(`/trade/${foundPool?.assetId}`)
}, [foundPool, history])

const runeMarketData = useAppSelector(state => selectMarketDataById(state, thorchainAssetId))
const assetMarketData = useAppSelector(state =>
selectMarketDataById(state, foundPool?.assetId ?? ''),
Expand Down Expand Up @@ -214,7 +220,12 @@ export const Pool = () => {
{translate('pools.addLiquidity')}
</Button>
</Tooltip>
<Button colorScheme='blue' leftIcon={swapIcon}>
<Button
colorScheme='blue'
leftIcon={swapIcon}
isDisabled={isTradingActiveLoading || isTradingActive === false}
onClick={handleTradeClick}
>
{translate('trade.trade')}
</Button>
</Flex>
Expand Down
Loading