// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.16; /// @title Oneshot /// @author Vladyslav Dalechyn /// @notice Oneshot is a contract extensions which brings one-shot function modifiers, meaning that /// those functions can be called only once. abstract contract Oneshot { /*/////////////////////////////////////////////////////////////// State variables //////////////////////////////////////////////////////////////*/ mapping(bytes4 => bool) private _shot; /*/////////////////////////////////////////////////////////////// Errors //////////////////////////////////////////////////////////////*/ error AlreadyShotError(); /*/////////////////////////////////////////////////////////////// Modifiers //////////////////////////////////////////////////////////////*/ modifier oneShot() { bytes4 sig = msg.sig; if (_shot[sig]) { revert AlreadyShotError(); } _shot[sig] = true; _; } }