// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ // 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 { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; import { Schema } from "@latticexyz/store/src/Schema.sol"; import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; library WorldVersion { // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "evefrontier", name: "WorldVersion", typeId: RESOURCE_TABLE });` ResourceId constant _tableId = ResourceId.wrap(0x746265766566726f6e74696572000000576f726c6456657273696f6e00000000); FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0000000100000000000000000000000000000000000000000000000000000000); // Hex-encoded key schema of () Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); // Hex-encoded value schema of (string) Schema constant _valueSchema = Schema.wrap(0x00000001c5000000000000000000000000000000000000000000000000000000); /** * @notice Get the table's key field names. * @return keyNames An array of strings with the names of key fields. */ function getKeyNames() internal pure returns (string[] memory keyNames) { keyNames = new string[](0); } /** * @notice Get the table's value field names. * @return fieldNames An array of strings with the names of value fields. */ function getFieldNames() internal pure returns (string[] memory fieldNames) { fieldNames = new string[](1); fieldNames[0] = "version"; } /** * @notice Register the table with its config. */ function register() internal { StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); } /** * @notice Register the table with its config. */ function _register() internal { StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); } /** * @notice Get version. */ function getVersion() internal view returns (string memory version) { bytes32[] memory _keyTuple = new bytes32[](0); bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0); return (string(_blob)); } /** * @notice Get version. */ function _getVersion() internal view returns (string memory version) { bytes32[] memory _keyTuple = new bytes32[](0); bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0); return (string(_blob)); } /** * @notice Get version. */ function get() internal view returns (string memory version) { bytes32[] memory _keyTuple = new bytes32[](0); bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0); return (string(_blob)); } /** * @notice Get version. */ function _get() internal view returns (string memory version) { bytes32[] memory _keyTuple = new bytes32[](0); bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0); return (string(_blob)); } /** * @notice Set version. */ function setVersion(string memory version) internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, bytes((version))); } /** * @notice Set version. */ function _setVersion(string memory version) internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreCore.setDynamicField(_tableId, _keyTuple, 0, bytes((version))); } /** * @notice Set version. */ function set(string memory version) internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, bytes((version))); } /** * @notice Set version. */ function _set(string memory version) internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreCore.setDynamicField(_tableId, _keyTuple, 0, bytes((version))); } /** * @notice Get the length of version. */ function lengthVersion() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 1; } } /** * @notice Get the length of version. */ function _lengthVersion() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 1; } } /** * @notice Get the length of version. */ function length() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 1; } } /** * @notice Get the length of version. */ function _length() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 1; } } /** * @notice Get an item of version. * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. */ function getItemVersion(uint256 _index) internal view returns (string memory) { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); return (string(_blob)); } } /** * @notice Get an item of version. * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. */ function _getItemVersion(uint256 _index) internal view returns (string memory) { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); return (string(_blob)); } } /** * @notice Get an item of version. * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. */ function getItem(uint256 _index) internal view returns (string memory) { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); return (string(_blob)); } } /** * @notice Get an item of version. * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. */ function _getItem(uint256 _index) internal view returns (string memory) { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); return (string(_blob)); } } /** * @notice Push a slice to version. */ function pushVersion(string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice))); } /** * @notice Push a slice to version. */ function _pushVersion(string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice))); } /** * @notice Push a slice to version. */ function push(string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice))); } /** * @notice Push a slice to version. */ function _push(string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice))); } /** * @notice Pop a slice from version. */ function popVersion() internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1); } /** * @notice Pop a slice from version. */ function _popVersion() internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1); } /** * @notice Pop a slice from version. */ function pop() internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1); } /** * @notice Pop a slice from version. */ function _pop() internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1); } /** * @notice Update a slice of version at `_index`. */ function updateVersion(uint256 _index, string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { bytes memory _encoded = bytes((_slice)); StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); } } /** * @notice Update a slice of version at `_index`. */ function _updateVersion(uint256 _index, string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { bytes memory _encoded = bytes((_slice)); StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); } } /** * @notice Update a slice of version at `_index`. */ function update(uint256 _index, string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { bytes memory _encoded = bytes((_slice)); StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); } } /** * @notice Update a slice of version at `_index`. */ function _update(uint256 _index, string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { bytes memory _encoded = bytes((_slice)); StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); } } /** * @notice Delete all data for given keys. */ function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** * @notice Delete all data for given keys. */ function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** * @notice Tightly pack dynamic data lengths using this table's schema. * @return _encodedLengths The lengths of the dynamic fields (packed into a single bytes32 value). */ function encodeLengths(string memory version) internal pure returns (EncodedLengths _encodedLengths) { // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits unchecked { _encodedLengths = EncodedLengthsLib.pack(bytes(version).length); } } /** * @notice Tightly pack dynamic (variable length) data using this table's schema. * @return The dynamic data, encoded into a sequence of bytes. */ function encodeDynamic(string memory version) internal pure returns (bytes memory) { return abi.encodePacked(bytes((version))); } /** * @notice Encode all of a record's fields. * @return The static (fixed length) data, encoded into a sequence of bytes. * @return The lengths of the dynamic fields (packed into a single bytes32 value). * @return The dynamic (variable length) data, encoded into a sequence of bytes. */ function encode(string memory version) internal pure returns (bytes memory, EncodedLengths, bytes memory) { bytes memory _staticData; EncodedLengths _encodedLengths = encodeLengths(version); bytes memory _dynamicData = encodeDynamic(version); return (_staticData, _encodedLengths, _dynamicData); } /** * @notice Encode keys as a bytes32 array using this table's field layout. */ function encodeKeyTuple() internal pure returns (bytes32[] memory) { bytes32[] memory _keyTuple = new bytes32[](0); return _keyTuple; } }