Make code clearer by setting things to app
This commit is contained in:
parent
2246a9c68b
commit
d9e4b32004
|
@ -15,6 +15,7 @@ const appName = "BasecoinApp"
|
|||
|
||||
type BasecoinApp struct {
|
||||
*bam.BaseApp
|
||||
router bam.Router
|
||||
cdc *wire.Codec
|
||||
multiStore sdk.CommitMultiStore
|
||||
|
||||
|
|
|
@ -7,12 +7,14 @@ import (
|
|||
|
||||
// initCapKeys, initBaseApp, initStores, initHandlers.
|
||||
func (app *BasecoinApp) initBaseApp() {
|
||||
app.BaseApp = baseapp.NewBaseApp(appName)
|
||||
bapp := baseapp.NewBaseApp(appName)
|
||||
app.BaseApp = bapp
|
||||
app.router = bapp.Router()
|
||||
app.initBaseAppTxDecoder()
|
||||
}
|
||||
|
||||
func (app *BasecoinApp) initBaseAppTxDecoder() {
|
||||
var cdc = makeTxCodec()
|
||||
cdc := makeTxCodec()
|
||||
app.BaseApp.SetTxDecoder(func(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||
var tx = sdk.StdTx{}
|
||||
// StdTx.Msg is an interface whose concrete
|
||||
|
|
|
@ -12,15 +12,17 @@ func (app *BasecoinApp) initHandlers() {
|
|||
}
|
||||
|
||||
func (app *BasecoinApp) initDefaultAnteHandler() {
|
||||
var authAnteHandler = auth.NewAnteHandler(app.accountMapper)
|
||||
app.BaseApp.SetDefaultAnteHandler(authAnteHandler)
|
||||
|
||||
// Deducts fee from payer.
|
||||
// Verifies signatures and nonces.
|
||||
// Sets Signers to ctx.
|
||||
app.BaseApp.SetDefaultAnteHandler(
|
||||
auth.NewAnteHandler(app.accountMapper))
|
||||
}
|
||||
|
||||
func (app *BasecoinApp) initRouterHandlers() {
|
||||
var router = app.BaseApp.Router()
|
||||
var accountMapper = app.accountMapper
|
||||
|
||||
// All handlers must be added here.
|
||||
// The order matters.
|
||||
router.AddRoute("bank", bank.NewHandler(accountMapper))
|
||||
app.router.AddRoute("bank", bank.NewHandler(app.accountMapper))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue