diff options
Diffstat (limited to 'packages/ethereum-types/src/index.ts')
-rw-r--r-- | packages/ethereum-types/src/index.ts | 154 |
1 files changed, 150 insertions, 4 deletions
diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts index f4d445e3b..3b6fdc77b 100644 --- a/packages/ethereum-types/src/index.ts +++ b/packages/ethereum-types/src/index.ts @@ -20,7 +20,7 @@ export type ConstructorStateMutability = 'nonpayable' | 'payable'; export type StateMutability = 'pure' | 'view' | ConstructorStateMutability; export interface MethodAbi { - type: AbiType.Function; + type: 'function'; // We hardcode this here b/c doc pages cannot render an enum value name: string; inputs: DataItem[]; outputs: DataItem[]; @@ -30,14 +30,14 @@ export interface MethodAbi { } export interface ConstructorAbi { - type: AbiType.Constructor; + type: 'constructor'; // We hardcode this here b/c doc pages cannot render an enum value inputs: DataItem[]; payable: boolean; stateMutability: ConstructorStateMutability; } export interface FallbackAbi { - type: AbiType.Fallback; + type: 'fallback'; // We hardcode this here b/c doc pages cannot render an enum value payable: boolean; } @@ -46,7 +46,7 @@ export interface EventParameter extends DataItem { } export interface EventAbi { - type: AbiType.Event; + type: 'event'; // We hardcode this here b/c doc pages cannot render an enum value name: string; inputs: EventParameter[]; anonymous: boolean; @@ -287,3 +287,149 @@ 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 ContractNetworks { + [networkId: number]: ContractNetworkData; +} + +export interface ContractNetworkData { + address: string; + links: { + [linkName: string]: string; + }; + constructorArgs: string; +} + +export interface StandardContractOutput { + abi: ContractAbi; + evm: EvmOutput; +} + +export interface EvmOutput { + bytecode: EvmBytecodeOutput; + deployedBytecode: EvmBytecodeOutput; +} + +export interface EvmBytecodeOutput { + object: string; + sourceMap: string; +} + +export interface ContractVersionData { + compiler: CompilerOpts; + sources: { + [sourceName: string]: { + id: number; + }; + }; + sourceCodes: { + [sourceName: string]: string; + }; + sourceTreeHashHex: string; + compilerOutput: StandardContractOutput; +} + +export interface CompilerOpts { + name: 'solc'; + version: string; + settings: CompilerSettings; +} + +/** + * 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?: OptimizerSettings; + evmVersion?: 'homestead' | 'tangerineWhistle' | 'spuriousDragon' | 'byzantium' | 'constantinople'; + metadata?: CompilerSettingsMetadata; + libraries?: { + [fileName: string]: { + [libName: string]: string; + }; + }; + outputSelection: { + [fileName: string]: { + [contractName: string]: OutputField[]; + }; + }; +} + +export interface CompilerSettingsMetadata { + useLiteralContent: true; +} + +export interface OptimizerSettings { + enabled: boolean; + runs?: number; +} + +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; +} |