Skip to content

Commit

Permalink
Merge pull request #421 from irisnet/refactor/add-gov-handler
Browse files Browse the repository at this point in the history
refactor: add gov handler
  • Loading branch information
mitch1024 authored Jul 5, 2024
2 parents 5248ff2 + 4d83c9a commit 55f906f
Showing 1 changed file with 30 additions and 0 deletions.
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)
}

0 comments on commit 55f906f

Please sign in to comment.