-
Notifications
You must be signed in to change notification settings - Fork 29
/
types.ts
30 lines (23 loc) · 956 Bytes
/
types.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
import { Args } from "@oclif/core";
import { findContractRecord, generateTypes } from "../../lib/index.js";
import { SwankyCommand } from "../../lib/swankyCommand.js";
import { contractFromRecord, ensureArtifactsExist } from "../../lib/checks.js";
export class GenerateTypes extends SwankyCommand<typeof GenerateTypes> {
static description = "Generate types from compiled contract metadata";
static args = {
contractName: Args.string({
name: "contractName",
required: true,
description: "Name of the contract",
}),
};
async run(): Promise<void> {
const { args } = await this.parse(GenerateTypes);
const contractRecord = findContractRecord(this.swankyConfig, args.contractName);
const contract = await contractFromRecord(contractRecord);
await ensureArtifactsExist(contract);
await this.spinner.runCommand(async () => {
await generateTypes(contract.name);
}, "Generating types");
}
}