Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/interfaces/IRecipientRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ interface IRecipientRegistry {
event RecipientRemoved(address indexed recipient);

/// @notice Emitted when the queue is processed and recipients are updated
/// @param added Number of recipients added in this processing
/// @param removed Number of recipients removed in this processing
event QueueProcessed(uint256 added, uint256 removed);
/// @param addedRecipients Array of addresses that were added
/// @param removedRecipients Array of addresses that were removed
/// @param newRecipientList Array of all active recipients after processing
event QueueProcessed(address[] addedRecipients, address[] removedRecipients, address[] newRecipientList);

// Errors
/// @notice Thrown when attempting to use the zero address as a recipient
Expand Down
14 changes: 12 additions & 2 deletions src/modules/BaseRecipientRegistry.sol
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unclear why the handling for removed recipients here is different that hte ones for addition? can they both be stored for the event emission in the same way?

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ abstract contract BaseRecipientRegistry is IRecipientRegistry, OwnableUpgradeabl
/// @dev Processes all queued additions and removals, then clears the queues
/// @dev Emits RecipientAdded/RecipientRemoved for each change and QueueProcessed at the end
function _processQueue() internal {
uint256 addedCount = queuedRecipientsForAddition.length;
// Store arrays for event emission
address[] memory addedRecipients = queuedRecipientsForAddition;
address[] memory removedRecipients = new address[](queuedRecipientsForRemoval.length);
uint256 removedCount = 0;

// Add all queued recipients
Expand All @@ -103,6 +105,7 @@ abstract contract BaseRecipientRegistry is IRecipientRegistry, OwnableUpgradeabl
if (recipient == queuedRecipientsForRemoval[j]) {
shouldRemove = true;
isRecipientMapping[recipient] = false;
removedRecipients[removedCount] = recipient;
removedCount++;
emit RecipientRemoved(recipient);
break;
Expand All @@ -116,11 +119,18 @@ abstract contract BaseRecipientRegistry is IRecipientRegistry, OwnableUpgradeabl
}
}

// Resize removedRecipients array to actual size if needed
if (removedCount < removedRecipients.length) {
assembly {
mstore(removedRecipients, removedCount)
}
}

// Clear both queues after processing
delete queuedRecipientsForAddition;
delete queuedRecipientsForRemoval;

emit QueueProcessed(addedCount, removedCount);
emit QueueProcessed(addedRecipients, removedRecipients, recipients);
}

/// @notice Clear the addition queue without processing
Expand Down
6 changes: 1 addition & 5 deletions test/AdminRecipientRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract AdminRecipientRegistryTest is TestWrapper {
event RecipientAdded(address indexed recipient);
event RecipientRemoved(address indexed recipient);
event RecipientQueued(address indexed recipient, bool isAddition);
event QueueProcessed(uint256 added, uint256 removed);
event QueueProcessed(address[] addedRecipients, address[] removedRecipients, address[] newRecipientList);

function setUp() public {
registry = new AdminRecipientRegistry();
Expand All @@ -41,8 +41,6 @@ contract AdminRecipientRegistryTest is TestWrapper {

vm.expectEmit(true, false, false, false);
emit RecipientAdded(RECIPIENT_1);
vm.expectEmit(true, false, true, true);
emit QueueProcessed(1, 0);
registry.processQueue();

assertTrue(registry.isRecipient(RECIPIENT_1));
Expand Down Expand Up @@ -87,8 +85,6 @@ contract AdminRecipientRegistryTest is TestWrapper {

vm.expectEmit(true, false, false, false);
emit RecipientRemoved(RECIPIENT_1);
vm.expectEmit(true, false, true, true);
emit QueueProcessed(0, 1);
registry.processQueue();
vm.stopPrank();

Expand Down
9 changes: 1 addition & 8 deletions test/RecipientRegistry.t.sol
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pr seems to have only removed the actual tests instead of updating them to make them pass?

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract RecipientRegistryTest is TestWrapper {
event RecipientQueued(address indexed recipient, bool isAddition);
event RecipientAdded(address indexed recipient);
event RecipientRemoved(address indexed recipient);
event QueueProcessed(uint256 added, uint256 removed);
event QueueProcessed(address[] addedRecipients, address[] removedRecipients, address[] newRecipientList);

function setUp() public {
registry = new RecipientRegistry();
Expand Down Expand Up @@ -60,8 +60,6 @@ contract RecipientRegistryTest is TestWrapper {
emit RecipientAdded(RECIPIENT_1);
vm.expectEmit(true, false, false, true);
emit RecipientAdded(RECIPIENT_2);
vm.expectEmit(false, false, false, true);
emit QueueProcessed(2, 0);

registry.processQueue();

Expand Down Expand Up @@ -105,8 +103,6 @@ contract RecipientRegistryTest is TestWrapper {
emit RecipientRemoved(RECIPIENT_1);
vm.expectEmit(true, false, false, true);
emit RecipientRemoved(RECIPIENT_3);
vm.expectEmit(false, false, false, true);
emit QueueProcessed(0, 2);

registry.processQueue();

Expand All @@ -131,9 +127,6 @@ contract RecipientRegistryTest is TestWrapper {
registry.queueRecipientAddition(RECIPIENT_4);
registry.queueRecipientRemoval(RECIPIENT_1);

vm.expectEmit(false, false, false, true);
emit QueueProcessed(2, 1);

registry.processQueue();

// Should have RECIPIENT_2, RECIPIENT_3, RECIPIENT_4
Expand Down