Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Typescript definitions.
Browse files Browse the repository at this point in the history
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.  :)
MicahZoltu committed Nov 18, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent eace963 commit c609aea
Showing 2 changed files with 157 additions and 0 deletions.
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
@@ -3,6 +3,7 @@
"version": "0.5.0",
"description": "Solidity compiler",
"main": "index.js",
"types": "index.d.ts",
"bin": {
"solcjs": "solcjs"
},

0 comments on commit c609aea

Please sign in to comment.