Skip to content

๐Ÿ’  Upgradeable-first Solidity smart contract development library ๐Ÿ’ 

License

Notifications You must be signed in to change notification settings

Hotmanics/solidstate-solidity

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SolidState Solidity

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 the base contract behavior.

For example, consider a custom ERC20Base implementation:

import '@solidstate/contracts/token/ERC20/base/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', () => {
  let instance;

  beforeEach(async () => {
    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', () => {
  // custom tests
});

Development

Install dependencies via Yarn:

yarn install

Setup Husky to format code on commit:

yarn prepare

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

About

๐Ÿ’  Upgradeable-first Solidity smart contract development library ๐Ÿ’ 

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 56.6%
  • Solidity 43.4%