@@ -4,7 +4,6 @@ pragma solidity >=0.8.8 <0.9.0;
4
4
import {Script, console} from "forge-std/Script.sol " ;
5
5
import {DeployWormholeNttBase} from "./helpers/DeployWormholeNttBase.sol " ;
6
6
import {INttManager} from "../src/interfaces/INttManager.sol " ;
7
- import {IWormholeTransceiver} from "../src/interfaces/IWormholeTransceiver.sol " ;
8
7
import "../src/interfaces/IManagerBase.sol " ;
9
8
import "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol " ;
10
9
import {NttManager} from "../src/NttManager/NttManager.sol " ;
@@ -15,7 +14,10 @@ interface IWormhole {
15
14
16
15
contract DeployWormholeNtt is Script , DeployWormholeNttBase {
17
16
function run (
17
+ address endpoint ,
18
+ address executor ,
18
19
address wormhole ,
20
+ address transceiver ,
19
21
address token ,
20
22
address wormholeRelayer ,
21
23
address specialRelayer ,
@@ -28,66 +30,72 @@ contract DeployWormholeNtt is Script, DeployWormholeNttBase {
28
30
IWormhole wh = IWormhole (wormhole);
29
31
30
32
// sanity check decimals
31
- (bool success , bytes memory queriedDecimals ) =
32
- token.staticcall (abi.encodeWithSignature ("decimals() " ));
33
-
34
- if (success) {
35
- uint8 queriedDecimals = abi.decode (queriedDecimals, (uint8 ));
36
- if (queriedDecimals != decimals) {
37
- console.log ("Decimals mismatch: " , queriedDecimals, " != " , decimals);
38
- vm.stopBroadcast ();
39
- return ;
33
+ {
34
+ (bool success , bytes memory queriedDecimals ) =
35
+ token.staticcall (abi.encodeWithSignature ("decimals() " ));
36
+
37
+ if (success) {
38
+ uint8 queriedDec = abi.decode (queriedDecimals, (uint8 ));
39
+ if (queriedDec != decimals) {
40
+ console.log ("Decimals mismatch: " , queriedDec, " != " , decimals);
41
+ vm.stopBroadcast ();
42
+ return ;
43
+ }
44
+ } else {
45
+ // NOTE: this might not be a critical error. It could just mean that
46
+ // the token contract was compiled against a different EVM version than what the forge script is running on.
47
+ // In this case, it's the responsibility of the caller to ensure that the provided decimals are correct
48
+ // and that the token contract is valid.
49
+ // The best way to ensure that is by calling this script with the queried token decimals (which is what the NTT CLI does).
50
+ console.log (
51
+ "Failed to query token decimals. Proceeding with provided decimals. " , decimals
52
+ );
53
+ // the NTT manager initialiser calls the token contract to get the
54
+ // decimals as well. We're just going to mock that call to return the provided decimals.
55
+ // This is a bit of a hack, but in the worst case (i.e. if the token contract is actually broken), the
56
+ // NTT manager initialiser will fail anyway.
57
+ vm.mockCall (
58
+ token, abi.encodeWithSelector (ERC20 .decimals.selector ), abi.encode (decimals)
59
+ );
40
60
}
41
- } else {
42
- // NOTE: this might not be a critical error. It could just mean that
43
- // the token contract was compiled against a different EVM version than what the forge script is running on.
44
- // In this case, it's the responsibility of the caller to ensure that the provided decimals are correct
45
- // and that the token contract is valid.
46
- // The best way to ensure that is by calling this script with the queried token decimals (which is what the NTT CLI does).
47
- console.log (
48
- "Failed to query token decimals. Proceeding with provided decimals. " , decimals
49
- );
50
- // the NTT manager initialiser calls the token contract to get the
51
- // decimals as well. We're just going to mock that call to return the provided decimals.
52
- // This is a bit of a hack, but in the worst case (i.e. if the token contract is actually broken), the
53
- // NTT manager initialiser will fail anyway.
54
- vm.mockCall (
55
- token, abi.encodeWithSelector (ERC20 .decimals.selector ), abi.encode (decimals)
56
- );
57
61
}
58
62
59
- uint16 chainId = wh.chainId ();
60
-
61
- console.log ("Chain ID: " , chainId);
62
-
63
- uint256 scale =
64
- decimals > TRIMMED_DECIMALS ? uint256 (10 ** (decimals - TRIMMED_DECIMALS)) : 1 ;
65
-
66
- DeploymentParams memory params = DeploymentParams ({
67
- token: token,
68
- mode: mode,
69
- wormholeChainId: chainId,
70
- rateLimitDuration: 86400 ,
71
- shouldSkipRatelimiter: false ,
72
- wormholeCoreBridge: wormhole,
73
- wormholeRelayerAddr: wormholeRelayer,
74
- specialRelayerAddr: specialRelayer,
75
- consistencyLevel: 202 ,
76
- gasLimit: 500000 ,
77
- // the trimming will trim this number to uint64.max
78
- outboundLimit: uint256 (type (uint64 ).max) * scale
79
- });
63
+ DeploymentParams memory params;
64
+ {
65
+ uint16 chainId = wh.chainId ();
66
+
67
+ console.log ("Chain ID: " , chainId);
68
+
69
+ uint256 scale =
70
+ decimals > TRIMMED_DECIMALS ? uint256 (10 ** (decimals - TRIMMED_DECIMALS)) : 1 ;
71
+
72
+ params = DeploymentParams ({
73
+ endpointAddr: endpoint,
74
+ executorAddr: executor,
75
+ token: token,
76
+ mode: mode,
77
+ wormholeChainId: chainId,
78
+ rateLimitDuration: 86400 ,
79
+ shouldSkipRatelimiter: false ,
80
+ wormholeCoreBridge: wormhole,
81
+ wormholeRelayerAddr: wormholeRelayer,
82
+ specialRelayerAddr: specialRelayer,
83
+ consistencyLevel: 202 ,
84
+ gasLimit: 500000 ,
85
+ // the trimming will trim this number to uint64.max
86
+ outboundLimit: uint256 (type (uint64 ).max) * scale
87
+ });
88
+ }
80
89
81
90
// Deploy NttManager.
82
- address manager = deployNttManager (params);
83
-
84
- // Deploy Wormhole Transceiver.
85
- address transceiver = deployWormholeTransceiver (params, manager);
91
+ {
92
+ address manager = deployNttManager (params);
86
93
87
- // Configure NttManager.
88
- configureNttManager (
89
- manager, transceiver, params.outboundLimit, params.shouldSkipRatelimiter
90
- );
94
+ // Configure NttManager.
95
+ configureNttManager (
96
+ manager, transceiver, params.outboundLimit, params.shouldSkipRatelimiter
97
+ );
98
+ }
91
99
92
100
vm.stopBroadcast ();
93
101
}
@@ -105,6 +113,8 @@ contract DeployWormholeNtt is Script, DeployWormholeNttBase {
105
113
bool shouldSkipRatelimiter = rateLimitDuration == 0 ;
106
114
107
115
NttManager implementation = new NttManager (
116
+ address (nttManager.endpoint ()),
117
+ address (nttManager.executor ()),
108
118
nttManager.token (),
109
119
nttManager.mode (),
110
120
nttManager.chainId (),
0 commit comments