Skip to content

Commit

Permalink
Add notification event from fly and event-watcher (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
ftocal committed Oct 5, 2023
1 parent bc8a311 commit 5f17ba8
Showing 1 changed file with 45 additions and 0 deletions.
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"`
}

0 comments on commit 5f17ba8

Please sign in to comment.