Skip to content

Commit d05765a

Browse files
zone-liveaganglada
andauthored
chore: adds solana banner to carousel (#32000)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR adds the solana banner/slide to the existing carousel, to the 1st position. For users that don't have a solana account, it will invite you to create one when clicked. For Users that already have a solana account it will just focus on it. ![Screenshot 2025-04-15 at 15 11 09](https://github.com/user-attachments/assets/bc251df0-e3f3-440e-8a70-367395b9cadb) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: Alejandro Garcia Anglada <[email protected]>
1 parent 55848e6 commit d05765a

File tree

9 files changed

+126
-4
lines changed

9 files changed

+126
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Changes in account modal to switch to smart account type ([#31899](https://github.com/MetaMask/metamask-extension/pull/31899))
1010
- Support for Solana Devnet ([#31702](https://github.com/MetaMask/metamask-extension/pull/31702))
1111
- [Beta] Create Solana account automatically on wallet creation or SRP import [#32038](https://github.com/MetaMask/metamask-extension/pull/32038)
12+
- Adds the Solana banner/slide to the existing home carousel ([#32000](https://github.com/MetaMask/metamask-extension/pull/32000))
1213
- Support for Solana on Firefox ([#32104](https://github.com/MetaMask/metamask-extension/pull/32104))
1314
- Update CAIP-294 wallet announcement event to include `targets` property and new `caip-348` target object ([#32070](https://github.com/MetaMask/metamask-extension/pull/32070))
1415
- Replace `caip-x` with `caip-348` in Multichain API over externally_connectable ([#32070](https://github.com/MetaMask/metamask-extension/pull/32070))

app/_locales/en/messages.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/en_GB/messages.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/images/slide-solana-icon.svg

+11
Loading

ui/components/multichain/account-overview/account-overview-layout.tsx

+45-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ import { useDispatch, useSelector } from 'react-redux';
33
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
44
import { isEqual } from 'lodash';
55
///: END:ONLY_INCLUDE_IF
6-
import { removeSlide } from '../../../store/actions';
6+
import {
7+
removeSlide,
8+
///: BEGIN:ONLY_INCLUDE_IF(solana)
9+
setSelectedAccount,
10+
///: END:ONLY_INCLUDE_IF
11+
} from '../../../store/actions';
712
import { Carousel } from '..';
813
import {
914
getAppIsLoading,
1015
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
1116
getSwapsDefaultToken,
1217
///: END:ONLY_INCLUDE_IF
18+
///: BEGIN:ONLY_INCLUDE_IF(solana)
19+
hasCreatedSolanaAccount,
20+
///: END:ONLY_INCLUDE_IF
1321
} from '../../../selectors';
1422
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
1523
import useBridging from '../../../hooks/bridge/useBridging';
@@ -20,7 +28,16 @@ import {
2028
MetaMetricsEventCategory,
2129
} from '../../../../shared/constants/metametrics';
2230
import type { CarouselSlide } from '../../../../shared/constants/app-state';
23-
import { useCarouselManagement } from '../../../hooks/useCarouselManagement';
31+
import {
32+
useCarouselManagement,
33+
///: BEGIN:ONLY_INCLUDE_IF(solana)
34+
SOLANA_SLIDE,
35+
///: END:ONLY_INCLUDE_IF
36+
} from '../../../hooks/useCarouselManagement';
37+
///: BEGIN:ONLY_INCLUDE_IF(solana)
38+
import { CreateSolanaAccountModal } from '../create-solana-account-modal';
39+
import { getLastSelectedSolanaAccount } from '../../../selectors/multichain';
40+
///: END:ONLY_INCLUDE_IF
2441
import {
2542
AccountOverviewTabsProps,
2643
AccountOverviewTabs,
@@ -39,6 +56,13 @@ export const AccountOverviewLayout = ({
3956
const trackEvent = useContext(MetaMetricsContext);
4057
const [hasRendered, setHasRendered] = useState(false);
4158

59+
///: BEGIN:ONLY_INCLUDE_IF(solana)
60+
const [showCreateSolanaAccountModal, setShowCreateSolanaAccountModal] =
61+
useState(false);
62+
const hasSolanaAccount = useSelector(hasCreatedSolanaAccount);
63+
const selectedSolanaAccount = useSelector(getLastSelectedSolanaAccount);
64+
///: END:ONLY_INCLUDE_IF
65+
4266
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
4367
const defaultSwapsToken = useSelector(getSwapsDefaultToken, isEqual);
4468
///: END:ONLY_INCLUDE_IF
@@ -60,6 +84,16 @@ export const AccountOverviewLayout = ({
6084
}
6185
///: END:ONLY_INCLUDE_IF
6286

87+
///: BEGIN:ONLY_INCLUDE_IF(solana)
88+
if (id === SOLANA_SLIDE.id) {
89+
if (hasSolanaAccount && selectedSolanaAccount) {
90+
dispatch(setSelectedAccount(selectedSolanaAccount.address));
91+
} else {
92+
setShowCreateSolanaAccountModal(true);
93+
}
94+
}
95+
///: END:ONLY_INCLUDE_IF
96+
6397
trackEvent({
6498
event: MetaMetricsEventName.BannerSelect,
6599
category: MetaMetricsEventCategory.Banner,
@@ -108,6 +142,15 @@ export const AccountOverviewLayout = ({
108142
onRenderSlides={handleRenderSlides}
109143
/>
110144
<AccountOverviewTabs {...tabsProps}></AccountOverviewTabs>
145+
{
146+
///: BEGIN:ONLY_INCLUDE_IF(solana)
147+
showCreateSolanaAccountModal && (
148+
<CreateSolanaAccountModal
149+
onClose={() => setShowCreateSolanaAccountModal(false)}
150+
/>
151+
)
152+
///: END:ONLY_INCLUDE_IF
153+
}
111154
</>
112155
);
113156
};

ui/components/multichain/carousel/carousel.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import {
1515
MetaMetricsEventName,
1616
} from '../../../../shared/constants/metametrics';
1717
import { MetaMetricsContext } from '../../../contexts/metametrics';
18-
import { getSweepstakesCampaignActive } from '../../../hooks/useCarouselManagement';
18+
import {
19+
getSweepstakesCampaignActive,
20+
///: BEGIN:ONLY_INCLUDE_IF(solana)
21+
SOLANA_SLIDE,
22+
///: END:ONLY_INCLUDE_IF
23+
} from '../../../hooks/useCarouselManagement';
1924
import type { CarouselProps } from './carousel.types';
2025
import { BANNER_STYLES, MAX_SLIDES } from './constants';
2126
import {
@@ -43,6 +48,16 @@ export const Carousel = React.forwardRef(
4348
const visibleSlides = slides
4449
.filter((slide) => !slide.dismissed || slide.undismissable)
4550
.sort((a, b) => {
51+
///: BEGIN:ONLY_INCLUDE_IF(solana)
52+
// prioritize Solana slide
53+
if (a.id === SOLANA_SLIDE.id) {
54+
return -1;
55+
}
56+
if (b.id === SOLANA_SLIDE.id) {
57+
return 1;
58+
}
59+
///: END:ONLY_INCLUDE_IF
60+
4661
const isSweepstakesActive = getSweepstakesCampaignActive(
4762
new Date(new Date().toISOString()),
4863
);

ui/hooks/useCarouselManagement/constants.ts

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ export const REMOTE_MODE_SLIDE = {
77
href: '/home.html#remote',
88
};
99

10+
///: BEGIN:ONLY_INCLUDE_IF(solana)
11+
export const SOLANA_SLIDE = {
12+
id: 'solana',
13+
title: 'slideSolanaTitle',
14+
description: 'slideSolanaDescription',
15+
image: './images/slide-solana-icon.svg',
16+
};
17+
///: END:ONLY_INCLUDE_IF
18+
1019
export const SWEEPSTAKES_SLIDE = {
1120
id: 'sweepStake',
1221
title: 'slideSweepStakeTitle',

ui/hooks/useCarouselManagement/useCarouselManagement.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
ZERO_BALANCE,
2020
REMOTE_MODE_SLIDE,
2121
MULTI_SRP_SLIDE,
22+
SOLANA_SLIDE,
2223
} from './constants';
2324

2425
const SLIDES_ZERO_FUNDS_REMOTE_OFF_SWEEPSTAKES_OFF = [
@@ -29,6 +30,9 @@ const SLIDES_ZERO_FUNDS_REMOTE_OFF_SWEEPSTAKES_OFF = [
2930
CARD_SLIDE,
3031
CASH_SLIDE,
3132
MULTI_SRP_SLIDE,
33+
///: BEGIN:ONLY_INCLUDE_IF(solana)
34+
SOLANA_SLIDE,
35+
///: END:ONLY_INCLUDE_IF
3236
];
3337

3438
const SLIDES_POSITIVE_FUNDS_REMOTE_OFF_SWEEPSTAKES_OFF = [
@@ -39,6 +43,9 @@ const SLIDES_POSITIVE_FUNDS_REMOTE_OFF_SWEEPSTAKES_OFF = [
3943
{ ...FUND_SLIDE, undismissable: false },
4044
CASH_SLIDE,
4145
MULTI_SRP_SLIDE,
46+
///: BEGIN:ONLY_INCLUDE_IF(solana)
47+
SOLANA_SLIDE,
48+
///: END:ONLY_INCLUDE_IF
4249
];
4350

4451
const SLIDES_ZERO_FUNDS_REMOTE_ON_SWEEPSTAKES_OFF = [
@@ -50,6 +57,9 @@ const SLIDES_ZERO_FUNDS_REMOTE_ON_SWEEPSTAKES_OFF = [
5057
CARD_SLIDE,
5158
CASH_SLIDE,
5259
MULTI_SRP_SLIDE,
60+
///: BEGIN:ONLY_INCLUDE_IF(solana)
61+
SOLANA_SLIDE,
62+
///: END:ONLY_INCLUDE_IF
5363
];
5464

5565
const SLIDES_POSITIVE_FUNDS_REMOTE_ON_SWEEPSTAKES_OFF = [
@@ -61,6 +71,9 @@ const SLIDES_POSITIVE_FUNDS_REMOTE_ON_SWEEPSTAKES_OFF = [
6171
{ ...FUND_SLIDE, undismissable: false },
6272
CASH_SLIDE,
6373
MULTI_SRP_SLIDE,
74+
///: BEGIN:ONLY_INCLUDE_IF(solana)
75+
SOLANA_SLIDE,
76+
///: END:ONLY_INCLUDE_IF
6477
];
6578

6679
const SLIDES_ZERO_FUNDS_REMOTE_OFF_SWEEPSTAKES_ON = [
@@ -72,6 +85,9 @@ const SLIDES_ZERO_FUNDS_REMOTE_OFF_SWEEPSTAKES_ON = [
7285
CARD_SLIDE,
7386
CASH_SLIDE,
7487
MULTI_SRP_SLIDE,
88+
///: BEGIN:ONLY_INCLUDE_IF(solana)
89+
SOLANA_SLIDE,
90+
///: END:ONLY_INCLUDE_IF
7591
];
7692

7793
const SLIDES_POSITIVE_FUNDS_REMOTE_OFF_SWEEPSTAKES_ON = [
@@ -83,6 +99,9 @@ const SLIDES_POSITIVE_FUNDS_REMOTE_OFF_SWEEPSTAKES_ON = [
8399
{ ...FUND_SLIDE, undismissable: false },
84100
CASH_SLIDE,
85101
MULTI_SRP_SLIDE,
102+
///: BEGIN:ONLY_INCLUDE_IF(solana)
103+
SOLANA_SLIDE,
104+
///: END:ONLY_INCLUDE_IF
86105
];
87106

88107
const SLIDES_ZERO_FUNDS_REMOTE_ON_SWEEPSTAKES_ON = [
@@ -95,6 +114,9 @@ const SLIDES_ZERO_FUNDS_REMOTE_ON_SWEEPSTAKES_ON = [
95114
CARD_SLIDE,
96115
CASH_SLIDE,
97116
MULTI_SRP_SLIDE,
117+
///: BEGIN:ONLY_INCLUDE_IF(solana)
118+
SOLANA_SLIDE,
119+
///: END:ONLY_INCLUDE_IF
98120
];
99121

100122
const SLIDES_POSITIVE_FUNDS_REMOTE_ON_SWEEPSTAKES_ON = [
@@ -107,6 +129,9 @@ const SLIDES_POSITIVE_FUNDS_REMOTE_ON_SWEEPSTAKES_ON = [
107129
{ ...FUND_SLIDE, undismissable: false },
108130
CASH_SLIDE,
109131
MULTI_SRP_SLIDE,
132+
///: BEGIN:ONLY_INCLUDE_IF(solana)
133+
SOLANA_SLIDE,
134+
///: END:ONLY_INCLUDE_IF
110135
];
111136

112137
jest.mock('react-redux', () => ({

ui/hooks/useCarouselManagement/useCarouselManagement.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ import {
1212
CARD_SLIDE,
1313
CASH_SLIDE,
1414
REMOTE_MODE_SLIDE,
15-
SWEEPSTAKES_SLIDE,
1615
SWEEPSTAKES_START,
1716
SWEEPSTAKES_END,
1817
ZERO_BALANCE,
1918
MULTI_SRP_SLIDE,
19+
SWEEPSTAKES_SLIDE,
20+
///: BEGIN:ONLY_INCLUDE_IF(solana)
21+
SOLANA_SLIDE,
22+
///: END:ONLY_INCLUDE_IF
2023
} from './constants';
2124

2225
type UseSlideManagementProps = {
@@ -57,6 +60,9 @@ export const useCarouselManagement = ({
5760
defaultSlides.push(CARD_SLIDE);
5861
defaultSlides.push(CASH_SLIDE);
5962
defaultSlides.push(MULTI_SRP_SLIDE);
63+
///: BEGIN:ONLY_INCLUDE_IF(solana)
64+
defaultSlides.push(SOLANA_SLIDE);
65+
///: END:ONLY_INCLUDE_IF
6066

6167
defaultSlides.splice(hasZeroBalance ? 0 : 2, 0, fundSlide);
6268

0 commit comments

Comments
 (0)