diff --git a/CHANGELOG.md b/CHANGELOG.md index 516496448..36d4968cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - [Deposit] Wallet types based on routes [#2506](https://github.com/thorchain/asgardex-electron/pull/2506) - [SWAP] Persistant wallet state while reloading or switching asset pair [#2511](https://github.com/thorchain/asgardex-electron/pull/2511) - [Wallet] Add `Swap` to `ActionButton` to jump to swap view with one click only [#2512](https://github.com/thorchain/asgardex-electron/pull/2512) +- [Wallet] Add `Add` to `ActionButton` to jump to LP view with one click only [#2513](https://github.com/thorchain/asgardex-electron/pull/2513) ## Fix @@ -23,6 +24,10 @@ - [SymDeposit] RUNE can be selected on asset side [#2507](https://github.com/thorchain/asgardex-electron/issues/2507) - [Deposit] Check of asset missmatch failed [#2509](https://github.com/thorchain/asgardex-electron/issues/2509) +## Internal + +- Relax Mimir checks to have these on Swap / Deposit view level only [#2514](https://github.com/thorchain/asgardex-electron/pull/2514) + # 1.18.5 (2022-12-20) ## Add diff --git a/src/renderer/components/deposit/add/SymDeposit.stories.tsx b/src/renderer/components/deposit/add/SymDeposit.stories.tsx index 230daa6c9..6f84b1735 100644 --- a/src/renderer/components/deposit/add/SymDeposit.stories.tsx +++ b/src/renderer/components/deposit/add/SymDeposit.stories.tsx @@ -24,7 +24,6 @@ import { RUNE_PRICE_POOL } from '../../../helpers/poolHelper' import { mockWalletBalance } from '../../../helpers/test/testWalletHelper' import { INITIAL_SYM_DEPOSIT_STATE } from '../../../services/chain/const' import { SymDepositState } from '../../../services/chain/types' -import { DEFAULT_MIMIR_HALT } from '../../../services/thorchain/const' import { WalletBalance } from '../../../services/wallet/types' import { SymDeposit, Props as SymDepositProps } from './SymDeposit' @@ -51,10 +50,9 @@ const balanceTOMO: WalletBalance = mockWalletBalance({ }) const defaultProps: SymDepositProps = { - haltedChains: [], + disableDepositAction: false, availableAssets: [AssetRuneNative, AssetBNB, AssetBTC], walletBalances: { balances: O.some([balanceRune, balanceBNB, balanceBTC, balanceTOMO]), loading: false }, - mimirHalt: DEFAULT_MIMIR_HALT, asset: { asset: AssetBNB, decimal: BNB_DECIMAL }, poolDetails: [], pricePool: RUNE_PRICE_POOL, diff --git a/src/renderer/components/deposit/add/SymDeposit.tsx b/src/renderer/components/deposit/add/SymDeposit.tsx index 2caa32edd..bd8bcf9f1 100644 --- a/src/renderer/components/deposit/add/SymDeposit.tsx +++ b/src/renderer/components/deposit/add/SymDeposit.tsx @@ -11,7 +11,6 @@ import { baseAmount, BaseAmount, baseToAsset, - Chain, chainToString, formatAssetAmountCurrency, isAssetRuneNative, @@ -77,7 +76,6 @@ import { LiquidityProviderAssetMismatchRD, LiquidityProviderHasAsymAssets, LiquidityProviderHasAsymAssetsRD, - MimirHalt, PendingAssets, PendingAssetsRD } from '../../../services/thorchain/types' @@ -149,8 +147,7 @@ export type Props = { isApprovedERC20Token$: (params: IsApproveParams) => LiveData protocolLimitReached: boolean poolsData: PoolsDataMap - haltedChains: Chain[] - mimirHalt: MimirHalt + disableDepositAction: boolean symPendingAssets: PendingAssetsRD openRecoveryTool: FP.Lazy hasAsymAssets: LiquidityProviderHasAsymAssetsRD @@ -191,8 +188,7 @@ export const SymDeposit: React.FC = (props) => { approveFee$, protocolLimitReached, poolsData, - haltedChains, - mimirHalt, + disableDepositAction, symPendingAssets: symPendingAssetsRD, openRecoveryTool, hasAsymAssets: hasAsymAssetsRD, @@ -305,14 +301,6 @@ export const SymDeposit: React.FC = (props) => { [assetDecimal, oAssetWB] ) - const disableDepositAction = useMemo( - () => - PoolHelpers.disableAllActions({ chain: asset.chain, haltedChains, mimirHalt }) || - PoolHelpers.disableTradingActions({ chain: asset.chain, haltedChains, mimirHalt }) || - PoolHelpers.disablePoolActions({ chain: asset.chain, haltedChains, mimirHalt }), - [asset.chain, haltedChains, mimirHalt] - ) - const assetBalanceMax1e8: BaseAmount = useMemo(() => max1e8BaseAmount(assetBalance), [assetBalance]) const [runeAmountToDeposit, setRuneAmountToDeposit] = useState(baseAmount(0, THORCHAIN_DECIMAL)) diff --git a/src/renderer/components/pool/PoolDetails.stories.tsx b/src/renderer/components/pool/PoolDetails.stories.tsx index 03cfba236..821645376 100644 --- a/src/renderer/components/pool/PoolDetails.stories.tsx +++ b/src/renderer/components/pool/PoolDetails.stories.tsx @@ -42,10 +42,7 @@ const meta: ComponentMeta = { watched: true, priceRatio: ONE_BN, HistoryView: () => <>Actions History Here, - ChartView: () => <>Pool Chart Here, - disableTradingPoolAction: false, - disableAllPoolActions: false, - disablePoolActions: false + ChartView: () => <>Pool Chart Here } } diff --git a/src/renderer/components/pool/PoolDetails.tsx b/src/renderer/components/pool/PoolDetails.tsx index e02ec2f49..81432ea15 100644 --- a/src/renderer/components/pool/PoolDetails.tsx +++ b/src/renderer/components/pool/PoolDetails.tsx @@ -31,10 +31,6 @@ export type Props = { historyActions: PoolHistoryActions }> ChartView: React.ComponentType<{ priceRatio: BigNumber }> - disableTradingPoolAction: boolean - disableAllPoolActions: boolean - disablePoolActions: boolean - walletLocked: boolean network: Network poolsPeriod: GetPoolsPeriodEnum setPoolsPeriod: (v: GetPoolsPeriodEnum) => void @@ -54,10 +50,6 @@ export const PoolDetails: React.FC = ({ reloadPoolStatsDetail, HistoryView, ChartView, - disableTradingPoolAction, - disableAllPoolActions, - disablePoolActions, - walletLocked, network, poolsPeriod, setPoolsPeriod @@ -80,10 +72,6 @@ export const PoolDetails: React.FC = ({ return ( = ({ isAvailablePool={isAvailablePool} /> ) - }, [ - asset, - disableAllPoolActions, - disablePoolActions, - disableTradingPoolAction, - network, - poolDetailRD, - priceRatio, - priceSymbol, - unwatch, - walletLocked, - watch, - watched - ]) + }, [asset, network, poolDetailRD, priceRatio, priceSymbol, unwatch, watch, watched]) const reloadPoolCardsData = useCallback(() => { reloadPoolStatsDetail() diff --git a/src/renderer/components/pool/PoolTitle.tsx b/src/renderer/components/pool/PoolTitle.tsx index efc14d707..7aa68d186 100644 --- a/src/renderer/components/pool/PoolTitle.tsx +++ b/src/renderer/components/pool/PoolTitle.tsx @@ -22,10 +22,6 @@ export type Props = { watch: FP.Lazy unwatch: FP.Lazy price: RD.RemoteData - disableTradingPoolAction: boolean - disableAllPoolActions: boolean - disablePoolActions: boolean - walletLocked: boolean network: Network isAvailablePool: boolean } @@ -36,10 +32,6 @@ export const PoolTitle: React.FC = ({ watch, unwatch, price: priceRD, - disableTradingPoolAction, - disableAllPoolActions, - disablePoolActions, - walletLocked, network, isAvailablePool }) => { @@ -79,7 +71,7 @@ export const PoolTitle: React.FC = ({ const actions: ActionButtonAction[] = [ { label: intl.formatMessage({ id: 'common.swap' }), - disabled: !isAvailablePool || disableAllPoolActions || disableTradingPoolAction, + disabled: !isAvailablePool, callback: () => { navigate( poolsRoutes.swap.path({ @@ -93,7 +85,6 @@ export const PoolTitle: React.FC = ({ }, { label: intl.formatMessage({ id: 'common.manage' }), - disabled: disableAllPoolActions || disablePoolActions || walletLocked, callback: () => { navigate( poolsRoutes.deposit.path({ @@ -115,17 +106,7 @@ export const PoolTitle: React.FC = ({ ] return - }, [ - intl, - isAvailablePool, - disableAllPoolActions, - disableTradingPoolAction, - disablePoolActions, - walletLocked, - isDesktopView, - navigate, - asset - ]) + }, [intl, isAvailablePool, isDesktopView, navigate, asset]) return ( diff --git a/src/renderer/views/app/AppView.tsx b/src/renderer/views/app/AppView.tsx index 5617d4afc..c18c59d95 100644 --- a/src/renderer/views/app/AppView.tsx +++ b/src/renderer/views/app/AppView.tsx @@ -8,7 +8,6 @@ import * as A from 'fp-ts/lib/Array' import * as O from 'fp-ts/Option' import { useObservableState } from 'observable-hooks' import { useIntl } from 'react-intl' -import { useLocation } from 'react-router' import { DEFAULT_LOCALE } from '../../../shared/i18n/const' import { envOrDefault } from '../../../shared/utils/env' @@ -44,8 +43,6 @@ export const AppView: React.FC = (): JSX.Element => { const { isLight } = useTheme() - const location = useLocation() - // locale useEffect(() => { // Needed to update Electron native menu according to the selected locale @@ -317,9 +314,7 @@ export const AppView: React.FC = (): JSX.Element => { -
{location.pathname}
- {renderMidgardError} {renderImportKeystoreWalletsError} diff --git a/src/renderer/views/deposit/add/SymDepositView.tsx b/src/renderer/views/deposit/add/SymDepositView.tsx index 6acc11127..92a400c3e 100644 --- a/src/renderer/views/deposit/add/SymDepositView.tsx +++ b/src/renderer/views/deposit/add/SymDepositView.tsx @@ -20,6 +20,7 @@ import { useThorchainContext } from '../../../contexts/ThorchainContext' import { useWalletContext } from '../../../contexts/WalletContext' import { hasLedgerAddress } from '../../../helpers/addressHelper' import { sequenceTRD } from '../../../helpers/fpHelpers' +import * as PoolHelpers from '../../../helpers/poolHelper' import { RUNE_PRICE_POOL } from '../../../helpers/poolHelper' import { useLedgerAddresses } from '../../../hooks/useLedgerAddresses' import { useLiquidityProviders } from '../../../hooks/useLiquidityProviders' @@ -177,8 +178,7 @@ export const SymDepositView: React.FC = (props) => { )} = (props) => { ), [ intl, - haltedChains, - mimirHalt, validatePassword$, openRuneExplorerTxUrl, openAssetExplorerTxUrl, @@ -255,11 +253,15 @@ export const SymDepositView: React.FC = (props) => { // Since RUNE is not part of pool assets, add it to the list of available assets const availableAssets = [AssetRuneNative, ...poolAssets] + const disableDepositAction = + PoolHelpers.disableAllActions({ chain: asset.chain, haltedChains, mimirHalt }) || + PoolHelpers.disableTradingActions({ chain: asset.chain, haltedChains, mimirHalt }) || + PoolHelpers.disablePoolActions({ chain: asset.chain, haltedChains, mimirHalt }) + return ( <> { poolStatsDetail$, reloadPoolStatsDetail, reloadSelectedPoolDetail, - haltedChains$, poolsPeriod$, setPoolsPeriod }, @@ -81,30 +71,12 @@ export const PoolDetailsView: React.FC = () => { const intl = useIntl() - const { locked: walletLocked } = useKeystoreState() - const { asset } = useParams() const { add: addToWatchList, remove: removeFromWatchList, list: watchedList } = usePoolWatchlist() const poolsPeriod = useObservableState(poolsPeriod$, DEFAULT_GET_POOLS_PERIOD) - const [haltedChains] = useObservableState(() => FP.pipe(haltedChains$, RxOp.map(RD.getOrElse((): Chain[] => []))), []) - const { mimirHalt } = useMimirHalt() - - const getDisableAllPoolActions = useCallback( - (chain: Chain) => PoolHelpers.disableAllActions({ chain, haltedChains, mimirHalt }), - [haltedChains, mimirHalt] - ) - const getDisableTradingPoolAction = useCallback( - (chain: Chain) => PoolHelpers.disableTradingActions({ chain, haltedChains, mimirHalt }), - [haltedChains, mimirHalt] - ) - const getDisablePoolActions = useCallback( - (chain: Chain) => PoolHelpers.disablePoolActions({ chain, haltedChains, mimirHalt }), - [haltedChains, mimirHalt] - ) - const oRouteAsset = useMemo(() => getAssetFromNullableString(asset), [asset]) // Set selected pool asset whenever an asset in route has been changed @@ -166,10 +138,6 @@ export const PoolDetailsView: React.FC = () => { priceSymbol, HistoryView: PoolHistoryView, ChartView: PoolChartView, - disableAllPoolActions: getDisableAllPoolActions(asset.chain), - disableTradingPoolAction: getDisableTradingPoolAction(asset.chain), - disablePoolActions: getDisablePoolActions(asset.chain), - walletLocked, poolsPeriod } diff --git a/src/renderer/views/pools/ActivePools.tsx b/src/renderer/views/pools/ActivePools.tsx index c1bb607ac..b6b891667 100644 --- a/src/renderer/views/pools/ActivePools.tsx +++ b/src/renderer/views/pools/ActivePools.tsx @@ -40,12 +40,12 @@ import * as poolsRoutes from '../../routes/pools' import { DEFAULT_NETWORK } from '../../services/const' import { PoolsState, DEFAULT_POOL_FILTERS } from '../../services/midgard/types' import { GetPoolsPeriodEnum } from '../../types/generated/midgard' -import { PoolsComponentProps, PoolTableRowData, PoolTableRowsData } from './Pools.types' +import { PoolTableRowData, PoolTableRowsData } from './Pools.types' import { filterTableData } from './Pools.utils' import * as Shared from './PoolsOverview.shared' import * as Styled from './PoolsOverview.styles' -export const ActivePools: React.FC = ({ haltedChains, mimirHalt, walletLocked }): JSX.Element => { +export const ActivePools: React.FC = (): JSX.Element => { const navigate = useNavigate() const intl = useIntl() @@ -82,23 +82,9 @@ export const ActivePools: React.FC = ({ haltedChains, mimir const renderBtnPoolsColumn = useCallback( (_: string, { asset }: { asset: Asset }) => { - const chain = asset.chain - const disableAllPoolActions = PoolHelpers.disableAllActions({ chain, haltedChains, mimirHalt }) - const disableTradingActions = PoolHelpers.disableTradingActions({ - chain, - haltedChains, - mimirHalt - }) - const disablePoolActions = PoolHelpers.disablePoolActions({ - chain, - haltedChains, - mimirHalt - }) - const actions: ActionButtonAction[] = [ { label: intl.formatMessage({ id: 'common.swap' }), - disabled: disableAllPoolActions || disableTradingActions, callback: () => { navigate( poolsRoutes.swap.path({ @@ -112,7 +98,6 @@ export const ActivePools: React.FC = ({ haltedChains, mimir }, { label: intl.formatMessage({ id: 'common.manage' }), - disabled: disableAllPoolActions || disablePoolActions || walletLocked, callback: () => { navigate( poolsRoutes.deposit.path({ @@ -140,7 +125,7 @@ export const ActivePools: React.FC = ({ haltedChains, mimir ) }, - [haltedChains, mimirHalt, intl, walletLocked, navigate] + [intl, navigate] ) const btnPoolsColumn = useCallback( diff --git a/src/renderer/views/pools/PendingPools.tsx b/src/renderer/views/pools/PendingPools.tsx index 4a30f4470..b3c608c04 100644 --- a/src/renderer/views/pools/PendingPools.tsx +++ b/src/renderer/views/pools/PendingPools.tsx @@ -19,7 +19,6 @@ import { Table } from '../../components/uielements/table' import { useAppContext } from '../../contexts/AppContext' import { useMidgardContext } from '../../contexts/MidgardContext' import { useThorchainContext } from '../../contexts/ThorchainContext' -import * as PoolHelpers from '../../helpers/poolHelper' import { getPoolTableRowsData, RUNE_PRICE_POOL } from '../../helpers/poolHelper' import { useIncentivePendulum } from '../../hooks/useIncentivePendulum' import { usePoolCycle } from '../../hooks/usePoolCycle' @@ -31,14 +30,14 @@ import { DEFAULT_NETWORK } from '../../services/const' import { PendingPoolsState, DEFAULT_POOL_FILTERS } from '../../services/midgard/types' import { ThorchainLastblockRD } from '../../services/thorchain/types' import { PoolDetail } from '../../types/generated/midgard' -import { PoolsComponentProps, PoolTableRowData, PoolTableRowsData } from './Pools.types' +import { PoolTableRowData, PoolTableRowsData } from './Pools.types' import { getBlocksLeftForPendingPoolAsString, isEmptyPool } from './Pools.utils' import { filterTableData } from './Pools.utils' import * as Shared from './PoolsOverview.shared' import { TableAction, BlockLeftLabel } from './PoolsOverview.styles' import * as Styled from './PoolsOverview.styles' -export const PendingPools: React.FC = ({ haltedChains, mimirHalt, walletLocked }): JSX.Element => { +export const PendingPools: React.FC = (): JSX.Element => { const navigate = useNavigate() const intl = useIntl() @@ -81,21 +80,13 @@ export const PendingPools: React.FC = ({ haltedChains, mimi const renderBtnPoolsColumn = useCallback( (_: string, { asset }: PoolTableRowData) => { - const disablePool = - PoolHelpers.disableAllActions({ chain: asset.chain, haltedChains, mimirHalt }) || - PoolHelpers.disablePoolActions({ chain: asset.chain, haltedChains, mimirHalt }) return ( - + ) }, - [haltedChains, isDesktopView, mimirHalt, walletLocked] + [isDesktopView] ) const btnPendingPoolsColumn: ColumnType = useMemo( diff --git a/src/renderer/views/pools/Pools.types.ts b/src/renderer/views/pools/Pools.types.ts index 85edb0575..c2efb0fcf 100644 --- a/src/renderer/views/pools/Pools.types.ts +++ b/src/renderer/views/pools/Pools.types.ts @@ -1,9 +1,8 @@ import { PoolData } from '@thorchain/asgardex-util' -import { BaseAmount, Asset, Chain } from '@xchainjs/xchain-util' +import { BaseAmount, Asset } from '@xchainjs/xchain-util' import { NonEmptyArray } from 'fp-ts/lib/NonEmptyArray' import { Network } from '../../../shared/api/types' -import { MimirHalt } from '../../services/thorchain/types' import { GetPoolsStatusEnum } from '../../types/generated/midgard' // List of assets used for pricing @@ -35,9 +34,4 @@ export type PoolTableRowData = { watched: boolean } -export type PoolsComponentProps = { - haltedChains: Chain[] - mimirHalt: MimirHalt - walletLocked: boolean -} export type PoolTableRowsData = PoolTableRowData[] diff --git a/src/renderer/views/pools/PoolsOverview.tsx b/src/renderer/views/pools/PoolsOverview.tsx index f5eed659e..630fd61eb 100644 --- a/src/renderer/views/pools/PoolsOverview.tsx +++ b/src/renderer/views/pools/PoolsOverview.tsx @@ -68,12 +68,12 @@ export const PoolsOverview: React.FC = (): JSX.Element => { { index: TAB_INDEX['active'], label: intl.formatMessage({ id: 'pools.available' }), - content: + content: }, { index: TAB_INDEX['pending'], label: intl.formatMessage({ id: 'pools.pending' }), - content: + content: }, { index: TAB_INDEX['savers'],