UNPKG

1.39 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as fs from 'fs';
3import { sync as mkdirp } from 'mkdirp';
4import * as prettier from 'prettier';
5import { MarkOptional } from 'ts-essentials';
6export interface Config {
7 cwd: string;
8 target: string;
9 outDir?: string | undefined;
10 prettier?: object | undefined;
11 filesToProcess: string[];
12 allFiles: string[];
13 /**
14 * Optional path to directory with ABI files.
15 * If not specified, inferred to be lowest common path of all input files.
16 */
17 inputDir: string;
18 flags: CodegenConfig;
19}
20export interface CodegenConfig {
21 alwaysGenerateOverloads: boolean;
22 discriminateTypes: boolean;
23 tsNocheck?: boolean;
24 node16Modules?: boolean;
25 environment: 'hardhat' | undefined;
26}
27export type PublicConfig = MarkOptional<Config, 'flags' | 'inputDir'>;
28export declare abstract class TypeChainTarget {
29 readonly cfg: Config;
30 abstract readonly name: string;
31 constructor(cfg: Config);
32 beforeRun(): Output | Promise<Output>;
33 afterRun(): Output | Promise<Output>;
34 abstract transformFile(file: FileDescription): Output | Promise<Output>;
35}
36export type Output = void | FileDescription | FileDescription[];
37export interface FileDescription {
38 path: string;
39 contents: string;
40}
41export interface Services {
42 fs: typeof fs;
43 prettier: typeof prettier;
44 mkdirp: typeof mkdirp;
45}