diff --git a/script/helpers/PantosBaseAddresses.s.sol b/script/helpers/PantosBaseAddresses.s.sol index edb7336..2c8dfc3 100644 --- a/script/helpers/PantosBaseAddresses.s.sol +++ b/script/helpers/PantosBaseAddresses.s.sol @@ -24,6 +24,7 @@ import {PantosBaseScript} from "./PantosBaseScript.s.sol"; abstract contract PantosBaseAddresses is PantosBaseScript { enum Contract { + GENERIC, HUB_PROXY, HUB_INIT, DIAMOND_CUT_FACET, @@ -67,9 +68,9 @@ abstract contract PantosBaseAddresses is PantosBaseScript { string private constant _contractSerializer = "address"; mapping(BlockchainId => mapping(Contract => ContractInfo)) - private _otherChaincontractInfo; + internal _otherChaincontractInfo; mapping(Contract => CurrentChainContractInfo) - private _currentChainContractInfo; + internal _currentChainContractInfo; mapping(string => Contract) internal _keysToContracts; Blockchain private thisBlockchain; diff --git a/script/helpers/SafeAddresses.s.sol b/script/helpers/SafeAddresses.s.sol index 1ff4df6..c0c6b8e 100644 --- a/script/helpers/SafeAddresses.s.sol +++ b/script/helpers/SafeAddresses.s.sol @@ -35,6 +35,21 @@ contract SafeAddresses is PantosBaseScript { Blockchain private thisBlockchain; + modifier onlyValidRoleName(string memory roleName) { + bool isValidRoleName = false; + for (uint256 i = 0; i < getRolesLength(); i++) { + if ( + keccak256(abi.encodePacked(_roleInfo[Role(i)].key)) == + keccak256(abi.encodePacked(roleName)) + ) { + isValidRoleName = true; + break; + } + } + require(isValidRoleName, "Invalid role name"); + _; + } + function getRoleAddress(Role role) public view returns (address) { address roleAddress = _roleInfo[role].address_; require(roleAddress != address(0), "Error: Address is zero"); @@ -129,8 +144,9 @@ contract SafeAddresses is PantosBaseScript { writeSafeInfo(safeAddresses); } - function getRole(string memory roleName) public view returns (Role) { - require(_keysToRoles[roleName] != Role(0), "Role does not exist"); + function getRole( + string memory roleName + ) public view onlyValidRoleName(roleName) returns (Role) { return _keysToRoles[roleName]; }