Skip to content

Add wallet auth button for account linking in ewk demo#1208

Open
radusandor wants to merge 1 commit intomainfrom
radu/wallets-example-wallet-auth-account-linking
Open

Add wallet auth button for account linking in ewk demo#1208
radusandor wants to merge 1 commit intomainfrom
radu/wallets-example-wallet-auth-account-linking

Conversation

@radusandor
Copy link
Contributor

Summary & Motivation

This PR adds a WalletAuthButton component to the react-wallet-kit example, allowing users to link an external wallet (e.g. MetaMask, Phantom) as a backup authentication method to their existing account.

Changes:

Added WalletAuthButton.tsx in src/components/demo/AuthButtons/ following the same pattern as existing auth buttons
Added WalletSVG to src/components/Svg.tsx
Updated UserSettings.tsx to render WalletAuthButton when walletAuthEnabled is set in the config

How it works:

When a user clicks "+ Connect" on the Wallet button, it prompts their browser wallet to sign a request
The wallet's public key is stored as an API key in the user's sub-org under the label wallet-auth-{publicKey}
The user can then log in with that wallet as a backup authenticator
Unlinking removes the API key from the sub-org

How I Tested These Changes

Tested locally with Phantom (Solana) and MetaMask (EVM)
Verified wallet linking and unlinking with UI state refreshing correctly after each action
Verified that after linking, logging out and back in with the wallet routes to the correct sub-org

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 26fe5d9:

Sandbox Source
@turnkey/example-react-components Configuration


const providers = await fetchWalletProviders();
console.log(providers);
const selectedProvider = providers?.[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm - I’m not sure we can do this

right now, the user doesn’t get to choose which external wallet to use. We just automatically select the first one 😢

Ideally, we should present UI that allows the user to:

  • choose which external wallet they want to use
  • choose the chain (Solana vs Ethereum)

that said, we already have all of this UI logic built in @turnkey/react-wallet-kit for handleLogin(). Given that, I think the right better solution would be to introduce something like handleAddWallet() that reuses those UI components 🤔

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.

2 participants