Skip to content

Commit 2b902cd

Browse files
committed
feat: chainIDs
1 parent fa0f527 commit 2b902cd

File tree

2 files changed

+52
-28
lines changed

2 files changed

+52
-28
lines changed

src/contracts/interfaces/ICrossChainRegistry.sol

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ interface ICrossChainRegistryErrors {
3737

3838
/// @notice Thrown when the operator set is not valid
3939
error InvalidOperatorSet();
40+
41+
/// @notice Thrown when the chainIDs array is empty
42+
error EmptyChainIDsArray();
4043
}
4144

4245
interface ICrossChainRegistryTypes {
@@ -140,21 +143,21 @@ interface ICrossChainRegistry is ICrossChainRegistryErrors, ICrossChainRegistryE
140143
function removeTransportDestinations(OperatorSet calldata operatorSet, uint32[] calldata chainIDs) external;
141144

142145
/**
143-
* @notice Adds a chainID to the whitelist of chainIDs that can be transported to
144-
* @param chainID the chainID to add to the whitelist
146+
* @notice Adds chainIDs to the whitelist of chainIDs that can be transported to
147+
* @param chainIDs the chainIDs to add to the whitelist
145148
* @dev msg.sender must be the owner of the CrossChainRegistry
146149
*/
147-
function addChainIDToWhitelist(
148-
uint32 chainID
150+
function addChainIDsToWhitelist(
151+
uint32[] calldata chainIDs
149152
) external;
150153

151154
/**
152-
* @notice Removes a chainID from the whitelist of chainIDs that can be transported to
153-
* @param chainID the chainID to remove from the whitelist
155+
* @notice Removes chainIDs from the whitelist of chainIDs that can be transported to
156+
* @param chainIDs the chainIDs to remove from the whitelist
154157
* @dev msg.sender must be the owner of the CrossChainRegistry
155158
*/
156-
function removeChainIDFromWhitelist(
157-
uint32 chainID
159+
function removeChainIDsFromWhitelist(
160+
uint32[] calldata chainIDs
158161
) external;
159162

160163
/**

src/multichain/CrossChainRegistry.sol

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ contract CrossChainRegistry is
4343
_;
4444
}
4545

46+
/**
47+
* @dev Validates that the chainIDs array is not empty
48+
* @param chainIDs The array of chain IDs to validate
49+
*/
50+
modifier nonEmptyChainIDsArray(
51+
uint32[] calldata chainIDs
52+
) {
53+
require(chainIDs.length > 0, EmptyChainIDsArray());
54+
_;
55+
}
56+
4657
/**
4758
*
4859
* INITIALIZING FUNCTIONS
@@ -183,6 +194,7 @@ contract CrossChainRegistry is
183194
onlyWhenNotPaused(PAUSED_TRANSPORT_DESTINATIONS)
184195
checkCanCall(operatorSet.avs)
185196
isValidOperatorSet(operatorSet)
197+
nonEmptyChainIDsArray(chainIDs)
186198
{
187199
bytes32 operatorSetKey = operatorSet.key();
188200

@@ -205,6 +217,7 @@ contract CrossChainRegistry is
205217
onlyWhenNotPaused(PAUSED_TRANSPORT_DESTINATIONS)
206218
checkCanCall(operatorSet.avs)
207219
isValidOperatorSet(operatorSet)
220+
nonEmptyChainIDsArray(chainIDs)
208221
{
209222
bytes32 operatorSetKey = operatorSet.key();
210223

@@ -222,33 +235,41 @@ contract CrossChainRegistry is
222235
}
223236

224237
/// @inheritdoc ICrossChainRegistry
225-
function addChainIDToWhitelist(
226-
uint32 chainID
227-
) external onlyOwner onlyWhenNotPaused(PAUSED_CHAIN_WHITELIST) {
228-
// Validate chainID
229-
require(chainID != 0, InvalidChainId());
230-
// Check if already whitelisted
231-
require(!_whitelistedChainIDs.contains(chainID), ChainIDAlreadyWhitelisted());
238+
function addChainIDsToWhitelist(
239+
uint32[] calldata chainIDs
240+
) external onlyOwner onlyWhenNotPaused(PAUSED_CHAIN_WHITELIST) nonEmptyChainIDsArray(chainIDs) {
241+
for (uint256 i = 0; i < chainIDs.length; i++) {
242+
uint32 chainID = chainIDs[i];
243+
244+
// Validate chainID
245+
require(chainID != 0, InvalidChainId());
246+
// Check if already whitelisted
247+
require(!_whitelistedChainIDs.contains(chainID), ChainIDAlreadyWhitelisted());
232248

233-
// Add to whitelist
234-
_whitelistedChainIDs.add(chainID);
249+
// Add to whitelist
250+
_whitelistedChainIDs.add(chainID);
235251

236-
emit ChainIDAddedToWhitelist(chainID);
252+
emit ChainIDAddedToWhitelist(chainID);
253+
}
237254
}
238255

239256
/// @inheritdoc ICrossChainRegistry
240-
function removeChainIDFromWhitelist(
241-
uint32 chainID
242-
) external onlyOwner onlyWhenNotPaused(PAUSED_CHAIN_WHITELIST) {
243-
// Validate chainID
244-
require(chainID != 0, InvalidChainId());
245-
// Check if whitelisted
246-
require(_whitelistedChainIDs.contains(chainID), ChainIDNotWhitelisted());
257+
function removeChainIDsFromWhitelist(
258+
uint32[] calldata chainIDs
259+
) external onlyOwner onlyWhenNotPaused(PAUSED_CHAIN_WHITELIST) nonEmptyChainIDsArray(chainIDs) {
260+
for (uint256 i = 0; i < chainIDs.length; i++) {
261+
uint32 chainID = chainIDs[i];
247262

248-
// Remove from whitelist
249-
_whitelistedChainIDs.remove(chainID);
263+
// Validate chainID
264+
require(chainID != 0, InvalidChainId());
265+
// Check if whitelisted
266+
require(_whitelistedChainIDs.contains(chainID), ChainIDNotWhitelisted());
250267

251-
emit ChainIDRemovedFromWhitelist(chainID);
268+
// Remove from whitelist
269+
_whitelistedChainIDs.remove(chainID);
270+
271+
emit ChainIDRemovedFromWhitelist(chainID);
272+
}
252273
}
253274

254275
/**

0 commit comments

Comments
 (0)