modifiers.sol

Overview

This Solidity source file defines an abstract contract Modifiers which centralizes a collection of constants and reusable function modifiers to enforce common access controls, validations, and gas acceptance patterns in the GOSH smart contract ecosystem. The contract inherits from an Errors contract to utilize standardized error codes for revert messages.

The purpose of Modifiers is to provide a consistent and maintainable way to implement permission checks (such as ownership and sender verification), resource constraints (minimum balance or message value), and transaction acceptance across various contracts within the system. This helps reduce code duplication and enhances security by standardizing validation logic.

Constants

The file declares numerous constants used throughout the system, categorized as follows:

These constants are intended for use in various parts of the GOSH ecosystem and provide standardized values that ensure consistency and prevent magic numbers scattered across the codebase.

Contract: Modifiers

The Modifiers contract is an abstract contract extending from Errors, indicating it cannot be instantiated directly but serves as a base for other contracts.

Properties

Modifiers

Modifiers are reusable pieces of code that can be attached to functions to enforce certain preconditions or behaviors.

onlyOwnerPubkey(uint256 rootpubkey)

onlyOwner

accept

onlyOwnerWallet(optional(address) owner_wallet, uint256 rootpubkey)

onlyOwnerWalletOpt(optional(address) owner_wallet, optional(uint256) rootpubkey)

onlyOwnerAddress(address addr)

minValue(uint128 val)

senderIs(address sender)

minBalance(uint128 val)

Important Implementation Details

Interactions with Other Parts of the System

Mermaid Diagram: Contract Structure

classDiagram
class Modifiers {
+string versionModifiers
+modifier onlyOwnerPubkey()
+modifier onlyOwner()
+modifier accept()
+modifier onlyOwnerWallet()
+modifier onlyOwnerWalletOpt()
+modifier onlyOwnerAddress()
+modifier minValue()
+modifier senderIs()
+modifier minBalance()
}
Modifiers --|> Errors

The diagram illustrates the Modifiers contract inheriting from Errors and lists the available modifiers and the versionModifiers property. This structure reflects how Modifiers serves as a base for access control and validation in the system.