Skip to content

Commit

Permalink
x/bank: remove alias.go usage (#6439)
Browse files Browse the repository at this point in the history
* x/bank: remove alias.go usage

* Fix simd_test.go
  • Loading branch information
dauTT committed Jun 14, 2020
1 parent 8cf8098 commit 24b9be0
Show file tree
Hide file tree
Showing 29 changed files with 110 additions and 183 deletions.
6 changes: 3 additions & 3 deletions client/tx/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

func NewTestTxGenerator() client.TxGenerator {
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestBuildSimTx(t *testing.T) {
WithMemo("memo").
WithChainID("test-chain")

msg := bank.NewMsgSend(sdk.AccAddress("from"), sdk.AccAddress("to"), nil)
msg := banktypes.NewMsgSend(sdk.AccAddress("from"), sdk.AccAddress("to"), nil)
bz, err := tx.BuildSimTx(txf, msg)
require.NoError(t, err)
require.NotNil(t, bz)
Expand All @@ -101,7 +101,7 @@ func TestBuildUnsignedTx(t *testing.T) {
WithMemo("memo").
WithChainID("test-chain")

msg := bank.NewMsgSend(sdk.AccAddress("from"), sdk.AccAddress("to"), nil)
msg := banktypes.NewMsgSend(sdk.AccAddress("from"), sdk.AccAddress("to"), nil)
tx, err := tx.BuildUnsignedTx(txf, msg)
require.NoError(t, err)
require.NotNil(t, tx)
Expand Down
14 changes: 8 additions & 6 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"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"
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
Expand Down Expand Up @@ -137,7 +139,7 @@ type SimApp struct {

// keepers
AccountKeeper auth.AccountKeeper
BankKeeper bank.Keeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
Expand Down Expand Up @@ -176,7 +178,7 @@ func NewSimApp(
bApp.SetAppVersion(version.Version)

keys := sdk.NewKVStoreKeys(
auth.StoreKey, bank.StoreKey, stakingtypes.StoreKey,
auth.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
Expand All @@ -198,7 +200,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[bank.ModuleName] = app.ParamsKeeper.Subspace(bank.DefaultParamspace)
app.subspaces[banktypes.ModuleName] = app.ParamsKeeper.Subspace(banktypes.DefaultParamspace)
app.subspaces[stakingtypes.ModuleName] = app.ParamsKeeper.Subspace(stakingkeeper.DefaultParamspace)
app.subspaces[minttypes.ModuleName] = app.ParamsKeeper.Subspace(minttypes.DefaultParamspace)
app.subspaces[distrtypes.ModuleName] = app.ParamsKeeper.Subspace(distrtypes.DefaultParamspace)
Expand All @@ -218,8 +220,8 @@ func NewSimApp(
app.AccountKeeper = auth.NewAccountKeeper(
appCodec, keys[auth.StoreKey], app.subspaces[auth.ModuleName], auth.ProtoBaseAccount, maccPerms,
)
app.BankKeeper = bank.NewBaseKeeper(
appCodec, keys[bank.StoreKey], app.AccountKeeper, app.subspaces[bank.ModuleName], app.BlacklistedAccAddrs(),
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.subspaces[banktypes.ModuleName], app.BlacklistedAccAddrs(),
)
stakingKeeper := stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.subspaces[stakingtypes.ModuleName],
Expand Down Expand Up @@ -323,7 +325,7 @@ func NewSimApp(
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
app.mm.SetOrderInitGenesis(
capabilitytypes.ModuleName, auth.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, bank.ModuleName,
capabilitytypes.ModuleName, auth.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, banktypes.ModuleName,
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
)
Expand Down
10 changes: 5 additions & 5 deletions simapp/cmd/simd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/types"
authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)
Expand Down Expand Up @@ -88,7 +88,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
// create concrete account type based on input parameters
var genAccount types.GenesisAccount

balances := bank.Balance{Address: addr, Coins: coins.Sort()}
balances := banktypes.Balance{Address: addr, Coins: coins.Sort()}
baseAccount := auth.NewBaseAccount(addr, nil, 0, 0)
if !vestingAmt.IsZero() {
baseVestingAccount := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd)
Expand Down Expand Up @@ -140,16 +140,16 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa

appState[auth.ModuleName] = authGenStateBz

bankGenState := bank.GetGenesisStateFromAppState(depCdc, appState)
bankGenState := banktypes.GetGenesisStateFromAppState(depCdc, appState)
bankGenState.Balances = append(bankGenState.Balances, balances)
bankGenState.Balances = bank.SanitizeGenesisBalances(bankGenState.Balances)
bankGenState.Balances = banktypes.SanitizeGenesisBalances(bankGenState.Balances)

bankGenStateBz, err := cdc.MarshalJSON(bankGenState)
if err != nil {
return fmt.Errorf("failed to marshal bank genesis state: %w", err)
}

appState[bank.ModuleName] = bankGenStateBz
appState[banktypes.ModuleName] = bankGenStateBz

appStateJSON, err := cdc.MarshalJSON(appState)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions simapp/cmd/simd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/cosmos/cosmos-sdk/x/staking"
)
Expand Down Expand Up @@ -47,16 +47,16 @@ func main() {

rootCmd.AddCommand(
genutilcli.InitCmd(ctx, cdc, simapp.ModuleBasics, simapp.DefaultNodeHome),
genutilcli.CollectGenTxsCmd(ctx, cdc, bank.GenesisBalancesIterator{}, simapp.DefaultNodeHome),
genutilcli.CollectGenTxsCmd(ctx, cdc, banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome),
genutilcli.MigrateGenesisCmd(ctx, cdc),
genutilcli.GenTxCmd(
ctx, cdc, simapp.ModuleBasics, staking.AppModuleBasic{},
bank.GenesisBalancesIterator{}, simapp.DefaultNodeHome, simapp.DefaultCLIHome,
banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome, simapp.DefaultCLIHome,
),
genutilcli.ValidateGenesisCmd(ctx, cdc, simapp.ModuleBasics),
AddGenesisAccountCmd(ctx, cdc, appCodec, simapp.DefaultNodeHome, simapp.DefaultCLIHome),
flags.NewCompletionCmd(rootCmd, true),
testnetCmd(ctx, cdc, simapp.ModuleBasics, bank.GenesisBalancesIterator{}),
testnetCmd(ctx, cdc, simapp.ModuleBasics, banktypes.GenesisBalancesIterator{}),
debug.Cmd(cdc))

server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators)
Expand Down
20 changes: 10 additions & 10 deletions simapp/cmd/simd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"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"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"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 All @@ -46,7 +46,7 @@ var (

// get cmd to initialize all files for tendermint testnet and application
func testnetCmd(ctx *server.Context, cdc codec.JSONMarshaler,
mbm module.BasicManager, genBalIterator bank.GenesisBalancesIterator,
mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator,
) *cobra.Command {

cmd := &cobra.Command{
Expand Down Expand Up @@ -106,7 +106,7 @@ const nodeDirPerm = 0755
// Initialize the testnet
func InitTestnet(
cmd *cobra.Command, config *tmconfig.Config, cdc codec.JSONMarshaler,
mbm module.BasicManager, genBalIterator bank.GenesisBalancesIterator,
mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator,
outputDir, chainID, minGasPrices, nodeDirPrefix, nodeDaemonHome,
nodeCLIHome, startingIPAddress string, numValidators int,
) error {
Expand All @@ -124,7 +124,7 @@ func InitTestnet(

var (
genAccounts []authtypes.GenesisAccount
genBalances []bank.Balance
genBalances []banktypes.Balance
genFiles []string
)

Expand Down Expand Up @@ -203,7 +203,7 @@ func InitTestnet(
sdk.NewCoin(sdk.DefaultBondDenom, accStakingTokens),
}

genBalances = append(genBalances, bank.Balance{Address: addr, Coins: coins.Sort()})
genBalances = append(genBalances, banktypes.Balance{Address: addr, Coins: coins.Sort()})
genAccounts = append(genAccounts, auth.NewBaseAccount(addr, nil, 0, 0))

valTokens := sdk.TokensFromConsensusPower(100)
Expand Down Expand Up @@ -258,7 +258,7 @@ func InitTestnet(

func initGenFiles(
cdc codec.JSONMarshaler, mbm module.BasicManager, chainID string,
genAccounts []authtypes.GenesisAccount, genBalances []bank.Balance,
genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance,
genFiles []string, numValidators int,
) error {

Expand All @@ -272,11 +272,11 @@ func initGenFiles(
appGenState[auth.ModuleName] = cdc.MustMarshalJSON(authGenState)

// set the balances in the genesis state
var bankGenState bank.GenesisState
cdc.MustUnmarshalJSON(appGenState[bank.ModuleName], &bankGenState)
var bankGenState banktypes.GenesisState
cdc.MustUnmarshalJSON(appGenState[banktypes.ModuleName], &bankGenState)

bankGenState.Balances = genBalances
appGenState[bank.ModuleName] = cdc.MustMarshalJSON(bankGenState)
appGenState[banktypes.ModuleName] = cdc.MustMarshalJSON(bankGenState)

appGenStateJSON, err := codec.MarshalJSONIndent(cdc, appGenState)
if err != nil {
Expand All @@ -302,7 +302,7 @@ func collectGenFiles(
cdc codec.JSONMarshaler, config *tmconfig.Config, chainID string,
monikers, nodeIDs []string, valPubKeys []crypto.PubKey,
numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string,
genBalIterator bank.GenesisBalancesIterator,
genBalIterator banktypes.GenesisBalancesIterator,
) error {

var appState json.RawMessage
Expand Down
4 changes: 2 additions & 2 deletions simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestAppImportExport(t *testing.T) {
{app.keys[slashingtypes.StoreKey], newApp.keys[slashingtypes.StoreKey], [][]byte{}},
{app.keys[minttypes.StoreKey], newApp.keys[minttypes.StoreKey], [][]byte{}},
{app.keys[distrtypes.StoreKey], newApp.keys[distrtypes.StoreKey], [][]byte{}},
{app.keys[bank.StoreKey], newApp.keys[bank.StoreKey], [][]byte{bank.BalancesPrefix}},
{app.keys[banktypes.StoreKey], newApp.keys[banktypes.StoreKey], [][]byte{banktypes.BalancesPrefix}},
{app.keys[paramtypes.StoreKey], newApp.keys[paramtypes.StoreKey], [][]byte{}},
{app.keys[govtypes.StoreKey], newApp.keys[govtypes.StoreKey], [][]byte{}},
{app.keys[evidencetypes.StoreKey], newApp.keys[evidencetypes.StoreKey], [][]byte{}},
Expand Down
10 changes: 5 additions & 5 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp/helpers"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

// DefaultConsensusParams defines the default Tendermint consensus params used in
Expand Down Expand Up @@ -69,7 +69,7 @@ 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 []auth.GenesisAccount, balances ...banktypes.Balance) *SimApp {
db := dbm.NewMemDB()
app := NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0)

Expand All @@ -84,8 +84,8 @@ func SetupWithGenesisAccounts(genAccs []auth.GenesisAccount, balances ...bank.Ba
totalSupply = totalSupply.Add(b.Coins...)
}

bankGenesis := bank.NewGenesisState(bank.DefaultGenesisState().SendEnabled, balances, totalSupply)
genesisState[bank.ModuleName] = app.Codec().MustMarshalJSON(bankGenesis)
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().SendEnabled, balances, totalSupply)
genesisState[banktypes.ModuleName] = app.Codec().MustMarshalJSON(bankGenesis)

stateBytes, err := codec.MarshalJSONIndent(app.Codec(), genesisState)
if err != nil {
Expand Down Expand Up @@ -157,7 +157,7 @@ func AddTestAddrsFromPubKeys(app *SimApp, ctx sdk.Context, pubKeys []crypto.PubK
func setTotalSupply(app *SimApp, ctx sdk.Context, accAmt sdk.Int, totalAccounts int) {
totalSupply := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt.MulRaw(int64(totalAccounts))))
prevSupply := app.BankKeeper.GetSupply(ctx)
app.BankKeeper.SetSupply(ctx, bank.NewSupply(prevSupply.GetTotal().Add(totalSupply...)))
app.BankKeeper.SetSupply(ctx, banktypes.NewSupply(prevSupply.GetTotal().Add(totalSupply...)))
}

// AddTestAddrs constructs and returns accNum amount of accounts with an
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/simd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"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/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

func TestCLISimdCollectGentxs(t *testing.T) {
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestCLISimdAddGenesisAccount(t *testing.T) {
appCodec := std.NewAppCodec(f.Cdc, interfaceRegistry)

accounts := auth.GetGenesisStateFromAppState(appCodec, genesisState).Accounts
balances := bank.GetGenesisStateFromAppState(f.Cdc, genesisState).Balances
balances := banktypes.GetGenesisStateFromAppState(f.Cdc, genesisState).Balances
balancesSet := make(map[string]sdk.Coins)

for _, b := range balances {
Expand Down
4 changes: 2 additions & 2 deletions x/auth/signing/amino/amino_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"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/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) {
Expand All @@ -29,7 +29,7 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) {
}
memo := "foo"
msgs := []sdk.Msg{
&bank.MsgSend{
&banktypes.MsgSend{
FromAddress: addr1,
ToAddress: addr2,
Amount: coins,
Expand Down
4 changes: 2 additions & 2 deletions x/auth/signing/handler_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/signing/amino"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

func MakeTestHandlerMap() signing.SignModeHandler {
Expand All @@ -38,7 +38,7 @@ func TestHandlerMap_GetSignBytes(t *testing.T) {
}
memo := "foo"
msgs := []sdk.Msg{
&bank.MsgSend{
&banktypes.MsgSend{
FromAddress: addr1,
ToAddress: addr2,
Amount: coins,
Expand Down
Loading

0 comments on commit 24b9be0

Please sign in to comment.