GithubHelp home page GithubHelp logo

ericxstone / sol-flattener Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 14 KB

Utility to Flatten solidity contract

License: MIT License

TypeScript 79.35% JavaScript 10.91% Solidity 9.74%
ethereum solidity utilities typescript

sol-flattener's Introduction

Sol-Flattener

This repository consists of a utility which helps to flatten Solidity file for verification.

Git Repo: https://github.com/EricxStone/sol-flattener

NPM: https://www.npmjs.com/package/@ericxstone/sol-flattener

Usage

There are two ways of using this utilities. You can either import this package to your code or use it as a cli.

To get started, you can follow below steps:

  1. Install the package

Using yarn

yarn add -D @ericxstone/sol-flattener

Using npm

npm install @ericxstone/sol-flattener --save-dev
  1. Use the package as cli
yarn flatten-sol ./contracts/yourContract.sol ./node_modules ./output/yourContract_flatten.sol
  1. Import the package in your code
import {flatternFile} from "@ericxstone/sol-flattener"

...

const resultSol: string = flatternFile(path.join(__dirname, "../contracts/yourContract.sol"), path.join(__dirname, "../node_modules"));

The CLI

Use the following command on the cli

yarn flatten-sol SOLIDITY_CONTRACT_FILE_PATH NODE_MODULES_FOLDER OUTPUT_FILE_NAME
  • SOLIDITY_CONTRACT_FILE_PATH: The file path of the solidity contract, should work with relative path and full path.
  • NODE_MODULES_FOLDER: Path to the node_module folder where you have installed the contract dependencies (e.g. openzeppelin).
  • OUTPUT_FILE_NAME: The path and file name of the flattened solidity file.

Using Import

When you import this module to your code, you can use the function as follow:

flatternFile(contractFilePath: string, libDirPath: string): string

The function takes the contract file path and path to the node_modules as argument. The flattened solidity file will be output in string format.

Development

You may also want to contribute to this library. Follow below steps to setup development environment.

  1. Clone this repository
git clone https://github.com/EricxStone/sol-flattener
  1. Install dependencies
yarn
  1. Run test
yarn test
  1. Build Cli
yarn build

License

MIT

sol-flattener's People

Contributors

ericxstone avatar

Stargazers

Ben avatar  avatar

Watchers

 avatar  avatar

Forkers

max1015070108

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.