Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Relax Mimir checks (#2514)
Browse files Browse the repository at this point in the history
to have these on Swap / Deposit view level only
  • Loading branch information
veado authored Jan 2, 2023
1 parent 8166685 commit e64d3e7
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 151 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/renderer/components/deposit/add/SymDeposit.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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,
Expand Down
16 changes: 2 additions & 14 deletions src/renderer/components/deposit/add/SymDeposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
baseAmount,
BaseAmount,
baseToAsset,
Chain,
chainToString,
formatAssetAmountCurrency,
isAssetRuneNative,
Expand Down Expand Up @@ -77,7 +76,6 @@ import {
LiquidityProviderAssetMismatchRD,
LiquidityProviderHasAsymAssets,
LiquidityProviderHasAsymAssetsRD,
MimirHalt,
PendingAssets,
PendingAssetsRD
} from '../../../services/thorchain/types'
Expand Down Expand Up @@ -149,8 +147,7 @@ export type Props = {
isApprovedERC20Token$: (params: IsApproveParams) => LiveData<ApiError, boolean>
protocolLimitReached: boolean
poolsData: PoolsDataMap
haltedChains: Chain[]
mimirHalt: MimirHalt
disableDepositAction: boolean
symPendingAssets: PendingAssetsRD
openRecoveryTool: FP.Lazy<void>
hasAsymAssets: LiquidityProviderHasAsymAssetsRD
Expand Down Expand Up @@ -191,8 +188,7 @@ export const SymDeposit: React.FC<Props> = (props) => {
approveFee$,
protocolLimitReached,
poolsData,
haltedChains,
mimirHalt,
disableDepositAction,
symPendingAssets: symPendingAssetsRD,
openRecoveryTool,
hasAsymAssets: hasAsymAssetsRD,
Expand Down Expand Up @@ -305,14 +301,6 @@ export const SymDeposit: React.FC<Props> = (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>(baseAmount(0, THORCHAIN_DECIMAL))
Expand Down
5 changes: 1 addition & 4 deletions src/renderer/components/pool/PoolDetails.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ const meta: ComponentMeta<typeof Component> = {
watched: true,
priceRatio: ONE_BN,
HistoryView: () => <>Actions History Here</>,
ChartView: () => <>Pool Chart Here</>,
disableTradingPoolAction: false,
disableAllPoolActions: false,
disablePoolActions: false
ChartView: () => <>Pool Chart Here</>
}
}

Expand Down
27 changes: 1 addition & 26 deletions src/renderer/components/pool/PoolDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -54,10 +50,6 @@ export const PoolDetails: React.FC<Props> = ({
reloadPoolStatsDetail,
HistoryView,
ChartView,
disableTradingPoolAction,
disableAllPoolActions,
disablePoolActions,
walletLocked,
network,
poolsPeriod,
setPoolsPeriod
Expand All @@ -80,10 +72,6 @@ export const PoolDetails: React.FC<Props> = ({
return (
<PoolTitle
network={network}
disableAllPoolActions={disableAllPoolActions}
disableTradingPoolAction={disableTradingPoolAction}
disablePoolActions={disablePoolActions}
walletLocked={walletLocked}
asset={asset}
watched={watched}
watch={watch}
Expand All @@ -92,20 +80,7 @@ export const PoolDetails: React.FC<Props> = ({
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()
Expand Down
23 changes: 2 additions & 21 deletions src/renderer/components/pool/PoolTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export type Props = {
watch: FP.Lazy<void>
unwatch: FP.Lazy<void>
price: RD.RemoteData<Error, { amount: AssetAmount; symbol: string }>
disableTradingPoolAction: boolean
disableAllPoolActions: boolean
disablePoolActions: boolean
walletLocked: boolean
network: Network
isAvailablePool: boolean
}
Expand All @@ -36,10 +32,6 @@ export const PoolTitle: React.FC<Props> = ({
watch,
unwatch,
price: priceRD,
disableTradingPoolAction,
disableAllPoolActions,
disablePoolActions,
walletLocked,
network,
isAvailablePool
}) => {
Expand Down Expand Up @@ -79,7 +71,7 @@ export const PoolTitle: React.FC<Props> = ({
const actions: ActionButtonAction[] = [
{
label: intl.formatMessage({ id: 'common.swap' }),
disabled: !isAvailablePool || disableAllPoolActions || disableTradingPoolAction,
disabled: !isAvailablePool,
callback: () => {
navigate(
poolsRoutes.swap.path({
Expand All @@ -93,7 +85,6 @@ export const PoolTitle: React.FC<Props> = ({
},
{
label: intl.formatMessage({ id: 'common.manage' }),
disabled: disableAllPoolActions || disablePoolActions || walletLocked,
callback: () => {
navigate(
poolsRoutes.deposit.path({
Expand All @@ -115,17 +106,7 @@ export const PoolTitle: React.FC<Props> = ({
]

return <ActionButton size={isDesktopView ? 'large' : 'normal'} actions={actions} />
}, [
intl,
isAvailablePool,
disableAllPoolActions,
disableTradingPoolAction,
disablePoolActions,
walletLocked,
isDesktopView,
navigate,
asset
])
}, [intl, isAvailablePool, isDesktopView, navigate, asset])

return (
<Styled.Container>
Expand Down
5 changes: 0 additions & 5 deletions src/renderer/views/app/AppView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -317,9 +314,7 @@ export const AppView: React.FC = (): JSX.Element => {
<Styled.AppWrapper>
<Styled.AppLayout>
<AppUpdateView />
<div className="p-2">{location.pathname}</div>
<Header />

<View>
{renderMidgardError}
{renderImportKeystoreWalletsError}
Expand Down
14 changes: 8 additions & 6 deletions src/renderer/views/deposit/add/SymDepositView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -177,8 +178,7 @@ export const SymDepositView: React.FC<Props> = (props) => {
<Alert type="error" message={intl.formatMessage({ id: 'common.error' })} description={error.toString()} />
)}
<SymDeposit
haltedChains={haltedChains}
mimirHalt={mimirHalt}
disableDepositAction
validatePassword$={validatePassword$}
openRuneExplorerTxUrl={openRuneExplorerTxUrl}
openAssetExplorerTxUrl={openAssetExplorerTxUrl}
Expand Down Expand Up @@ -218,8 +218,6 @@ export const SymDepositView: React.FC<Props> = (props) => {
),
[
intl,
haltedChains,
mimirHalt,
validatePassword$,
openRuneExplorerTxUrl,
openAssetExplorerTxUrl,
Expand Down Expand Up @@ -255,11 +253,15 @@ export const SymDepositView: React.FC<Props> = (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 (
<>
<SymDeposit
haltedChains={haltedChains}
mimirHalt={mimirHalt}
disableDepositAction={disableDepositAction}
validatePassword$={validatePassword$}
openRuneExplorerTxUrl={openRuneExplorerTxUrl}
openAssetExplorerTxUrl={openAssetExplorerTxUrl}
Expand Down
32 changes: 0 additions & 32 deletions src/renderer/views/pool/PoolDetailsView.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React, { useCallback, useEffect, useMemo, useRef } from 'react'

import * as RD from '@devexperts/remote-data-ts'
import { Chain } from '@xchainjs/xchain-util'
import * as FP from 'fp-ts/function'
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 { useParams } from 'react-router-dom'
import * as RxOp from 'rxjs/operators'

import { PoolDetails, Props as PoolDetailProps } from '../../components/pool/PoolDetails'
import { ErrorView } from '../../components/shared/error'
Expand All @@ -18,10 +16,7 @@ import { useAppContext } from '../../contexts/AppContext'
import { useMidgardContext } from '../../contexts/MidgardContext'
import { getAssetFromNullableString } from '../../helpers/assetHelper'
import { eqAsset } from '../../helpers/fp/eq'
import * as PoolHelpers from '../../helpers/poolHelper'
import { useKeystoreState } from '../../hooks/useKeystoreState'
import { useMidgardHistoryActions } from '../../hooks/useMidgardHistoryActions'
import { useMimirHalt } from '../../hooks/useMimirHalt'
import { usePoolWatchlist } from '../../hooks/usePoolWatchlist'
import { PoolDetailRouteParams } from '../../routes/pools/detail'
import { DEFAULT_NETWORK } from '../../services/const'
Expand Down Expand Up @@ -50,10 +45,6 @@ const defaultDetailsProps: TargetPoolDetailProps = {
poolStatsDetail: RD.initial,
priceSymbol: '',
network: DEFAULT_NETWORK,
disableAllPoolActions: false,
disableTradingPoolAction: false,
disablePoolActions: false,
walletLocked: false,
poolsPeriod: DEFAULT_GET_POOLS_PERIOD
}

Expand All @@ -69,7 +60,6 @@ export const PoolDetailsView: React.FC = () => {
poolStatsDetail$,
reloadPoolStatsDetail,
reloadSelectedPoolDetail,
haltedChains$,
poolsPeriod$,
setPoolsPeriod
},
Expand All @@ -81,30 +71,12 @@ export const PoolDetailsView: React.FC = () => {

const intl = useIntl()

const { locked: walletLocked } = useKeystoreState()

const { asset } = useParams<PoolDetailRouteParams>()

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
Expand Down Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit e64d3e7

Please sign in to comment.