feat(browser-playground): migrate Solana connection#240
Conversation
…et-adapter-react to @solana/react-hooks
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
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:
|
|
@SocketSecurity ignore-all All flagged dependencies are necessary as part of this migration. |
| "@metamask/utils": "^11.8.1", | ||
| "@open-rpc/meta-schema": "^1.14.9", | ||
| "@open-rpc/schema-utils-js": "^2.0.5", | ||
| "@solana/wallet-adapter-react": "patch:@solana/wallet-adapter-react@npm%3A0.15.39#~/.yarn/patches/@solana-wallet-adapter-react-npm-0.15.39-86277fdcc0.patch", |
There was a problem hiding this comment.
I tried testing if the bug that this patch fixed exists in the new libraries or not, but got blocked on Initializing Solana not going away for MWP. Still need to verify this.
.yarn/patches/@solana-wallet-adapter-react-npm-0.15.39-86277fdcc0.patch should be deleted though
|
We've gotten mixed signals from the Solana Foundation about the direction we should take this so we're gonna wait until a clear signal. |
Explanation
The Solana Foundation is actively moving dapp connection infrastructure to
@solana/react-hooks(part of framework-kit), built on web3.js v2. Most major Solana apps are converging on this library. The playground should reflect the recommended integration path so we validate the MetaMask Connect Solana integration against what consumers will actually use.@solana/wallet-adapter-reactand@solana/wallet-adapter-react-uiwith@solana/react-hooks+@solana/kit(web3.js v2) in the browser playgroundSolanaProvider.tsxto use<SolanaProvider>from framework-kit, eliminating the manualConnectionProvider/WalletProvider/WalletModalProviderstack and built-inautoConnectwiringSolanaWalletCard.tsxfrom wallet-adapter hook shapes to framework-kit hooks (useWalletSession,useDisconnectWallet,useSolanaClient) and replaces all@solana/web3.jsv1 transaction primitives with@solana/kitv2 equivalents (createTransactionMessage,pipe,compileTransaction,createNoopSigner,getTransferSolInstruction)App.tsxto useuseWalletConnection().connect(connectorId)instead ofwallets.find(...) + select(name), and wiresuseDisconnectWalletinto the "Disconnect All" buttonDependency Changes
@solana/wallet-adapter-react(patched 0.15.39)@solana/react-hooks@^1.4.1@solana/wallet-adapter-react-ui@^0.9.35@solana/kit@^6.5.0@solana/wallet-standard-chains@^1.1.1@solana-program/system@^0.12.0@solana/web3.jsis retained — it is still used bysolana-method-signatures.ts(out of scope).Key API Differences
ConnectionProvider+WalletProvider+WalletModalProvider<SolanaProvider config={{ endpoint }}>useWallet()→ flat fieldsuseWalletSession()→ session object orundefinedpublicKey.toBase58()(v1PublicKey)session.account.address(brandedstring)wallets.find(...) + select(name)useWalletConnection().connect(connectorId)disconnect()fromuseWallet()useDisconnectWallet()useConnection()→Connection(v1)useSolanaClient().runtime.rpc(v2)signMessage(bytes)fromuseWallet()session.signMessage(bytes)signTransaction(v1Tx)session.signTransaction(compiledTx)sendTransaction(v1Tx, connection)session.sendTransaction(compiledTx)WalletMultiButtonuseWalletConnection().connectorsReferences
Fixes WAPI-1303
Recording
solana-kit-migration.mov
Checklist