2020-04-01 18:49:21 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
|
|
dbm "github.com/tendermint/tm-db"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Setup initializes a new EthermintApp. A Nop logger is set in EthermintApp.
|
|
|
|
func Setup(isCheckTx bool) *EthermintApp {
|
|
|
|
db := dbm.NewMemDB()
|
|
|
|
app := NewEthermintApp(log.NewNopLogger(), db, nil, true, 0)
|
2020-04-17 22:32:01 +00:00
|
|
|
|
2020-04-01 18:49:21 +00:00
|
|
|
if !isCheckTx {
|
|
|
|
// init chain must be called to stop deliverState from being nil
|
2020-04-17 22:32:01 +00:00
|
|
|
genesisState := NewDefaultGenesisState()
|
2020-04-01 18:49:21 +00:00
|
|
|
stateBytes, err := codec.MarshalJSONIndent(app.Codec(), genesisState)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the chain
|
|
|
|
app.InitChain(
|
|
|
|
abci.RequestInitChain{
|
|
|
|
Validators: []abci.ValidatorUpdate{},
|
|
|
|
AppStateBytes: stateBytes,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return app
|
|
|
|
}
|