-
Notifications
You must be signed in to change notification settings - Fork 3
Description
ProcessStacksEvent is the main interface for processing Stacks events within the Stacks Provider. It should use the ParseStacksEvent() function below and handle any additional provider-specific logic or error handling.
Stacks events
Define constants for the xCall event names we'll be monitoring on the Stacks blockchain:
const (
EmitMessage = "EmitMessage"
CallMessage = "CallMessage"
)
Implement eventMap()
This function should create a mapping between Stacks contract addresses and their associated events. It will be used to determine which events to monitor for each contract. The returned map should use contract addresses as keys and providerTypes.EventMap as values, where EventMap contains the contract name and a mapping of event signatures to event types.
func (p *Config) eventMap() map[string]providerTypes.EventMap
Implement GetMonitorEventFilters()
This function should return a list of event filters based on the eventMap(). These filters will be used by the Stacks Blockchain Listener to determine which events to monitor. Each EventFilter should specify the contract address and event signature to watch for.
func (p *Provider) GetMonitorEventFilters() []*types.EventFilter
Implement GetEventName() and GetAddressByEventType()
GetEventName() should return the human-readable event name (e.g., "EmitMessage") given an event signature.
func (p *Provider) GetEventName(sig string) string
GetAddressByEventType() should return the contract address associated with a given event type.
func (p *Provider) GetAddressByEventType(eventType string) types.Address
These functions will be used for event processing and routing.
Implement ParseStacksEvent()
This is the main entry point for parsing Stacks events. It should determine the event type and call the appropriate parsing function (parseEmitMessage or parseCallMessage). The function should return a types.Message that can be processed by the relay system.
func (p *Provider) ParseStacksEvent(event StacksEvent) (*types.Message, error)
Implement parseEmitMessage and parseCallMessage that handle the specific parsing logic for each event type. They should extract relevant data from the Stacks event and construct a types.Message. Use the ClarityValue types to parse the event data correctly.
func (p *Provider) parseEmitMessage(event StacksEvent) (*types.Message, error)
func (p *Provider) parseCallMessage(event StacksEvent) (*types.Message, error)
Acceptance Criteria
- Event parsing logic correctly interprets EmitMessage and CallMessage events from Stacks xCall contract
- Parsed events are correctly converted into the common types.Message format
- Unit tests cover all methods and edge cases with >80% code coverage
- Integration tests confirm functionality against Stacks testnet