Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
Merge 03445c5 into b6ee39d
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Jul 28, 2022
2 parents b6ee39d + 03445c5 commit b1bbb2a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions contracts/utils/Domain.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity 0.8.10;

abstract contract Domain {
/*//////////////////////////////////////////////////////////////
DOMAIN STORAGE/LOGIC
//////////////////////////////////////////////////////////////*/

uint256 internal immutable INITIAL_CHAIN_ID;

bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;

mapping(address => uint256) public nonces;

function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
}

function computeDomainSeparator() internal view virtual returns (bytes32) {
return
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes("Domain")),
keccak256("1"),
block.chainid,
address(this)
)
);
}

/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/

constructor() {
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
}

0 comments on commit b1bbb2a

Please sign in to comment.