Skip to content

Commit c3dc52a

Browse files
committed
rename DON registry to Capabilities Registry
1 parent 6aa9066 commit c3dc52a

7 files changed

+137
-137
lines changed

contracts/src/v0.8/workflow/dev/v2/WorkflowRegistry.sol

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ contract WorkflowRegistry is Ownable2StepMsgSender, ITypeAndVersion {
107107
/// Tracks every user that currently has an override for a specific DON.
108108
mapping(bytes32 donHash => EnumerableSet.AddressSet userOverrides) private s_donOverrideUsers;
109109

110-
/// @dev Stores the current DON Registry reference used by this contract.
111-
DONRegistryConfig private s_donRegistry;
110+
/// @dev Stores the current Capabilities Registry reference used by this contract.
111+
CapabilitiesRegistryConfig private s_capabilitiesRegistry;
112112
/// @dev Storage of all capacity and workflow life‑cycle events
113113
EventRecord[] private s_events;
114114

@@ -144,7 +144,7 @@ contract WorkflowRegistry is Ownable2StepMsgSender, ITypeAndVersion {
144144
/// @notice Emitted when a workflow owner’s config is updated
145145
event WorkflowOwnerConfigUpdated(address indexed owner, bytes config);
146146
/// @notice Emitted whenever the registry reference is changed.
147-
event DONRegistryUpdated(address oldAddr, address newAddr, uint64 oldChainSelector, uint64 newChainSelector);
147+
event CapabilitiesRegistryUpdated(address oldAddr, address newAddr, uint64 oldChainSelector, uint64 newChainSelector);
148148

149149
// ================================================================
150150
// | Errors |
@@ -266,10 +266,10 @@ contract WorkflowRegistry is Ownable2StepMsgSender, ITypeAndVersion {
266266
uint32 limit;
267267
}
268268

269-
/// @notice DONRegistryConfig struct stores the pointer to the DON Registry this Workflow Registry uses.
269+
/// @notice CapabilitiesRegistryConfig struct stores the pointer to the Capabilities Registry this Workflow Registry uses.
270270
/// @dev `registry` is the contract address; `chainSelector` identifies the
271271
/// chain where the registry lives (Chainlink selector).
272-
struct DONRegistryConfig {
272+
struct CapabilitiesRegistryConfig {
273273
address registry;
274274
uint64 chainSelector;
275275
}
@@ -553,36 +553,36 @@ contract WorkflowRegistry is Ownable2StepMsgSender, ITypeAndVersion {
553553
}
554554

555555
// ================================================================
556-
// | DON registry |
556+
// | Capabilities Registry |
557557
// ================================================================
558-
/// @notice Sets or replaces the DON Registry that this Workflow Registry points to.
558+
/// @notice Sets or replaces the Capabilities Registry that this Workflow Registry points to.
559559
/// @dev Owner-only. Overwrites the previous entry and emits
560-
/// {DONRegistryUpdated}.
561-
/// @param registry Address of the DON Registry contract.
560+
/// {CapabilitiesRegistryUpdated}.
561+
/// @param registry Address of the Capabilities Registry contract.
562562
/// @param chainSelector Chain selector for the registry’s chain.
563-
function setDONRegistry(address registry, uint64 chainSelector) external onlyOwner {
564-
address oldRegistry = s_donRegistry.registry;
565-
uint64 oldChain = s_donRegistry.chainSelector;
563+
function setCapabilitiesRegistry(address registry, uint64 chainSelector) external onlyOwner {
564+
address oldRegistry = s_capabilitiesRegistry.registry;
565+
uint64 oldChain = s_capabilitiesRegistry.chainSelector;
566566

567567
if (registry == oldRegistry && chainSelector == oldChain) {
568568
return;
569569
}
570570

571571
if (registry != oldRegistry) {
572-
s_donRegistry.registry = registry;
572+
s_capabilitiesRegistry.registry = registry;
573573
}
574574
if (chainSelector != oldChain) {
575-
s_donRegistry.chainSelector = chainSelector;
575+
s_capabilitiesRegistry.chainSelector = chainSelector;
576576
}
577577

578-
emit DONRegistryUpdated(oldRegistry, registry, oldChain, chainSelector);
578+
emit CapabilitiesRegistryUpdated(oldRegistry, registry, oldChain, chainSelector);
579579
}
580580

581-
/// @notice Returns the current DON Registry reference and its chain selector.
582-
/// @return Address of the DON Registry contract.
581+
/// @notice Returns the current Capabilities Registry reference and its chain selector.
582+
/// @return Address of the Capabilities Registry contract.
583583
/// @return Chain selector for the registry’s chain.
584-
function getDONRegistry() external view returns (address, uint64) {
585-
return (s_donRegistry.registry, s_donRegistry.chainSelector);
584+
function getCapabilitiesRegistry() external view returns (address, uint64) {
585+
return (s_capabilitiesRegistry.registry, s_capabilitiesRegistry.chainSelector);
586586
}
587587

588588
// ================================================================
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: BUSL 1.1
2+
pragma solidity 0.8.26;
3+
4+
import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol";
5+
6+
contract WorkflowRegistry_getCapabilitiesRegistry is WorkflowRegistrySetup {
7+
function test_getCapabilitiesRegistry_WhenTheRegistryHasnNotBeenSetYet() external view {
8+
// it should return address 0, 0
9+
10+
(address capRegValue, uint64 chainSelValue) = s_registry.getCapabilitiesRegistry();
11+
assertEq(chainSelValue, 0);
12+
assertEq(capRegValue, address(0));
13+
}
14+
15+
function test_getCapabilitiesRegistry_WhenTheRegistryHasBeenSet() external {
16+
// it should return the Capabilities Registry values
17+
18+
// set the Capabilities Registry
19+
vm.prank(s_owner);
20+
address capRegAddr = makeAddr("cap-registry-address");
21+
uint64 chainSel = 123456;
22+
s_registry.setCapabilitiesRegistry(capRegAddr, chainSel);
23+
24+
(address capRegValue, uint64 chainSelValue) = s_registry.getCapabilitiesRegistry();
25+
assertEq(chainSelValue, chainSel);
26+
assertEq(capRegValue, capRegAddr);
27+
}
28+
}

contracts/src/v0.8/workflow/dev/v2/test/WorkflowRegistry/WorkflowRegistry.getDONRegistry.tree renamed to contracts/src/v0.8/workflow/dev/v2/test/WorkflowRegistry/WorkflowRegistry.getCapabilitiesRegistry.tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
WorkflowRegistry_getDONRegistry
1+
WorkflowRegistry_getCapabilitiesRegistry
22
├── when the registry hasn not been set yet
33
│ └── it should return address 0, 0
44
└── when the registry has been set
5-
└── it should return the DON registry values
5+
└── it should return the Capabilities registry values

contracts/src/v0.8/workflow/dev/v2/test/WorkflowRegistry/WorkflowRegistry.getDONRegistry.t.sol

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// SPDX-License-Identifier: BUSL 1.1
2+
pragma solidity 0.8.26;
3+
4+
import {Ownable2Step} from "../../../../../shared/access/Ownable2Step.sol";
5+
6+
import {WorkflowRegistry} from "../../WorkflowRegistry.sol";
7+
import {WorkflowRegistrySetup} from "./WorkflowRegistrySetup.t.sol";
8+
import {Vm} from "forge-std/Test.sol";
9+
10+
contract WorkflowRegistry_setCapabilitiesRegistry is WorkflowRegistrySetup {
11+
function test_setCapabilitiesRegistry_WhenTheCallerIsNOTTheContractOwner() external {
12+
// It should revert with caller is not the owner
13+
vm.prank(s_stranger);
14+
address capReg = makeAddr("cap-registry-address");
15+
vm.expectRevert(abi.encodeWithSelector(Ownable2Step.OnlyCallableByOwner.selector, s_stranger));
16+
s_registry.setCapabilitiesRegistry(capReg, 123456);
17+
}
18+
19+
// whenTheCallerISTheContractOwner
20+
function test_setCapabilitiesRegistry_WhenThereAreNoExistingRegistries() external {
21+
// It should write to s_capabilitiesRegistry with the pair and emit CapabilitiesRegistryUpdated
22+
vm.prank(s_owner);
23+
address capReg = makeAddr("cap-registry-address");
24+
uint64 chainSel = 123456;
25+
26+
vm.expectEmit(true, true, true, false);
27+
emit WorkflowRegistry.CapabilitiesRegistryUpdated(address(0), capReg, uint64(0), chainSel);
28+
s_registry.setCapabilitiesRegistry(capReg, chainSel);
29+
30+
(address capRegValue, uint64 chainSelValue) = s_registry.getCapabilitiesRegistry();
31+
assertEq(chainSelValue, chainSel);
32+
assertEq(capRegValue, capReg);
33+
}
34+
35+
// whenTheCallerISTheContractOwner
36+
function test_setCapabilitiesRegistry_WhenBothRegistryAndChainSelectorDifferFromTheCurrentValues() external {
37+
// It should overwrite s_capabilitiesRegistry with the new pair and emit CapabilitiesRegistryUpdated
38+
39+
vm.startPrank(s_owner);
40+
// set the capabilities registry
41+
address capReg = makeAddr("cap-registry-address");
42+
uint64 chainSel = 123456;
43+
44+
s_registry.setCapabilitiesRegistry(capReg, chainSel);
45+
46+
// set it with different values
47+
address newCapReg = makeAddr("cap-registry-address-2");
48+
uint64 newChainSel = 678910;
49+
50+
s_registry.setCapabilitiesRegistry(newCapReg, newChainSel);
51+
52+
(address capRegValue, uint64 chainSelValue) = s_registry.getCapabilitiesRegistry();
53+
assertEq(chainSelValue, newChainSel);
54+
assertEq(capRegValue, newCapReg);
55+
vm.stopPrank();
56+
}
57+
58+
// whenTheCallerISTheContractOwner
59+
function test_setCapabilitiesRegistry_WhenBothRegistryAndChainSelectorAreTheSameAsCurrent() external {
60+
// It should do nothing
61+
62+
vm.startPrank(s_owner);
63+
// set the capabilities registry
64+
address capReg = makeAddr("cap-registry-address");
65+
uint64 chainSel = 123456;
66+
s_registry.setCapabilitiesRegistry(capReg, chainSel);
67+
68+
// set the same registry again
69+
vm.recordLogs();
70+
s_registry.setCapabilitiesRegistry(capReg, chainSel);
71+
72+
Vm.Log[] memory entries = vm.getRecordedLogs();
73+
bytes32 sig = keccak256("CapabilitiesRegistryUpdated(address,address,uint64,uint64)");
74+
for (uint256 i = 0; i < entries.length; i++) {
75+
if (entries[i].topics[0] == sig) {
76+
emit log("CapabilitiesRegistryUpdated was emitted when it should not have been");
77+
fail();
78+
}
79+
}
80+
81+
(address capRegValue, uint64 chainSelValue) = s_registry.getCapabilitiesRegistry();
82+
assertEq(chainSelValue, chainSel);
83+
assertEq(capRegValue, capReg);
84+
85+
vm.stopPrank();
86+
}
87+
}

contracts/src/v0.8/workflow/dev/v2/test/WorkflowRegistry/WorkflowRegistry.setDONRegistry.tree renamed to contracts/src/v0.8/workflow/dev/v2/test/WorkflowRegistry/WorkflowRegistry.setCapabilitiesRegistry.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
WorkflowRegistry.setDONRegistry
1+
WorkflowRegistry.setCapabilitiesRegistry
22
├── When the caller is NOT the contract owner
33
│ └── It should revert with caller is not the owner
44
└── When the caller IS the contract owner

contracts/src/v0.8/workflow/dev/v2/test/WorkflowRegistry/WorkflowRegistry.setDONRegistry.t.sol

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

0 commit comments

Comments
 (0)