diff --git a/app/component-library/components/BottomSheets/BottomSheet/BottomSheet.tsx b/app/component-library/components/BottomSheets/BottomSheet/BottomSheet.tsx index 1f70eb9e00a..ed26cfd5340 100644 --- a/app/component-library/components/BottomSheets/BottomSheet/BottomSheet.tsx +++ b/app/component-library/components/BottomSheets/BottomSheet/BottomSheet.tsx @@ -39,6 +39,7 @@ const BottomSheet = forwardRef( isInteractable = true, shouldNavigateBack = true, isFullscreen = false, + customMarginTop, ...props }, ref, @@ -105,6 +106,7 @@ const BottomSheet = forwardRef( isInteractable={isInteractable} onClose={onCloseCB} onOpen={onOpenCB} + customMarginTop={customMarginTop} ref={bottomSheetDialogRef} isFullscreen={isFullscreen} > diff --git a/app/component-library/components/BottomSheets/BottomSheet/README.md b/app/component-library/components/BottomSheets/BottomSheet/README.md index c858d5319b6..cd3f19b7748 100644 --- a/app/component-library/components/BottomSheets/BottomSheet/README.md +++ b/app/component-library/components/BottomSheets/BottomSheet/README.md @@ -22,6 +22,14 @@ Boolean that indicates if sheet is swippable. This affects whether or not tappin | :-------------------------------------------------- | :------------------------------------------------------ | :----------------------------------------------------- | | boolean | No | true | + +### `customMarginTop` + +Configure height of the modal by setting the distance between top of modal and top of screen. +| TYPE | REQUIRED | DEFAULT | +| :-------------------------------------------------- | :------------------------------------------------------ | :----------------------------------------------------- | +| number | No | 250 + ### `children` Content to wrap in sheet. diff --git a/app/component-library/components/BottomSheets/BottomSheet/foundation/BottomSheetDialog/BottomSheetDialog.tsx b/app/component-library/components/BottomSheets/BottomSheet/foundation/BottomSheetDialog/BottomSheetDialog.tsx index 126fadc098c..a5d1a69c510 100644 --- a/app/component-library/components/BottomSheets/BottomSheet/foundation/BottomSheetDialog/BottomSheetDialog.tsx +++ b/app/component-library/components/BottomSheets/BottomSheet/foundation/BottomSheetDialog/BottomSheetDialog.tsx @@ -60,6 +60,7 @@ const BottomSheetDialog = forwardRef< isInteractable = true, onClose, onOpen, + customMarginTop, ...props }, ref, @@ -68,9 +69,10 @@ const BottomSheetDialog = forwardRef< useSafeAreaInsets(); const { y: frameY } = useSafeAreaFrame(); const { height: screenHeight } = useWindowDimensions(); + const marginTop = customMarginTop ?? DEFAULT_BOTTOMSHEETDIALOG_MARGINTOP; const maxSheetHeight = isFullscreen ? screenHeight - screenTopPadding - : screenHeight - screenTopPadding - DEFAULT_BOTTOMSHEETDIALOG_MARGINTOP; + : screenHeight - screenTopPadding - marginTop; const { styles } = useStyles(styleSheet, { maxSheetHeight, screenBottomPadding, diff --git a/app/component-library/components/BottomSheets/BottomSheet/foundation/BottomSheetDialog/BottomSheetDialog.types.ts b/app/component-library/components/BottomSheets/BottomSheet/foundation/BottomSheetDialog/BottomSheetDialog.types.ts index da2ba4a6f35..244e00d0c0b 100644 --- a/app/component-library/components/BottomSheets/BottomSheet/foundation/BottomSheetDialog/BottomSheetDialog.types.ts +++ b/app/component-library/components/BottomSheets/BottomSheet/foundation/BottomSheetDialog/BottomSheetDialog.types.ts @@ -27,6 +27,10 @@ export interface BottomSheetDialogProps extends ViewProps { * Optional callback that gets triggered when sheet is opened. */ onOpen?: (hasPendingAction?: boolean) => void; + /** + * Customize the top margin of the sheet. + */ + customMarginTop?: number; } export interface BottomSheetDialogRef { diff --git a/app/component-library/components/Tags/TagUrl/TagUrl.styles.ts b/app/component-library/components/Tags/TagUrl/TagUrl.styles.ts index 41373df52b4..da586a0f21d 100644 --- a/app/component-library/components/Tags/TagUrl/TagUrl.styles.ts +++ b/app/component-library/components/Tags/TagUrl/TagUrl.styles.ts @@ -37,6 +37,8 @@ const styleSheet = (params: { theme: Theme; vars: TagUrlStyleSheetVars }) => { ) as ViewStyle, favicon: { marginRight: 8, + width: 24, + height: 24, }, label: { color: colors.text.alternative, diff --git a/app/component-library/components/Tags/TagUrl/__snapshots__/TagUrl.test.tsx.snap b/app/component-library/components/Tags/TagUrl/__snapshots__/TagUrl.test.tsx.snap index e70af7ccb3b..f734e43eb0b 100644 --- a/app/component-library/components/Tags/TagUrl/__snapshots__/TagUrl.test.tsx.snap +++ b/app/component-library/components/Tags/TagUrl/__snapshots__/TagUrl.test.tsx.snap @@ -26,7 +26,9 @@ exports[`TagUrl should render correctly 1`] = ` size="32" style={ Object { + "height": 24, "marginRight": 8, + "width": 24, } } variant="Favicon" diff --git a/app/components/Nav/App/index.js b/app/components/Nav/App/index.js index 5ff59ed9e1f..8a5e876e7ae 100644 --- a/app/components/Nav/App/index.js +++ b/app/components/Nav/App/index.js @@ -99,6 +99,8 @@ import AsyncStorage from '../../../store/async-storage-wrapper'; import ShowIpfsGatewaySheet from '../../Views/ShowIpfsGatewaySheet/ShowIpfsGatewaySheet'; import ShowDisplayNftMediaSheet from '../../Views/ShowDisplayMediaNFTSheet/ShowDisplayNFTMediaSheet'; import AmbiguousAddressSheet from '../../../../app/components/Views/Settings/Contacts/AmbiguousAddressSheet/AmbiguousAddressSheet'; +import SDKDisconnectModal from '../../../../app/components/Views/SDKDisconnectModal/SDKDisconnectModal'; +import SDKSessionModal from '../../../../app/components/Views/SDKSessionModal/SDKSessionModal'; import { MetaMetrics } from '../../../core/Analytics'; import trackErrorAsAnalytics from '../../../util/metrics/TrackError/trackErrorAsAnalytics'; @@ -552,6 +554,14 @@ const App = ({ userLoggedIn }) => { name={Routes.SHEET.SDK_FEEDBACK} component={SDKFeedbackModal} /> + + { ? AvatarAccountType.Blockies : AvatarAccountType.JazzIcon, ); + + const { id: channelId, origin: metadataOrigin } = hostInfo.metadata as { + id: string; + origin: string; + }; + + // Extract connection info from sdk + // FIXME should be replaced by passing dynamic parameters to the PermissionController + // TODO: Retrive wallet connect connection info from channelId + const sdkConnection = SDKConnect.getInstance().getConnection({ channelId }); + const hostname = ( + sdkConnection?.originatorInfo?.url ?? metadataOrigin + ).replace(AppConstants.MM_SDK.SDK_REMOTE_ORIGIN, ''); + const origin: string = useSelector(getActiveTabUrl, isEqual); const faviconSource = useFavicon(origin); - - const hostname = hostInfo.metadata.origin; const urlWithProtocol = prefixUrlWithProtocol(hostname); const secureIcon = useMemo( @@ -117,13 +131,25 @@ const AccountConnect = (props: AccountConnectProps) => { const cancelPermissionRequest = useCallback( (requestId) => { Engine.context.PermissionController.rejectPermissionsRequest(requestId); + if (channelId && accountsLength === 0) { + // Remove Potential SDK connection + SDKConnect.getInstance().removeChannel({ + channelId, + sendTerminate: true, + }); + } trackEvent(MetaMetricsEvents.CONNECT_REQUEST_CANCELLED, { number_of_accounts: accountsLength, source: 'permission system', }); }, - [Engine.context.PermissionController, accountsLength, trackEvent], + [ + Engine.context.PermissionController, + accountsLength, + channelId, + trackEvent, + ], ); const triggerDappVisitedEvent = useCallback( @@ -141,10 +167,11 @@ const AccountConnect = (props: AccountConnectProps) => { ...hostInfo, metadata: { ...hostInfo.metadata, - origin: hostname, + origin: metadataOrigin, }, approvedAccounts: selectedAccounts, }; + const connectedAccountLength = selectedAccounts.length; const activeAddress = selectedAccounts[0].address; const activeAccountName = getAccountNameWithENS({ @@ -199,11 +226,11 @@ const AccountConnect = (props: AccountConnectProps) => { hostInfo, accounts, ensByAccountAddress, - hostname, accountAvatarType, Engine.context.PermissionController, toastRef, accountsLength, + metadataOrigin, triggerDappVisitedEvent, trackEvent, ]); @@ -318,6 +345,7 @@ const AccountConnect = (props: AccountConnectProps) => { return ( { secureIcon, urlWithProtocol, setUserIntent, + sdkConnection, ]); const renderSingleConnectSelectorScreen = useCallback( @@ -376,6 +405,7 @@ const AccountConnect = (props: AccountConnectProps) => { urlWithProtocol={urlWithProtocol} onUserAction={setUserIntent} onBack={() => setScreen(AccountConnectScreens.SingleConnect)} + connection={sdkConnection} /> ), [ @@ -388,6 +418,7 @@ const AccountConnect = (props: AccountConnectProps) => { faviconSource, urlWithProtocol, secureIcon, + sdkConnection, ], ); @@ -408,7 +439,11 @@ const AccountConnect = (props: AccountConnectProps) => { ]); return ( - + {renderConnectScreens()} ); diff --git a/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.styles.ts b/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.styles.ts index 0e85d288de6..d7489654983 100644 --- a/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.styles.ts +++ b/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.styles.ts @@ -12,6 +12,9 @@ const styleSheet = (params: { theme: Theme }) => { const { colors } = params.theme; return StyleSheet.create({ + container: { + height: '100%', + }, body: { paddingHorizontal: 16, }, @@ -32,6 +35,20 @@ const styleSheet = (params: { theme: Theme }) => { selectAllButton: { marginBottom: 16, }, + sdkInfoContainer: { + flexDirection: 'column', + alignItems: 'center', + justifyContent: 'center', + gap: 10, + paddingHorizontal: 16, + marginBottom: -16, + }, + sdkInfoDivier: { + borderTopWidth: 1, + borderTopColor: colors.border.muted, + height: 1, + width: '100%', + }, disabled: { opacity: 0.5, }, diff --git a/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.tsx b/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.tsx index 1052912c313..f1f2fd88c9e 100644 --- a/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.tsx +++ b/app/components/Views/AccountConnect/AccountConnectMultiSelector/AccountConnectMultiSelector.tsx @@ -1,32 +1,34 @@ // Third party dependencies. import React, { useCallback, useState } from 'react'; -import { View, Platform } from 'react-native'; +import { Platform, View } from 'react-native'; // External dependencies. -import SheetHeader from '../../../../component-library/components/Sheet/SheetHeader'; import { strings } from '../../../../../locales/i18n'; -import TagUrl from '../../../../component-library/components/Tags/TagUrl'; -import Text from '../../../../component-library/components/Texts/Text'; -import { useStyles } from '../../../../component-library/hooks'; +import { ACCOUNT_APPROVAL_SELECT_ALL_BUTTON } from '../../../../../wdio/screen-objects/testIDs/Components/AccountApprovalModal.testIds'; +import generateTestId from '../../../../../wdio/utils/generateTestId'; import Button, { ButtonSize, ButtonVariants, ButtonWidthTypes, } from '../../../../component-library/components/Buttons/Button'; -import AccountSelectorList from '../../../UI/AccountSelectorList'; +import SheetHeader from '../../../../component-library/components/Sheet/SheetHeader'; +import TagUrl from '../../../../component-library/components/Tags/TagUrl'; +import Text, { + TextColor, +} from '../../../../component-library/components/Texts/Text'; +import { useStyles } from '../../../../component-library/hooks'; import { USER_INTENT } from '../../../../constants/permissions'; -import generateTestId from '../../../../../wdio/utils/generateTestId'; -import { ACCOUNT_APPROVAL_SELECT_ALL_BUTTON } from '../../../../../wdio/screen-objects/testIDs/Components/AccountApprovalModal.testIds'; +import AccountSelectorList from '../../../UI/AccountSelectorList'; // Internal dependencies. +import { ConnectAccountModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/ConnectAccountModal.selectors'; +import { ACCOUNT_LIST_ADD_BUTTON_ID } from '../../../../../wdio/screen-objects/testIDs/Components/AccountListComponent.testIds'; +import AddAccountActions from '../../AddAccountActions'; import styleSheet from './AccountConnectMultiSelector.styles'; import { AccountConnectMultiSelectorProps, AccountConnectMultiSelectorScreens, } from './AccountConnectMultiSelector.types'; -import AddAccountActions from '../../AddAccountActions'; -import { ACCOUNT_LIST_ADD_BUTTON_ID } from '../../../../../wdio/screen-objects/testIDs/Components/AccountListComponent.testIds'; -import { ConnectAccountModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/ConnectAccountModal.selectors'; const AccountConnectMultiSelector = ({ accounts, @@ -39,6 +41,7 @@ const AccountConnectMultiSelector = ({ secureIcon, isAutoScrollEnabled = true, urlWithProtocol, + connection, onBack, }: AccountConnectMultiSelectorProps) => { const { styles } = useStyles(styleSheet, {}); @@ -147,7 +150,7 @@ const AccountConnectMultiSelector = ({ const renderAccountConnectMultiSelector = useCallback( () => ( - <> + + {connection?.originatorInfo?.apiVersion && ( + + + + SDK {connection?.originatorInfo?.platform} v + {connection?.originatorInfo?.apiVersion} + + + )}