/
MCDVestMkr.go
executable file
·124 lines (110 loc) · 2.9 KB
/
MCDVestMkr.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package MCDVestMkr
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(MCDVESTMKRDeny)
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 "File":
e := new(MCDVESTMKRFile)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &File{
Ts: timestamp,
What: e.What[:],
Data: e.Data.Bytes(),
}
case "Init":
e := new(MCDVESTMKRInit)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &Init{
Ts: timestamp,
Id: e.Id.Bytes(),
Usr: e.Usr.Bytes(),
}
case "Move":
e := new(MCDVESTMKRMove)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &Move{
Ts: timestamp,
Id: e.Id.Bytes(),
Dst: e.Dst.Bytes(),
}
case "Rely":
e := new(MCDVESTMKRRely)
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(),
}
case "Restrict":
e := new(MCDVESTMKRRestrict)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &Restrict{
Ts: timestamp,
Id: e.Id.Bytes(),
}
case "Unrestrict":
e := new(MCDVESTMKRUnrestrict)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &Unrestrict{
Ts: timestamp,
Id: e.Id.Bytes(),
}
case "Vest":
e := new(MCDVESTMKRVest)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &Vest{
Ts: timestamp,
Id: e.Id.Bytes(),
Amt: e.Amt.Bytes(),
}
case "Yank":
e := new(MCDVESTMKRYank)
if err := common.UnpackLog(*contractAbi, e, eventName, vLog); err != nil {
log.Error().Err(err).Msg("Failed to unpack log")
return nil
}
return &Yank{
Ts: timestamp,
Id: e.Id.Bytes(),
End: e.End.Bytes(),
}
}
return nil
}