-
Notifications
You must be signed in to change notification settings - Fork 6
/
msgs.go
48 lines (39 loc) · 1.35 KB
/
msgs.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
package poa
import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"cosmossdk.io/math"
)
var (
_ codectypes.UnpackInterfacesMessage = (*MsgCreateValidator)(nil)
_ codectypes.UnpackInterfacesMessage = (*Validator)(nil)
)
// NewMsgCreateValidator creates a new MsgCreateValidator instance.
func NewMsgCreateValidator(
valAddr string, pubKey cryptotypes.PubKey, description Description, commission CommissionRates, minSelfDelegation math.Int,
) (*MsgCreateValidator, error) {
var pkAny *codectypes.Any
if pubKey != nil {
var err error
if pkAny, err = codectypes.NewAnyWithValue(pubKey); err != nil {
return nil, err
}
}
return &MsgCreateValidator{
Description: description,
ValidatorAddress: valAddr,
Pubkey: pkAny,
Commission: commission,
MinSelfDelegation: minSelfDelegation,
}, nil
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (msg MsgCreateValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
var pubKey cryptotypes.PubKey
return unpacker.UnpackAny(msg.Pubkey, &pubKey)
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (v Validator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
var pk cryptotypes.PubKey
return unpacker.UnpackAny(v.ConsensusPubkey, &pk)
}