Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changelog/await-compat-login-whoami-output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
wallet-cli: patch
---

Await the whoami payload in the compatibility `login --no-browser` path so it prints wallet details instead of an empty object.
2 changes: 1 addition & 1 deletion src/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function handleCompatCommand(args: readonly string[]) {
const activeAccount = state.accounts[state.activeAccount ?? 0];
if (!activeAccount) return false;
printCompatOutput(
currentWhoamiOutput({
await currentWhoamiOutput({
walletAddress: activeAccount.address,
chain: state.chainId ?? null,
accessKeys: state.accessKeys,
Expand Down
22 changes: 22 additions & 0 deletions test/compat.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, expect, it, vi } from "vitest";

import { handleCompatCommand } from "../src/compat.js";
import { useTempHome, testWallet, walletState, writeWalletState } from "./helpers.js";

describe("handleCompatCommand", () => {
it("prints the resolved whoami payload for login --no-browser", async () => {
await useTempHome();
await writeWalletState(walletState());

const log = vi.spyOn(console, "log").mockImplementation(() => undefined);
const handled = await handleCompatCommand(["login", "--no-browser", "--json-output"]);

expect(handled).toBe(true);
expect(log).toHaveBeenCalledTimes(1);

const printed = JSON.parse(String(log.mock.calls[0]?.[0])) as Record<string, unknown>;
expect(printed.wallet).toBe(testWallet.toLowerCase());
expect(printed).toHaveProperty("balance");
expect(printed).toHaveProperty("key");
});
});