Git Product home page Git Product logo

resolver-engine's Introduction

This is a fork of the original project developed by the Crypto-Punkers team, re-released by OpenZeppelin with additional fixes.

Single API for resolving Solidity artefacts and imports

Example usage

We provide a pre-built complete engine with sane defaults. Resolver-engine is a common importing interface for all the Ethereum inventions out there.

import { ImportFsEngine } from "@openzeppelin/resolver-engine-import-fs";

ImportFsEngine()
  .require("github:OpenZeppelin/openzeppelin-solidity/contracts/ownership/Ownable.sol#v2.1.2")
  .then(file => console.log(`Loaded url ${file.url} with source: ${file.source}`);

Otherwise, you can build your own engines, suited to your needs.

import { ResolverEngine } from "@openzeppelin/resolver-engine-core";
import { parsers, resolvers } from "@openzeppelin/resolver-engine-imports-fs";

const resolver = new ResolverEngine<string>()
  .addResolver(resolvers.FsResolver())
  .addResolver(resolvers.NodeResolver())
  .addParser(parsers.FsParser());

resolver
  .resolve("@openzeppelin-solidity/contracts/ownership/Ownable.sol")
  .then(fileSource => console.log(fileSource))
  .catch(console.error);
import { parsers, resolvers, ResolverEngine } from "@openzeppelin/resolver-engine-core";

const resolver = new ResolverEngine<string>().addResolver(resolvers.UriResolver()).addParser(parsers.UrlParser());

resolver.resolve("https://pastebin.com/raw/D8ziKX0a").then(console.log);

In the examples/ folder more granular examples can be found.

Published packages

Package NPM Description
@openzeppelin/resolver-engine-imports-fs npm link Solidity imports with filesystem support
@openzeppelin/resolver-engine-imports npm link Browser-friendly version of Solidity imports
@openzeppelin/resolver-engine-core npm link Core of the project consisting of the engine and interfaces
@openzeppelin/resolver-engine-fs npm link Filesystem abstractions, basis for future artifacts resolver and many others

Long description

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.

resolver-engine's People

Contributors

cymerrad avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar frangio avatar ritave avatar spalladino avatar squadack avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.