-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created script to deploy modified TWCloneFactory
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 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,44 @@ | ||
pragma solidity ^0.8.20; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import "lib/forge-std/src/console.sol"; | ||
import {TWCloneFactory} from "src/TWCloneFactory.sol"; | ||
import {SuperChainInterop} from "src/module/token/crosschain/SuperChainInterop.sol"; | ||
|
||
interface ICreateX { | ||
|
||
function deployCreate2(bytes32 salt, bytes memory initCode) external returns (address newContract); | ||
|
||
} | ||
|
||
contract DeployTWCloneFactoryScript is Script { | ||
|
||
address createX = 0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed; | ||
|
||
function deployDeterministic(bytes32 salt, bytes memory creationCode) public returns (address) { | ||
address deployedAddress; | ||
|
||
// Deploy using CREATE2 | ||
assembly { | ||
deployedAddress := create2(0, add(creationCode, 0x20), mload(creationCode), salt) | ||
} | ||
|
||
require(deployedAddress != address(0), "CREATE2 failed"); | ||
|
||
return deployedAddress; | ||
} | ||
|
||
function run() external { | ||
uint256 testPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
vm.startBroadcast(testPrivateKey); | ||
|
||
bytes32 salt; | ||
bytes memory initCode = abi.encodePacked(type(TWCloneFactory).creationCode); | ||
|
||
address twCloneFactory = ICreateX(createX).deployCreate2(salt, initCode); | ||
console.log("TWCloneFactory deployed: ", twCloneFactory); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
} |