Giter Site home page Giter Site logo

gmh5225 / vscode-huff Goto Github PK

View Code? Open in Web Editor NEW

This project forked from huff-language/vscode-huff

0.0 0.0 0.0 895 KB

An interactive VSCode extension that enables developers to visualize, debug, and break down Huff contracts.

License: MIT License

JavaScript 95.93% CSS 4.07%

vscode-huff's Introduction

VSCode Huff

NOTE: Debugger requires path installations of huffc and hevm from dapptools before use.

A mirror version of this repository can be found on open-vsx

Features at a glances:

  • Advanced language support
  • Syntax Highlighting
  • Hover cards detailing gas usage
  • Code Generation

Hevm Powered Debugging

Step through execution of your contracts from external calls, or even individual macros. Manipulate the stack inputs when your macro starts and even override storage slots. Star power your productivity. This is particularly useful for debugging your macros individually. For more e2e debugging, the foundry debugger is an excellent tool.

How it works: Open up any .huff file and press Load Interface to prepare external functions, enter in your calldata parameters and hit debug to get started.

function debugging window

The example above is for an erc721 mint function, entering from the function debugger will allow you to step through execution from the MAIN entrypoint. To select another function, click the drop down and select another function! The drop down will be populated with functions that are defined at the top of the file that you are currently debugging.

Notice - Relevant to WSL users To get the extension to run in wsl there is a workaround that you will have to make. Unfortunately, vscode extensions do not run in the same environment as your wsl shell so do not have access to the same path (even when mounted with wsl-remote). If the extension detects that you are working in a remote code space it will attempt to execute huffc and hevm within the wsl shell. The wsl api does not run the ~/.bashrc script (the file which huffup adds to the path), therefore to use this extension in wsl you will have to copy the following into your ~/.profile.

if [ -d  "$HOME/.huff/bin" ]; then
    PATH="$HOME/.huff/bin:$PATH"
fi

We will look to address this limitation in further releases of huffup.

Macro Debugging

Macro debugging is the tool's most useful feature. Clicking Load Macros will load the macros of the currently open file. If the macro has no takes arguments then the window will look like this:

function debugging window

You can choose to add arbitrary hex calldata to the debugger instance by selecting the With Calldata checkbox.

Defining takes parameters:

function debugging window

If the selected macro has takes(n) then n windows will appear to allow setting of the stack before execution.

Overriding storage:

function debugging window

Storage Overrides allows you to test your macro with arbitrary overrides for specified storage slots! To use, select the Storage Overrides checkbox, then add as many slots as you require. Upon execution, the slots will be set to the values that you have defined. You can quickly toggle this feature off by unselecting the Storage Overrides checkbox.

Code Generation

Switch table generation
Generate the MAIN macro switch table with jumps from just the interface definition. No more visiting keccak online or using cast sig xxx to copy function selectors into your code. Just write the interface and let us handle the rest.

Usage: commandPallete -> Huff: Generate MAIN() Switch Table

Event signature generation Similarly to switch table generation above. Forget about calculating the keccak of you event topics yourself.

Usage: commandPallete -> Huff: Generate interface signature from interface

Hover Cards

Hovering the cursor over an opcode will explain what operation it performs, the minimum amount of gas it uses, as well as a link to evm.codes to read more about it.

Currently not supported

[] Constructor Arguments.

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.