Crate casper_event_standard

Source
Expand description

The smart contract level events for Casper.

use casper_event_standard::Event;

// Turn a struct into an event.
#[derive(Event)]
struct Transfer {
   amount: U256,
   from: Key,
   to: Key
}

// Register event schemas.
fn init_events() {
    let schemas = Schemas::new()
        .with::<Transfer>();
    casper_event_standard::init(schemas);
}

// Emit event.
fn emit_transfer(transfer: Transfer) {
    casper_event_standard::emit(transfer);
}

Structs§

CLType2
A wrapper on top of CLType.
Schema
The information about a single event.
Schemas
The information about multiple events.

Constants§

CES_VERSION
The version of CES implemented in this library.
CES_VERSION_KEY
The key under which the ces version is stored.
EVENTS_DICT
The key under which the events are stored.
EVENTS_LENGTH
The key under which the events length is stored.
EVENTS_SCHEMA
The key under which the event schemas are stored.

Traits§

EventInstance
Helper trait, used for the schema generation.

Functions§

emit
Emits an event.
emit_bytes
Emits an event. Don’t convert to bytes.
init
Initializes events-releated named keys and stores Schemas.
try_full_name_from_bytes
Extracts full name of the event including event_ prefix.
validate_type
Make sure the type of a value is not CLType::Any.

Derive Macros§

Event
Macro that derives CLTyped, FromBytes, ToBytes and EventInstance.