-
Notifications
You must be signed in to change notification settings - Fork 206
/
msg_server.go
48 lines (40 loc) · 1.52 KB
/
msg_server.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 keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/NibiruChain/nibiru/x/inflation/types"
)
type msgServer struct {
Keeper
}
// NewMsgServerImpl returns an implementation of the inflation MsgServer interface
// for the provided Keeper.
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
return &msgServer{Keeper: keeper}
}
// EditInflationParams: gRPC tx msg for editing the inflation module params.
// [SUDO] Only callable by sudoers.
func (ms msgServer) EditInflationParams(
goCtx context.Context, msg *types.MsgEditInflationParams,
) (resp *types.MsgEditInflationParamsResponse, err error) {
ctx := sdk.UnwrapSDKContext(goCtx)
// Stateless field validation is already performed in msg.ValidateBasic()
// before the current scope is reached.
sender, _ := sdk.AccAddressFromBech32(msg.Sender)
err = ms.Sudo().EditInflationParams(ctx, *msg, sender)
resp = &types.MsgEditInflationParamsResponse{}
return resp, err
}
// ToggleInflation: gRPC tx msg for enabling or disabling token inflation.
// [SUDO] Only callable by sudoers.
func (ms msgServer) ToggleInflation(
goCtx context.Context, msg *types.MsgToggleInflation,
) (resp *types.MsgToggleInflationResponse, err error) {
ctx := sdk.UnwrapSDKContext(goCtx)
// Stateless field validation is already performed in msg.ValidateBasic()
// before the current scope is reached.
sender, _ := sdk.AccAddressFromBech32(msg.Sender)
err = ms.Sudo().ToggleInflation(ctx, msg.Enable, sender)
resp = &types.MsgToggleInflationResponse{}
return resp, err
}