// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.4; /// @title Reentrancy Guard /// @notice Abstract contract to provide protection against reentrancy abstract contract ReentrancyGuard { ////////////////////////////////////////////////////////////// ////////////////////////// Storage /////////////////////////// ////////////////////////////////////////////////////////////// bytes32 private constant NAMESPACE = keccak256("io.etherspot.helpers.reentrancyguard"); ////////////////////////////////////////////////////////////// ////////////////////////// Structs /////////////////////////// ////////////////////////////////////////////////////////////// struct ReentrancyStorage { uint256 status; } ////////////////////////////////////////////////////////////// ////////////////////////// Errors //////////////////////////// ////////////////////////////////////////////////////////////// error ReentrancyError(); ////////////////////////////////////////////////////////////// ///////////////////////// Constants ////////////////////////// ////////////////////////////////////////////////////////////// uint256 private constant _NOT_ENTERED = 0; uint256 private constant _ENTERED = 1; ////////////////////////////////////////////////////////////// ///////////////////////// Modifiers /////////////////////////// ////////////////////////////////////////////////////////////// modifier nonReentrant() { ReentrancyStorage storage s = reentrancyStorage(); if (s.status == _ENTERED) revert ReentrancyError(); s.status = _ENTERED; _; s.status = _NOT_ENTERED; } ////////////////////////////////////////////////////////////// ////////////////////// Private Functions ///////////////////// ////////////////////////////////////////////////////////////// /// @dev fetch local storage function reentrancyStorage() private pure returns (ReentrancyStorage storage data) { bytes32 position = NAMESPACE; // solhint-disable-next-line no-inline-assembly assembly { data.slot := position } } }