@@ -11,34 +11,36 @@ import {TypeCasts} from "@nomad-xyz/contracts-core/contracts/XAppConnectionManag
11
11
import {JsonWriter} from "./JsonWriter.sol " ;
12
12
13
13
import "forge-std/Script.sol " ;
14
+ import "forge-std/Vm.sol " ;
14
15
15
- abstract contract CallBatch is Script {
16
+ abstract contract CallBatch {
16
17
using JsonWriter for JsonWriter.Buffer;
17
18
using JsonWriter for string ;
18
19
20
+ Vm private constant vm =
21
+ Vm (address (uint160 (uint256 (keccak256 ("hevm cheat code " )))));
22
+
19
23
string localDomainName;
20
24
uint32 public localDomain;
21
25
GovernanceMessage.Call[] public localCalls;
22
26
uint32 [] public remoteDomains;
23
27
mapping (uint32 => GovernanceMessage.Call[]) public remoteCalls;
24
28
25
29
bool public written;
26
- JsonWriter.File outputFile ;
30
+ JsonWriter.File batchOutput ;
27
31
28
32
function __CallBatch_initialize (
29
33
string memory _localDomainName ,
30
34
uint32 _localDomain ,
31
- string memory _outputFilePath ,
35
+ string memory _batchOutput ,
32
36
bool _overwrite
33
37
) public {
34
38
require (localDomain == 0 , "already initialized " );
35
39
require (_localDomain != 0 , "can't pass zero domain " );
36
40
localDomainName = _localDomainName;
37
41
localDomain = _localDomain;
38
- outputFile.overwrite = _overwrite;
39
- outputFile.path = string (
40
- abi.encodePacked ("./actions/ " , _outputFilePath)
41
- );
42
+ batchOutput.overwrite = _overwrite;
43
+ batchOutput.path = string (abi.encodePacked ("./actions/ " , _batchOutput));
42
44
}
43
45
44
46
function pushRemote (
@@ -112,7 +114,7 @@ abstract contract CallBatch is Script {
112
114
string memory indent ,
113
115
GovernanceMessage.Call storage call ,
114
116
bool terminal
115
- ) private {
117
+ ) private view {
116
118
buffer.writeObjectOpen (indent);
117
119
string memory inner = indent.nextIndent ();
118
120
buffer.writeKv (
@@ -129,7 +131,7 @@ abstract contract CallBatch is Script {
129
131
JsonWriter.Buffer memory buffer ,
130
132
string memory indent ,
131
133
GovernanceMessage.Call[] storage calls
132
- ) private {
134
+ ) private view {
133
135
for (uint32 i = 0 ; i < calls.length ; i++ ) {
134
136
writeCall (
135
137
buffer,
@@ -142,6 +144,7 @@ abstract contract CallBatch is Script {
142
144
143
145
function writeLocal (JsonWriter.Buffer memory buffer , string memory indent )
144
146
private
147
+ view
145
148
{
146
149
buffer.writeArrayOpen (indent, "local " );
147
150
writeCallList (buffer, indent, localCalls);
@@ -150,6 +153,7 @@ abstract contract CallBatch is Script {
150
153
151
154
function writeRemotes (JsonWriter.Buffer memory buffer , string memory indent )
152
155
private
156
+ view
153
157
{
154
158
if (remoteDomains.length == 0 ) return ;
155
159
buffer.writeObjectOpen (indent, "remote " );
@@ -172,7 +176,7 @@ abstract contract CallBatch is Script {
172
176
uint32 domain ,
173
177
GovernanceMessage.Call[] memory calls ,
174
178
bool isLastDomain
175
- ) private {
179
+ ) private pure {
176
180
buffer.writeObjectOpen (indent, vm.toString (uint256 (domain)));
177
181
bytes memory data = abi.encodeWithSelector (
178
182
GovernanceRouter.executeGovernanceActions.selector ,
@@ -260,7 +264,7 @@ abstract contract CallBatch is Script {
260
264
writeRemotes (buffer, inner);
261
265
writeBuilt (buffer, inner, recovery);
262
266
buffer.writeObjectClose (indent, true );
263
- buffer.flushTo (outputFile );
267
+ buffer.flushTo (batchOutput );
264
268
// finish
265
269
written = true ;
266
270
}
0 commit comments