Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Typescript definitions. #205

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
declare module 'solc' {
export type Primitive =
'bool' |
'string' |
'address' |
'uint8' |
'uint16' |
'uint32' |
'uint64' |
'uint128' |
'uint256' |
'int8' |
'int16' |
'int32' |
'int64' |
'int128' |
'int256' |
'bytes' |
'bytes20' |
'bytes32' |
'bool[]' |
'string[]' |
'address[]' |
'uint8[]' |
'uint16[]' |
'uint32[]' |
'uint64[]' |
'uint128[]' |
'uint256[]' |
'int8[]' |
'int16[]' |
'int32[]' |
'int64[]' |
'int128[]' |
'int256[]' |
'bytes[]' |
'bytes20[]' |
'bytes32[]';

export interface AbiParameter {
name: string,
type: Primitive,
}

export interface AbiEventParameter extends AbiParameter {
indexed: boolean,
}

export interface AbiFunction {
name: string,
type: 'function' | 'constructor' | 'fallback',
stateMutability: 'pure' | 'view' | 'payable' | 'nonpayable',
constant: boolean,
payable: boolean,
inputs: Array<AbiParameter>,
outputs: Array<AbiParameter>,
}

export interface AbiEvent {
name: string,
type: 'event',
inputs: Array<AbiEventParameter>,
anonymous: boolean,
}

export type Abi = Array<AbiFunction | AbiEvent>;

interface CompilerInputSourceFile {
keccak256?: string;
urls: string[];
}
interface CompilerInputSourceCode {
keccak256?: string;
content: string;
}
interface CompilerInput {
language: "Solidity" | "serpent" | "lll" | "assembly";
settings?: any,
sources: {
[globalName: string]: CompilerInputSourceFile|CompilerInputSourceCode,
};
}
interface CompilerOutputError {
sourceLocation?: {
file: string;
start: number;
end: number;
};
type: "TypeError" | "InternalCompilerError" | "Exception";
component: "general" | "ewasm";
severity: "error" | "warning";
message: string;
formattedMessage?: string;
}
interface CompilerOutputEvmBytecode {
object?: string;
opcodes?: string;
sourceMap?: string;
linkReferences?: {} | {
[globalName: string]: {
[name: string]: {start: number, length: number}[];
};
};
}
interface CompilerOutputSources {
[globalName: string]: {
id: number;
ast?: any;
legacyAST?: any;
},
}
interface CompilerOutputContracts {
[globalName: string]: {
[contractName: string]: {
abi?: Abi;
metadata?: string;
userdoc?: any;
devdoc?: any;
ir?: string;
evm?: {
assembly?: string;
legacyAssembly?: any;
bytecode: CompilerOutputEvmBytecode;
deployedBytecode?: CompilerOutputEvmBytecode;
methodIdentifiers?: {
[methodName: string]: string;
};
gasEstimates?: {
creation: {
codeDepositCost: string;
executionCost: string;
totalCost: string;
};
external: {
[functionSignature: string]: string;
};
internal: {
[functionSignature: string]: string;
};
};
};
ewasm: {
wast?: string;
wasm?: string;
}
}
};
}
interface CompilerOutput {
errors: CompilerOutputError[];
sources: CompilerOutputSources;
contracts: CompilerOutputContracts;
}
type ReadCallback = (path: string) => { contents?: string, error?: string};
function compileStandardWrapper(input: string, readCallback?: ReadCallback): string;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.5.0",
"description": "Solidity compiler",
"main": "index.js",
"types": "index.d.ts",
"bin": {
"solcjs": "solcjs"
},
Expand Down