-
Notifications
You must be signed in to change notification settings - Fork 742
Open
Description
Hi!
I'm trying to make a call to a method in a contract that's guarded by a modifier which checks if the sender (ERC-4337 SA) is a valid non-zero code size contract, as follows:
/// @dev Allow only calls from contracts implementing the {ISpace} interface
modifier onlySpace() {
// Checks: the sender is a valid non-zero code size contract
if (msg.sender.code.length == 0) {
revert SpaceZeroCodeSize();
}
// Checks: the sender implements the ERC-165 interface required by {ISpace}
bytes4 interfaceId = type(ISpace).interfaceId;
if (!ISpace(msg.sender).supportsInterface(interfaceId)) revert SpaceUnsupportedInterface();
_;
}
, where ISpace
is our own ERC-4337 compliant implementation.
When calling the method for the first time, due to the fact that the account is not deployed yet, it will fail with SpaceZeroCodeSize()
. Therefore, we first need to send an empty UserOp to deploy and then call the target method. This adds some traction to the overall workflow.
Is there a better way or workaround to address this behavior e.g. bypassing the initial validation? Thanks!
Metadata
Metadata
Assignees
Labels
No labels