Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alephao/solcery
Solidity code generation tool
https://github.com/alephao/solcery
codegen ethereum foundry solidity
Last synced: 8 days ago
JSON representation
Solidity code generation tool
- Host: GitHub
- URL: https://github.com/alephao/solcery
- Owner: alephao
- License: mit
- Created: 2022-02-23T18:14:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-03T02:07:12.000Z (11 months ago)
- Last Synced: 2024-01-04T02:58:34.747Z (11 months ago)
- Topics: codegen, ethereum, foundry, solidity
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 13
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Solcery
> WIP!
Codegen tool for Solidity development.
## Installing
```bash
git clone https://github.com/alephao/solcery.git
cd solcery
pip install -r requirements.txtpython main.py
```## Commands
### `solcery errsig []`
Add error signature comments on top of each `error` declaration if it contains a `/// @dev 0x` comment on top of it.
**Example:**
Given the file `MyContract.sol`, running `solcery errsig MyContract.sol` will update the file adding the contents bellow:
```diff
contract MyContract {
- /// @dev 0x
+ /// @dev 0xbfb4ebcf
error Foo();
- /// @dev 0x
+ /// @dev 0xdd448093
error Bar(uint256 a);
}
```### `solcery errgen []`
Generates a solidity file containing sugar functions to use when expecting errors.
**Example:**
Given the file bellow `MyContract.sol` containing some error declarations, running `solcery errgen Errors.sol MyContract.sol` will generate the file `Errors.sol` you can find below.
**MyContract.sol**
```solidity
contract MyContract {
error Foo();
error Bar(uint256 a);
// ...
}
```**Errors.sol**
```solidity
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;// The code in this file was generate. Do not modify!
// solhint-disable const-name-snakecase
library Errors {
function Foo() internal pure returns (bytes memory) { return abi.encodeWithSignature("Foo()"); }
function Bar(uint256 a) internal pure returns (bytes memory) { return abi.encodeWithSignature("Bar(uint256)", a); }
}
// solhint-enable const-name-snakecase
```**Usage in a foundry test file**:
```solidity
contract MyTests {
function testSomething() public {
HEVM.expectRevert(Errors.Bar(123))
//...
}
}
```