// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { InventoryInteractSystem } from "../../systems/inventory/InventoryInteractSystem.sol"; import { InventoryItemParams } from "../../systems/inventory/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 InventoryInteractSystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "InventoryInterac" })) InventoryInteractSystemType constant inventoryInteractSystem = InventoryInteractSystemType.wrap( 0x737965766566726f6e74696572000000496e76656e746f7279496e7465726163 ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title InventoryInteractSystemLib * @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 InventoryInteractSystemLib { error InventoryInteractSystemLib_CallingFromRootSystem(); function transferToInventory( InventoryInteractSystemType self, uint256 smartObjectId, uint256 toObjectId, InventoryItemParams[] memory items ) internal { return CallWrapper(self.toResourceId(), address(0)).transferToInventory(smartObjectId, toObjectId, items); } function setTransferToInventoryAccess( InventoryInteractSystemType self, uint256 smartObjectId, address accessAddress, bool isAllowed ) internal { return CallWrapper(self.toResourceId(), address(0)).setTransferToInventoryAccess( smartObjectId, accessAddress, isAllowed ); } function transferToInventory( CallWrapper memory self, uint256 smartObjectId, uint256 toObjectId, InventoryItemParams[] memory items ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert InventoryInteractSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _transferToInventory_uint256_uint256_InventoryItemParamsArray.transferToInventory, (smartObjectId, toObjectId, items) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function setTransferToInventoryAccess( CallWrapper memory self, uint256 smartObjectId, address accessAddress, bool isAllowed ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert InventoryInteractSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _setTransferToInventoryAccess_uint256_address_bool.setTransferToInventoryAccess, (smartObjectId, accessAddress, isAllowed) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function transferToInventory( RootCallWrapper memory self, uint256 smartObjectId, uint256 toObjectId, InventoryItemParams[] memory items ) internal { bytes memory systemCall = abi.encodeCall( _transferToInventory_uint256_uint256_InventoryItemParamsArray.transferToInventory, (smartObjectId, toObjectId, items) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function setTransferToInventoryAccess( RootCallWrapper memory self, uint256 smartObjectId, address accessAddress, bool isAllowed ) internal { bytes memory systemCall = abi.encodeCall( _setTransferToInventoryAccess_uint256_address_bool.setTransferToInventoryAccess, (smartObjectId, accessAddress, isAllowed) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function callFrom(InventoryInteractSystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(InventoryInteractSystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom( InventoryInteractSystemType self, address from ) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(InventoryInteractSystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(InventoryInteractSystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (InventoryInteractSystemType) { return InventoryInteractSystemType.wrap(resourceId.unwrap()); } function getAddress(InventoryInteractSystemType 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 _transferToInventory_uint256_uint256_InventoryItemParamsArray { function transferToInventory(uint256 smartObjectId, uint256 toObjectId, InventoryItemParams[] memory items) external; } interface _setTransferToInventoryAccess_uint256_address_bool { function setTransferToInventoryAccess(uint256 smartObjectId, address accessAddress, bool isAllowed) external; } using InventoryInteractSystemLib for InventoryInteractSystemType global; using InventoryInteractSystemLib for CallWrapper global; using InventoryInteractSystemLib for RootCallWrapper global;