|
1 | | -// SPDX-License-Identifier: MIT |
2 | | -pragma solidity 0.8.28; |
3 | | - |
4 | | -import {Script} from "forge-std/Script.sol"; |
5 | | -import {console} from "forge-std/console.sol"; |
6 | | - |
7 | | -import {ERC1967Factory} from "solady/utils/ERC1967Factory.sol"; |
8 | | -import {ERC1967FactoryConstants} from "solady/utils/ERC1967FactoryConstants.sol"; |
9 | | - |
10 | | -import {CrossChainERC20Factory} from "../src/CrossChainERC20Factory.sol"; |
11 | | -import {CrossChainMessenger} from "../src/CrossChainMessenger.sol"; |
12 | | -import {MessagePasser} from "../src/MessagePasser.sol"; |
13 | | -import {TokenBridge} from "../src/TokenBridge.sol"; |
14 | | - |
15 | | -contract DeployScript is Script { |
16 | | - address public constant PROXY_ADMIN = 0x0fe884546476dDd290eC46318785046ef68a0BA9; |
17 | | - |
18 | | - bytes32 public constant ORACLE = 0x0000000000000000000000000e9a877906EBc3b7098DA2404412BF0Ed1A5EFb4; |
19 | | - bytes32 public constant REMOTE_MESSENGER = 0x7e273983f136714ba93a740a050279b541d6f25ebc6bbc6fc67616d0d5529cea; |
20 | | - bytes32 public constant OTHER_BRIDGE = 0x7a25452c36304317d6fe970091c383b0d45e9b0b06485d2561156f025c6936af; |
21 | | - |
22 | | - function setUp() public { |
23 | | - vm.label(PROXY_ADMIN, "PROXY_ADMIN"); |
24 | | - vm.label(ERC1967FactoryConstants.ADDRESS, "ERC1967_FACTORY"); |
25 | | - } |
26 | | - |
27 | | - function run() public { |
28 | | - Chain memory chain = getChain(block.chainid); |
29 | | - console.log("Deploying on chain: %s", chain.name); |
30 | | - |
31 | | - vm.startBroadcast(); |
32 | | - address messagePasser = _deployMessagePasser(); |
33 | | - address messenger = _deployMessenger(messagePasser); |
34 | | - address bridge = _deployBridge(messenger); |
35 | | - address factory = _deployFactory(bridge); |
36 | | - vm.stopBroadcast(); |
37 | | - |
38 | | - console.log("Deployed MessagePasser at: %s", messagePasser); |
39 | | - console.log("Deployed CrossChainMessenger at: %s", messenger); |
40 | | - console.log("Deployed TokenBridge at: %s", bridge); |
41 | | - console.log("Deployed CrossChainERC20Factory at: %s", factory); |
42 | | - |
43 | | - string memory out = "{"; |
44 | | - out = _record(out, "MessagePasser", messagePasser, false); |
45 | | - out = _record(out, "CrossChainMessenger", messenger, false); |
46 | | - out = _record(out, "TokenBridge", bridge, false); |
47 | | - out = _record(out, "CrossChainERC20Factory", factory, true); |
48 | | - out = string.concat(out, "}"); |
49 | | - |
50 | | - vm.createDir("deployments", true); |
51 | | - vm.writeFile(string.concat("deployments/", chain.chainAlias, ".json"), out); |
52 | | - } |
53 | | - |
54 | | - function _deployMessagePasser() private returns (address) { |
55 | | - MessagePasser messagePasser = new MessagePasser(); |
56 | | - return address(messagePasser); |
57 | | - } |
58 | | - |
59 | | - function _deployMessenger(address messagePasser) private returns (address) { |
60 | | - CrossChainMessenger messengerImpl = new CrossChainMessenger(messagePasser, REMOTE_MESSENGER); |
61 | | - CrossChainMessenger messengerProxy = CrossChainMessenger( |
62 | | - ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({ |
63 | | - implementation: address(messengerImpl), |
64 | | - admin: PROXY_ADMIN, |
65 | | - data: abi.encodeCall(CrossChainMessenger.initialize, (ORACLE)) |
66 | | - }) |
67 | | - ); |
68 | | - |
69 | | - return address(messengerProxy); |
70 | | - } |
71 | | - |
72 | | - function _deployBridge(address messenger) private returns (address) { |
73 | | - TokenBridge bridgeImpl = new TokenBridge(); |
74 | | - TokenBridge bridgeProxy = TokenBridge( |
75 | | - ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({ |
76 | | - implementation: address(bridgeImpl), |
77 | | - admin: PROXY_ADMIN, |
78 | | - data: abi.encodeCall(TokenBridge.initialize, (messenger, OTHER_BRIDGE)) |
79 | | - }) |
80 | | - ); |
81 | | - |
82 | | - return address(bridgeProxy); |
83 | | - } |
84 | | - |
85 | | - function _deployFactory(address bridge) private returns (address) { |
86 | | - CrossChainERC20Factory xChainERC20FactoryImpl = new CrossChainERC20Factory(); |
87 | | - CrossChainERC20Factory xChainERC20Factory = CrossChainERC20Factory( |
88 | | - ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({ |
89 | | - implementation: address(xChainERC20FactoryImpl), |
90 | | - admin: PROXY_ADMIN, |
91 | | - data: abi.encodeCall(CrossChainERC20Factory.initialize, (bridge)) |
92 | | - }) |
93 | | - ); |
94 | | - |
95 | | - return address(xChainERC20Factory); |
96 | | - } |
97 | | - |
98 | | - function _record(string memory out, string memory key, address addr, bool isLast) |
99 | | - private |
100 | | - pure |
101 | | - returns (string memory) |
102 | | - { |
103 | | - return string.concat(out, "\"", key, "\": \"", vm.toString(addr), isLast ? "\"" : "\","); |
104 | | - } |
105 | | - |
106 | | - function _addressToBytes32(address value) private pure returns (bytes32) { |
107 | | - return bytes32(uint256(uint160(value))); |
108 | | - } |
109 | | -} |
| 1 | +// // SPDX-License-Identifier: MIT |
| 2 | +// pragma solidity 0.8.28; |
| 3 | + |
| 4 | +// import {Script} from "forge-std/Script.sol"; |
| 5 | +// import {console} from "forge-std/console.sol"; |
| 6 | + |
| 7 | +// import {ERC1967Factory} from "solady/utils/ERC1967Factory.sol"; |
| 8 | +// import {ERC1967FactoryConstants} from "solady/utils/ERC1967FactoryConstants.sol"; |
| 9 | + |
| 10 | +// import {CrossChainERC20Factory} from "../src/CrossChainERC20Factory.sol"; |
| 11 | +// import {CrossChainMessenger} from "../src/CrossChainMessenger.sol"; |
| 12 | +// import {MessagePasser} from "../src/MessagePasser.sol"; |
| 13 | +// import {TokenBridge} from "../src/TokenBridge.sol"; |
| 14 | + |
| 15 | +// contract DeployScript is Script { |
| 16 | +// address public constant PROXY_ADMIN = 0x0fe884546476dDd290eC46318785046ef68a0BA9; |
| 17 | + |
| 18 | +// bytes32 public constant ORACLE = 0x0000000000000000000000000e9a877906EBc3b7098DA2404412BF0Ed1A5EFb4; |
| 19 | +// bytes32 public constant REMOTE_MESSENGER = 0x7e273983f136714ba93a740a050279b541d6f25ebc6bbc6fc67616d0d5529cea; |
| 20 | +// bytes32 public constant OTHER_BRIDGE = 0x7a25452c36304317d6fe970091c383b0d45e9b0b06485d2561156f025c6936af; |
| 21 | + |
| 22 | +// function setUp() public { |
| 23 | +// vm.label(PROXY_ADMIN, "PROXY_ADMIN"); |
| 24 | +// vm.label(ERC1967FactoryConstants.ADDRESS, "ERC1967_FACTORY"); |
| 25 | +// } |
| 26 | + |
| 27 | +// function run() public { |
| 28 | +// Chain memory chain = getChain(block.chainid); |
| 29 | +// console.log("Deploying on chain: %s", chain.name); |
| 30 | + |
| 31 | +// vm.startBroadcast(); |
| 32 | +// address messagePasser = _deployMessagePasser(); |
| 33 | +// address messenger = _deployMessenger(messagePasser); |
| 34 | +// address bridge = _deployBridge(messenger); |
| 35 | +// address factory = _deployFactory(bridge); |
| 36 | +// vm.stopBroadcast(); |
| 37 | + |
| 38 | +// console.log("Deployed MessagePasser at: %s", messagePasser); |
| 39 | +// console.log("Deployed CrossChainMessenger at: %s", messenger); |
| 40 | +// console.log("Deployed TokenBridge at: %s", bridge); |
| 41 | +// console.log("Deployed CrossChainERC20Factory at: %s", factory); |
| 42 | + |
| 43 | +// string memory out = "{"; |
| 44 | +// out = _record(out, "MessagePasser", messagePasser, false); |
| 45 | +// out = _record(out, "CrossChainMessenger", messenger, false); |
| 46 | +// out = _record(out, "TokenBridge", bridge, false); |
| 47 | +// out = _record(out, "CrossChainERC20Factory", factory, true); |
| 48 | +// out = string.concat(out, "}"); |
| 49 | + |
| 50 | +// vm.createDir("deployments", true); |
| 51 | +// vm.writeFile(string.concat("deployments/", chain.chainAlias, ".json"), out); |
| 52 | +// } |
| 53 | + |
| 54 | +// function _deployMessagePasser() private returns (address) { |
| 55 | +// MessagePasser messagePasser = new MessagePasser(); |
| 56 | +// return address(messagePasser); |
| 57 | +// } |
| 58 | + |
| 59 | +// function _deployMessenger(address messagePasser) private returns (address) { |
| 60 | +// CrossChainMessenger messengerImpl = new CrossChainMessenger(messagePasser, REMOTE_MESSENGER); |
| 61 | +// CrossChainMessenger messengerProxy = CrossChainMessenger( |
| 62 | +// ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({ |
| 63 | +// implementation: address(messengerImpl), |
| 64 | +// admin: PROXY_ADMIN, |
| 65 | +// data: abi.encodeCall(CrossChainMessenger.initialize, (ORACLE)) |
| 66 | +// }) |
| 67 | +// ); |
| 68 | + |
| 69 | +// return address(messengerProxy); |
| 70 | +// } |
| 71 | + |
| 72 | +// function _deployBridge(address messenger) private returns (address) { |
| 73 | +// TokenBridge bridgeImpl = new TokenBridge(); |
| 74 | +// TokenBridge bridgeProxy = TokenBridge( |
| 75 | +// ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({ |
| 76 | +// implementation: address(bridgeImpl), |
| 77 | +// admin: PROXY_ADMIN, |
| 78 | +// data: abi.encodeCall(TokenBridge.initialize, (messenger, OTHER_BRIDGE)) |
| 79 | +// }) |
| 80 | +// ); |
| 81 | + |
| 82 | +// return address(bridgeProxy); |
| 83 | +// } |
| 84 | + |
| 85 | +// function _deployFactory(address bridge) private returns (address) { |
| 86 | +// CrossChainERC20Factory xChainERC20FactoryImpl = new CrossChainERC20Factory(); |
| 87 | +// CrossChainERC20Factory xChainERC20Factory = CrossChainERC20Factory( |
| 88 | +// ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({ |
| 89 | +// implementation: address(xChainERC20FactoryImpl), |
| 90 | +// admin: PROXY_ADMIN, |
| 91 | +// data: abi.encodeCall(CrossChainERC20Factory.initialize, (bridge)) |
| 92 | +// }) |
| 93 | +// ); |
| 94 | + |
| 95 | +// return address(xChainERC20Factory); |
| 96 | +// } |
| 97 | + |
| 98 | +// function _record(string memory out, string memory key, address addr, bool isLast) |
| 99 | +// private |
| 100 | +// pure |
| 101 | +// returns (string memory) |
| 102 | +// { |
| 103 | +// return string.concat(out, "\"", key, "\": \"", vm.toString(addr), isLast ? "\"" : "\","); |
| 104 | +// } |
| 105 | + |
| 106 | +// function _addressToBytes32(address value) private pure returns (bytes32) { |
| 107 | +// return bytes32(uint256(uint160(value))); |
| 108 | +// } |
| 109 | +// } |
0 commit comments