2018-01-24 11:47:51 -08:00
|
|
|
package baseapp
|
|
|
|
|
2018-02-08 20:33:42 -08:00
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
2018-01-24 11:47:51 -08:00
|
|
|
|
2018-01-29 04:55:28 -08:00
|
|
|
// NewContext returns a new Context suitable for AnteHandler (and indirectly Handler) processing.
|
2018-01-26 04:19:33 -08:00
|
|
|
// NOTE: txBytes may be nil to support TestApp.RunCheckTx
|
|
|
|
// and TestApp.RunDeliverTx.
|
2018-01-29 04:55:28 -08:00
|
|
|
func (app *BaseApp) NewContext(isCheckTx bool, txBytes []byte) sdk.Context {
|
2018-01-24 11:47:51 -08:00
|
|
|
var store sdk.MultiStore
|
|
|
|
if isCheckTx {
|
|
|
|
store = app.msCheck
|
|
|
|
} else {
|
|
|
|
store = app.msDeliver
|
|
|
|
}
|
2018-02-08 20:33:42 -08:00
|
|
|
|
2018-01-24 12:11:14 -08:00
|
|
|
if store == nil {
|
|
|
|
panic("BaseApp.NewContext() requires BeginBlock(): missing store")
|
|
|
|
}
|
|
|
|
if app.header == nil {
|
|
|
|
panic("BaseApp.NewContext() requires BeginBlock(): missing header")
|
|
|
|
}
|
2018-01-24 11:47:51 -08:00
|
|
|
|
|
|
|
// Initialize arguments to Handler.
|
|
|
|
var ctx = sdk.NewContext(
|
|
|
|
store,
|
2018-01-24 12:11:14 -08:00
|
|
|
*app.header,
|
2018-01-24 11:47:51 -08:00
|
|
|
isCheckTx,
|
|
|
|
txBytes,
|
|
|
|
)
|
|
|
|
return ctx
|
|
|
|
}
|