1
1
// SPDX-License-Identifier: Apache 2
2
2
pragma solidity >= 0.8.8 < 0.9.0 ;
3
3
4
- import {Script} from "forge-std/Script.sol " ;
4
+ import {Script, console } from "forge-std/Script.sol " ;
5
5
import {DeployWormholeNttBase} from "./helpers/DeployWormholeNttBase.sol " ;
6
+ import {INttManager} from "../src/interfaces/INttManager.sol " ;
7
+ import {IWormholeTransceiver} from "../src/interfaces/IWormholeTransceiver.sol " ;
8
+ import "../src/interfaces/IManagerBase.sol " ;
9
+ import "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol " ;
10
+ import {NttManager} from "../src/NttManager/NttManager.sol " ;
11
+
12
+ interface IWormhole {
13
+ function chainId () external view returns (uint16 );
14
+ }
6
15
7
16
contract DeployWormholeNtt is Script , DeployWormholeNttBase {
8
- function run () public {
17
+ function run (
18
+ address wormhole ,
19
+ address token ,
20
+ address wormholeRelayer ,
21
+ address specialRelayer ,
22
+ IManagerBase.Mode mode
23
+ ) public {
9
24
vm.startBroadcast ();
10
25
11
- // Sanity check deployment parameters.
12
- DeploymentParams memory params = _readEnvVariables ();
26
+ console.log ("Deploying Wormhole Ntt... " );
27
+ IWormhole wh = IWormhole (wormhole);
28
+
29
+ uint16 chainId = wh.chainId ();
30
+
31
+ console.log ("Chain ID: " , chainId);
32
+
33
+ DeploymentParams memory params = DeploymentParams ({
34
+ token: token,
35
+ mode: mode,
36
+ wormholeChainId: chainId,
37
+ rateLimitDuration: 86400 ,
38
+ shouldSkipRatelimiter: false ,
39
+ wormholeCoreBridge: wormhole,
40
+ wormholeRelayerAddr: wormholeRelayer,
41
+ specialRelayerAddr: specialRelayer,
42
+ consistencyLevel: 202 ,
43
+ gasLimit: 500000 ,
44
+ outboundLimit: uint256 (type (uint64 ).max) * 10 ** 10
45
+ });
13
46
14
47
// Deploy NttManager.
15
48
address manager = deployNttManager (params);
@@ -24,4 +57,27 @@ contract DeployWormholeNtt is Script, DeployWormholeNttBase {
24
57
25
58
vm.stopBroadcast ();
26
59
}
60
+
61
+ function upgrade (address manager ) public {
62
+ vm.startBroadcast ();
63
+
64
+ NttManager nttManager = NttManager (manager);
65
+
66
+ console.log ("Upgrading manager... " );
67
+
68
+ uint64 rateLimitDuration = nttManager.rateLimitDuration ();
69
+ bool shouldSkipRatelimiter = rateLimitDuration == 0 ;
70
+
71
+ NttManager implementation = new NttManager (
72
+ nttManager.token (),
73
+ nttManager.mode (),
74
+ nttManager.chainId (),
75
+ nttManager.rateLimitDuration (),
76
+ shouldSkipRatelimiter
77
+ );
78
+
79
+ nttManager.upgrade (address (implementation));
80
+
81
+ vm.stopBroadcast ();
82
+ }
27
83
}
0 commit comments