Skip to content

Commit

Permalink
feat(Solana): add "Add a new Solana account" link to the account crea…
Browse files Browse the repository at this point in the history
…tion dialog (#28270)

## **Description**

Adds a "Add a new Solana account" link to the account creation dialog:

## **Related issues**

Fixes:
[[SOL-24] [Setup] Add "Add a new Solana account (Beta)" button to the
account
picker](https://consensyssoftware.atlassian.net/browse/SOL-24?atlOrigin=eyJpIjoiYzhmNjk2NzVmZWM1NDFhNmI5NWZhMjc3YjkzM2I3OTIiLCJwIjoiaiJ9)

## **Manual testing steps**

1. Build and load the extension locally
2. Open the account picker
3. Click on "Add account or hardware wallet"
4. Click on "Add a new Solana wallet (Beta)"
5. A new Solana wallet should have been created, using the same seed
phrase used for Ethereum accounts

## **Screenshots/Recordings**

![Screenshot 2024-11-07 at 13 59
22](https://github.com/user-attachments/assets/15c51041-26ea-4ba4-b987-aed9ae57c277)


## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.


[SOL-24]:
https://consensyssoftware.atlassian.net/browse/SOL-24?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net>
Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com>
Co-authored-by: António Regadas <apregadas@gmail.com>
Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
  • Loading branch information
5 people authored Nov 8, 2024
1 parent 4ba7d89 commit d2ddf24
Show file tree
Hide file tree
Showing 21 changed files with 234 additions and 67 deletions.
3 changes: 3 additions & 0 deletions app/_locales/de/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/el/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/en_GB/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/es/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/fr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/hi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/id/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/ja/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/ko/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/pt/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/ru/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/tl/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/tr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/vi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/zh_CN/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/e2e/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ export const DEFAULT_BTC_ACCOUNT = 'bc1qg6whd6pc0cguh6gpp3ewujm53hv32ta9hdp252';

/* Default (mocked) BTC balance used by the Bitcoin RPC provider */
export const DEFAULT_BTC_BALANCE = 1; // BTC

/* Default (mocked) SOLANA address created using test SRP */
export const DEFAULT_SOLANA_ACCOUNT =
'E6Aa9DDv7zsePJHosoqiNb3cFuup3fkXTyRH2pZ1nVzP';

/* Default (mocked) SOLANA balance used by the Solana RPC provider */
export const DEFAULT_SOLANA_BALANCE = 1; // SOL
64 changes: 62 additions & 2 deletions ui/components/multichain/account-list-menu/account-list-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ import {
getOriginOfCurrentTab,
getSelectedInternalAccount,
getUpdatedAndSortedAccounts,
///: BEGIN:ONLY_INCLUDE_IF(solana)
getIsSolanaSupportEnabled,
///: END:ONLY_INCLUDE_IF
} from '../../../selectors';
import { setSelectedAccount } from '../../../store/actions';
import {
Expand Down Expand Up @@ -97,15 +100,27 @@ import {
hasCreatedBtcMainnetAccount,
hasCreatedBtcTestnetAccount,
} from '../../../selectors/accounts';
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(build-flask,solana)
import { MultichainNetworks } from '../../../../shared/constants/multichain/networks';
import { useBitcoinWalletSnapClient } from '../../../hooks/accounts/useBitcoinWalletSnapClient';
import {
WalletClientType,
useMultichainWalletSnapClient,
} from '../../../hooks/accounts/useMultichainWalletSnapClient';
///: END:ONLY_INCLUDE_IF
import {
InternalAccountWithBalance,
AccountConnections,
MergedInternalAccount,
} from '../../../selectors/selectors.types';
import { endTrace, TraceName } from '../../../../shared/lib/trace';
///: BEGIN:ONLY_INCLUDE_IF(solana)
import {
SOLANA_WALLET_NAME,
SOLANA_WALLET_SNAP_ID,
} from '../../../../shared/lib/accounts/solana-wallet-snap';
///: END:ONLY_INCLUDE_IF
import { HiddenAccountList } from './hidden-account-list';

const ACTION_MODES = {
Expand Down Expand Up @@ -269,7 +284,16 @@ export const AccountListMenu = ({
hasCreatedBtcTestnetAccount,
);

const bitcoinWalletSnapClient = useBitcoinWalletSnapClient();
const bitcoinWalletSnapClient = useMultichainWalletSnapClient(
WalletClientType.Bitcoin,
);
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(solana)
const solanaSupportEnabled = useSelector(getIsSolanaSupportEnabled);
const solanaWalletSnapClient = useMultichainWalletSnapClient(
WalletClientType.Solana,
);
///: END:ONLY_INCLUDE_IF

const [searchQuery, setSearchQuery] = useState('');
Expand Down Expand Up @@ -453,6 +477,42 @@ export const AccountListMenu = ({
) : null
///: END:ONLY_INCLUDE_IF
}
{
///: BEGIN:ONLY_INCLUDE_IF(solana)
solanaSupportEnabled && (
<Box marginTop={4}>
<ButtonLink
size={ButtonLinkSize.Sm}
startIconName={IconName.Add}
onClick={async () => {
trackEvent({
category: MetaMetricsEventCategory.Navigation,
event: MetaMetricsEventName.AccountAddSelected,
properties: {
account_type: MetaMetricsEventAccountType.Snap,
snap_id: SOLANA_WALLET_SNAP_ID,
snap_name: SOLANA_WALLET_NAME,
location: 'Main Menu',
},
});

// The account creation + renaming is handled by the
// Snap account bridge, so we need to close the current
// modal
onClose();

await solanaWalletSnapClient.createAccount(
MultichainNetworks.SOLANA,
);
}}
data-testid="multichain-account-menu-popover-add-solana-account"
>
{t('addNewSolanaAccount')}
</ButtonLink>
</Box>
)
///: END:ONLY_INCLUDE_IF
}
<Box marginTop={4}>
<ButtonLink
size={ButtonLinkSize.Sm}
Expand Down
57 changes: 0 additions & 57 deletions ui/hooks/accounts/useBitcoinWalletSnapClient.test.ts

This file was deleted.

Loading

0 comments on commit d2ddf24

Please sign in to comment.