Skip to content

Commit ed4294f

Browse files
Chris-Mollerclaude
andcommitted
fix(cli): require auth for build info and app releases commands
Both commands require authentication but were incorrectly using `requirePrivateKey: false` when an ID was provided directly. This skipped keyring lookup entirely, even when the user was logged in. Now uses the same pattern as deploy/upgrade: always call validateCommonFlags() without requirePrivateKey option, which fetches from keyring or prompts interactively. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 5b551ca commit ed4294f

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

packages/cli/src/client.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,19 @@ export async function createBuildClient(flags: CommonFlags) {
8383
const environmentConfig = getEnvironmentConfig(environment);
8484
const rpcUrl = flags["rpc-url"] || environmentConfig.defaultRPCURL;
8585

86-
const { walletClient } = createViemClients({
87-
privateKey: flags["private-key"] as Hex,
88-
rpcUrl,
89-
environment,
90-
});
86+
// Only create walletClient if we have a private key - createViemClients throws if privateKey is undefined
87+
let walletClient;
88+
if (flags["private-key"]) {
89+
walletClient = createViemClients({
90+
privateKey: flags["private-key"] as Hex,
91+
rpcUrl,
92+
environment,
93+
}).walletClient;
94+
}
9195

9296
return createBuildModule({
9397
verbose: flags.verbose,
94-
walletClient: flags["private-key"] ? walletClient : undefined,
98+
walletClient,
9599
environment,
96100
clientId: getClientId(),
97101
skipTelemetry: true, // CLI already has telemetry, skip SDK telemetry

packages/cli/src/commands/compute/app/releases.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,13 @@ export default class AppReleases extends Command {
8686
return withTelemetry(this, async () => {
8787
const { args, flags } = await this.parse(AppReleases);
8888

89-
// Releases endpoint is readable without auth; only require private key when we need to
90-
// resolve app names interactively (or when the provided identifier isn't an address).
91-
const rawAppId = args["app-id"];
92-
const needsPrivateKey = !rawAppId || !isAddress(rawAppId);
93-
const validatedFlags = await validateCommonFlags(flags, {
94-
requirePrivateKey: needsPrivateKey,
95-
});
89+
// Auth is required to call the API (you can view any app's releases, not just your own)
90+
const validatedFlags = await validateCommonFlags(flags);
9691

9792
const environment = validatedFlags.environment || "sepolia";
9893
const environmentConfig = getEnvironmentConfig(environment);
9994
const rpcUrl = validatedFlags["rpc-url"] || environmentConfig.defaultRPCURL;
100-
const privateKey = validatedFlags["private-key"];
95+
const privateKey = validatedFlags["private-key"]!;
10196

10297
const appID = await getOrPromptAppID({
10398
appID: args["app-id"],
@@ -106,11 +101,6 @@ export default class AppReleases extends Command {
106101
rpcUrl,
107102
action: "view releases for",
108103
});
109-
110-
// Create viem clients and UserAPI client
111-
if (!privateKey) {
112-
this.error("Private key is required to fetch releases. Please provide --private-key.");
113-
}
114104
const { publicClient, walletClient } = createViemClients({
115105
privateKey,
116106
rpcUrl,

packages/cli/src/commands/compute/build/info.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ export default class BuildInfo extends Command {
3131
async run(): Promise<void> {
3232
return withTelemetry(this, async () => {
3333
const { args, flags } = await this.parse(BuildInfo);
34-
const validatedFlags = await validateCommonFlags(flags, {
35-
requirePrivateKey: !args.buildId,
36-
});
34+
// Auth is required (you can view any build, not just your own)
35+
const validatedFlags = await validateCommonFlags(flags);
3736
const client = await createBuildClient(validatedFlags);
3837

3938
let buildId = args.buildId;

0 commit comments

Comments
 (0)