Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add setUpDefaultNetworks and setUpDefaultContracts #7

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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