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