From c2d3d9aea4ef68688bf84c62ff16d8adc7a772ad Mon Sep 17 00:00:00 2001 From: doylet Date: Fri, 4 Oct 2024 13:24:12 +1000 Subject: [PATCH] Add the old beneficiary to the log for UpdateStakerBeneficiary --- contracts/ServiceNodeContribution.sol | 8 +++++--- contracts/interfaces/IServiceNodeContribution.sol | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contracts/ServiceNodeContribution.sol b/contracts/ServiceNodeContribution.sol index 4aed282..474f0b1 100644 --- a/contracts/ServiceNodeContribution.sol +++ b/contracts/ServiceNodeContribution.sol @@ -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; } @@ -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); } diff --git a/contracts/interfaces/IServiceNodeContribution.sol b/contracts/interfaces/IServiceNodeContribution.sol index 708ed4e..5b8e395 100644 --- a/contracts/interfaces/IServiceNodeContribution.sol +++ b/contracts/interfaces/IServiceNodeContribution.sol @@ -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); ////////////////////////////////////////////////////////////// // //