diff --git a/src/Paymaster.sol b/src/Paymaster.sol index 360a8c5..618b7a9 100644 --- a/src/Paymaster.sol +++ b/src/Paymaster.sol @@ -25,6 +25,8 @@ contract Paymaster is BasePaymaster { uint256 private constant SIGNATURE_OFFSET = VALID_TIMESTAMP_OFFSET + 64; constructor(IEntryPoint _entryPoint, address _verifyingSigner) BasePaymaster(_entryPoint) { + require(_verifyingSigner != address(0), "Paymaster: verifyingSigner cannot be address(0)"); + require(_verifyingSigner != msg.sender, "Paymaster: verifyingSigner cannot be the owner"); verifyingSigner = _verifyingSigner; } diff --git a/test/Paymaster.t.sol b/test/Paymaster.t.sol index 8fd4825..670dedc 100644 --- a/test/Paymaster.t.sol +++ b/test/Paymaster.t.sol @@ -31,6 +31,16 @@ contract PaymasterTest is Test { account = factory.createAccount(ACCOUNT_OWNER, 0); } + function test_zeroAddressVerifyingSigner() public { + vm.expectRevert("Paymaster: verifyingSigner cannot be address(0)"); + new Paymaster(entrypoint, address(0)); + } + + function test_ownerVerifyingSigner() public { + vm.expectRevert("Paymaster: verifyingSigner cannot be the owner"); + new Paymaster(entrypoint, address(this)); + } + function test_parsePaymasterAndData() public { bytes memory paymasterAndData = abi.encodePacked(address(paymaster), abi.encode(MOCK_VALID_UNTIL, MOCK_VALID_AFTER), MOCK_SIG); (uint48 validUntil, uint48 validAfter, bytes memory signature) = paymaster.parsePaymasterAndData(paymasterAndData);