// SPDX-License-Identifier: MIT // buenos_andres Compact Contracts v0.2.11 (security/Initializable.compact) pragma language_version >= 0.18.0; /** * @module Initializable * @description Initializable provides a simple mechanism that mimics the functionality of a constructor. */ module Initializable { import CompactStandardLibrary; export ledger _isInitialized: Boolean; /** * @description Initializes the state thus ensuring the calling circuit can only be called once. * * @circuitInfo k=10, rows=38 * * Requirements: * * - Contract must not be initialized. * * @return {[]} - Empty tuple. */ export circuit initialize(): [] { assertNotInitialized(); _isInitialized = true; } /** * @description Asserts that the contract has been initialized, throwing an error if not. * * @circuitInfo k=10, rows=31 * * Requirements: * * - Contract must be initialized. * * @return {[]} - Empty tuple. */ export circuit assertInitialized(): [] { assert(_isInitialized, "Initializable: contract not initialized"); } /** * @description Asserts that the contract has not been initialized, throwing an error if it has. * * @circuitInfo k=10, rows=35 * * Requirements: * * - Contract must not be initialized. * * @return {[]} - Empty tuple. */ export circuit assertNotInitialized(): [] { assert(!_isInitialized, "Initializable: contract already initialized"); } }