@@ -6,116 +6,116 @@ import {ICreateXFactory} from "src/ICreateXFactory.sol";
66import {VmSafe} from "forge-std/Vm.sol " ;
77
88abstract contract BaseScript is Script {
9- using stdJson for string ;
10-
11- string private constant DEFAULT_MNEMONIC = "test test test test test test test test test test test junk " ;
12-
13- string private constant DEFAULT_CHAINS = "ethereum, optimism, polygon, base, arbitrum " ;
14-
15- address internal broadcaster;
16-
17- modifier broadcast () {
18- vm.startBroadcast (broadcaster);
19- _;
20- vm.stopBroadcast ();
21- }
22-
23- modifier fork (string memory chainAlias ) {
24- vm.createSelectFork (chainAlias);
25- _;
26- }
27-
28- function setUp () public virtual {
29- broadcaster = vm.rememberKey (configurePrivateKey ());
30- }
31-
32- function configurePrivateKey () internal view virtual returns (uint256 privateKey ) {
33- privateKey = vm.envOr ({
34- name: "PRIVATE_KEY " ,
35- defaultValue: vm.deriveKey ({
36- mnemonic: vm.envOr ({name: "MNEMONIC " , defaultValue: DEFAULT_MNEMONIC}),
37- index: uint8 (vm.envOr ({name: "EOA_INDEX " , defaultValue: uint256 (0 )}))
38- })
39- });
40- }
41-
42- function generateJson (string memory path , string memory name , address instance , bytes32 salt ) internal virtual {
43- string memory json = "json " ;
44- json.serialize ("address " , instance);
45- json.serialize ("blockNumber " , vm.getBlockNumber ());
46- json.serialize ("timestamp " , vm.getBlockTimestamp ());
47- json.serialize ("salt " , salt);
48- json = json.serialize ("name " , name);
49- json.write (path);
50- }
51-
52- function promptChains () internal virtual returns (string [] memory chainAliases ) {
53- string memory input = prompt ("Chains separated by ',' " , defaultChains ());
54- return vm.split (vm.replace (input, " " , "" ), ", " );
55- }
56-
57- function prompt (string memory promptText ) internal returns (string memory input ) {
58- return prompt (promptText, new string (0 ));
59- }
60-
61- function prompt (string memory promptText , string memory defaultValue ) internal returns (string memory input ) {
62- input = vm.prompt (string .concat (promptText, " (default: ` " , defaultValue, "`) " ));
63- if (bytes (input).length == 0 ) input = defaultValue;
64- }
65-
66- function promptAddress (string memory promptText , address defaultValue ) internal returns (address ) {
67- return vm.parseAddress (prompt (promptText, vm.toString (defaultValue)));
68- }
69-
70- function promptAddress (string memory promptText ) internal returns (address ) {
71- return promptAddress (promptText, address (0 ));
72- }
73-
74- function promptBool (string memory promptText , bool defaultValue ) internal returns (bool ) {
75- return vm.parseBool (prompt (promptText, vm.toString (defaultValue)));
76- }
77-
78- function promptBool (string memory promptText ) internal returns (bool ) {
79- return promptBool (promptText, false );
80- }
81-
82- function promptUint256 (string memory promptText , uint256 defaultValue ) internal returns (uint256 ) {
83- return vm.parseUint (prompt (promptText, vm.toString (defaultValue)));
84- }
85-
86- function promptUint256 (string memory promptText ) internal returns (uint256 ) {
87- return promptUint256 (promptText, uint256 (0 ));
88- }
89-
90- function promptInt256 (string memory promptText , int256 defaultValue ) internal returns (int256 ) {
91- return vm.parseInt (prompt (promptText, vm.toString (defaultValue)));
92- }
93-
94- function promptInt256 (string memory promptText ) internal returns (int256 ) {
95- return promptInt256 (promptText, int256 (0 ));
96- }
97-
98- function promptBytes32 (string memory promptText , bytes32 defaultValue ) internal returns (bytes32 ) {
99- return vm.parseBytes32 (prompt (promptText, vm.toString (defaultValue)));
100- }
101-
102- function promptBytes32 (string memory promptText ) internal returns (bytes32 ) {
103- return promptBytes32 (promptText, bytes32 (0 ));
104- }
105-
106- function promptBytes (string memory promptText , bytes memory defaultValue ) internal returns (bytes memory ) {
107- return vm.parseBytes (prompt (promptText, vm.toString (defaultValue)));
108- }
109-
110- function promptBytes (string memory promptText ) internal returns (bytes memory ) {
111- return promptBytes (promptText, new bytes (0 ));
112- }
113-
114- function defaultChains () internal view virtual returns (string memory chains ) {
115- return DEFAULT_CHAINS;
116- }
117-
118- function defaultSalt () internal view virtual returns (bytes32 ) {
119- return bytes32 (0 );
120- }
9+ using stdJson for string ;
10+
11+ string private constant DEFAULT_MNEMONIC = "test test test test test test test test test test test junk " ;
12+
13+ string private constant DEFAULT_CHAINS = "ethereum, optimism, polygon, base, arbitrum " ;
14+
15+ address internal broadcaster;
16+
17+ modifier broadcast () {
18+ vm.startBroadcast (broadcaster);
19+ _;
20+ vm.stopBroadcast ();
21+ }
22+
23+ modifier fork (string memory chainAlias ) {
24+ vm.createSelectFork (chainAlias);
25+ _;
26+ }
27+
28+ function setUp () public virtual {
29+ broadcaster = vm.rememberKey (configurePrivateKey ());
30+ }
31+
32+ function configurePrivateKey () internal view virtual returns (uint256 privateKey ) {
33+ privateKey = vm.envOr ({
34+ name: "PRIVATE_KEY " ,
35+ defaultValue: vm.deriveKey ({
36+ mnemonic: vm.envOr ({name: "MNEMONIC " , defaultValue: DEFAULT_MNEMONIC}),
37+ index: uint8 (vm.envOr ({name: "EOA_INDEX " , defaultValue: uint256 (0 )}))
38+ })
39+ });
40+ }
41+
42+ function generateJson (string memory path , string memory name , address instance , bytes32 salt ) internal virtual {
43+ string memory json = "json " ;
44+ json.serialize ("address " , instance);
45+ json.serialize ("blockNumber " , vm.getBlockNumber ());
46+ json.serialize ("timestamp " , vm.getBlockTimestamp ());
47+ json.serialize ("salt " , salt);
48+ json = json.serialize ("name " , name);
49+ json.write (path);
50+ }
51+
52+ function promptChains () internal virtual returns (string [] memory chainAliases ) {
53+ string memory input = prompt ("Chains separated by ',' " , defaultChains ());
54+ return vm.split (vm.replace (input, " " , "" ), ", " );
55+ }
56+
57+ function prompt (string memory promptText ) internal returns (string memory input ) {
58+ return prompt (promptText, new string (0 ));
59+ }
60+
61+ function prompt (string memory promptText , string memory defaultValue ) internal returns (string memory input ) {
62+ input = vm.prompt (string .concat (promptText, " (default: ` " , defaultValue, "`) " ));
63+ if (bytes (input).length == 0 ) input = defaultValue;
64+ }
65+
66+ function promptAddress (string memory promptText , address defaultValue ) internal returns (address ) {
67+ return vm.parseAddress (prompt (promptText, vm.toString (defaultValue)));
68+ }
69+
70+ function promptAddress (string memory promptText ) internal returns (address ) {
71+ return promptAddress (promptText, address (0 ));
72+ }
73+
74+ function promptBool (string memory promptText , bool defaultValue ) internal returns (bool ) {
75+ return vm.parseBool (prompt (promptText, vm.toString (defaultValue)));
76+ }
77+
78+ function promptBool (string memory promptText ) internal returns (bool ) {
79+ return promptBool (promptText, false );
80+ }
81+
82+ function promptUint256 (string memory promptText , uint256 defaultValue ) internal returns (uint256 ) {
83+ return vm.parseUint (prompt (promptText, vm.toString (defaultValue)));
84+ }
85+
86+ function promptUint256 (string memory promptText ) internal returns (uint256 ) {
87+ return promptUint256 (promptText, uint256 (0 ));
88+ }
89+
90+ function promptInt256 (string memory promptText , int256 defaultValue ) internal returns (int256 ) {
91+ return vm.parseInt (prompt (promptText, vm.toString (defaultValue)));
92+ }
93+
94+ function promptInt256 (string memory promptText ) internal returns (int256 ) {
95+ return promptInt256 (promptText, int256 (0 ));
96+ }
97+
98+ function promptBytes32 (string memory promptText , bytes32 defaultValue ) internal returns (bytes32 ) {
99+ return vm.parseBytes32 (prompt (promptText, vm.toString (defaultValue)));
100+ }
101+
102+ function promptBytes32 (string memory promptText ) internal returns (bytes32 ) {
103+ return promptBytes32 (promptText, bytes32 (0 ));
104+ }
105+
106+ function promptBytes (string memory promptText , bytes memory defaultValue ) internal returns (bytes memory ) {
107+ return vm.parseBytes (prompt (promptText, vm.toString (defaultValue)));
108+ }
109+
110+ function promptBytes (string memory promptText ) internal returns (bytes memory ) {
111+ return promptBytes (promptText, new bytes (0 ));
112+ }
113+
114+ function defaultChains () internal view virtual returns (string memory chains ) {
115+ return DEFAULT_CHAINS;
116+ }
117+
118+ function defaultSalt () internal view virtual returns (bytes32 ) {
119+ return bytes32 (0 );
120+ }
121121}
0 commit comments