@@ -49,7 +49,7 @@ abstract contract BaseScript is Script {
4949
5050 constructor () {
5151 _loadChains ();
52- _loadContracts (false );
52+ _loadDeployedContracts (false );
5353 }
5454
5555 function _loadChains () private {
@@ -69,6 +69,28 @@ abstract contract BaseScript is Script {
6969 }
7070 }
7171
72+ /**
73+ * @notice _loadDeployedContractsInSimulation - Load deployed contracts in simulation
74+ * too.
75+ */
76+ function _loadDeployedContractsInSimulation () internal {
77+ _loadDeployedContracts (true );
78+ }
79+
80+ function _loadDeployedContracts (bool _loadInSimulation ) private {
81+ if (! _loadInSimulation && _isSimulation ()) return ;
82+
83+ Deployment[] memory deployments = _getDeployedContracts (_getNetwork ());
84+
85+ Deployment memory cached;
86+ uint256 length = deployments.length ;
87+ for (uint256 i = 0 ; i < length; ++ i) {
88+ cached = deployments[i];
89+ contracts[cached.contractName] = cached.contractAddress;
90+ vm.label (cached.contractAddress, cached.contractName);
91+ }
92+ }
93+
7294 //Entrypoint for the script
7395 function run () external virtual ;
7496
@@ -272,25 +294,6 @@ abstract contract BaseScript is Script {
272294 return currentNetwork == localNetwork;
273295 }
274296
275- /**
276- * @notice _loadContracts - Loads the deployed contracts from the current network inside
277- * the mapping "contracts"
278- * @param _loadInSimulation If it should load in simulation
279- */
280- function _loadContracts (bool _loadInSimulation ) internal {
281- if (! _loadInSimulation && _isSimulation ()) return ;
282-
283- Deployment[] memory deployments = _getDeployedContracts (_getNetwork ());
284-
285- Deployment memory cached;
286- uint256 length = deployments.length ;
287- for (uint256 i = 0 ; i < length; ++ i) {
288- cached = deployments[i];
289- contracts[cached.contractName] = cached.contractAddress;
290- vm.label (cached.contractAddress, cached.contractName);
291- }
292- }
293-
294297 /**
295298 * @notice _loadOtherContractNetwork - Loads the deployed contracts from a network
296299 * inside the mapping "contractsOtherNetworks"
0 commit comments