package keeper import ( "context" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "git.vdb.to/cerc-io/laconicd/utils" "git.vdb.to/cerc-io/laconicd/x/onboarding" ) type msgServer struct { k Keeper } var _ onboarding.MsgServer = msgServer{} // NewMsgServerImpl returns an implementation of the module MsgServer interface. func NewMsgServerImpl(keeper *Keeper) onboarding.MsgServer { return &msgServer{k: *keeper} } func (ms msgServer) OnboardParticipant(c context.Context, msg *onboarding.MsgOnboardParticipant) (*onboarding.MsgOnboardParticipantResponse, error) { if err := msg.ValidateBasic(); err != nil { return nil, err } ctx := sdk.UnwrapSDKContext(c) ctx = *utils.CtxWithCustomKVGasConfig(&ctx) signerAddress, err := sdk.AccAddressFromBech32(msg.Participant) if err != nil { return nil, err } _, err = ms.k.OnboardParticipant(ctx, msg, signerAddress) if err != nil { return nil, err } ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( onboarding.EventTypeOnboardParticipant, sdk.NewAttribute(onboarding.AttributeKeySigner, msg.Participant), sdk.NewAttribute(onboarding.AttributeKeyEthAddress, msg.EthPayload.Address), ), sdk.NewEvent( sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyModule, onboarding.AttributeValueCategory), sdk.NewAttribute(onboarding.AttributeKeySigner, msg.Participant), ), }) utils.LogTxGasConsumed(ctx, ms.k.Logger(ctx), "OnboardParticipant") return &onboarding.MsgOnboardParticipantResponse{}, nil } // UpdateParams defines a method to perform updation of module params. func (ms msgServer) UpdateParams(c context.Context, msg *onboarding.MsgUpdateParams) (*onboarding.MsgUpdateParamsResponse, error) { if ms.k.authority != msg.Authority { return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.k.authority, msg.Authority) } if err := msg.Params.Validate(); err != nil { return nil, err } ctx := sdk.UnwrapSDKContext(c) if err := ms.k.SetParams(ctx, msg.Params); err != nil { return nil, err } return &onboarding.MsgUpdateParamsResponse{}, nil }