Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing events #105

Merged
merged 1 commit into from
Jan 20, 2025
Merged
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
11 changes: 11 additions & 0 deletions src/contracts/StakingContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ contract StakingContract {
event SetWithdrawerCustomizationStatus(bool _status);
event ExitRequest(address caller, bytes pubkey);
event ValidatorsEdited(uint256 blockNumber);
event NewSanctionsOracle(address sanctionsOracle);
event BeginOwnershipTransfer(address indexed previousAdmin, address indexed newAdmin);

/// @notice Ensures an initialisation call has been called only once per _version value
/// @param _version The current initialisation value
Expand Down Expand Up @@ -211,6 +213,14 @@ contract StakingContract {
/// @dev If the address is address(0), the sanctions oracle checks are skipped
function setSanctionsOracle(address _sanctionsOracle) external onlyAdmin {
StakingContractStorageLib.setSanctionsOracle(_sanctionsOracle);
emit NewSanctionsOracle(_sanctionsOracle);
}

/// @notice Get the sanctions oracle address
/// @notice If the address is address(0), the sanctions oracle checks are skipped
/// @return sanctionsOracle The sanctions oracle address
function getSanctionsOracle() external view returns (address) {
return StakingContractStorageLib.getSanctionsOracle();
}

/// @notice Retrieve system admin
Expand Down Expand Up @@ -375,6 +385,7 @@ contract StakingContract {
/// @param _newAdmin New Administrator address
function transferOwnership(address _newAdmin) external onlyAdmin {
StakingContractStorageLib.setPendingAdmin(_newAdmin);
emit BeginOwnershipTransfer(msg.sender, _newAdmin);
}

/// @notice New admin must accept its role by calling this method
Expand Down
15 changes: 15 additions & 0 deletions src/test/StakingContract.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,16 @@ contract StakingContractTest is Test {
assertEq(stakingContract.getAdmin(), admin);
}

event BeginOwnershipTransfer(address indexed previousAdmin, address indexed newAdmin);
event ChangedAdmin(address newAdmin);

function testSetAdmin(address newAdmin) public {
assertEq(stakingContract.getAdmin(), admin);

// Start ownership transfer process.
vm.startPrank(admin);
vm.expectEmit(true, true, true, true);
emit BeginOwnershipTransfer(admin, newAdmin);
stakingContract.transferOwnership(newAdmin);
vm.stopPrank();
// At this point, the old admin is still in charge.
Expand Down Expand Up @@ -2055,6 +2058,18 @@ contract StakingContractBehindProxyTest is Test {
assert(deactivated == false);
}

event NewSanctionsOracle(address);

function test_setSanctionsOracle() public {
assertEq(stakingContract.getSanctionsOracle(), address(0));
vm.startPrank(admin);
vm.expectEmit(true, true, true, true);
emit NewSanctionsOracle(address(oracle));
stakingContract.setSanctionsOracle(address(oracle));
vm.stopPrank();
assertEq(stakingContract.getSanctionsOracle(), address(oracle));
}

function test_deposit_withsanctions_senderSanctioned(address user) public {
assumeAddress(user);
oracle.setSanction(user, true);
Expand Down
Loading