Oighty / quabi

Solidity library to query contract ABI in Foundry tests and scripts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quabi

A Solidity library for querying contract ABI data using Foundry's ffi cheatcode in Forge Tests and Scripts.

Roadmap

  • Function selectors
  • Functions selectors that have a specific modifier
  • Errors
  • Events
  • State Variables
  • Others?

Getting Started

Install in your forge project

forge install https://github.com/Oighty/quabi

Import Quabi and use it in your tests

import {Quabi} from "lib/quabi/src/Quabi.sol";
...
contract MyTest is Test {
   
  ContractToTest internal testme;
  ...
  
  bytes4[] memory selectors = Quabi.getFunctions(type(ContractToTest).name);
  bytes4[] memory authSelectors = Quabi.getFunctionsWithModifier(type(ContractToTest).name, "requiresAuth");
  
  ...
  
}

Run your test file with the --ffi flag

forge test --ffi --match-contract MyTest

Acknowledgement

This project was conceived while developing some testing utilities for OlympusDAO.

The project is inspired by Surl and leveraged some of their ideas on preparing shell commands within Solidity.

About

Solidity library to query contract ABI in Foundry tests and scripts

License:GNU Affero General Public License v3.0


Languages

Language:Solidity 74.1%Language:Shell 25.9%