forked from taikoxyz/taiko-mono
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevent.go
63 lines (54 loc) · 1.5 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package relayer
import (
"context"
"math/big"
"github.com/ethereum/go-ethereum/common"
"gorm.io/datatypes"
)
var (
EventNameMessageSent = "MessageSent"
)
// EventStatus is used to indicate whether processing has been attempted
// for this particular event, and it's success
type EventStatus int
const (
EventStatusNew EventStatus = iota
EventStatusRetriable
EventStatusDone
EventStatusNewOnlyOwner
)
// String returns string representation of an event status for logging
func (e EventStatus) String() string {
return [...]string{"new", "retriable", "done", "onlyOwner"}[e]
}
// Event represents a stored EVM event. The fields will be serialized
// into the Data field to be unmarshalled into a concrete struct
// dependant on the name of the event
type Event struct {
ID int `json:"id"`
Name string `json:"name"`
Data datatypes.JSON `json:"data"`
Status EventStatus `json:"status"`
ChainID int64 `json:"chainID"`
}
// SaveEventOpts
type SaveEventOpts struct {
Name string
Data string
ChainID *big.Int
Status EventStatus
}
// EventRepository is used to interact with events in the store
type EventRepository interface {
Save(ctx context.Context, opts SaveEventOpts) (*Event, error)
UpdateStatus(ctx context.Context, id int, status EventStatus) error
FindAllByAddressAndChainID(
ctx context.Context,
chainID *big.Int,
address common.Address,
) ([]*Event, error)
FindAllByAddress(
ctx context.Context,
address common.Address,
) ([]*Event, error)
}