Skip to content

Commit

Permalink
fix: added correct profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
sendra committed Jul 25, 2024
1 parent f3db00a commit f4168c0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ Modified from https://github.com/lifinance/create3-factory/blob/main/src/CREATE3
- removal of named returns
- changed name of getDeployed for predictAddress
- usage of create3 lib by Agustin Aguilar instead of solmate

## ZkSync

As ZkSync network requires the use of a [forked](https://github.com/matter-labs/foundry-zksync) version of foundry we have created different profiles so that they can run
as expected.

- Contracts specific for ZkSync network can be found [here](src-zksync)
- 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
```
8 changes: 6 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ out = 'out'
libs = ['lib']
remappings = []

[profile.default.zksync]
[profile.zksync]
src = 'src-zksync'
test = 'test-sksync'
test = 'test-zksync'
libs = ['lib']
solc="0.8.19"

[profile.zksync.zksync]
fallback_oz = true
mode = "3"
zksolc="1.4.1"


# See more config options https://github.com/gakonst/foundry/tree/master/config
[rpc_endpoints]
ethereum = "${RPC_MAINNET}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.0;

import {IOwnable} from '../../../src/contracts/transparent-proxy/interfaces/IOwnable.sol';
import {ITransparentProxyFactoryZkSync} from "./interfaces/ITransparentProxyFactoryZkSync.sol";
import {ITransparentProxyFactoryZkSync} from './interfaces/ITransparentProxyFactoryZkSync.sol';
import {TransparentUpgradeableProxy} from '../../../src/contracts/transparent-proxy/TransparentUpgradeableProxy.sol';
import {ProxyAdmin} from '../../../src/contracts/transparent-proxy/ProxyAdmin.sol';

Expand All @@ -13,26 +13,29 @@ import {ProxyAdmin} from '../../../src/contracts/transparent-proxy/ProxyAdmin.so
* @dev `create()` and `createDeterministic()` are not unified for clearer interface, and at the same
* time allowing `createDeterministic()` with salt == 0
* @dev Highly recommended to pass as `admin` on creation an OZ ProxyAdmin instance
* @dev This contract needs solc=0.8.19 and zksolc=1.4.1 as codeHashes are specifically made for those versions
**/
contract TransparentProxyFactoryZkSync is ITransparentProxyFactoryZkSync {
/// @inheritdoc ITransparentProxyFactory
bytes32 public constant TRANSPARENT_UPGRADABLE_PROXY_INIT_CODE_HASH = 0x010001b73fa7f2c39ea2d9c597a419e15436fc9d3e00e032410072fb94ad95e1;
/// @inheritdoc ITransparentProxyFactoryZkSync
bytes32 public constant TRANSPARENT_UPGRADABLE_PROXY_INIT_CODE_HASH =
0x010001b73fa7f2c39ea2d9c597a419e15436fc9d3e00e032410072fb94ad95e1;

/// @inheritdoc ITransparentProxyFactory
bytes32 public constant PROXY_ADMIN_INIT_CODE_HASH = 0x010000e7f9a8b61da13fe7e27804d9f641f5f8db05b07df720973af749a01ac1;
/// @inheritdoc ITransparentProxyFactoryZkSync
bytes32 public constant PROXY_ADMIN_INIT_CODE_HASH =
0x010000e7f9a8b61da13fe7e27804d9f641f5f8db05b07df720973af749a01ac1;

/// @inheritdoc ITransparentProxyFactory
bytes32 public constant ZKSYNC_CREATE2_PREFIX = keccak256("zksyncCreate2");
/// @inheritdoc ITransparentProxyFactoryZkSync
bytes32 public constant ZKSYNC_CREATE2_PREFIX = keccak256('zksyncCreate2');

/// @inheritdoc ITransparentProxyFactory
/// @inheritdoc ITransparentProxyFactoryZkSync
function create(address logic, address admin, bytes calldata data) external returns (address) {
address proxy = address(new TransparentUpgradeableProxy(logic, admin, data));

emit ProxyCreated(proxy, logic, admin);
return proxy;
}

/// @inheritdoc ITransparentProxyFactory
/// @inheritdoc ITransparentProxyFactoryZkSync
function createProxyAdmin(address adminOwner) external returns (address) {
address proxyAdmin = address(new ProxyAdmin());
IOwnable(proxyAdmin).transferOwnership(adminOwner);
Expand All @@ -41,7 +44,7 @@ contract TransparentProxyFactoryZkSync is ITransparentProxyFactoryZkSync {
return proxyAdmin;
}

/// @inheritdoc ITransparentProxyFactory
/// @inheritdoc ITransparentProxyFactoryZkSync
function createDeterministic(
address logic,
address admin,
Expand All @@ -54,7 +57,7 @@ contract TransparentProxyFactoryZkSync is ITransparentProxyFactoryZkSync {
return proxy;
}

/// @inheritdoc ITransparentProxyFactory
/// @inheritdoc ITransparentProxyFactoryZkSync
function createDeterministicProxyAdmin(
address adminOwner,
bytes32 salt
Expand All @@ -66,7 +69,7 @@ contract TransparentProxyFactoryZkSync is ITransparentProxyFactoryZkSync {
return proxyAdmin;
}

/// @inheritdoc ITransparentProxyFactory
/// @inheritdoc ITransparentProxyFactoryZkSync
function predictCreateDeterministic(
address logic,
address admin,
Expand All @@ -82,7 +85,7 @@ contract TransparentProxyFactoryZkSync is ITransparentProxyFactoryZkSync {
);
}

/// @inheritdoc ITransparentProxyFactory
/// @inheritdoc ITransparentProxyFactoryZkSync
function predictCreateDeterministicProxyAdmin(bytes32 salt) public view returns (address) {
return _predictCreate2Address(address(this), salt, PROXY_ADMIN_INIT_CODE_HASH, abi.encode());
}
Expand Down

0 comments on commit f4168c0

Please sign in to comment.