-
Notifications
You must be signed in to change notification settings - Fork 0
/
msg_parse.go
25 lines (20 loc) · 936 Bytes
/
msg_parse.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
package crisis
import (
"github.com/Moonyongjung/xpriv.go/key"
"github.com/Moonyongjung/xpriv.go/types"
"github.com/Moonyongjung/xpriv.go/types/errors"
"github.com/Moonyongjung/xpriv.go/util"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
)
// Parsing - invariant broken
func parseInvariantBrokenArgs(invariantBrokenMsg types.InvariantBrokenMsg, privKey key.PrivateKey) (crisistypes.MsgVerifyInvariant, error) {
if invariantBrokenMsg.ModuleName == "" || invariantBrokenMsg.InvariantRoute == "" {
return crisistypes.MsgVerifyInvariant{}, util.LogErr(errors.ErrInsufficientParams, "invalid module name or invariant route")
}
senderAddr, err := util.GetAddrByPrivKey(privKey)
if err != nil {
return crisistypes.MsgVerifyInvariant{}, util.LogErr(errors.ErrParse, err)
}
msg := crisistypes.NewMsgVerifyInvariant(senderAddr, invariantBrokenMsg.ModuleName, invariantBrokenMsg.InvariantRoute)
return *msg, nil
}