Summary
Currently, Erc7677Paymaster.createPaymasterUserOperation casts SmartAccountWithEntrypoint to PrependTokenPaymasterApproveAccount when context.token is set, without a static type guarantee that the method exists on the account.
Every smart account class in the SDK already implements prependTokenPaymasterApproveToCallData, so the cast is safe today — but the lack of a static guarantee means a consumer passing a custom account without the method would get an opaque runtime TypeError.
Proposed fix
Lift prependTokenPaymasterApproveToCallData onto the base smart account class so that the Erc7677Paymaster token-flow parameter type can reflect the guarantee statically, removing the need for the cast entirely.
Once done, the tokenPaymasterFlow signature can accept SmartAccountWithEntrypoint (or the updated base type) directly, and no runtime guard is required.
Background
Raised during review of PR #102 (feat(paymaster): add generic ERC-7677 paymaster class).
Relevant review comment: #102 (comment)
Requested by: @andrewwahid
Summary
Currently,
Erc7677Paymaster.createPaymasterUserOperationcastsSmartAccountWithEntrypointtoPrependTokenPaymasterApproveAccountwhencontext.tokenis set, without a static type guarantee that the method exists on the account.Every smart account class in the SDK already implements
prependTokenPaymasterApproveToCallData, so the cast is safe today — but the lack of a static guarantee means a consumer passing a custom account without the method would get an opaque runtimeTypeError.Proposed fix
Lift
prependTokenPaymasterApproveToCallDataonto the base smart account class so that theErc7677Paymastertoken-flow parameter type can reflect the guarantee statically, removing the need for the cast entirely.Once done, the
tokenPaymasterFlowsignature can acceptSmartAccountWithEntrypoint(or the updated base type) directly, and no runtime guard is required.Background
Raised during review of PR #102 (feat(paymaster): add generic ERC-7677 paymaster class).
Relevant review comment: #102 (comment)
Requested by: @andrewwahid