diff --git a/contracts/src/base/registry/facets/operator/INodeOperator.sol b/contracts/src/base/registry/facets/operator/INodeOperator.sol index df5f37c08..22278a527 100644 --- a/contracts/src/base/registry/facets/operator/INodeOperator.sol +++ b/contracts/src/base/registry/facets/operator/INodeOperator.sol @@ -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. diff --git a/contracts/src/base/registry/facets/operator/NodeOperatorFacet.sol b/contracts/src/base/registry/facets/operator/NodeOperatorFacet.sol index 8613bb2db..1c394a6c8 100644 --- a/contracts/src/base/registry/facets/operator/NodeOperatorFacet.sol +++ b/contracts/src/base/registry/facets/operator/NodeOperatorFacet.sol @@ -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)) @@ -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); } diff --git a/contracts/test/base/registry/NodeOperator.t.sol b/contracts/test/base/registry/NodeOperator.t.sol index 60ae7f3a1..2e50a7550 100644 --- a/contracts/test/base/registry/NodeOperator.t.sol +++ b/contracts/test/base/registry/NodeOperator.t.sol @@ -63,7 +63,7 @@ contract NodeOperatorFacetTest is emit OperatorRegistered(_operator); emit OperatorRegistered(_operator); vm.prank(_operator); - operator.registerOperator(); + operator.registerOperator(_operator); _; } @@ -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( diff --git a/contracts/test/base/registry/RewardsDistribution.t.sol b/contracts/test/base/registry/RewardsDistribution.t.sol index be4c30bb3..cdb1d92f2 100644 --- a/contracts/test/base/registry/RewardsDistribution.t.sol +++ b/contracts/test/base/registry/RewardsDistribution.t.sol @@ -1133,7 +1133,7 @@ contract RewardsDistributionTest is vm.expectEmit(); emit INodeOperatorBase.OperatorRegistered(operatorAddr); vm.prank(operatorAddr); - operator.registerOperator(); + operator.registerOperator(operatorAddr); } function setOperatorCommissionRate(