UNPKG

3.7 kBTypeScriptView Raw
1import { Dictionary } from 'ts-essentials';
2import { EvmOutputType, EvmType, StructType } from './parseEvmType';
3export interface AbiParameter {
4 name: string;
5 type: EvmType;
6}
7export interface AbiOutputParameter {
8 name: string;
9 type: EvmOutputType;
10}
11export type Named<T> = {
12 name: string;
13 values: T;
14};
15export type StateMutability = 'pure' | 'view' | 'nonpayable' | 'payable';
16export interface FunctionDocumentation {
17 author?: string;
18 details?: string;
19 notice?: string;
20 params?: {
21 [paramName: string]: string;
22 };
23 return?: string;
24}
25export interface FunctionDeclaration {
26 name: string;
27 stateMutability: StateMutability;
28 inputs: AbiParameter[];
29 outputs: AbiOutputParameter[];
30 documentation?: FunctionDocumentation | undefined;
31}
32export interface FunctionWithoutOutputDeclaration extends FunctionDeclaration {
33 outputs: [];
34}
35export interface FunctionWithoutInputDeclaration extends FunctionDeclaration {
36 inputs: [];
37}
38export interface Contract {
39 name: string;
40 rawName: string;
41 path: string[];
42 fallback?: FunctionWithoutInputDeclaration | undefined;
43 constructor: FunctionWithoutOutputDeclaration[];
44 functions: Dictionary<FunctionDeclaration[]>;
45 events: Dictionary<EventDeclaration[]>;
46 structs: Dictionary<StructType[]>;
47 documentation?: {
48 author?: string;
49 details?: string;
50 notice?: string;
51 } | undefined;
52}
53export interface RawAbiParameter {
54 name: string;
55 type: string;
56 internalType?: string;
57 components?: RawAbiParameter[];
58}
59export interface RawAbiDefinition {
60 name: string;
61 constant: boolean;
62 payable: boolean;
63 stateMutability?: StateMutability;
64 inputs: RawAbiParameter[];
65 outputs: RawAbiParameter[];
66 type: string;
67}
68export interface EventDeclaration {
69 name: string;
70 isAnonymous: boolean;
71 inputs: EventArgDeclaration[];
72}
73export interface EventArgDeclaration {
74 isIndexed: boolean;
75 name?: string | undefined;
76 type: EvmType;
77}
78export interface RawEventAbiDefinition {
79 type: 'event';
80 anonymous?: boolean;
81 name: string;
82 inputs: RawEventArgAbiDefinition[];
83}
84export interface RawEventArgAbiDefinition {
85 indexed: boolean;
86 name: string;
87 type: string;
88}
89export interface BytecodeLinkReference {
90 reference: string;
91 name?: string;
92}
93export interface BytecodeWithLinkReferences {
94 bytecode: string;
95 linkReferences?: BytecodeLinkReference[];
96}
97export interface DocumentationResult {
98 author?: string;
99 details?: string;
100 notice?: string;
101 title?: string;
102 methods?: {
103 [methodName: string]: FunctionDocumentation;
104 };
105}
106export declare function parseContractPath(path: string): {
107 name: string;
108 rawName: string;
109 path: string[];
110};
111export declare function parse(abi: RawAbiDefinition[], path: string, documentation?: DocumentationResult): Contract;
112export declare function parseEvent(abiPiece: RawEventAbiDefinition, registerStruct: (struct: StructType) => void): EventDeclaration;
113export declare function getFunctionDocumentation(abiPiece: RawAbiDefinition, documentation?: DocumentationResult): FunctionDocumentation | undefined;
114export declare function extractAbi(rawJson: string): RawAbiDefinition[];
115export declare function extractBytecode(rawContents: string): BytecodeWithLinkReferences | undefined;
116export declare function extractDocumentation(rawContents: string): DocumentationResult | undefined;
117export declare function ensure0xPrefix(hexString: string): string;
118export declare function isConstant(fn: FunctionDeclaration): boolean;
119export declare function isConstantFn(fn: FunctionDeclaration): boolean;