feat: add Stellar Freighter wallet connection (#386)#410
Open
OpadijoIdris wants to merge 1 commit into
Open
Conversation
Implement Freighter wallet integration so users can connect, view their
address, and disconnect without leaving the app. All error paths are
handled gracefully with user-friendly messages.
Core additions:
- src/context/WalletContext.tsx: React Context provider wrapping
@stellar/freighter-api. Handles isConnected(), requestAccess(), and
getAddress() calls. Persists connected address in sessionStorage and
restores it on mount. Exposes connect(), disconnect(), and
shortenAddress() via useWallet() hook.
- src/components/wallet/WalletButton.tsx: Navbar button with two states:
- Disconnected: "Connect Wallet" button with loading spinner.
- Connected: shortened address (GABC...XYZ1) with dropdown showing
full address, copy-to-clipboard, Stellar Explorer link, and
Disconnect option.
Error popup auto-dismisses after 6 s; links to freighter.app when
extension is absent.
Wiring:
- src/main.tsx: WalletProvider added inside ThemeProvider/ToastProvider.
- src/components/layout/Navbar.tsx: WalletButton placed between
ThemeToggle and NotificationCentreDropdown.
Error scenarios handled:
- Freighter extension not installed
- User rejects the connection request
- Unexpected network/runtime errors
Tests (18 tests, all passing):
- src/context/__tests__/WalletContext.test.tsx — hook unit tests
- src/components/wallet/__tests__/WalletButton.test.tsx — component tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@OpadijoIdris is attempting to deploy a commit to the sheriffamina1-9497's projects Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
@OpadijoIdris , failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement Freighter wallet integration so users can connect, view their
address, and disconnect without leaving the app. All error paths are
handled gracefully with user-friendly messages.
Core additions
src/context/WalletContext.tsx— React Context provider wrapping@stellar/freighter-api. HandlesisConnected(),requestAccess(), andgetAddress()calls. Persists connected address insessionStorageandrestores it on mount. Exposes
connect(),disconnect(), andshortenAddress()viauseWallet()hook.src/components/wallet/WalletButton.tsx— Navbar button with two states:GABC...XYZ1) with dropdown showingfull address, copy-to-clipboard, Stellar Explorer link, and Disconnect
option. Error popup auto-dismisses after 6 s; links to freighter.app
when extension is absent.
Wiring
src/main.tsx— WalletProvider added inside ThemeProvider/ToastProvider.src/components/layout/Navbar.tsx— WalletButton placed betweenThemeToggle and NotificationCentreDropdown.
Error scenarios handled
Tests (18 tests, all passing)
src/context/__tests__/WalletContext.test.tsx— hook unit testssrc/components/wallet/__tests__/WalletButton.test.tsx— component testsTest plan
Closes #386