Add tx to feeHandler, move around in example apps
This commit is contained in:
parent
39ee95abe4
commit
3bbb15f454
|
@ -63,9 +63,6 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
|
|||
&types.AppAccount{}, // prototype
|
||||
).Seal()
|
||||
|
||||
// Define the feeHandler.
|
||||
app.feeHandler = func(ctx sdk.Context, fees sdk.Coins) {}
|
||||
|
||||
// Add handlers.
|
||||
coinKeeper := bank.NewCoinKeeper(app.accountMapper)
|
||||
ibcMapper := ibc.NewIBCMapper(app.cdc, app.capKeyIBCStore)
|
||||
|
@ -75,6 +72,9 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
|
|||
AddRoute("ibc", ibc.NewHandler(ibcMapper, coinKeeper)).
|
||||
AddRoute("simplestake", simplestake.NewHandler(stakeKeeper))
|
||||
|
||||
// Define the feeHandler.
|
||||
app.feeHandler = func(ctx sdk.Context, tx sdk.Tx, fees sdk.Coins) {}
|
||||
|
||||
// Initialize BaseApp.
|
||||
app.SetTxDecoder(app.txDecoder)
|
||||
app.SetInitChainer(app.initChainer)
|
||||
|
|
|
@ -68,9 +68,6 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
|||
&types.AppAccount{}, // prototype
|
||||
).Seal()
|
||||
|
||||
// Define the feeHandler.
|
||||
app.feeHandler = func(ctx sdk.Context, fee sdk.Coins) {}
|
||||
|
||||
// Add handlers.
|
||||
coinKeeper := bank.NewCoinKeeper(app.accountMapper)
|
||||
coolKeeper := cool.NewKeeper(app.capKeyMainStore, coinKeeper)
|
||||
|
@ -85,6 +82,9 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp {
|
|||
AddRoute("ibc", ibc.NewHandler(ibcMapper, coinKeeper)).
|
||||
AddRoute("simplestake", simplestake.NewHandler(stakeKeeper))
|
||||
|
||||
// Define the feeHandler.
|
||||
app.feeHandler = func(ctx sdk.Context, tx sdk.Tx, fee sdk.Coins) {}
|
||||
|
||||
// Initialize BaseApp.
|
||||
app.SetTxDecoder(app.txDecoder)
|
||||
app.SetInitChainer(app.initChainerFn(coolKeeper, powKeeper))
|
||||
|
|
|
@ -4,7 +4,7 @@ package types
|
|||
type Handler func(ctx Context, msg Msg) Result
|
||||
|
||||
// core function variable which application runs to handle fees
|
||||
type FeeHandler func(ctx Context, fee Coins)
|
||||
type FeeHandler func(ctx Context, tx Tx, fee Coins)
|
||||
|
||||
// If newCtx.IsZero(), ctx is used instead.
|
||||
type AnteHandler func(ctx Context, tx Tx) (newCtx Context, result Result, abort bool)
|
||||
|
|
|
@ -74,7 +74,7 @@ func NewAnteHandler(accountMapper sdk.AccountMapper, feeHandler sdk.FeeHandler)
|
|||
// TODO: min fee
|
||||
if !fee.Amount.IsZero() {
|
||||
signerAcc, res = deductFees(signerAcc, fee)
|
||||
feeHandler(ctx, fee.Amount)
|
||||
feeHandler(ctx, tx, fee.Amount)
|
||||
if !res.IsOK() {
|
||||
return ctx, res, true
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
wire "github.com/cosmos/cosmos-sdk/wire"
|
||||
)
|
||||
|
||||
func nopFeeHandler(ctx sdk.Context, fee sdk.Coins) {
|
||||
func nopFeeHandler(ctx sdk.Context, tx sdk.Tx, fee sdk.Coins) {
|
||||
}
|
||||
|
||||
func newTestMsg(addrs ...sdk.Address) *sdk.TestMsg {
|
||||
|
|
Loading…
Reference in New Issue