-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Replace Create3 with ZeframLou/create3-factory (#1387)"
This reverts commit 616c5ab.
- Loading branch information
Showing
8 changed files
with
57 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/contracts-core/contracts/create3/CREATE3Factory.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
packages/contracts-core/contracts/create3/ICREATE3Factory.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Submodule create3-factory
deleted from
06ec0f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters