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