diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-22 06:58:06 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-22 06:58:06 +0800 |
commit | 301cb296ec77e8af5c1722679e04cb983c848153 (patch) | |
tree | c4f3c94c2f76e47d7b12d3761af57c15819c9cc2 /packages/ethereum-types/src | |
parent | 1bbd7bf870730dfe2146819e3740522990eb83ca (diff) | |
download | dexon-sol-tools-301cb296ec77e8af5c1722679e04cb983c848153.tar dexon-sol-tools-301cb296ec77e8af5c1722679e04cb983c848153.tar.gz dexon-sol-tools-301cb296ec77e8af5c1722679e04cb983c848153.tar.bz2 dexon-sol-tools-301cb296ec77e8af5c1722679e04cb983c848153.tar.lz dexon-sol-tools-301cb296ec77e8af5c1722679e04cb983c848153.tar.xz dexon-sol-tools-301cb296ec77e8af5c1722679e04cb983c848153.tar.zst dexon-sol-tools-301cb296ec77e8af5c1722679e04cb983c848153.zip |
Move types from sol-compiler to types so they can be used in other places without requiring sol-compiler as a dep
Diffstat (limited to 'packages/ethereum-types/src')
-rw-r--r-- | packages/ethereum-types/src/index.ts | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts index b2af028fb..5ace18452 100644 --- a/packages/ethereum-types/src/index.ts +++ b/packages/ethereum-types/src/index.ts @@ -287,3 +287,164 @@ export interface TraceParams { disableStack?: boolean; disableStorage?: boolean; } + +export type OutputField = + | '*' + | 'ast' + | 'legacyAST' + | 'abi' + | 'devdoc' + | 'userdoc' + | 'metadata' + | 'ir' + | 'evm.assembly' + | 'evm.legacyAssembly' + | 'evm.bytecode.object' + | 'evm.bytecode.opcodes' + | 'evm.bytecode.sourceMap' + | 'evm.bytecode.linkReferences' + | 'evm.deployedBytecode.object' + | 'evm.deployedBytecode.opcodes' + | 'evm.deployedBytecode.sourceMap' + | 'evm.deployedBytecode.linkReferences' + | 'evm.methodIdentifiers' + | 'evm.gasEstimates' + | 'ewasm.wast' + | 'ewasm.wasm'; + +export interface CompilerSettings { + remappings?: string[]; + optimizer?: { + enabled: boolean; + runs?: number; + }; + evmVersion?: 'homestead' | 'tangerineWhistle' | 'spuriousDragon' | 'byzantium' | 'constantinople'; + metadata?: { + useLiteralContent: true; + }; + libraries?: { + [fileName: string]: { + [libName: string]: string; + }; + }; + outputSelection: { + [fileName: string]: { + [contractName: string]: OutputField[]; + }; + }; +} + +export interface ContractNetworks { + [networkId: number]: ContractNetworkData; +} + +export interface ContractNetworkData { + address: string; + links: { + [linkName: string]: string; + }; + constructorArgs: string; +} + +export interface StandardContractOutput { + abi: ContractAbi; + evm: { + bytecode: { + object: string; + sourceMap: string; + }; + deployedBytecode: { + object: string; + sourceMap: string; + }; + }; +} + +export interface ContractVersionData { + compiler: { + name: 'solc'; + version: string; + settings: CompilerSettings; + }; + sources: { + [sourceName: string]: { + id: number; + }; + }; + sourceCodes: { + [sourceName: string]: string; + }; + sourceTreeHashHex: string; + compilerOutput: StandardContractOutput; +} + +/** + * This type defines the schema of the artifact.json file generated by Sol-compiler + * schemaVersion: The version of the artifact schema + * contractName: The contract name it represents + * networks: Network specific information by network (address, id, constructor args, etc...) + * compilerOutput: The Solidity compiler output generated from the specified compiler input + * description (http://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#compiler-input-and-output-json-description) + * compiler: The compiler settings used + * sourceCodes: The source code of the contract and all it's dependencies + * sources: A mapping from source filePath to sourceMap id + * sourceTreeHashHex: A unique hash generated from the contract source and that of it's dependencies. + * If any of the sources change, the hash would change notifying us that a re-compilation is necessary + */ +export interface ContractArtifact extends ContractVersionData { + schemaVersion: string; + contractName: string; + networks: ContractNetworks; +} + +export interface GeneratedCompilerOptions { + name: 'solc'; + version: string; + settings: CompilerSettings; +} + +// Copied from the solc.js library types +export interface CompilerSettings { + remappings?: string[]; + optimizer?: { + enabled: boolean; + runs?: number; + }; + evmVersion?: 'homestead' | 'tangerineWhistle' | 'spuriousDragon' | 'byzantium' | 'constantinople'; + metadata?: { + useLiteralContent: true; + }; + libraries?: { + [fileName: string]: { + [libName: string]: string; + }; + }; + outputSelection: { + [fileName: string]: { + [contractName: string]: OutputField[]; + }; + }; +} + +export interface Source { + id: number; +} + +/** + * Options you can specify (as flags or in a compiler.json file) when invoking sol-compiler + * contractsDir: Directory containing your project's Solidity contracts. Can contain nested directories. + * artifactsDir: Directory where you want the generated artifacts.json written to + * compilerSettings: Desired settings to pass to the Solidity compiler during compilation. + * (http://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#compiler-input-and-output-json-description) + * contracts: List of contract names you wish to compile, or alternatively ['*'] to compile all contracts in the + * specified directory. + * solcVersion: If you don't want to compile each contract with the Solidity version specified in-file, you can force all + * contracts to compile with the the version specified here. + */ +export interface CompilerOptions { + contractsDir?: string; + artifactsDir?: string; + compilerSettings?: CompilerSettings; + contracts?: string[] | '*'; + solcVersion?: string; +} |