-
Notifications
You must be signed in to change notification settings - Fork 41
/
tx_msg_create_resource.go
58 lines (45 loc) · 1.4 KB
/
tx_msg_create_resource.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
package types
import (
didtypes "github.com/cheqd/cheqd-node/x/did/types"
sdk "github.com/cosmos/cosmos-sdk/types"
validation "github.com/go-ozzo/ozzo-validation/v4"
)
var _ sdk.Msg = &MsgCreateResource{}
func NewMsgCreateResource(payload *MsgCreateResourcePayload, signatures []*didtypes.SignInfo) *MsgCreateResource {
return &MsgCreateResource{
Payload: payload,
Signatures: signatures,
}
}
func (msg *MsgCreateResource) Route() string {
return RouterKey
}
func (msg *MsgCreateResource) Type() string {
return "MsgCreateResource"
}
func (msg *MsgCreateResource) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{}
}
func (msg *MsgCreateResource) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
func (msg *MsgCreateResource) ValidateBasic() error {
err := msg.Validate([]string{})
if err != nil {
return ErrBasicValidation.Wrap(err.Error())
}
return nil
}
// Validate
func (msg MsgCreateResource) Validate(allowedNamespaces []string) error {
return validation.ValidateStruct(&msg,
validation.Field(&msg.Payload, validation.Required, ValidMsgCreateResourcePayload()),
validation.Field(&msg.Signatures, didtypes.IsUniqueSignInfoListRule(), validation.Each(didtypes.ValidSignInfoRule(allowedNamespaces))),
)
}
// Normalize
func (msg *MsgCreateResource) Normalize() {
msg.Payload.Normalize()
didtypes.NormalizeSignInfoList(msg.Signatures)
}