Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions contracts/accounts/Simple7702Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ contract Simple7702Account is BaseAccount, IERC165, IERC1271, ERC1155Holder, ERC
PackedUserOperation calldata userOp,
bytes32 userOpHash
) internal virtual override returns (uint256 validationData) {

return _checkSignature(userOpHash, userOp.signature) ? SIG_VALIDATION_SUCCESS : SIG_VALIDATION_FAILED;
}

Expand All @@ -42,7 +41,7 @@ contract Simple7702Account is BaseAccount, IERC165, IERC1271, ERC1155Holder, ERC
}

function _checkSignature(bytes32 hash, bytes memory signature) internal view returns (bool) {
return ECDSA.recover(hash, signature) == address(this);
return signature.length == 65 && ECDSA.recover(hash, signature) == address(this);
}

function _requireForExecute() internal view virtual override {
Expand Down
4 changes: 4 additions & 0 deletions contracts/accounts/SimpleAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ contract SimpleAccount is BaseAccount, TokenCallbackHandler, UUPSUpgradeable, In
/// implement template method of BaseAccount
function _validateSignature(PackedUserOperation calldata userOp, bytes32 userOpHash)
internal override virtual returns (uint256 validationData) {
// bundler sets the signature as empty when estimating gas
if (userOp.signature.length != 65)
return SIG_VALIDATION_FAILED;

// UserOpHash can be generated using eth_signTypedData_v4
if (owner != ECDSA.recover(userOpHash, userOp.signature))
return SIG_VALIDATION_FAILED;

return SIG_VALIDATION_SUCCESS;
}

Expand Down