From a3715e55c41d6db4f608294c78968e1199be4ef5 Mon Sep 17 00:00:00 2001 From: TuDo1403 Date: Tue, 12 Dec 2023 10:19:22 +0700 Subject: [PATCH] chore: minor refactor --- script/BaseGeneralConfig.sol | 23 +++++++++++++++++------ script/sample/SampleGeneralConfig.sol | 2 -- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/script/BaseGeneralConfig.sol b/script/BaseGeneralConfig.sol index 437796e..f99ff2a 100644 --- a/script/BaseGeneralConfig.sol +++ b/script/BaseGeneralConfig.sol @@ -37,13 +37,19 @@ contract BaseGeneralConfig is RuntimeConfig, WalletConfig, ContractConfig, Netwo NetworkConfig(deploymentRoot) ContractConfig(absolutePath, deploymentRoot) { - _setUpNetworks(); - _setUpContracts(); + _setUpDefaultNetworks(); + _setUpDefaultContracts(); _setUpDefaultSender(); _storeDeploymentData(deploymentRoot); } - function _setUpNetworks() internal virtual { + function _setUpNetworks() internal virtual { } + + function _setUpContracts() internal virtual { } + + function _setUpSender() internal virtual { } + + function _setUpDefaultNetworks() private { setNetworkInfo( DefaultNetwork.Local.chainId(), DefaultNetwork.Local.key(), @@ -68,26 +74,31 @@ contract BaseGeneralConfig is RuntimeConfig, WalletConfig, ContractConfig, Netwo DefaultNetwork.RoninMainnet.envLabel(), DefaultNetwork.RoninMainnet.explorer() ); + + _setUpNetworks(); } - function _setUpContracts() internal virtual { + function _setUpDefaultContracts() private { _contractNameMap[DefaultContract.ProxyAdmin.key()] = DefaultContract.ProxyAdmin.name(); - setAddress( DefaultNetwork.RoninTestnet.key(), DefaultContract.ProxyAdmin.key(), 0x505d91E8fd2091794b45b27f86C045529fa92CD7 ); setAddress( DefaultNetwork.RoninMainnet.key(), DefaultContract.ProxyAdmin.key(), 0xA3e7d085E65CB0B916f6717da876b7bE5cC92f03 ); + + _setUpContracts(); } - function _setUpDefaultSender() internal virtual { + function _setUpDefaultSender() private { // by default we will read private key from .env _envPk = vm.envUint(getPrivateKeyEnvLabel(getCurrentNetwork())); _envSender = vm.rememberKey(_envPk); label(block.chainid, _envSender, "ENVSender"); console.log("GeneralConfig:", vm.getLabel(_envSender)); + + _setUpSender(); } function getSender() public view virtual override returns (address payable sender) { diff --git a/script/sample/SampleGeneralConfig.sol b/script/sample/SampleGeneralConfig.sol index 2384c5a..3466e4f 100644 --- a/script/sample/SampleGeneralConfig.sol +++ b/script/sample/SampleGeneralConfig.sol @@ -8,8 +8,6 @@ contract SampleGeneralConfig is BaseGeneralConfig { constructor() BaseGeneralConfig("", "deployments/") { } function _setUpContracts() internal virtual override { - super._setUpContracts(); - _contractNameMap[Contract.Sample.key()] = Contract.Sample.name(); // {SamepleClone} share same logic as {Sample} _contractNameMap[Contract.SampleClone.key()] = Contract.Sample.name();