pub async fn spawn(
indexer_http_url: impl Into<String>,
initial_state: ContractRuntimeState,
start_offset: Option<BlockOffset>,
) -> Result<Watcher>Expand description
Spawn a long-lived driver that replays + tails the indexer’s
contractActions(address) stream and advances
initial_state in-place. Returns a Watcher carrying the
latest state and the driver’s join handle.
indexer_http_url is the same URL passed to
crate::providers::IndexerPublicDataProvider::new — the
helper derives the WebSocket form via
moonproof_indexer_client::graphql_ws_url.
start_offset = None replays from the beginning and then tails
live ticks. Callers that already have a state synced up to some
block pass Some(BlockOffset::Height(last_known_height + 1)) to
skip the historic replay.
§Errors
- The initial subscription open errors (bad URL, server down) are
surfaced as
ContractRuntimeError::Indexerfrom this function. - Errors observed while the stream is running are propagated
through
Watcher::join.