-
Notifications
You must be signed in to change notification settings - Fork 5
/
edit_validator.go
47 lines (40 loc) · 1.19 KB
/
edit_validator.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
package staking
import (
. "github.com/kaifei-bianjie/msg-parser/modules"
)
// MsgEditValidator - struct for editing a validator
type DocMsgEditValidator struct {
Description Description `bson:"description"`
ValidatorAddress string `bson:"validator_address"`
CommissionRate string `bson:"commission_rate"`
MinSelfDelegation string `bson:"min_self_delegation"`
}
func (doctx *DocMsgEditValidator) GetType() string {
return MsgTypeStakeEditValidator
}
func (doctx *DocMsgEditValidator) BuildMsg(txMsg interface{}) {
msg := txMsg.(*MsgStakeEdit)
doctx.ValidatorAddress = msg.ValidatorAddress
commissionRate := msg.CommissionRate
if commissionRate == nil {
doctx.CommissionRate = ""
} else {
doctx.CommissionRate = commissionRate.String()
}
doctx.Description = loadDescription(msg.Description)
if msg.MinSelfDelegation != nil {
doctx.MinSelfDelegation = msg.MinSelfDelegation.String()
}
}
func (m *DocMsgEditValidator) HandleTxMsg(v SdkMsg) MsgDocInfo {
var (
addrs []string
msg MsgStakeEdit
)
ConvertMsg(v, &msg)
addrs = append(addrs, msg.ValidatorAddress)
handler := func() (Msg, []string) {
return m, addrs
}
return CreateMsgDocInfo(v, handler)
}