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 |
|
#6 in #anchor
279 downloads per month
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