|
1 | 1 | // SPDX-License-Identifier: Apache 2 |
2 | 2 | pragma solidity >=0.8.8 <0.9.0; |
3 | 3 |
|
4 | | -import {Script, console2} from "forge-std/Script.sol"; |
5 | | - |
6 | | -import "../src/interfaces/IManagerBase.sol"; |
7 | | -import "../src/interfaces/INttManager.sol"; |
8 | | -import "../src/interfaces/IWormholeTransceiver.sol"; |
9 | | - |
10 | | -import {NttManager} from "../src/NttManager/NttManager.sol"; |
11 | | -import {WormholeTransceiver} from "../src/Transceiver/WormholeTransceiver/WormholeTransceiver.sol"; |
12 | | -import {ERC1967Proxy} from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol"; |
13 | | -import {ParseNttConfig} from "./helpers/ParseNttConfig.sol"; |
14 | | - |
15 | | -contract DeployWormholeNtt is Script, ParseNttConfig { |
16 | | - struct DeploymentParams { |
17 | | - address token; |
18 | | - IManagerBase.Mode mode; |
19 | | - uint16 wormholeChainId; |
20 | | - uint64 rateLimitDuration; |
21 | | - bool shouldSkipRatelimiter; |
22 | | - address wormholeCoreBridge; |
23 | | - address wormholeRelayerAddr; |
24 | | - address specialRelayerAddr; |
25 | | - uint8 consistencyLevel; |
26 | | - uint256 gasLimit; |
27 | | - uint256 outboundLimit; |
28 | | - } |
29 | | - |
30 | | - // The minimum gas limit to verify a message on mainnet. If you're worried about saving |
31 | | - // gas on testnet, pick up the phone and start dialing! |
32 | | - uint256 constant MIN_WORMHOLE_GAS_LIMIT = 150000; |
33 | | - |
34 | | - function deployNttManager(DeploymentParams memory params) internal returns (address) { |
35 | | - // Deploy the Manager Implementation. |
36 | | - NttManager implementation = new NttManager( |
37 | | - params.token, |
38 | | - params.mode, |
39 | | - params.wormholeChainId, |
40 | | - params.rateLimitDuration, |
41 | | - params.shouldSkipRatelimiter |
42 | | - ); |
43 | | - |
44 | | - // NttManager Proxy |
45 | | - NttManager nttManagerProxy = |
46 | | - NttManager(address(new ERC1967Proxy(address(implementation), ""))); |
47 | | - |
48 | | - nttManagerProxy.initialize(); |
49 | | - |
50 | | - console2.log("NttManager deployed at: "); |
51 | | - console2.logBytes32(toUniversalAddress(address(nttManagerProxy))); |
52 | | - |
53 | | - return address(nttManagerProxy); |
54 | | - } |
55 | | - |
56 | | - function deployWormholeTransceiver( |
57 | | - DeploymentParams memory params, |
58 | | - address nttManager |
59 | | - ) public returns (address) { |
60 | | - // Deploy the Wormhole Transceiver. |
61 | | - WormholeTransceiver implementation = new WormholeTransceiver( |
62 | | - nttManager, |
63 | | - params.wormholeCoreBridge, |
64 | | - params.wormholeRelayerAddr, |
65 | | - params.specialRelayerAddr, |
66 | | - params.consistencyLevel, |
67 | | - params.gasLimit |
68 | | - ); |
69 | | - |
70 | | - WormholeTransceiver transceiverProxy = |
71 | | - WormholeTransceiver(address(new ERC1967Proxy(address(implementation), ""))); |
72 | | - |
73 | | - transceiverProxy.initialize(); |
74 | | - |
75 | | - console2.log("Wormhole Transceiver deployed at: "); |
76 | | - console2.logBytes32(toUniversalAddress(address(transceiverProxy))); |
77 | | - |
78 | | - return address(transceiverProxy); |
79 | | - } |
80 | | - |
81 | | - function configureNttManager( |
82 | | - address nttManager, |
83 | | - address transceiver, |
84 | | - uint256 outboundLimit, |
85 | | - bool shouldSkipRateLimiter |
86 | | - ) public { |
87 | | - IManagerBase(nttManager).setTransceiver(transceiver); |
88 | | - console2.log("Transceiver address set on NttManager: ", transceiver); |
89 | | - |
90 | | - if (!shouldSkipRateLimiter) { |
91 | | - INttManager(nttManager).setOutboundLimit(outboundLimit); |
92 | | - console2.log("Outbound rate limit set on NttManager: ", outboundLimit); |
93 | | - } |
94 | | - |
95 | | - // Hardcoded to one since these scripts handle Wormhole-only deployments. |
96 | | - INttManager(nttManager).setThreshold(1); |
97 | | - console2.log("Threshold set on NttManager: %d", uint256(1)); |
98 | | - } |
99 | | - |
100 | | - function _readEnvVariables() internal view returns (DeploymentParams memory params) { |
101 | | - // Token address. |
102 | | - params.token = vm.envAddress("RELEASE_TOKEN_ADDRESS"); |
103 | | - require(params.token != address(0), "Invalid token address"); |
104 | | - |
105 | | - // Mode. |
106 | | - uint8 mode = uint8(vm.envUint("RELEASE_MODE")); |
107 | | - if (mode == 0) { |
108 | | - params.mode = IManagerBase.Mode.LOCKING; |
109 | | - } else if (mode == 1) { |
110 | | - params.mode = IManagerBase.Mode.BURNING; |
111 | | - } else { |
112 | | - revert("Invalid mode"); |
113 | | - } |
114 | | - |
115 | | - // Chain ID. |
116 | | - params.wormholeChainId = uint16(vm.envUint("RELEASE_WORMHOLE_CHAIN_ID")); |
117 | | - require(params.wormholeChainId != 0, "Invalid chain ID"); |
118 | | - |
119 | | - // Rate limit duration. |
120 | | - params.rateLimitDuration = uint64(vm.envUint("RELEASE_RATE_LIMIT_DURATION")); |
121 | | - params.shouldSkipRatelimiter = vm.envBool("RELEASE_SKIP_RATE_LIMIT"); |
122 | | - |
123 | | - // Wormhole Core Bridge address. |
124 | | - params.wormholeCoreBridge = vm.envAddress("RELEASE_CORE_BRIDGE_ADDRESS"); |
125 | | - require(params.wormholeCoreBridge != address(0), "Invalid wormhole core bridge address"); |
126 | | - |
127 | | - // Wormhole relayer, special relayer, consistency level. |
128 | | - params.wormholeRelayerAddr = vm.envAddress("RELEASE_WORMHOLE_RELAYER_ADDRESS"); |
129 | | - params.specialRelayerAddr = vm.envAddress("RELEASE_SPECIAL_RELAYER_ADDRESS"); |
130 | | - params.consistencyLevel = uint8(vm.envUint("RELEASE_CONSISTENCY_LEVEL")); |
131 | | - |
132 | | - params.gasLimit = vm.envUint("RELEASE_GAS_LIMIT"); |
133 | | - require(params.gasLimit >= MIN_WORMHOLE_GAS_LIMIT, "Invalid gas limit"); |
134 | | - |
135 | | - // Outbound rate limiter limit. |
136 | | - params.outboundLimit = vm.envUint("RELEASE_OUTBOUND_LIMIT"); |
137 | | - } |
| 4 | +import {Script} from "forge-std/Script.sol"; |
| 5 | +import {DeployWormholeNttBase} from "./helpers/DeployWormholeNttBase.sol"; |
138 | 6 |
|
| 7 | +contract DeployWormholeNtt is Script, DeployWormholeNttBase { |
139 | 8 | function run() public { |
140 | 9 | vm.startBroadcast(); |
141 | 10 |
|
|
0 commit comments