From 378a9fb11dd2e2eed2edfa4fcf440a6aa4d90618 Mon Sep 17 00:00:00 2001 From: defiQUG Date: Mon, 8 Jun 2026 06:51:46 -0700 Subject: [PATCH] fix(registry): one-time setRegistry on GRUAssetRegistryFacet (GRU-005). Prevent post-init registry pointer swaps; add test_setRegistry_oneTimeOnly (8/8 GRUCompliantTokensRegistryTest). Co-authored-by: Cursor --- contracts/registry/GRUAssetRegistryFacet.sol | 3 ++- test/integration/GRUCompliantTokensRegistry.t.sol | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/contracts/registry/GRUAssetRegistryFacet.sol b/contracts/registry/GRUAssetRegistryFacet.sol index ec67162..dee2f29 100644 --- a/contracts/registry/GRUAssetRegistryFacet.sol +++ b/contracts/registry/GRUAssetRegistryFacet.sol @@ -13,8 +13,9 @@ contract GRUAssetRegistryFacet { event RegistrySet(address indexed registry); - /// @notice Set the UniversalAssetRegistry to delegate to. Call from Diamond cut init (only Diamond owner can execute cut). + /// @notice One-time set of UniversalAssetRegistry delegate. Callable once (diamond cut init or standalone deploy). function setRegistry(address _registry) external { + require(address(registry) == address(0), "RegistryAlreadySet"); require(_registry != address(0), "Zero registry"); registry = UniversalAssetRegistry(_registry); emit RegistrySet(_registry); diff --git a/test/integration/GRUCompliantTokensRegistry.t.sol b/test/integration/GRUCompliantTokensRegistry.t.sol index ebf9f37..557d69d 100644 --- a/test/integration/GRUCompliantTokensRegistry.t.sol +++ b/test/integration/GRUCompliantTokensRegistry.t.sol @@ -53,6 +53,13 @@ contract GRUCompliantTokensRegistryTest is Test { vm.stopPrank(); } + function test_setRegistry_oneTimeOnly() public { + GRUAssetRegistryFacet localFacet = new GRUAssetRegistryFacet(); + localFacet.setRegistry(address(registry)); + vm.expectRevert("RegistryAlreadySet"); + localFacet.setRegistry(makeAddr("otherRegistry")); + } + function test_registerGRUCompliantAsset_cUSDT() public { vm.prank(admin); registry.registerGRUCompliantAsset(