From 474fa1dfd1ade9e450ba65eb746f819a9d4468e4 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Tue, 17 Apr 2018 01:06:07 +0200 Subject: [PATCH] Switch to BurnFeeHandler --- examples/basecoin/app/app.go | 2 +- examples/democoin/app/app.go | 2 +- x/auth/ante.go | 4 ++++ x/auth/ante_test.go | 13 +++++-------- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/basecoin/app/app.go b/examples/basecoin/app/app.go index 8a4f4810d..ae60e8a73 100644 --- a/examples/basecoin/app/app.go +++ b/examples/basecoin/app/app.go @@ -73,7 +73,7 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp { AddRoute("simplestake", simplestake.NewHandler(stakeKeeper)) // Define the feeHandler. - app.feeHandler = func(ctx sdk.Context, tx sdk.Tx, fees sdk.Coins) {} + app.feeHandler = auth.BurnFeeHandler // Initialize BaseApp. app.SetTxDecoder(app.txDecoder) diff --git a/examples/democoin/app/app.go b/examples/democoin/app/app.go index 85ed50b30..151241d14 100644 --- a/examples/democoin/app/app.go +++ b/examples/democoin/app/app.go @@ -83,7 +83,7 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp { AddRoute("simplestake", simplestake.NewHandler(stakeKeeper)) // Define the feeHandler. - app.feeHandler = func(ctx sdk.Context, tx sdk.Tx, fee sdk.Coins) {} + app.feeHandler = auth.BurnFeeHandler // Initialize BaseApp. app.SetTxDecoder(app.txDecoder) diff --git a/x/auth/ante.go b/x/auth/ante.go index dc756e360..c7af7e2d9 100644 --- a/x/auth/ante.go +++ b/x/auth/ante.go @@ -157,3 +157,7 @@ func deductFees(acc sdk.Account, fee sdk.StdFee) (sdk.Account, sdk.Result) { acc.SetCoins(newCoins) return acc, sdk.Result{} } + +// BurnFeeHandler burns all fees (decreasing total supply) +func BurnFeeHandler(ctx sdk.Context, tx sdk.Tx, fee sdk.Coins) { +} diff --git a/x/auth/ante_test.go b/x/auth/ante_test.go index 8445c1448..58633ff9a 100644 --- a/x/auth/ante_test.go +++ b/x/auth/ante_test.go @@ -12,9 +12,6 @@ import ( wire "github.com/cosmos/cosmos-sdk/wire" ) -func nopFeeHandler(ctx sdk.Context, tx sdk.Tx, fee sdk.Coins) { -} - func newTestMsg(addrs ...sdk.Address) *sdk.TestMsg { return sdk.NewTestMsg(addrs...) } @@ -75,7 +72,7 @@ func TestAnteHandlerSigErrors(t *testing.T) { cdc := wire.NewCodec() RegisterBaseAccount(cdc) mapper := NewAccountMapper(cdc, capKey, &BaseAccount{}) - anteHandler := NewAnteHandler(mapper, nopFeeHandler) + anteHandler := NewAnteHandler(mapper, BurnFeeHandler) ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil) // keys and addresses @@ -116,7 +113,7 @@ func TestAnteHandlerSequences(t *testing.T) { cdc := wire.NewCodec() RegisterBaseAccount(cdc) mapper := NewAccountMapper(cdc, capKey, &BaseAccount{}) - anteHandler := NewAnteHandler(mapper, nopFeeHandler) + anteHandler := NewAnteHandler(mapper, BurnFeeHandler) ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil) // keys and addresses @@ -182,7 +179,7 @@ func TestAnteHandlerFees(t *testing.T) { cdc := wire.NewCodec() RegisterBaseAccount(cdc) mapper := NewAccountMapper(cdc, capKey, &BaseAccount{}) - anteHandler := NewAnteHandler(mapper, nopFeeHandler) + anteHandler := NewAnteHandler(mapper, BurnFeeHandler) ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil) // keys and addresses @@ -219,7 +216,7 @@ func TestAnteHandlerBadSignBytes(t *testing.T) { cdc := wire.NewCodec() RegisterBaseAccount(cdc) mapper := NewAccountMapper(cdc, capKey, &BaseAccount{}) - anteHandler := NewAnteHandler(mapper, nopFeeHandler) + anteHandler := NewAnteHandler(mapper, BurnFeeHandler) ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil) // keys and addresses @@ -294,7 +291,7 @@ func TestAnteHandlerSetPubKey(t *testing.T) { cdc := wire.NewCodec() RegisterBaseAccount(cdc) mapper := NewAccountMapper(cdc, capKey, &BaseAccount{}) - anteHandler := NewAnteHandler(mapper, nopFeeHandler) + anteHandler := NewAnteHandler(mapper, BurnFeeHandler) ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil) // keys and addresses