// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { EntityRecordSystem } from "../../systems/entity-record/EntityRecordSystem.sol"; import { EntityRecordParams, EntityMetadataParams } 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 EntityRecordSystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "EntityRecordSyst" })) EntityRecordSystemType constant entityRecordSystem = EntityRecordSystemType.wrap( 0x737965766566726f6e74696572000000456e746974795265636f726453797374 ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title EntityRecordSystemLib * @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 EntityRecordSystemLib { error EntityRecordSystemLib_CallingFromRootSystem(); function createRecord( EntityRecordSystemType self, uint256 smartObjectId, EntityRecordParams memory entityRecordParams ) internal { return CallWrapper(self.toResourceId(), address(0)).createRecord(smartObjectId, entityRecordParams); } function createMetadata( EntityRecordSystemType self, uint256 smartObjectId, EntityMetadataParams memory entityRecordMetadata ) internal { return CallWrapper(self.toResourceId(), address(0)).createMetadata(smartObjectId, entityRecordMetadata); } function setName(EntityRecordSystemType self, uint256 smartObjectId, string memory name) internal { return CallWrapper(self.toResourceId(), address(0)).setName(smartObjectId, name); } function setDappURL(EntityRecordSystemType self, uint256 smartObjectId, string memory dappURL) internal { return CallWrapper(self.toResourceId(), address(0)).setDappURL(smartObjectId, dappURL); } function setDescription(EntityRecordSystemType self, uint256 smartObjectId, string memory description) internal { return CallWrapper(self.toResourceId(), address(0)).setDescription(smartObjectId, description); } function createRecord( CallWrapper memory self, uint256 smartObjectId, EntityRecordParams memory entityRecordParams ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert EntityRecordSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _createRecord_uint256_EntityRecordParams.createRecord, (smartObjectId, entityRecordParams) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function createMetadata( CallWrapper memory self, uint256 smartObjectId, EntityMetadataParams memory entityRecordMetadata ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert EntityRecordSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _createMetadata_uint256_EntityMetadataParams.createMetadata, (smartObjectId, entityRecordMetadata) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function setName(CallWrapper memory self, uint256 smartObjectId, string memory name) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert EntityRecordSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_setName_uint256_string.setName, (smartObjectId, name)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function setDappURL(CallWrapper memory self, uint256 smartObjectId, string memory dappURL) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert EntityRecordSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_setDappURL_uint256_string.setDappURL, (smartObjectId, dappURL)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function setDescription(CallWrapper memory self, uint256 smartObjectId, string memory description) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert EntityRecordSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _setDescription_uint256_string.setDescription, (smartObjectId, description) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function createRecord( RootCallWrapper memory self, uint256 smartObjectId, EntityRecordParams memory entityRecordParams ) internal { bytes memory systemCall = abi.encodeCall( _createRecord_uint256_EntityRecordParams.createRecord, (smartObjectId, entityRecordParams) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function createMetadata( RootCallWrapper memory self, uint256 smartObjectId, EntityMetadataParams memory entityRecordMetadata ) internal { bytes memory systemCall = abi.encodeCall( _createMetadata_uint256_EntityMetadataParams.createMetadata, (smartObjectId, entityRecordMetadata) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function setName(RootCallWrapper memory self, uint256 smartObjectId, string memory name) internal { bytes memory systemCall = abi.encodeCall(_setName_uint256_string.setName, (smartObjectId, name)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function setDappURL(RootCallWrapper memory self, uint256 smartObjectId, string memory dappURL) internal { bytes memory systemCall = abi.encodeCall(_setDappURL_uint256_string.setDappURL, (smartObjectId, dappURL)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function setDescription(RootCallWrapper memory self, uint256 smartObjectId, string memory description) internal { bytes memory systemCall = abi.encodeCall( _setDescription_uint256_string.setDescription, (smartObjectId, description) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function callFrom(EntityRecordSystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(EntityRecordSystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom(EntityRecordSystemType self, address from) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(EntityRecordSystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(EntityRecordSystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (EntityRecordSystemType) { return EntityRecordSystemType.wrap(resourceId.unwrap()); } function getAddress(EntityRecordSystemType 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 _createRecord_uint256_EntityRecordParams { function createRecord(uint256 smartObjectId, EntityRecordParams memory entityRecordParams) external; } interface _createMetadata_uint256_EntityMetadataParams { function createMetadata(uint256 smartObjectId, EntityMetadataParams memory entityRecordMetadata) external; } interface _setName_uint256_string { function setName(uint256 smartObjectId, string memory name) external; } interface _setDappURL_uint256_string { function setDappURL(uint256 smartObjectId, string memory dappURL) external; } interface _setDescription_uint256_string { function setDescription(uint256 smartObjectId, string memory description) external; } using EntityRecordSystemLib for EntityRecordSystemType global; using EntityRecordSystemLib for CallWrapper global; using EntityRecordSystemLib for RootCallWrapper global;