Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
adamegyed committed Mar 19, 2024
1 parent 0882535 commit 6c9f6e5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
22 changes: 11 additions & 11 deletions src/interfaces/IPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,6 @@ interface IPlugin {
/// @param data The calldata sent.
function validateRuntime(address sender, uint256 value, bytes calldata data) external;

/// @notice Validates a signature using ERC-1271.
/// @param sender the address that sent the ERC-1271 request to the smart account
/// @param hash the hash of the ERC-1271 request
/// @param signature the signature of the ERC-1271 request
///
/// @return the ERC-1271 `MAGIC_VALUE` if the signature is valid, or 0xFFFFFFFF if invalid.
function isValidSignatureWithSender(address sender, bytes32 hash, bytes calldata signature)
external
view
returns (bytes4);

/// @notice Run the pre execution hook.
/// @dev To indicate the entire call should revert, the function MUST revert.
/// @param sender The caller address.
Expand All @@ -163,6 +152,17 @@ interface IPlugin {
/// @param preExecHookData The context returned by its associated pre execution hook.
function postExecutionHook(bytes calldata preExecHookData) external;

/// @notice Validates a signature using ERC-1271.
/// @param sender the address that sent the ERC-1271 request to the smart account
/// @param hash the hash of the ERC-1271 request
/// @param signature the signature of the ERC-1271 request
///
/// @return the ERC-1271 `MAGIC_VALUE` if the signature is valid, or 0xFFFFFFFF if invalid.
function isValidSignatureWithSender(address sender, bytes32 hash, bytes calldata signature)
external
view
returns (bytes4);

/// @notice Describe the contents and intended configuration of the plugin.
/// @dev This manifest MUST stay constant over time.
/// @return A manifest describing the contents and intended configuration of the plugin.
Expand Down
22 changes: 11 additions & 11 deletions src/plugins/BasePlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ abstract contract BasePlugin is ERC165, IPlugin {
revert NotImplemented();
}

/// @inheritdoc IPlugin
function isValidSignatureWithSender(address sender, bytes32 hash, bytes calldata signature)
external
virtual
view
returns (bytes4)
{
(sender, hash, signature);
revert NotImplemented();
}

/// @inheritdoc IPlugin
function preExecutionHook(address sender, uint256 value, bytes calldata data)
external
Expand All @@ -84,6 +73,17 @@ abstract contract BasePlugin is ERC165, IPlugin {
revert NotImplemented();
}

/// @inheritdoc IPlugin
function isValidSignatureWithSender(address sender, bytes32 hash, bytes calldata signature)
external
view
virtual
returns (bytes4)
{
(sender, hash, signature);
revert NotImplemented();
}

/// @inheritdoc IPlugin
function pluginManifest() external pure virtual returns (PluginManifest memory) {
revert NotImplemented();
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/owner/SingleOwnerPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ contract SingleOwnerPlugin is BasePlugin, ISingleOwnerPlugin {
/// validation used in `validateUserOp`, this does///*not** wrap the digest in
/// an "Ethereum Signed Message" envelope before checking the signature in
/// the EOA-owner case.
function isValidSignatureWithSender(address sender, bytes32 digest, bytes memory signature) public view override returns (bytes4) {
function isValidSignatureWithSender(address sender, bytes32 digest, bytes memory signature)
public
view
override
returns (bytes4)
{
(sender);
if (SignatureChecker.isValidSignatureNow(_owners[msg.sender], digest, signature)) {
return _1271_MAGIC_VALUE;
Expand Down
8 changes: 6 additions & 2 deletions test/plugin/SingleOwnerPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,18 @@ contract SingleOwnerPluginTest is OptimizedTest {
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);

// sig check should fail
assertEq(plugin.isValidSignatureWithSender(address(0), digest, abi.encodePacked(r, s, v)), bytes4(0xFFFFFFFF));
assertEq(
plugin.isValidSignatureWithSender(address(0), digest, abi.encodePacked(r, s, v)), bytes4(0xFFFFFFFF)
);

// transfer ownership to signer
plugin.transferOwnership(signer);
assertEq(signer, plugin.owner());

// sig check should pass
assertEq(plugin.isValidSignatureWithSender(address(0), digest, abi.encodePacked(r, s, v)), _1271_MAGIC_VALUE);
assertEq(
plugin.isValidSignatureWithSender(address(0), digest, abi.encodePacked(r, s, v)), _1271_MAGIC_VALUE
);
}

function testFuzz_isValidSignatureForContractOwner(bytes32 digest) public {
Expand Down

0 comments on commit 6c9f6e5

Please sign in to comment.