-
Notifications
You must be signed in to change notification settings - Fork 0
/
msg.go
59 lines (49 loc) · 1.55 KB
/
msg.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
package staking
import (
"fmt"
processorCommon "github.com/LampardNguyen234/whale-alert/internal/processor/common"
)
type DelegateMsg struct {
processorCommon.TxMsg
Validator string
}
func (msg DelegateMsg) String() string {
msgFormatter := new(processorCommon.MsgFormatter).
FormatTitle("Staking").
FormatKeyValueMsg("Staker", msg.From).
FormatKeyValueMsg("Validator", msg.Validator).
FormatKeyValueMsg("Amount", msg.Amount).
FormatKeyValueMsg("TxHash", processorCommon.FormatTxURL(msg.TxHash))
return msgFormatter.String()
}
type UndelegateMsg struct {
processorCommon.TxMsg
Validator string
}
func (msg UndelegateMsg) String() string {
msgFormatter := new(processorCommon.MsgFormatter).
FormatTitle("Withdraw Staking").
FormatKeyValueMsg("Staker", msg.From).
FormatKeyValueMsg("From Validator", msg.Validator).
FormatKeyValueMsg("Amount", msg.Amount).
FormatKeyValueMsg("TxHash", processorCommon.FormatTxURL(msg.TxHash))
return msgFormatter.String()
}
type CreateValidatorMsg struct {
processorCommon.TxMsg
Address string
Name string
Commission float64
}
func (msg CreateValidatorMsg) String() string {
msgFormatter := new(processorCommon.MsgFormatter).
FormatTitle("New Validator")
if msg.Name != "" {
msgFormatter = msgFormatter.FormatKeyValueMsg("Name", msg.Name)
}
msgFormatter = msgFormatter.
FormatKeyValueMsg("Address", msg.Address).
FormatKeyValueMsg("Commission", fmt.Sprintf("%v%%", msg.Commission*100)).
FormatKeyValueMsg("TxHash", processorCommon.FormatTxURL(msg.TxHash))
return msgFormatter.String()
}