Skip to content

Commit 79cd70e

Browse files
satoshai-devclaude
andcommitted
fix: validate network before fetch loop for fail-fast behavior
Move network validation before the contract iteration loop so invalid network strings are caught immediately instead of surfacing during the first fetch — which is confusing when fetching multiple contracts. Closes #12 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fed887c commit 79cd70e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/commands/fetch.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineCommand } from 'citty';
22
import { parseContractId, fetchContractAbi } from '../fetcher.js';
33
import { generateTypescript, generateJson, defaultFilename } from '../codegen.js';
4+
import { resolveNetwork } from '../network.js';
45
import { writeFile } from 'node:fs/promises';
56
import { resolve } from 'node:path';
67

@@ -44,6 +45,9 @@ export const fetchCommand = defineCommand({
4445
throw new Error(`Invalid format "${format}". Use "ts" or "json".`);
4546
}
4647

48+
// Validate network early to fail fast before fetching any contracts
49+
resolveNetwork(args.network);
50+
4751
const contractIds = args.contract.split(',').map((s) => s.trim());
4852

4953
for (const contractId of contractIds) {

0 commit comments

Comments
 (0)