-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.ts
75 lines (69 loc) · 2.05 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env node
import chalk from "chalk";
import clear from "clear";
import figlet from "figlet";
import { COMPILER_VERSION, LICENSE, NETWORK } from "./lib/constants.js";
import {
enterClassOrContractAddress,
enterCompilerVersion,
enterLicense,
enterIsAccountContract,
enterContractName,
enterNetwork,
enterExistingClassOrContractAddress,
enterContractToVerify,
enterContractToVerifyWithValidDependencies,
} from "./lib/prompts.js";
import { dispatchClassVerificationJob, pollVerificationStatus } from "./lib/requests.js";
import { withSpinner } from "./lib/utils.js";
(async () => {
clear();
console.log(
chalk.yellow(figlet.textSync("Voyager", { horizontalLayout: "full" }))
);
console.log(
chalk.yellow(figlet.textSync("CLI Verifier", { horizontalLayout: "full" }))
);
try {
const network: NETWORK = await enterNetwork();
const address: string = await enterExistingClassOrContractAddress(network);
const version: COMPILER_VERSION = await enterCompilerVersion();
const license: LICENSE = await enterLicense();
const isAccount: boolean = await enterIsAccountContract();
const { contract, files } = <{ contract: any; files: any[] }>(
await enterContractToVerifyWithValidDependencies()
);
const fileSet = new Set<string>();
const uniqueFiles = [];
for (let i = 0; i < files.length; i++) {
const file = files[i];
if (fileSet.has(file.path)) {
continue;
}
fileSet.add(file.path);
uniqueFiles.push(file);
}
const contractName: string = await enterContractName(contract);
const jobId = await dispatchClassVerificationJob(
network,
address,
version,
license,
isAccount,
contractName,
contract,
uniqueFiles
);
await withSpinner(
"Verifying the contract...",
pollVerificationStatus(network, jobId.jobId)
);
console.log(
chalk.green(
"The verification was successful, thank you for using Voyager!"
)
);
} catch (error) {
console.log(chalk.red(error));
}
})();