Skip to content

Conversation

@wenfix
Copy link
Contributor

@wenfix wenfix commented Jan 20, 2026

Explanation

Introduces @metamask/connect-solana, a new package that wraps @metamask/solana-wallet-standard with MetaMask Connect, enabling Solana dapps to use MetaMask via the wallet-standard protocol. It also adds playground support for solana-wallet-standard which enables testing this feature.

Testing Steps

  1. Install dependencies and build (yarn install && yarn build)
  2. Launch browser playground (yarn workspace @metamask/browser-playground start)
  3. Click Connect (Solana) button (ensure no extension is installed if using desktop browser)
  4. IMPORTANT: Make sure Solana Devnet is permitted when accepting
  5. Confirm connection -> Solana Card should appear in dapp
  6. Try interactions available interactions such as sign, which should succeed.

References

Fixes WAPI-751

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@socket-security
Copy link

socket-security bot commented Jan 20, 2026

@socket-security
Copy link

socket-security bot commented Jan 20, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

View full report

@wenfix wenfix marked this pull request as ready for review January 20, 2026 15:10
@wenfix wenfix requested a review from a team as a code owner January 20, 2026 15:10
@wenfix
Copy link
Contributor Author

wenfix commented Jan 20, 2026

@SocketSecurity ignore npm/@solana/[email protected]
@SocketSecurity ignore npm/@solana/[email protected]
@SocketSecurity ignore npm/@solana/[email protected]
@SocketSecurity ignore npm/@solana/[email protected]

solana-devs is a known publisher of Solana related libraries.

};
/** Optional API configuration */
api?: {
/** A map of CAIP chain IDs to RPC URLs for supported networks */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be Solana Genesis Hash to RPC URLs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 also not following this one haha

const connectSolana = useCallback(async () => {
// Find the MetaMask wallet in registered wallets
const metamaskWallet = wallets.find((w) =>
w.adapter.name.toLowerCase().includes('metamask')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a chance this will perfer the extension announced event instead of the ConnectSolana one?

@adonesky1
Copy link
Contributor

Running into a build issue on the browser playground:

Screenshot 2026-01-28 at 2 27 09 PM

@wenfix
Copy link
Contributor Author

wenfix commented Jan 29, 2026

Running into a build issue on the browser playground:

Screenshot 2026-01-28 at 2 27 09 PM

Adding Solana introduced [email protected] (ESM) alongside [email protected] (CJS), causing webpack bundling failures due to ESM/CJS interoperability issues with the base-x dependency.

Solution:

Force all packages to use [email protected] via yarn resolution.

This is safe because the bs58 API is identical across versions:

interface BS58 {  
  encode(source: Buffer | Uint8Array): string;  
  decode(string: string): Buffer;  // v4 returns Buffer  
  decodeUnsafe(string: string): Buffer | undefined;
}

The only difference is decode() return type:
v4/v5: Returns Buffer
v6: Returns Uint8Array

Since Buffer extends Uint8Array, code expecting Uint8Array works transparently with Buffer. All consumer packages (@metamask/solana-wallet-standard, @solana/web3.js, @walletconnect/utils, etc.) are compatible.

@adonesky1
Copy link
Contributor

I'm not seeing the sign **and** send flow working:

Each time I click it (even after repeated attempts) I get prompted to connect again (I think this has to do with devnet permissions not getting granted initially...? though I don't know why the connection request happens again and again then) but as you can see I don't ever get the subsequent signature request to show:

Screen.Recording.2026-01-29.at.2.08.38.PM.mov

@wenfix
Copy link
Contributor Author

wenfix commented Feb 2, 2026

I'm not seeing the sign **and** send flow working:

Each time I click it (even after repeated attempts) I get prompted to connect again (I think this has to do with devnet permissions not getting granted initially...? though I don't know why the connection request happens again and again then) but as you can see I don't ever get the subsequent signature request to show:

Screen.Recording.2026-01-29.at.2.08.38.PM.mov

Yes, I've confirmed its due to the connection request not including the Solana Devnet scope. If you manually include it, you should see the tx confirmation pop-up. Let's discuss some of this during our standup today.

@adonesky1 adonesky1 force-pushed the feat/connect-solana branch from f26522e to 9e944ae Compare February 3, 2026 20:41
adonesky1
adonesky1 previously approved these changes Feb 3, 2026
Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@adonesky1 adonesky1 force-pushed the feat/connect-solana branch from ea1a85e to 1e5a26b Compare February 3, 2026 20:58
Comment on lines 210 to 250
@@ -218,18 +227,12 @@ export class DefaultTransport implements ExtendedTransport {
walletSession,
proposedCaipAccountIds,
);

if (!hasSameScopesAndAccounts) {
await this.request(
{ method: 'wallet_revokeSession', params: walletSession },
this.#defaultRequestOptions,
);
const optionalScopes = addValidAccounts(
getOptionalScopes(options?.scopes ?? []),
getValidAccounts(options?.caipAccountIds ?? []),
);
const createSessionParams: CreateSessionParams<RPCAPI> = {
optionalScopes,
};
const response = await this.request(
{ method: 'wallet_createSession', params: createSessionParams },
this.#defaultRequestOptions,
@@ -240,14 +243,6 @@ export class DefaultTransport implements ExtendedTransport {
walletSession = response.result as SessionData;
}
} else if (!walletSession || options?.forceRequest) {
const optionalScopes = addValidAccounts(
getOptionalScopes(options?.scopes ?? []),
getValidAccounts(options?.caipAccountIds ?? []),
);
const createSessionParams: CreateSessionParams<RPCAPI> = {
optionalScopes,
sessionProperties: options?.sessionProperties,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we weren't passing along sessionProperties in certain cases -> theoretically this could be its own PR but was causing an issue where Solana connection wasn't leading to additional network permissions being added as is expected (and currently happens in the injected script version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants