mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-25 15:55:18 +00:00
update app and cmd
This commit is contained in:
parent
d060b4145f
commit
3bf82e9ee9
@ -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
|
// genutils must occur after staking so that pools are properly
|
||||||
// initialized with tokens from genesis accounts.
|
// initialized with tokens from genesis accounts.
|
||||||
app.mm.SetOrderInitGenesis(auth.ModuleName, distr.ModuleName,
|
// TODO should auth be first?
|
||||||
staking.ModuleName, auth.ModuleName, bank.ModuleName, slashing.ModuleName,
|
app.mm.SetOrderInitGenesis(
|
||||||
gov.ModuleName, mint.ModuleName, supply.ModuleName, crisis.ModuleName, genutil.ModuleName)
|
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.RegisterInvariants(&app.crisisKeeper)
|
||||||
app.mm.RegisterRoutes(app.Router(), app.QueryRouter())
|
app.mm.RegisterRoutes(app.Router(), app.QueryRouter())
|
||||||
|
@ -2,9 +2,6 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"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.
|
// 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 {
|
func NewDefaultGenesisState() GenesisState {
|
||||||
return ModuleBasics.DefaultGenesis()
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -34,6 +34,7 @@ func main() {
|
|||||||
cdc := app.MakeCodec()
|
cdc := app.MakeCodec()
|
||||||
|
|
||||||
// Read in the configuration file for the sdk
|
// Read in the configuration file for the sdk
|
||||||
|
// TODO check there is no issue with `kvcli keys parse`
|
||||||
config := sdk.GetConfig()
|
config := sdk.GetConfig()
|
||||||
app.SetBech32AddressPrefixes(config)
|
app.SetBech32AddressPrefixes(config)
|
||||||
config.Seal()
|
config.Seal()
|
||||||
@ -115,6 +116,7 @@ func txCmd(cdc *amino.Codec) *cobra.Command {
|
|||||||
client.LineBreak,
|
client.LineBreak,
|
||||||
authcmd.GetBroadcastCommand(cdc),
|
authcmd.GetBroadcastCommand(cdc),
|
||||||
authcmd.GetEncodeCommand(cdc),
|
authcmd.GetEncodeCommand(cdc),
|
||||||
|
authcmd.GetDecodeCommand(cdc),
|
||||||
client.LineBreak,
|
client.LineBreak,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -104,24 +104,15 @@ func AddGenesisAccountCmd(
|
|||||||
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
|
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// authGenState := auth.GetGenesisStateFromAppState(cdc, appState)
|
authGenState := auth.GetGenesisStateFromAppState(cdc, appState)
|
||||||
// TODO replace 2 following lines with above once sdk updated
|
if authGenState.Accounts.Contains(addr) {
|
||||||
var authGenState auth.GenesisState
|
return fmt.Errorf("cannot add account at existing address %s", addr)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new account to the set of genesis accounts and sanitize the
|
// Add the new account to the set of genesis accounts and sanitize the
|
||||||
// accounts afterwards.
|
// accounts afterwards.
|
||||||
authGenState.Accounts = append(authGenState.Accounts, genAccount)
|
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)
|
authGenStateBz, err := cdc.MarshalJSON(authGenState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/app"
|
"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.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.MigrateGenesisCmd(ctx, cdc))
|
||||||
rootCmd.AddCommand(genutilcli.GenTxCmd(
|
rootCmd.AddCommand(genutilcli.GenTxCmd(
|
||||||
ctx,
|
ctx,
|
||||||
cdc,
|
cdc,
|
||||||
app.ModuleBasics,
|
app.ModuleBasics,
|
||||||
staking.AppModuleBasic{},
|
staking.AppModuleBasic{},
|
||||||
app.GenesisAccountIterator{},
|
auth.GenesisAccountIterator{},
|
||||||
app.DefaultNodeHome,
|
app.DefaultNodeHome,
|
||||||
app.DefaultCLIHome))
|
app.DefaultCLIHome))
|
||||||
rootCmd.AddCommand(genutilcli.ValidateGenesisCmd(ctx, cdc, app.ModuleBasics))
|
rootCmd.AddCommand(genutilcli.ValidateGenesisCmd(ctx, cdc, app.ModuleBasics))
|
||||||
|
Loading…
Reference in New Issue
Block a user