-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpost_handler.go
34 lines (28 loc) · 1.04 KB
/
post_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
package app
import (
errorsmod "cosmossdk.io/errors"
xfeemarketpost "github.com/MANTRA-Chain/mantrachain/v2/x/xfeemarket/post"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// PostHandlerOptions are the options required for constructing a FeeMarket PostHandler.
type PostHandlerOptions struct {
BankKeeper xfeemarketpost.BankKeeper
FeeMarketKeeper xfeemarketpost.FeeMarketKeeper
}
// NewPostHandler returns a PostHandler chain with the fee deduct decorator.
func NewPostHandler(options PostHandlerOptions) (sdk.PostHandler, error) {
if options.BankKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for post builder")
}
if options.FeeMarketKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "feemarket keeper is required for post builder")
}
postDecorators := []sdk.PostDecorator{
xfeemarketpost.NewFeeMarketDeductDecorator(
options.BankKeeper,
options.FeeMarketKeeper,
),
}
return sdk.ChainPostDecorators(postDecorators...), nil
}