// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { SmartGateSystem } from "../../systems/smart-gate/SmartGateSystem.sol"; import { CreateAndAnchorParams } from "../../systems/deployable/types.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.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 { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; type SmartGateSystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "SmartGateSystem" })) SmartGateSystemType constant smartGateSystem = SmartGateSystemType.wrap( 0x737965766566726f6e74696572000000536d6172744761746553797374656d00 ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title SmartGateSystemLib * @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 SmartGateSystemLib { error SmartGateSystemLib_CallingFromRootSystem(); error SmartGate_UndefinedClassId(); error SmartGate_NotConfigured(uint256 smartObjectId); error SmartGate_GateAlreadyLinked(uint256 sourceGateId, uint256 destinationGateId); error SmartGate_GateNotLinked(uint256 sourceGateId, uint256 destinationGateId); error SmartGate_NotWithtinRange(uint256 sourceGateId, uint256 destinationGateId); error SmartGate_SameSourceAndDestination(uint256 sourceGateId, uint256 destinationGateId); error SmartGate_GatesNotOnline(uint256 sourceGateId, uint256 destinationGateId); error SmartGate_GateNotOnline(uint256 smartObjectId); function createAndAnchorGate( SmartGateSystemType self, CreateAndAnchorParams memory params, uint256 maxDistance, uint256 networkNodeId ) internal { return CallWrapper(self.toResourceId(), address(0)).createAndAnchorGate(params, maxDistance, networkNodeId); } function linkGates(SmartGateSystemType self, uint256 sourceGateId, uint256 destinationGateId) internal { return CallWrapper(self.toResourceId(), address(0)).linkGates(sourceGateId, destinationGateId); } function unlinkGates(SmartGateSystemType self, uint256 sourceGateId, uint256 destinationGateId) internal { return CallWrapper(self.toResourceId(), address(0)).unlinkGates(sourceGateId, destinationGateId); } function configureGate(SmartGateSystemType self, uint256 smartObjectId, ResourceId systemId) internal { return CallWrapper(self.toResourceId(), address(0)).configureGate(smartObjectId, systemId); } function canJump( SmartGateSystemType self, uint256 characterId, uint256 sourceGateId, uint256 destinationGateId ) internal returns (bool) { return CallWrapper(self.toResourceId(), address(0)).canJump(characterId, sourceGateId, destinationGateId); } function areGatesOnline( SmartGateSystemType self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { return CallWrapper(self.toResourceId(), address(0)).areGatesOnline(sourceGateId, destinationGateId); } function isGateLinked( SmartGateSystemType self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { return CallWrapper(self.toResourceId(), address(0)).isGateLinked(sourceGateId, destinationGateId); } function isAnyGateLinked( SmartGateSystemType self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { return CallWrapper(self.toResourceId(), address(0)).isAnyGateLinked(sourceGateId, destinationGateId); } function isWithinRange( SmartGateSystemType self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { return CallWrapper(self.toResourceId(), address(0)).isWithinRange(sourceGateId, destinationGateId); } function createAndAnchorGate( CallWrapper memory self, CreateAndAnchorParams memory params, uint256 maxDistance, uint256 networkNodeId ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartGateSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _createAndAnchorGate_CreateAndAnchorParams_uint256_uint256.createAndAnchorGate, (params, maxDistance, networkNodeId) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function linkGates(CallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartGateSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_linkGates_uint256_uint256.linkGates, (sourceGateId, destinationGateId)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function unlinkGates(CallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartGateSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _unlinkGates_uint256_uint256.unlinkGates, (sourceGateId, destinationGateId) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function configureGate(CallWrapper memory self, uint256 smartObjectId, ResourceId systemId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartGateSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _configureGate_uint256_ResourceId.configureGate, (smartObjectId, systemId) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function canJump( CallWrapper memory self, uint256 characterId, uint256 sourceGateId, uint256 destinationGateId ) internal returns (bool) { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartGateSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _canJump_uint256_uint256_uint256.canJump, (characterId, sourceGateId, destinationGateId) ); bytes memory result = self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); return abi.decode(result, (bool)); } function areGatesOnline( CallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartGateSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _areGatesOnline_uint256_uint256.areGatesOnline, (sourceGateId, destinationGateId) ); 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, (bool)); } function isGateLinked( CallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartGateSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _isGateLinked_uint256_uint256.isGateLinked, (sourceGateId, destinationGateId) ); 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, (bool)); } function isAnyGateLinked( CallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartGateSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _isAnyGateLinked_uint256_uint256.isAnyGateLinked, (sourceGateId, destinationGateId) ); 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, (bool)); } function isWithinRange( CallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartGateSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _isWithinRange_uint256_uint256.isWithinRange, (sourceGateId, destinationGateId) ); 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, (bool)); } function createAndAnchorGate( RootCallWrapper memory self, CreateAndAnchorParams memory params, uint256 maxDistance, uint256 networkNodeId ) internal { bytes memory systemCall = abi.encodeCall( _createAndAnchorGate_CreateAndAnchorParams_uint256_uint256.createAndAnchorGate, (params, maxDistance, networkNodeId) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function linkGates(RootCallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId) internal { bytes memory systemCall = abi.encodeCall(_linkGates_uint256_uint256.linkGates, (sourceGateId, destinationGateId)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function unlinkGates(RootCallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId) internal { bytes memory systemCall = abi.encodeCall( _unlinkGates_uint256_uint256.unlinkGates, (sourceGateId, destinationGateId) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function configureGate(RootCallWrapper memory self, uint256 smartObjectId, ResourceId systemId) internal { bytes memory systemCall = abi.encodeCall( _configureGate_uint256_ResourceId.configureGate, (smartObjectId, systemId) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function canJump( RootCallWrapper memory self, uint256 characterId, uint256 sourceGateId, uint256 destinationGateId ) internal returns (bool) { bytes memory systemCall = abi.encodeCall( _canJump_uint256_uint256_uint256.canJump, (characterId, sourceGateId, destinationGateId) ); bytes memory result = SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); return abi.decode(result, (bool)); } function areGatesOnline( RootCallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { bytes memory systemCall = abi.encodeCall( _areGatesOnline_uint256_uint256.areGatesOnline, (sourceGateId, destinationGateId) ); bytes memory result = SystemCall.staticcallOrRevert(self.from, self.systemId, systemCall); return abi.decode(result, (bool)); } function isGateLinked( RootCallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { bytes memory systemCall = abi.encodeCall( _isGateLinked_uint256_uint256.isGateLinked, (sourceGateId, destinationGateId) ); bytes memory result = SystemCall.staticcallOrRevert(self.from, self.systemId, systemCall); return abi.decode(result, (bool)); } function isAnyGateLinked( RootCallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { bytes memory systemCall = abi.encodeCall( _isAnyGateLinked_uint256_uint256.isAnyGateLinked, (sourceGateId, destinationGateId) ); bytes memory result = SystemCall.staticcallOrRevert(self.from, self.systemId, systemCall); return abi.decode(result, (bool)); } function isWithinRange( RootCallWrapper memory self, uint256 sourceGateId, uint256 destinationGateId ) internal view returns (bool) { bytes memory systemCall = abi.encodeCall( _isWithinRange_uint256_uint256.isWithinRange, (sourceGateId, destinationGateId) ); bytes memory result = SystemCall.staticcallOrRevert(self.from, self.systemId, systemCall); return abi.decode(result, (bool)); } function callFrom(SmartGateSystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(SmartGateSystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom(SmartGateSystemType self, address from) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(SmartGateSystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(SmartGateSystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (SmartGateSystemType) { return SmartGateSystemType.wrap(resourceId.unwrap()); } function getAddress(SmartGateSystemType 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 _createAndAnchorGate_CreateAndAnchorParams_uint256_uint256 { function createAndAnchorGate( CreateAndAnchorParams memory params, uint256 maxDistance, uint256 networkNodeId ) external; } interface _linkGates_uint256_uint256 { function linkGates(uint256 sourceGateId, uint256 destinationGateId) external; } interface _unlinkGates_uint256_uint256 { function unlinkGates(uint256 sourceGateId, uint256 destinationGateId) external; } interface _configureGate_uint256_ResourceId { function configureGate(uint256 smartObjectId, ResourceId systemId) external; } interface _canJump_uint256_uint256_uint256 { function canJump(uint256 characterId, uint256 sourceGateId, uint256 destinationGateId) external; } interface _areGatesOnline_uint256_uint256 { function areGatesOnline(uint256 sourceGateId, uint256 destinationGateId) external; } interface _isGateLinked_uint256_uint256 { function isGateLinked(uint256 sourceGateId, uint256 destinationGateId) external; } interface _isAnyGateLinked_uint256_uint256 { function isAnyGateLinked(uint256 sourceGateId, uint256 destinationGateId) external; } interface _isWithinRange_uint256_uint256 { function isWithinRange(uint256 sourceGateId, uint256 destinationGateId) external; } using SmartGateSystemLib for SmartGateSystemType global; using SmartGateSystemLib for CallWrapper global; using SmartGateSystemLib for RootCallWrapper global;