/
authz_royalty_config.go
86 lines (72 loc) · 2.66 KB
/
authz_royalty_config.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/authz"
)
var _ authz.Authorization = &CreateRoyaltyConfigAuthorization{}
var _ authz.Authorization = &UpdateRoyaltyConfigAuthorization{}
var _ authz.Authorization = &DeleteRoyaltyConfigAuthorization{}
func NewCreateRoyaltyConfigAuthorization(classId string) *CreateRoyaltyConfigAuthorization {
return &CreateRoyaltyConfigAuthorization{
ClassId: classId,
}
}
func (a CreateRoyaltyConfigAuthorization) MsgTypeURL() string {
return sdk.MsgTypeURL(&MsgCreateRoyaltyConfig{})
}
func (a CreateRoyaltyConfigAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptResponse, error) {
msgCreate, ok := msg.(*MsgCreateRoyaltyConfig)
if !ok {
return authz.AcceptResponse{}, sdkerrors.ErrInvalidType.Wrap("type mismatch")
}
if msgCreate.ClassId != a.ClassId {
return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrap("class ID mismatch")
}
return authz.AcceptResponse{Accept: true}, nil
}
func (a CreateRoyaltyConfigAuthorization) ValidateBasic() error {
return nil
}
func NewUpdateRoyaltyConfigAuthorization(classId string) *UpdateRoyaltyConfigAuthorization {
return &UpdateRoyaltyConfigAuthorization{
ClassId: classId,
}
}
func (a UpdateRoyaltyConfigAuthorization) MsgTypeURL() string {
return sdk.MsgTypeURL(&MsgUpdateRoyaltyConfig{})
}
func (a UpdateRoyaltyConfigAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptResponse, error) {
msgUpdate, ok := msg.(*MsgUpdateRoyaltyConfig)
if !ok {
return authz.AcceptResponse{}, sdkerrors.ErrInvalidType.Wrap("type mismatch")
}
if msgUpdate.ClassId != a.ClassId {
return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrap("class ID mismatch")
}
return authz.AcceptResponse{Accept: true}, nil
}
func (a UpdateRoyaltyConfigAuthorization) ValidateBasic() error {
return nil
}
func NewDeleteRoyaltyConfigAuthorization(classId string) *DeleteRoyaltyConfigAuthorization {
return &DeleteRoyaltyConfigAuthorization{
ClassId: classId,
}
}
func (a DeleteRoyaltyConfigAuthorization) MsgTypeURL() string {
return sdk.MsgTypeURL(&MsgDeleteRoyaltyConfig{})
}
func (a DeleteRoyaltyConfigAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptResponse, error) {
msgDelete, ok := msg.(*MsgDeleteRoyaltyConfig)
if !ok {
return authz.AcceptResponse{}, sdkerrors.ErrInvalidType.Wrap("type mismatch")
}
if msgDelete.ClassId != a.ClassId {
return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrap("class ID mismatch")
}
return authz.AcceptResponse{Accept: true}, nil
}
func (a DeleteRoyaltyConfigAuthorization) ValidateBasic() error {
return nil
}