PWN Revoked Nonce

1. Summary

PWNRevokedNonce.sol contract is used for revoking offers and loan requests. Each offer or loan request has a unique nonce value which can be revoked. It is also possible to set a minimal nonce value to revoke all nonces up to a set value. One PWNRevokedNonce contract corresponds with one offer or loan type.

3. Contract details

  • PWNRevokedNonce.sol is written in Solidity version 0.8.16

Features

  • Revoke nonce

  • Revoke nonce on behalf of the owner

  • Set a minimal nonce value

Functions

revokeNonce(uint256 nonce)

Overview

Revokes supplied nonce for msg.sender.

This function takes one argument supplied by the caller:

  • uint256nonce

Implementation

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

Overview

Revokes supplied nonce 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

  • uint256nonce

Implementation

function revokeNonce(address owner, uint256 nonce) external onlyWithTag(accessTag) {
    _revokeNonce(owner, nonce);
}
setMinNonce

Overview

Sets a minimal nonce for msg.sender, thus revoking all nonces with a smaller nonce.

This function takes one argument supplied by the caller:

  • uint256minNonce

Implementation

function setMinNonce(uint256 minNonce) external {
    // Check that nonce is greater than current min nonce
    uint256 currentMinNonce = minNonces[msg.sender];
    if (currentMinNonce >= minNonce)
        revert InvalidMinNonce();

    // Set new min nonce value
    minNonces[msg.sender] = minNonce;

    // Emit event
    emit MinNonceSet(msg.sender, minNonce);
}

View Functions

isNonceRevoked

Overview

This function returns a boolean determining if the supplied nonce is valid for a given address.

This function takes two arguments supplied by the caller:

  • addressowner - The address to check

  • uint256nonce - The nonce to check

Implementation

function isNonceRevoked(address owner, uint256 nonce) external view returns (bool) {
    if (nonce < minNonces[owner])
        return true;

    return revokedNonces[owner][nonce];
}

Events

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

event NonceRevoked(address indexed owner, uint256 indexed nonce);
event MinNonceSet(address indexed owner, uint256 indexed minNonce);
NonceRevoked

A NonceRevoked event is emitted when a nonce is revoked.

This event has two parameters:

  • address indexedowner

  • uint256 indexednonce

MinNonceSet

A MinNonceSet event is emitted when a minimal nonce value is set.

This event has two parameters:

  • address indexedowner

  • uint256 indexedminNonce

Last updated