Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bidyut-arianelabs committed Sep 23, 2022
1 parent 25ef20d commit 59cd7dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
1 change: 0 additions & 1 deletion contracts/protocol/facets/ConfigHandlerFacet.sol
Expand Up @@ -71,7 +71,6 @@ contract ConfigHandlerFacet is IBosonConfigHandler, ProtocolBase {
ProtocolLib.ProtocolMetaTxInfo storage pmti = protocolMetaTxInfo();
pmti.domainSeparator = EIP712Lib.buildDomainSeparator(PROTOCOL_NAME, PROTOCOL_VERSION);
pmti.cachedChainId = block.chainid;
pmti.cachedThis = address(this);
}

/**
Expand Down
15 changes: 9 additions & 6 deletions contracts/protocol/libs/EIP712Lib.sol
Expand Up @@ -12,6 +12,8 @@ import { ProtocolLib } from "../libs/ProtocolLib.sol";
library EIP712Lib {
/**
* @notice Generates the domain separator hash.
* @dev Using chainId as the salt allows you that your client is active on one chain,
* while you sign metaTx for another chain.
*
* @param _name - the name of the protocol
* @param _version - The version of the protocol
Expand Down Expand Up @@ -49,7 +51,7 @@ library EIP712Lib {
bytes32 _sigR,
bytes32 _sigS,
uint8 _sigV
) internal view returns (bool) {
) internal returns (bool) {
// Ensure signature is unique
// See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/04695aecbd4d17dddfd55de766d10e3805d6f42f/contracts/cryptography/ECDSA.sol#63
require(
Expand All @@ -68,13 +70,14 @@ library EIP712Lib {
*
* @return the domain separator
*/
function getDomainSeparator() private view returns (bytes32) {
address cachedThis = ProtocolLib.protocolMetaTxInfo().cachedThis;
uint256 cachedChainId = ProtocolLib.protocolMetaTxInfo().cachedChainId;
function getDomainSeparator() private returns (bytes32) {
ProtocolLib.ProtocolMetaTxInfo storage pmti = ProtocolLib.protocolMetaTxInfo();
uint256 cachedChainId = pmti.cachedChainId;

if (address(this) == cachedThis && block.chainid == cachedChainId) {
if (block.chainid == cachedChainId) {
return ProtocolLib.protocolMetaTxInfo().domainSeparator;
} else {
pmti.cachedChainId = block.chainid;
return buildDomainSeparator(PROTOCOL_NAME, PROTOCOL_VERSION);
}
}
Expand All @@ -91,7 +94,7 @@ library EIP712Lib {
* @param _messageHash - the message hash
* @return the EIP712 compatible message hash
*/
function toTypedMessageHash(bytes32 _messageHash) internal view returns (bytes32) {
function toTypedMessageHash(bytes32 _messageHash) internal returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", getDomainSeparator(), _messageHash));
}

Expand Down
2 changes: 0 additions & 2 deletions contracts/protocol/libs/ProtocolLib.sol
Expand Up @@ -204,8 +204,6 @@ library ProtocolLib {
mapping(address => mapping(uint256 => bool)) usedNonce;
// The cached chain id
uint256 cachedChainId;
// The cached address of the diamond
address cachedThis;
// map function name to input type
mapping(string => BosonTypes.MetaTxInputType) inputType;
// map input type => hash info
Expand Down

0 comments on commit 59cd7dd

Please sign in to comment.