refactor(x/auth): auth module can recognize x/accounts account (#20002)
This commit is contained in:
parent
1d2a795eaf
commit
a0d727eebc
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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"
|
||||
@ -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
|
||||
@ -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,
|
||||
@ -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{}),
|
||||
|
||||
@ -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"
|
||||
@ -74,6 +75,7 @@ type SimApp struct {
|
||||
UnorderedTxManager *unorderedtx.Manager
|
||||
|
||||
// keepers
|
||||
AccountsKeeper accounts.Keeper
|
||||
AuthKeeper authkeeper.AccountKeeper
|
||||
BankKeeper bankkeeper.Keeper
|
||||
StakingKeeper *stakingkeeper.Keeper
|
||||
@ -184,6 +186,7 @@ func NewSimApp(
|
||||
&app.txConfig,
|
||||
&app.interfaceRegistry,
|
||||
&app.AuthKeeper,
|
||||
&app.AccountsKeeper,
|
||||
&app.BankKeeper,
|
||||
&app.StakingKeeper,
|
||||
&app.SlashingKeeper,
|
||||
|
||||
@ -27,6 +27,7 @@ import (
|
||||
|
||||
func Test_TestnetCmd(t *testing.T) {
|
||||
config := configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.GenutilModule(),
|
||||
@ -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{}
|
||||
|
||||
@ -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"
|
||||
@ -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(),
|
||||
|
||||
@ -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"
|
||||
@ -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(),
|
||||
|
||||
@ -86,6 +86,7 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
nil,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
|
||||
@ -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
|
||||
@ -15,6 +16,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
@ -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"
|
||||
@ -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,
|
||||
@ -93,6 +99,7 @@ func initFixture(t *testing.T) *fixture {
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
|
||||
@ -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
|
||||
@ -14,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -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"
|
||||
@ -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"
|
||||
@ -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},
|
||||
@ -113,6 +119,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
|
||||
@ -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)
|
||||
@ -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)
|
||||
|
||||
@ -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"
|
||||
@ -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(),
|
||||
|
||||
@ -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"
|
||||
@ -46,6 +47,7 @@ type suite struct {
|
||||
}
|
||||
|
||||
var appConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.BankModule(),
|
||||
|
||||
@ -3,6 +3,7 @@ package keeper_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
@ -11,6 +12,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"
|
||||
@ -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,
|
||||
@ -80,6 +86,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
|
||||
@ -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"
|
||||
@ -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(),
|
||||
|
||||
@ -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
|
||||
@ -13,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -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"
|
||||
@ -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(),
|
||||
|
||||
@ -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
|
||||
@ -16,6 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
@ -14,6 +15,7 @@ import (
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/auth"
|
||||
authkeeper "cosmossdk.io/x/auth/keeper"
|
||||
authtestutil "cosmossdk.io/x/auth/testutil"
|
||||
authtypes "cosmossdk.io/x/auth/types"
|
||||
"cosmossdk.io/x/bank"
|
||||
bankkeeper "cosmossdk.io/x/bank/keeper"
|
||||
@ -73,6 +75,10 @@ func initFixture(tb testing.TB) *fixture {
|
||||
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
}
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(&testing.T{})
|
||||
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
@ -81,6 +87,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
|
||||
@ -62,6 +62,7 @@ func TestSlashingMsgs(t *testing.T) {
|
||||
app, err := sims.SetupWithConfiguration(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.SlashingModule(),
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package staking
|
||||
|
||||
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
|
||||
@ -16,6 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
@ -13,6 +14,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"
|
||||
@ -122,6 +124,10 @@ func initFixture(tb testing.TB) *fixture {
|
||||
types.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
|
||||
}
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(&testing.T{})
|
||||
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
@ -130,6 +136,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"gotest.tools/v3/assert"
|
||||
"pgregory.net/rapid"
|
||||
|
||||
@ -14,6 +15,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"
|
||||
@ -86,6 +88,10 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
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,
|
||||
@ -94,6 +100,7 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
_ "cosmossdk.io/x/accounts"
|
||||
"cosmossdk.io/x/tx/signing"
|
||||
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
@ -33,6 +34,7 @@ func TestDefineCustomGetSigners(t *testing.T) {
|
||||
_, err := simtestutil.SetupAtGenesis(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.StakingModule(),
|
||||
configurator.BankModule(),
|
||||
|
||||
@ -11,7 +11,8 @@ import (
|
||||
"cosmossdk.io/core/header"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
_ "cosmossdk.io/x/auth" // import as blank for app wiring
|
||||
_ "cosmossdk.io/x/accounts" // import as blank for app wiring
|
||||
_ "cosmossdk.io/x/auth" // import as blank for app wiring
|
||||
authkeeper "cosmossdk.io/x/auth/keeper"
|
||||
_ "cosmossdk.io/x/auth/tx/config" // import as blank for app wiring
|
||||
"cosmossdk.io/x/authz"
|
||||
@ -39,6 +40,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
_ "cosmossdk.io/x/accounts"
|
||||
_ "cosmossdk.io/x/auth"
|
||||
_ "cosmossdk.io/x/auth/tx/config"
|
||||
_ "cosmossdk.io/x/bank"
|
||||
@ -47,6 +48,7 @@ func (suite *SimTestSuite) SetupTest() {
|
||||
suite.app, err = simtestutil.Setup(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package distribution
|
||||
|
||||
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
|
||||
@ -15,6 +16,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
"cosmossdk.io/core/header"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
_ "cosmossdk.io/x/accounts" // import as blank for app wiring
|
||||
_ "cosmossdk.io/x/auth"
|
||||
authkeeper "cosmossdk.io/x/auth/keeper"
|
||||
_ "cosmossdk.io/x/auth/tx/config"
|
||||
@ -56,6 +57,7 @@ func (suite *SimTestSuite) SetupTest() {
|
||||
suite.app, err = simtestutil.Setup(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
"cosmossdk.io/core/header"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
_ "cosmossdk.io/x/accounts"
|
||||
_ "cosmossdk.io/x/auth"
|
||||
authkeeper "cosmossdk.io/x/auth/keeper"
|
||||
_ "cosmossdk.io/x/auth/tx/config"
|
||||
@ -384,6 +385,7 @@ func createTestSuite(t *testing.T, isCheckTx bool) (suite, sdk.Context) {
|
||||
app, err := simtestutil.Setup(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.TxModule(),
|
||||
configurator.BankModule(),
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package nft
|
||||
|
||||
import (
|
||||
_ "cosmossdk.io/x/accounts"
|
||||
_ "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
|
||||
@ -14,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package protocolpool
|
||||
|
||||
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
|
||||
@ -15,6 +16,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -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
|
||||
@ -16,6 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package configurator
|
||||
|
||||
import (
|
||||
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"
|
||||
@ -89,6 +90,7 @@ func defaultConfig() *Config {
|
||||
testutil.ProtocolPoolModuleName,
|
||||
},
|
||||
InitGenesisOrder: []string{
|
||||
testutil.AccountsModuleName,
|
||||
testutil.AuthModuleName,
|
||||
testutil.BankModuleName,
|
||||
testutil.DistributionModuleName,
|
||||
@ -330,6 +332,15 @@ func ProtocolPoolModule() ModuleOption {
|
||||
}
|
||||
}
|
||||
|
||||
func AccountsModule() ModuleOption {
|
||||
return func(config *Config) {
|
||||
config.ModuleConfigs[testutil.AccountsModuleName] = &appv1alpha1.ModuleConfig{
|
||||
Name: testutil.AccountsModuleName,
|
||||
Config: appconfig.WrapAny(&accountsmodulev1.Module{}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CounterModule() ModuleOption {
|
||||
return func(config *Config) {
|
||||
config.ModuleConfigs["counter"] = &appv1alpha1.ModuleConfig{
|
||||
|
||||
@ -25,6 +25,7 @@ import (
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"cosmossdk.io/math/unsafe"
|
||||
pruningtypes "cosmossdk.io/store/pruning/types"
|
||||
_ "cosmossdk.io/x/accounts"
|
||||
_ "cosmossdk.io/x/auth" // import auth as a blank
|
||||
_ "cosmossdk.io/x/auth/tx/config" // import auth tx config as a blank
|
||||
authtypes "cosmossdk.io/x/auth/types"
|
||||
@ -168,6 +169,7 @@ func DefaultConfig(factory TestFixtureFactory) Config {
|
||||
// MinimumAppConfig defines the minimum of modules required for a call to New to succeed
|
||||
func MinimumAppConfig() depinject.Config {
|
||||
return configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.GenutilModule(),
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
"cosmossdk.io/store/prefix"
|
||||
_ "cosmossdk.io/x/accounts"
|
||||
_ "cosmossdk.io/x/auth"
|
||||
authkeeper "cosmossdk.io/x/auth/keeper"
|
||||
_ "cosmossdk.io/x/bank"
|
||||
@ -68,6 +69,7 @@ func (s *paginationTestSuite) SetupTest() {
|
||||
app, err := testutilsims.Setup(
|
||||
depinject.Configs(
|
||||
configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.ConsensusModule(),
|
||||
|
||||
@ -1,8 +1,73 @@
|
||||
package accounts
|
||||
|
||||
import "cosmossdk.io/depinject"
|
||||
import (
|
||||
"context"
|
||||
|
||||
modulev1 "cosmossdk.io/api/cosmos/accounts/module/v1"
|
||||
signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/depinject/appconfig"
|
||||
baseaccount "cosmossdk.io/x/accounts/defaults/base"
|
||||
"cosmossdk.io/x/tx/signing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
)
|
||||
|
||||
var _ depinject.OnePerModuleType = AppModule{}
|
||||
|
||||
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
|
||||
func (am AppModule) IsOnePerModuleType() {}
|
||||
|
||||
func init() {
|
||||
appconfig.RegisterModule(
|
||||
&modulev1.Module{},
|
||||
appconfig.Provide(ProvideModule),
|
||||
)
|
||||
}
|
||||
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
|
||||
Cdc codec.Codec
|
||||
Environment appmodule.Environment
|
||||
AddressCodec address.Codec
|
||||
ExecRouter MsgRouter
|
||||
QueryRouter QueryRouter
|
||||
Registry cdctypes.InterfaceRegistry
|
||||
}
|
||||
|
||||
type ModuleOutputs struct {
|
||||
depinject.Out
|
||||
|
||||
AccountsKeeper Keeper
|
||||
Module appmodule.AppModule
|
||||
}
|
||||
|
||||
var _ signing.SignModeHandler = directHandler{}
|
||||
|
||||
type directHandler struct{}
|
||||
|
||||
func (s directHandler) Mode() signingv1beta1.SignMode {
|
||||
return signingv1beta1.SignMode_SIGN_MODE_DIRECT
|
||||
}
|
||||
|
||||
func (s directHandler) GetSignBytes(_ context.Context, _ signing.SignerData, _ signing.TxData) ([]byte, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
handler := directHandler{}
|
||||
account := baseaccount.NewAccount("base", signing.NewHandlerMap(handler))
|
||||
accountskeeper, err := NewKeeper(
|
||||
in.Cdc, in.Environment, in.AddressCodec, in.Cdc,
|
||||
in.ExecRouter, in.QueryRouter, in.Registry, account,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
m := NewAppModule(in.Cdc, accountskeeper)
|
||||
return ModuleOutputs{AccountsKeeper: accountskeeper, Module: m}
|
||||
}
|
||||
|
||||
@ -126,6 +126,15 @@ type Keeper struct {
|
||||
AccountsState collections.Map[collections.Pair[uint64, []byte], []byte]
|
||||
}
|
||||
|
||||
// IsAccountsModuleAccount check if an address belong to a smart account.
|
||||
func (k Keeper) IsAccountsModuleAccount(
|
||||
ctx context.Context,
|
||||
accountAddr []byte,
|
||||
) bool {
|
||||
hasAcc, _ := k.AccountByNumber.Has(ctx, accountAddr)
|
||||
return hasAcc
|
||||
}
|
||||
|
||||
// Init creates a new account of the given type.
|
||||
func (k Keeper) Init(
|
||||
ctx context.Context,
|
||||
|
||||
@ -81,7 +81,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
|
||||
|
||||
suite.accountKeeper = keeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()), suite.encCfg.Codec, types.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec("cosmos"),
|
||||
sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(),
|
||||
sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(), nil,
|
||||
)
|
||||
suite.accountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName)
|
||||
err := suite.accountKeeper.Params.Set(suite.ctx, types.DefaultParams())
|
||||
|
||||
@ -27,6 +27,7 @@ func init() {
|
||||
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
AccountsModKeeper types.AccountsModKeeper
|
||||
|
||||
Config *modulev1.Module
|
||||
Environment appmodule.Environment
|
||||
@ -69,7 +70,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
k := keeper.NewAccountKeeper(in.Environment, in.Cdc, in.AccountI, maccPerms, in.AddressCodec, in.Config.Bech32Prefix, auth)
|
||||
k := keeper.NewAccountKeeper(in.Environment, in.Cdc, in.AccountI, maccPerms, in.AddressCodec, in.Config.Bech32Prefix, auth, in.AccountsModKeeper)
|
||||
m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn)
|
||||
|
||||
return ModuleOutputs{AccountKeeper: k, Module: m}
|
||||
|
||||
@ -32,7 +32,7 @@ func (ak AccountKeeper) NewAccount(ctx context.Context, acc sdk.AccountI) sdk.Ac
|
||||
// HasAccount implements AccountKeeperI.
|
||||
func (ak AccountKeeper) HasAccount(ctx context.Context, addr sdk.AccAddress) bool {
|
||||
has, _ := ak.Accounts.Has(ctx, addr)
|
||||
return has
|
||||
return has || ak.AccountsModKeeper.IsAccountsModuleAccount(ctx, addr)
|
||||
}
|
||||
|
||||
// GetAccount implements AccountKeeperI.
|
||||
|
||||
@ -79,6 +79,7 @@ func (suite *DeterministicTestSuite) SetupTest() {
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
types.NewModuleAddress("gov").String(),
|
||||
nil,
|
||||
)
|
||||
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.encCfg.InterfaceRegistry)
|
||||
@ -299,6 +300,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() {
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
types.NewModuleAddress("gov").String(),
|
||||
nil,
|
||||
)
|
||||
suite.setModuleAccounts(suite.ctx, ak, maccs)
|
||||
|
||||
@ -346,6 +348,7 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() {
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
types.NewModuleAddress("gov").String(),
|
||||
nil,
|
||||
)
|
||||
suite.setModuleAccounts(suite.ctx, ak, []string{mName})
|
||||
|
||||
|
||||
@ -83,7 +83,8 @@ func (a AccountsIndexes) IndexesList() []collections.Index[sdk.AccAddress, sdk.A
|
||||
// AccountKeeper encodes/decodes accounts using the go-amino (binary)
|
||||
// encoding/decoding library.
|
||||
type AccountKeeper struct {
|
||||
addressCodec address.Codec
|
||||
addressCodec address.Codec
|
||||
AccountsModKeeper types.AccountsModKeeper
|
||||
|
||||
environment appmodule.Environment
|
||||
cdc codec.BinaryCodec
|
||||
@ -115,7 +116,7 @@ var _ AccountKeeperI = &AccountKeeper{}
|
||||
// may use auth.Keeper to access the accounts permissions map.
|
||||
func NewAccountKeeper(
|
||||
env appmodule.Environment, cdc codec.BinaryCodec, proto func() sdk.AccountI,
|
||||
maccPerms map[string][]string, ac address.Codec, bech32Prefix, authority string,
|
||||
maccPerms map[string][]string, ac address.Codec, bech32Prefix, authority string, accountsModKeeper types.AccountsModKeeper,
|
||||
) AccountKeeper {
|
||||
permAddrs := make(map[string]types.PermissionsForAddress)
|
||||
for name, perms := range maccPerms {
|
||||
@ -125,16 +126,17 @@ func NewAccountKeeper(
|
||||
sb := collections.NewSchemaBuilder(env.KVStoreService)
|
||||
|
||||
ak := AccountKeeper{
|
||||
addressCodec: ac,
|
||||
bech32Prefix: bech32Prefix,
|
||||
environment: env,
|
||||
proto: proto,
|
||||
cdc: cdc,
|
||||
permAddrs: permAddrs,
|
||||
authority: authority,
|
||||
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
|
||||
AccountNumber: collections.NewSequence(sb, types.GlobalAccountNumberKey, "account_number"),
|
||||
Accounts: collections.NewIndexedMap(sb, types.AddressStoreKeyPrefix, "accounts", sdk.AccAddressKey, codec.CollInterfaceValue[sdk.AccountI](cdc), NewAccountIndexes(sb)),
|
||||
addressCodec: ac,
|
||||
bech32Prefix: bech32Prefix,
|
||||
environment: env,
|
||||
proto: proto,
|
||||
cdc: cdc,
|
||||
permAddrs: permAddrs,
|
||||
authority: authority,
|
||||
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
|
||||
AccountNumber: collections.NewSequence(sb, types.GlobalAccountNumberKey, "account_number"),
|
||||
Accounts: collections.NewIndexedMap(sb, types.AddressStoreKeyPrefix, "accounts", sdk.AccAddressKey, codec.CollInterfaceValue[sdk.AccountI](cdc), NewAccountIndexes(sb)),
|
||||
AccountsModKeeper: accountsModKeeper,
|
||||
}
|
||||
schema, err := sb.Build()
|
||||
if err != nil {
|
||||
|
||||
@ -72,6 +72,7 @@ func (suite *KeeperTestSuite) SetupTest() {
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
types.NewModuleAddress("gov").String(),
|
||||
nil,
|
||||
)
|
||||
suite.msgServer = keeper.NewMsgServerImpl(suite.accountKeeper)
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.encCfg.InterfaceRegistry)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package testutil
|
||||
|
||||
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/auth/vesting" // import as blank for app wiring
|
||||
@ -13,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.VestingModule(),
|
||||
|
||||
@ -81,3 +81,43 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAd
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromAccountToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromAccountToModule), ctx, senderAddr, recipientModule, amt)
|
||||
}
|
||||
|
||||
|
||||
// MockAccountsModKeeper is a mock of AccountsModKeeper interface.
|
||||
type MockAccountsModKeeper struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockAccountsModKeeperMockRecorder
|
||||
}
|
||||
|
||||
// MockAccountsModKeeperMockRecorder is the mock recorder for MockAccountsModKeeper.
|
||||
type MockAccountsModKeeperMockRecorder struct {
|
||||
mock *MockAccountsModKeeper
|
||||
}
|
||||
|
||||
// NewMockAccountsModKeeper creates a new mock instance.
|
||||
func NewMockAccountsModKeeper(ctrl *gomock.Controller) *MockAccountsModKeeper {
|
||||
mock := &MockAccountsModKeeper{ctrl: ctrl}
|
||||
mock.recorder = &MockAccountsModKeeperMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockAccountsModKeeper) EXPECT() *MockAccountsModKeeperMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// IsAccountsModuleAccount mocks base method.
|
||||
func (m *MockAccountsModKeeper) IsAccountsModuleAccount(ctx context.Context, addr []byte) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsAccountsModuleAccount", ctx, addr)
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsAccountsModuleAccount indicates an expected call of IsAccountsModuleAccount.
|
||||
func (mr *MockAccountsModKeeperMockRecorder) IsAccountsModuleAccount(ctx, addr interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAccountsModuleAccount", reflect.TypeOf((*MockAccountsModKeeper)(nil).IsAccountsModuleAccount), ctx, addr)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -12,3 +12,8 @@ type BankKeeper interface {
|
||||
SendCoins(ctx context.Context, from, to sdk.AccAddress, amt sdk.Coins) error
|
||||
SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
||||
}
|
||||
|
||||
// AccountsModKeeper defines the contract for x/accounts APIs
|
||||
type AccountsModKeeper interface {
|
||||
IsAccountsModuleAccount(ctx context.Context, accountAddr []byte) bool
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ func (s *VestingAccountTestSuite) SetupTest() {
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
authtypes.NewModuleAddress("gov").String(),
|
||||
authtypes.NewModuleAddress("gov").String(), nil,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -439,6 +439,10 @@ func (k BaseKeeper) setSupply(ctx context.Context, coin sdk.Coin) {
|
||||
func (k BaseKeeper) trackDelegation(ctx context.Context, addr sdk.AccAddress, balance, amt sdk.Coins) error {
|
||||
acc := k.ak.GetAccount(ctx, addr)
|
||||
if acc == nil {
|
||||
// check if it's an x/accounts smart account
|
||||
if k.ak.HasAccount(ctx, addr) {
|
||||
return nil
|
||||
}
|
||||
return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
|
||||
}
|
||||
|
||||
@ -456,6 +460,10 @@ func (k BaseKeeper) trackDelegation(ctx context.Context, addr sdk.AccAddress, ba
|
||||
func (k BaseKeeper) trackUndelegation(ctx context.Context, addr sdk.AccAddress, amt sdk.Coins) error {
|
||||
acc := k.ak.GetAccount(ctx, addr)
|
||||
if acc == nil {
|
||||
// check if it's an x/accounts smart account
|
||||
if k.ak.HasAccount(ctx, addr) {
|
||||
return nil
|
||||
}
|
||||
return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr)
|
||||
}
|
||||
|
||||
|
||||
@ -1778,6 +1778,7 @@ func (suite *KeeperTestSuite) TestUndelegateCoins_Invalid() {
|
||||
suite.mockFundAccount(accAddrs[0])
|
||||
require.NoError(banktestutil.FundAccount(ctx, suite.bankKeeper, accAddrs[0], origCoins))
|
||||
|
||||
suite.authKeeper.EXPECT().HasAccount(ctx, accAddrs[0]).Return(false)
|
||||
suite.mockDelegateCoins(ctx, acc0, holderAcc)
|
||||
require.NoError(suite.bankKeeper.DelegateCoins(ctx, accAddrs[0], holderAcc.GetAddress(), delCoins))
|
||||
|
||||
|
||||
@ -216,3 +216,17 @@ func (mr *MockAccountKeeperMockRecorder) ValidatePermissions(macc interface{}) *
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatePermissions", reflect.TypeOf((*MockAccountKeeper)(nil).ValidatePermissions), macc)
|
||||
}
|
||||
|
||||
// IsAccountsModuleAccount mocks base method.
|
||||
func (m *MockAccountKeeper) IsAccountsModuleAccount(ctx context.Context, addr []byte) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsAccountsModuleAccount", ctx, addr)
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsAccountsModuleAccount indicates an expected call of IsAccountsModuleAccount.
|
||||
func (mr *MockAccountKeeperMockRecorder) IsAccountsModuleAccount(ctx, addr interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAccountsModuleAccount", reflect.TypeOf((*MockAccountKeeper)(nil).IsAccountsModuleAccount), ctx, addr)
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ func TestFundsMigration(t *testing.T) {
|
||||
addressCodec,
|
||||
sdk.Bech32MainPrefix,
|
||||
authority,
|
||||
nil,
|
||||
)
|
||||
|
||||
// create bank keeper
|
||||
|
||||
@ -3,6 +3,7 @@ package v2_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"cosmossdk.io/core/address"
|
||||
@ -11,6 +12,7 @@ import (
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/auth"
|
||||
authkeeper "cosmossdk.io/x/auth/keeper"
|
||||
authtestutil "cosmossdk.io/x/auth/testutil"
|
||||
authtypes "cosmossdk.io/x/auth/types"
|
||||
"cosmossdk.io/x/group"
|
||||
"cosmossdk.io/x/group/internal/orm"
|
||||
@ -101,7 +103,10 @@ func createOldPolicyAccount(ctx sdk.Context, storeKey storetypes.StoreKey, cdc c
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
accountKeeper := authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)), log.NewNopLogger()), cdc, authtypes.ProtoBaseAccount, nil, addressCodec, sdk.Bech32MainPrefix, authorityStrAddr)
|
||||
ctrl := gomock.NewController(&testing.T{})
|
||||
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)), log.NewNopLogger()), cdc, authtypes.ProtoBaseAccount, nil, addressCodec, sdk.Bech32MainPrefix, authorityStrAddr, acctsModKeeper)
|
||||
|
||||
oldPolicyAccounts := make([]*authtypes.ModuleAccount, len(policies))
|
||||
for i, policyAddr := range policies {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package testutil
|
||||
|
||||
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/authz" // import as blank for app wiring
|
||||
@ -15,6 +16,7 @@ import (
|
||||
)
|
||||
|
||||
var AppConfig = configurator.NewAppConfig(
|
||||
configurator.AccountsModule(),
|
||||
configurator.AuthModule(),
|
||||
configurator.BankModule(),
|
||||
configurator.StakingModule(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user