@latticexyz/cli | @latticexyz/common | @latticexyz/config | @latticexyz/store |
---|---|---|---|
major |
major |
major |
major |
-
ResourceSelector
is replaced withResourceId
,ResourceIdLib
,ResourceIdInstance
,WorldResourceIdLib
andWorldResourceIdInstance
.Previously a "resource selector" was a
bytes32
value with the first 16 bytes reserved for the resource's namespace, and the last 16 bytes reserved for the resource's name. Now a "resource ID" is abytes32
value with the first 2 bytes reserved for the resource type, the next 14 bytes reserved for the resource's namespace, and the last 16 bytes reserved for the resource's name.Previously
ResouceSelector
was a library and the resource selector type was a plainbytes32
. NowResourceId
is a user type, and the functionality is implemented in theResourceIdInstance
(for type) andWorldResourceIdInstance
(for namespace and name) libraries. We split the logic into two libraries, becauseStore
now also usesResourceId
and needs to be aware of resource types, but not of namespaces/names.- import { ResourceSelector } from "@latticexyz/world/src/ResourceSelector.sol"; + import { ResourceId, ResourceIdInstance } from "@latticexyz/store/src/ResourceId.sol"; + import { WorldResourceIdLib, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol"; + import { RESOURCE_SYSTEM } from "@latticexyz/world/src/worldResourceTypes.sol"; - bytes32 systemId = ResourceSelector.from("namespace", "name"); + ResourceId systemId = WorldResourceIdLib.encode(RESOURCE_SYSTEM, "namespace", "name"); - using ResourceSelector for bytes32; + using WorldResourceIdInstance for ResourceId; + using ResourceIdInstance for ResourceId; systemId.getName(); systemId.getNamespace(); + systemId.getType();
-
All
Store
andWorld
methods now use theResourceId
type fortableId
,systemId
,moduleId
andnamespaceId
. All mentions ofresourceSelector
were renamed toresourceId
or the more specific type (e.g.tableId
,systemId
)import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; IStore { function setRecord( - bytes32 tableId, + ResourceId tableId, bytes32[] calldata keyTuple, bytes calldata staticData, PackedCounter encodedLengths, bytes calldata dynamicData, FieldLayout fieldLayout ) external; // Same for all other methods }
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; IBaseWorld { function callFrom( address delegator, - bytes32 resourceSelector, + ResourceId systemId, bytes memory callData ) external payable returns (bytes memory); // Same for all other methods }