Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/legacy/legacy-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1982,19 +1982,29 @@ async function main(): Promise<void> {
}

if (switchToProfile(profileName)) {
console.log(`✓ Switched to wallet profile: ${profileName}`);
// Issue sphere-sdk#282 Residual #2 — confirmation output
// goes to STDERR so that pipelines capturing the NEXT
// command's stdout (e.g. `sphere wallet use alice &&
// sphere balance > file`) don't accidentally include the
// wallet-use banner in the captured snapshot. Without
// this, the same logical command sequence produces
// different captured-stdout content depending on whether
// the harness redirects the `wallet use` invocation
// separately or groups it in a subshell — see the
// peer1-vs-peer2 asymmetry in `manual-test-full-recovery.sh`.
console.error(`✓ Switched to wallet profile: ${profileName}`);

// Show wallet status
try {
const sphere = await getSphere();
const identity = sphere.identity;
if (identity) {
console.log(` Nametag: ${identity.nametag || '(not set)'}`);
console.log(` L1 Addr: ${identity.l1Address}`);
console.error(` Nametag: ${identity.nametag || '(not set)'}`);
console.error(` L1 Addr: ${identity.l1Address}`);
}
await closeSphere();
} catch {
console.log(' (wallet not initialized in this profile)');
console.error(' (wallet not initialized in this profile)');
}
} else {
console.error(`Profile "${profileName}" not found.`);
Expand Down
6 changes: 5 additions & 1 deletion test/integration/cli-wallet-profile.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ describe('sphere-cli — wallet profile CRUD lifecycle (offline)', () => {
it('`wallet use alice` switches the active profile', () => {
const r = runSphere(env, ['wallet', 'use', 'alice'], { timeoutMs: 15_000 });
expect(r.status).toBe(0);
expect(r.stdout).toMatch(/Switched to wallet profile:\s*alice/);
// sphere-sdk#282 Residual #2 — confirmation lives on STDERR so
// downstream `sphere wallet use … && sphere balance > file` shell
// pipelines don't fold the banner into the captured snapshot.
expect(r.stderr).toMatch(/Switched to wallet profile:\s*alice/);
expect(r.stdout).not.toMatch(/Switched to wallet profile/);

// Verify by re-reading current.
const current = runSphere(env, ['wallet', 'current'], { timeoutMs: 15_000 });
Expand Down