Skip to content

Commit bd5b8e2

Browse files
committed
evm/script: add upgrade support to deploy script
1 parent d25f0c1 commit bd5b8e2

File tree

2 files changed

+62
-8
lines changed

2 files changed

+62
-8
lines changed

evm/script/DeployWormholeNtt.s.sol

+60-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,48 @@
11
// SPDX-License-Identifier: Apache 2
22
pragma solidity >=0.8.8 <0.9.0;
33

4-
import {Script} from "forge-std/Script.sol";
4+
import {Script, console} from "forge-std/Script.sol";
55
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+
}
615

716
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 {
924
vm.startBroadcast();
1025

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+
});
1346

1447
// Deploy NttManager.
1548
address manager = deployNttManager(params);
@@ -24,4 +57,27 @@ contract DeployWormholeNtt is Script, DeployWormholeNttBase {
2457

2558
vm.stopBroadcast();
2659
}
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+
}
2783
}

evm/script/helpers/DeployWormholeNttBase.sol

+2-4
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ contract DeployWormholeNttBase is ParseNttConfig {
4747

4848
nttManagerProxy.initialize();
4949

50-
console2.log("NttManager deployed at: ");
51-
console2.logBytes32(toUniversalAddress(address(nttManagerProxy)));
50+
console2.log("NttManager:", address(nttManagerProxy));
5251

5352
return address(nttManagerProxy);
5453
}
@@ -72,8 +71,7 @@ contract DeployWormholeNttBase is ParseNttConfig {
7271

7372
transceiverProxy.initialize();
7473

75-
console2.log("Wormhole Transceiver deployed at: ");
76-
console2.logBytes32(toUniversalAddress(address(transceiverProxy)));
74+
console2.log("WormholeTransceiver:", address(transceiverProxy));
7775

7876
return address(transceiverProxy);
7977
}

0 commit comments

Comments
 (0)