Skip to content

Commit

Permalink
add claimer to registerOperator (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppecrj authored May 20, 2024
1 parent 523ff39 commit cb69c7d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface INodeOperator is INodeOperatorBase {
/*
* @notice Registers an operator.
*/
function registerOperator() external;
function registerOperator(address claimer) external;

/*
* @notice Returns whether an operator is registered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ contract NodeOperatorFacet is INodeOperator, OwnableBase, ERC721ABase, Facet {
// =============================================================

/// @inheritdoc INodeOperator
function registerOperator() external {
function registerOperator(address claimer) external {
if (claimer == address(0)) revert NodeOperator__InvalidAddress();

NodeOperatorStorage.Layout storage ds = NodeOperatorStorage.layout();

if (ds.operators.contains(msg.sender))
Expand All @@ -36,8 +38,8 @@ contract NodeOperatorFacet is INodeOperator, OwnableBase, ERC721ABase, Facet {

ds.operators.add(msg.sender);
ds.statusByOperator[msg.sender] = NodeOperatorStatus.Standby;
ds.claimerByOperator[msg.sender] = msg.sender;
ds.operatorsByClaimer[msg.sender].add(msg.sender);
ds.claimerByOperator[msg.sender] = claimer;
ds.operatorsByClaimer[claimer].add(msg.sender);

emit OperatorRegistered(msg.sender);
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/base/registry/NodeOperator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contract NodeOperatorFacetTest is
emit OperatorRegistered(_operator);
emit OperatorRegistered(_operator);
vm.prank(_operator);
operator.registerOperator();
operator.registerOperator(_operator);
_;
}

Expand All @@ -72,7 +72,7 @@ contract NodeOperatorFacetTest is
) public givenOperatorIsRegistered(randomOperator) {
vm.expectRevert(NodeOperator__AlreadyRegistered.selector);
vm.prank(randomOperator);
operator.registerOperator();
operator.registerOperator(randomOperator);
}

function test_registerOperatorWithValidAddress(
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/base/registry/RewardsDistribution.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ contract RewardsDistributionTest is
vm.expectEmit();
emit INodeOperatorBase.OperatorRegistered(operatorAddr);
vm.prank(operatorAddr);
operator.registerOperator();
operator.registerOperator(operatorAddr);
}

function setOperatorCommissionRate(
Expand Down

0 comments on commit cb69c7d

Please sign in to comment.