Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notification event from fly and event-watcher #644

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions common/domain/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package domain

import (
"encoding/json"
"time"
)

type NotificationEvent struct {
TrackID string `json:"trackId"`
Source string `json:"source"`
Type string `json:"type"`
Payload json.RawMessage `json:"payload"`
}

type EventPayload interface {
SignedVaa | PublishedLogMessage
}

func GetEventPayload[T EventPayload](e *NotificationEvent) (T, error) {
var payload T
err := json.Unmarshal(e.Payload, &payload)
return payload, err
}

type SignedVaa struct {
ID string `json:"id"`
EmitterChain int `json:"emitterChain"`
EmitterAddr string `json:"emitterAddr"`
Sequence string `json:"sequence"`
GuardianSetIndex int `json:"guardianSetIndex"`
Timestamp time.Time `json:"timestamp"`
Vaa string `json:"vaa"`
TxHash string `json:"txHash"`
Version int `json:"version"`
}

type PublishedLogMessage struct {
ID string `json:"id"`
EmitterChain int `json:"emitterChain"`
EmitterAddr string `json:"emitterAddr"`
Sequence string `json:"sequence"`
Timestamp time.Time `json:"timestamp"`
Vaa string `json:"vaa"`
TxHash string `json:"txHash"`
}
Loading