2022-12-13 00:38:27 +00:00
|
|
|
package community
|
|
|
|
|
|
|
|
import (
|
2023-04-05 23:21:59 +00:00
|
|
|
errorsmod "cosmossdk.io/errors"
|
2022-12-13 00:38:27 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
2023-04-04 00:08:45 +00:00
|
|
|
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
2022-12-13 00:38:27 +00:00
|
|
|
|
|
|
|
"github.com/kava-labs/kava/x/community/keeper"
|
|
|
|
"github.com/kava-labs/kava/x/community/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewCommunityPoolProposalHandler handles x/community proposals.
|
2023-04-04 00:08:45 +00:00
|
|
|
func NewCommunityPoolProposalHandler(k keeper.Keeper) govv1beta1.Handler {
|
|
|
|
return func(ctx sdk.Context, content govv1beta1.Content) error {
|
2022-12-13 00:38:27 +00:00
|
|
|
switch c := content.(type) {
|
2023-04-20 21:13:16 +00:00
|
|
|
case *types.CommunityCDPRepayDebtProposal:
|
|
|
|
return keeper.HandleCommunityCDPRepayDebtProposal(ctx, k, c)
|
2023-04-20 23:08:53 +00:00
|
|
|
case *types.CommunityCDPWithdrawCollateralProposal:
|
|
|
|
return keeper.HandleCommunityCDPWithdrawCollateralProposal(ctx, k, c)
|
2022-12-13 00:38:27 +00:00
|
|
|
case *types.CommunityPoolLendDepositProposal:
|
|
|
|
return keeper.HandleCommunityPoolLendDepositProposal(ctx, k, c)
|
|
|
|
case *types.CommunityPoolLendWithdrawProposal:
|
|
|
|
return keeper.HandleCommunityPoolLendWithdrawProposal(ctx, k, c)
|
|
|
|
default:
|
2023-04-05 23:21:59 +00:00
|
|
|
return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized community proposal content type: %T", c)
|
2022-12-13 00:38:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|