PWN Revoked Nonce

1. Summary

PWNRevokedNonce.sol contract is used for revoking proposals. Each proposal has a unique nonce value which can be revoked. Every address has its own nonce space.

3. Contract details

  • PWNRevokedNonce.sol is written in Solidity version 0.8.16

Features

  • Revoke nonces and nonce spaces

  • Revoke nonce on behalf of the owner

Functions

revokeNonce(uint256 nonce)

Overview

Revokes supplied nonce in the current nonce space for msg.sender.

This function takes one argument supplied by the caller:

  • uint256nonce

Implementation

function revokeNonce(uint256 nonce) external {
    _revokeNonce(msg.sender, _nonceSpace[msg.sender], nonce);
}
revokeNonce(uint256 nonceSpace, uint256 nonce)

Overview

Revokes supplied nonce in the supplied nonce space for msg.sender.

This function takes two arguments supplied by the caller:

  • uint256nonceSpace

  • uint256nonce

Implementation

function revokeNonce(uint256 nonceSpace, uint256 nonce) external {
    _revokeNonce(msg.sender, nonceSpace, nonce);
}
revokeNonce(address owner, uint256 nonce)

Overview

Revokes supplied nonce on behalf of the owner in the current nonce space. This function can be called only by addresses with the accessTag set in the PWN Hub.

This function takes two arguments supplied by the caller:

  • addressowner

  • uint256nonce

Implementation

function revokeNonce(address owner, uint256 nonce) external onlyWithHubTag {
    _revokeNonce(owner, _nonceSpace[owner], nonce);
}
revokeNonce(address owner, uint256 nonceSpace, uint256 nonce)

Overview

Revokes supplied nonce in the supplied nonce space on behalf of the owner. This function can be called only by addresses with the accessTag set in the PWN Hub.

This function takes two arguments supplied by the caller:

  • addressowner

  • uint256nonceSpace

  • uint256nonce

Implementation

function revokeNonce(address owner, uint256 nonceSpace, uint256 nonce) external onlyWithHubTag {
    _revokeNonce(owner, nonceSpace, nonce);
}
revokeNonceSpace

Overview

Revokes all nonces in the current nonce space and increments the nonce space for msg.sender.

This function doesn't take any arguments.

Implementation

function revokeNonceSpace() external returns (uint256) {
    emit NonceSpaceRevoked(msg.sender, _nonceSpace[msg.sender]);
    return ++_nonceSpace[msg.sender];
}

View Functions

isNonceRevoked

Overview

This function returns a boolean determining if the supplied nonce is revoked for a given address in supplied nonce space.

This function takes three arguments supplied by the caller:

  • addressowner

  • uint256nonceSpace

  • uint256nonce

Implementation

function isNonceRevoked(address owner, uint256 nonceSpace, uint256 nonce) external view returns (bool) {
    return _revokedNonce[owner][nonceSpace][nonce];
}
isNonceUsable

Overview

This function returns a boolean determining if the supplied nonce is usable for a given address in supplied nonce space.

This function takes three arguments supplied by the caller:

  • addressowner

  • uint256nonceSpace

  • uint256nonce

Implementation

function isNonceUsable(address owner, uint256 nonceSpace, uint256 nonce) external view returns (bool) {
    if (_nonceSpace[owner] != nonceSpace)
        return false;

    return !_revokedNonce[owner][nonceSpace][nonce];
}
currentNonceSpace

Overview

This function returns current nonce space for an address.

This function takes one argument supplied by the caller:

  • addressowner

Implementation

function currentNonceSpace(address owner) external view returns (uint256) {
    return _nonceSpace[owner];
}

Events

The PWN Revoked Nonce contract defines two events and two errors.

event NonceRevoked(address indexed owner, uint256 indexed nonceSpace, uint256 indexed nonce);
event NonceSpaceRevoked(address indexed owner, uint256 indexed nonceSpace);
NonceRevoked

A NonceRevoked event is emitted when a nonce is revoked.

This event has three parameters:

  • address indexedowner

  • uint256 indexednonceSpace

  • uint256 indexednonce

NonceSpaceRevoked

A NonceSpaceRevoked event is emitted when a nonce space is revoked.

This event has two parameters:

  • address indexedowner

  • uint256 indexednonceSpace

Errors

error NonceAlreadyRevoked(address addr, uint256 nonceSpace, uint256 nonce);
error NonceNotUsable(address addr, uint256 nonceSpace, uint256 nonce);
NonceAlreadyRevoked

A NonceAlreadyRevoked error is thrown when trying to revoke a nonce that is already revoked.

This error has three parameters:

  • addressaddr

  • uint256nonceSpace

  • uint256nonce

NonceNotUsable

A NonceNotUsable error is thrown when trying to use a nonce that is revoked or not in the current nonce space.

This error has three parameters:

  • addressaddr

  • uint256nonceSpace

  • uint256nonce

Last updated