-
Notifications
You must be signed in to change notification settings - Fork 0
/
LerpFab.go
executable file
·88 lines (78 loc) · 2.17 KB
/
LerpFab.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package LerpFab
import (
"github.com/nakji-network/connector/common"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/core/types"
"github.com/rs/zerolog/log"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/known/timestamppb"
)
type SmartContract struct{}
func (sc *SmartContract) Message(eventName string, contractAbi *abi.ABI, vLog types.Log, timestamp *timestamppb.Timestamp) protoreflect.ProtoMessage {
switch eventName {
case "Deny":
e := new(LERPFABDeny)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &Deny{
Ts: timestamp,
Usr: e.Usr.Bytes(),
}
case "LerpFinished":
e := new(LERPFABLerpFinished)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &LerpFinished{
Ts: timestamp,
Lerp: e.Lerp.Bytes(),
}
case "NewIlkLerp":
e := new(LERPFABNewIlkLerp)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &NewIlkLerp{
Ts: timestamp,
Name: e.Name[:],
Target: e.Target.Bytes(),
Ilk: e.Ilk[:],
What: e.What[:],
StartTime: e.StartTime.Bytes(),
Start: e.Start.Bytes(),
End: e.End.Bytes(),
Duration: e.Duration.Bytes(),
}
case "NewLerp":
e := new(LERPFABNewLerp)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &NewLerp{
Ts: timestamp,
Name: e.Name[:],
Target: e.Target.Bytes(),
What: e.What[:],
StartTime: e.StartTime.Bytes(),
Start: e.Start.Bytes(),
End: e.End.Bytes(),
Duration: e.Duration.Bytes(),
}
case "Rely":
e := new(LERPFABRely)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &Rely{
Ts: timestamp,
Usr: e.Usr.Bytes(),
}
}
return nil
}