x/genutil: remove alias.go usage (#6433)
This commit is contained in:
parent
e07c1e20bc
commit
c3ff8c0c06
|
@ -25,6 +25,7 @@ import (
|
|||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
transfer "github.com/cosmos/cosmos-sdk/x/ibc-transfer"
|
||||
|
@ -309,7 +310,7 @@ func NewSimApp(
|
|||
app.mm.SetOrderInitGenesis(
|
||||
capability.ModuleName, auth.ModuleName, distr.ModuleName, stakingtypes.ModuleName, bank.ModuleName,
|
||||
slashingtypes.ModuleName, gov.ModuleName, minttypes.ModuleName, crisis.ModuleName,
|
||||
ibc.ModuleName, genutil.ModuleName, evidence.ModuleName, transfer.ModuleName,
|
||||
ibc.ModuleName, genutiltypes.ModuleName, evidence.ModuleName, transfer.ModuleName,
|
||||
)
|
||||
|
||||
app.mm.RegisterInvariants(&app.CrisisKeeper)
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -116,7 +117,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
|
|||
}
|
||||
|
||||
genFile := config.GenesisFile()
|
||||
appState, genDoc, err := genutil.GenesisStateFromGenFile(depCdc, genFile)
|
||||
appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(depCdc, genFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
|
@ -317,7 +318,7 @@ func collectGenFiles(
|
|||
config.SetRoot(nodeDir)
|
||||
|
||||
nodeID, valPubKey := nodeIDs[i], valPubKeys[i]
|
||||
initCfg := genutil.NewInitConfig(chainID, gentxsDir, moniker, nodeID, valPubKey)
|
||||
initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, moniker, nodeID, valPubKey)
|
||||
|
||||
genDoc, err := types.GenesisDocFromFile(config.GenesisFile())
|
||||
if err != nil {
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package genutil
|
||||
|
||||
// autogenerated code using github.com/rigelrozanski/multitool
|
||||
// aliases generated for the following subdirectories:
|
||||
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/genutil/types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
const (
|
||||
ModuleName = types.ModuleName
|
||||
)
|
||||
|
||||
var (
|
||||
// functions aliases
|
||||
NewGenesisState = types.NewGenesisState
|
||||
NewGenesisStateFromStdTx = types.NewGenesisStateFromStdTx
|
||||
NewInitConfig = types.NewInitConfig
|
||||
GetGenesisStateFromAppState = types.GetGenesisStateFromAppState
|
||||
SetGenesisStateInAppState = types.SetGenesisStateInAppState
|
||||
GenesisStateFromGenDoc = types.GenesisStateFromGenDoc
|
||||
GenesisStateFromGenFile = types.GenesisStateFromGenFile
|
||||
ValidateGenesis = types.ValidateGenesis
|
||||
|
||||
// variable aliases
|
||||
ModuleCdc = types.ModuleCdc
|
||||
)
|
||||
|
||||
type (
|
||||
GenesisState = types.GenesisState
|
||||
AppMap = types.AppMap
|
||||
MigrationCallback = types.MigrationCallback
|
||||
MigrationMap = types.MigrationMap
|
||||
InitConfig = types.InitConfig
|
||||
)
|
|
@ -44,7 +44,7 @@ func CollectGenTxsCmd(ctx *server.Context, cdc codec.JSONMarshaler, genBalIterat
|
|||
}
|
||||
|
||||
toPrint := newPrintInfo(config.Moniker, genDoc.ChainID, nodeID, genTxsDir, json.RawMessage(""))
|
||||
initCfg := genutil.NewInitConfig(genDoc.ChainID, genTxsDir, name, nodeID, valPubKey)
|
||||
initCfg := types.NewInitConfig(genDoc.ChainID, genTxsDir, name, nodeID, valPubKey)
|
||||
|
||||
appMessage, err := genutil.GenAppStateFromConfig(cdc, config, initCfg, *genDoc, genBalIterator)
|
||||
if err != nil {
|
||||
|
|
|
@ -7,16 +7,16 @@ import (
|
|||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
extypes "github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
v036 "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v0_36"
|
||||
v038 "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v0_38"
|
||||
v039 "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v0_39"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -27,14 +27,14 @@ const (
|
|||
// Allow applications to extend and modify the migration process.
|
||||
//
|
||||
// Ref: https://github.com/cosmos/cosmos-sdk/issues/5041
|
||||
var migrationMap = extypes.MigrationMap{
|
||||
var migrationMap = types.MigrationMap{
|
||||
"v0.36": v036.Migrate,
|
||||
"v0.38": v038.Migrate, // NOTE: v0.37 and v0.38 are genesis compatible
|
||||
"v0.39": v039.Migrate,
|
||||
}
|
||||
|
||||
// GetMigrationCallback returns a MigrationCallback for a given version.
|
||||
func GetMigrationCallback(version string) extypes.MigrationCallback {
|
||||
func GetMigrationCallback(version string) types.MigrationCallback {
|
||||
return migrationMap[version]
|
||||
}
|
||||
|
||||
|
@ -71,12 +71,12 @@ $ %s migrate v0.36 /path/to/genesis.json --chain-id=cosmoshub-3 --genesis-time=2
|
|||
target := args[0]
|
||||
importGenesis := args[1]
|
||||
|
||||
genDoc, err := types.GenesisDocFromFile(importGenesis)
|
||||
genDoc, err := tmtypes.GenesisDocFromFile(importGenesis)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to read genesis document from file %s", importGenesis)
|
||||
}
|
||||
|
||||
var initialState extypes.AppMap
|
||||
var initialState types.AppMap
|
||||
if err := cdc.UnmarshalJSON(genDoc.AppState, &initialState); err != nil {
|
||||
return errors.Wrap(err, "failed to JSON unmarshal initial genesis state")
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
|
||||
// GenAppStateFromConfig gets the genesis app state from the config
|
||||
func GenAppStateFromConfig(cdc codec.JSONMarshaler, config *cfg.Config,
|
||||
initCfg InitConfig, genDoc tmtypes.GenesisDoc, genBalIterator types.GenesisBalancesIterator,
|
||||
initCfg types.InitConfig, genDoc tmtypes.GenesisDoc, genBalIterator types.GenesisBalancesIterator,
|
||||
) (appState json.RawMessage, err error) {
|
||||
|
||||
// process genesis transactions, else create default genesis.json
|
||||
|
@ -45,7 +45,7 @@ func GenAppStateFromConfig(cdc codec.JSONMarshaler, config *cfg.Config,
|
|||
}
|
||||
|
||||
// create the app state
|
||||
appGenesisState, err := GenesisStateFromGenDoc(cdc, genDoc)
|
||||
appGenesisState, err := types.GenesisStateFromGenDoc(cdc, genDoc)
|
||||
if err != nil {
|
||||
return appState, err
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
// InitGenesis - initialize accounts and deliver genesis transactions
|
||||
func InitGenesis(
|
||||
ctx sdk.Context, cdc *codec.Codec, stakingKeeper types.StakingKeeper,
|
||||
deliverTx deliverTxfn, genesisState GenesisState,
|
||||
deliverTx deliverTxfn, genesisState types.GenesisState,
|
||||
) []abci.ValidatorUpdate {
|
||||
|
||||
var validators []abci.ValidatorUpdate
|
||||
|
|
|
@ -21,7 +21,7 @@ func SetGenTxsInAppGenesisState(
|
|||
cdc codec.JSONMarshaler, appGenesisState map[string]json.RawMessage, genTxs []authtypes.StdTx,
|
||||
) (map[string]json.RawMessage, error) {
|
||||
|
||||
genesisState := GetGenesisStateFromAppState(cdc, appGenesisState)
|
||||
genesisState := types.GetGenesisStateFromAppState(cdc, appGenesisState)
|
||||
genTxsBz := make([]json.RawMessage, 0, len(genTxs))
|
||||
|
||||
for _, genTx := range genTxs {
|
||||
|
@ -34,7 +34,7 @@ func SetGenTxsInAppGenesisState(
|
|||
}
|
||||
|
||||
genesisState.GenTxs = genTxsBz
|
||||
return SetGenesisStateInAppState(cdc, appGenesisState, genesisState), nil
|
||||
return types.SetGenesisStateInAppState(cdc, appGenesisState, genesisState), nil
|
||||
}
|
||||
|
||||
// ValidateAccountInGenesis checks that the provided account has a sufficient
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
v036distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_36"
|
||||
v034genAccounts "github.com/cosmos/cosmos-sdk/x/genaccounts/legacy/v0_34"
|
||||
v036genAccounts "github.com/cosmos/cosmos-sdk/x/genaccounts/legacy/v0_36"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
v034gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v0_34"
|
||||
v036gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v0_36"
|
||||
v034staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_34"
|
||||
|
@ -18,7 +18,7 @@ import (
|
|||
)
|
||||
|
||||
// Migrate migrates exported state from v0.34 to a v0.36 genesis state.
|
||||
func Migrate(appState genutil.AppMap) genutil.AppMap {
|
||||
func Migrate(appState types.AppMap) types.AppMap {
|
||||
v034Codec := codec.New()
|
||||
cryptocodec.RegisterCrypto(v034Codec)
|
||||
v034gov.RegisterCodec(v034Codec)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
var basic034Gov = []byte(`
|
||||
|
@ -86,7 +86,7 @@ var basic034Gov = []byte(`
|
|||
`)
|
||||
|
||||
func TestDummyGenesis(t *testing.T) {
|
||||
genesisDummy := genutil.AppMap{
|
||||
genesisDummy := types.AppMap{
|
||||
"foo": {},
|
||||
"bar": []byte(`{"custom": "module"}`),
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ func TestDummyGenesis(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGovGenesis(t *testing.T) {
|
||||
genesis := genutil.AppMap{
|
||||
genesis := types.AppMap{
|
||||
"gov": basic034Gov,
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
v036distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_36"
|
||||
v038distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_38"
|
||||
v036genaccounts "github.com/cosmos/cosmos-sdk/x/genaccounts/legacy/v0_36"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
v036staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_36"
|
||||
v038staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_38"
|
||||
)
|
||||
|
||||
// Migrate migrates exported state from v0.36/v0.37 to a v0.38 genesis state.
|
||||
func Migrate(appState genutil.AppMap) genutil.AppMap {
|
||||
func Migrate(appState types.AppMap) types.AppMap {
|
||||
v036Codec := codec.New()
|
||||
cryptocodec.RegisterCrypto(v036Codec)
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
|
||||
v036auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v0_36"
|
||||
v036genaccounts "github.com/cosmos/cosmos-sdk/x/genaccounts/legacy/v0_36"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
v038 "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v0_38"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
v036staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_36"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -132,7 +132,7 @@ var genStakingState = []byte(`{
|
|||
}`)
|
||||
|
||||
func TestMigrate(t *testing.T) {
|
||||
genesis := genutil.AppMap{
|
||||
genesis := types.AppMap{
|
||||
v036auth.ModuleName: genAuthState,
|
||||
v036genaccounts.ModuleName: genAccountsState,
|
||||
v036staking.ModuleName: genStakingState,
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v0_39"
|
||||
v038bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v0_38"
|
||||
v039bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v0_39"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
func Migrate(appState genutil.AppMap) genutil.AppMap {
|
||||
func Migrate(appState types.AppMap) types.AppMap {
|
||||
v038Codec := codec.New()
|
||||
cryptocodec.RegisterCrypto(v038Codec)
|
||||
v038auth.RegisterCodec(v038Codec)
|
||||
|
|
|
@ -26,7 +26,7 @@ type AppModuleBasic struct{}
|
|||
|
||||
// Name returns the genutil module's name.
|
||||
func (AppModuleBasic) Name() string {
|
||||
return ModuleName
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// RegisterCodec registers the genutil module's types for the given codec.
|
||||
|
@ -40,12 +40,12 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage {
|
|||
|
||||
// ValidateGenesis performs genesis state validation for the genutil module.
|
||||
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) error {
|
||||
var data GenesisState
|
||||
var data types.GenesisState
|
||||
if err := cdc.UnmarshalJSON(bz, &data); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", ModuleName, err)
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
|
||||
}
|
||||
|
||||
return ValidateGenesis(data)
|
||||
return types.ValidateGenesis(data)
|
||||
}
|
||||
|
||||
// RegisterRESTRoutes registers the REST routes for the genutil module.
|
||||
|
@ -83,9 +83,9 @@ func NewAppModule(accountKeeper types.AccountKeeper,
|
|||
// InitGenesis performs genesis initialization for the genutil module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genesisState GenesisState
|
||||
var genesisState types.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
return InitGenesis(ctx, ModuleCdc, am.stakingKeeper, am.deliverTx, genesisState)
|
||||
return InitGenesis(ctx, types.ModuleCdc, am.stakingKeeper, am.deliverTx, genesisState)
|
||||
}
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the genutil
|
||||
|
|
Loading…
Reference in New Issue