Giter Site home page Giter Site logo

zemse / hardhat-storage-layout-changes Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 97 KB

๐Ÿ’พ Check for storage layout changes

License: MIT License

TypeScript 97.37% Solidity 2.63%
ethereum hardhat hardhat-plugin smart-contracts storage-layout upgradable-contracts

hardhat-storage-layout-changes's Introduction

hardhat-storage-layout-changes

Hardhat plugin to check for storage layout changes

What

When working with complex and upgradable contracts, it can be difficult to manually see whether some solidity changes broke the storage layout or not. A mistake can cause undefined behavior in deployed contracts. This plugin aims to help notice any storage layout breakings while dev works on solidity changes.

Installation

npm install hardhat-storage-layout-changes

Import the plugin in your hardhat.config.js:

require("hardhat-storage-layout-changes");

Or if you are using TypeScript, in your hardhat.config.ts:

import "hardhat-storage-layout-changes";

Tasks

This plugin adds the storage-layout task to Hardhat:

Usage: hardhat [GLOBAL OPTIONS] storage-layout [--check] [--update]

OPTIONS:

  --check       Checks if storage layout has changed
  --update      Updates storage layout artifact

Configuration

This plugin extends the HardhatUserConfig's ProjectPathsUserConfig object with an optional storageLayouts field and also adds a storageLayoutConfig.

This is an example of how to set it:

module.exports = {
  paths: {
    storageLayouts: ".storage-layouts",
  },
  storageLayoutConfig: {
    contracts: ["Pool"],
    fullPath: false
  };
};

Usage

npx hardhat storage-layout --check

Contract: Pool
   "accounts": at same location
         "user": at same location
         "balance": at same location
   "owner": changed slot from 1 to 2
   "lastUpdate": found new storage entry at slot 1 offset 0
   "owner": found new storage entry at slot 2 offset 0

Error: Storage Layout Changed. If this was intentional, please update the storage layout files using "npx hardhat storage-layout --update".

npx hardhat storage-layout --update

Contract: Pool
updating Pool.json

hardhat-storage-layout-changes's People

Contributors

zemse avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.