WorldResourceId.sol constants
Git Source (opens in a new tab)
NAMESPACE_BYTES
uint256 constant NAMESPACE_BYTES = 14;
NAMESPACE_BITS
uint256 constant NAMESPACE_BITS = 14 * 8;
NAME_BITS
uint256 constant NAME_BITS = 16 * 8;
NAMESPACE_MASK
bytes32 constant NAMESPACE_MASK = bytes32(~bytes14("")) >> (TYPE_BITS);
WorldResourceIdInstance
Git Source (opens in a new tab)
A library for handling instances of World Resource IDs.
Functions
getNamespace
Get the namespace from a resource ID.
function getNamespace(ResourceId resourceId) internal pure returns (bytes14);
Parameters
Name | Type | Description |
---|---|---|
resourceId | ResourceId | The resource ID. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes14 | A 14-byte namespace. |
getNamespaceId
Get the namespace ID from a resource ID.
function getNamespaceId(ResourceId resourceId) internal pure returns (ResourceId);
Parameters
Name | Type | Description |
---|---|---|
resourceId | ResourceId | The resource ID. |
Returns
Name | Type | Description |
---|---|---|
<none> | ResourceId | A 32-byte namespace resource ID. |
getName
Get the name from a resource ID.
function getName(ResourceId resourceId) internal pure returns (bytes16);
Parameters
Name | Type | Description |
---|---|---|
resourceId | ResourceId | The resource ID. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes16 | A 16-byte name. |
toString
Convert a resource ID to a string.
function toString(ResourceId resourceId) internal pure returns (string memory);
Parameters
Name | Type | Description |
---|---|---|
resourceId | ResourceId | The resource ID. |
Returns
Name | Type | Description |
---|---|---|
<none> | string | A string representation of the resource ID. |
WorldResourceIdLib
Git Source (opens in a new tab)
A library for handling World Resource ID encoding and decoding.
Functions
encode
Encode a resource ID.
function encode(bytes2 typeId, bytes14 namespace, bytes16 name) internal pure returns (ResourceId);
Parameters
Name | Type | Description |
---|---|---|
typeId | bytes2 | The resource type ID. |
namespace | bytes14 | The namespace of the resource. |
name | bytes16 | The name of the resource. |
Returns
Name | Type | Description |
---|---|---|
<none> | ResourceId | A 32-byte resource ID. |
encodeNamespace
Encode a namespace to resource ID.
function encodeNamespace(bytes14 namespace) internal pure returns (ResourceId);
Parameters
Name | Type | Description |
---|---|---|
namespace | bytes14 | The namespace to be encoded. |
Returns
Name | Type | Description |
---|---|---|
<none> | ResourceId | A 32-byte resource ID with the namespace encoded. |
toTrimmedString
Convert a padded string to a trimmed string.
function toTrimmedString(bytes16 paddedString) internal pure returns (string memory);
Parameters
Name | Type | Description |
---|---|---|
paddedString | bytes16 | The input string with potential padding. |
Returns
Name | Type | Description |
---|---|---|
<none> | string | A string without trailing null ASCII characters. |
worldResourceTypes.sol constants
Git Source (opens in a new tab)
RESOURCE_NAMESPACE
World Resource Types
Constants related to World Resource Types and Masks.
These constants are used to represent various resource types within the system.
bytes2 constant RESOURCE_NAMESPACE = "ns";
RESOURCE_SYSTEM
bytes2 constant RESOURCE_SYSTEM = "sy";
MASK_RESOURCE_NAMESPACE
bytes32 constant MASK_RESOURCE_NAMESPACE = bytes32(RESOURCE_NAMESPACE);