-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from abstraction-hq/25-create2-contract
create2 contract
- Loading branch information
Showing
5 changed files
with
74 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: Apache | ||
pragma solidity ^0.8.0; | ||
|
||
import "../src/GenericFactory.sol"; | ||
|
||
contract BaseDeployer { | ||
GenericFactory public genericFactory = GenericFactory(0x9aE7a293de3D5789Cd24324C167B7BC98A0c70B7); | ||
} |
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
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,24 @@ | ||
// SPDX-License-Identifier: Apache | ||
pragma solidity ^0.8.0; | ||
|
||
import {Script, console2} from "forge-std/Script.sol"; | ||
|
||
import "forge-std/console.sol"; | ||
import "account-abstraction/core/EntryPoint.sol"; | ||
import "../src/GenericFactory.sol"; | ||
|
||
contract Deployer is Script { | ||
function setUp() external {} | ||
|
||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
address exitedEntryPoint = vm.envAddress("ENTRY_POINT"); | ||
require(exitedEntryPoint != address(0), "ENTRY_POINT is required"); | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
GenericFactory factory = new GenericFactory(); | ||
console.log("Generic factory: ", address(factory)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
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: Apache | ||
pragma solidity ^0.8.0; | ||
|
||
contract GenericFactory { | ||
function create(bytes memory code) external returns (address addr) { | ||
assembly { | ||
addr := create(0, add(code, 0x20), mload(code)) | ||
if iszero(extcodesize(addr)) { | ||
revert(0, 0) | ||
} | ||
} | ||
} | ||
|
||
function create2(bytes memory code, bytes32 salt) external returns (address addr) { | ||
assembly { | ||
addr := create2(0, add(code, 0x20), mload(code), salt) | ||
if iszero(extcodesize(addr)) { | ||
revert(0, 0) | ||
} | ||
} | ||
} | ||
} |