#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

#6 in #anchor

Download history 11/week @ 2024-07-22 114/week @ 2024-08-05 1/week @ 2024-08-12 7/week @ 2024-09-16 11/week @ 2024-09-30

279 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.4MB
~50K SLoC