Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add gov handler #421

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions modules/farm/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package farm

import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

"mods.irisnet.org/modules/farm/keeper"
"mods.irisnet.org/modules/farm/types"
)

// NewProposalHandler returns a handler function for processing farm proposals.
//
// It takes in a context and a content interface and returns an error.
func NewProposalHandler(k keeper.Keeper) govtypes.Handler {
return func(ctx sdk.Context, content govtypes.Content) error {
switch c := content.(type) {
case *types.CommunityPoolCreateFarmProposal:
return handleCreateFarmProposal(ctx, k, c)
default:
return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized farm proposal content type: %T", c)
}
}
}


func handleCreateFarmProposal(ctx sdk.Context, k keeper.Keeper, p *types.CommunityPoolCreateFarmProposal) error {
return k.HandleCreateFarmProposal(ctx, p)
}
Loading