Skip to content

Commit 2e61e02

Browse files
authored
fix: zeta registry contracts (#525)
1 parent a2b6c07 commit 2e61e02

File tree

61 files changed

+4423
-541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4423
-541
lines changed

broadcast/DeployCoreRegistry.s.sol/7000/run-latest.json

Lines changed: 175 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/DeployCoreRegistry.s.sol/7001/run-latest.json

Lines changed: 66 additions & 66 deletions
Large diffs are not rendered by default.

broadcast/DeployCoreRegistryImpl.s.sol/7000/run-latest.json

Lines changed: 61 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/DeployRegistry.s.sol/11155111/run-1747736905.json

Lines changed: 0 additions & 191 deletions
This file was deleted.

broadcast/DeployRegistry.s.sol/11155111/run-1747741983.json

Lines changed: 0 additions & 191 deletions
This file was deleted.

broadcast/DeployRegistry.s.sol/56/run-latest.json

Lines changed: 191 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/DeployRegistryImpl.s.sol/56/run-latest.json

Lines changed: 61 additions & 0 deletions
Large diffs are not rendered by default.

contracts/evm/Registry.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ contract Registry is BaseRegistry, IRegistry {
2929

3030
/// @notice Initialize the Registry contract
3131
/// @param admin_ Address with DEFAULT_ADMIN_ROLE, authorized for upgrades and pausing actions
32-
/// @param pauserAddress_ Address with PAUSER_ROLE, authorized for pausing actions
3332
/// @param registryManager_ Address with REGISTRY_MANAGER_ROLE, authorized for all registry write actions.
3433
/// @param gatewayEVM_ Address of the GatewayEVM contract for cross-chain messaging
3534
/// @param coreRegistry_ Address of the CoreRegistry contract deployed on ZetaChain
3635
function initialize(
3736
address admin_,
38-
address pauserAddress_,
3937
address registryManager_,
4038
address gatewayEVM_,
4139
address coreRegistry_
@@ -45,7 +43,7 @@ contract Registry is BaseRegistry, IRegistry {
4543
{
4644
if (
4745
admin_ == address(0) || gatewayEVM_ == address(0) || coreRegistry_ == address(0)
48-
|| pauserAddress_ == address(0) || registryManager_ == address(0)
46+
|| registryManager_ == address(0)
4947
) {
5048
revert ZeroAddress();
5149
}
@@ -55,11 +53,13 @@ contract Registry is BaseRegistry, IRegistry {
5553
__Pausable_init_unchained();
5654

5755
_grantRole(DEFAULT_ADMIN_ROLE, admin_);
58-
_grantRole(PAUSER_ROLE, admin_);
59-
_grantRole(PAUSER_ROLE, pauserAddress_);
6056
_grantRole(REGISTRY_MANAGER_ROLE, registryManager_);
57+
_grantRole(PAUSER_ROLE, registryManager_);
58+
_grantRole(PAUSER_ROLE, admin_);
6159
_grantRole(GATEWAY_ROLE, gatewayEVM_);
6260

61+
admin = admin_;
62+
registryManager = registryManager_;
6363
gatewayEVM = IGatewayEVM(gatewayEVM_);
6464
coreRegistry = coreRegistry_;
6565
}

contracts/helpers/BaseRegistry.sol

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ abstract contract BaseRegistry is
2020
/// @notice New role identifier for registry manager role.
2121
bytes32 public constant REGISTRY_MANAGER_ROLE = keccak256("REGISTRY_MANAGER_ROLE");
2222

23+
/// @notice Address with DEFAULT_ADMIN_ROLE, authorized for upgrades and pausing actions.
24+
address public admin;
25+
/// @notice Address with REGISTRY_MANAGER_ROLE, authorized for all registry write actions.
26+
address public registryManager;
2327
/// @notice Active chains in the registry.
2428
uint256[] internal _activeChains;
2529
/// @notice Array of all chain IDs in the registry (active and inactive).
@@ -58,19 +62,52 @@ abstract contract BaseRegistry is
5862
_unpause();
5963
}
6064

65+
/// @notice Changes the admin address and transfers DEFAULT_ADMIN_ROLE and PAUSER_ROLE.
66+
/// @dev Only callable by current admin.
67+
/// @param newAdmin The address of the new admin.
68+
function changeAdmin(address newAdmin) external onlyRole(DEFAULT_ADMIN_ROLE) {
69+
if (newAdmin == address(0)) revert ZeroAddress();
70+
71+
_grantRole(DEFAULT_ADMIN_ROLE, newAdmin);
72+
_grantRole(PAUSER_ROLE, newAdmin);
73+
74+
_revokeRole(DEFAULT_ADMIN_ROLE, admin);
75+
_revokeRole(PAUSER_ROLE, admin);
76+
77+
emit AdminChanged(admin, newAdmin);
78+
79+
admin = newAdmin;
80+
}
81+
82+
/// @notice Changes the registry manager address and transfers REGISTRY_MANAGER_ROLE and PAUSER_ROLE.
83+
/// @dev Only callable by admin.
84+
/// @param newRegistryManager The address of the new registry manager.
85+
function changeRegistryManager(address newRegistryManager) external onlyRole(DEFAULT_ADMIN_ROLE) {
86+
if (newRegistryManager == address(0)) revert ZeroAddress();
87+
88+
_grantRole(REGISTRY_MANAGER_ROLE, newRegistryManager);
89+
_grantRole(PAUSER_ROLE, newRegistryManager);
90+
91+
_revokeRole(REGISTRY_MANAGER_ROLE, registryManager);
92+
_revokeRole(PAUSER_ROLE, registryManager);
93+
94+
emit RegistryManagerChanged(registryManager, newRegistryManager);
95+
96+
registryManager = newRegistryManager;
97+
}
98+
6199
/// @notice Changes status of the chain to activated/deactivated.
62100
/// @param chainId The ID of the chain to activate.
63101
/// @param gasZRC20 The address of the ZRC20 token that represents gas token for the chain.
64102
/// @param registry Address of the Registry contract on the connected chain.
65103
/// @param activation Whether activate or deactivate the chain
66104
function _changeChainStatus(uint256 chainId, address gasZRC20, bytes calldata registry, bool activation) internal {
67-
if (registry.length == 0) revert ZeroAddress();
68105
// In the case chain is already activated
69106
if (_chains[chainId].active && activation) revert ChainActive(chainId);
70107
// In the case chain is inactive
71108
if (!_chains[chainId].active && !activation) revert ChainNonActive(chainId);
72109
// Check does chain already exist.
73-
if (bytes(_chains[chainId].registry).length == 0) {
110+
if (_chains[chainId].gasZRC20 == address(0) && chainId != block.chainid) {
74111
_allChains.push(chainId);
75112
}
76113

@@ -189,7 +226,6 @@ abstract contract BaseRegistry is
189226
// Validate inputs
190227
if (address_ == address(0)) revert ZeroAddress();
191228
if (bytes(symbol).length == 0) revert InvalidContractType("Symbol cannot be empty");
192-
if (bytes(originAddress).length == 0) revert InvalidContractType("Origin address cannot be empty");
193229

194230
// Check if token already registered
195231
if (_zrc20Tokens[address_].address_ != address(0)) revert ZRC20AlreadyRegistered(address_);

contracts/helpers/interfaces/IBaseRegistry.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ interface IBaseRegistryEvents {
126126
/// @param address_ The address of the ZRC20 token.
127127
/// @param active Whether the token should be active.
128128
event ZRC20TokenUpdated(address address_, bool active);
129+
130+
/// @notice Emitted when admin address is changed.
131+
/// @param oldAdmin The previous admin address.
132+
/// @param newAdmin The new admin address.
133+
event AdminChanged(address oldAdmin, address newAdmin);
134+
135+
/// @notice Emitted when registry manager address is changed.
136+
/// @param oldRegistryManager The previous registry manager address.
137+
/// @param newRegistryManager The new registry manager address.
138+
event RegistryManagerChanged(address oldRegistryManager, address newRegistryManager);
129139
}
130140

131141
/// @title IBaseRegistryErrors

0 commit comments

Comments
 (0)