// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { SmartAssemblySystem } from "../../systems/smart-assembly/SmartAssemblySystem.sol"; import { EntityRecordParams } from "../../systems/entity-record/types.sol"; import { revertWithBytes } from "@latticexyz/world/src/revertWithBytes.sol"; import { IWorldCall } from "@latticexyz/world/src/IWorldKernel.sol"; import { SystemCall } from "@latticexyz/world/src/SystemCall.sol"; import { Systems } from "@latticexyz/world/src/codegen/tables/Systems.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; type SmartAssemblySystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "SmartAssemblySys" })) SmartAssemblySystemType constant smartAssemblySystem = SmartAssemblySystemType.wrap( 0x737965766566726f6e74696572000000536d617274417373656d626c79537973 ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title SmartAssemblySystemLib * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) * @dev This library is automatically generated from the corresponding system contract. Do not edit manually. */ library SmartAssemblySystemLib { error SmartAssemblySystemLib_CallingFromRootSystem(); error SmartAssembly_TypeCannotBeEmpty(uint256 smartObjectId); error SmartAssembly_DoesNotExist(uint256 smartObjectId); error SmartAssembly_InvalidTypeId(uint256 smartObjectId, uint256 typeId); error SmartAssembly_InvalidTenantId(uint256 smartObjectId, bytes32 tenantId); error SmartAssembly_InvalidObjectId(uint256 smartObjectId); function createAssembly( SmartAssemblySystemType self, uint256 smartObjectId, string memory assemblyType, EntityRecordParams memory entityRecordParams ) internal { return CallWrapper(self.toResourceId(), address(0)).createAssembly(smartObjectId, assemblyType, entityRecordParams); } function setAssemblyType(SmartAssemblySystemType self, uint256 smartObjectId, string memory assemblyType) internal { return CallWrapper(self.toResourceId(), address(0)).setAssemblyType(smartObjectId, assemblyType); } function updateAssemblyType( SmartAssemblySystemType self, uint256 smartObjectId, string memory assemblyType ) internal { return CallWrapper(self.toResourceId(), address(0)).updateAssemblyType(smartObjectId, assemblyType); } function createAssembly( CallWrapper memory self, uint256 smartObjectId, string memory assemblyType, EntityRecordParams memory entityRecordParams ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartAssemblySystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _createAssembly_uint256_string_EntityRecordParams.createAssembly, (smartObjectId, assemblyType, entityRecordParams) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function setAssemblyType(CallWrapper memory self, uint256 smartObjectId, string memory assemblyType) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartAssemblySystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _setAssemblyType_uint256_string.setAssemblyType, (smartObjectId, assemblyType) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function updateAssemblyType(CallWrapper memory self, uint256 smartObjectId, string memory assemblyType) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartAssemblySystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _updateAssemblyType_uint256_string.updateAssemblyType, (smartObjectId, assemblyType) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function createAssembly( RootCallWrapper memory self, uint256 smartObjectId, string memory assemblyType, EntityRecordParams memory entityRecordParams ) internal { bytes memory systemCall = abi.encodeCall( _createAssembly_uint256_string_EntityRecordParams.createAssembly, (smartObjectId, assemblyType, entityRecordParams) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function setAssemblyType(RootCallWrapper memory self, uint256 smartObjectId, string memory assemblyType) internal { bytes memory systemCall = abi.encodeCall( _setAssemblyType_uint256_string.setAssemblyType, (smartObjectId, assemblyType) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function updateAssemblyType(RootCallWrapper memory self, uint256 smartObjectId, string memory assemblyType) internal { bytes memory systemCall = abi.encodeCall( _updateAssemblyType_uint256_string.updateAssemblyType, (smartObjectId, assemblyType) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function callFrom(SmartAssemblySystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(SmartAssemblySystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom(SmartAssemblySystemType self, address from) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(SmartAssemblySystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(SmartAssemblySystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (SmartAssemblySystemType) { return SmartAssemblySystemType.wrap(resourceId.unwrap()); } function getAddress(SmartAssemblySystemType self) internal view returns (address) { return Systems.getSystem(self.toResourceId()); } function _world() private view returns (IWorldCall) { return IWorldCall(StoreSwitch.getStoreAddress()); } } /** * System Function Interfaces * * We generate an interface for each system function, which is then used for encoding system calls. * This is necessary to handle function overloading correctly (which abi.encodeCall cannot). * * Each interface is uniquely named based on the function name and parameters to prevent collisions. */ interface _createAssembly_uint256_string_EntityRecordParams { function createAssembly( uint256 smartObjectId, string memory assemblyType, EntityRecordParams memory entityRecordParams ) external; } interface _setAssemblyType_uint256_string { function setAssemblyType(uint256 smartObjectId, string memory assemblyType) external; } interface _updateAssemblyType_uint256_string { function updateAssemblyType(uint256 smartObjectId, string memory assemblyType) external; } using SmartAssemblySystemLib for SmartAssemblySystemType global; using SmartAssemblySystemLib for CallWrapper global; using SmartAssemblySystemLib for RootCallWrapper global;