// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { SmartStorageUnitSystem } from "../../systems/smart-storage-unit/SmartStorageUnitSystem.sol"; import { CreateAndAnchorParams } from "../../systems/deployable/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 SmartStorageUnitSystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "SmartStorageUnit" })) SmartStorageUnitSystemType constant smartStorageUnitSystem = SmartStorageUnitSystemType.wrap( 0x737965766566726f6e74696572000000536d61727453746f72616765556e6974 ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title SmartStorageUnitSystemLib * @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 SmartStorageUnitSystemLib { error SmartStorageUnitSystemLib_CallingFromRootSystem(); function createAndAnchorStorageUnit( SmartStorageUnitSystemType self, CreateAndAnchorParams memory params, uint256 capacity, uint256 ephemeralCapacity, uint256 networkNodeId ) internal { return CallWrapper(self.toResourceId(), address(0)).createAndAnchorStorageUnit( params, capacity, ephemeralCapacity, networkNodeId ); } function createAndAnchorStorageUnit( CallWrapper memory self, CreateAndAnchorParams memory params, uint256 capacity, uint256 ephemeralCapacity, uint256 networkNodeId ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartStorageUnitSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _createAndAnchorStorageUnit_CreateAndAnchorParams_uint256_uint256_uint256.createAndAnchorStorageUnit, (params, capacity, ephemeralCapacity, networkNodeId) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function createAndAnchorStorageUnit( RootCallWrapper memory self, CreateAndAnchorParams memory params, uint256 capacity, uint256 ephemeralCapacity, uint256 networkNodeId ) internal { bytes memory systemCall = abi.encodeCall( _createAndAnchorStorageUnit_CreateAndAnchorParams_uint256_uint256_uint256.createAndAnchorStorageUnit, (params, capacity, ephemeralCapacity, networkNodeId) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function callFrom(SmartStorageUnitSystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(SmartStorageUnitSystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom( SmartStorageUnitSystemType self, address from ) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(SmartStorageUnitSystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(SmartStorageUnitSystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (SmartStorageUnitSystemType) { return SmartStorageUnitSystemType.wrap(resourceId.unwrap()); } function getAddress(SmartStorageUnitSystemType 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 _createAndAnchorStorageUnit_CreateAndAnchorParams_uint256_uint256_uint256 { function createAndAnchorStorageUnit( CreateAndAnchorParams memory params, uint256 capacity, uint256 ephemeralCapacity, uint256 networkNodeId ) external; } using SmartStorageUnitSystemLib for SmartStorageUnitSystemType global; using SmartStorageUnitSystemLib for CallWrapper global; using SmartStorageUnitSystemLib for RootCallWrapper global;