GithubHelp home page GithubHelp logo

tokenchain / solidity-flatliner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blockcatio/solidity-flattener

0.0 1.0 0.0 66 KB

A python utility to flatten Solidity code with imports into a single file.

License: MIT License

Python 12.17% Shell 1.45% Solidity 86.38%

solidity-flatliner's Introduction

Solidity Flatliner

Unfolds all local imports in a solidity file to generate a flat solidity file.

Introduction

Manually combining all imports in a solidity file when verifying your contract source on Etherscan is time-consuming and cumbersome. This tool automatically traverses the dependency graph of imports and combines them in the correct order, which is ready to be pasted into the contract verifier.

NOTE: This tool won't work with imports that are aliased (i.e. import "./foo.sol" as bar; )

Features

  • support external library folder destination
  • support output folder name
  • auto remove redundant license place and solidity version code
  • auto remove redundant contract / interface / abstract contract / library
  • added support safety line

Installation

There are no requirements for this tool.

pip3 install solflatliner

or if you want to get the upgrade

sudo pip3 install solflatliner --upgrade

Create bin file for easy execution

#!/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
# -*- coding: utf-8 -*-
import re
import sys
from solflatliner.cmd import cli
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(cli())

Usage

usage: solflatliner [-h] [-o *.sol] *.sol *.*.*

Unfolds all local imports in a solidity file to generate a flat solidity file.
Put the output file into out/ folders.

positional arguments:
  *.sol                 Target filename with imports
  *.*.*                 Solidity compiler version e.g. 0.4.24

optional arguments:
  -h, --help            Show this help message and exit
  -o *.sol, --output *.sol
                        Output filename (default: flat.sol)
  -f, --ofolder         The output folder (default: verify)
  -lib, --library       Selection of library folder from the execution path. (default: lib)
  -l, --license         The license identifier from https://spdx.org/licenses/ (default: AGPL-3.0)

Example

solu contract-with-imports.sol 0.4.24

It will output flat.sol (default output filename) with solidity version 0.4.24 in verify/ folder.

solflatliner contract-with-imports.sol 0.4.20 --output contract-flat.sol

It will output contract-flat.sol with solidity version 0.4.20 in verify/ folder.

License

MIT License (2022), Jun-You Liu, Heskemo

solidity-flatliner's People

Contributors

jjhesk avatar stickerpants avatar t4n6a1ka avatar

Watchers

James Cloos 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.