Skip to content
Verified contractExactLGPL-3.0-only

SetTxNonceGuard

Address0x7ae03372ecdcee335cdefb7d354d507f0506616c
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.6

 

Same code

1 more contract

 

Details

Compiler
solc 0.8.6+commit.11564f7e
Language
solidity
Optimization
No
License
LGPL-3.0-only
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,041,911
Creation transaction
0x919d6b1ea5…77b3634e83

contracts/helpers/SetTxNonceGuard.sol

// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "@gnosis.pm/zodiac/contracts/guard/BaseGuard.sol";

interface IDelay {
    function setTxNonce(uint256 _nonce) external;
}

/// @title SetTxNonceGuard - Restricts a module to calling setTxNonce on one Delay modifier.
/// @dev Attach with `setGuard` on a Zodiac module. Module.exec and
/// Module.execAndReturnData route every transaction through checkTransaction,
/// so while this guard is set the module can do nothing other than invalidate
/// the queue of the Delay it was deployed against.
contract SetTxNonceGuard is BaseGuard {
    /// @dev Delay modifier whose transaction queue may be invalidated.
    address public immutable delay;

    /// Destination is not the Delay modifier
    error UnexpectedTarget(address to);

    /// Only plain calls are allowed, not delegate calls
    error UnexpectedOperation();

    /// Only zero value transactions are allowed
    error UnexpectedValue();

    /// Payload is not an abi encoded setTxNonce(uint256)
    error UnexpectedCalldata();

    constructor(address _delay) {
        delay = _delay;
    }

    /// @dev Reverts unless the transaction is delay.setTxNonce(uint256).
    /// @param to Destination address of module transaction
    /// @param value Ether value of module transaction
    /// @param data Data payload of module transaction
    /// @param operation Operation type of module transaction
    function checkTransaction(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation,
        uint256,
        uint256,
        uint256,
        address,
        address payable,
        bytes memory,
        address
    ) external view override {
        if (to != delay) {
            revert UnexpectedTarget(to);
        }
        if (operation != Enum.Operation.Call) {
            revert UnexpectedOperation();
        }
        if (value != 0) {
            revert UnexpectedValue();
        }
        // Exact length, so that no extra calldata rides along behind the nonce
        if (data.length != 36 || bytes4(data) != IDelay.setTxNonce.selector) {
            revert UnexpectedCalldata();
        }
    }

    function checkAfterExecution(bytes32, bool) external view override {}
}

@gnosis.pm/safe-contracts/contracts/common/Enum.sol

// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/// @title Enum - Collection of enums
/// @author Richard Meissner - <[email protected]>
contract Enum {
    enum Operation {Call, DelegateCall}
}

@gnosis.pm/safe-contracts/contracts/interfaces/IERC165.sol

// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/// @notice More details at https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

@gnosis.pm/zodiac/contracts/guard/BaseGuard.sol

// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "@gnosis.pm/safe-contracts/contracts/common/Enum.sol";
import "@gnosis.pm/safe-contracts/contracts/interfaces/IERC165.sol";
import "../interfaces/IGuard.sol";

abstract contract BaseGuard is IERC165 {
    function supportsInterface(bytes4 interfaceId)
        external
        pure
        override
        returns (bool)
    {
        return
            interfaceId == type(IGuard).interfaceId || // 0xe6d7a83a
            interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7
    }

    /// Module transactions only use the first four parameters: to, value, data, and operation.
    /// Module.sol hardcodes the remaining parameters as 0 since they are not used for module transactions.
    /// This interface is used to maintain compatibilty with Gnosis Safe transaction guards.
    function checkTransaction(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address payable refundReceiver,
        bytes memory signatures,
        address msgSender
    ) external virtual;

    function checkAfterExecution(bytes32 txHash, bool success) external virtual;
}

@gnosis.pm/zodiac/contracts/interfaces/IGuard.sol

// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "@gnosis.pm/safe-contracts/contracts/common/Enum.sol";

interface IGuard {
    function checkTransaction(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address payable refundReceiver,
        bytes memory signatures,
        address msgSender
    ) external;

    function checkAfterExecution(bytes32 txHash, bool success) external;
}
Compiler settingsShow
{
  "metadata": {
    "useLiteralContent": true
  },
  "optimizer": {
    "runs": 200,
    "enabled": false
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.