Skip to content

Commit

Permalink
Merge pull request #6 from axieinfinity/implement-feature/migration-s…
Browse files Browse the repository at this point in the history
…cript/refactor-migration-script

feat(migration-script): implement `refactor-migration-script`
  • Loading branch information
TuDo1403 authored Dec 12, 2023
2 parents 37f5284 + a3715e5 commit 63507d8
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 63507d8

Please sign in to comment.