Improve examples in standard json documentation.

This commit is contained in:
Daniel Kirchner 2019-01-11 17:47:06 +01:00
parent d7e2838702
commit b145934fdb

View File

@ -140,9 +140,9 @@ Input Description
{ {
// Required: Source code language, such as "Solidity", "Vyper", "lll", "assembly", etc. // Required: Source code language, such as "Solidity", "Vyper", "lll", "assembly", etc.
language: "Solidity", "language": "Solidity",
// Required // Required
sources: "sources":
{ {
// The keys here are the "global" names of the source files, // The keys here are the "global" names of the source files,
// imports can use other files via remappings (see below). // imports can use other files via remappings (see below).
@ -155,13 +155,16 @@ Input Description
// URL(s) should be imported in this order and the result checked against the // URL(s) should be imported in this order and the result checked against the
// keccak256 hash (if available). If the hash doesn't match or none of the // keccak256 hash (if available). If the hash doesn't match or none of the
// URL(s) result in success, an error should be raised. // URL(s) result in success, an error should be raised.
// Using the commandline interface only filesystem paths are supported.
// With the JavaScript interface the URL will be passed to the user-supplied
// read callback, so any URL supported by the callback can be used.
"urls": "urls":
[ [
"bzzr://56ab...", "bzzr://56ab...",
"ipfs://Qma...", "ipfs://Qma...",
"/tmp/path/to/file.sol"
// If files are used, their directories should be added to the command line via // If files are used, their directories should be added to the command line via
// `--allow-paths <path>`. // `--allow-paths <path>`.
"file:///tmp/path/to/file.sol"
] ]
}, },
"mortal": "mortal":
@ -173,26 +176,26 @@ Input Description
} }
}, },
// Optional // Optional
settings: "settings":
{ {
// Optional: Sorted list of remappings // Optional: Sorted list of remappings
remappings: [ ":g/dir" ], "remappings": [ ":g/dir" ],
// Optional: Optimizer settings // Optional: Optimizer settings
optimizer: { "optimizer": {
// disabled by default // disabled by default
enabled: true, "enabled": true,
// Optimize for how many times you intend to run the code. // Optimize for how many times you intend to run the code.
// Lower values will optimize more for initial deployment cost, higher values will optimize more for high-frequency usage. // Lower values will optimize more for initial deployment cost, higher values will optimize more for high-frequency usage.
runs: 200 "runs": 200
}, },
evmVersion: "byzantium", // Version of the EVM to compile for. Affects type checking and code generation. Can be homestead, tangerineWhistle, spuriousDragon, byzantium or constantinople "evmVersion": "byzantium", // Version of the EVM to compile for. Affects type checking and code generation. Can be homestead, tangerineWhistle, spuriousDragon, byzantium or constantinople
// Metadata settings (optional) // Metadata settings (optional)
metadata: { "metadata": {
// Use only literal content and not URLs (false by default) // Use only literal content and not URLs (false by default)
useLiteralContent: true "useLiteralContent": true
}, },
// Addresses of the libraries. If not all libraries are given here, it can result in unlinked objects whose output data is different. // Addresses of the libraries. If not all libraries are given here, it can result in unlinked objects whose output data is different.
libraries: { "libraries": {
// The top level key is the the name of the source file where the library is used. // The top level key is the the name of the source file where the library is used.
// If remappings are used, this source file should match the global path after remappings were applied. // If remappings are used, this source file should match the global path after remappings were applied.
// If this key is an empty string, that refers to a global level. // If this key is an empty string, that refers to a global level.
@ -240,22 +243,17 @@ Input Description
// Note that using a using `evm`, `evm.bytecode`, `ewasm`, etc. will select every // Note that using a using `evm`, `evm.bytecode`, `ewasm`, etc. will select every
// target part of that output. Additionally, `*` can be used as a wildcard to request everything. // target part of that output. Additionally, `*` can be used as a wildcard to request everything.
// //
outputSelection: { "outputSelection": {
// Enable the metadata and bytecode outputs of every single contract.
"*": { "*": {
"*": [ "metadata", "evm.bytecode" ] "*": [
"metadata", "evm.bytecode" // Enable the metadata and bytecode outputs of every single contract.
, "evm.bytecode.sourceMap" // Enable the source map output of every single contract.
, "ast" // Enable the AST output of every single file.
]
}, },
// Enable the abi and opcodes output of MyContract defined in file def. // Enable the abi and opcodes output of MyContract defined in file def.
"def": { "def": {
"MyContract": [ "abi", "evm.bytecode.opcodes" ] "MyContract": [ "abi", "evm.bytecode.opcodes" ]
},
// Enable the source map output of every single contract.
"*": {
"*": [ "evm.bytecode.sourceMap" ]
},
// Enable the legacy AST output of every single file.
"*": {
"": [ "legacyAST" ]
} }
} }
} }
@ -269,106 +267,106 @@ Output Description
{ {
// Optional: not present if no errors/warnings were encountered // Optional: not present if no errors/warnings were encountered
errors: [ "errors": [
{ {
// Optional: Location within the source file. // Optional: Location within the source file.
sourceLocation: { "sourceLocation": {
file: "sourceFile.sol", "file": "sourceFile.sol",
start: 0, "start": 0,
end: 100 "end": 100
], ],
// Mandatory: Error type, such as "TypeError", "InternalCompilerError", "Exception", etc. // Mandatory: Error type, such as "TypeError", "InternalCompilerError", "Exception", etc.
// See below for complete list of types. // See below for complete list of types.
type: "TypeError", "type": "TypeError",
// Mandatory: Component where the error originated, such as "general", "ewasm", etc. // Mandatory: Component where the error originated, such as "general", "ewasm", etc.
component: "general", "component": "general",
// Mandatory ("error" or "warning") // Mandatory ("error" or "warning")
severity: "error", "severity": "error",
// Mandatory // Mandatory
message: "Invalid keyword" "message": "Invalid keyword"
// Optional: the message formatted with source location // Optional: the message formatted with source location
formattedMessage: "sourceFile.sol:100: Invalid keyword" "formattedMessage": "sourceFile.sol:100: Invalid keyword"
} }
], ],
// This contains the file-level outputs. In can be limited/filtered by the outputSelection settings. // This contains the file-level outputs. In can be limited/filtered by the outputSelection settings.
sources: { "sources": {
"sourceFile.sol": { "sourceFile.sol": {
// Identifier of the source (used in source maps) // Identifier of the source (used in source maps)
id: 1, "id": 1,
// The AST object // The AST object
ast: {}, "ast": {},
// The legacy AST object // The legacy AST object
legacyAST: {} "legacyAST": {}
} }
}, },
// This contains the contract-level outputs. It can be limited/filtered by the outputSelection settings. // This contains the contract-level outputs. It can be limited/filtered by the outputSelection settings.
contracts: { "contracts": {
"sourceFile.sol": { "sourceFile.sol": {
// If the language used has no contract names, this field should equal to an empty string. // If the language used has no contract names, this field should equal to an empty string.
"ContractName": { "ContractName": {
// The Ethereum Contract ABI. If empty, it is represented as an empty array. // The Ethereum Contract ABI. If empty, it is represented as an empty array.
// See https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI // See https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI
abi: [], "abi": [],
// See the Metadata Output documentation (serialised JSON string) // See the Metadata Output documentation (serialised JSON string)
metadata: "{...}", "metadata": "{...}",
// User documentation (natspec) // User documentation (natspec)
userdoc: {}, "userdoc": {},
// Developer documentation (natspec) // Developer documentation (natspec)
devdoc: {}, "devdoc": {},
// Intermediate representation (string) // Intermediate representation (string)
ir: "", "ir": "",
// EVM-related outputs // EVM-related outputs
evm: { "evm": {
// Assembly (string) // Assembly (string)
assembly: "", "assembly": "",
// Old-style assembly (object) // Old-style assembly (object)
legacyAssembly: {}, "legacyAssembly": {},
// Bytecode and related details. // Bytecode and related details.
bytecode: { "bytecode": {
// The bytecode as a hex string. // The bytecode as a hex string.
object: "00fe", "object": "00fe",
// Opcodes list (string) // Opcodes list (string)
opcodes: "", "opcodes": "",
// The source mapping as a string. See the source mapping definition. // The source mapping as a string. See the source mapping definition.
sourceMap: "", "sourceMap": "",
// If given, this is an unlinked object. // If given, this is an unlinked object.
linkReferences: { "linkReferences": {
"libraryFile.sol": { "libraryFile.sol": {
// Byte offsets into the bytecode. Linking replaces the 20 bytes located there. // Byte offsets into the bytecode. Linking replaces the 20 bytes located there.
"Library1": [ "Library1": [
{ start: 0, length: 20 }, { "start": 0, "length": 20 },
{ start: 200, length: 20 } { "start": 200, "length": 20 }
] ]
} }
} }
}, },
// The same layout as above. // The same layout as above.
deployedBytecode: { }, "deployedBytecode": { },
// The list of function hashes // The list of function hashes
methodIdentifiers: { "methodIdentifiers": {
"delegate(address)": "5c19a95c" "delegate(address)": "5c19a95c"
}, },
// Function gas estimates // Function gas estimates
gasEstimates: { "gasEstimates": {
creation: { "creation": {
codeDepositCost: "420000", "codeDepositCost": "420000",
executionCost: "infinite", "executionCost": "infinite",
totalCost: "infinite" "totalCost": "infinite"
}, },
external: { "external": {
"delegate(address)": "25000" "delegate(address)": "25000"
}, },
internal: { "internal": {
"heavyLifting()": "infinite" "heavyLifting()": "infinite"
} }
} }
}, },
// eWASM related outputs // eWASM related outputs
ewasm: { "ewasm": {
// S-expressions format // S-expressions format
wast: "", "wast": "",
// Binary format (hex string) // Binary format (hex string)
wasm: "" "wasm": ""
} }
} }
} }