#anchor #run-time #events #service #indexer #syndica #dyndexer

syndica-dyndexer-runtime

Support library for code to run on Syndica's indexer service

4 releases (breaking)

0.4.0 Aug 6, 2024
0.3.0 Jul 19, 2024
0.2.0 Jul 9, 2024
0.1.1 Jun 24, 2024
0.1.0 Jun 24, 2024

#7 in #anchor

Download history 192/week @ 2024-06-21 14/week @ 2024-06-28 104/week @ 2024-07-05 16/week @ 2024-07-12 114/week @ 2024-07-19 3/week @ 2024-07-26 106/week @ 2024-08-02 9/week @ 2024-08-09

115 downloads per month

Apache-2.0

43KB
535 lines

Syndica Dyndexer Runtime

This crate provides access to the runtime facilities offered to code running on the Syndica Dyndexer service.

Example

A simple example is to use the anchor feature which includes a parser for Anchor events, and can record any anchor events as outputs:

use std::sync::OnceLock;

use syndica_dyndexer_runtime::{processor, record_output, Event, Output};
use syndica_dyndexer_runtime::anchor::AnchorIdl;

const PROGRAM_ADDR: &str = "...";
const PROGRAM_IDL: &[u8] = include_bytes!("path/to/program-idl.json");
static IDL: OnceLock<AnchorIdl> = OnceLock::new();

#[processor]
fn process(event: Event) {
    let idl = IDL.get_or_init(|| AnchorIdl::deserialize(PROGRAM_ADDR, PROGRAM_IDL));

    if let Event::Transaction(transaction) = event {
        let events = idl.parse_events(&transaction);
        let signature = transaction.signature;

        for (idx, event) in events.into_iter().enumerate() {
            record_output(&Output::Object {
                uid: format!("{signature}:{idx}"),
                key: None,
                value: &event.data,
            });
        }
    }
}

Dependencies

~1.1–2.5MB
~52K SLoC