Skip to content

Commit

Permalink
Add upgradeTo function
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcarpanelli committed Oct 7, 2021
1 parent a682cbf commit 67f568c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions contracts/contracts/levels/PuzzleWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,24 @@ contract PuzzleProxy is UpgradeableProxy {
admin = _admin;
}

modifier onlyAdmin {
require(msg.sender == admin, "Caller is not the admin");
_;
}

// Anyone can propose a new admin, but the current admin must accept the change in the `changeAdmin` function
function proposeNewAdmin(address _newAdmin) external {
pendingAdmin = _newAdmin;
}

function approveNewAdmin(address _expectedAdmin) external {
require(msg.sender == admin, "Caller is not the admin");
function approveNewAdmin(address _expectedAdmin) external onlyAdmin {
require(pendingAdmin == _expectedAdmin, "Expected new admin by the current admin is not the pending admin");
admin = pendingAdmin;
}

function upgradeTo(address _newImplementation) external onlyAdmin {
_upgradeTo(_newImplementation);
}
}

contract PuzzleWallet {
Expand Down

0 comments on commit 67f568c

Please sign in to comment.