forked from zerodevapp/userop_debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.ts
36 lines (30 loc) · 951 Bytes
/
cli.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { toPackedUserOperation } from "./packUserOperation";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import dotenv from "dotenv";
import fs from 'fs'
dotenv.config();
async function main() {
const argv = await yargs(hideBin(process.argv))
.option("operation", {
alias: "o",
description: "The unpacked user operation as a JSON string",
type: "string",
})
.parse();
if (argv.operation) {
try {
const operation = fs.readFileSync(argv.operation, 'utf8');
const unpackedUserOperation = JSON.parse(operation);
const packedOperation = toPackedUserOperation(unpackedUserOperation);
console.log(JSON.stringify(packedOperation));
} catch (error) {
console.error("Failed to parse unpacked user operation:", error);
}
} else {
console.error(
"No operation provided. Please pass an operation using the --operation flag."
);
}
}
main();