-
Notifications
You must be signed in to change notification settings - Fork 182
/
proposal_handler.go
36 lines (31 loc) · 1.03 KB
/
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
30
31
32
33
34
35
36
package farm
import (
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
"github.com/okex/exchain/x/common"
"github.com/okex/exchain/x/farm/types"
govTypes "github.com/okex/exchain/x/gov/types"
)
// NewManageWhiteListProposalHandler handles "gov" type message in "farm"
func NewManageWhiteListProposalHandler(k *Keeper) govTypes.Handler {
return func(ctx sdk.Context, proposal *govTypes.Proposal) (err sdk.Error) {
switch content := proposal.Content.(type) {
case types.ManageWhiteListProposal:
return handleManageWhiteListProposal(ctx, k, content)
default:
return common.ErrUnknownProposalType(DefaultCodespace, content.ProposalType())
}
}
}
func handleManageWhiteListProposal(ctx sdk.Context, k *Keeper, p types.ManageWhiteListProposal) sdk.Error {
if sdkErr := k.CheckMsgManageWhiteListProposal(ctx, p); sdkErr != nil {
return sdkErr
}
if p.IsAdded {
// add pool name into whitelist
k.SetWhitelist(ctx, p.PoolName)
return nil
}
// remove pool name from whitelist
k.DeleteWhiteList(ctx, p.PoolName)
return nil
}