Skip to content

Commit

Permalink
Add the old beneficiary to the log for UpdateStakerBeneficiary
Browse files Browse the repository at this point in the history
  • Loading branch information
Doy-lee committed Oct 4, 2024
1 parent 3e4b471 commit c2d3d9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions contracts/ServiceNodeContribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,14 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
function updateBeneficiary(address newBeneficiary) external { _updateBeneficiary(msg.sender, newBeneficiary); }

function _updateBeneficiary(address stakerAddr, address newBeneficiary) private {
bool updated = false;
uint256 length = _contributorAddresses.length;
address oldBeneficiary = address(0);
bool updated = false;
uint256 length = _contributorAddresses.length;
for (uint256 i = 0; i < length; i++) {
IServiceNodeRewards.Staker storage staker = _contributorAddresses[i];
if (staker.addr == stakerAddr) {
updated = true;
oldBeneficiary = staker.beneficiary;
staker.beneficiary = newBeneficiary;
break;
}
Expand All @@ -227,7 +229,7 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
if (!updated)
revert NonContributorUpdatedBeneficiary(stakerAddr);

emit UpdateStakerBeneficiary(stakerAddr, newBeneficiary);
emit UpdateStakerBeneficiary(stakerAddr, oldBeneficiary, newBeneficiary);
}

function contributeFunds(uint256 amount, BeneficiaryData memory data) external { _contributeFunds(msg.sender, data, amount); }
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IServiceNodeContribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ interface IServiceNodeContribution {
event OpenForPublicContribution(uint256 indexed serviceNodePubkey, address indexed operator, uint16 fee);
event Filled (uint256 indexed serviceNodePubkey, address indexed operator);
event WithdrawContribution (address indexed contributor, uint256 amount);
event UpdateStakerBeneficiary (address indexed staker, address beneficiary);
event UpdateStakerBeneficiary (address indexed staker, address oldBeneficiary, address newBeneficiary);

//////////////////////////////////////////////////////////////
// //
Expand Down

0 comments on commit c2d3d9a

Please sign in to comment.