update app and cmd

This commit is contained in:
rhuairahrighairigh 2019-09-25 15:50:03 -04:00
parent d060b4145f
commit 3bf82e9ee9
5 changed files with 15 additions and 40 deletions

View File

@ -224,9 +224,12 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
// genutils must occur after staking so that pools are properly
// initialized with tokens from genesis accounts.
app.mm.SetOrderInitGenesis(auth.ModuleName, distr.ModuleName,
staking.ModuleName, auth.ModuleName, bank.ModuleName, slashing.ModuleName,
gov.ModuleName, mint.ModuleName, supply.ModuleName, crisis.ModuleName, genutil.ModuleName)
// TODO should auth be first?
app.mm.SetOrderInitGenesis(
auth.ModuleName, distr.ModuleName,
staking.ModuleName, bank.ModuleName, slashing.ModuleName,
gov.ModuleName, mint.ModuleName, supply.ModuleName, crisis.ModuleName, genutil.ModuleName,
)
app.mm.RegisterInvariants(&app.crisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter())

View File

@ -2,9 +2,6 @@ package app
import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/exported"
)
// GenesisState represents the genesis state of the blockchain. It is a map from module names to module genesis states.
@ -14,22 +11,3 @@ type GenesisState map[string]json.RawMessage
func NewDefaultGenesisState() GenesisState {
return ModuleBasics.DefaultGenesis()
}
// TODO remove iterator once merged into sdk master
type GenesisAccountIterator struct{}
// IterateGenesisAccounts iterates over all the genesis accounts found in
// appGenesis and invokes a callback on each genesis account. If any call
// returns true, iteration stops.
func (GenesisAccountIterator) IterateGenesisAccounts(
cdc *codec.Codec, appGenesis map[string]json.RawMessage, cb func(exported.Account) (stop bool),
) {
var authGenState auth.GenesisState
cdc.MustUnmarshalJSON(appGenesis[auth.ModuleName], &authGenState)
for _, genAcc := range authGenState.Accounts {
if cb(genAcc) {
break
}
}
}

View File

@ -34,6 +34,7 @@ func main() {
cdc := app.MakeCodec()
// Read in the configuration file for the sdk
// TODO check there is no issue with `kvcli keys parse`
config := sdk.GetConfig()
app.SetBech32AddressPrefixes(config)
config.Seal()
@ -115,6 +116,7 @@ func txCmd(cdc *amino.Codec) *cobra.Command {
client.LineBreak,
authcmd.GetBroadcastCommand(cdc),
authcmd.GetEncodeCommand(cdc),
authcmd.GetDecodeCommand(cdc),
client.LineBreak,
)

View File

@ -104,24 +104,15 @@ func AddGenesisAccountCmd(
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
}
// authGenState := auth.GetGenesisStateFromAppState(cdc, appState)
// TODO replace 2 following lines with above once sdk updated
var authGenState auth.GenesisState
cdc.MustUnmarshalJSON(appState[auth.ModuleName], &authGenState)
// if authGenState.Accounts.Contains(addr) {
// TODO replace loop below with above once sdk is updated
for _, acc := range authGenState.Accounts {
if acc.GetAddress().Equals(addr) {
return fmt.Errorf("cannot add account at existing address %s", addr)
}
authGenState := auth.GetGenesisStateFromAppState(cdc, appState)
if authGenState.Accounts.Contains(addr) {
return fmt.Errorf("cannot add account at existing address %s", addr)
}
// Add the new account to the set of genesis accounts and sanitize the
// accounts afterwards.
authGenState.Accounts = append(authGenState.Accounts, genAccount)
// TODO uncomment following line once merged into master
// authGenState.Accounts = auth.SanitizeGenesisAccounts(authGenState.Accounts)
authGenState.Accounts = auth.SanitizeGenesisAccounts(authGenState.Accounts)
authGenStateBz, err := cdc.MarshalJSON(authGenState)
if err != nil {

View File

@ -20,6 +20,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/kava-labs/kava/app"
)
@ -45,14 +46,14 @@ func main() {
}
rootCmd.AddCommand(genutilcli.InitCmd(ctx, cdc, app.ModuleBasics, app.DefaultNodeHome))
rootCmd.AddCommand(genutilcli.CollectGenTxsCmd(ctx, cdc, app.GenesisAccountIterator{}, app.DefaultNodeHome))
rootCmd.AddCommand(genutilcli.CollectGenTxsCmd(ctx, cdc, auth.GenesisAccountIterator{}, app.DefaultNodeHome))
rootCmd.AddCommand(genutilcli.MigrateGenesisCmd(ctx, cdc))
rootCmd.AddCommand(genutilcli.GenTxCmd(
ctx,
cdc,
app.ModuleBasics,
staking.AppModuleBasic{},
app.GenesisAccountIterator{},
auth.GenesisAccountIterator{},
app.DefaultNodeHome,
app.DefaultCLIHome))
rootCmd.AddCommand(genutilcli.ValidateGenesisCmd(ctx, cdc, app.ModuleBasics))