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

refactor(x/auth): auth module can recognize x/accounts account #20002

Merged
merged 13 commits into from
Apr 11, 2024
2 changes: 2 additions & 0 deletions client/rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"

_ "cosmossdk.io/x/accounts"

"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/types/address"
Expand Down
1 change: 1 addition & 0 deletions server/api/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/stretchr/testify/suite"
"google.golang.org/grpc/codes"

_ "cosmossdk.io/x/accounts"
_ "cosmossdk.io/x/auth"
_ "cosmossdk.io/x/auth/tx/config"
_ "cosmossdk.io/x/bank"
Expand Down
2 changes: 1 addition & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func NewSimApp(
}
app.AccountsKeeper = accountsKeeper

app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger), appCodec, authtypes.ProtoBaseAccount, maccPerms, signingCtx.AddressCodec(), sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger), appCodec, authtypes.ProtoBaseAccount, maccPerms, signingCtx.AddressCodec(), sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AccountsKeeper)

app.BankKeeper = bankkeeper.NewBaseKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), logger),
Expand Down
7 changes: 7 additions & 0 deletions simapp/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"google.golang.org/protobuf/types/known/durationpb"

accountsmodulev1 "cosmossdk.io/api/cosmos/accounts/module/v1"
runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
Expand All @@ -29,6 +30,7 @@ import (
upgrademodulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1"
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
"cosmossdk.io/depinject/appconfig"
"cosmossdk.io/x/accounts"
_ "cosmossdk.io/x/auth/tx/config" // import for side-effects
authtypes "cosmossdk.io/x/auth/types"
_ "cosmossdk.io/x/auth/vesting" // import for side-effects
Expand Down Expand Up @@ -138,6 +140,7 @@ var (
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
InitGenesis: []string{
accounts.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
Expand Down Expand Up @@ -258,6 +261,10 @@ var (
Name: pooltypes.ModuleName,
Config: appconfig.WrapAny(&poolmodulev1.Module{}),
},
{
Name: accounts.ModuleName,
Config: appconfig.WrapAny(&accountsmodulev1.Module{}),
},
{
Name: epochstypes.ModuleName,
Config: appconfig.WrapAny(&epochsmodulev1.Module{}),
Expand Down
3 changes: 3 additions & 0 deletions simapp/app_di.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"cosmossdk.io/depinject"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/accounts"
"cosmossdk.io/x/auth"
"cosmossdk.io/x/auth/ante"
"cosmossdk.io/x/auth/ante/unorderedtx"
Expand Down Expand Up @@ -74,6 +75,7 @@ type SimApp struct {
UnorderedTxManager *unorderedtx.Manager

// keepers
AccountsKeeper accounts.Keeper
AuthKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
Expand Down Expand Up @@ -184,6 +186,7 @@ func NewSimApp(
&app.txConfig,
&app.interfaceRegistry,
&app.AuthKeeper,
&app.AccountsKeeper,
&app.BankKeeper,
&app.StakingKeeper,
&app.SlashingKeeper,
Expand Down
3 changes: 2 additions & 1 deletion simapp/simd/cmd/testnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

func Test_TestnetCmd(t *testing.T) {
config := configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.BankModule(),
configurator.GenutilModule(),
Expand All @@ -44,7 +45,7 @@ func Test_TestnetCmd(t *testing.T) {
)
require.NoError(t, err)
require.NotNil(t, moduleManager)
require.Len(t, moduleManager.Modules, 7)
require.Len(t, moduleManager.Modules, 8)

home := t.TempDir()
cdcOpts := codectestutil.CodecOptions{}
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
store "cosmossdk.io/store/types"
_ "cosmossdk.io/x/accounts"
xauthsigning "cosmossdk.io/x/auth/signing"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -85,6 +86,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
err = depinject.Inject(
depinject.Configs(
configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/bank/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"cosmossdk.io/depinject"
"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
_ "cosmossdk.io/x/accounts"
_ "cosmossdk.io/x/auth"
_ "cosmossdk.io/x/auth/tx/config"
authtypes "cosmossdk.io/x/auth/types"
Expand Down Expand Up @@ -92,6 +93,7 @@ func createTestSuite(t *testing.T, genesisAccounts []authtypes.GenesisAccount) s
app, err := simtestutil.SetupWithConfiguration(
depinject.Configs(
configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.TxModule(),
Expand Down
1 change: 1 addition & 0 deletions tests/integration/bank/keeper/deterministic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
sdk.Bech32MainPrefix,
authority.String(),
nil,
)

blockedAddresses := map[string]bool{
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/distribution/appconfig.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package distribution_test

import (
_ "cosmossdk.io/x/accounts" // import as blank for app wiring
_ "cosmossdk.io/x/auth" // import as blank for app wiring
_ "cosmossdk.io/x/auth/tx/config" // import as blank for app wiring
_ "cosmossdk.io/x/bank" // import as blank for app wiring
Expand All @@ -15,6 +16,7 @@ import (
)

var AppConfig = configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.BankModule(),
configurator.StakingModule(),
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/distribution/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"

Expand All @@ -16,6 +17,7 @@ import (
"cosmossdk.io/x/auth"
authkeeper "cosmossdk.io/x/auth/keeper"
authsims "cosmossdk.io/x/auth/simulation"
authtestutil "cosmossdk.io/x/auth/testutil"
authtypes "cosmossdk.io/x/auth/types"
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
Expand Down Expand Up @@ -85,6 +87,10 @@ func initFixture(t *testing.T) *fixture {
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
}

// gomock initializations
ctrl := gomock.NewController(t)
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)

accountKeeper := authkeeper.NewAccountKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
cdc,
Expand All @@ -93,6 +99,7 @@ func initFixture(t *testing.T) *fixture {
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
sdk.Bech32MainPrefix,
authority.String(),
acctsModKeeper,
)

blockedAddresses := map[string]bool{
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/evidence/app_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package evidence_test

import (
_ "cosmossdk.io/x/accounts" // import as blank for app wiring
_ "cosmossdk.io/x/auth" // import as blank for app wiring
_ "cosmossdk.io/x/auth/tx/config" // import as blank for app wiring
_ "cosmossdk.io/x/bank" // import as blank for app wiring
Expand All @@ -14,6 +15,7 @@ import (
)

var AppConfig = configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.BankModule(),
configurator.StakingModule(),
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/evidence/keeper/infraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/golang/mock/gomock"
"gotest.tools/v3/assert"

"cosmossdk.io/collections"
Expand All @@ -20,6 +21,7 @@ import (
"cosmossdk.io/x/auth"
authkeeper "cosmossdk.io/x/auth/keeper"
authsims "cosmossdk.io/x/auth/simulation"
authtestutil "cosmossdk.io/x/auth/testutil"
authtypes "cosmossdk.io/x/auth/types"
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
Expand Down Expand Up @@ -98,6 +100,10 @@ func initFixture(tb testing.TB) *fixture {

authority := authtypes.NewModuleAddress("gov")

// gomock initializations
ctrl := gomock.NewController(tb)
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)

maccPerms := map[string][]string{
pooltypes.ModuleName: {},
minttypes.ModuleName: {authtypes.Minter},
Expand All @@ -113,6 +119,7 @@ func initFixture(tb testing.TB) *fixture {
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
sdk.Bech32MainPrefix,
authority.String(),
acctsModKeeper,
)

blockedAddresses := map[string]bool{
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/example/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Example() {
addresscodec.NewBech32Codec("cosmos"),
"cosmos",
authority,
nil,
)

// subspace is nil because we don't test params (which is legacy anyway)
Expand Down Expand Up @@ -141,6 +142,7 @@ func Example_oneModule() {
addresscodec.NewBech32Codec("cosmos"),
"cosmos",
authority,
nil,
)

// subspace is nil because we don't test params (which is legacy anyway)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/gov/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"cosmossdk.io/depinject"
sdklog "cosmossdk.io/log"
"cosmossdk.io/math"
_ "cosmossdk.io/x/accounts"
_ "cosmossdk.io/x/auth"
authtypes "cosmossdk.io/x/auth/types"
_ "cosmossdk.io/x/bank"
Expand Down Expand Up @@ -105,6 +106,7 @@ func createTestSuite(t *testing.T) suite {
app, err := simtestutil.SetupWithConfiguration(
depinject.Configs(
configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.BankModule(),
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/gov/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"cosmossdk.io/depinject"
"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
_ "cosmossdk.io/x/accounts"
_ "cosmossdk.io/x/auth"
authkeeper "cosmossdk.io/x/auth/keeper"
authtypes "cosmossdk.io/x/auth/types"
Expand Down Expand Up @@ -46,6 +47,7 @@ type suite struct {
}

var appConfig = configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.BankModule(),
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/gov/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"cosmossdk.io/x/auth"
authkeeper "cosmossdk.io/x/auth/keeper"
authsims "cosmossdk.io/x/auth/simulation"
authtestutil "cosmossdk.io/x/auth/testutil"
authtypes "cosmossdk.io/x/auth/types"
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
Expand All @@ -26,6 +27,7 @@ import (
"cosmossdk.io/x/staking"
stakingkeeper "cosmossdk.io/x/staking/keeper"
stakingtypes "cosmossdk.io/x/staking/types"
"github.com/golang/mock/gomock"

"github.com/cosmos/cosmos-sdk/baseapp"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
Expand Down Expand Up @@ -72,6 +74,10 @@ func initFixture(tb testing.TB) *fixture {
types.ModuleName: {authtypes.Burner},
}

// gomock initializations
ctrl := gomock.NewController(tb)
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)

accountKeeper := authkeeper.NewAccountKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
cdc,
Expand All @@ -80,6 +86,7 @@ func initFixture(tb testing.TB) *fixture {
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
sdk.Bech32MainPrefix,
authority.String(),
acctsModKeeper,
)

blockedAddresses := map[string]bool{
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/gov/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"cosmossdk.io/depinject"
"cosmossdk.io/log"
_ "cosmossdk.io/x/accounts"
authkeeper "cosmossdk.io/x/auth/keeper"
authtypes "cosmossdk.io/x/auth/types"
"cosmossdk.io/x/gov/types"
Expand All @@ -22,6 +23,7 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
app, err := simtestutil.SetupAtGenesis(
depinject.Configs(
configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.BankModule(),
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/mint/app_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mint

import (
_ "cosmossdk.io/x/accounts" // import as blank for app wiring
_ "cosmossdk.io/x/auth" // import as blank for app wiring
_ "cosmossdk.io/x/auth/tx/config" // import as blank for app wiring
_ "cosmossdk.io/x/bank" // import as blank for app wiring
Expand All @@ -13,6 +14,7 @@ import (
)

var AppConfig = configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.BankModule(),
configurator.StakingModule(),
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/runtime/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
_ "cosmossdk.io/x/accounts"
_ "cosmossdk.io/x/auth"
_ "cosmossdk.io/x/auth/tx/config"
_ "cosmossdk.io/x/bank"
Expand Down Expand Up @@ -42,6 +43,7 @@ func initFixture(t assert.TestingT) *fixture {
app, err := simtestutil.Setup(
depinject.Configs(
configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/slashing/app_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package slashing

import (
_ "cosmossdk.io/x/accounts" // import as blank for app wiring
_ "cosmossdk.io/x/auth" // import as blank for app wiring
_ "cosmossdk.io/x/auth/tx/config" // import as blank for app wiring
_ "cosmossdk.io/x/bank" // import as blank for app wiring
Expand All @@ -16,6 +17,7 @@ import (
)

var AppConfig = configurator.NewAppConfig(
configurator.AccountsModule(),
configurator.AuthModule(),
configurator.BankModule(),
configurator.StakingModule(),
Expand Down
Loading
Loading