Single API for resolving Solidity artefacts and imports
Switch branches/tags
Nothing to show
Clone or download
Latest commit 397600c Nov 5, 2018

README.md

Single API for resolving Solidity artefacts and imports

Chat on telegram

Usage

We provide a pre-built complete engine with sane defaults.

import { SolidityImportResolver } from "resolver-engine";

const resolver = SolidityImportResolver();

resolver
  .require("@zeppelin-solidity/contracts/Ownable.sol")
  .then(console.log)
  .catch(console.error);

Otherwise, you can build your own engines

import { ResolverEngine, NodeResolver, FsResolver, FsParser } from "resolver-engine";

const resolver = new ResolverEngine<string>()
  .addResolver(FsResolver("contracts/"))
  .addResolver(NodeResolver())
  .addParser(FsParser());

resolver
  .resolve("@zeppelin-solidity/contracts/Ownable.sol")
  .then(console.log)
  .catch(console.error);

In the examples/ folder more granular examples can be found

Why

Each Solidity framework has different logic concerning Solidity import statements as well as creating different format of artifacts. This becomes problematic when target developers want to use multiple tools on the same codebase.

For example, Truffle artifacts are not compatible with 0xProject's solidity coverage tooling. Documentation generation doesn't support NPM-like Solidity imports which are supported by both Truffle and 0x, at the same time, neither of which support github import statements as the ones Remix does.

The goal of this library is to provide tooling for framework developers so that they can implement multiple artifacts and solidity importing with ease, as well as providing sane defaults that would standarize the functionallity.