Giter Site home page Giter Site logo

declar's Introduction

A simple minimizer for Clarity

Declar, somehting to make your Clarity contracts less clear, but smaller, so it will cost less to deploy. Consider not using to make your deployed contracts less nebulous, or publish the non minimized version. Many people will forever thank you!

Rules

This is work in progress, as it currently implements removing comments and compressing spaces however the basis to do smarter things is already there as the full syntactic tree is available and will make implementing the rest fairly straightforward.

It can already shave 40% from the swapr contract, which is the biggest Clarity contract I had available

  • remove comments
  • remove unnecessary blank space
  • do not rename define-public and define-read-only function names
  • rename constants
  • rename parameters
  • rename variable names in let
  • rename define-data-var variable names
  • remove unused constants
  • remove unused define-private methods
  • do not rename all strings and numbers
  • do not rename principals
  • do not rename tuple keys as they might be returned (unless can figure out this is the case)
  • include a way to add the url of the non minimized contract (using an url shortener too?)

How to run declar

You just need to pass the contract path, and the path for outputing the minimized contract

For example:

node declar.js contracts/my-token.clar contracts/my-token-min.clar

Other plans

  • make it a webapp where you can paste your clarity contract
  • add options to control how aggressive the minization shoul be, i.e. just spaces and comments, rename internal names, rename variables, ...
  • tests will be included

Bonuses included

The Clarity parser, implemented in plain javascript, should be usable as a standalone module. npm version should be available soon. For now, you can require using the github url using

npm i github:psq/declar

Report issues

If you try it and the minized contract does not work or does not look correct, submit a PR, or create an issue. Thanks!

declar's People

Contributors

psq avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.