Skip to content

Commit c609aea

Browse files
committed
Adds Typescript definitions.
This isn't complete, but it is _way_ better than nothing and gives a place for people to add additional typescript definitions in the future. Recommend switching over to TypeScript for this library so this file is generated automatically. :)
1 parent eace963 commit c609aea

File tree

2 files changed

+157
-0
lines changed

2 files changed

+157
-0
lines changed

index.d.ts

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
declare module 'solc' {
2+
export type Primitive =
3+
'bool' |
4+
'string' |
5+
'address' |
6+
'uint8' |
7+
'uint16' |
8+
'uint32' |
9+
'uint64' |
10+
'uint128' |
11+
'uint256' |
12+
'int8' |
13+
'int16' |
14+
'int32' |
15+
'int64' |
16+
'int128' |
17+
'int256' |
18+
'bytes' |
19+
'bytes20' |
20+
'bytes32' |
21+
'bool[]' |
22+
'string[]' |
23+
'address[]' |
24+
'uint8[]' |
25+
'uint16[]' |
26+
'uint32[]' |
27+
'uint64[]' |
28+
'uint128[]' |
29+
'uint256[]' |
30+
'int8[]' |
31+
'int16[]' |
32+
'int32[]' |
33+
'int64[]' |
34+
'int128[]' |
35+
'int256[]' |
36+
'bytes[]' |
37+
'bytes20[]' |
38+
'bytes32[]';
39+
40+
export interface AbiParameter {
41+
name: string,
42+
type: Primitive,
43+
}
44+
45+
export interface AbiEventParameter extends AbiParameter {
46+
indexed: boolean,
47+
}
48+
49+
export interface AbiFunction {
50+
name: string,
51+
type: 'function' | 'constructor' | 'fallback',
52+
stateMutability: 'pure' | 'view' | 'payable' | 'nonpayable',
53+
constant: boolean,
54+
payable: boolean,
55+
inputs: Array<AbiParameter>,
56+
outputs: Array<AbiParameter>,
57+
}
58+
59+
export interface AbiEvent {
60+
name: string,
61+
type: 'event',
62+
inputs: Array<AbiEventParameter>,
63+
anonymous: boolean,
64+
}
65+
66+
export type Abi = Array<AbiFunction | AbiEvent>;
67+
68+
interface CompilerInputSourceFile {
69+
keccak256?: string;
70+
urls: string[];
71+
}
72+
interface CompilerInputSourceCode {
73+
keccak256?: string;
74+
content: string;
75+
}
76+
interface CompilerInput {
77+
language: "Solidity" | "serpent" | "lll" | "assembly";
78+
settings?: any,
79+
sources: {
80+
[globalName: string]: CompilerInputSourceFile|CompilerInputSourceCode,
81+
};
82+
}
83+
interface CompilerOutputError {
84+
sourceLocation?: {
85+
file: string;
86+
start: number;
87+
end: number;
88+
};
89+
type: "TypeError" | "InternalCompilerError" | "Exception";
90+
component: "general" | "ewasm";
91+
severity: "error" | "warning";
92+
message: string;
93+
formattedMessage?: string;
94+
}
95+
interface CompilerOutputEvmBytecode {
96+
object?: string;
97+
opcodes?: string;
98+
sourceMap?: string;
99+
linkReferences?: {} | {
100+
[globalName: string]: {
101+
[name: string]: {start: number, length: number}[];
102+
};
103+
};
104+
}
105+
interface CompilerOutputSources {
106+
[globalName: string]: {
107+
id: number;
108+
ast?: any;
109+
legacyAST?: any;
110+
},
111+
}
112+
interface CompilerOutputContracts {
113+
[globalName: string]: {
114+
[contractName: string]: {
115+
abi?: Abi;
116+
metadata?: string;
117+
userdoc?: any;
118+
devdoc?: any;
119+
ir?: string;
120+
evm?: {
121+
assembly?: string;
122+
legacyAssembly?: any;
123+
bytecode: CompilerOutputEvmBytecode;
124+
deployedBytecode?: CompilerOutputEvmBytecode;
125+
methodIdentifiers?: {
126+
[methodName: string]: string;
127+
};
128+
gasEstimates?: {
129+
creation: {
130+
codeDepositCost: string;
131+
executionCost: string;
132+
totalCost: string;
133+
};
134+
external: {
135+
[functionSignature: string]: string;
136+
};
137+
internal: {
138+
[functionSignature: string]: string;
139+
};
140+
};
141+
};
142+
ewasm: {
143+
wast?: string;
144+
wasm?: string;
145+
}
146+
}
147+
};
148+
}
149+
interface CompilerOutput {
150+
errors: CompilerOutputError[];
151+
sources: CompilerOutputSources;
152+
contracts: CompilerOutputContracts;
153+
}
154+
type ReadCallback = (path: string) => { contents?: string, error?: string};
155+
function compileStandardWrapper(input: string, readCallback?: ReadCallback): string;
156+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.5.0",
44
"description": "Solidity compiler",
55
"main": "index.js",
6+
"types": "index.d.ts",
67
"bin": {
78
"solcjs": "solcjs"
89
},

0 commit comments

Comments
 (0)