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 FundCommunityPoolFromModule to use SDK #1909

Merged
Merged
Show file tree
Hide file tree
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
12 changes: 5 additions & 7 deletions x/pool-incentives/keeper/distr.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// FundCommunityPoolFromModule allows the pool-incentives module to directly fund the community fund pool.
func (k Keeper) FundCommunityPoolFromModule(ctx sdk.Context, asset sdk.Coin) error {
err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.communityPoolName, sdk.Coins{asset})
if err != nil {
return err
moduleAddr := k.accountKeeper.GetModuleAddress(types.ModuleName)
if moduleAddr == nil {
panic("Could not get distribution module from SDK")
}

feePool := k.distrKeeper.GetFeePool(ctx)
feePool.CommunityPool = feePool.CommunityPool.Add(sdk.NewDecCoinsFromCoins(asset)...)
k.distrKeeper.SetFeePool(ctx, feePool)
return nil
return k.distrKeeper.FundCommunityPool(ctx, sdk.Coins{asset}, moduleAddr)
}

// AllocateAsset allocates and distributes coin according a gauge’s proportional weight that is recorded in the record.
Expand Down
1 change: 1 addition & 0 deletions x/pool-incentives/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ type IncentivesKeeper interface {
type DistrKeeper interface {
GetFeePool(ctx sdk.Context) (feePool distrtypes.FeePool)
SetFeePool(ctx sdk.Context, feePool distrtypes.FeePool)
FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
}