// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; /* Autogenerated file. Do not edit manually. */ // Import schema type import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; // Import store internals import { IStore } from "@latticexyz/store/src/IStore.sol"; import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; import { Bytes } from "@latticexyz/store/src/Bytes.sol"; import { Memory } from "@latticexyz/store/src/Memory.sol"; import { SliceLib } from "@latticexyz/store/src/Slice.sol"; import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; bytes32 constant _tableId = bytes32(abi.encodePacked(bytes16(""), bytes16("Counter"))); bytes32 constant CounterTableId = _tableId; library Counter { /** Get the table's schema */ function getSchema() internal pure returns (Schema) { SchemaType[] memory _schema = new SchemaType[](1); _schema[0] = SchemaType.UINT32; return SchemaLib.encode(_schema); } function getKeySchema() internal pure returns (Schema) { SchemaType[] memory _schema = new SchemaType[](0); return SchemaLib.encode(_schema); } /** Get the table's metadata */ function getMetadata() internal pure returns (string memory, string[] memory) { string[] memory _fieldNames = new string[](1); _fieldNames[0] = "value"; return ("Counter", _fieldNames); } /** Register the table's schema */ function registerSchema() internal { StoreSwitch.registerSchema(_tableId, getSchema(), getKeySchema()); } /** Register the table's schema (using the specified store) */ function registerSchema(IStore _store) internal { _store.registerSchema(_tableId, getSchema(), getKeySchema()); } /** Set the table's metadata */ function setMetadata() internal { (string memory _tableName, string[] memory _fieldNames) = getMetadata(); StoreSwitch.setMetadata(_tableId, _tableName, _fieldNames); } /** Set the table's metadata (using the specified store) */ function setMetadata(IStore _store) internal { (string memory _tableName, string[] memory _fieldNames) = getMetadata(); _store.setMetadata(_tableId, _tableName, _fieldNames); } /** Get value */ function get() internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); return (uint32(Bytes.slice4(_blob, 0))); } /** Get value (using the specified store) */ function get(IStore _store) internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); return (uint32(Bytes.slice4(_blob, 0))); } /** Set value */ function set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); } /** Set value (using the specified store) */ function set(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); } /** Tightly pack full data using this table's schema */ function encode(uint32 value) internal pure returns (bytes memory) { return abi.encodePacked(value); } /** Encode keys as a bytes32 array using this table's schema */ function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { _keyTuple = new bytes32[](0); } /* Delete all data for given keys */ function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreSwitch.deleteRecord(_tableId, _keyTuple); } /* Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); _store.deleteRecord(_tableId, _keyTuple); } }