Skip to content

Commit

Permalink
refactor moduleSignature decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipp Makarov authored and Filipp Makarov committed Oct 12, 2023
1 parent 66c7bc2 commit 495a2a7
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 177 deletions.
11 changes: 5 additions & 6 deletions contracts/smart-account/handler/DefaultCallbackHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ contract DefaultCallbackHandler is
IERC721TokenReceiver,
IERC165
{
string public constant NAME = "Default Callback Handler";
string public constant VERSION = "1.0.0";

error NonExistingMethodCalled(bytes4 selector);

string public constant NAME = "Default Callback Handler";
string public constant VERSION = "1.0.0";
fallback() external {
revert NonExistingMethodCalled(msg.sig);
}

function supportsInterface(
bytes4 interfaceId
Expand Down Expand Up @@ -73,8 +76,4 @@ contract DefaultCallbackHandler is
) external pure override {
// We implement this for completeness, doesn't really have any value
}

fallback() external {
revert NonExistingMethodCalled(msg.sig);
}
}
20 changes: 10 additions & 10 deletions contracts/smart-account/modules/AccountRecoveryModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ contract AccountRecoveryModule is BaseAuthorizationModule {
// otherwise we need to check all the signatures first
uint256 requiredSignatures = _smartAccountSettings[userOp.sender]
.recoveryThreshold;
if (requiredSignatures == 0)
revert("AccRecovery: Threshold not set");
if (requiredSignatures == 0) revert("AccRecovery: Threshold not set");

bytes calldata moduleSignature = userOp.signature[96:];

(bytes memory signatures, ) = abi.decode(
userOp.signature,
(bytes, address)
require(
moduleSignature.length >= requiredSignatures * 2 * 65,
"AccRecovery: Invalid Sigs Length"
);
require(signatures.length >= requiredSignatures * 2 * 65, "AccRecovery: Invalid Sigs Length");

address lastGuardianAddress;
address currentGuardianAddress;
Expand All @@ -205,12 +205,12 @@ contract AccountRecoveryModule is BaseAuthorizationModule {
address currentUserOpSignerAddress = userOpHash
.toEthSignedMessageHash()
.recover(
userOp.signature[96 + 2 * i * 65:96 + (2 * i + 1) * 65]
moduleSignature[2 * i * 65:(2 * i + 1) * 65]
);

currentGuardianSig = userOp.signature[96 + (2 * i + 1) * 65:96 +
(2 * i + 2) *
65];
currentGuardianSig = moduleSignature[
(2 * i + 1) * 65 : (2 * i + 2) * 65
];

currentGuardianAddress = CONTROL_HASH
.toEthSignedMessageHash()
Expand Down
Loading

0 comments on commit 495a2a7

Please sign in to comment.