Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: try new ci #68

Merged
merged 12 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 6 additions & 43 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Test

concurrency:
group: ${{ github.workflow }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
Expand All @@ -11,46 +11,9 @@ on:
- main

jobs:
lint:
uses: bgd-labs/github-workflows/.github/workflows/foundry-lint-prettier.yml@main
test:
name: Foundry build n test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: bgd-labs/action-rpc-env@main
with:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}

# we simply use foundry zk for all jobs in this repo
- name: Run Foundry setup
uses: bgd-labs/github-workflows/.github/actions/foundry-setup@main
with:
ZKSYNC: 'true'

- name: Run Forge tests
id: test
uses: bgd-labs/github-workflows/.github/actions/foundry-test@main

- name: Run ZK tests
id: zktest
uses: bgd-labs/github-workflows/.github/actions/foundry-test@main
with:
ZKSYNC: true

- name: Run Gas report
uses: bgd-labs/github-workflows/.github/actions/foundry-gas-report@main

- name: Run Lcov report
uses: bgd-labs/github-workflows/.github/actions/foundry-lcov-report@main

- name: Run Forge tests
uses: bgd-labs/github-workflows/.github/actions/comment-artifact@main

# we let failing tests pass so we can log them in the comment, still we want the ci to fail
- name: Post test
if: ${{ steps.test.outputs.testStatus != 0 || steps.zktest.outputs.testStatus != 0 }}
run: |
echo "tests failed"
exit 1
uses: bgd-labs/github-workflows/.github/workflows/foundry-test.yml@main
test-zk:
uses: bgd-labs/github-workflows/.github/workflows/foundry-test-zk.yml@main
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ out/
.env
broadcast
node_modules
package-lock.json
yarn.lock
zkout/
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lib
broadcast
cache
out
node_modules
zkout
48 changes: 23 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,31 @@ All notable changes to this project will be documented in this file. See [standa

## 1.1.0 (2022-11-15)


### Features

* add ierc20 with permit ([1093eaa](https://github.com/bgd-labs/solidity-utils/commit/1093eaa8c7ee3a605d1935da3b115e97960a61aa))
* added emergency consumer logic ([23a0c85](https://github.com/bgd-labs/solidity-utils/commit/23a0c855ac8a599b0bc3ea34fcebb134994b6aa2))
* added IERC20 and SafeERC20 oz contracts ([ba4d85f](https://github.com/bgd-labs/solidity-utils/commit/ba4d85f14cc2cf94e403c56395cda5e705877b38))
* added IERC20Metadata interface ([3afcba2](https://github.com/bgd-labs/solidity-utils/commit/3afcba2a81dc916f18c3411eb0329ee40d6b5f41))
* added test workflow ([03028a7](https://github.com/bgd-labs/solidity-utils/commit/03028a7b6fc1b94eeafbb828bbcff23b9266542d))
* deploy on npm ([#11](https://github.com/bgd-labs/solidity-utils/issues/11)) ([0bece64](https://github.com/bgd-labs/solidity-utils/commit/0bece649ec134950634b80b255772a0eacab7746))

- add ierc20 with permit ([1093eaa](https://github.com/bgd-labs/solidity-utils/commit/1093eaa8c7ee3a605d1935da3b115e97960a61aa))
- added emergency consumer logic ([23a0c85](https://github.com/bgd-labs/solidity-utils/commit/23a0c855ac8a599b0bc3ea34fcebb134994b6aa2))
- added IERC20 and SafeERC20 oz contracts ([ba4d85f](https://github.com/bgd-labs/solidity-utils/commit/ba4d85f14cc2cf94e403c56395cda5e705877b38))
- added IERC20Metadata interface ([3afcba2](https://github.com/bgd-labs/solidity-utils/commit/3afcba2a81dc916f18c3411eb0329ee40d6b5f41))
- added test workflow ([03028a7](https://github.com/bgd-labs/solidity-utils/commit/03028a7b6fc1b94eeafbb828bbcff23b9266542d))
- deploy on npm ([#11](https://github.com/bgd-labs/solidity-utils/issues/11)) ([0bece64](https://github.com/bgd-labs/solidity-utils/commit/0bece649ec134950634b80b255772a0eacab7746))

### Bug Fixes

* add 20 to filename to be consistent ([0c5a8b8](https://github.com/bgd-labs/solidity-utils/commit/0c5a8b894b6bd9e434c9e8b5b355469c6c306228))
* add indexed to few fields on events ([7a6fd00](https://github.com/bgd-labs/solidity-utils/commit/7a6fd00a06def5fdbc33cb0759efd18f5865500a))
* add lockfile ([6d07157](https://github.com/bgd-labs/solidity-utils/commit/6d071575f3085c4f45d084429a6bced227a155c6))
* add natspec for cl oracle interface ([ee1fcfd](https://github.com/bgd-labs/solidity-utils/commit/ee1fcfde4b47426e2370bbc54ce3e365b1cae7bb))
* added deterministic method to create proxy, also creating admin and transfering ownership of deployed admin to specified address ([37a0f96](https://github.com/bgd-labs/solidity-utils/commit/37a0f967166bbe893a810c7b2014c939e1ad72ac))
* added deterministic proxy admin ([23892f3](https://github.com/bgd-labs/solidity-utils/commit/23892f362de15e1cad1166fd881b159fa463bd15))
* added predictive proxy admin deployment ([b18f754](https://github.com/bgd-labs/solidity-utils/commit/b18f754af61d65ab6951dfb4f5418ff67e0f740e))
* added solved event ([82832ba](https://github.com/bgd-labs/solidity-utils/commit/82832baf8cc3d289a69dba57039a7f7fc38902c4))
* **ci:** better triggers ([c097977](https://github.com/bgd-labs/solidity-utils/commit/c09797758e76103f41840c8ecc7acb5e142bfa18))
* fixed imports ([f3bbb92](https://github.com/bgd-labs/solidity-utils/commit/f3bbb92d2420ebadcfbc9bf68ec239849f52e0ac))
* removed comments ([eca9e94](https://github.com/bgd-labs/solidity-utils/commit/eca9e94ba34c53743ab650255787bddf1cb27316))
* removed highly recomended ([394dbce](https://github.com/bgd-labs/solidity-utils/commit/394dbce5f078bb363deb6617469a285f090a2e31))
* removed highly recomended from all comments ([3a5bdf3](https://github.com/bgd-labs/solidity-utils/commit/3a5bdf34dc764136f2154993482877574dd26805))
* removed mock contract ([e266d70](https://github.com/bgd-labs/solidity-utils/commit/e266d708c969f59ebff052156692ce058819c0e3))
* updated docs ([d07d705](https://github.com/bgd-labs/solidity-utils/commit/d07d705d83d7bae0511b53b46fa1b1bbca0c22cb))
* updated tests ([8570de9](https://github.com/bgd-labs/solidity-utils/commit/8570de9e6aa7868ea277dc1627da745c3add4e10))
* updated with virtual update method, and moved solve emergency to modifier ([1a86eb3](https://github.com/bgd-labs/solidity-utils/commit/1a86eb3fcc65e267ff67bb72888eb65a35f83542))
- add 20 to filename to be consistent ([0c5a8b8](https://github.com/bgd-labs/solidity-utils/commit/0c5a8b894b6bd9e434c9e8b5b355469c6c306228))
- add indexed to few fields on events ([7a6fd00](https://github.com/bgd-labs/solidity-utils/commit/7a6fd00a06def5fdbc33cb0759efd18f5865500a))
- add lockfile ([6d07157](https://github.com/bgd-labs/solidity-utils/commit/6d071575f3085c4f45d084429a6bced227a155c6))
- add natspec for cl oracle interface ([ee1fcfd](https://github.com/bgd-labs/solidity-utils/commit/ee1fcfde4b47426e2370bbc54ce3e365b1cae7bb))
- added deterministic method to create proxy, also creating admin and transfering ownership of deployed admin to specified address ([37a0f96](https://github.com/bgd-labs/solidity-utils/commit/37a0f967166bbe893a810c7b2014c939e1ad72ac))
- added deterministic proxy admin ([23892f3](https://github.com/bgd-labs/solidity-utils/commit/23892f362de15e1cad1166fd881b159fa463bd15))
- added predictive proxy admin deployment ([b18f754](https://github.com/bgd-labs/solidity-utils/commit/b18f754af61d65ab6951dfb4f5418ff67e0f740e))
- added solved event ([82832ba](https://github.com/bgd-labs/solidity-utils/commit/82832baf8cc3d289a69dba57039a7f7fc38902c4))
- **ci:** better triggers ([c097977](https://github.com/bgd-labs/solidity-utils/commit/c09797758e76103f41840c8ecc7acb5e142bfa18))
- fixed imports ([f3bbb92](https://github.com/bgd-labs/solidity-utils/commit/f3bbb92d2420ebadcfbc9bf68ec239849f52e0ac))
- removed comments ([eca9e94](https://github.com/bgd-labs/solidity-utils/commit/eca9e94ba34c53743ab650255787bddf1cb27316))
- removed highly recomended ([394dbce](https://github.com/bgd-labs/solidity-utils/commit/394dbce5f078bb363deb6617469a285f090a2e31))
- removed highly recomended from all comments ([3a5bdf3](https://github.com/bgd-labs/solidity-utils/commit/3a5bdf34dc764136f2154993482877574dd26805))
- removed mock contract ([e266d70](https://github.com/bgd-labs/solidity-utils/commit/e266d708c969f59ebff052156692ce058819c0e3))
- updated docs ([d07d705](https://github.com/bgd-labs/solidity-utils/commit/d07d705d83d7bae0511b53b46fa1b1bbca0c22cb))
- updated tests ([8570de9](https://github.com/bgd-labs/solidity-utils/commit/8570de9e6aa7868ea277dc1627da745c3add4e10))
- updated with virtual update method, and moved solve emergency to modifier ([1a86eb3](https://github.com/bgd-labs/solidity-utils/commit/1a86eb3fcc65e267ff67bb72888eb65a35f83542))
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

Common contracts we use almost everywhere


## Create3

Contracts to deploy a Create3 Factory which so that contract addresses can be predicted without influence from
constructor arguments.

These contracts where modified from:

- Create3 lib:
Modified from https://github.com/0xsequence/create3/blob/5a4a152e6be4e0ecfbbbe546992a5aaa43a4c1b0/contracts/Create3.sol by Agustin Aguilar <[email protected]>
Modified from https://github.com/0xsequence/create3/blob/5a4a152e6be4e0ecfbbbe546992a5aaa43a4c1b0/contracts/Create3.sol by Agustin Aguilar <[email protected]>
- Modifications consist on:
- removal of named returns
- moved logic of addressOf method to addressOfWithPreDeployedFactory so that factory address can be abstracted
- Create3Factory:
Modified from https://github.com/lifinance/create3-factory/blob/main/src/CREATE3Factory.sol
Modified from https://github.com/lifinance/create3-factory/blob/main/src/CREATE3Factory.sol
- Modifications consist on:
- removal of named returns
- changed name of getDeployed for predictAddress
Expand All @@ -29,7 +30,9 @@ as expected.
- Tests specific for ZkSync network can be found [here](test-zksync)

To build and test the contracts use `FOUNDRY_PROFILE=zksync` and the flag `--zksync`

- Example:

```solidity
FOUNDRY_PROFILE=zksync forge test -vvv --zksync
```
66 changes: 66 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"test": "tests"
},
"scripts": {
"lint": "prettier ./",
"lint:fix": "npm run lint -- --write",
"lint": "prettier . --check",
"lint:fix": "prettier . --write",
"ci:publish": "npm publish --access=public"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion script/DeployCreate3Factory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.0;

import {Script} from 'forge-std/Script.sol';
import {TransparentProxyFactory} from '../src/contracts/transparent-proxy/TransparentProxyFactory.sol';
import {Create3Factory} from "../src/contracts/create3/Create3Factory.sol";
import {Create3Factory} from '../src/contracts/create3/Create3Factory.sol';

contract DeployCreate3Factory is Script {
bytes32 public constant CREATE3_FACTORY_SALT = keccak256(bytes('Create3 Factory'));
Expand Down
28 changes: 5 additions & 23 deletions src/contracts/create3/Create3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.0;
/**
* @title A library for deploying contracts EIP-3171 style.
* @author BGD Labs
*/
*/
library Create3 {
error ErrorCreatingProxy();
error ErrorCreatingContract();
Expand Down Expand Up @@ -59,10 +59,7 @@ library Create3 {
* @param creationCode Creation code (constructor) of the contract to be deployed, this value doesn't affect the resulting address
* @return address of the deployed contract, reverts on error
*/
function create3(
bytes32 salt,
bytes memory creationCode
) internal returns (address) {
function create3(bytes32 salt, bytes memory creationCode) internal returns (address) {
return create3(salt, creationCode, 0);
}

Expand All @@ -88,12 +85,7 @@ library Create3 {
// Create CREATE2 proxy
address proxy;
assembly {
proxy := create2(
value,
add(proxyCreationCode, 32),
mload(proxyCreationCode),
salt
)
proxy := create2(value, add(proxyCreationCode, 32), mload(proxyCreationCode), salt)
}
if (proxy == address(0)) revert ErrorCreatingProxy();

Expand Down Expand Up @@ -128,22 +120,12 @@ library Create3 {
uint160(
uint256(
keccak256(
abi.encodePacked(
hex'ff',
preDeployedFactory,
salt,
KECCAK256_PROXY_CHILD_BYTECODE
)
abi.encodePacked(hex'ff', preDeployedFactory, salt, KECCAK256_PROXY_CHILD_BYTECODE)
)
)
)
);

return
address(
uint160(
uint256(keccak256(abi.encodePacked(hex'd6_94', proxy, hex'01')))
)
);
return address(uint160(uint256(keccak256(abi.encodePacked(hex'd6_94', proxy, hex'01')))));
}
}
18 changes: 6 additions & 12 deletions src/contracts/create3/Create3Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,20 @@ import {Create3} from './Create3.sol';
import {ICreate3Factory} from './interfaces/ICreate3Factory.sol';

/**
* @title Factory for deploying contracts to deterministic addresses via Create3
* @author BGD Labs
* @notice Enables deploying contracts using CREATE3. Each deployer (msg.sender) has its own namespace for deployed addresses.
*/
* @title Factory for deploying contracts to deterministic addresses via Create3
* @author BGD Labs
* @notice Enables deploying contracts using CREATE3. Each deployer (msg.sender) has its own namespace for deployed addresses.
*/
contract Create3Factory is ICreate3Factory {
/// @inheritdoc ICreate3Factory
function create(
bytes32 salt,
bytes memory creationCode
) external payable returns (address) {
function create(bytes32 salt, bytes memory creationCode) external payable returns (address) {
// hash salt with the deployer address to give each deployer its own namespace
salt = keccak256(abi.encodePacked(msg.sender, salt));
return Create3.create3(salt, creationCode, msg.value);
}

/// @inheritdoc ICreate3Factory
function predictAddress(
address deployer,
bytes32 salt
) external view returns (address) {
function predictAddress(address deployer, bytes32 salt) external view returns (address) {
// hash salt with the deployer address to give each deployer its own namespace
salt = keccak256(abi.encodePacked(deployer, salt));
return Create3.addressOf(salt);
Expand Down
10 changes: 2 additions & 8 deletions src/contracts/create3/interfaces/ICreate3Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ interface ICreate3Factory {
* @param creationCode The creation code of the contract to deploy
* @return The address of the deployed contract
*/
function create(
bytes32 salt,
bytes memory creationCode
) external payable returns (address);
function create(bytes32 salt, bytes memory creationCode) external payable returns (address);

/**
* @notice Predicts the address of a deployed contract
Expand All @@ -27,8 +24,5 @@ interface ICreate3Factory {
* @param salt The deployer-specific salt for determining the deployed contract's address
* @return The address of the contract that will be deployed
*/
function predictAddress(
address deployer,
bytes32 salt
) external view returns (address);
function predictAddress(address deployer, bytes32 salt) external view returns (address);
}
1 change: 0 additions & 1 deletion src/contracts/utils/Rescuable721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {Rescuable} from './Rescuable.sol';
* @notice abstract contract that extend Rescuable with the methods to rescue ERC721 tokens from a contract
*/
abstract contract Rescuable721 is Rescuable, IRescuable721 {

/// @inheritdoc IRescuable721
function emergency721TokenTransfer(
address erc721Token,
Expand Down
Loading
Loading