2019-05-21 03:02:10 -07:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2019-12-27 09:57:54 -08:00
|
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
2019-05-21 03:02:10 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
|
|
|
)
|
|
|
|
|
2019-06-28 13:11:27 -07:00
|
|
|
// HandleCommunityPoolSpendProposal is a handler for executing a passed community spend proposal
|
2020-04-14 12:05:14 -07:00
|
|
|
func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolSpendProposal) error {
|
2019-08-02 05:29:00 -07:00
|
|
|
if k.blacklistedAddrs[p.Recipient.String()] {
|
2019-12-27 09:57:54 -08:00
|
|
|
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is blacklisted from receiving external funds", p.Recipient)
|
2019-08-02 05:29:00 -07:00
|
|
|
}
|
|
|
|
|
2019-06-28 13:11:27 -07:00
|
|
|
err := k.DistributeFromFeePool(ctx, p.Amount, p.Recipient)
|
2019-05-21 03:02:10 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-06-28 13:11:27 -07:00
|
|
|
|
2019-05-21 03:02:10 -07:00
|
|
|
logger := k.Logger(ctx)
|
2019-06-28 13:11:27 -07:00
|
|
|
logger.Info(fmt.Sprintf("transferred %s from the community pool to recipient %s", p.Amount, p.Recipient))
|
2019-05-21 03:02:10 -07:00
|
|
|
return nil
|
|
|
|
}
|