Git Product home page Git Product logo

contracts-libs's Introduction

@looksrare/contracts-libs

Tests License: MIT

This repository contains a set of Solidity contracts that can be used across contracts for purposes such as verifying signatures, protecting contracts against reentrancy attacks, low-level call functions, and a library for managing the ownership of a contract.

It also contains generic contract interfaces (for EIP/ERC) that can be used.

Installation

# Yarn
yarn add @looksrare/contracts-libs

# NPM
npm install @looksrare/contracts-libs

NPM package

The NPM package contains the following:

  • Solidity smart contracts (".sol")
  • ABIs (".json")

Current contracts

Name Description Type Latest version
OwnableTwoSteps Contract for managing ownership of a smart contract. The transfer of ownership is done in a 2-step process. Contract 2.5.0
SignatureCheckerCalldata Contract for verifying the validity of a (calldata) signature for EOA (64-byte, 65-byte signatures) and EIP-1271. Contract 3.0.0
SignatureCheckerMemory Contract for verifying the validity of a (memory) signature for EOA (64-byte, 65-byte signatures) and EIP-1271. Contract 3.0.0
ReentrancyGuard Contract with a modifier to prevent reentrancy calls. Contract 2.4.4
PackedReentrancyGuard Contract with a modifier to prevent reentrancy calls. Adapted from ReentrancyGuard. Contract 2.5.1
LowLevelETHTransfer Low-level call function to transfer ETH Contract 2.4.4
LowLevelETHReturnETHIfAny Low-level call function to return all ETH left Contract 2.4.4
LowLevelETHReturnETHIfAnyExceptOneWei Low-level call function to return all ETH left except one wei Contract 2.4.4
LowLevelWETH Low-level call functions to transfer ETH with an option to wrap to WETH if the original ETH transfer fails within a gas limit Contract 2.4.4
LowLevelERC20Approve Low-level call functions for ERC20 approve functions Contract 2.4.4
LowLevelERC20Transfer Low-level call functions for ERC20 transfer functions Contract 2.4.4
LowLevelERC721Transfer Low-level call functions for ERC721 functions Contract 2.4.4
LowLevelERC1155Transfer Low-level call functions for ERC1155 functions Contract 2.4.4

About this repo

Structure

It is a hybrid Hardhat repo that also requires Foundry to run Solidity tests powered by the ds-test library.

To install Foundry, please follow the instructions here.

Run tests

  • Solidity tests are included in the foundry folder in the test folder.

Example of Foundry/Forge commands

forge build
forge test
forge test -vv
forge tree

Example of other commands

npx eslint '**/*.{js,ts}'
npx eslint '**/*.{js,ts}' --fix
npx prettier '**/*.{json,sol,md}' --check
npx prettier '**/*.{json,sol,md}' --write
npx solhint 'contracts/**/*.sol'
npx solhint 'contracts/**/*.sol' --fix

Coverage

It is required to install lcov.

brew install lcov

To run the coverage report, the below command can be executed.

forge coverage --report lcov
LCOV_EXCLUDE=("test/*" "contracts/interfaces/*" "contracts/errors/*.sol")
echo $LCOV_EXCLUDE | xargs lcov --output-file lcov-filtered.info --remove lcov.info
genhtml lcov-filtered.info --output-directory out
open out/index.html

contracts-libs's People

Contributors

0xhiroshi avatar 0xjurassicpunk avatar 0xshisui avatar dependabot[bot] 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.