// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { InventoryOwnershipSystem } from "../../systems/ownership/InventoryOwnershipSystem.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 InventoryOwnershipSystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "InventoryOwnersh" })) InventoryOwnershipSystemType constant inventoryOwnershipSystem = InventoryOwnershipSystemType.wrap( 0x737965766566726f6e74696572000000496e76656e746f72794f776e65727368 ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title InventoryOwnershipSystemLib * @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 InventoryOwnershipSystemLib { error InventoryOwnershipSystemLib_CallingFromRootSystem(); error InventoryOwnership_Ephemeral_InsufficientQuantity( uint256 inventoryObjectId, address ephemeralOwner, uint256 itemObjectId, uint256 providedQuantity, uint256 availableQuantity ); error InventoryOwnership_InvalidQuantity(uint256 itemObjectId, uint256 providedQuantity, uint256 expectedQuantity); error InventoryOwnership_ZeroQuantity(uint256 itemObjectId); error InventoryOwnership_InsufficientQuantity( uint256 inventoryObjectId, uint256 itemObjectId, uint256 providedQuantity, uint256 availableQuantity ); error InventoryOwnership_InvalidInventory(uint256 itemObjectId, uint256 inventoryObjectId); error InventoryOwnership_NonexistentItemRecord(uint256 itemObjectId); error InventoryOwnership_NonexistentObject(uint256 objectId); error InventoryOwnership_InvalidOperation(string message); error InventoryOwnership_SingletonAlreadyAssigned(uint256 itemObjectId, uint256 currentInventoryObjectId); error InventoryOwnership_SingletonDirectlyOwned(uint256 itemObjectId, address directOwner); function assignItemToInventory( InventoryOwnershipSystemType self, uint256 inventoryObjectId, uint256 itemObjectId, uint256 quantity ) internal { return CallWrapper(self.toResourceId(), address(0)).assignItemToInventory(inventoryObjectId, itemObjectId, quantity); } function removeItemFromInventory( InventoryOwnershipSystemType self, uint256 inventoryObjectId, uint256 itemObjectId, uint256 quantity ) internal { return CallWrapper(self.toResourceId(), address(0)).removeItemFromInventory(inventoryObjectId, itemObjectId, quantity); } function assignItemToInventory( CallWrapper memory self, uint256 inventoryObjectId, uint256 itemObjectId, uint256 quantity ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert InventoryOwnershipSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _assignItemToInventory_uint256_uint256_uint256.assignItemToInventory, (inventoryObjectId, itemObjectId, quantity) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function removeItemFromInventory( CallWrapper memory self, uint256 inventoryObjectId, uint256 itemObjectId, uint256 quantity ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert InventoryOwnershipSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _removeItemFromInventory_uint256_uint256_uint256.removeItemFromInventory, (inventoryObjectId, itemObjectId, quantity) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function assignItemToInventory( RootCallWrapper memory self, uint256 inventoryObjectId, uint256 itemObjectId, uint256 quantity ) internal { bytes memory systemCall = abi.encodeCall( _assignItemToInventory_uint256_uint256_uint256.assignItemToInventory, (inventoryObjectId, itemObjectId, quantity) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function removeItemFromInventory( RootCallWrapper memory self, uint256 inventoryObjectId, uint256 itemObjectId, uint256 quantity ) internal { bytes memory systemCall = abi.encodeCall( _removeItemFromInventory_uint256_uint256_uint256.removeItemFromInventory, (inventoryObjectId, itemObjectId, quantity) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function callFrom(InventoryOwnershipSystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(InventoryOwnershipSystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom( InventoryOwnershipSystemType self, address from ) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(InventoryOwnershipSystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(InventoryOwnershipSystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (InventoryOwnershipSystemType) { return InventoryOwnershipSystemType.wrap(resourceId.unwrap()); } function getAddress(InventoryOwnershipSystemType 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 _assignItemToInventory_uint256_uint256_uint256 { function assignItemToInventory(uint256 inventoryObjectId, uint256 itemObjectId, uint256 quantity) external; } interface _removeItemFromInventory_uint256_uint256_uint256 { function removeItemFromInventory(uint256 inventoryObjectId, uint256 itemObjectId, uint256 quantity) external; } using InventoryOwnershipSystemLib for InventoryOwnershipSystemType global; using InventoryOwnershipSystemLib for CallWrapper global; using InventoryOwnershipSystemLib for RootCallWrapper global;