pub trait NativeHandlers: Send + Sync {
// Required methods
fn supported_handlers(&self) -> Vec<String>;
fn handle_trigger<'a>(
&'a self,
handler_name: &str,
log: &'a Log,
ctx: &'a mut dyn HandlerContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>;
}Expand description
The trait that a native subgraph plugin must implement.
Generated by the native-transpiler’s lib.ts codegen. The .so plugin
exports a constructor function that returns a Box<dyn NativeHandlers>.
Phase C will add plugin loading in graph-node’s RuntimeHost that:
- dlopen’s the .so
- Calls the constructor to get a NativeHandlers instance
- Routes triggers to handle_trigger() for supported handlers
Required Methods§
Sourcefn supported_handlers(&self) -> Vec<String>
fn supported_handlers(&self) -> Vec<String>
Returns the list of handler names this plugin supports natively. Example: vec![“handleTransfer”, “handleApproval”] Handlers not in this list fall back to WASM execution.
Sourcefn handle_trigger<'a>(
&'a self,
handler_name: &str,
log: &'a Log,
ctx: &'a mut dyn HandlerContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn handle_trigger<'a>( &'a self, handler_name: &str, log: &'a Log, ctx: &'a mut dyn HandlerContext, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Execute a handler for a matched trigger.
handler_name: the handler to invoke (must be in supported_handlers)log: the decoded Ethereum log event (trigger data)ctx: handler context wrapping BlockState for entity operations
The handler reads event data from log, creates/updates/removes
entities through ctx, and returns Ok(()) on success.
Note: This takes &Log (our trigger struct) for now. Phase C will change this to accept graph-node’s MappingTrigger directly.