From 518f2760cfbbb027253120d9a97412f3882fd6f4 Mon Sep 17 00:00:00 2001 From: DauTT Date: Sat, 13 Jun 2020 23:26:48 +0200 Subject: [PATCH 1/6] x/auth: remove alias.go usage --- simapp/app.go | 38 ++++++----- simapp/cmd/simd/genaccounts.go | 13 ++-- simapp/cmd/simd/testnet.go | 13 ++-- simapp/genesis_account.go | 3 +- simapp/helpers/test_helpers.go | 14 ++-- simapp/sim_test.go | 4 +- simapp/state.go | 8 +-- simapp/test_helpers.go | 12 ++-- simapp/utils_test.go | 8 +-- tests/cli/helpers.go | 6 +- x/auth/alias.go | 99 ---------------------------- x/auth/genesis.go | 11 ++-- x/auth/keeper/keeper_test.go | 10 +-- x/auth/module.go | 37 ++++++----- x/auth/module_test.go | 10 +-- x/auth/signing/amino/amino_test.go | 8 +-- x/bank/app_test.go | 29 ++++---- x/bank/bench_test.go | 10 +-- x/bank/client/testutil/helpers.go | 6 +- x/bank/keeper/keeper.go | 10 +-- x/bank/keeper/keeper_test.go | 97 +++++++++++++-------------- x/distribution/keeper/common_test.go | 4 +- x/distribution/module_test.go | 4 +- x/evidence/keeper/keeper_test.go | 4 +- x/genutil/client/cli/gentx.go | 12 ++-- x/gov/genesis_test.go | 3 +- x/gov/module_test.go | 4 +- x/mint/module_test.go | 4 +- x/slashing/app_test.go | 3 +- x/staking/app_test.go | 8 +-- x/staking/client/cli/tx.go | 4 +- x/staking/module_test.go | 6 +- 32 files changed, 202 insertions(+), 300 deletions(-) delete mode 100644 x/auth/alias.go diff --git a/simapp/app.go b/simapp/app.go index 8b090a74f11a..2382ce1ea858 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -19,6 +19,8 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/capability" "github.com/cosmos/cosmos-sdk/x/crisis" @@ -89,13 +91,13 @@ var ( // module account permissions maccPerms = map[string][]string{ - auth.FeeCollectorName: nil, + authtypes.FeeCollectorName: nil, distr.ModuleName: nil, - minttypes.ModuleName: {auth.Minter}, - stakingtypes.BondedPoolName: {auth.Burner, auth.Staking}, - stakingtypes.NotBondedPoolName: {auth.Burner, auth.Staking}, - govtypes.ModuleName: {auth.Burner}, - transfer.ModuleName: {auth.Minter, auth.Burner}, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + transfer.ModuleName: {authtypes.Minter, authtypes.Burner}, } // module accounts that are allowed to receive tokens @@ -125,7 +127,7 @@ type SimApp struct { subspaces map[string]paramstypes.Subspace // keepers - AccountKeeper auth.AccountKeeper + AccountKeeper authkeeper.AccountKeeper BankKeeper bank.Keeper CapabilityKeeper *capability.Keeper StakingKeeper stakingkeeper.Keeper @@ -160,12 +162,12 @@ func NewSimApp( // TODO: Remove cdc in favor of appCodec once all modules are migrated. appCodec, cdc := MakeCodecs() - bApp := baseapp.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...) + bApp := baseapp.NewBaseApp(appName, logger, db, authtypes.DefaultTxDecoder(cdc), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetAppVersion(version.Version) keys := sdk.NewKVStoreKeys( - auth.StoreKey, bank.StoreKey, stakingtypes.StoreKey, + authtypes.StoreKey, bank.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distr.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, evidence.StoreKey, transfer.StoreKey, capability.StoreKey, @@ -186,7 +188,7 @@ func NewSimApp( // init params keeper and subspaces app.ParamsKeeper = paramskeeper.NewKeeper(appCodec, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) - app.subspaces[auth.ModuleName] = app.ParamsKeeper.Subspace(auth.DefaultParamspace) + app.subspaces[authtypes.ModuleName] = app.ParamsKeeper.Subspace(authtypes.DefaultParamspace) app.subspaces[bank.ModuleName] = app.ParamsKeeper.Subspace(bank.DefaultParamspace) app.subspaces[stakingtypes.ModuleName] = app.ParamsKeeper.Subspace(stakingkeeper.DefaultParamspace) app.subspaces[minttypes.ModuleName] = app.ParamsKeeper.Subspace(minttypes.DefaultParamspace) @@ -204,8 +206,8 @@ func NewSimApp( scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(transfer.ModuleName) // add keepers - app.AccountKeeper = auth.NewAccountKeeper( - appCodec, keys[auth.StoreKey], app.subspaces[auth.ModuleName], auth.ProtoBaseAccount, maccPerms, + app.AccountKeeper = authkeeper.NewAccountKeeper( + appCodec, keys[authtypes.StoreKey], app.subspaces[authtypes.ModuleName], authtypes.ProtoBaseAccount, maccPerms, ) app.BankKeeper = bank.NewBaseKeeper( appCodec, keys[bank.StoreKey], app.AccountKeeper, app.subspaces[bank.ModuleName], app.BlacklistedAccAddrs(), @@ -215,17 +217,17 @@ func NewSimApp( ) app.MintKeeper = mintkeeper.NewKeeper( appCodec, keys[minttypes.StoreKey], app.subspaces[minttypes.ModuleName], &stakingKeeper, - app.AccountKeeper, app.BankKeeper, auth.FeeCollectorName, + app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, ) app.DistrKeeper = distr.NewKeeper( appCodec, keys[distr.StoreKey], app.subspaces[distr.ModuleName], app.AccountKeeper, app.BankKeeper, - &stakingKeeper, auth.FeeCollectorName, app.ModuleAccountAddrs(), + &stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), ) app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.subspaces[slashingtypes.ModuleName], ) app.CrisisKeeper = crisis.NewKeeper( - app.subspaces[crisis.ModuleName], invCheckPeriod, app.BankKeeper, auth.FeeCollectorName, + app.subspaces[crisis.ModuleName], invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, ) app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath) @@ -312,7 +314,7 @@ func NewSimApp( // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. app.mm.SetOrderInitGenesis( - capability.ModuleName, auth.ModuleName, distr.ModuleName, stakingtypes.ModuleName, bank.ModuleName, + capability.ModuleName, authtypes.ModuleName, distr.ModuleName, stakingtypes.ModuleName, bank.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisis.ModuleName, ibchost.ModuleName, genutiltypes.ModuleName, evidence.ModuleName, transfer.ModuleName, ) @@ -421,7 +423,7 @@ func (app *SimApp) LoadHeight(height int64) error { func (app *SimApp) ModuleAccountAddrs() map[string]bool { modAccAddrs := make(map[string]bool) for acc := range maccPerms { - modAccAddrs[auth.NewModuleAddress(acc).String()] = true + modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true } return modAccAddrs @@ -431,7 +433,7 @@ func (app *SimApp) ModuleAccountAddrs() map[string]bool { func (app *SimApp) BlacklistedAccAddrs() map[string]bool { blacklistedAddrs := make(map[string]bool) for acc := range maccPerms { - blacklistedAddrs[auth.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc] + blacklistedAddrs[authtypes.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc] } return blacklistedAddrs diff --git a/simapp/cmd/simd/genaccounts.go b/simapp/cmd/simd/genaccounts.go index d6812e960675..4b94dbda0353 100644 --- a/simapp/cmd/simd/genaccounts.go +++ b/simapp/cmd/simd/genaccounts.go @@ -18,8 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/auth/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -86,10 +85,10 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa } // create concrete account type based on input parameters - var genAccount types.GenesisAccount + var genAccount authtypes.GenesisAccount balances := bank.Balance{Address: addr, Coins: coins.Sort()} - baseAccount := auth.NewBaseAccount(addr, nil, 0, 0) + baseAccount := authtypes.NewBaseAccount(addr, nil, 0, 0) if !vestingAmt.IsZero() { baseVestingAccount := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd) @@ -122,7 +121,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa return fmt.Errorf("failed to unmarshal genesis state: %w", err) } - authGenState := auth.GetGenesisStateFromAppState(cdc, appState) + authGenState := authtypes.GetGenesisStateFromAppState(cdc, appState) if authGenState.Accounts.Contains(addr) { return fmt.Errorf("cannot add account at existing address %s", addr) @@ -131,14 +130,14 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa // Add the new account to the set of genesis accounts and sanitize the // accounts afterwards. authGenState.Accounts = append(authGenState.Accounts, genAccount) - authGenState.Accounts = auth.SanitizeGenesisAccounts(authGenState.Accounts) + authGenState.Accounts = authtypes.SanitizeGenesisAccounts(authGenState.Accounts) authGenStateBz, err := cdc.MarshalJSON(authGenState) if err != nil { return fmt.Errorf("failed to marshal auth genesis state: %w", err) } - appState[auth.ModuleName] = authGenStateBz + appState[authtypes.ModuleName] = authGenStateBz bankGenState := bank.GetGenesisStateFromAppState(depCdc, appState) bankGenState.Balances = append(bankGenState.Balances, balances) diff --git a/simapp/cmd/simd/testnet.go b/simapp/cmd/simd/testnet.go index 048f4850f14b..7c145b855e31 100644 --- a/simapp/cmd/simd/testnet.go +++ b/simapp/cmd/simd/testnet.go @@ -27,7 +27,6 @@ import ( srvconfig "github.com/cosmos/cosmos-sdk/server/config" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/auth" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -204,7 +203,7 @@ func InitTestnet( } genBalances = append(genBalances, bank.Balance{Address: addr, Coins: coins.Sort()}) - genAccounts = append(genAccounts, auth.NewBaseAccount(addr, nil, 0, 0)) + genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) valTokens := sdk.TokensFromConsensusPower(100) msg := stakingtypes.NewMsgCreateValidator( @@ -216,8 +215,8 @@ func InitTestnet( sdk.OneInt(), ) - tx := auth.NewStdTx([]sdk.Msg{msg}, auth.StdFee{}, []auth.StdSignature{}, memo) - txBldr := auth.NewTxBuilderFromCLI(inBuf).WithChainID(chainID).WithMemo(memo).WithKeybase(kb) + tx := authtypes.NewStdTx([]sdk.Msg{msg}, authtypes.StdFee{}, []authtypes.StdSignature{}, memo) + txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithChainID(chainID).WithMemo(memo).WithKeybase(kb) signedTx, err := txBldr.SignStdTx(nodeDirName, tx, false) if err != nil { @@ -265,11 +264,11 @@ func initGenFiles( appGenState := mbm.DefaultGenesis(cdc) // set the accounts in the genesis state - var authGenState auth.GenesisState - cdc.MustUnmarshalJSON(appGenState[auth.ModuleName], &authGenState) + var authGenState authtypes.GenesisState + cdc.MustUnmarshalJSON(appGenState[authtypes.ModuleName], &authGenState) authGenState.Accounts = genAccounts - appGenState[auth.ModuleName] = cdc.MustMarshalJSON(authGenState) + appGenState[authtypes.ModuleName] = cdc.MustMarshalJSON(authGenState) // set the balances in the genesis state var bankGenState bank.GenesisState diff --git a/simapp/genesis_account.go b/simapp/genesis_account.go index 860370057a92..5c9c7f9a03f8 100644 --- a/simapp/genesis_account.go +++ b/simapp/genesis_account.go @@ -4,7 +4,6 @@ import ( "errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -36,7 +35,7 @@ func (sga SimGenesisAccount) Validate() error { } if sga.ModuleName != "" { - ma := auth.ModuleAccount{ + ma := authtypes.ModuleAccount{ BaseAccount: sga.BaseAccount, Name: sga.ModuleName, Permissions: sga.ModulePermissions, } if err := ma.Validate(); err != nil { diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index ff807ff29ece..785de22ec6d2 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // SimAppChainID hardcoded chainID for simulation @@ -18,13 +18,13 @@ const ( ) // GenTx generates a signed mock transaction. -func GenTx(msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accnums []uint64, seq []uint64, priv ...crypto.PrivKey) auth.StdTx { - fee := auth.StdFee{ +func GenTx(msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accnums []uint64, seq []uint64, priv ...crypto.PrivKey) authtypes.StdTx { + fee := authtypes.StdFee{ Amount: feeAmt, Gas: gas, } - sigs := make([]auth.StdSignature, len(priv)) + sigs := make([]authtypes.StdSignature, len(priv)) // create a random length memo r := rand.New(rand.NewSource(time.Now().UnixNano())) @@ -33,16 +33,16 @@ func GenTx(msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accnums for i, p := range priv { // use a empty chainID for ease of testing - sig, err := p.Sign(auth.StdSignBytes(chainID, accnums[i], seq[i], fee, msgs, memo)) + sig, err := p.Sign(authtypes.StdSignBytes(chainID, accnums[i], seq[i], fee, msgs, memo)) if err != nil { panic(err) } - sigs[i] = auth.StdSignature{ + sigs[i] = authtypes.StdSignature{ PubKey: p.PubKey().Bytes(), Signature: sig, } } - return auth.NewStdTx(msgs, fee, sigs, memo) + return authtypes.NewStdTx(msgs, fee, sigs, memo) } diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 48a6ec1c5c1e..1f4c6bfb20ee 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -17,7 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp/helpers" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/capability" distr "github.com/cosmos/cosmos-sdk/x/distribution" @@ -148,7 +148,7 @@ func TestAppImportExport(t *testing.T) { fmt.Printf("comparing stores...\n") storeKeysPrefixes := []StoreKeysPrefixes{ - {app.keys[auth.StoreKey], newApp.keys[auth.StoreKey], [][]byte{}}, + {app.keys[authtypes.StoreKey], newApp.keys[authtypes.StoreKey], [][]byte{}}, {app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], [][]byte{ stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey, diff --git a/simapp/state.go b/simapp/state.go index b4e1b789a015..055a4bd73b03 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -15,7 +15,7 @@ import ( simapparams "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // AppStateFn returns the initial application state using a genesis or the simulation parameters. @@ -137,9 +137,9 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc *codec.Codec, genesisFile string var appState GenesisState cdc.MustUnmarshalJSON(genesis.AppState, &appState) - var authGenesis auth.GenesisState - if appState[auth.ModuleName] != nil { - cdc.MustUnmarshalJSON(appState[auth.ModuleName], &authGenesis) + var authGenesis authtypes.GenesisState + if appState[authtypes.ModuleName] != nil { + cdc.MustUnmarshalJSON(appState[authtypes.ModuleName], &authGenesis) } newAccs := make([]simtypes.Account, len(authGenesis.Accounts)) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 7b17fe743044..6c0113d42e31 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -19,7 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp/helpers" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" ) @@ -69,15 +69,15 @@ func Setup(isCheckTx bool) *SimApp { // SetupWithGenesisAccounts initializes a new SimApp with the provided genesis // accounts and possible balances. -func SetupWithGenesisAccounts(genAccs []auth.GenesisAccount, balances ...bank.Balance) *SimApp { +func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...bank.Balance) *SimApp { db := dbm.NewMemDB() app := NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0) // initialize the chain with the passed in genesis accounts genesisState := NewDefaultGenesisState() - authGenesis := auth.NewGenesisState(auth.DefaultParams(), genAccs) - genesisState[auth.ModuleName] = app.Codec().MustMarshalJSON(authGenesis) + authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) + genesisState[authtypes.ModuleName] = app.Codec().MustMarshalJSON(authGenesis) totalSupply := sdk.NewCoins() for _, b := range balances { @@ -288,8 +288,8 @@ func SignCheckDeliver( // GenSequenceOfTxs generates a set of signed transactions of messages, such // that they differ only by having the sequence numbers incremented between // every transaction. -func GenSequenceOfTxs(msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...crypto.PrivKey) []auth.StdTx { - txs := make([]auth.StdTx, numToGenerate) +func GenSequenceOfTxs(msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...crypto.PrivKey) []authtypes.StdTx { + txs := make([]authtypes.StdTx, numToGenerate) for i := 0; i < numToGenerate; i++ { txs[i] = helpers.GenTx( msgs, diff --git a/simapp/utils_test.go b/simapp/utils_test.go index 45ab3b693ec3..2218e296f7f8 100644 --- a/simapp/utils_test.go +++ b/simapp/utils_test.go @@ -10,14 +10,14 @@ import ( tmkv "github.com/tendermint/tendermint/libs/kv" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) func TestGetSimulationLog(t *testing.T) { cdc := std.MakeCodec(ModuleBasics) decoders := make(sdk.StoreDecoderRegistry) - decoders[auth.StoreKey] = func(kvAs, kvBs tmkv.Pair) string { return "10" } + decoders[authtypes.StoreKey] = func(kvAs, kvBs tmkv.Pair) string { return "10" } tests := []struct { store string @@ -30,8 +30,8 @@ func TestGetSimulationLog(t *testing.T) { "", }, { - auth.StoreKey, - []tmkv.Pair{{Key: auth.GlobalAccountNumberKey, Value: cdc.MustMarshalBinaryBare(uint64(10))}}, + authtypes.StoreKey, + []tmkv.Pair{{Key: authtypes.GlobalAccountNumberKey, Value: cdc.MustMarshalBinaryBare(uint64(10))}}, "10", }, { diff --git a/tests/cli/helpers.go b/tests/cli/helpers.go index 35c5d31b4bc6..72e665b0b818 100644 --- a/tests/cli/helpers.go +++ b/tests/cli/helpers.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/tests" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) var ( @@ -191,7 +191,7 @@ func AddFlags(cmd string, flags []string) string { return strings.TrimSpace(cmd) } -func UnmarshalStdTx(t require.TestingT, c *codec.Codec, s string) (stdTx auth.StdTx) { +func UnmarshalStdTx(t require.TestingT, c *codec.Codec, s string) (stdTx authtypes.StdTx) { require.Nil(t, c.UnmarshalJSON([]byte(s), &stdTx)) return } @@ -200,7 +200,7 @@ func buildEventsQueryString(events []string) string { return strings.Join(events, "&") } -func MarshalStdTx(t require.TestingT, c *codec.Codec, stdTx auth.StdTx) []byte { +func MarshalStdTx(t require.TestingT, c *codec.Codec, stdTx authtypes.StdTx) []byte { bz, err := c.MarshalBinaryBare(stdTx) require.NoError(t, err) diff --git a/x/auth/alias.go b/x/auth/alias.go deleted file mode 100644 index 036100bf885a..000000000000 --- a/x/auth/alias.go +++ /dev/null @@ -1,99 +0,0 @@ -package auth - -import ( - "github.com/cosmos/cosmos-sdk/x/auth/ante" - "github.com/cosmos/cosmos-sdk/x/auth/keeper" - "github.com/cosmos/cosmos-sdk/x/auth/types" -) - -// DONTCOVER -// nolint - -const ( - ModuleName = types.ModuleName - StoreKey = types.StoreKey - FeeCollectorName = types.FeeCollectorName - QuerierRoute = types.QuerierRoute - DefaultParamspace = types.DefaultParamspace - DefaultMaxMemoCharacters = types.DefaultMaxMemoCharacters - DefaultTxSigLimit = types.DefaultTxSigLimit - DefaultTxSizeCostPerByte = types.DefaultTxSizeCostPerByte - DefaultSigVerifyCostED25519 = types.DefaultSigVerifyCostED25519 - DefaultSigVerifyCostSecp256k1 = types.DefaultSigVerifyCostSecp256k1 - QueryAccount = types.QueryAccount - QueryParams = types.QueryParams - MaxGasWanted = types.MaxGasWanted - Minter = types.Minter - Burner = types.Burner - Staking = types.Staking -) - -var ( - // functions aliases - NewAnteHandler = ante.NewAnteHandler - GetSignerAcc = ante.GetSignerAcc - DefaultSigVerificationGasConsumer = ante.DefaultSigVerificationGasConsumer - DeductFees = ante.DeductFees - SetGasMeter = ante.SetGasMeter - NewAccountKeeper = keeper.NewAccountKeeper - NewQuerier = keeper.NewQuerier - NewBaseAccount = types.NewBaseAccount - ProtoBaseAccount = types.ProtoBaseAccount - NewBaseAccountWithAddress = types.NewBaseAccountWithAddress - NewAccountRetriever = types.NewAccountRetriever - RegisterCodec = types.RegisterCodec - NewGenesisState = types.NewGenesisState - DefaultGenesisState = types.DefaultGenesisState - ValidateGenesis = types.ValidateGenesis - SanitizeGenesisAccounts = types.SanitizeGenesisAccounts - AddressStoreKey = types.AddressStoreKey - NewParams = types.NewParams - ParamKeyTable = types.ParamKeyTable - DefaultParams = types.DefaultParams - NewQueryAccountParams = types.NewQueryAccountParams - NewStdTx = types.NewStdTx - CountSubKeys = types.CountSubKeys - NewStdFee = types.NewStdFee //nolint:staticcheck // this will be removed when proto is ready - StdSignBytes = types.StdSignBytes - DefaultTxDecoder = types.DefaultTxDecoder - DefaultTxEncoder = types.DefaultTxEncoder - NewTxBuilder = types.NewTxBuilder - NewTxBuilderFromCLI = types.NewTxBuilderFromCLI - MakeSignature = types.MakeSignature - ValidateGenAccounts = types.ValidateGenAccounts - GetGenesisStateFromAppState = types.GetGenesisStateFromAppState - NewStdSignature = types.NewStdSignature - NewModuleAddress = types.NewModuleAddress - NewEmptyModuleAccount = types.NewEmptyModuleAccount - NewModuleAccount = types.NewModuleAccount - - // variable aliases - AddressStoreKeyPrefix = types.AddressStoreKeyPrefix - GlobalAccountNumberKey = types.GlobalAccountNumberKey - KeyMaxMemoCharacters = types.KeyMaxMemoCharacters - KeyTxSigLimit = types.KeyTxSigLimit - KeyTxSizeCostPerByte = types.KeyTxSizeCostPerByte - KeySigVerifyCostED25519 = types.KeySigVerifyCostED25519 - KeySigVerifyCostSecp256k1 = types.KeySigVerifyCostSecp256k1 -) - -type ( - AccountI = types.AccountI - SignatureVerificationGasConsumer = ante.SignatureVerificationGasConsumer - AccountKeeper = keeper.AccountKeeper - BaseAccount = types.BaseAccount - AccountRetriever = types.AccountRetriever - GenesisState = types.GenesisState - Params = types.Params - QueryAccountParams = types.QueryAccountParams - StdSignMsg = types.StdSignMsg - StdTx = types.StdTx - StdFee = types.StdFee //nolint:staticcheck // this will be removed when proto is ready - StdSignDoc = types.StdSignDoc - StdSignature = types.StdSignature //nolint:staticcheck // this will be removed when proto is ready - TxBuilder = types.TxBuilder - GenesisAccountIterator = types.GenesisAccountIterator - ModuleAccount = types.ModuleAccount - GenesisAccounts = types.GenesisAccounts - GenesisAccount = types.GenesisAccount -) diff --git a/x/auth/genesis.go b/x/auth/genesis.go index 93f7688a1541..71a6413cf5ac 100644 --- a/x/auth/genesis.go +++ b/x/auth/genesis.go @@ -2,6 +2,7 @@ package auth import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -9,20 +10,20 @@ import ( // // CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through // a genesis port script to the new fee collector account -func InitGenesis(ctx sdk.Context, ak AccountKeeper, data GenesisState) { +func InitGenesis(ctx sdk.Context, ak keeper.AccountKeeper, data types.GenesisState) { ak.SetParams(ctx, data.Params) - data.Accounts = SanitizeGenesisAccounts(data.Accounts) + data.Accounts = types.SanitizeGenesisAccounts(data.Accounts) for _, a := range data.Accounts { acc := ak.NewAccount(ctx, a) ak.SetAccount(ctx, acc) } - ak.GetModuleAccount(ctx, FeeCollectorName) + ak.GetModuleAccount(ctx, types.FeeCollectorName) } // ExportGenesis returns a GenesisState for a given context and keeper -func ExportGenesis(ctx sdk.Context, ak AccountKeeper) GenesisState { +func ExportGenesis(ctx sdk.Context, ak keeper.AccountKeeper) types.GenesisState { params := ak.GetParams(ctx) var genAccounts types.GenesisAccounts @@ -32,5 +33,5 @@ func ExportGenesis(ctx sdk.Context, ak AccountKeeper) GenesisState { return false }) - return NewGenesisState(params, genAccounts) + return types.NewGenesisState(params, genAccounts) } diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index e3f5d7f3d88b..505502a021b9 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -20,8 +20,8 @@ const ( ) var ( - multiPermAcc = auth.NewEmptyModuleAccount(multiPerm, auth.Burner, auth.Minter, auth.Staking) - randomPermAcc = auth.NewEmptyModuleAccount(randomPerm, "random") + multiPermAcc = types.NewEmptyModuleAccount(multiPerm, types.Burner, types.Minter, types.Staking) + randomPermAcc = types.NewEmptyModuleAccount(randomPerm, "random") ) func TestAccountMapperGetSet(t *testing.T) { @@ -104,12 +104,12 @@ func TestSupply_ValidatePermissions(t *testing.T) { maccPerms := simapp.GetMaccPerms() maccPerms[holder] = nil maccPerms[types.Burner] = []string{types.Burner} - maccPerms[auth.Minter] = []string{types.Minter} + maccPerms[types.Minter] = []string{types.Minter} maccPerms[multiPerm] = []string{types.Burner, types.Minter, types.Staking} maccPerms[randomPerm] = []string{"random"} appCodec := std.NewAppCodec(app.Codec(), codectypes.NewInterfaceRegistry()) - keeper := auth.NewAccountKeeper( + keeper := keeper.NewAccountKeeper( appCodec, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName), types.ProtoBaseAccount, maccPerms, ) diff --git a/x/auth/module.go b/x/auth/module.go index afb93d73adfc..fb360e0e78ce 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -13,14 +13,15 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/client/rest" + "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/simulation" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" ) var ( @@ -35,33 +36,33 @@ type AppModuleBasic struct{} // Name returns the auth module's name. func (AppModuleBasic) Name() string { - return authtypes.ModuleName + return types.ModuleName } // RegisterCodec registers the auth module's types for the given codec. func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { - authtypes.RegisterCodec(cdc) + types.RegisterCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the auth // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { - return cdc.MustMarshalJSON(authtypes.DefaultGenesisState()) + return cdc.MustMarshalJSON(types.DefaultGenesisState()) } // ValidateGenesis performs genesis state validation for the auth module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) error { - var data authtypes.GenesisState + var data types.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", authtypes.ModuleName, err) + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } - return authtypes.ValidateGenesis(data) + return types.ValidateGenesis(data) } // RegisterRESTRoutes registers the REST routes for the auth module. func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - rest.RegisterRoutes(clientCtx, rtr, authtypes.StoreKey) + rest.RegisterRoutes(clientCtx, rtr, types.StoreKey) } // GetTxCmd returns the root tx command for the auth module. @@ -75,8 +76,8 @@ func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { } // RegisterInterfaceTypes registers interfaces and implementations of the auth module. -func (AppModuleBasic) RegisterInterfaceTypes(registry types.InterfaceRegistry) { - authtypes.RegisterInterfaces(registry) +func (AppModuleBasic) RegisterInterfaceTypes(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) } //____________________________________________________________________________ @@ -85,11 +86,11 @@ func (AppModuleBasic) RegisterInterfaceTypes(registry types.InterfaceRegistry) { type AppModule struct { AppModuleBasic - accountKeeper AccountKeeper + accountKeeper keeper.AccountKeeper } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Marshaler, accountKeeper AccountKeeper) AppModule { +func NewAppModule(cdc codec.Marshaler, accountKeeper keeper.AccountKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, accountKeeper: accountKeeper, @@ -98,7 +99,7 @@ func NewAppModule(cdc codec.Marshaler, accountKeeper AccountKeeper) AppModule { // Name returns the auth module's name. func (AppModule) Name() string { - return authtypes.ModuleName + return types.ModuleName } // RegisterInvariants performs a no-op. @@ -109,12 +110,12 @@ func (AppModule) Route() sdk.Route { return sdk.Route{} } // QuerierRoute returns the auth module's querier route name. func (AppModule) QuerierRoute() string { - return authtypes.QuerierRoute + return types.QuerierRoute } // NewQuerierHandler returns the auth module sdk.Querier. func (am AppModule) NewQuerierHandler() sdk.Querier { - return NewQuerier(am.accountKeeper) + return keeper.NewQuerier(am.accountKeeper) } func (am AppModule) RegisterQueryService(grpc.Server) {} @@ -122,7 +123,7 @@ func (am AppModule) RegisterQueryService(grpc.Server) {} // InitGenesis performs genesis initialization for the auth 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) InitGenesis(ctx, am.accountKeeper, genesisState) return []abci.ValidatorUpdate{} @@ -165,7 +166,7 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { // RegisterStoreDecoder registers a decoder for auth module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - sdr[StoreKey] = simulation.NewDecodeStore(am.accountKeeper) + sdr[types.StoreKey] = simulation.NewDecodeStore(am.accountKeeper) } // WeightedOperations doesn't return any auth module operation. diff --git a/x/auth/module_test.go b/x/auth/module_test.go index f0789b2cdcac..849f2d15409d 100644 --- a/x/auth/module_test.go +++ b/x/auth/module_test.go @@ -4,23 +4,23 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/abci/types" + abcitypes "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/cosmos/cosmos-sdk/x/auth/types" ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, types.Header{}) + ctx := app.BaseApp.NewContext(false, abcitypes.Header{}) app.InitChain( - types.RequestInitChain{ + abcitypes.RequestInitChain{ AppStateBytes: []byte("{}"), ChainId: "test-chain-id", }, ) - acc := app.AccountKeeper.GetAccount(ctx, auth.NewModuleAddress(auth.FeeCollectorName)) + acc := app.AccountKeeper.GetAccount(ctx, types.NewModuleAddress(types.FeeCollectorName)) require.NotNil(t, acc) } diff --git a/x/auth/signing/amino/amino_test.go b/x/auth/signing/amino/amino_test.go index 3e073ae881af..befea51b2f8b 100644 --- a/x/auth/signing/amino/amino_test.go +++ b/x/auth/signing/amino/amino_test.go @@ -9,9 +9,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/signing/amino" + "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" ) @@ -23,7 +23,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { coins := sdk.Coins{sdk.NewInt64Coin("foocoin", 10)} - fee := auth.StdFee{ + fee := types.StdFee{ Amount: coins, Gas: 10000, } @@ -36,7 +36,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { }, } - tx := auth.StdTx{ + tx := types.StdTx{ Msgs: msgs, Fee: fee, Signatures: nil, @@ -58,7 +58,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) require.NoError(t, err) - expectedSignBz := auth.StdSignBytes(chainId, accNum, seqNum, fee, msgs, memo) + expectedSignBz := types.StdSignBytes(chainId, accNum, seqNum, fee, msgs, memo) require.Equal(t, expectedSignBz, signBz) diff --git a/x/bank/app_test.go b/x/bank/app_test.go index 2fff4f728ba5..9827e77c9192 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -89,7 +88,7 @@ var ( ) func TestSendNotEnoughBalance(t *testing.T) { - acc := &auth.BaseAccount{ + acc := &authtypes.BaseAccount{ Address: addr1, } @@ -104,7 +103,7 @@ func TestSendNotEnoughBalance(t *testing.T) { res1 := app.AccountKeeper.GetAccount(ctx, addr1) require.NotNil(t, res1) - require.Equal(t, acc, res1.(*auth.BaseAccount)) + require.Equal(t, acc, res1.(*authtypes.BaseAccount)) origAccNum := res1.GetAccountNumber() origSeq := res1.GetSequence() @@ -146,7 +145,7 @@ func TestSendToModuleAcc(t *testing.T) { { name: "Allowed module account can be the recipient of bank sends", fromBalance: coins, - msg: types.NewMsgSend(addr1, auth.NewModuleAddress(distribution.ModuleName), coins), + msg: types.NewMsgSend(addr1, authtypes.NewModuleAddress(distribution.ModuleName), coins), expPass: true, expSimPass: true, expFromBalance: sdk.NewCoins(), @@ -157,7 +156,7 @@ func TestSendToModuleAcc(t *testing.T) { for _, test := range tests { test := test t.Run(test.name, func(t *testing.T) { - acc := &auth.BaseAccount{ + acc := &authtypes.BaseAccount{ Address: test.msg.FromAddress, } @@ -172,7 +171,7 @@ func TestSendToModuleAcc(t *testing.T) { res1 := app.AccountKeeper.GetAccount(ctx, test.msg.FromAddress) require.NotNil(t, res1) - require.Equal(t, acc, res1.(*auth.BaseAccount)) + require.Equal(t, acc, res1.(*authtypes.BaseAccount)) origAccNum := res1.GetAccountNumber() origSeq := res1.GetSequence() @@ -198,7 +197,7 @@ func TestSendToModuleAcc(t *testing.T) { } func TestMsgMultiSendWithAccounts(t *testing.T) { - acc := &auth.BaseAccount{ + acc := &authtypes.BaseAccount{ Address: addr1, } @@ -213,7 +212,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { res1 := app.AccountKeeper.GetAccount(ctx, addr1) require.NotNil(t, res1) - require.Equal(t, acc, res1.(*auth.BaseAccount)) + require.Equal(t, acc, res1.(*authtypes.BaseAccount)) testCases := []appTestCase{ { @@ -262,10 +261,10 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { } func TestMsgMultiSendMultipleOut(t *testing.T) { - acc1 := &auth.BaseAccount{ + acc1 := &authtypes.BaseAccount{ Address: addr1, } - acc2 := &auth.BaseAccount{ + acc2 := &authtypes.BaseAccount{ Address: addr2, } @@ -309,13 +308,13 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { } func TestMsgMultiSendMultipleInOut(t *testing.T) { - acc1 := &auth.BaseAccount{ + acc1 := &authtypes.BaseAccount{ Address: addr1, } - acc2 := &auth.BaseAccount{ + acc2 := &authtypes.BaseAccount{ Address: addr2, } - acc4 := &auth.BaseAccount{ + acc4 := &authtypes.BaseAccount{ Address: addr4, } @@ -363,8 +362,8 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { } func TestMsgMultiSendDependent(t *testing.T) { - acc1 := auth.NewBaseAccountWithAddress(addr1) - acc2 := auth.NewBaseAccountWithAddress(addr2) + acc1 := authtypes.NewBaseAccountWithAddress(addr1) + acc2 := authtypes.NewBaseAccountWithAddress(addr2) err := acc2.SetAccountNumber(1) require.NoError(t, err) diff --git a/x/bank/bench_test.go b/x/bank/bench_test.go index 5910c300ce9e..b380fa073bc4 100644 --- a/x/bank/bench_test.go +++ b/x/bank/bench_test.go @@ -8,16 +8,16 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) -var moduleAccAddr = auth.NewModuleAddress(stakingtypes.BondedPoolName) +var moduleAccAddr = authtypes.NewModuleAddress(stakingtypes.BondedPoolName) func BenchmarkOneBankSendTxPerBlock(b *testing.B) { // Add an account at genesis - acc := auth.BaseAccount{ + acc := authtypes.BaseAccount{ Address: addr1, } @@ -57,12 +57,12 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) { // Add an account at genesis - acc := auth.BaseAccount{ + acc := authtypes.BaseAccount{ Address: addr1, } // Construct genesis state - genAccs := []types.GenesisAccount{&acc} + genAccs := []authtypes.GenesisAccount{&acc} benchmarkApp := simapp.SetupWithGenesisAccounts(genAccs) ctx := benchmarkApp.BaseApp.NewContext(false, abci.Header{}) diff --git a/x/bank/client/testutil/helpers.go b/x/bank/client/testutil/helpers.go index c09de98ac873..4c2d1eca1475 100644 --- a/x/bank/client/testutil/helpers.go +++ b/x/bank/client/testutil/helpers.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/tests" "github.com/cosmos/cosmos-sdk/tests/cli" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // TxSend is simcli tx send @@ -21,7 +21,7 @@ func TxSend(f *cli.Fixtures, from string, to sdk.AccAddress, amount sdk.Coin, fl } // QueryAccount is simcli query account -func QueryAccount(f *cli.Fixtures, address sdk.AccAddress, flags ...string) auth.BaseAccount { +func QueryAccount(f *cli.Fixtures, address sdk.AccAddress, flags ...string) authtypes.BaseAccount { cmd := fmt.Sprintf("%s query account %s %v", f.SimcliBinary, address, f.Flags()) out, _ := tests.ExecuteT(f.T, cli.AddFlags(cmd, flags), "") @@ -31,7 +31,7 @@ func QueryAccount(f *cli.Fixtures, address sdk.AccAddress, flags ...string) auth require.NoError(f.T, err, "out %v, err %v", out, err) value := initRes["value"] - var acc auth.BaseAccount + var acc authtypes.BaseAccount err = f.Cdc.UnmarshalJSON(value, &acc) require.NoError(f.T, err, "value %v, err %v", string(value), err) diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 6c0fa582c038..bf9e939b338c 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -10,7 +10,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" "github.com/cosmos/cosmos-sdk/x/bank/exported" "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -236,7 +236,7 @@ func (k BaseKeeper) DelegateCoinsFromAccountToModule( panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", recipientModule)) } - if !recipientAcc.HasPermission(auth.Staking) { + if !recipientAcc.HasPermission(authtypes.Staking) { panic(sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "module account %s does not have permissions to receive delegated coins", recipientModule)) } @@ -255,7 +255,7 @@ func (k BaseKeeper) UndelegateCoinsFromModuleToAccount( panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", senderModule)) } - if !acc.HasPermission(auth.Staking) { + if !acc.HasPermission(authtypes.Staking) { panic(sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "module account %s does not have permissions to undelegate coins", senderModule)) } @@ -270,7 +270,7 @@ func (k BaseKeeper) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", moduleName)) } - if !acc.HasPermission(auth.Minter) { + if !acc.HasPermission(authtypes.Minter) { panic(sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "module account %s does not have permissions to mint tokens", moduleName)) } @@ -299,7 +299,7 @@ func (k BaseKeeper) BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", moduleName)) } - if !acc.HasPermission(auth.Burner) { + if !acc.HasPermission(authtypes.Burner) { panic(sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "module account %s does not have permissions to burn tokens", moduleName)) } diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index ed1fa4a558d9..39acc005ab8f 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -11,7 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -27,11 +28,11 @@ const ( ) var ( - holderAcc = auth.NewEmptyModuleAccount(holder) - burnerAcc = auth.NewEmptyModuleAccount(auth.Burner, auth.Burner) - minterAcc = auth.NewEmptyModuleAccount(auth.Minter, auth.Minter) - multiPermAcc = auth.NewEmptyModuleAccount(multiPerm, auth.Burner, auth.Minter, auth.Staking) - randomPermAcc = auth.NewEmptyModuleAccount(randomPerm, "random") + holderAcc = authtypes.NewEmptyModuleAccount(holder) + burnerAcc = authtypes.NewEmptyModuleAccount(authtypes.Burner, authtypes.Burner) + minterAcc = authtypes.NewEmptyModuleAccount(authtypes.Minter, authtypes.Minter) + multiPermAcc = authtypes.NewEmptyModuleAccount(multiPerm, authtypes.Burner, authtypes.Minter, authtypes.Staking) + randomPermAcc = authtypes.NewEmptyModuleAccount(randomPerm, "random") initTokens = sdk.TokensFromConsensusPower(initialPower) initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens)) @@ -67,7 +68,7 @@ func (suite *IntegrationTestSuite) SetupTest() { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, abci.Header{}) - app.AccountKeeper.SetParams(ctx, auth.DefaultParams()) + app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) app.BankKeeper.SetSendEnabled(ctx, true) suite.app = app @@ -95,21 +96,21 @@ func (suite *IntegrationTestSuite) TestSupply_SendCoins() { // add module accounts to supply keeper maccPerms := simapp.GetMaccPerms() maccPerms[holder] = nil - maccPerms[auth.Burner] = []string{auth.Burner} - maccPerms[auth.Minter] = []string{auth.Minter} - maccPerms[multiPerm] = []string{auth.Burner, auth.Minter, auth.Staking} + maccPerms[authtypes.Burner] = []string{authtypes.Burner} + maccPerms[authtypes.Minter] = []string{authtypes.Minter} + maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} maccPerms[randomPerm] = []string{"random"} - authKeeper := auth.NewAccountKeeper( + authKeeper := authkeeper.NewAccountKeeper( appCodec, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName), - auth.ProtoBaseAccount, maccPerms, + authtypes.ProtoBaseAccount, maccPerms, ) keeper := bank.NewBaseKeeper( appCodec, app.GetKey(types.StoreKey), authKeeper, app.GetSubspace(bank.ModuleName), make(map[string]bool), ) - baseAcc := authKeeper.NewAccountWithAddress(ctx, auth.NewModuleAddress("baseAcc")) + baseAcc := authKeeper.NewAccountWithAddress(ctx, authtypes.NewModuleAddress("baseAcc")) suite.Require().NoError(keeper.SetBalances(ctx, holderAcc.GetAddress(), initCoins)) keeper.SetSupply(ctx, types.NewSupply(initCoins)) @@ -122,7 +123,7 @@ func (suite *IntegrationTestSuite) TestSupply_SendCoins() { }) suite.Require().Panics(func() { - keeper.SendCoinsFromModuleToModule(ctx, auth.Burner, "", initCoins) // nolint:errcheck + keeper.SendCoinsFromModuleToModule(ctx, authtypes.Burner, "", initCoins) // nolint:errcheck }) suite.Require().Panics(func() { @@ -134,20 +135,20 @@ func (suite *IntegrationTestSuite) TestSupply_SendCoins() { ) suite.Require().NoError( - keeper.SendCoinsFromModuleToModule(ctx, holderAcc.GetName(), auth.Burner, initCoins), + keeper.SendCoinsFromModuleToModule(ctx, holderAcc.GetName(), authtypes.Burner, initCoins), ) suite.Require().Equal(sdk.Coins(nil), getCoinsByName(ctx, keeper, authKeeper, holderAcc.GetName())) - suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, auth.Burner)) + suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner)) suite.Require().NoError( - keeper.SendCoinsFromModuleToAccount(ctx, auth.Burner, baseAcc.GetAddress(), initCoins), + keeper.SendCoinsFromModuleToAccount(ctx, authtypes.Burner, baseAcc.GetAddress(), initCoins), ) - suite.Require().Equal(sdk.Coins(nil), getCoinsByName(ctx, keeper, authKeeper, auth.Burner)) + suite.Require().Equal(sdk.Coins(nil), getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner)) suite.Require().Equal(initCoins, keeper.GetAllBalances(ctx, baseAcc.GetAddress())) - suite.Require().NoError(keeper.SendCoinsFromAccountToModule(ctx, baseAcc.GetAddress(), auth.Burner, initCoins)) + suite.Require().NoError(keeper.SendCoinsFromAccountToModule(ctx, baseAcc.GetAddress(), authtypes.Burner, initCoins)) suite.Require().Equal(sdk.Coins(nil), keeper.GetAllBalances(ctx, baseAcc.GetAddress())) - suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, auth.Burner)) + suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner)) } func (suite *IntegrationTestSuite) TestSupply_MintCoins() { @@ -158,14 +159,14 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { // add module accounts to supply keeper maccPerms := simapp.GetMaccPerms() maccPerms[holder] = nil - maccPerms[auth.Burner] = []string{auth.Burner} - maccPerms[auth.Minter] = []string{auth.Minter} - maccPerms[multiPerm] = []string{auth.Burner, auth.Minter, auth.Staking} + maccPerms[authtypes.Burner] = []string{authtypes.Burner} + maccPerms[authtypes.Minter] = []string{authtypes.Minter} + maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} maccPerms[randomPerm] = []string{"random"} - authKeeper := auth.NewAccountKeeper( + authKeeper := authkeeper.NewAccountKeeper( appCodec, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName), - auth.ProtoBaseAccount, maccPerms, + authtypes.ProtoBaseAccount, maccPerms, ) keeper := bank.NewBaseKeeper( appCodec, app.GetKey(types.StoreKey), authKeeper, @@ -179,18 +180,18 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { initialSupply := keeper.GetSupply(ctx) - suite.Require().Panics(func() { keeper.MintCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck - suite.Require().Panics(func() { keeper.MintCoins(ctx, auth.Burner, initCoins) }, "invalid permission") // nolint:errcheck + suite.Require().Panics(func() { keeper.MintCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck + suite.Require().Panics(func() { keeper.MintCoins(ctx, authtypes.Burner, initCoins) }, "invalid permission") // nolint:errcheck - err := keeper.MintCoins(ctx, auth.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdk.NewInt(-10)}}) + err := keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdk.NewInt(-10)}}) suite.Require().Error(err, "insufficient coins") suite.Require().Panics(func() { keeper.MintCoins(ctx, randomPerm, initCoins) }) // nolint:errcheck - err = keeper.MintCoins(ctx, auth.Minter, initCoins) + err = keeper.MintCoins(ctx, authtypes.Minter, initCoins) suite.Require().NoError(err) - suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, auth.Minter)) + suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, authtypes.Minter)) suite.Require().Equal(initialSupply.GetTotal().Add(initCoins...), keeper.GetSupply(ctx).GetTotal()) // test same functionality on module account with multiple permissions @@ -201,7 +202,7 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, multiPermAcc.GetName())) suite.Require().Equal(initialSupply.GetTotal().Add(initCoins...), keeper.GetSupply(ctx).GetTotal()) - suite.Require().Panics(func() { keeper.MintCoins(ctx, auth.Burner, initCoins) }) // nolint:errcheck + suite.Require().Panics(func() { keeper.MintCoins(ctx, authtypes.Burner, initCoins) }) // nolint:errcheck } func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { @@ -212,14 +213,14 @@ func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { // add module accounts to supply keeper maccPerms := simapp.GetMaccPerms() maccPerms[holder] = nil - maccPerms[auth.Burner] = []string{auth.Burner} - maccPerms[auth.Minter] = []string{auth.Minter} - maccPerms[multiPerm] = []string{auth.Burner, auth.Minter, auth.Staking} + maccPerms[authtypes.Burner] = []string{authtypes.Burner} + maccPerms[authtypes.Minter] = []string{authtypes.Minter} + maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} maccPerms[randomPerm] = []string{"random"} - authKeeper := auth.NewAccountKeeper( + authKeeper := authkeeper.NewAccountKeeper( appCodec, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName), - auth.ProtoBaseAccount, maccPerms, + authtypes.ProtoBaseAccount, maccPerms, ) keeper := bank.NewBaseKeeper( appCodec, app.GetKey(types.StoreKey), authKeeper, @@ -235,14 +236,14 @@ func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { keeper.SetSupply(ctx, initialSupply) suite.Require().Panics(func() { keeper.BurnCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck - suite.Require().Panics(func() { keeper.BurnCoins(ctx, auth.Minter, initCoins) }, "invalid permission") // nolint:errcheck + suite.Require().Panics(func() { keeper.BurnCoins(ctx, authtypes.Minter, initCoins) }, "invalid permission") // nolint:errcheck suite.Require().Panics(func() { keeper.BurnCoins(ctx, randomPerm, initialSupply.GetTotal()) }, "random permission") // nolint:errcheck - err := keeper.BurnCoins(ctx, auth.Burner, initialSupply.GetTotal()) + err := keeper.BurnCoins(ctx, authtypes.Burner, initialSupply.GetTotal()) suite.Require().Error(err, "insufficient coins") - err = keeper.BurnCoins(ctx, auth.Burner, initCoins) + err = keeper.BurnCoins(ctx, authtypes.Burner, initCoins) suite.Require().NoError(err) - suite.Require().Equal(sdk.Coins(nil), getCoinsByName(ctx, keeper, authKeeper, auth.Burner)) + suite.Require().Equal(sdk.Coins(nil), getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner)) suite.Require().Equal(initialSupply.GetTotal().Sub(initCoins), keeper.GetSupply(ctx).GetTotal()) // test same functionality on module account with multiple permissions @@ -414,7 +415,7 @@ func (suite *IntegrationTestSuite) TestValidateBalance() { suite.Require().NoError(app.BankKeeper.SetBalances(ctx, addr1, balances)) suite.Require().NoError(app.BankKeeper.ValidateBalance(ctx, addr1)) - bacc := auth.NewBaseAccountWithAddress(addr2) + bacc := authtypes.NewBaseAccountWithAddress(addr2) vacc := vesting.NewContinuousVestingAccount(bacc, balances.Add(balances...), now.Unix(), endTime.Unix()) app.AccountKeeper.SetAccount(ctx, vacc) @@ -635,7 +636,7 @@ func (suite *IntegrationTestSuite) TestSpendableCoins() { addrModule := sdk.AccAddress([]byte("moduleAcc")) macc := app.AccountKeeper.NewAccountWithAddress(ctx, addrModule) - bacc := auth.NewBaseAccountWithAddress(addr1) + bacc := authtypes.NewBaseAccountWithAddress(addr1) vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) @@ -664,7 +665,7 @@ func (suite *IntegrationTestSuite) TestVestingAccountSend() { addr1 := sdk.AccAddress([]byte("addr1")) addr2 := sdk.AccAddress([]byte("addr2")) - bacc := auth.NewBaseAccountWithAddress(addr1) + bacc := authtypes.NewBaseAccountWithAddress(addr1) vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) app.AccountKeeper.SetAccount(ctx, vacc) @@ -697,7 +698,7 @@ func (suite *IntegrationTestSuite) TestPeriodicVestingAccountSend() { vesting.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 25)}}, } - bacc := auth.NewBaseAccountWithAddress(addr1) + bacc := authtypes.NewBaseAccountWithAddress(addr1) vacc := vesting.NewPeriodicVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), periods) app.AccountKeeper.SetAccount(ctx, vacc) @@ -727,7 +728,7 @@ func (suite *IntegrationTestSuite) TestVestingAccountReceive() { addr1 := sdk.AccAddress([]byte("addr1")) addr2 := sdk.AccAddress([]byte("addr2")) - bacc := auth.NewBaseAccountWithAddress(addr1) + bacc := authtypes.NewBaseAccountWithAddress(addr1) vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) @@ -760,7 +761,7 @@ func (suite *IntegrationTestSuite) TestPeriodicVestingAccountReceive() { addr1 := sdk.AccAddress([]byte("addr1")) addr2 := sdk.AccAddress([]byte("addr2")) - bacc := auth.NewBaseAccountWithAddress(addr1) + bacc := authtypes.NewBaseAccountWithAddress(addr1) periods := vesting.Periods{ vesting.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 50)}}, vesting.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 25)}}, @@ -803,7 +804,7 @@ func (suite *IntegrationTestSuite) TestDelegateCoins() { macc := app.AccountKeeper.NewAccountWithAddress(ctx, addrModule) // we don't need to define an actual module account bc we just need the address for testing acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) - bacc := auth.NewBaseAccountWithAddress(addr1) + bacc := authtypes.NewBaseAccountWithAddress(addr1) vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) app.AccountKeeper.SetAccount(ctx, vacc) @@ -861,7 +862,7 @@ func (suite *IntegrationTestSuite) TestUndelegateCoins() { addr2 := sdk.AccAddress([]byte("addr2")) addrModule := sdk.AccAddress([]byte("moduleAcc")) - bacc := auth.NewBaseAccountWithAddress(addr1) + bacc := authtypes.NewBaseAccountWithAddress(addr1) macc := app.AccountKeeper.NewAccountWithAddress(ctx, addrModule) // we don't need to define an actual module account bc we just need the address for testing vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) diff --git a/x/distribution/keeper/common_test.go b/x/distribution/keeper/common_test.go index 655082cc426e..807fd45c2520 100644 --- a/x/distribution/keeper/common_test.go +++ b/x/distribution/keeper/common_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/distribution/types" ) @@ -17,5 +17,5 @@ var ( valConsAddr1 = sdk.ConsAddress(valConsPk1.Address()) valConsAddr2 = sdk.ConsAddress(valConsPk2.Address()) - distrAcc = auth.NewEmptyModuleAccount(types.ModuleName) + distrAcc = authtypes.NewEmptyModuleAccount(types.ModuleName) ) diff --git a/x/distribution/module_test.go b/x/distribution/module_test.go index 7095ce859014..e9503db63b18 100644 --- a/x/distribution/module_test.go +++ b/x/distribution/module_test.go @@ -7,7 +7,7 @@ import ( "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/distribution" ) @@ -22,6 +22,6 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { }, ) - acc := app.AccountKeeper.GetAccount(ctx, auth.NewModuleAddress(distribution.ModuleName)) + acc := app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(distribution.ModuleName)) require.NotNil(t, acc) } diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 11606401052b..78b7305f63c0 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/evidence" "github.com/cosmos/cosmos-sdk/x/evidence/exported" @@ -96,7 +96,7 @@ func (suite *KeeperTestSuite) SetupTest() { for i, addr := range valAddresses { addr := sdk.AccAddress(addr) - app.AccountKeeper.SetAccount(suite.ctx, auth.NewBaseAccount(addr, pubkeys[i], uint64(i), 0)) + app.AccountKeeper.SetAccount(suite.ctx, authtypes.NewBaseAccount(addr, pubkeys[i], uint64(i), 0)) } } diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index 5de254415358..c72abb69b165 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -26,8 +26,8 @@ import ( "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/auth" authclient "github.com/cosmos/cosmos-sdk/x/auth/client" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil/types" ) @@ -36,7 +36,7 @@ import ( type StakingMsgBuildingHelpers interface { CreateValidatorMsgHelpers(ipDefault string) (fs *flag.FlagSet, nodeIDFlag, pubkeyFlag, amountFlag, defaultsDesc string) PrepareFlagsForTxCreateValidator(config *cfg.Config, nodeID, chainID string, valPubKey crypto.PubKey) - BuildCreateValidatorMsg(clientCtx client.Context, txBldr auth.TxBuilder) (auth.TxBuilder, sdk.Msg, error) + BuildCreateValidatorMsg(clientCtx client.Context, txBldr authtypes.TxBuilder) (authtypes.TxBuilder, sdk.Msg, error) } // GenTxCmd builds the application's gentx command. @@ -120,7 +120,7 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm return errors.Wrap(err, "failed to validate account in genesis") } - txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc)) + txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc)) clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc) // Set the generate-only flag here after the CLI context has @@ -203,8 +203,8 @@ func makeOutputFilepath(rootDir, nodeID string) (string, error) { return filepath.Join(writePath, fmt.Sprintf("gentx-%v.json", nodeID)), nil } -func readUnsignedGenTxFile(cdc *codec.Codec, r io.Reader) (auth.StdTx, error) { - var stdTx auth.StdTx +func readUnsignedGenTxFile(cdc *codec.Codec, r io.Reader) (authtypes.StdTx, error) { + var stdTx authtypes.StdTx bytes, err := ioutil.ReadAll(r) if err != nil { @@ -216,7 +216,7 @@ func readUnsignedGenTxFile(cdc *codec.Codec, r io.Reader) (auth.StdTx, error) { return stdTx, err } -func writeSignedGenTx(cdc *codec.Codec, outputDocument string, tx auth.StdTx) error { +func writeSignedGenTx(cdc *codec.Codec, outputDocument string, tx authtypes.StdTx) error { outputFile, err := os.OpenFile(outputDocument, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644) if err != nil { return err diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index ba6d5a1f9af4..ee73c62791f1 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -56,7 +57,7 @@ func TestImportExportQueues(t *testing.T) { govGenState := gov.ExportGenesis(ctx, app.GovKeeper) genesisState := simapp.NewDefaultGenesisState() - genesisState[auth.ModuleName] = app.AppCodec().MustMarshalJSON(authGenState) + genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenState) genesisState[bank.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenState) genesisState[types.ModuleName] = app.AppCodec().MustMarshalJSON(govGenState) diff --git a/x/gov/module_test.go b/x/gov/module_test.go index 99a7923f31ac..a4b44922460b 100644 --- a/x/gov/module_test.go +++ b/x/gov/module_test.go @@ -7,7 +7,7 @@ import ( abcitypes "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -22,6 +22,6 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { }, ) - acc := app.AccountKeeper.GetAccount(ctx, auth.NewModuleAddress(types.ModuleName)) + acc := app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName)) require.NotNil(t, acc) } diff --git a/x/mint/module_test.go b/x/mint/module_test.go index ff282ab4c4be..92e22d4986b9 100644 --- a/x/mint/module_test.go +++ b/x/mint/module_test.go @@ -7,7 +7,7 @@ import ( abcitypes "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/mint/types" ) @@ -22,6 +22,6 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { }, ) - acc := app.AccountKeeper.GetAccount(ctx, auth.NewModuleAddress(types.ModuleName)) + acc := app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName)) require.NotNil(t, acc) } diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index 400c5b712eef..f0cb766da520 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/slashing/types" @@ -42,7 +41,7 @@ func TestSlashingMsgs(t *testing.T) { genCoin := sdk.NewCoin(sdk.DefaultBondDenom, genTokens) bondCoin := sdk.NewCoin(sdk.DefaultBondDenom, bondTokens) - acc1 := &auth.BaseAccount{ + acc1 := &authtypes.BaseAccount{ Address: addr1, } accs := authtypes.GenesisAccounts{acc1} diff --git a/x/staking/app_test.go b/x/staking/app_test.go index 6cc5a2083160..bd656750878b 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -44,9 +44,9 @@ func TestStakingMsgs(t *testing.T) { genCoin := sdk.NewCoin(sdk.DefaultBondDenom, genTokens) bondCoin := sdk.NewCoin(sdk.DefaultBondDenom, bondTokens) - acc1 := &auth.BaseAccount{Address: addr1} - acc2 := &auth.BaseAccount{Address: addr2} - accs := auth.GenesisAccounts{acc1, acc2} + acc1 := &authtypes.BaseAccount{Address: addr1} + acc2 := &authtypes.BaseAccount{Address: addr2} + accs := authtypes.GenesisAccounts{acc1, acc2} balances := []bank.Balance{ { Address: addr1, diff --git a/x/staking/client/cli/tx.go b/x/staking/client/cli/tx.go index efafb272b6ce..b42fc7becd1d 100644 --- a/x/staking/client/cli/tx.go +++ b/x/staking/client/cli/tx.go @@ -5,7 +5,7 @@ import ( "os" "strings" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/spf13/cobra" flag "github.com/spf13/pflag" @@ -407,7 +407,7 @@ func PrepareFlagsForTxCreateValidator( } // BuildCreateValidatorMsg makes a new MsgCreateValidator. -func BuildCreateValidatorMsg(clientCtx client.Context, txBldr auth.TxBuilder) (auth.TxBuilder, sdk.Msg, error) { +func BuildCreateValidatorMsg(clientCtx client.Context, txBldr authtypes.TxBuilder) (authtypes.TxBuilder, sdk.Msg, error) { amounstStr := viper.GetString(FlagAmount) amount, err := sdk.ParseCoin(amounstStr) diff --git a/x/staking/module_test.go b/x/staking/module_test.go index ed90d8458560..fa7cf6a83f63 100644 --- a/x/staking/module_test.go +++ b/x/staking/module_test.go @@ -7,7 +7,7 @@ import ( abcitypes "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -22,9 +22,9 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { }, ) - acc := app.AccountKeeper.GetAccount(ctx, auth.NewModuleAddress(types.BondedPoolName)) + acc := app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.BondedPoolName)) require.NotNil(t, acc) - acc = app.AccountKeeper.GetAccount(ctx, auth.NewModuleAddress(types.NotBondedPoolName)) + acc = app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.NotBondedPoolName)) require.NotNil(t, acc) } From bc6f77b2847bd826cbeafc6bce021321ea7759a1 Mon Sep 17 00:00:00 2001 From: DauTT Date: Mon, 15 Jun 2020 21:28:05 +0200 Subject: [PATCH 2/6] Fix simd_test.go and formatting --- tests/cli/simd_test.go | 4 ++-- x/evidence/keeper/keeper_test.go | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/cli/simd_test.go b/tests/cli/simd_test.go index 9d87602a26c1..b1cabadeb864 100644 --- a/tests/cli/simd_test.go +++ b/tests/cli/simd_test.go @@ -15,7 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/std" "github.com/cosmos/cosmos-sdk/tests/cli" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -102,7 +102,7 @@ func TestCLISimdAddGenesisAccount(t *testing.T) { interfaceRegistry := codectypes.NewInterfaceRegistry() appCodec := std.NewAppCodec(f.Cdc, interfaceRegistry) - accounts := auth.GetGenesisStateFromAppState(appCodec, genesisState).Accounts + accounts := authtypes.GetGenesisStateFromAppState(appCodec, genesisState).Accounts balances := banktypes.GetGenesisStateFromAppState(f.Cdc, genesisState).Balances balancesSet := make(map[string]sdk.Coins) diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 555eed6021f2..512cd1dd542a 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -10,7 +10,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/evidence" "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/keeper" "github.com/cosmos/cosmos-sdk/x/evidence/types" From 9e242033ecc87c6462ef0509da4998e103754f3a Mon Sep 17 00:00:00 2001 From: DauTT Date: Mon, 15 Jun 2020 23:22:06 +0200 Subject: [PATCH 3/6] Fix app.go formatting --- simapp/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simapp/app.go b/simapp/app.go index 49dce624c00d..2c1cdc84cbd0 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -21,9 +21,9 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" + authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" From 25550d55da740a834918d074e41a35b1020b085b Mon Sep 17 00:00:00 2001 From: DauTT Date: Mon, 15 Jun 2020 23:36:57 +0200 Subject: [PATCH 4/6] Fix cli_test.go --- x/auth/client/cli/cli_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/auth/client/cli/cli_test.go b/x/auth/client/cli/cli_test.go index b831ee348a72..0bb8d2c3eae1 100644 --- a/x/auth/client/cli/cli_test.go +++ b/x/auth/client/cli/cli_test.go @@ -14,8 +14,8 @@ import ( "github.com/cosmos/cosmos-sdk/tests" "github.com/cosmos/cosmos-sdk/tests/cli" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/client/testutil" + "github.com/cosmos/cosmos-sdk/x/auth/types" bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" ) @@ -308,7 +308,7 @@ func TestCLIEncode(t *testing.T) { require.Nil(t, err) // Check that the transaction decodes as epxceted - var decodedTx auth.StdTx + var decodedTx types.StdTx require.Nil(t, f.Cdc.UnmarshalBinaryBare(decodedBytes, &decodedTx)) require.Equal(t, "deadbeef", decodedTx.Memo) } From d99012436f9ff7161edf43ec493aee404936dd28 Mon Sep 17 00:00:00 2001 From: DauTT Date: Tue, 16 Jun 2020 21:05:12 +0200 Subject: [PATCH 5/6] Fix lint warnings --- simapp/cmd/simd/testnet.go | 2 +- simapp/helpers/test_helpers.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/simapp/cmd/simd/testnet.go b/simapp/cmd/simd/testnet.go index c8ca56f99c21..256503e59609 100644 --- a/simapp/cmd/simd/testnet.go +++ b/simapp/cmd/simd/testnet.go @@ -216,7 +216,7 @@ func InitTestnet( sdk.OneInt(), ) - tx := authtypes.NewStdTx([]sdk.Msg{msg}, authtypes.StdFee{}, []authtypes.StdSignature{}, memo) + tx := authtypes.NewStdTx([]sdk.Msg{msg}, authtypes.StdFee{}, []authtypes.StdSignature{}, memo) //nolint:staticcheck // SA1019: authtypes.StdFee is deprecated txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithChainID(chainID).WithMemo(memo).WithKeybase(kb) signedTx, err := txBldr.SignStdTx(nodeDirName, tx, false) diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index 785de22ec6d2..fa7b6d648bd0 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -19,12 +19,12 @@ const ( // GenTx generates a signed mock transaction. func GenTx(msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accnums []uint64, seq []uint64, priv ...crypto.PrivKey) authtypes.StdTx { - fee := authtypes.StdFee{ + fee := authtypes.StdFee{ //nolint:staticcheck // SA1019: authtypes.StdFee is deprecated Amount: feeAmt, Gas: gas, } - sigs := make([]authtypes.StdSignature, len(priv)) + sigs := make([]authtypes.StdSignature, len(priv)) //nolint:staticcheck // SA1019: authtypes.StdSignature is deprecated // create a random length memo r := rand.New(rand.NewSource(time.Now().UnixNano())) @@ -38,7 +38,7 @@ func GenTx(msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accnums panic(err) } - sigs[i] = authtypes.StdSignature{ + sigs[i] = authtypes.StdSignature{ //nolint:staticcheck // SA1019: authtypes.StdSignature is deprecated PubKey: p.PubKey().Bytes(), Signature: sig, } From 91f0ca91039802bf26ce262eb470041539cd5bc6 Mon Sep 17 00:00:00 2001 From: DauTT Date: Tue, 16 Jun 2020 21:08:20 +0200 Subject: [PATCH 6/6] Undo accidental deletion during merge --- x/genutil/client/cli/gentx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index c72abb69b165..985412ee3b7d 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -121,7 +121,7 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm } txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc)) - clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc) + clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc).WithJSONMarshaler(cdc) // Set the generate-only flag here after the CLI context has // been created. This allows the from name/key to be correctly populated.