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:
@@ -38,6 +38,10 @@ export function App() {
|
||||
void browser.runtime.sendMessage({ type: 'nexa:sign-out' } satisfies NexaMessage);
|
||||
}
|
||||
|
||||
function switchAccount(): void {
|
||||
void browser.runtime.sendMessage({ type: 'nexa:switch-account' } satisfies NexaMessage);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<header>
|
||||
@@ -64,9 +68,14 @@ export function App() {
|
||||
</section>
|
||||
|
||||
{connectionStatus === 'connected' && (
|
||||
<button type="button" className="sign-out-button" onClick={signOut}>
|
||||
Sign out
|
||||
</button>
|
||||
<div className="account-actions">
|
||||
<button type="button" className="sign-out-button" onClick={switchAccount}>
|
||||
Switch account
|
||||
</button>
|
||||
<button type="button" className="sign-out-button" onClick={signOut}>
|
||||
Sign out
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<a
|
||||
|
||||
Reference in New Issue
Block a user