Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AccountFreezable

Git Source

Inherits: Initializable

Author: EVMAuth

Provides account freezing functionality for access control.

Abstract contract implementing account-level restrictions. Frozen accounts should be. prevented from purchasing, transferring, or receiving tokens. Uses EIP-7201 storage pattern.

State Variables

ACCOUNT_FROZEN_STATUS

Status constant for frozen accounts.

Emitted in events when an account is frozen.

bytes32 public constant ACCOUNT_FROZEN_STATUS = keccak256("ACCOUNT_FROZEN_STATUS");

ACCOUNT_UNFROZEN_STATUS

Status constant for unfrozen accounts.

Emitted in events when an account is unfrozen.

bytes32 public constant ACCOUNT_UNFROZEN_STATUS = keccak256("ACCOUNT_UNFROZEN_STATUS");

AccountFreezableStorageLocation

EIP-7201 storage slot for AccountFreezable state.

Computed as: keccak256(abi.encode(uint256(keccak256("accountfreezable.storage.AccountFreezable")) - 1)) & ~bytes32(uint256(0xff)). Prevents storage collisions in upgradeable contracts.

bytes32 private constant AccountFreezableStorageLocation =
    0xa095fe5a3c31691ae0832631cef3701285d36b2af1972f4c23463476b0353a00;

Functions

_getAccountFreezableStorage

Retrieves the storage struct for AccountFreezable.

Internal function using inline assembly for direct storage access.

function _getAccountFreezableStorage() private pure returns (AccountFreezableStorage storage $);

Returns

NameTypeDescription
$AccountFreezableStorageStorage pointer to AccountFreezableStorage struct

notFrozen

Validates account is not frozen before proceeding.

Modifier reverting with AccountFrozen if account is frozen.

modifier notFrozen(address account);

Parameters

NameTypeDescription
accountaddressAddress to check freeze status

__AccountFreezable_init

Internal initializer for AccountFreezable setup.

Currently empty as no initialization needed.

function __AccountFreezable_init() internal onlyInitializing;

__AccountFreezable_init_unchained

Unchained initializer for contract-specific storage.

Currently empty but reserved for future initialization.

function __AccountFreezable_init_unchained() internal onlyInitializing;

isFrozen

Checks if an account is frozen.

Frozen accounts should not be permitted to perform token operations.

function isFrozen(address account) external view virtual returns (bool);

Parameters

NameTypeDescription
accountaddressAddress to check

Returns

NameTypeDescription
<none>boolTrue if account is frozen, false otherwise

frozenAccounts

Retrieves all currently frozen accounts.

Returns the complete frozen accounts list.

function frozenAccounts() external view virtual returns (address[] memory);

Returns

NameTypeDescription
<none>address[]Array of frozen account addresses

_freezeAccount

Internal function to freeze an account.

Idempotent operation. Adds account to frozen list if not already frozen.

Notes:

  • throws: InvalidAddress When account is zero address

  • emits: AccountStatusUpdated With ACCOUNT_FROZEN_STATUS

function _freezeAccount(address account) internal virtual;

Parameters

NameTypeDescription
accountaddressAddress to freeze (cannot be zero address)

_unfreezeAccount

Internal function to unfreeze an account.

Idempotent operation. Removes account from frozen list if frozen.

Note: emits: AccountStatusUpdated With ACCOUNT_UNFROZEN_STATUS

function _unfreezeAccount(address account) internal virtual;

Parameters

NameTypeDescription
accountaddressAddress to unfreeze

Events

AccountStatusUpdated

Emitted when account status changes.

event AccountStatusUpdated(address indexed account, bytes32 indexed status);

Parameters

NameTypeDescription
accountaddressAddress whose status changed
statusbytes32New status (ACCOUNT_FROZEN_STATUS or ACCOUNT_UNFROZEN_STATUS)

Errors

AccountFrozen

Error for operations attempted by frozen accounts.

error AccountFrozen(address account);

Parameters

NameTypeDescription
accountaddressThe frozen account address

InvalidAddress

Error for invalid address in access control operations.

error InvalidAddress(address account);

Parameters

NameTypeDescription
accountaddressThe invalid address provided

Structs

AccountFreezableStorage

Note: storage-location: erc7201:accountfreezable.storage.AccountFreezable

struct AccountFreezableStorage {
    mapping(address => bool) frozenAccounts;
    address[] frozenList;
}