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
10 changes: 8 additions & 2 deletions packages/commands/src/query/cctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ const gatherCctxs = async (
while (true) {
// Check if we've exceeded the timeout (skip if timeout is 0)
if (timeoutMs > 0 && Date.now() - startTime > timeoutMs) {
console.log("\nTimeout reached. Exiting...");
console.log(
`\n${
Array.from(results.values()).length
} CCTXs found. Timeout reached. Exiting...`
);
return;
}

Expand Down Expand Up @@ -311,7 +315,8 @@ Revert Gas Limit: ${revert_gas_limit}
* CLI entry – clears screen and prints the list of indexes each round.
*/
const main = async (options: CctxOptions) => {
const { hash, rpc, delay, timeout } = options;
const { hash, rpc, delay, interactive } = options;
const timeout = interactive ? options.timeout : 5000;
Comment on lines +318 to +319
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Property name mismatch prevents this logic from working.

This code attempts to destructure interactive from options, but the schema validation (line 8 in src/schemas/commands/cctx.ts) and CLI flag (line 337) create a property named nonInteractive instead. This will result in interactive being undefined.

After applying the fix suggested in src/schemas/commands/cctx.ts, update this code to:

-  const { hash, rpc, delay, interactive } = options;
-  const timeout = interactive ? options.timeout : 5000;
+  const { hash, rpc, delay, nonInteractive } = options;
+  const timeout = nonInteractive ? 5000 : options.timeout;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { hash, rpc, delay, interactive } = options;
const timeout = interactive ? options.timeout : 5000;
const { hash, rpc, delay, nonInteractive } = options;
const timeout = nonInteractive ? 5000 : options.timeout;
🤖 Prompt for AI Agents
In packages/commands/src/query/cctx.ts around lines 318-319, the code
destructures an undefined 'interactive' property but the schema/CLI use
'nonInteractive'; replace the destructuring and logic to use the existing
property (e.g., derive interactive as !options.nonInteractive or directly use
options.nonInteractive in the conditional) so timeout is set to options.timeout
when interactive is true (nonInteractive is false) and defaults to 5000 when
nonInteractive is true.

cctxEmitter.on("cctx", (all) => {
console.clear();
all.forEach((cctx) => {
Expand All @@ -329,6 +334,7 @@ export const cctxCommand = new Command("cctx")
)
.requiredOption("--hash <hash>", "Inbound transaction hash")
.option("-r, --rpc <rpc>", "RPC endpoint", DEFAULT_API_URL)
.option("--non-interactive", "Run in non-interactive mode.")
.option(
"-d, --delay <ms>",
"Delay between polling rounds in milliseconds",
Expand Down
1 change: 1 addition & 0 deletions src/schemas/commands/cctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DEFAULT_DELAY, DEFAULT_TIMEOUT } from "../../constants/commands/cctx";
export const cctxOptionsSchema = z.object({
delay: z.coerce.number().int().positive().default(DEFAULT_DELAY),
hash: z.string(),
interactive: z.coerce.boolean(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Property name mismatch and missing default will cause validation failure.

The CLI flag is defined as --non-interactive (line 337 in packages/commands/src/query/cctx.ts), which Commander automatically converts to the camelCase property nonInteractive. However, the schema expects a field named interactive. This mismatch will cause cctxOptionsSchema.parse(opts) to fail at runtime.

Additionally, the field has no default value, meaning validation will fail when the flag is not provided.

Apply this diff to fix the issues:

-  interactive: z.coerce.boolean(),
+  nonInteractive: z.coerce.boolean().default(false),

Then update the logic in packages/commands/src/query/cctx.ts line 319 to:

const timeout = options.nonInteractive ? 5000 : options.timeout;

Alternatively, if you prefer to keep the schema property as interactive, change the CLI flag to:

.option("--interactive", "Run in interactive mode (default).", true)
🤖 Prompt for AI Agents
In src/schemas/commands/cctx.ts around line 8, the schema uses property name
"interactive" but the CLI flag produces "nonInteractive" (camelCase), and there
is no default, causing parse failures; update the schema to use nonInteractive:
z.coerce.boolean().default(false) (or rename to nonInteractive and add the
default) so the field matches the CLI flag and has a default; then update
packages/commands/src/query/cctx.ts at line 319 to use const timeout =
options.nonInteractive ? 5000 : options.timeout; ensuring the property names and
defaults are consistent.

rpc: z.string(),
timeout: z.coerce.number().int().min(0).default(DEFAULT_TIMEOUT),
});