Actor operations
Actor field API
The Actor Field API provides operations for managing access to actor object fields, enabling controlled reading and writing of field data while maintaining state consistency and access control.
ACTOR_OPEN_FIELD
This opens a field on the current actor object for reading or writing.
It includes critical validations:
Actor-context validation
It ensures operation occurs within valid actor context.
if self.get_actor().actor_type() != ActorType::Method { return Err(RuntimeError::SystemError(SystemError::InvalidActorContext)); }Field-index validation
It validates the field index against the blueprint definition.
let num_fields = self.get_blueprint_interface().state.num_fields(); if field_index >= num_fields { return Err(RuntimeError::SystemError(SystemError::InvalidFieldIndex)); }Duplicate open prevention
It prevents opening already opened fields.
FIELD_ENTRY_READ
/ FIELD_ENTRY_WRITE
/ FIELD_ENTRY_CLOSE
These operations manage field access after opening:
The field operations perform the following validations and state management:
Handle validation
It verifies a handle corresponds to an opened field.
Access control
Read requires a field to be opened, write requires mutable access, and close releases a field lock.
State consistency
It maintains field open/close state tracking.
Actor information API
The Actor Information API provides methods to retrieve identity and contextual information about the currently executing actor, including its object ID, package address, and blueprint name.
ACTOR_GET_OBJECT_ID
/ ACTOR_GET_PACKAGE_ADDRESS
/ ACTOR_GET_BLUEPRINT_NAME
These methods provide identity information about the current actor:
These methods perform the following validations and access control checks:
Context validation
It ensures operations occur in valid actor context.
Actor event API
The Actor Event API enables actors to emit events during execution, providing a mechanism for tracking and logging important state changes or notifications with appropriate validation and size constraints.
ACTOR_EMIT_EVENT
This handles event emission from actors:
The event emission process includes the following validations and tracking:
Event-schema validation
It validates the event name and data format.
Size limits
It enforces size restrictions on event data.
Context tracking
It records the event in the system's event log with the current actor context.