Skip to content

Commit

Permalink
chore: minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 committed Dec 12, 2023
1 parent 7c7da0e commit a3715e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 17 additions & 6 deletions script/BaseGeneralConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions script/sample/SampleGeneralConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a3715e5

Please sign in to comment.