LinkedResources
Last updated
Last updated
The linkedresources module enables accounts to attach, update, and remove arbitrary binary data ("linked resources") to an on‑chain document. Each resource is versioned, signed by an authorised DID verification method, and subject to configurable size and length limits. In addition to resource management, the module provides parameter governance, rich gRPC/CLI queries, emitted events, a simulation framework, and CLI tooling.
The linkedresources module provides the following capabilities:
Create Linked Resource: Attach a new binary payload to an existing DID. Each resource is uniquely identified by(did, id)
, typed via a string (type
), versioned (version ≥ 1
), and cryptographically signed by a DIDcapabilityInvocation
key.
Update Linked Resource: Submit a new version of an existing resource. The version
must increment by exactly 1,
with a valid signature and respecting size/type limits. Only the latest version is stored on‑chain.
Delete Linked Resource: Mark a resource as deleted. The on‑chain record remains for auditability; its data
is
zeroed, and its status changes to DELETED
.
Parameter Governance: Network governance (via a designated authority) can update module parameters that govern data size and identifier length limits.
Rich Queries: gRPC and gRPC‑Gateway endpoints expose queries for parameters, single resources, all resources for a DID, or resources filtered by ID prefix.
Events: Typed events are emitted for create, update, delete, and parameter updates.
CLI Tools: emped
commands for transactions and queries.
Simulation: Weighted simulation operations for create, update, and delete flows.
Represents the client‑facing payload and metadata for a linked resource.
Internal storage format, capturing raw data, version, timestamps, and status (ACTIVE
or DELETED
).
Returned by query endpoints, combining the core LinkedResource
with its creation/update timestamps and status.
All tx messages are defined under empe.linkedresources.Msg
.
Validation: sender
is valid, resource.Validate()
passes (non‑empty fields, version ≥1, allowed characters),
sizes within params, DID exists and is ACTIVE
, signature authorised and valid, resource not already present.
Effects: Charges createLinkedResource_<tier>
fee, stores as LinkedResourceEntity(status=ACTIVE)
, emitsEventCreateLinkedResource
.
Validation: Same checks as create, plus existing resource must be ACTIVE
andresource.version = stored.version + 1
, signature valid.
Effects: Charges updateLinkedResource_<tier>
fee, updates LinkedResourceEntity
(overwriting data, updating
timestamps, keeping status=ACTIVE
), emits EventUpdateLinkedResource
.
Validation: Same identity checks, existing resource ACTIVE
, payload.version
matches stored version, signature
valid.
Effects: Charges deleteLinkedResource_<tier>
fee, stores entity with zeroed data
, status=DELETED
, updated
timestamp, emits EventDeleteLinkedResource
.
Validation: authority
matches module authority, params.Validate()
passes (non‑zero limits).
Effects: Persists new params, emits EventUpdateParams
.
All queries under empe.linkedresources.Query
.
CLI: emped query linkedresources params
Fetch by DID and ID.
CLI: emped query linkedresources resource <did> <id>
List all resources for a DID (paginated).
CLI: emped query linkedresources resources <did> [--limit N --page P]
Filter resources whose id
starts with a given prefix. Supports pagination.
CLI: emped query linkedresources resources <did> --prefix <prefix> [--limit N --page P]
EventCreateLinkedResource
sender
, did
, resource_id
, resource_type
, resource_size
EventUpdateLinkedResource
sender
, did
, resource_id
, version
, resource_type
, resource_size
EventDeleteLinkedResource
sender
, did
, resource_id
EventUpdateParams
authority
, params
(JSON‑encoded)
Params
define module limits and defaults:
ResourceDataMaxSize
(int64): max bytes for data
(default 64 KiB)
ResourceIdMaxLength
(int64): max characters for id
(default 64)
ResourceTypeMaxLength
(int64): max characters for type
(default 32)
Modifiable via the MsgUpdateParams
transaction.
The GenesisState
includes:
params
: initial Params
values.
linked_resources
: a repeated list of LinkedResourceRecord
entries (with resource payload, timestamps, and status).
On InitGenesis
, all entries are loaded into state with StoreLinkedResource
.
Weighted operations registered for fuzz testing:
SimulateMsgCreateLinkedResource
(weight: 200)
SimulateMsgUpdateLinkedResource
(weight: 100)
SimulateMsgDeleteLinkedResource
(weight: 50)
These simulate DID document creation, resource operations, and fee handling.
Storage Layout: Keys stored as <did>||0x00||<id>
under a module prefix for per‑DID iteration.
Internal Types: LinkedResourceEntity
for KV storage; LinkedResourceRecord
for queries.
Fee Model: Fees named createLinkedResource_<tier>
, updateLinkedResource_<tier>
, anddeleteLinkedResource_<tier>
based on DID tier.
DID Integration: Signatures must be from a capabilityInvocation
method in the DID document.
Validation: Resources validated for format (id/type
pattern) and size limits from Params
.
Errors: Defined errors include ErrResourceTooLarge
, ErrInvalidSignature
, ErrLinkedResourceNotFound
, etc.