Skip to content

Commit

Permalink
fix: ensure proper documentation for the Resource enum (n-01) (#2640)
Browse files Browse the repository at this point in the history
* fix: ensure proper documentation for the Resource enum

* fix: fmt
  • Loading branch information
glihm authored Nov 9, 2024
1 parent 9076795 commit dbe04ad
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions crates/dojo/core/src/world/resource.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,28 @@ use starknet::ContractAddress;
/// of re-computing the descriptor each time, which involves several poseidon hash
/// operations.
///
/// Namespaced resources: Those resources are scoped by a namespace, which
/// defines a logical separation of resources. Namespaced resources are Model, Event and Contract.
///
/// - World: The world itself, identified by the selector 0.
///
/// - Namespace: ByteArray
/// Namespace is a unique resource type, identified by a `ByteArray`, to scope models, events and
/// contracts.
/// The poseidon hash of the serialized `ByteArray` is used as the namespace hash.
///
/// - Model: (ContractAddress, NamespaceHash)
/// A model defines data that can be stored in the world's storage.
///
/// - Event: (ContractAddress, NamespaceHash)
/// An event is never stored in the world's storage, but it's emitted by the world to be consumed by
/// off-chain components.
///
/// - Contract: (ContractAddress, NamespaceHash)
/// - Namespace: ByteArray
/// - World: The world itself, identified by the selector 0.
/// - Unregistered: The unregistered state.
/// A contract defines user logic to interact with the world's data (models) and to emit events.
///
/// - Unregistered: The unregistered state, required to ensure the security of the world
/// to not have operations done on non-existent resources.
#[derive(Drop, starknet::Store, Serde, Default, Debug)]
pub enum Resource {
Model: (ContractAddress, felt252),
Expand All @@ -26,6 +43,7 @@ pub enum Resource {

#[generate_trait]
pub impl ResourceIsNoneImpl of ResourceIsNoneTrait {
/// Returns true if the resource is unregistered, false otherwise.
fn is_unregistered(self: @Resource) -> bool {
match self {
Resource::Unregistered => true,
Expand Down

0 comments on commit dbe04ad

Please sign in to comment.