Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/little-falcons-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---

Add internal name and version getters for EIP712
26 changes: 24 additions & 2 deletions contracts/utils/cryptography/EIP712.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,34 @@ abstract contract EIP712 is IERC5267 {
{
return (
hex"0f", // 01111
_name.toStringWithFallback(_nameFallback),
_version.toStringWithFallback(_versionFallback),
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}

/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: By default this function reads _name which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Name() internal view returns (string memory) {
return _name.toStringWithFallback(_nameFallback);
}

/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: By default this function reads _version which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Version() internal view returns (string memory) {
return _version.toStringWithFallback(_versionFallback);
}
}
8 changes: 8 additions & 0 deletions test/utils/cryptography/EIP712.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ contract('EIP712', function (accounts) {

await this.eip712.verify(signature, wallet.getAddressString(), message.to, message.contents);
});

it('name', async function () {
expect(await this.eip712.$_EIP712Name()).to.be.equal(name);
});

it('version', async function () {
expect(await this.eip712.$_EIP712Version()).to.be.equal(version);
});
});
}
});