Skip to content

Commit

Permalink
Emit old values when updating authorised caller and sender
Browse files Browse the repository at this point in the history
  • Loading branch information
ermyas committed Oct 4, 2023
1 parent 55e741e commit daf7da2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
22 changes: 12 additions & 10 deletions src/controllers/MessageSenderGAC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ contract MessageSenderGAC is GAC {
//////////////////////////////////////////////////////////////*/
event DstGasLimitUpdated(uint256 oldLimit, uint256 newLimit);

event MultiBridgeMessageCallerUpdated(address indexed mmaCaller);
event MultiBridgeMessageCallerUpdated(address indexed oldAuthCaller, address indexed newAuthCaller);

event MultiBridgeMessageSenderUpdated(address indexed mmaSender);
event MultiBridgeMessageSenderUpdated(address indexed oldMMS, address indexed newMMS);

event MultiBridgeMessageReceiverUpdated(uint256 indexed chainId, address indexed oldMMR, address indexed newMMR);

Expand All @@ -43,24 +43,26 @@ contract MessageSenderGAC is GAC {
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

function setMultiBridgeMessageSender(address _mmaSender) external onlyOwner {
if (_mmaSender == address(0)) {
function setMultiBridgeMessageSender(address _newMMS) external onlyOwner {
if (_newMMS == address(0)) {
revert Error.ZERO_ADDRESS_INPUT();
}

multiBridgeMessageSender = _mmaSender;
address oldMMS = multiBridgeMessageSender;
multiBridgeMessageSender = _newMMS;

emit MultiBridgeMessageSenderUpdated(_mmaSender);
emit MultiBridgeMessageSenderUpdated(oldMMS, _newMMS);
}

function setAuthorisedCaller(address _newMMSCaller) external onlyOwner {
if (_newMMSCaller == address(0)) {
function setAuthorisedCaller(address _newAuthCaller) external onlyOwner {
if (_newAuthCaller == address(0)) {
revert Error.ZERO_ADDRESS_INPUT();
}

authorisedCaller = _newMMSCaller;
address oldAuthCaller = authorisedCaller;
authorisedCaller = _newAuthCaller;

emit MultiBridgeMessageCallerUpdated(_newMMSCaller);
emit MultiBridgeMessageCallerUpdated(oldAuthCaller, _newAuthCaller);
}

function setRemoteMultiBridgeMessageReceiver(uint256 _chainId, address _remoteMMR) external onlyOwner {
Expand Down
8 changes: 4 additions & 4 deletions test/unit-tests/MessageSenderGAC.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {MultiBridgeMessageSender} from "src/MultiBridgeMessageSender.sol";

contract MessageSenderGACTest is Setup {
event DstGasLimitUpdated(uint256 oldLimit, uint256 newLimit);
event MultiBridgeMessageCallerUpdated(address indexed mmaCaller);
event MultiBridgeMessageSenderUpdated(address indexed mmaSender);
event MultiBridgeMessageCallerUpdated(address indexed oldAuthCaller, address indexed newAuthCaller);
event MultiBridgeMessageSenderUpdated(address indexed oldMMS, address indexed newMMS);
event MultiBridgeMessageReceiverUpdated(uint256 indexed chainId, address indexed oldMMR, address indexed newMMR);

address senderAddr;
Expand Down Expand Up @@ -48,7 +48,7 @@ contract MessageSenderGACTest is Setup {
vm.startPrank(owner);

vm.expectEmit(true, true, true, true, address(senderGAC));
emit MultiBridgeMessageSenderUpdated(address(42));
emit MultiBridgeMessageSenderUpdated(senderGAC.multiBridgeMessageSender(), address(42));

senderGAC.setMultiBridgeMessageSender(address(42));

Expand Down Expand Up @@ -76,7 +76,7 @@ contract MessageSenderGACTest is Setup {
vm.startPrank(owner);

vm.expectEmit(true, true, true, true, address(senderGAC));
emit MultiBridgeMessageCallerUpdated(address(42));
emit MultiBridgeMessageCallerUpdated(senderGAC.authorisedCaller(), address(42));

senderGAC.setAuthorisedCaller(address(42));

Expand Down

0 comments on commit daf7da2

Please sign in to comment.