forked from cerc-io/laconicd-deprecated
261f86fdf2
* bump sdk version to v0.39.0 candidate * updates * update evm * bump commit * more changes * build * genesis * fix tests * fix tests * bump commit * bump commit * bump commit * add keygen func * bump version to 0.39.0-rc0 * update AnteHandler * fix TxDecoder * lint * fix test * update statedb * changelog * fixes * remove extra files * update make test-import * rename test * bump SDK version to final release * update to 0.39.1-rc1 * fix evm tests * update RPC * minor fixes * update to rc2 * bump to v0.39.1 * fix personal API * fix string type cast ambiguity (#449) * init * fix estimate gas test * minor genesis change * remove comments from unstable commit (stargate release) Co-authored-by: Alessio Treglia <quadrispro@ubuntu.com>
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package faucet
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
|
|
"github.com/cosmos/ethermint/x/faucet/types"
|
|
)
|
|
|
|
// NewHandler returns a handler for faucet messages.
|
|
func NewHandler(keeper Keeper) sdk.Handler {
|
|
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
|
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
|
switch msg := msg.(type) {
|
|
case types.MsgFund:
|
|
return handleMsgFund(ctx, keeper, msg)
|
|
default:
|
|
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", ModuleName, msg)
|
|
}
|
|
}
|
|
}
|
|
|
|
// handleMsgFund handles a message to fund an address
|
|
func handleMsgFund(ctx sdk.Context, keeper Keeper, msg types.MsgFund) (*sdk.Result, error) {
|
|
err := keeper.Fund(ctx, msg.Amount, msg.Recipient)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
ctx.EventManager().EmitEvent(
|
|
sdk.NewEvent(
|
|
sdk.EventTypeMessage,
|
|
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
|
|
sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender.String()),
|
|
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.String()),
|
|
sdk.NewAttribute(types.AttributeRecipient, msg.Recipient.String()),
|
|
),
|
|
)
|
|
|
|
return &sdk.Result{
|
|
Events: ctx.EventManager().Events(),
|
|
}, nil
|
|
}
|