modifiers.sol

Overview

The modifiers.sol file defines an abstract Solidity contract named Modifiers that provides a set of reusable modifiers, constants, and access control mechanisms to be used by other contracts in the system. It extends from the Errors contract, presumably containing error codes and messages, to enforce common validation rules and preconditions across contract functions. This modular approach promotes code reuse and consistent security checks, especially around ownership verification and message sender validation.

The file also includes several constant declarations related to deployment fees, minimum balances, and currency identifiers, which standardize these values across contracts utilizing this module.

Contract: Modifiers

Description

The Modifiers contract is an abstract contract that acts as a foundational building block for other contracts. It centralizes common validation logic via Solidity modifiers, which enforce conditions such as ownership verification, minimum balance checks, and message sender validation before function execution proceeds.

Constants

Constant Name

Type

Value

Description

versionModifiers

string

"1.0.0"

Version identifier for this modifiers contract.

m_ConfigCode

uint8

1

TvmCell constant likely used for configuration validation.

FEE_DEPLOY_CONFIG

uint128

15 vmshell

Fee required for deploying configuration.

MIN_BALANCE

uint64

100000 vmshell

Minimum balance threshold for the contract.

BALANCE_ECC

uint64

100000 vmshell

Balance related to ECC (Elliptic Curve Cryptography).

MIN_BALANCE_DEPLOY

uint64

100 vmshell

Minimum balance required to deploy.

CURRENCIES_ID

uint32

1

Identifier for primary currency.

CURRENCIES_ID_SHELL

uint32

2

Identifier for shell currency.

MAX_SIZE_OF_KEYS

uint128

15

Maximum allowed size for keys, likely in a data structure.

Modifiers

Modifiers in Solidity are used to change the behavior of functions by adding prerequisite checks or logic that runs before and/or after the function body. The Modifiers contract defines the following:

onlyOwnerPubkeyOptional

modifier onlyOwnerPubkeyOptional(optional(uint256) rootpubkey)
function restrictedFunction(optional(uint256) rootpubkey) public onlyOwnerPubkeyOptional(rootpubkey) {
    // function logic
}

onlyOwner

modifier onlyOwner()
function adminFunction() public onlyOwner {
    // function logic
}

accept

modifier accept()
function payableFunction() public accept {
    // function logic
}

onlyOwnerPubkey

modifier onlyOwnerPubkey(uint256 rootpubkey)
function secureFunction(uint256 rootpubkey) public onlyOwnerPubkey(rootpubkey) {
    // function logic
}

onlyOwnerAddress

modifier onlyOwnerAddress(address addr)
function functionForSpecificSender(address addr) public onlyOwnerAddress(addr) {
    // function logic
}

minValue

modifier minValue(uint128 val)
function payableFunction() public minValue(1 vmshell) {
    // function logic
}

senderIs

modifier senderIs(address sender)
function restrictedToSender(address sender) public senderIs(sender) {
    // function logic
}

minBalance

modifier minBalance(uint128 val)
function sensitiveOperation() public minBalance(1000 vmshell) {
    // function logic
}

Implementation Details

Interactions with Other Files

Visual Diagram

classDiagram
class Modifiers {
+string versionModifiers
+uint8 m_ConfigCode
+uint128 FEE_DEPLOY_CONFIG
+uint64 MIN_BALANCE
+uint64 BALANCE_ECC
+uint64 MIN_BALANCE_DEPLOY
+uint32 CURRENCIES_ID
+uint32 CURRENCIES_ID_SHELL
+uint128 MAX_SIZE_OF_KEYS
+onlyOwnerPubkeyOptional(optional(uint256))
+onlyOwner()
+accept()
+onlyOwnerPubkey(uint256)
+onlyOwnerAddress(address)
+minValue(uint128)
+senderIs(address)
+minBalance(uint128)
}
Modifiers --|> Errors