Skip to content

Commit

Permalink
Don't let owner be zero address or verifying signer
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Nov 3, 2023
1 parent b5a3f9d commit e937f40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Paymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ contract Paymaster is BasePaymaster {
revert("Paymaster: renouncing ownership is not allowed");
}

function transferOwnership(address newOwner) public override onlyOwner {
require(newOwner != address(0), "Paymaster: owner cannot be address(0)");
require(newOwner != verifyingSigner, "Paymaster: owner cannot be the verifyingSigner");
_transferOwnership(newOwner);
}

receive() external payable {
// use address(this).balance rather than msg.value in case of force-send
(bool callSuccess, ) = payable(address(entryPoint)).call{value: address(this).balance}("");
Expand Down
10 changes: 10 additions & 0 deletions test/Paymaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ contract PaymasterTest is Test {
paymaster.renounceOwnership();
}

function test_zeroAddressTransferOwnership() public {
vm.expectRevert("Paymaster: owner cannot be address(0)");
paymaster.transferOwnership(address(0));
}

function test_verifyingSignerTransferOwnership() public {
vm.expectRevert("Paymaster: owner cannot be the verifyingSigner");
paymaster.transferOwnership(PAYMASTER_SIGNER);
}

function test_getHash() public {
UserOperation memory userOp = createUserOp();
userOp.initCode = "initCode";
Expand Down

0 comments on commit e937f40

Please sign in to comment.