Skip to content

Commit

Permalink
Rename addAdmin message to scheduleUpgrade (#74)
Browse files Browse the repository at this point in the history
* rename addAdmin to scheduleRely

* forge fmt

* rename scheduleRely to scheduleUpgrade

* rename upgrade contract variable name
  • Loading branch information
AStox authored Aug 14, 2023
1 parent 36251d5 commit a2652fa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/Messages.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ library ConnectorMessages {
ExecutedCollectInvest,
/// 18 - Executed Collect Redeem
ExecutedCollectRedeem,
/// 19 - Add a new admin
AddAdmin
/// 19 - Schedule an upgrade contract to be granted admin rights
ScheduleUpgrade
}

enum Domain {
Expand Down Expand Up @@ -746,16 +746,16 @@ library ConnectorMessages {
remainingRedeemOrder = uint128(_msg.indexUint(105, 16));
}

function formatAddAdmin(address user) internal pure returns (bytes memory) {
return abi.encodePacked(uint8(Call.AddAdmin), user);
function formatScheduleUpgrade(address _contract) internal pure returns (bytes memory) {
return abi.encodePacked(uint8(Call.ScheduleUpgrade), _contract);
}

function isAddAdmin(bytes29 _msg) internal pure returns (bool) {
return messageType(_msg) == Call.AddAdmin;
function isScheduleUpgrade(bytes29 _msg) internal pure returns (bool) {
return messageType(_msg) == Call.ScheduleUpgrade;
}

function parseAddAdmin(bytes29 _msg) internal pure returns (address user) {
user = address(bytes20(_msg.index(1, 20)));
function parseScheduleUpgrade(bytes29 _msg) internal pure returns (address _contract) {
_contract = address(bytes20(_msg.index(1, 20)));
}

// Utils
Expand Down
4 changes: 2 additions & 2 deletions src/routers/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ contract ConnectorGateway {
connector.handleExecutedCollectRedeem(
poolId, trancheId, investor, currency, currencyPayout, trancheTokensRedeemed, remainingRedeemOrder
);
} else if (ConnectorMessages.isAddAdmin(_msg)) {
address spell = ConnectorMessages.parseAddAdmin(_msg);
} else if (ConnectorMessages.isScheduleUpgrade(_msg)) {
address spell = ConnectorMessages.parseScheduleUpgrade(_msg);
scheduleShortRely(spell);
} else {
revert("ConnectorGateway/invalid-message");
Expand Down
6 changes: 3 additions & 3 deletions test/Admin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,23 @@ contract AdminTest is Test {

function testShortRelyWorks() public {
address spell = vm.addr(1);
centChainConnector.incomingScheduleRely(spell);
centChainConnector.incomingScheduleUpgrade(spell);
vm.warp(block.timestamp + shortWait + 1 hours);
gateway.executeScheduledRely(spell);
assertEq(gateway.wards(spell), 1);
}

function testShortRelyFailsBefore24hours() public {
address spell = vm.addr(1);
centChainConnector.incomingScheduleRely(spell);
centChainConnector.incomingScheduleUpgrade(spell);
vm.warp(block.timestamp + shortWait - 1 hours);
vm.expectRevert("ConnectorGateway/user-not-ready");
gateway.executeScheduledRely(spell);
}

function testShortRelyFailsAfterGracePeriod() public {
address spell = vm.addr(1);
centChainConnector.incomingScheduleRely(spell);
centChainConnector.incomingScheduleUpgrade(spell);
vm.warp(block.timestamp + shortWait + gateway.gracePeriod());
vm.expectRevert("ConnectorGateway/user-too-old");
gateway.executeScheduledRely(spell);
Expand Down
4 changes: 2 additions & 2 deletions test/mock/MockHomeConnector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ contract MockHomeConnector is Test {
router.handle(_message);
}

function incomingScheduleRely(address spell) public {
bytes memory _message = ConnectorMessages.formatAddAdmin(spell);
function incomingScheduleUpgrade(address spell) public {
bytes memory _message = ConnectorMessages.formatScheduleUpgrade(spell);
router.handle(_message);
}

Expand Down

0 comments on commit a2652fa

Please sign in to comment.