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

Revert "Replace Create3 with ZeframLou/create3-factory" #1388

Merged
merged 1 commit into from
Sep 18, 2023
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
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
[submodule "services/cctp-relayer/external/synapse-contracts"]
path = services/cctp-relayer/external/synapse-contracts
url = https://github.com/synapsecns/synapse-contracts
[submodule "packages/contracts-core/lib/create3-factory"]
path = packages/contracts-core/lib/create3-factory
url = https://github.com/zeframlou/create3-factory
[submodule "packages/contracts-core/lib/solmate"]
path = packages/contracts-core/lib/solmate
url = https://github.com/transmissions11/solmate
26 changes: 26 additions & 0 deletions packages/contracts-core/contracts/create3/CREATE3Factory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.13;

import {CREATE3} from "solmate/utils/CREATE3.sol";

import {ICREATE3Factory} from "./ICREATE3Factory.sol";

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

/// @inheritdoc ICREATE3Factory
function getDeployed(address deployer, bytes32 salt) external view override returns (address deployed) {
// hash salt with the deployer address to give each deployer its own namespace
salt = keccak256(abi.encodePacked(deployer, salt));
return CREATE3.getDeployed(salt);
}
}
22 changes: 22 additions & 0 deletions packages/contracts-core/contracts/create3/ICREATE3Factory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.6.0;

/// @title Factory for deploying contracts to deterministic addresses via CREATE3
/// @author zefram.eth
/// @notice Enables deploying contracts using CREATE3. Each deployer (msg.sender) has
/// its own namespace for deployed addresses.
interface ICREATE3Factory {
/// @notice Deploys a contract using CREATE3
/// @dev The provided salt is hashed together with msg.sender to generate the final salt
/// @param salt The deployer-specific salt for determining the deployed contract's address
/// @param creationCode The creation code of the contract to deploy
/// @return deployed The address of the deployed contract
function deploy(bytes32 salt, bytes memory creationCode) external payable returns (address deployed);

/// @notice Predicts the address of a deployed contract
/// @dev The provided salt is hashed together with the deployer address to generate the final salt
/// @param deployer The deployer account that will call deploy()
/// @param salt The deployer-specific salt for determining the deployed contract's address
/// @return deployed The address of the contract that will be deployed
function getDeployed(address deployer, bytes32 salt) external view returns (address deployed);
}
Comment on lines +1 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface ICREATE3Factory is well defined with clear function signatures for deploy and getDeployed. The comments provide a good understanding of what each function does. However, it would be beneficial to include more information about the parameters, especially creationCode in the deploy function. What format should this code be in? Is there any specific requirement or limitation that the user should be aware of?

1 change: 0 additions & 1 deletion packages/contracts-core/lib/create3-factory
Submodule create3-factory deleted from 06ec0f
1 change: 1 addition & 0 deletions packages/contracts-core/lib/solmate
Submodule solmate added at fadb2e
3 changes: 1 addition & 2 deletions packages/contracts-core/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
forge-std=lib/forge-std/src
ds-test=lib/forge-std/lib/ds-test/src
create3=lib/create3-factory/src
ds-test=lib/forge-std/lib/ds-test/src
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
// ═════════════════════════════ INTERNAL IMPORTS ══════════════════════════════
import {DeployerUtils} from "./utils/DeployerUtils.sol";

import {CREATE3Factory} from "create3/CREATE3Factory.sol";
import {CREATE3Factory} from "../contracts/create3/CREATE3Factory.sol";

// TODO: move this to a common deployer-utils package, as this is not specific to SIN
contract DeployCREATE3Factory is DeployerUtils {
// TODO: remove this script, I don't think we need it since we handle the devnet create3 deploy in setupDevnetIfEnabled();
contract DeployCREATE3 is DeployerUtils {
using stdJson for string;
using Strings for uint256;

Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-core/script/utils/DeployerUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {console, Script, stdJson} from "forge-std/Script.sol";

import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {CREATE3Factory} from "create3/CREATE3Factory.sol";
import {CREATE3Factory} from "../../contracts/create3/CREATE3Factory.sol";

interface ICreate3Factory {
function deploy(bytes32 salt, bytes memory creationCode) external payable returns (address deployed);
Expand Down