diff --git a/widget/embedded/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx b/widget/embedded/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx index 44146380fa..020102ceab 100644 --- a/widget/embedded/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +++ b/widget/embedded/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx @@ -1,30 +1,36 @@ import type { WalletStateContentProps } from './SwapDetailsModal.types'; -import { MessageBox, Wallet, WalletState } from '@rango-dev/ui'; +import { MessageBox, Wallet } from '@rango-dev/ui'; import { useWallets } from '@rango-dev/wallets-react'; import React from 'react'; import { getContainer } from '../../utils/common'; +import { mapStatusToWalletState } from '../../utils/wallets'; import { WalletContainer } from './SwapDetailsModal.styles'; export const WalletStateContent = (props: WalletStateContentProps) => { const { type, title, currentStepWallet, message, showWalletButton } = props; - const { connect, getWalletInfo, state: walletState } = useWallets(); + const { connect, getWalletInfo, state } = useWallets(); const walletType = currentStepWallet?.walletType; - const isConnected = walletType && walletState(walletType).connected; - const state = isConnected ? WalletState.CONNECTED : WalletState.DISCONNECTED; + const walletState = walletType + ? mapStatusToWalletState(state(walletType)) + : null; + const walletInfo = walletType ? getWalletInfo(walletType) : null; + const shouldShowWallet = + showWalletButton && !!walletType && !!walletState && !!walletInfo; return ( <> - {showWalletButton && walletType && ( + {shouldShowWallet && ( connect(walletType)} /> diff --git a/widget/ui/src/components/Wallet/Wallet.types.ts b/widget/ui/src/components/Wallet/Wallet.types.ts index cfb217b35b..e6fe7d25c5 100644 --- a/widget/ui/src/components/Wallet/Wallet.types.ts +++ b/widget/ui/src/components/Wallet/Wallet.types.ts @@ -21,26 +21,6 @@ export interface Info { tooltipText: string; } -interface StateConnected { - state: WalletState.CONNECTED; -} -interface StateDisconnected { - state: WalletState.DISCONNECTED; -} -interface StateConnecting { - state: WalletState.CONNECTING; -} -interface StateNotInstalled { - state: WalletState.NOT_INSTALLED; - link: InstallObjects | string; -} - -type State = - | StateConnected - | StateDisconnected - | StateConnecting - | StateNotInstalled; - export interface ContentProps { image: string; title: string; @@ -48,9 +28,11 @@ export interface ContentProps { descriptionColor?: string; } -interface WalletProps { +export interface WalletPropTypes { + state: WalletState; title: string; image: string; + link: InstallObjects | string; type: WalletType; onClick: (type: WalletType) => void; selected?: boolean; @@ -59,8 +41,6 @@ interface WalletProps { container?: HTMLElement; } -export type WalletPropTypes = State & WalletProps; - export type SelectablePropTypes = WalletPropTypes & { selected: boolean; };