Fix duplicate signing; make account switching an explicit action
Root cause of "requires a lot of signs, not just a single one": inject.ts wired Phantom's own accountChanged provider event to auto-trigger re-auth, but calling connect() ourselves also fires that same event -- so a normal silent reconnect raced its own event-triggered handler, producing two competing "wallet connected" reports that each independently asked Phantom to sign a fresh nonce. Removed that event wiring entirely (onWalletEvent, EVENT_CHANNEL) -- inject.ts now only responds to our own explicit calls, never reacts to unsolicited provider events. Per feedback, account switching isn't something that should be inferred from a Phantom event anyway; it's now its own explicit feature: a "Switch account" button in the popup (nexa:switch-account) that tells the content script to disconnect and immediately reconnect, so Phantom's connect UI reflects whichever account is currently active there. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YXiHuScXrjxBh7yFGAPq3B
This commit is contained in:
@@ -25,8 +25,10 @@ export type NexaMessage =
|
||||
| { type: 'nexa:wallet-sign-request'; nonce: string }
|
||||
| { type: 'nexa:request-wallet-connect' }
|
||||
| { type: 'nexa:wallet-disconnect-request' }
|
||||
// Sign-out (popup -> background). See entrypoints/popup/App.tsx.
|
||||
| { type: 'nexa:sign-out' };
|
||||
| { type: 'nexa:switch-account-request' }
|
||||
// Sign-out / switch account (popup -> background). See entrypoints/popup/App.tsx.
|
||||
| { type: 'nexa:sign-out' }
|
||||
| { type: 'nexa:switch-account' };
|
||||
|
||||
/** Response shape for 'nexa:wallet-sign-request', returned via sendResponse (not a dispatched NexaMessage). */
|
||||
export type WalletSignResult = { signature: string } | { error: string };
|
||||
|
||||
Reference in New Issue
Block a user