-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add x/community Lend proposals (#1425)
* implement & register x/community lend proposals * register proposals in x/community codec * allow x/community macc to receive funds * init lend from genesis in proposal tests * test CommunityLendWithdrawProposal * helpful comment on x/community keeper deps * use RouteKey in module.go
- Loading branch information
1 parent
a7f3b77
commit 7c58fb5
Showing
13 changed files
with
474 additions
and
28 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
# Output of the go coverage tool | ||
*.out | ||
cover.html | ||
|
||
# Exclude build files | ||
vendor | ||
|
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
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
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,24 @@ | ||
package community | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||
|
||
"github.com/kava-labs/kava/x/community/keeper" | ||
"github.com/kava-labs/kava/x/community/types" | ||
) | ||
|
||
// NewCommunityPoolProposalHandler handles x/community proposals. | ||
func NewCommunityPoolProposalHandler(k keeper.Keeper) govtypes.Handler { | ||
return func(ctx sdk.Context, content govtypes.Content) error { | ||
switch c := content.(type) { | ||
case *types.CommunityPoolLendDepositProposal: | ||
return keeper.HandleCommunityPoolLendDepositProposal(ctx, k, c) | ||
case *types.CommunityPoolLendWithdrawProposal: | ||
return keeper.HandleCommunityPoolLendWithdrawProposal(ctx, k, c) | ||
default: | ||
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized community proposal content type: %T", c) | ||
} | ||
} | ||
} |
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
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,17 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/kava-labs/kava/x/community/types" | ||
) | ||
|
||
// HandleCommunityPoolLendDepositProposal is a handler for executing a passed community pool lend deposit proposal. | ||
func HandleCommunityPoolLendDepositProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolLendDepositProposal) error { | ||
return k.hardKeeper.Deposit(ctx, k.moduleAddress, p.Amount) | ||
} | ||
|
||
// HandleCommunityPoolLendWithdrawProposal is a handler for executing a passed community pool lend withdraw proposal. | ||
func HandleCommunityPoolLendWithdrawProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolLendWithdrawProposal) error { | ||
return k.hardKeeper.Withdraw(ctx, k.moduleAddress, p.Amount) | ||
} |
Oops, something went wrong.