Skip to content

VIP: vyper-json #1520

@alcuadrado

Description

@alcuadrado

Simple Summary

Vyper should provide an interface for non-python-based tools to use.

Abstract

This VIP proposes the addition of another CLI tool: vyper-json. This tool will compile contracts, generating a structured JSON output containing everything needed to integrate Vyper, including errors.

Motivation

See #1492

Specification

This section describes the input and output interfaces of vyper-json.

Input description

vyper-json doesn't need any special input apart from a list of files to compile.

An example execution could be vyper-json path/to/contract1.vy path/to/other.vy

Output description

vyper-json outputs a single JSON object with one key of type PATH per input
file, associated with an object of type OUTPUT.

PATH values should be absolute paths. If symlinks are present, they should not
be resolved, keeping the path closer to the user's input.

OUTPUT values are objects with the following properties:

  • files: An array of PATH values containing all the source files used to compile this contract. This is useful to implement things like cache, watchers, etc.
  • errors: An array of ERROR objects. One per each fatal compilation error. This array must be empty if the compilation succeeded.
  • warnings: An array of ERROR objects. One per each compilation warning. This array must be empty if no warning is emitted.
  • output: An object containing bytecode, bytecode_runtime, abi, source_map, method_identifiers as returned by vyper when format combined_json is used. This value should be null if the compilation failed.

ERROR objects must contain the following properties:

  • file: A PATH value pointing to the file where the warning or error originated.
  • line: The error/warning's line number.
  • column: The error/warning's line column.
  • message: An explanation of the warning/error.

Example

Executing vyper-json path/to/contract1.vy path/to/other.vy

should output something like:

{
  "/absolute/path/to/contract1.vy": {
    "files": ["/absolute/path/to/contract1.vy", "/absolute/path/to/interface.vy"],
    "errors": [
      {
        "file": "/absolute/path/to/contract1.vy",
        "line": 1,
        "column": 20,
        "message": "A fatal error"
      }
    ],
    "warnings": [],
    "output": null
  },
  "/absolute/path/to/other.vy": {
    "files": ["/absolute/path/to/other.vy", "/path/path/to/ERC20.vy"],
    "errors": [],
    "warnings": [
      {
        "file": "/absolute/path/to/other.vy",
        "line": 2,
        "column": 30,
        "message": "A warning"
      }
    ],
    "output": { /* same as combined_json */ }
  }
}

Backwards Compatibility

This VIP proposes the introduction of a new command-line tool, which should have no impact on the existing one.

Dependencies

This VIP has no dependencies.

Copyright

Copyright and related rights waived via CC0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions