diff --git a/.changelog/await-compat-login-whoami-output.md b/.changelog/await-compat-login-whoami-output.md new file mode 100644 index 0000000..c636aff --- /dev/null +++ b/.changelog/await-compat-login-whoami-output.md @@ -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. diff --git a/src/compat.ts b/src/compat.ts index 60af830..cf375eb 100644 --- a/src/compat.ts +++ b/src/compat.ts @@ -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, diff --git a/test/compat.test.ts b/test/compat.test.ts new file mode 100644 index 0000000..c623b9e --- /dev/null +++ b/test/compat.test.ts @@ -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; + expect(printed.wallet).toBe(testWallet.toLowerCase()); + expect(printed).toHaveProperty("balance"); + expect(printed).toHaveProperty("key"); + }); +});