Skip to content

Commit f3f711e

Browse files
committed
feat(cctx): non-interactive flag
1 parent 31170ea commit f3f711e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/commands/src/query/cctx.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ const gatherCctxs = async (
6464
while (true) {
6565
// Check if we've exceeded the timeout (skip if timeout is 0)
6666
if (timeoutMs > 0 && Date.now() - startTime > timeoutMs) {
67-
console.log("\nTimeout reached. Exiting...");
67+
console.log(
68+
`\n${
69+
Array.from(results.values()).length
70+
} CCTXs found. Timeout reached. Exiting...`
71+
);
6872
return;
6973
}
7074

@@ -311,7 +315,8 @@ Revert Gas Limit: ${revert_gas_limit}
311315
* CLI entry – clears screen and prints the list of indexes each round.
312316
*/
313317
const main = async (options: CctxOptions) => {
314-
const { hash, rpc, delay, timeout } = options;
318+
const { hash, rpc, delay, interactive } = options;
319+
const timeout = interactive ? options.timeout : 5000;
315320
cctxEmitter.on("cctx", (all) => {
316321
console.clear();
317322
all.forEach((cctx) => {
@@ -329,6 +334,7 @@ export const cctxCommand = new Command("cctx")
329334
)
330335
.requiredOption("--hash <hash>", "Inbound transaction hash")
331336
.option("-r, --rpc <rpc>", "RPC endpoint", DEFAULT_API_URL)
337+
.option("--non-interactive", "Run in non-interactive mode.")
332338
.option(
333339
"-d, --delay <ms>",
334340
"Delay between polling rounds in milliseconds",

src/schemas/commands/cctx.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DEFAULT_DELAY, DEFAULT_TIMEOUT } from "../../constants/commands/cctx";
55
export const cctxOptionsSchema = z.object({
66
delay: z.coerce.number().int().positive().default(DEFAULT_DELAY),
77
hash: z.string(),
8+
interactive: z.coerce.boolean(),
89
rpc: z.string(),
910
timeout: z.coerce.number().int().min(0).default(DEFAULT_TIMEOUT),
1011
});

0 commit comments

Comments
 (0)