// 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"; // Import user types import { State } from "../../../../codegen/common.sol"; struct DeployableStateData { uint256 createdAt; State previousState; State currentState; bool isValid; uint256 anchoredAt; uint256 updatedBlockNumber; uint256 updatedBlockTime; } library DeployableState { // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "evefrontier", name: "DeployableState", typeId: RESOURCE_TABLE });` ResourceId constant _tableId = ResourceId.wrap(0x746265766566726f6e746965720000004465706c6f7961626c65537461746500); FieldLayout constant _fieldLayout = FieldLayout.wrap(0x0083070020010101202020000000000000000000000000000000000000000000); // Hex-encoded key schema of (uint256) Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); // Hex-encoded value schema of (uint256, uint8, uint8, bool, uint256, uint256, uint256) Schema constant _valueSchema = Schema.wrap(0x008307001f0000601f1f1f000000000000000000000000000000000000000000); /** * @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[](1); keyNames[0] = "smartObjectId"; } /** * @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[](7); fieldNames[0] = "createdAt"; fieldNames[1] = "previousState"; fieldNames[2] = "currentState"; fieldNames[3] = "isValid"; fieldNames[4] = "anchoredAt"; fieldNames[5] = "updatedBlockNumber"; fieldNames[6] = "updatedBlockTime"; } /** * @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 createdAt. */ function getCreatedAt(uint256 smartObjectId) internal view returns (uint256 createdAt) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); return (uint256(bytes32(_blob))); } /** * @notice Get createdAt. */ function _getCreatedAt(uint256 smartObjectId) internal view returns (uint256 createdAt) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); return (uint256(bytes32(_blob))); } /** * @notice Set createdAt. */ function setCreatedAt(uint256 smartObjectId, uint256 createdAt) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((createdAt)), _fieldLayout); } /** * @notice Set createdAt. */ function _setCreatedAt(uint256 smartObjectId, uint256 createdAt) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((createdAt)), _fieldLayout); } /** * @notice Get previousState. */ function getPreviousState(uint256 smartObjectId) internal view returns (State previousState) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); return State(uint8(bytes1(_blob))); } /** * @notice Get previousState. */ function _getPreviousState(uint256 smartObjectId) internal view returns (State previousState) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); return State(uint8(bytes1(_blob))); } /** * @notice Set previousState. */ function setPreviousState(uint256 smartObjectId, State previousState) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked(uint8(previousState)), _fieldLayout); } /** * @notice Set previousState. */ function _setPreviousState(uint256 smartObjectId, State previousState) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked(uint8(previousState)), _fieldLayout); } /** * @notice Get currentState. */ function getCurrentState(uint256 smartObjectId) internal view returns (State currentState) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); return State(uint8(bytes1(_blob))); } /** * @notice Get currentState. */ function _getCurrentState(uint256 smartObjectId) internal view returns (State currentState) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); return State(uint8(bytes1(_blob))); } /** * @notice Set currentState. */ function setCurrentState(uint256 smartObjectId, State currentState) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked(uint8(currentState)), _fieldLayout); } /** * @notice Set currentState. */ function _setCurrentState(uint256 smartObjectId, State currentState) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked(uint8(currentState)), _fieldLayout); } /** * @notice Get isValid. */ function getIsValid(uint256 smartObjectId) internal view returns (bool isValid) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 3, _fieldLayout); return (_toBool(uint8(bytes1(_blob)))); } /** * @notice Get isValid. */ function _getIsValid(uint256 smartObjectId) internal view returns (bool isValid) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 3, _fieldLayout); return (_toBool(uint8(bytes1(_blob)))); } /** * @notice Set isValid. */ function setIsValid(uint256 smartObjectId, bool isValid) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((isValid)), _fieldLayout); } /** * @notice Set isValid. */ function _setIsValid(uint256 smartObjectId, bool isValid) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((isValid)), _fieldLayout); } /** * @notice Get anchoredAt. */ function getAnchoredAt(uint256 smartObjectId) internal view returns (uint256 anchoredAt) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 4, _fieldLayout); return (uint256(bytes32(_blob))); } /** * @notice Get anchoredAt. */ function _getAnchoredAt(uint256 smartObjectId) internal view returns (uint256 anchoredAt) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 4, _fieldLayout); return (uint256(bytes32(_blob))); } /** * @notice Set anchoredAt. */ function setAnchoredAt(uint256 smartObjectId, uint256 anchoredAt) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((anchoredAt)), _fieldLayout); } /** * @notice Set anchoredAt. */ function _setAnchoredAt(uint256 smartObjectId, uint256 anchoredAt) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((anchoredAt)), _fieldLayout); } /** * @notice Get updatedBlockNumber. */ function getUpdatedBlockNumber(uint256 smartObjectId) internal view returns (uint256 updatedBlockNumber) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 5, _fieldLayout); return (uint256(bytes32(_blob))); } /** * @notice Get updatedBlockNumber. */ function _getUpdatedBlockNumber(uint256 smartObjectId) internal view returns (uint256 updatedBlockNumber) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 5, _fieldLayout); return (uint256(bytes32(_blob))); } /** * @notice Set updatedBlockNumber. */ function setUpdatedBlockNumber(uint256 smartObjectId, uint256 updatedBlockNumber) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.setStaticField(_tableId, _keyTuple, 5, abi.encodePacked((updatedBlockNumber)), _fieldLayout); } /** * @notice Set updatedBlockNumber. */ function _setUpdatedBlockNumber(uint256 smartObjectId, uint256 updatedBlockNumber) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.setStaticField(_tableId, _keyTuple, 5, abi.encodePacked((updatedBlockNumber)), _fieldLayout); } /** * @notice Get updatedBlockTime. */ function getUpdatedBlockTime(uint256 smartObjectId) internal view returns (uint256 updatedBlockTime) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 6, _fieldLayout); return (uint256(bytes32(_blob))); } /** * @notice Get updatedBlockTime. */ function _getUpdatedBlockTime(uint256 smartObjectId) internal view returns (uint256 updatedBlockTime) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 6, _fieldLayout); return (uint256(bytes32(_blob))); } /** * @notice Set updatedBlockTime. */ function setUpdatedBlockTime(uint256 smartObjectId, uint256 updatedBlockTime) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.setStaticField(_tableId, _keyTuple, 6, abi.encodePacked((updatedBlockTime)), _fieldLayout); } /** * @notice Set updatedBlockTime. */ function _setUpdatedBlockTime(uint256 smartObjectId, uint256 updatedBlockTime) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.setStaticField(_tableId, _keyTuple, 6, abi.encodePacked((updatedBlockTime)), _fieldLayout); } /** * @notice Get the full data. */ function get(uint256 smartObjectId) internal view returns (DeployableStateData memory _table) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord( _tableId, _keyTuple, _fieldLayout ); return decode(_staticData, _encodedLengths, _dynamicData); } /** * @notice Get the full data. */ function _get(uint256 smartObjectId) internal view returns (DeployableStateData memory _table) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord( _tableId, _keyTuple, _fieldLayout ); return decode(_staticData, _encodedLengths, _dynamicData); } /** * @notice Set the full data using individual values. */ function set( uint256 smartObjectId, uint256 createdAt, State previousState, State currentState, bool isValid, uint256 anchoredAt, uint256 updatedBlockNumber, uint256 updatedBlockTime ) internal { bytes memory _staticData = encodeStatic( createdAt, previousState, currentState, isValid, anchoredAt, updatedBlockNumber, updatedBlockTime ); EncodedLengths _encodedLengths; bytes memory _dynamicData; bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** * @notice Set the full data using individual values. */ function _set( uint256 smartObjectId, uint256 createdAt, State previousState, State currentState, bool isValid, uint256 anchoredAt, uint256 updatedBlockNumber, uint256 updatedBlockTime ) internal { bytes memory _staticData = encodeStatic( createdAt, previousState, currentState, isValid, anchoredAt, updatedBlockNumber, updatedBlockTime ); EncodedLengths _encodedLengths; bytes memory _dynamicData; bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** * @notice Set the full data using the data struct. */ function set(uint256 smartObjectId, DeployableStateData memory _table) internal { bytes memory _staticData = encodeStatic( _table.createdAt, _table.previousState, _table.currentState, _table.isValid, _table.anchoredAt, _table.updatedBlockNumber, _table.updatedBlockTime ); EncodedLengths _encodedLengths; bytes memory _dynamicData; bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** * @notice Set the full data using the data struct. */ function _set(uint256 smartObjectId, DeployableStateData memory _table) internal { bytes memory _staticData = encodeStatic( _table.createdAt, _table.previousState, _table.currentState, _table.isValid, _table.anchoredAt, _table.updatedBlockNumber, _table.updatedBlockTime ); EncodedLengths _encodedLengths; bytes memory _dynamicData; bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** * @notice Decode the tightly packed blob of static data using this table's field layout. */ function decodeStatic( bytes memory _blob ) internal pure returns ( uint256 createdAt, State previousState, State currentState, bool isValid, uint256 anchoredAt, uint256 updatedBlockNumber, uint256 updatedBlockTime ) { createdAt = (uint256(Bytes.getBytes32(_blob, 0))); previousState = State(uint8(Bytes.getBytes1(_blob, 32))); currentState = State(uint8(Bytes.getBytes1(_blob, 33))); isValid = (_toBool(uint8(Bytes.getBytes1(_blob, 34)))); anchoredAt = (uint256(Bytes.getBytes32(_blob, 35))); updatedBlockNumber = (uint256(Bytes.getBytes32(_blob, 67))); updatedBlockTime = (uint256(Bytes.getBytes32(_blob, 99))); } /** * @notice Decode the tightly packed blobs using this table's field layout. * @param _staticData Tightly packed static fields. * * */ function decode( bytes memory _staticData, EncodedLengths, bytes memory ) internal pure returns (DeployableStateData memory _table) { ( _table.createdAt, _table.previousState, _table.currentState, _table.isValid, _table.anchoredAt, _table.updatedBlockNumber, _table.updatedBlockTime ) = decodeStatic(_staticData); } /** * @notice Delete all data for given keys. */ function deleteRecord(uint256 smartObjectId) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** * @notice Delete all data for given keys. */ function _deleteRecord(uint256 smartObjectId) internal { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** * @notice Tightly pack static (fixed length) data using this table's schema. * @return The static data, encoded into a sequence of bytes. */ function encodeStatic( uint256 createdAt, State previousState, State currentState, bool isValid, uint256 anchoredAt, uint256 updatedBlockNumber, uint256 updatedBlockTime ) internal pure returns (bytes memory) { return abi.encodePacked( createdAt, previousState, currentState, isValid, anchoredAt, updatedBlockNumber, updatedBlockTime ); } /** * @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( uint256 createdAt, State previousState, State currentState, bool isValid, uint256 anchoredAt, uint256 updatedBlockNumber, uint256 updatedBlockTime ) internal pure returns (bytes memory, EncodedLengths, bytes memory) { bytes memory _staticData = encodeStatic( createdAt, previousState, currentState, isValid, anchoredAt, updatedBlockNumber, updatedBlockTime ); EncodedLengths _encodedLengths; bytes memory _dynamicData; return (_staticData, _encodedLengths, _dynamicData); } /** * @notice Encode keys as a bytes32 array using this table's field layout. */ function encodeKeyTuple(uint256 smartObjectId) internal pure returns (bytes32[] memory) { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(smartObjectId)); return _keyTuple; } } /** * @notice Cast a value to a bool. * @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool. * @param value The uint8 value to convert. * @return result The boolean value. */ function _toBool(uint8 value) pure returns (bool result) { assembly { result := value } }