Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BT-235: ERC2612 - Add ERC-20 Permit function compatibility #236

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

pgonday
Copy link

@pgonday pgonday commented Dec 16, 2024

@pgonday pgonday marked this pull request as ready for review December 17, 2024 11:05

pragma solidity 0.8.27;

import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named imports are preferred when possible

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that as been done for token-factory, but in trex all import are "classical"... But ok to update it.

EIP712Storage storage $ = _getEIP712Storage();
// If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized
// and the EIP712 domain is not reliable, as it will be missing name and version.
require($._hashedName == 0 && $._hashedVersion == 0, "EIP712: Uninitialized");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom error instead of string could help to save some gas here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact I have just copy/paste OpenZeppelin contract to be sure to not add regression (just reorder function for solhint). At first I try to just import the file, but I haven't succeed to manage several version into the package.json. I need the last version of contract-upgradeable (for the custom storage), but it have dependencies on last OpenZeppelin contracts which is not the one we are using...
So either we find a way to just import the correct version, if not we can maybe replace with a custom error.

* @dev See {IERC-5267}.
*/
function eip712Domain()
public
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this function is public and not external? It seems to be external in the specification and I haven't seen it being explicitly called internally within the contract

https://eips.ethereum.org/EIPS/eip-5267

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -119,7 +120,13 @@ error DefaultAllowanceAlreadyDisabled(address _user);
error DefaultAllowanceAlreadySet(address _target);


contract Token is IToken, AgentRoleUpgradeable, TokenStorage, IERC165 {
contract Token is IToken, AgentRoleUpgradeable, TokenStorage, IERC165, TokenPermit {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are implementing ERC165, therefore we should add IERC20Permit to the supported interfaces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants