Skip to content

Commit

Permalink
Update _originalMessageHash -> _hash
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrishang committed Feb 25, 2024
1 parent 295b00d commit 1e9fe41
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions contracts/prebuilts/account/non-upgradeable/Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,17 @@ contract Account is AccountCore, ContractMetadata, ERC1271, ERC721Holder, ERC115
super.supportsInterface(interfaceId);
}

/// @notice See EIP-1271
/**
* @notice See EIP-1271
*
* @param _hash The original message hash of the data to sign (before mixing this contract's domain separator)
* @param _signature The signature produced on signing the typed data hash (result of `getMessageHash(abi.encode(rawData))`)
*/
function isValidSignature(
bytes32 _originalMessageHash,
bytes32 _hash,
bytes memory _signature
) public view virtual override returns (bytes4 magicValue) {
bytes32 typedDataHash = keccak256(abi.encode(MSG_TYPEHASH, _originalMessageHash));
bytes32 typedDataHash = keccak256(abi.encode(MSG_TYPEHASH, _hash));
bytes32 targetDigest = keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), typedDataHash));

address signer = targetDigest.recover(_signature);
Expand Down
11 changes: 8 additions & 3 deletions contracts/prebuilts/account/utils/AccountExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ contract AccountExtension is ContractMetadata, ERC1271, AccountPermissions, ERC7
super.supportsInterface(interfaceId);
}

/// @notice See EIP-1271
/**
* @notice See EIP-1271
*
* @param _hash The original message hash of the data to sign (before mixing this contract's domain separator)
* @param _signature The signature produced on signing the typed data hash (result of `getMessageHash(abi.encode(rawData))`)
*/
function isValidSignature(
bytes32 _originalMessageHash,
bytes32 _hash,
bytes memory _signature
) public view virtual override returns (bytes4 magicValue) {
bytes32 typedDataHash = keccak256(abi.encode(MSG_TYPEHASH, _originalMessageHash));
bytes32 typedDataHash = keccak256(abi.encode(MSG_TYPEHASH, _hash));
bytes32 targetDigest = keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), typedDataHash));

Check warning on line 78 in contracts/prebuilts/account/utils/AccountExtension.sol

View check run for this annotation

Codecov / codecov/patch

contracts/prebuilts/account/utils/AccountExtension.sol#L77-L78

Added lines #L77 - L78 were not covered by tests

address signer = targetDigest.recover(_signature);

Check warning on line 80 in contracts/prebuilts/account/utils/AccountExtension.sol

View check run for this annotation

Codecov / codecov/patch

contracts/prebuilts/account/utils/AccountExtension.sol#L80

Added line #L80 was not covered by tests
Expand Down

0 comments on commit 1e9fe41

Please sign in to comment.