11import React , { useCallback , useRef } from 'react' ;
2- import { TouchableOpacity , View } from 'react-native' ;
2+ import { Linking , TouchableOpacity , View } from 'react-native' ;
33import { useNavigation } from '@react-navigation/native' ;
44import {
55 BottomSheet ,
@@ -14,7 +14,15 @@ import {
1414 TextColor ,
1515 TextVariant ,
1616} from '@metamask/design-system-react-native' ;
17+ import Clipboard from '@react-native-clipboard/clipboard' ;
1718import Tag from '../../../../../component-library/components/Tags/Tag' ;
19+ import ButtonIcon , {
20+ ButtonIconSizes ,
21+ } from '../../../../../component-library/components/Buttons/ButtonIcon' ;
22+ import {
23+ IconName as ComponentLibraryIconName ,
24+ IconColor as ComponentLibraryIconColor ,
25+ } from '../../../../../component-library/components/Icons/Icon' ;
1826import { strings } from '../../../../../../locales/i18n' ;
1927import { useStyles } from '../../../../../component-library/hooks' ;
2028import { useMusdConversionFlowData } from '../../../Earn/hooks/useMusdConversionFlowData' ;
@@ -25,6 +33,15 @@ import {
2533} from '../../../Earn/constants/musd' ;
2634import { useRampNavigation } from '../../../Ramp/hooks/useRampNavigation' ;
2735import { useMoneyAccountDeposit } from '../../hooks/useMoneyAccount' ;
36+ import { useSelector } from 'react-redux' ;
37+ import {
38+ selectMoneyShowMoneyAccountAddress ,
39+ selectMoneyAccountVaultConfig ,
40+ } from '../../../../../selectors/featureFlagController/moneyAccount' ;
41+ import { selectPrimaryMoneyAccount } from '../../../../../selectors/moneyAccountController' ;
42+ import { selectNetworkConfigurations } from '../../../../../selectors/networkController' ;
43+ import { findBlockExplorerUrlForChain } from '../../../../../util/networks' ;
44+ import { renderShortAddress } from '../../../../../util/address' ;
2845import styleSheet from './MoneyAddMoneySheet.styles' ;
2946import { MoneyAddMoneySheetTestIds } from './MoneyAddMoneySheet.testIds' ;
3047
@@ -47,6 +64,19 @@ const MoneyAddMoneySheet: React.FC = () => {
4764 const { goToBuy } = useRampNavigation ( ) ;
4865 const { initiateDeposit } = useMoneyAccountDeposit ( ) ;
4966
67+ const showMoneyAccountAddress = useSelector (
68+ selectMoneyShowMoneyAccountAddress ,
69+ ) ;
70+ const vaultConfig = useSelector ( selectMoneyAccountVaultConfig ) ;
71+ const primaryMoneyAccount = useSelector ( selectPrimaryMoneyAccount ) ;
72+ const networkConfigurations = useSelector ( selectNetworkConfigurations ) ;
73+
74+ const moneyAccountAddress = primaryMoneyAccount ?. address ;
75+
76+ const blockExplorerUrl = vaultConfig ?. chainId
77+ ? findBlockExplorerUrlForChain ( vaultConfig . chainId , networkConfigurations )
78+ : undefined ;
79+
5080 const closeAndNavigate = useCallback ( ( navigateFn : ( ) => void ) => {
5181 sheetRef . current ?. onCloseBottomSheet ( navigateFn ) ;
5282 } , [ ] ) ;
@@ -88,6 +118,18 @@ const MoneyAddMoneySheet: React.FC = () => {
88118 moveMusdLabel = strings ( 'money.add_money_sheet.move_musd_no_amount' ) ;
89119 }
90120
121+ const handleCopyAddress = useCallback ( ( ) => {
122+ if ( moneyAccountAddress ) {
123+ Clipboard . setString ( moneyAccountAddress ) ;
124+ }
125+ } , [ moneyAccountAddress ] ) ;
126+
127+ const handleOpenExplorer = useCallback ( ( ) => {
128+ if ( blockExplorerUrl && moneyAccountAddress ) {
129+ Linking . openURL ( `${ blockExplorerUrl } /address/${ moneyAccountAddress } ` ) ;
130+ }
131+ } , [ blockExplorerUrl , moneyAccountAddress ] ) ;
132+
91133 const options : Option [ ] = [
92134 {
93135 label : strings ( 'money.add_money_sheet.convert_crypto' ) ,
@@ -163,21 +205,74 @@ const MoneyAddMoneySheet: React.FC = () => {
163205 < Icon
164206 name = { IconName . Arrow2Down }
165207 size = { IconSize . Lg }
166- color = { IconColor . IconMuted }
208+ color = {
209+ showMoneyAccountAddress && moneyAccountAddress
210+ ? IconColor . IconDefault
211+ : IconColor . IconMuted
212+ }
167213 />
168- < View style = { styles . disabledRowContent } >
169- < Text
170- variant = { TextVariant . BodyMd }
171- fontWeight = { FontWeight . Medium }
172- color = { TextColor . TextAlternative }
173- >
174- { strings ( 'money.add_money_sheet.receive_external' ) }
175- </ Text >
176- < Tag
177- label = { strings ( 'money.add_money_sheet.coming_soon' ) }
178- style = { styles . comingSoonTag }
179- />
180- </ View >
214+
215+ { /* This is intended to be for development
216+ Until we have implemented the receive by address flow
217+ */ }
218+
219+ { showMoneyAccountAddress && moneyAccountAddress ? (
220+ < >
221+ < View style = { styles . addressRowContent } >
222+ < Text
223+ variant = { TextVariant . BodyMd }
224+ fontWeight = { FontWeight . Medium }
225+ >
226+ { strings ( 'money.add_money_sheet.receive_external' ) }
227+ </ Text >
228+ < Text
229+ variant = { TextVariant . BodySm }
230+ color = { TextColor . TextAlternative }
231+ testID = { MoneyAddMoneySheetTestIds . RECEIVE_EXTERNAL_ADDRESS }
232+ >
233+ { renderShortAddress ( moneyAccountAddress ) }
234+ </ Text >
235+ </ View >
236+ < View style = { styles . addressActions } >
237+ < ButtonIcon
238+ testID = { MoneyAddMoneySheetTestIds . COPY_ADDRESS_BUTTON }
239+ iconName = { ComponentLibraryIconName . Copy }
240+ iconColor = { ComponentLibraryIconColor . Default }
241+ size = { ButtonIconSizes . Lg }
242+ onPress = { handleCopyAddress }
243+ accessibilityLabel = { strings (
244+ 'money.add_money_sheet.copy_address' ,
245+ ) }
246+ />
247+ { blockExplorerUrl ? (
248+ < ButtonIcon
249+ testID = { MoneyAddMoneySheetTestIds . EXPLORER_BUTTON }
250+ iconName = { ComponentLibraryIconName . Export }
251+ iconColor = { ComponentLibraryIconColor . Default }
252+ size = { ButtonIconSizes . Lg }
253+ onPress = { handleOpenExplorer }
254+ accessibilityLabel = { strings (
255+ 'money.add_money_sheet.view_on_explorer' ,
256+ ) }
257+ />
258+ ) : null }
259+ </ View >
260+ </ >
261+ ) : (
262+ < View style = { styles . disabledRowContent } >
263+ < Text
264+ variant = { TextVariant . BodyMd }
265+ fontWeight = { FontWeight . Medium }
266+ color = { TextColor . TextAlternative }
267+ >
268+ { strings ( 'money.add_money_sheet.receive_external' ) }
269+ </ Text >
270+ < Tag
271+ label = { strings ( 'money.add_money_sheet.coming_soon' ) }
272+ style = { styles . comingSoonTag }
273+ />
274+ </ View >
275+ ) }
181276 </ View >
182277 </ View >
183278 </ BottomSheet >
0 commit comments