Giter VIP home page Giter VIP logo

solidstate-solidity's Introduction

SolidState Solidity

A version of this library has been audited by Hacken. More details are available in the report.

SolidState is an upgradeable-first Solidity smart contract development library.

It consists of the following packages:

package description ๐Ÿ“•
@solidstate/abi contract ABIs ๐Ÿ“–
@solidstate/contracts core contracts ๐Ÿ“–
@solidstate/library functions for interacting with and validating contracts ๐Ÿ“–
@solidstate/spec portable tests which may be run against third-party implementations of core contracts ๐Ÿ“–

Contracts

All contracts are designed to either be deployed through the standard constructor method, or referenced by a proxy. To this end, the diamond storage pattern is employed exclusively.

Spec

Where possible, automated tests are designed to be imported by repositories which make use of the SolidState contracts and run against any derived contracts. This is to help prevent unintended changes to to the base contract behavior.

For example, consider a custom ERC20Base implementation:

import '@solidstate/contracts/token/ERC20/ERC20Base.sol';

contract CustomToken is ERC20Base {
  // custom code...
}

Rather than rewrite the ERC20Base tests or assume that all core behavior remains untouched, one can import the included tests and run them against the custom implementation:

describe('CustomToken', function () {
  let instance;

  beforeEach(async function () {
    const factory = await ethers.getContractFactory('CustomToken');
    instance = await factory.deploy();
    await instance.deployed();
  });

  describeBehaviorOfERC20Base(
    {
      deploy: () => instance,
    },
    [],
  );

  // custom tests...
});

If parts of the base implementation are changed intentionally, tests can be selectively skipped:

describeBehaviorOfERC20Base(
  {
    deploy: () => instance,
  },
  ['#balanceOf'],
);

describe('#balanceOf', function () {
  // custom tests
});

Development

Install dependencies via Yarn:

yarn install

Setup Husky to format code on commit:

yarn prepare

Link local packages and install remaining dependencies via Lerna:

yarn run lerna bootstrap

Compile contracts via Hardhat:

yarn run hardhat compile

Automatically upgrade dependencies with yarn-up:

yarn upgrade-dependencies

Testing

Test contracts with Hardhat and generate gas report using hardhat-gas-reporter:

yarn run hardhat test

Generate a code coverage report using solidity-coverage:

yarn run hardhat coverage

Publication

Publish packages via Lerna:

yarn lerna-publish

Sponsors

premia.finance

frexa.io

solidstate-solidity's People

Contributors

antoncoding avatar itsnickbarry avatar julesgoullee avatar lumyo avatar noudaimon avatar zimmah 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.