@@ -30,6 +30,13 @@ import ConvertTokenRow from '../../../Earn/components/Musd/ConvertTokenRow';
3030import { AssetType } from '../../../../Views/confirmations/types/token' ;
3131import { MoneyConvertStablecoinsTestIds } from './MoneyConvertStablecoins.testIds' ;
3232import { CaipChainId } from '@metamask/utils' ;
33+ import { useSelector } from 'react-redux' ;
34+ import {
35+ createTokenChainKey ,
36+ selectHasInFlightMusdConversion ,
37+ selectHasUnapprovedMusdConversion ,
38+ selectMusdConversionStatuses ,
39+ } from '../../../Earn/selectors/musdConversionStatus' ;
3340
3441interface MoneyConvertStablecoinsProps {
3542 tokens : AssetType [ ] ;
@@ -134,6 +141,33 @@ const MoneyConvertStablecoins = ({
134141} : MoneyConvertStablecoinsProps ) => {
135142 const hasTokens = tokens . length > 0 ;
136143
144+ const hasUnapprovedMusdConversion = useSelector (
145+ selectHasUnapprovedMusdConversion ,
146+ ) ;
147+ const hasInFlightMusdConversion = useSelector (
148+ selectHasInFlightMusdConversion ,
149+ ) ;
150+
151+ const conversionStatusesByTokenChainKey = useSelector (
152+ selectMusdConversionStatuses ,
153+ ) ;
154+
155+ const isConversionPending = ( token : AssetType ) => {
156+ const tokenAddress = token . address ;
157+ const tokenChainId = token . chainId ;
158+
159+ const tokenChainKey =
160+ tokenAddress && tokenChainId
161+ ? createTokenChainKey ( tokenAddress , tokenChainId )
162+ : undefined ;
163+
164+ const txStatusInfo = tokenChainKey
165+ ? conversionStatusesByTokenChainKey [ tokenChainKey ]
166+ : undefined ;
167+
168+ return Boolean ( txStatusInfo ?. isPending ) ;
169+ } ;
170+
137171 return (
138172 < Box testID = { MoneyConvertStablecoinsTestIds . CONTAINER } >
139173 < Box twClassName = "px-4 pt-3" >
@@ -164,6 +198,10 @@ const MoneyConvertStablecoins = ({
164198 token = { token }
165199 onMaxPress = { onMaxPress }
166200 onEditPress = { onEditPress }
201+ areActionsDisabled = {
202+ hasUnapprovedMusdConversion || hasInFlightMusdConversion
203+ }
204+ isConversionPending = { isConversionPending ( token ) }
167205 />
168206 </ Box >
169207 ) ) }
0 commit comments