diff --git a/contracts/src/v0.8/ccip/capability/CCIPConfig.sol b/contracts/src/v0.8/ccip/capability/CCIPConfig.sol index 3f3e99ed91..e6135e78db 100644 --- a/contracts/src/v0.8/ccip/capability/CCIPConfig.sol +++ b/contracts/src/v0.8/ccip/capability/CCIPConfig.sol @@ -149,7 +149,7 @@ contract CCIPConfig is ITypeAndVersion, ICapabilityConfiguration, OwnerIsCreator /// @notice Returns all the chain configurations. /// @return paginatedChainConfigs chain configurations. - function getAllChainConfigs(uint256 pageIndex, uint256 pageSize) external view returns (ChainConfigInfo[] memory paginatedChainConfigs) { + function getAllChainConfigs(uint256 pageIndex, uint256 pageSize) external view returns (ChainConfigInfo[] memory) { uint256 totalItems = s_remoteChainSelectors.length(); // Total number of chain selectors if (pageSize == 0 || pageIndex * pageSize >= totalItems) { return new ChainConfigInfo[](0); // Return an empty array if pageSize is 0 or pageIndex is out of bounds @@ -158,7 +158,7 @@ contract CCIPConfig is ITypeAndVersion, ICapabilityConfiguration, OwnerIsCreator uint256 startIndex = pageIndex * pageSize; uint256 endIndex = startIndex + pageSize > totalItems ? totalItems : startIndex + pageSize; - paginatedChainConfigs = new ChainConfigInfo[](endIndex - startIndex); + ChainConfigInfo[] memory paginatedChainConfigs = new ChainConfigInfo[](endIndex - startIndex); uint256[] memory chainSelectors = s_remoteChainSelectors.values(); for (uint256 i = startIndex; i < endIndex; ++i) { @@ -166,6 +166,8 @@ contract CCIPConfig is ITypeAndVersion, ICapabilityConfiguration, OwnerIsCreator paginatedChainConfigs[i - startIndex] = ChainConfigInfo({chainSelector: chainSelector, chainConfig: s_chainConfigurations[chainSelector]}); } + + return paginatedChainConfigs; } /// @notice Returns the OCR configuration for the given don ID and plugin type. diff --git a/contracts/src/v0.8/ccip/test/capability/CCIPConfig.t.sol b/contracts/src/v0.8/ccip/test/capability/CCIPConfig.t.sol index fe8ad23fa1..2409e653e2 100644 --- a/contracts/src/v0.8/ccip/test/capability/CCIPConfig.t.sol +++ b/contracts/src/v0.8/ccip/test/capability/CCIPConfig.t.sol @@ -124,7 +124,7 @@ contract CCIPConfig_chainConfig is CCIPConfigSetup { emit CCIPConfig.ChainConfigSet(2, adds[1].chainConfig); s_ccipCC.applyChainConfigUpdates(new uint64[](0), adds); - CCIPCapabilityConfiguration.ChainConfigInfo[] memory configs = s_ccipCC.getAllChainConfigs(0, 2); + CCIPConfig.ChainConfigInfo[] memory configs = s_ccipCC.getAllChainConfigs(0, 2); assertEq(configs.length, 2, "chain configs length must be 2"); assertEq(configs[0].chainSelector, 1, "chain selector must match"); assertEq(configs[1].chainSelector, 2, "chain selector must match"); @@ -139,6 +139,9 @@ contract CCIPConfig_chainConfig is CCIPConfigSetup { assertEq(configs[1].chainSelector, 2, "chain selector must match"); configs = s_ccipCC.getAllChainConfigs(1, 1); + assertEq(configs.length, 1, "chain configs length must be 1"); + + configs = s_ccipCC.getAllChainConfigs(1, 2); assertEq(configs.length, 0, "chain configs length must be 0"); }