Nonces .sol safe to use?

Hi there,

I have installed "@openzeppelin/contracts": "^4.9.2" and I noticed that Nonces.sol is not bundled on it.

How safe is to use the once in the repo?

Thx.

Looks safe.

This function:

    /**
     * @dev Returns an address nonce.
     */
    function nonces(address owner) public view virtual returns (uint256) {
        return _nonces[owner];
    }

Should probably be renamed, since it returns a single nonce rather than several nonces.
That's just semantics of course, but perhaps it indicates that this contract is work-in-progress.

1 Like

Thx for the replay!

How do u believe this method would be called? nonce? getNonce?

Just to deploy it with a different name. Thx in advance

Well, nonce would be the most suitable as far a OZ naming convention goes (in opposed to getNonce, for example).

But it is already in use as a local variable in other functions, so that's gonna give a compilation error (or at least warning).

Same goes for currentNonce.

Perhaps usedNonce is suitable enough.

1 Like

Mmm not sure if usedNonce is a good name for it because, nonces method returns the currentNonce (the once to be used) instead of the last nonce used.

Well, finally I decided not to change it because it seems is already being used in the IERC20Permit so...

not sure if its something its gonna change in the future.

Folks please read the README there is a big disclaimer at the top:

Warning Version 5.0 is under active development. The code in this branch is not recommended for use

As a general recommendation you should avoid using the master or main branch of a library... There is a reason we do releases.

1 Like