-
Notifications
You must be signed in to change notification settings - Fork 0
/
proposal_handler.go
29 lines (23 loc) · 919 Bytes
/
proposal_handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package keeper
import (
sdk "github.com/mycodeku/transtionhelper/types"
sdkerrors "github.com/mycodeku/transtionhelper/types/errors"
"github.com/mycodeku/transtionhelper/x/distribution/types"
)
// HandleCommunityPoolSpendProposal is a handler for executing a passed community spend proposal
func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolSpendProposal) error {
recipient, addrErr := sdk.AccAddressFromBech32(p.Recipient)
if addrErr != nil {
return addrErr
}
if k.bankKeeper.BlockedAddr(recipient) {
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive external funds", p.Recipient)
}
err := k.DistributeFromFeePool(ctx, p.Amount, recipient)
if err != nil {
return err
}
logger := k.Logger(ctx)
logger.Info("transferred from the community pool to recipient", "amount", p.Amount.String(), "recipient", p.Recipient)
return nil
}