-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #421 from irisnet/refactor/add-gov-handler
refactor: add gov handler
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |