Skip to content

Commit 7083385

Browse files
authored
Don't let owner be zero address or verifying signer (#19)
1 parent b5a3f9d commit 7083385

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Paymaster.sol

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ contract Paymaster is BasePaymaster {
9797
revert("Paymaster: renouncing ownership is not allowed");
9898
}
9999

100+
function transferOwnership(address newOwner) public override onlyOwner {
101+
require(newOwner != address(0), "Paymaster: owner cannot be address(0)");
102+
require(newOwner != verifyingSigner, "Paymaster: owner cannot be the verifyingSigner");
103+
_transferOwnership(newOwner);
104+
}
105+
100106
receive() external payable {
101107
// use address(this).balance rather than msg.value in case of force-send
102108
(bool callSuccess, ) = payable(address(entryPoint)).call{value: address(this).balance}("");

test/Paymaster.t.sol

+10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ contract PaymasterTest is Test {
6161
paymaster.renounceOwnership();
6262
}
6363

64+
function test_zeroAddressTransferOwnership() public {
65+
vm.expectRevert("Paymaster: owner cannot be address(0)");
66+
paymaster.transferOwnership(address(0));
67+
}
68+
69+
function test_verifyingSignerTransferOwnership() public {
70+
vm.expectRevert("Paymaster: owner cannot be the verifyingSigner");
71+
paymaster.transferOwnership(PAYMASTER_SIGNER);
72+
}
73+
6474
function test_getHash() public {
6575
UserOperation memory userOp = createUserOp();
6676
userOp.initCode = "initCode";

0 commit comments

Comments
 (0)