diff --git a/src/paymasters/SponsorPaymaster.sol b/src/paymasters/SponsorPaymaster.sol index 9fe316f9..4c9fee5b 100644 --- a/src/paymasters/SponsorPaymaster.sol +++ b/src/paymasters/SponsorPaymaster.sol @@ -351,7 +351,7 @@ contract SponsorPaymaster is Initializable, BasePaymaster, UUPSUpgradeable, Reen if (sponsor != userOp.sender) { revert DepositTooLow(); } - // Wallets get automfunded by kinto core app + // Wallets get auto funded by kinto core app sponsor = appRegistry.getApp(address(walletFactory)); } return (abi.encode(sponsor, userOp.sender, userOp.maxFeePerGas, userOp.maxPriorityFeePerGas), 0); diff --git a/test/unit/SponsorPaymaster.t.sol b/test/unit/SponsorPaymaster.t.sol index f60e3379..1c2ac157 100644 --- a/test/unit/SponsorPaymaster.t.sol +++ b/test/unit/SponsorPaymaster.t.sol @@ -15,6 +15,8 @@ import {IKintoWalletFactory} from "@kinto-core/interfaces/IKintoWalletFactory.so import "@kinto-core-test/SharedSetup.t.sol"; +import "forge-std/console2.sol"; + contract SponsorPaymasterUpgrade is SponsorPaymaster { constructor(IEntryPoint __entryPoint, IKintoWalletFactory factory, address _owner) SponsorPaymaster(__entryPoint, factory) @@ -253,6 +255,23 @@ contract SponsorPaymasterTest is SharedSetup { _paymaster.validatePaymasterUserOp(userOp, "", 0); } + function testValidatePaymasterUserOp_WhenWalletIsApp() public { + address wallet = address(alice); + UserOperation memory userOp = _createUserOperation( + wallet, wallet, 0, privateKeys, abi.encodeWithSignature("increment()"), address(_paymaster) + ); + + address kintoCoreApp = _paymaster.appRegistry().getApp(address(_walletFactory)); + + vm.prank(address(_entryPoint)); + (bytes memory context, uint256 validationData) = _paymaster.validatePaymasterUserOp(userOp, "", 0.01 ether); + + assertEq(validationData, 0); + (address sponsor, address sender,,) = abi.decode(context, (address, address, uint256, uint256)); + assertEq(sponsor, kintoCoreApp, "Sponsor for the wallet has to be a Kinto App"); + assertEq(sender, wallet, "Sender has to be a wallet"); + } + function testValidatePaymasterUserOp_RevertWhen_GasLimitIsLessThanCostOfPost() public { UserOperation memory userOp = _createUserOperation( address(_kintoWallet),