// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { DeployableSystem } from "../../systems/deployable/DeployableSystem.sol"; import { State, CreateAndAnchorParams } from "../../systems/deployable/types.sol"; import { LocationData } from "../index.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 DeployableSystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "DeployableSystem" })) DeployableSystemType constant deployableSystem = DeployableSystemType.wrap( 0x737965766566726f6e746965720000004465706c6f7961626c6553797374656d ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title DeployableSystemLib * @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 DeployableSystemLib { error DeployableSystemLib_CallingFromRootSystem(); error Deployable_IncorrectState(uint256 smartObjectId, State currentState); error Deployable_InvalidObjectOwner(string message, address smartObjectOwner, uint256 smartObjectId); function createAndAnchor( DeployableSystemType self, CreateAndAnchorParams memory params, uint256 networkNodeId ) internal { return CallWrapper(self.toResourceId(), address(0)).createAndAnchor(params, networkNodeId); } function createDeployable(DeployableSystemType self, uint256 smartObjectId, address owner) internal { return CallWrapper(self.toResourceId(), address(0)).createDeployable(smartObjectId, owner); } function destroyDeployable(DeployableSystemType self, uint256 smartObjectId) internal { return CallWrapper(self.toResourceId(), address(0)).destroyDeployable(smartObjectId); } function bringOnline(DeployableSystemType self, uint256 smartObjectId) internal { return CallWrapper(self.toResourceId(), address(0)).bringOnline(smartObjectId); } function bringOffline(DeployableSystemType self, uint256 smartObjectId) internal { return CallWrapper(self.toResourceId(), address(0)).bringOffline(smartObjectId); } function anchor( DeployableSystemType self, uint256 smartObjectId, address owner, LocationData memory locationData ) internal { return CallWrapper(self.toResourceId(), address(0)).anchor(smartObjectId, owner, locationData); } function unanchor(DeployableSystemType self, uint256 smartObjectId) internal { return CallWrapper(self.toResourceId(), address(0)).unanchor(smartObjectId); } function getDeployableClassId(DeployableSystemType self) internal view returns (uint256) { return CallWrapper(self.toResourceId(), address(0)).getDeployableClassId(); } function _handleNodeOffline(DeployableSystemType self, uint256 networkNodeId) internal { return CallWrapper(self.toResourceId(), address(0))._handleNodeOffline(networkNodeId); } function createAndAnchor( CallWrapper memory self, CreateAndAnchorParams memory params, uint256 networkNodeId ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert DeployableSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _createAndAnchor_CreateAndAnchorParams_uint256.createAndAnchor, (params, networkNodeId) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function createDeployable(CallWrapper memory self, uint256 smartObjectId, address owner) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert DeployableSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _createDeployable_uint256_address.createDeployable, (smartObjectId, owner) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function destroyDeployable(CallWrapper memory self, uint256 smartObjectId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert DeployableSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_destroyDeployable_uint256.destroyDeployable, (smartObjectId)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function bringOnline(CallWrapper memory self, uint256 smartObjectId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert DeployableSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_bringOnline_uint256.bringOnline, (smartObjectId)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function bringOffline(CallWrapper memory self, uint256 smartObjectId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert DeployableSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_bringOffline_uint256.bringOffline, (smartObjectId)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function anchor( CallWrapper memory self, uint256 smartObjectId, address owner, LocationData memory locationData ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert DeployableSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _anchor_uint256_address_LocationData.anchor, (smartObjectId, owner, locationData) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function unanchor(CallWrapper memory self, uint256 smartObjectId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert DeployableSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_unanchor_uint256.unanchor, (smartObjectId)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function getDeployableClassId(CallWrapper memory self) internal view returns (uint256) { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert DeployableSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_getDeployableClassId.getDeployableClassId, ()); bytes memory worldCall = self.from == address(0) ? abi.encodeCall(IWorldCall.call, (self.systemId, systemCall)) : abi.encodeCall(IWorldCall.callFrom, (self.from, self.systemId, systemCall)); (bool success, bytes memory returnData) = address(_world()).staticcall(worldCall); if (!success) revertWithBytes(returnData); bytes memory result = abi.decode(returnData, (bytes)); return abi.decode(result, (uint256)); } function _handleNodeOffline(CallWrapper memory self, uint256 networkNodeId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert DeployableSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(__handleNodeOffline_uint256._handleNodeOffline, (networkNodeId)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function createAndAnchor( RootCallWrapper memory self, CreateAndAnchorParams memory params, uint256 networkNodeId ) internal { bytes memory systemCall = abi.encodeCall( _createAndAnchor_CreateAndAnchorParams_uint256.createAndAnchor, (params, networkNodeId) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function createDeployable(RootCallWrapper memory self, uint256 smartObjectId, address owner) internal { bytes memory systemCall = abi.encodeCall( _createDeployable_uint256_address.createDeployable, (smartObjectId, owner) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function destroyDeployable(RootCallWrapper memory self, uint256 smartObjectId) internal { bytes memory systemCall = abi.encodeCall(_destroyDeployable_uint256.destroyDeployable, (smartObjectId)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function bringOnline(RootCallWrapper memory self, uint256 smartObjectId) internal { bytes memory systemCall = abi.encodeCall(_bringOnline_uint256.bringOnline, (smartObjectId)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function bringOffline(RootCallWrapper memory self, uint256 smartObjectId) internal { bytes memory systemCall = abi.encodeCall(_bringOffline_uint256.bringOffline, (smartObjectId)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function anchor( RootCallWrapper memory self, uint256 smartObjectId, address owner, LocationData memory locationData ) internal { bytes memory systemCall = abi.encodeCall( _anchor_uint256_address_LocationData.anchor, (smartObjectId, owner, locationData) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function unanchor(RootCallWrapper memory self, uint256 smartObjectId) internal { bytes memory systemCall = abi.encodeCall(_unanchor_uint256.unanchor, (smartObjectId)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function getDeployableClassId(RootCallWrapper memory self) internal view returns (uint256) { bytes memory systemCall = abi.encodeCall(_getDeployableClassId.getDeployableClassId, ()); bytes memory result = SystemCall.staticcallOrRevert(self.from, self.systemId, systemCall); return abi.decode(result, (uint256)); } function _handleNodeOffline(RootCallWrapper memory self, uint256 networkNodeId) internal { bytes memory systemCall = abi.encodeCall(__handleNodeOffline_uint256._handleNodeOffline, (networkNodeId)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function callFrom(DeployableSystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(DeployableSystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom(DeployableSystemType self, address from) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(DeployableSystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(DeployableSystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (DeployableSystemType) { return DeployableSystemType.wrap(resourceId.unwrap()); } function getAddress(DeployableSystemType 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 _createAndAnchor_CreateAndAnchorParams_uint256 { function createAndAnchor(CreateAndAnchorParams memory params, uint256 networkNodeId) external; } interface _createDeployable_uint256_address { function createDeployable(uint256 smartObjectId, address owner) external; } interface _destroyDeployable_uint256 { function destroyDeployable(uint256 smartObjectId) external; } interface _bringOnline_uint256 { function bringOnline(uint256 smartObjectId) external; } interface _bringOffline_uint256 { function bringOffline(uint256 smartObjectId) external; } interface _anchor_uint256_address_LocationData { function anchor(uint256 smartObjectId, address owner, LocationData memory locationData) external; } interface _unanchor_uint256 { function unanchor(uint256 smartObjectId) external; } interface _getDeployableClassId { function getDeployableClassId() external; } interface __handleNodeOffline_uint256 { function _handleNodeOffline(uint256 networkNodeId) external; } using DeployableSystemLib for DeployableSystemType global; using DeployableSystemLib for CallWrapper global; using DeployableSystemLib for RootCallWrapper global;