diff --git a/packages/world/mud.config.ts b/packages/world/mud.config.ts index a3f9c8f25f..054cb1ffd9 100644 --- a/packages/world/mud.config.ts +++ b/packages/world/mud.config.ts @@ -32,7 +32,7 @@ export default mudConfig({ argumentsHash: "bytes32", // Hash of the params passed to the `install` function }, valueSchema: { - isInitialized: "bool", + isInstalled: "bool", }, }, UserDelegationControl: { diff --git a/packages/world/src/codegen/tables/InstalledModules.sol b/packages/world/src/codegen/tables/InstalledModules.sol index 07fdf1e4ee..abf0df5adc 100644 --- a/packages/world/src/codegen/tables/InstalledModules.sol +++ b/packages/world/src/codegen/tables/InstalledModules.sol @@ -77,7 +77,7 @@ library InstalledModules { */ function getFieldNames() internal pure returns (string[] memory fieldNames) { fieldNames = new string[](1); - fieldNames[0] = "isInitialized"; + fieldNames[0] = "isInstalled"; } /** @@ -95,9 +95,9 @@ library InstalledModules { } /** - * @notice Get isInitialized. + * @notice Get isInstalled. */ - function getIsInitialized(address moduleAddress, bytes32 argumentsHash) internal view returns (bool isInitialized) { + function getIsInstalled(address moduleAddress, bytes32 argumentsHash) internal view returns (bool isInstalled) { bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = bytes32(uint256(uint160(moduleAddress))); _keyTuple[1] = argumentsHash; @@ -107,9 +107,9 @@ library InstalledModules { } /** - * @notice Get isInitialized. + * @notice Get isInstalled. */ - function _getIsInitialized(address moduleAddress, bytes32 argumentsHash) internal view returns (bool isInitialized) { + function _getIsInstalled(address moduleAddress, bytes32 argumentsHash) internal view returns (bool isInstalled) { bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = bytes32(uint256(uint160(moduleAddress))); _keyTuple[1] = argumentsHash; @@ -119,9 +119,9 @@ library InstalledModules { } /** - * @notice Get isInitialized. + * @notice Get isInstalled. */ - function get(address moduleAddress, bytes32 argumentsHash) internal view returns (bool isInitialized) { + function get(address moduleAddress, bytes32 argumentsHash) internal view returns (bool isInstalled) { bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = bytes32(uint256(uint160(moduleAddress))); _keyTuple[1] = argumentsHash; @@ -131,9 +131,9 @@ library InstalledModules { } /** - * @notice Get isInitialized. + * @notice Get isInstalled. */ - function _get(address moduleAddress, bytes32 argumentsHash) internal view returns (bool isInitialized) { + function _get(address moduleAddress, bytes32 argumentsHash) internal view returns (bool isInstalled) { bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = bytes32(uint256(uint160(moduleAddress))); _keyTuple[1] = argumentsHash; @@ -143,47 +143,47 @@ library InstalledModules { } /** - * @notice Set isInitialized. + * @notice Set isInstalled. */ - function setIsInitialized(address moduleAddress, bytes32 argumentsHash, bool isInitialized) internal { + function setIsInstalled(address moduleAddress, bytes32 argumentsHash, bool isInstalled) internal { bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = bytes32(uint256(uint160(moduleAddress))); _keyTuple[1] = argumentsHash; - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInitialized)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInstalled)), _fieldLayout); } /** - * @notice Set isInitialized. + * @notice Set isInstalled. */ - function _setIsInitialized(address moduleAddress, bytes32 argumentsHash, bool isInitialized) internal { + function _setIsInstalled(address moduleAddress, bytes32 argumentsHash, bool isInstalled) internal { bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = bytes32(uint256(uint160(moduleAddress))); _keyTuple[1] = argumentsHash; - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInitialized)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInstalled)), _fieldLayout); } /** - * @notice Set isInitialized. + * @notice Set isInstalled. */ - function set(address moduleAddress, bytes32 argumentsHash, bool isInitialized) internal { + function set(address moduleAddress, bytes32 argumentsHash, bool isInstalled) internal { bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = bytes32(uint256(uint160(moduleAddress))); _keyTuple[1] = argumentsHash; - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInitialized)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInstalled)), _fieldLayout); } /** - * @notice Set isInitialized. + * @notice Set isInstalled. */ - function _set(address moduleAddress, bytes32 argumentsHash, bool isInitialized) internal { + function _set(address moduleAddress, bytes32 argumentsHash, bool isInstalled) internal { bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = bytes32(uint256(uint160(moduleAddress))); _keyTuple[1] = argumentsHash; - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInitialized)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInstalled)), _fieldLayout); } /** @@ -212,8 +212,8 @@ library InstalledModules { * @notice Tightly pack static (fixed length) data using this table's schema. * @return The static data, encoded into a sequence of bytes. */ - function encodeStatic(bool isInitialized) internal pure returns (bytes memory) { - return abi.encodePacked(isInitialized); + function encodeStatic(bool isInstalled) internal pure returns (bytes memory) { + return abi.encodePacked(isInstalled); } /** @@ -222,8 +222,8 @@ library InstalledModules { * @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(bool isInitialized) internal pure returns (bytes memory, PackedCounter, bytes memory) { - bytes memory _staticData = encodeStatic(isInitialized); + function encode(bool isInstalled) internal pure returns (bytes memory, PackedCounter, bytes memory) { + bytes memory _staticData = encodeStatic(isInstalled); PackedCounter _encodedLengths; bytes memory _dynamicData; diff --git a/packages/world/src/codegen/tables/WorldInitialized.sol b/packages/world/src/codegen/tables/WorldInitialized.sol deleted file mode 100644 index 1ebd9e9c32..0000000000 --- a/packages/world/src/codegen/tables/WorldInitialized.sol +++ /dev/null @@ -1,230 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.21; - -/* 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 { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol"; -import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; -import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; - -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("WorldInitialized"))) -); -ResourceId constant WorldInitializedTableId = _tableId; - -FieldLayout constant _fieldLayout = FieldLayout.wrap( - 0x0001010001000000000000000000000000000000000000000000000000000000 -); - -library WorldInitialized { - /** - * @notice Get the table values' field layout. - * @return _fieldLayout The field layout for the table. - */ - function getFieldLayout() internal pure returns (FieldLayout) { - return _fieldLayout; - } - - /** - * @notice Get the table's key schema. - * @return _keySchema The key schema for the table. - */ - function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _keySchema = new SchemaType[](0); - - return SchemaLib.encode(_keySchema); - } - - /** - * @notice Get the table's value schema. - * @return _valueSchema The value schema for the table. - */ - function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _valueSchema = new SchemaType[](1); - _valueSchema[0] = SchemaType.BOOL; - - return SchemaLib.encode(_valueSchema); - } - - /** - * @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] = "isInitialized"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); - } - - /** - * @notice Get isInitialized. - */ - function getIsInitialized() internal view returns (bool isInitialized) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (_toBool(uint8(bytes1(_blob)))); - } - - /** - * @notice Get isInitialized. - */ - function _getIsInitialized() internal view returns (bool isInitialized) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (_toBool(uint8(bytes1(_blob)))); - } - - /** - * @notice Get isInitialized. - */ - function get() internal view returns (bool isInitialized) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (_toBool(uint8(bytes1(_blob)))); - } - - /** - * @notice Get isInitialized. - */ - function _get() internal view returns (bool isInitialized) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (_toBool(uint8(bytes1(_blob)))); - } - - /** - * @notice Set isInitialized. - */ - function setIsInitialized(bool isInitialized) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInitialized)), _fieldLayout); - } - - /** - * @notice Set isInitialized. - */ - function _setIsInitialized(bool isInitialized) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInitialized)), _fieldLayout); - } - - /** - * @notice Set isInitialized. - */ - function set(bool isInitialized) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInitialized)), _fieldLayout); - } - - /** - * @notice Set isInitialized. - */ - function _set(bool isInitialized) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((isInitialized)), _fieldLayout); - } - - /** - * @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 static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(bool isInitialized) internal pure returns (bytes memory) { - return abi.encodePacked(isInitialized); - } - - /** - * @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(bool isInitialized) internal pure returns (bytes memory, PackedCounter, bytes memory) { - bytes memory _staticData = encodeStatic(isInitialized); - - PackedCounter _encodedLengths; - bytes memory _dynamicData; - - 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; - } -} - -/** - * @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 - } -}