-
Notifications
You must be signed in to change notification settings - Fork 1
/
msg_claim_key.go
72 lines (63 loc) · 1.92 KB
/
msg_claim_key.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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ sdk.Msg = MsgClaimKey{}
// MsgClaimKey is used to claim a prior rekey message
type MsgClaimKey struct {
AttendeeAddress sdk.AccAddress `json:"attendeeAddress"`
Name string `json:"name"`
Secret string `json:"secret"`
RsaPublicKey string `json:"rsaPublicKey"`
EncryptedInfo []byte `json:"encryptedInfo"`
}
// NewMsgClaimKey in the constructor for `MsgClaimKey`
func NewMsgClaimKey(address sdk.AccAddress, name string, secret string, rsaPublicKey string,
encryptedInfo []byte) MsgClaimKey {
return MsgClaimKey{
AttendeeAddress: address,
Name: name,
Secret: secret,
RsaPublicKey: rsaPublicKey,
EncryptedInfo: encryptedInfo,
}
}
// Route defines the route for this message
//nolint:gocritic
func (msg MsgClaimKey) Route() string {
return RouterKey
}
// Type is the message type
//nolint:gocritic
func (msg MsgClaimKey) Type() string {
return "claim_key"
}
// ValidateBasic performs sanity checks on the message
//nolint:gocritic
func (msg MsgClaimKey) ValidateBasic() sdk.Error {
switch {
case msg.AttendeeAddress.Empty():
return sdk.ErrInvalidAddress("empty attendee address")
case msg.Name == "":
return ErrEmptyName("name cannot be empty")
case len(msg.Secret) == 0:
return ErrEmptySecret("secret cannot be empty")
case len(msg.RsaPublicKey) == 0:
return ErrEmptyRsaKey("rsa public key cannot be empty")
case len(msg.EncryptedInfo) == 0:
return ErrEmptyEncryptedInfo("encrypted info cannot be empty")
default:
return nil
}
}
// GetSignBytes returns the byte array that is signed over
//nolint:gocritic
func (msg MsgClaimKey) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
// GetSigners returns the
//nolint:gocritic
func (msg MsgClaimKey) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{msg.AttendeeAddress}
}