Skip to content

Commit

Permalink
Rename helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
cristovaoth committed Sep 30, 2023
1 parent 805bfe1 commit db222c6
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions contracts/signature/SignatureChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ abstract contract SignatureChecker {
bytes32 r,
bytes32 s,
uint8 v,
bool isContractSignature,
uint256 start,
uint256 end
bool isEIP1271,
uint256 start
) = _splitSignature(data);

bytes32 hash = _moduleTxHash(data[:start], nonce);

if (isContractSignature) {
if (isEIP1271) {
// When handling contract signatures the address
// of the contract is encoded into r
signer = address(uint160(uint256(r)));
if (!isValidContractSignature(signer, hash, data[start:end])) {
uint256 end = data.length - 65;

if (!_isValidContractSignature(signer, hash, data[start:end])) {
signer = address(0);
}
} else {
Expand All @@ -61,22 +62,14 @@ abstract contract SignatureChecker {
)
private
pure
returns (
bytes32 r,
bytes32 s,
uint8 v,
bool isEIP1271,
uint256 start,
uint256 end
)
returns (bytes32 r, bytes32 s, uint8 v, bool isEIP1271, uint256 start)
{
uint256 length = data.length;
r = bytes32(data[length - 65:]);
s = bytes32(data[length - 33:]);
v = uint8(bytes1(data[length - 1:]));
isEIP1271 = v == 0 && (uint256(s) < (length - 65));
start = isEIP1271 ? uint256(s) : length - 65;
end = isEIP1271 ? length - 65 : length;
}

/**
Expand All @@ -101,7 +94,7 @@ abstract contract SignatureChecker {
return keccak256(moduleTxData);
}

function isValidContractSignature(
function _isValidContractSignature(
address signer,
bytes32 hash,
bytes calldata signature
Expand Down

0 comments on commit db222c6

Please sign in to comment.