Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/genutil: remove alias.go usage #6433

Merged
merged 2 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion simapp/cmd/simd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion simapp/cmd/simd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
36 changes: 0 additions & 36 deletions x/genutil/alias.go

This file was deleted.

2 changes: 1 addition & 1 deletion x/genutil/client/cli/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions x/genutil/client/cli/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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]
}

Expand Down Expand Up @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions x/genutil/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion x/genutil/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions x/genutil/gentx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions x/genutil/legacy/v0_36/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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"
v036staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_36"
)

// 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)
Expand Down
6 changes: 3 additions & 3 deletions x/genutil/legacy/v0_36/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand Down Expand Up @@ -86,7 +86,7 @@ var basic034Gov = []byte(`
`)

func TestDummyGenesis(t *testing.T) {
genesisDummy := genutil.AppMap{
genesisDummy := types.AppMap{
"foo": {},
"bar": []byte(`{"custom": "module"}`),
}
Expand All @@ -98,7 +98,7 @@ func TestDummyGenesis(t *testing.T) {
}

func TestGovGenesis(t *testing.T) {
genesis := genutil.AppMap{
genesis := types.AppMap{
"gov": basic034Gov,
}

Expand Down
4 changes: 2 additions & 2 deletions x/genutil/legacy/v0_38/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions x/genutil/legacy/v0_38/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions x/genutil/legacy/v0_39/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions x/genutil/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down