Module chaindexing::states

source ·
Expand description

Houses traits and structs for implementing states that can be indexed.

§States

Any struct that can be serialized and deserialized while implementing any state type, such as ContractState, ChainState, MultiChainState etc. is a valid Chaindexing State

§Example

use chaindexing::states::{ContractState, StateMigrations};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Nft {
    pub token_id: u32,
    pub owner_address: String,
}
impl ContractState for Nft {
    fn table_name() -> &'static str {
        "nfts"
    }
}
pub struct NftMigrations;
impl StateMigrations for NftMigrations {
    fn migrations(&self) -> &'static [&'static str] {
        &["CREATE TABLE IF NOT EXISTS nfts (
                token_id INTEGER NOT NULL,
                owner_address TEXT NOT NULL
            )"]
    }
}

Structs§

  • Represents a set of filters used for querying data.
  • Represents the fields to be updated in a state

Traits§

  • States derived from different contracts within a chain
  • States derived from a contract
  • States derived from different contracts across different chains N/B: Indexing MultiChainStates must be Order-Agnostic
  • Represents the idempotent database migrations required before indexing a state.