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 28, 2023
1 parent 9274399 commit cdc04f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
26 changes: 11 additions & 15 deletions contracts/signature/Eip712Signature.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ abstract contract EIP712Signature {
}

/**
* @dev When signature present, returns the signer address.
* @dev When signature present in calldata, returns the address of the signer.
*/
function eip712SignedBy() internal returns (address signer) {
if (msg.data.length >= 4 + 65) {
if (msg.data.length >= 4 + 32 + 32 + 1) {
(
bytes calldata dataTrimmed,
uint8 v,
bytes32 r,
bytes32 s
) = _splitSignature(msg.data);

bytes32 txHash = _transactionHash(dataTrimmed, nonce);
bytes32 txHash = _moduleTxHash(dataTrimmed, nonce);

signer = ecrecover(txHash, v, r, s);
}
Expand Down Expand Up @@ -62,24 +62,20 @@ abstract contract EIP712Signature {
* @param _nonce The nonce value.
* @return the bytes32 hash to be signed by owners.
*/
function _transactionHash(
function _moduleTxHash(
bytes calldata data,
uint256 _nonce
) private view returns (bytes32) {
bytes32 domainSeparator = keccak256(
abi.encode(DOMAIN_SEPARATOR_TYPEHASH, block.chainid, this)
);
return
keccak256(
abi.encodePacked(
bytes1(0x19),
bytes1(0x01),
domainSeparator,
keccak256(
abi.encode(MODULE_TX_TYPEHASH, keccak256(data), _nonce)
)
)
);
bytes memory moduleTxData = abi.encodePacked(
bytes1(0x19),
bytes1(0x01),
domainSeparator,
keccak256(abi.encode(MODULE_TX_TYPEHASH, keccak256(data), _nonce))
);
return keccak256(moduleTxData);
}

// keccak256(
Expand Down
1 change: 0 additions & 1 deletion test/03_Modifier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import hre from "hardhat";
import typedDataForTransaction from "./typesDataForTransaction";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { TestModifier__factory } from "../typechain-types";
import { keccak256, toUtf8Bytes } from "ethers/lib/utils";

describe("Modifier", async () => {
const SENTINEL_MODULES = "0x0000000000000000000000000000000000000001";
Expand Down

0 comments on commit cdc04f2

Please sign in to comment.