-
Notifications
You must be signed in to change notification settings - Fork 37
/
msg_server.go
43 lines (35 loc) · 1.36 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
package keeper
import (
"context"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/provenance-io/provenance/x/msgfees/types"
)
type msgServer struct {
Keeper
}
// NewMsgServerImpl returns an implementation of the msgfees MsgServer interface
// for the provided Keeper.
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
return &msgServer{Keeper: keeper}
}
var _ types.MsgServer = msgServer{}
func (m msgServer) AssessCustomMsgFee(goCtx context.Context, req *types.MsgAssessCustomMsgFeeRequest) (*types.MsgAssessCustomMsgFeeResponse, error) {
// method only emits that the event has been submitted, all logic is handled in the provenance custom msg handlers
ctx := sdk.UnwrapSDKContext(goCtx)
// if there is a recipient and bips are not set, we will want to emit the default bips with event
recipientBips := req.RecipientBasisPoints
if len(req.Recipient) > 0 && len(req.RecipientBasisPoints) == 0 {
recipientBips = fmt.Sprintf("%v", types.AssessCustomMsgFeeBips)
}
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeAssessCustomMsgFee,
sdk.NewAttribute(types.KeyAttributeName, req.Name),
sdk.NewAttribute(types.KeyAttributeAmount, req.Amount.String()),
sdk.NewAttribute(types.KeyAttributeRecipient, req.Recipient),
sdk.NewAttribute(types.KeyAttributeBips, recipientBips),
),
)
return &types.MsgAssessCustomMsgFeeResponse{}, nil
}