feat: Add legacy wallet adapter for SIWS support #8
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.
PR: Add Legacy Wallet Adapter for SIWS Support
Summary
Adds automatic patching for Solana wallets that support
signMessagebut lack native SIWSsignIn, enabling legacy wallets like Glow to authenticate without requiring wallet developer updates.Problem
There exist popular Solana wallets that only implement
signMessageand lack the newersignInmethod required for Sign-In With Solana (SIWS), preventing users from authenticating with IC applications.Solution
Lightweight adapter pattern that wraps legacy wallets and synthesizes a
signInmethod using their existingsignMessagefunctionality. The patching is automatic, transparent, and never overwrites native implementations.Minimal:
Safe:
Non-Breaking:
Core Changes
1. New File:
src/siws-legacy-adapter.tsSingle-purpose utility that:
signInsupportsignMessage→ returns result insignInformat2. Modified:
src/index.ts(SiwsManager)3. Modified:
src/react/index.tsxnetwork?: stringprop toSiwsIdentityProviderand passed it through toSiwsManager.4. Modified:
src/delegation.ts- ~3 lines@ts-ignorecomments for dfinity v2.4.1 ArrayBuffer type strictness issues. Unrelated to SIWS functionality but necessary for builds to succeed.Demo Updates
The demo's provider needed proper state management to handle wallet connection lifecycle:
Before:
Issues:
After:
Improvements:
undefinedadapter) → no context errorsTesting
Verified Wallets:
signInsupport, no patching needed. Console:"Phantom already has native signIn; leaving as-is"signInsupport, no patching needed."Patching Solflare to add SIWS signIn support (network: devnet)"