feat: Add non atomic multimsg (#19350)
This commit is contained in:
parent
037cf98f7e
commit
07c0aa73e0
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,8 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
Msg_UpdateParams_FullMethodName = "/cosmos.auth.v1beta1.Msg/UpdateParams"
|
||||
Msg_UpdateParams_FullMethodName = "/cosmos.auth.v1beta1.Msg/UpdateParams"
|
||||
Msg_NonAtomicExec_FullMethodName = "/cosmos.auth.v1beta1.Msg/NonAtomicExec"
|
||||
)
|
||||
|
||||
// MsgClient is the client API for Msg service.
|
||||
@ -31,6 +32,8 @@ type MsgClient interface {
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
||||
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
|
||||
NonAtomicExec(ctx context.Context, in *MsgNonAtomicExec, opts ...grpc.CallOption) (*MsgNonAtomicExecResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@ -50,6 +53,15 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) NonAtomicExec(ctx context.Context, in *MsgNonAtomicExec, opts ...grpc.CallOption) (*MsgNonAtomicExecResponse, error) {
|
||||
out := new(MsgNonAtomicExecResponse)
|
||||
err := c.cc.Invoke(ctx, Msg_NonAtomicExec_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
// All implementations must embed UnimplementedMsgServer
|
||||
// for forward compatibility
|
||||
@ -59,6 +71,8 @@ type MsgServer interface {
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
|
||||
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
|
||||
NonAtomicExec(context.Context, *MsgNonAtomicExec) (*MsgNonAtomicExecResponse, error)
|
||||
mustEmbedUnimplementedMsgServer()
|
||||
}
|
||||
|
||||
@ -69,6 +83,9 @@ type UnimplementedMsgServer struct {
|
||||
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) NonAtomicExec(context.Context, *MsgNonAtomicExec) (*MsgNonAtomicExecResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method NonAtomicExec not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
|
||||
|
||||
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
|
||||
@ -100,6 +117,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_NonAtomicExec_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgNonAtomicExec)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).NonAtomicExec(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Msg_NonAtomicExec_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).NonAtomicExec(ctx, req.(*MsgNonAtomicExec))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@ -111,6 +146,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "UpdateParams",
|
||||
Handler: _Msg_UpdateParams_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "NonAtomicExec",
|
||||
Handler: _Msg_NonAtomicExec_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/auth/v1beta1/tx.proto",
|
||||
|
||||
@ -289,7 +289,6 @@ func NewSimApp(
|
||||
appCodec,
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), logger),
|
||||
signingCtx.AddressCodec(),
|
||||
appCodec,
|
||||
app.MsgServiceRouter(),
|
||||
app.GRPCQueryRouter(),
|
||||
appCodec.InterfaceRegistry(),
|
||||
@ -309,7 +308,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.AccountsKeeper)
|
||||
app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger), appCodec, authtypes.ProtoBaseAccount, accountsKeeper, maccPerms, signingCtx.AddressCodec(), sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
|
||||
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), logger),
|
||||
@ -431,7 +430,7 @@ func NewSimApp(
|
||||
app.ModuleManager = module.NewManager(
|
||||
genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator),
|
||||
accounts.NewAppModule(appCodec, app.AccountsKeeper),
|
||||
auth.NewAppModule(appCodec, app.AuthKeeper, authsims.RandomGenesisAccounts),
|
||||
auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts),
|
||||
vesting.NewAppModule(app.AuthKeeper, app.BankKeeper),
|
||||
bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper),
|
||||
feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
|
||||
@ -523,7 +522,7 @@ func NewSimApp(
|
||||
// NOTE: this is not required apps that don't use the simulator for fuzz testing
|
||||
// transactions
|
||||
overrideModules := map[string]module.AppModuleSimulation{
|
||||
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AuthKeeper, authsims.RandomGenesisAccounts),
|
||||
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts),
|
||||
}
|
||||
app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, overrideModules)
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ import (
|
||||
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
|
||||
"cosmossdk.io/depinject/appconfig"
|
||||
"cosmossdk.io/x/accounts"
|
||||
_ "cosmossdk.io/x/accounts" // import for side-effects
|
||||
_ "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
|
||||
|
||||
@ -260,7 +260,7 @@ func NewSimApp(
|
||||
// NOTE: this is not required apps that don't use the simulator for fuzz testing
|
||||
// transactions
|
||||
overrideModules := map[string]module.AppModuleSimulation{
|
||||
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AuthKeeper, authsims.RandomGenesisAccounts),
|
||||
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AuthKeeper, &app.AccountsKeeper, authsims.RandomGenesisAccounts),
|
||||
}
|
||||
app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, overrideModules)
|
||||
|
||||
|
||||
287
tests/integration/auth/keeper/msg_server_test.go
Normal file
287
tests/integration/auth/keeper/msg_server_test.go
Normal file
@ -0,0 +1,287 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/log"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/accounts"
|
||||
baseaccount "cosmossdk.io/x/accounts/defaults/base"
|
||||
"cosmossdk.io/x/auth"
|
||||
authkeeper "cosmossdk.io/x/auth/keeper"
|
||||
authsims "cosmossdk.io/x/auth/simulation"
|
||||
"cosmossdk.io/x/auth/types"
|
||||
authtypes "cosmossdk.io/x/auth/types"
|
||||
"cosmossdk.io/x/bank"
|
||||
"cosmossdk.io/x/bank/keeper"
|
||||
bankkeeper "cosmossdk.io/x/bank/keeper"
|
||||
"cosmossdk.io/x/bank/testutil"
|
||||
banktypes "cosmossdk.io/x/bank/types"
|
||||
minttypes "cosmossdk.io/x/mint/types"
|
||||
"cosmossdk.io/x/tx/signing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
|
||||
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/integration"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
)
|
||||
|
||||
type fixture struct {
|
||||
app *integration.App
|
||||
|
||||
cdc codec.Codec
|
||||
ctx sdk.Context
|
||||
|
||||
authKeeper authkeeper.AccountKeeper
|
||||
accountsKeeper accounts.Keeper
|
||||
bankKeeper bankkeeper.Keeper
|
||||
}
|
||||
|
||||
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 initFixture(t *testing.T) *fixture {
|
||||
t.Helper()
|
||||
keys := storetypes.NewKVStoreKeys(
|
||||
authtypes.StoreKey, banktypes.StoreKey, accounts.StoreKey,
|
||||
)
|
||||
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, accounts.AppModule{})
|
||||
cdc := encodingCfg.Codec
|
||||
|
||||
logger := log.NewTestLogger(t)
|
||||
cms := integration.CreateMultiStore(keys, logger)
|
||||
|
||||
newCtx := sdk.NewContext(cms, true, logger)
|
||||
|
||||
router := baseapp.NewMsgServiceRouter()
|
||||
router.SetInterfaceRegistry(cdc.InterfaceRegistry())
|
||||
queryRouter := baseapp.NewGRPCQueryRouter()
|
||||
queryRouter.SetInterfaceRegistry(cdc.InterfaceRegistry())
|
||||
|
||||
handler := directHandler{}
|
||||
account := baseaccount.NewAccount("base", signing.NewHandlerMap(handler))
|
||||
accountsKeeper, err := accounts.NewKeeper(
|
||||
cdc,
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), log.NewNopLogger()),
|
||||
addresscodec.NewBech32Codec("cosmos"),
|
||||
router,
|
||||
queryRouter,
|
||||
cdc.InterfaceRegistry(),
|
||||
account,
|
||||
)
|
||||
assert.NilError(t, err)
|
||||
|
||||
authority := authtypes.NewModuleAddress("gov")
|
||||
|
||||
authKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
authtypes.ProtoBaseAccount,
|
||||
accountsKeeper,
|
||||
map[string][]string{minttypes.ModuleName: {authtypes.Minter}},
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
authKeeper.GetAuthority(): false,
|
||||
}
|
||||
bankKeeper := keeper.NewBaseKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
authKeeper,
|
||||
blockedAddresses,
|
||||
authority.String(),
|
||||
)
|
||||
|
||||
params := banktypes.DefaultParams()
|
||||
assert.NilError(t, bankKeeper.SetParams(newCtx, params))
|
||||
|
||||
accountsModule := accounts.NewAppModule(cdc, accountsKeeper)
|
||||
authModule := auth.NewAppModule(cdc, authKeeper, accountsKeeper, authsims.RandomGenesisAccounts)
|
||||
bankModule := bank.NewAppModule(cdc, bankKeeper, authKeeper)
|
||||
|
||||
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
|
||||
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
|
||||
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
|
||||
map[string]appmodule.AppModule{
|
||||
accounts.ModuleName: accountsModule,
|
||||
authtypes.ModuleName: authModule,
|
||||
banktypes.ModuleName: bankModule,
|
||||
})
|
||||
|
||||
authtypes.RegisterInterfaces(cdc.InterfaceRegistry())
|
||||
banktypes.RegisterInterfaces(cdc.InterfaceRegistry())
|
||||
|
||||
authtypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), authkeeper.NewMsgServerImpl(authKeeper))
|
||||
authtypes.RegisterQueryServer(integrationApp.QueryHelper(), authkeeper.NewQueryServer(authKeeper))
|
||||
|
||||
banktypes.RegisterMsgServer(router, bankkeeper.NewMsgServerImpl(bankKeeper))
|
||||
|
||||
return &fixture{
|
||||
app: integrationApp,
|
||||
cdc: cdc,
|
||||
ctx: newCtx,
|
||||
accountsKeeper: accountsKeeper,
|
||||
authKeeper: authKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
}
|
||||
}
|
||||
|
||||
func TestAsyncExec(t *testing.T) {
|
||||
t.Parallel()
|
||||
f := initFixture(t)
|
||||
|
||||
addrs := simtestutil.CreateIncrementalAccounts(2)
|
||||
coins := sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(10)))
|
||||
|
||||
assert.NilError(t, testutil.FundAccount(f.ctx, f.bankKeeper, addrs[0], sdk.NewCoins(sdk.NewInt64Coin("stake", 50))))
|
||||
|
||||
msg := &banktypes.MsgSend{
|
||||
FromAddress: addrs[0].String(),
|
||||
ToAddress: addrs[1].String(),
|
||||
Amount: coins,
|
||||
}
|
||||
msg2 := &banktypes.MsgSend{
|
||||
FromAddress: addrs[1].String(),
|
||||
ToAddress: addrs[0].String(),
|
||||
Amount: coins,
|
||||
}
|
||||
failingMsg := &banktypes.MsgSend{
|
||||
FromAddress: addrs[0].String(),
|
||||
ToAddress: addrs[1].String(),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", sdkmath.ZeroInt())), // No amount specified
|
||||
}
|
||||
|
||||
msgAny, err := codectypes.NewAnyWithValue(msg)
|
||||
assert.NilError(t, err)
|
||||
|
||||
msgAny2, err := codectypes.NewAnyWithValue(msg2)
|
||||
assert.NilError(t, err)
|
||||
|
||||
failingMsgAny, err := codectypes.NewAnyWithValue(failingMsg)
|
||||
assert.NilError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
req *types.MsgNonAtomicExec
|
||||
expectErr bool
|
||||
expErrMsg string
|
||||
}{
|
||||
{
|
||||
name: "empty signer address",
|
||||
req: &types.MsgNonAtomicExec{
|
||||
Signer: "",
|
||||
Msgs: []*codectypes.Any{},
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "empty signer address string is not allowed",
|
||||
},
|
||||
{
|
||||
name: "invalid signer address",
|
||||
req: &types.MsgNonAtomicExec{
|
||||
Signer: "invalid",
|
||||
Msgs: []*codectypes.Any{},
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "invalid signer address",
|
||||
},
|
||||
{
|
||||
name: "empty msgs",
|
||||
req: &types.MsgNonAtomicExec{
|
||||
Signer: addrs[0].String(),
|
||||
Msgs: []*codectypes.Any{},
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "messages cannot be empty",
|
||||
},
|
||||
{
|
||||
name: "valid msg",
|
||||
req: &types.MsgNonAtomicExec{
|
||||
Signer: addrs[0].String(),
|
||||
Msgs: []*codectypes.Any{msgAny},
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
{
|
||||
name: "multiple messages being executed",
|
||||
req: &types.MsgNonAtomicExec{
|
||||
Signer: addrs[0].String(),
|
||||
Msgs: []*codectypes.Any{msgAny, msgAny},
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
{
|
||||
name: "multiple messages with different signers",
|
||||
req: &types.MsgNonAtomicExec{
|
||||
Signer: addrs[0].String(),
|
||||
Msgs: []*codectypes.Any{msgAny, msgAny2},
|
||||
},
|
||||
expectErr: false,
|
||||
expErrMsg: "unauthorized: sender does not match expected sender",
|
||||
},
|
||||
{
|
||||
name: "multi msg with one failing being executed",
|
||||
req: &types.MsgNonAtomicExec{
|
||||
Signer: addrs[0].String(),
|
||||
Msgs: []*codectypes.Any{msgAny, failingMsgAny},
|
||||
},
|
||||
expectErr: false,
|
||||
expErrMsg: "invalid coins",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
res, err := f.app.RunMsg(
|
||||
tc.req,
|
||||
integration.WithAutomaticFinalizeBlock(),
|
||||
integration.WithAutomaticCommit(),
|
||||
)
|
||||
if tc.expectErr {
|
||||
assert.ErrorContains(t, err, tc.expErrMsg)
|
||||
} else {
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, res != nil)
|
||||
|
||||
// check the result
|
||||
result := authtypes.MsgNonAtomicExecResponse{}
|
||||
err = f.cdc.Unmarshal(res.Value, &result)
|
||||
assert.NilError(t, err)
|
||||
|
||||
if tc.expErrMsg != "" {
|
||||
for _, res := range result.Results {
|
||||
if res.Error != "" {
|
||||
assert.Assert(t, strings.Contains(res.Error, tc.expErrMsg))
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ package keeper_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"gotest.tools/v3/assert"
|
||||
"pgregory.net/rapid"
|
||||
|
||||
@ -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"
|
||||
_ "cosmossdk.io/x/auth/tx/config"
|
||||
authtypes "cosmossdk.io/x/auth/types"
|
||||
"cosmossdk.io/x/bank"
|
||||
@ -78,15 +80,19 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
minttypes.ModuleName: {authtypes.Minter},
|
||||
}
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(t)
|
||||
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
nil,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
@ -101,7 +107,7 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
authority.String(),
|
||||
)
|
||||
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts)
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts)
|
||||
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
|
||||
|
||||
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
|
||||
|
||||
@ -95,11 +95,11 @@ func initFixture(t *testing.T) *fixture {
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
@ -122,7 +122,7 @@ func initFixture(t *testing.T) *fixture {
|
||||
cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger), accountKeeper, bankKeeper, stakingKeeper, poolKeeper, distrtypes.ModuleName, authority.String(),
|
||||
)
|
||||
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts)
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts)
|
||||
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
|
||||
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
|
||||
distrModule := distribution.NewAppModule(cdc, distrKeeper, accountKeeper, bankKeeper, stakingKeeper, poolKeeper)
|
||||
|
||||
@ -115,11 +115,11 @@ func initFixture(tb testing.TB) *fixture {
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
@ -144,7 +144,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
router = router.AddRoute(evidencetypes.RouteEquivocation, testEquivocationHandler(evidenceKeeper))
|
||||
evidenceKeeper.SetRouter(router)
|
||||
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts)
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts)
|
||||
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
|
||||
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
|
||||
slashingModule := slashing.NewAppModule(cdc, slashingKeeper, accountKeeper, bankKeeper, stakingKeeper, cdc.InterfaceRegistry())
|
||||
|
||||
@ -3,7 +3,9 @@ package integration_test
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
@ -12,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/mint"
|
||||
mintkeeper "cosmossdk.io/x/mint/keeper"
|
||||
@ -42,19 +45,23 @@ func Example() {
|
||||
cms := integration.CreateMultiStore(keys, logger)
|
||||
newCtx := sdk.NewContext(cms, true, logger)
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(&testing.T{})
|
||||
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
encodingCfg.Codec,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
map[string][]string{minttypes.ModuleName: {authtypes.Minter}},
|
||||
addresscodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
authority,
|
||||
nil,
|
||||
)
|
||||
|
||||
// subspace is nil because we don't test params (which is legacy anyway)
|
||||
authModule := auth.NewAppModule(encodingCfg.Codec, accountKeeper, authsims.RandomGenesisAccounts)
|
||||
authModule := auth.NewAppModule(encodingCfg.Codec, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts)
|
||||
|
||||
// here bankkeeper and staking keeper is nil because we are not testing them
|
||||
// subspace is nil because we don't test params (which is legacy anyway)
|
||||
@ -134,19 +141,23 @@ func Example_oneModule() {
|
||||
cms := integration.CreateMultiStore(keys, logger)
|
||||
newCtx := sdk.NewContext(cms, true, logger)
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(&testing.T{})
|
||||
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
encodingCfg.Codec,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
map[string][]string{minttypes.ModuleName: {authtypes.Minter}},
|
||||
addresscodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
authority,
|
||||
nil,
|
||||
)
|
||||
|
||||
// subspace is nil because we don't test params (which is legacy anyway)
|
||||
authModule := auth.NewAppModule(encodingCfg.Codec, accountKeeper, authsims.RandomGenesisAccounts)
|
||||
authModule := auth.NewAppModule(encodingCfg.Codec, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts)
|
||||
|
||||
// create the application and register all the modules from the previous step
|
||||
integrationApp := integration.NewIntegrationApp(
|
||||
|
||||
@ -82,11 +82,11 @@ func initFixture(tb testing.TB) *fixture {
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
@ -132,7 +132,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
err = govKeeper.Params.Set(newCtx, v1.DefaultParams())
|
||||
assert.NilError(tb, err)
|
||||
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts)
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts)
|
||||
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
|
||||
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
|
||||
govModule := gov.NewAppModule(cdc, govKeeper, accountKeeper, bankKeeper, poolKeeper)
|
||||
|
||||
@ -83,11 +83,11 @@ func initFixture(tb testing.TB) *fixture {
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
|
||||
@ -132,11 +132,11 @@ func initFixture(tb testing.TB) *fixture {
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
@ -152,7 +152,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
|
||||
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr))
|
||||
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts)
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts)
|
||||
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
|
||||
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
|
||||
|
||||
|
||||
@ -96,11 +96,11 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
cdc,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
addresscodec.NewBech32Codec(sdk.Bech32MainPrefix),
|
||||
sdk.Bech32MainPrefix,
|
||||
authority.String(),
|
||||
acctsModKeeper,
|
||||
)
|
||||
|
||||
blockedAddresses := map[string]bool{
|
||||
@ -116,7 +116,7 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
|
||||
|
||||
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr))
|
||||
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts)
|
||||
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts)
|
||||
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
|
||||
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package nft
|
||||
|
||||
import (
|
||||
_ "cosmossdk.io/x/accounts"
|
||||
_ "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
|
||||
|
||||
@ -62,7 +62,7 @@ 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.Cdc, in.Environment, in.AddressCodec,
|
||||
in.ExecRouter, in.QueryRouter, in.Registry, account,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@ -30,7 +30,7 @@ type AccountCreatorFunc = func(deps Dependencies) (string, Account, error)
|
||||
// MakeAccountsMap creates a map of account names to account implementations
|
||||
// from a list of account creator functions.
|
||||
func MakeAccountsMap(
|
||||
cdc codec.BinaryCodec,
|
||||
cdc codec.Codec,
|
||||
addressCodec address.Codec,
|
||||
env appmodule.Environment,
|
||||
accounts []AccountCreatorFunc,
|
||||
|
||||
@ -8,8 +8,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
@ -50,22 +48,15 @@ type MsgRouter interface {
|
||||
ResponseNameByMsgName(name string) string
|
||||
}
|
||||
|
||||
// SignerProvider defines an interface used to get the expected sender from a message.
|
||||
type SignerProvider interface {
|
||||
// GetMsgV1Signers returns the signers of the message.
|
||||
GetMsgV1Signers(msg gogoproto.Message) ([][]byte, proto.Message, error)
|
||||
}
|
||||
|
||||
type InterfaceRegistry interface {
|
||||
RegisterInterface(name string, iface any, impls ...protoiface.MessageV1)
|
||||
RegisterImplementations(iface any, impls ...protoiface.MessageV1)
|
||||
}
|
||||
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec,
|
||||
cdc codec.Codec,
|
||||
env appmodule.Environment,
|
||||
addressCodec address.Codec,
|
||||
signerProvider SignerProvider,
|
||||
execRouter MsgRouter,
|
||||
queryRouter QueryRouter,
|
||||
ir InterfaceRegistry,
|
||||
@ -76,7 +67,7 @@ func NewKeeper(
|
||||
environment: env,
|
||||
addressCodec: addressCodec,
|
||||
msgRouter: execRouter,
|
||||
signerProvider: signerProvider,
|
||||
codec: cdc,
|
||||
queryRouter: queryRouter,
|
||||
makeSendCoinsMsg: defaultCoinsTransferMsgFunc(addressCodec),
|
||||
Schema: collections.Schema{},
|
||||
@ -103,8 +94,8 @@ type Keeper struct {
|
||||
// deps coming from the runtime
|
||||
environment appmodule.Environment
|
||||
addressCodec address.Codec
|
||||
msgRouter MsgRouter // todo use env
|
||||
signerProvider SignerProvider
|
||||
codec codec.Codec
|
||||
msgRouter MsgRouter // todo use env
|
||||
queryRouter QueryRouter // todo use env
|
||||
makeSendCoinsMsg coinsTransferMsgFunc
|
||||
|
||||
@ -302,7 +293,7 @@ func (k Keeper) makeAccountContext(ctx context.Context, accountNumber uint64, ac
|
||||
sender,
|
||||
funds,
|
||||
k.sendModuleMessage,
|
||||
k.sendModuleMessageUntyped,
|
||||
k.SendModuleMessageUntyped,
|
||||
k.queryModule,
|
||||
)
|
||||
}
|
||||
@ -336,7 +327,7 @@ func (k Keeper) sendAnyMessages(ctx context.Context, sender []byte, anyMessages
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := k.sendModuleMessageUntyped(ctx, sender, msg)
|
||||
resp, err := k.SendModuleMessageUntyped(ctx, sender, msg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute message %d: %s", i, err.Error())
|
||||
}
|
||||
@ -349,9 +340,9 @@ func (k Keeper) sendAnyMessages(ctx context.Context, sender []byte, anyMessages
|
||||
return anyResponses, nil
|
||||
}
|
||||
|
||||
// sendModuleMessageUntyped can be used to send a message towards a module.
|
||||
// SendModuleMessageUntyped can be used to send a message towards a module.
|
||||
// It should be used when the response type is not known by the caller.
|
||||
func (k Keeper) sendModuleMessageUntyped(ctx context.Context, sender []byte, msg implementation.ProtoMsg) (implementation.ProtoMsg, error) {
|
||||
func (k Keeper) SendModuleMessageUntyped(ctx context.Context, sender []byte, msg implementation.ProtoMsg) (implementation.ProtoMsg, error) {
|
||||
// we need to fetch the response type from the request message type.
|
||||
// this is because the response type is not known.
|
||||
respName := k.msgRouter.ResponseNameByMsgName(implementation.MessageName(msg))
|
||||
@ -372,7 +363,7 @@ func (k Keeper) sendModuleMessageUntyped(ctx context.Context, sender []byte, msg
|
||||
// is not trying to impersonate another account.
|
||||
func (k Keeper) sendModuleMessage(ctx context.Context, sender []byte, msg, msgResp implementation.ProtoMsg) error {
|
||||
// do sender assertions.
|
||||
wantSenders, _, err := k.signerProvider.GetMsgV1Signers(msg)
|
||||
wantSenders, _, err := k.codec.GetMsgV1Signers(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot get signers: %w", err)
|
||||
}
|
||||
|
||||
@ -80,14 +80,18 @@ func TestKeeper_Execute(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
m.signerProvider = mockSigner(func(msg implementation.ProtoMsg) ([]byte, error) {
|
||||
require.Equal(t, msg.(*bankv1beta1.MsgSend).FromAddress, string(accAddr))
|
||||
return accAddr, nil
|
||||
})
|
||||
m.msgRouter = mockExec(func(ctx context.Context, msg, msgResp implementation.ProtoMsg) error {
|
||||
concrete, ok := msg.(*bankv1beta1.MsgSend)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, concrete.FromAddress, string(accAddr))
|
||||
_, ok = msgResp.(*bankv1beta1.MsgSendResponse)
|
||||
require.True(t, ok)
|
||||
|
||||
resp, err := m.Execute(ctx, accAddr, sender, &types.Int64Value{Value: 1000}, nil)
|
||||
require.NoError(t, err)
|
||||
require.True(t, implementation.Equal(&types.Empty{}, resp))
|
||||
resp, err := m.Execute(ctx, accAddr, sender, &types.Int64Value{Value: 1000}, nil)
|
||||
require.NoError(t, err)
|
||||
require.True(t, implementation.Equal(&types.Empty{}, resp))
|
||||
return nil
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -4,9 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
|
||||
"cosmossdk.io/collections/colltest"
|
||||
@ -48,7 +46,7 @@ func newKeeper(t *testing.T, accounts ...implementation.AccountCreatorFunc) (Kee
|
||||
ss, ctx := colltest.MockStore()
|
||||
env := runtime.NewEnvironment(ss, log.NewNopLogger())
|
||||
env.EventService = eventService{}
|
||||
m, err := NewKeeper(nil, env, addressCodec{}, nil, nil, nil, interfaceRegistry{}, accounts...)
|
||||
m, err := NewKeeper(nil, env, addressCodec{}, nil, nil, interfaceRegistry{}, accounts...)
|
||||
require.NoError(t, err)
|
||||
return m, ctx
|
||||
}
|
||||
@ -63,18 +61,6 @@ func (m mockQuery) HybridHandlerByRequestName(_ string) []func(ctx context.Conte
|
||||
}}
|
||||
}
|
||||
|
||||
var _ SignerProvider = (*mockSigner)(nil)
|
||||
|
||||
type mockSigner func(msg implementation.ProtoMsg) ([]byte, error)
|
||||
|
||||
func (m mockSigner) GetMsgV1Signers(msg gogoproto.Message) ([][]byte, proto.Message, error) {
|
||||
s, err := m(msg)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return [][]byte{s}, nil, nil
|
||||
}
|
||||
|
||||
var _ MsgRouter = (*mockExec)(nil)
|
||||
|
||||
type mockExec func(ctx context.Context, msg, msgResp implementation.ProtoMsg) error
|
||||
|
||||
@ -9,11 +9,49 @@ import (
|
||||
reflect "reflect"
|
||||
|
||||
address "cosmossdk.io/core/address"
|
||||
appmodule "cosmossdk.io/core/appmodule"
|
||||
types "cosmossdk.io/x/auth/types"
|
||||
types0 "github.com/cosmos/cosmos-sdk/types"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
// MockHasEnvironment is a mock of HasEnvironment interface.
|
||||
type MockHasEnvironment struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockHasEnvironmentMockRecorder
|
||||
}
|
||||
|
||||
// MockHasEnvironmentMockRecorder is the mock recorder for MockHasEnvironment.
|
||||
type MockHasEnvironmentMockRecorder struct {
|
||||
mock *MockHasEnvironment
|
||||
}
|
||||
|
||||
// NewMockHasEnvironment creates a new mock instance.
|
||||
func NewMockHasEnvironment(ctrl *gomock.Controller) *MockHasEnvironment {
|
||||
mock := &MockHasEnvironment{ctrl: ctrl}
|
||||
mock.recorder = &MockHasEnvironmentMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockHasEnvironment) EXPECT() *MockHasEnvironmentMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Environment mocks base method.
|
||||
func (m *MockHasEnvironment) Environment() appmodule.Environment {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Environment")
|
||||
ret0, _ := ret[0].(appmodule.Environment)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Environment indicates an expected call of Environment.
|
||||
func (mr *MockHasEnvironmentMockRecorder) Environment() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Environment", reflect.TypeOf((*MockHasEnvironment)(nil).Environment))
|
||||
}
|
||||
|
||||
// MockAccountKeeper is a mock of AccountKeeper interface.
|
||||
type MockAccountKeeper struct {
|
||||
ctrl *gomock.Controller
|
||||
@ -51,6 +89,20 @@ func (mr *MockAccountKeeperMockRecorder) AddressCodec() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddressCodec", reflect.TypeOf((*MockAccountKeeper)(nil).AddressCodec))
|
||||
}
|
||||
|
||||
// Environment mocks base method.
|
||||
func (m *MockAccountKeeper) Environment() appmodule.Environment {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Environment")
|
||||
ret0, _ := ret[0].(appmodule.Environment)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Environment indicates an expected call of Environment.
|
||||
func (mr *MockAccountKeeperMockRecorder) Environment() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Environment", reflect.TypeOf((*MockAccountKeeper)(nil).Environment))
|
||||
}
|
||||
|
||||
// GetAccount mocks base method.
|
||||
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types0.AccAddress) types0.AccountI {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
@ -51,6 +51,7 @@ type AnteTestSuite struct {
|
||||
txBuilder client.TxBuilder
|
||||
accountKeeper keeper.AccountKeeper
|
||||
bankKeeper *authtestutil.MockBankKeeper
|
||||
acctsModKeeper *authtestutil.MockAccountsModKeeper
|
||||
txBankKeeper *txtestutil.MockBankKeeper
|
||||
feeGrantKeeper *antetestutil.MockFeegrantKeeper
|
||||
encCfg moduletestutil.TestEncodingConfig
|
||||
@ -60,10 +61,12 @@ type AnteTestSuite struct {
|
||||
func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
|
||||
t.Helper()
|
||||
suite := &AnteTestSuite{}
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(t)
|
||||
suite.bankKeeper = authtestutil.NewMockBankKeeper(ctrl)
|
||||
suite.txBankKeeper = txtestutil.NewMockBankKeeper(ctrl)
|
||||
suite.feeGrantKeeper = antetestutil.NewMockFeegrantKeeper(ctrl)
|
||||
suite.acctsModKeeper = authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
|
||||
key := storetypes.NewKVStoreKey(types.StoreKey)
|
||||
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
|
||||
@ -80,8 +83,8 @@ 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(), nil,
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()), suite.encCfg.Codec, types.ProtoBaseAccount, suite.acctsModKeeper, maccPerms, authcodec.NewBech32Codec("cosmos"),
|
||||
sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(),
|
||||
)
|
||||
suite.accountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName)
|
||||
err := suite.accountKeeper.Params.Set(suite.ctx, types.DefaultParams())
|
||||
|
||||
@ -27,11 +27,11 @@ func init() {
|
||||
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
AccountsModKeeper types.AccountsModKeeper
|
||||
|
||||
Config *modulev1.Module
|
||||
Environment appmodule.Environment
|
||||
Cdc codec.Codec
|
||||
Config *modulev1.Module
|
||||
Environment appmodule.Environment
|
||||
Cdc codec.Codec
|
||||
AccountsModKeeper types.AccountsModKeeper
|
||||
|
||||
AddressCodec address.Codec
|
||||
RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"`
|
||||
@ -70,8 +70,8 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
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)
|
||||
k := keeper.NewAccountKeeper(in.Environment, in.Cdc, in.AccountI, in.AccountsModKeeper, maccPerms, in.AddressCodec, in.Config.Bech32Prefix, auth)
|
||||
m := NewAppModule(in.Cdc, k, in.AccountsModKeeper, in.RandomGenesisAccountsFn)
|
||||
|
||||
return ModuleOutputs{AccountKeeper: k, Module: m}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"pgregory.net/rapid"
|
||||
|
||||
@ -16,6 +17,7 @@ import (
|
||||
"cosmossdk.io/x/auth"
|
||||
authcodec "cosmossdk.io/x/auth/codec"
|
||||
"cosmossdk.io/x/auth/keeper"
|
||||
authtestutil "cosmossdk.io/x/auth/testutil"
|
||||
"cosmossdk.io/x/auth/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
@ -33,13 +35,14 @@ type DeterministicTestSuite struct {
|
||||
|
||||
accountNumberLanes uint64
|
||||
|
||||
key *storetypes.KVStoreKey
|
||||
environment appmodule.Environment
|
||||
ctx sdk.Context
|
||||
queryClient types.QueryClient
|
||||
accountKeeper keeper.AccountKeeper
|
||||
encCfg moduletestutil.TestEncodingConfig
|
||||
maccPerms map[string][]string
|
||||
key *storetypes.KVStoreKey
|
||||
environment appmodule.Environment
|
||||
ctx sdk.Context
|
||||
queryClient types.QueryClient
|
||||
accountKeeper keeper.AccountKeeper
|
||||
acctsModKeeper *authtestutil.MockAccountsModKeeper
|
||||
encCfg moduletestutil.TestEncodingConfig
|
||||
maccPerms map[string][]string
|
||||
}
|
||||
|
||||
var (
|
||||
@ -62,6 +65,11 @@ func (suite *DeterministicTestSuite) SetupTest() {
|
||||
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
|
||||
suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{})
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(suite.T())
|
||||
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
suite.acctsModKeeper = acctsModKeeper
|
||||
|
||||
maccPerms := map[string][]string{
|
||||
"fee_collector": nil,
|
||||
"mint": {"minter"},
|
||||
@ -75,11 +83,11 @@ func (suite *DeterministicTestSuite) SetupTest() {
|
||||
env,
|
||||
suite.encCfg.Codec,
|
||||
types.ProtoBaseAccount,
|
||||
suite.acctsModKeeper,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
types.NewModuleAddress("gov").String(),
|
||||
nil,
|
||||
)
|
||||
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.encCfg.InterfaceRegistry)
|
||||
@ -296,11 +304,11 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccounts() {
|
||||
suite.environment,
|
||||
suite.encCfg.Codec,
|
||||
types.ProtoBaseAccount,
|
||||
suite.acctsModKeeper,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
types.NewModuleAddress("gov").String(),
|
||||
nil,
|
||||
)
|
||||
suite.setModuleAccounts(suite.ctx, ak, maccs)
|
||||
|
||||
@ -344,11 +352,11 @@ func (suite *DeterministicTestSuite) TestGRPCQueryModuleAccountByName() {
|
||||
suite.environment,
|
||||
suite.encCfg.Codec,
|
||||
types.ProtoBaseAccount,
|
||||
suite.acctsModKeeper,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
types.NewModuleAddress("gov").String(),
|
||||
nil,
|
||||
)
|
||||
suite.setModuleAccounts(suite.ctx, ak, []string{mName})
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"cosmossdk.io/x/auth/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
@ -115,8 +116,8 @@ var _ AccountKeeperI = &AccountKeeper{}
|
||||
// and don't have to fit into any predefined structure. This auth module does not use account permissions internally, though other modules
|
||||
// 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, accountsModKeeper types.AccountsModKeeper,
|
||||
env appmodule.Environment, cdc codec.BinaryCodec, proto func() sdk.AccountI, accountsModKeeper types.AccountsModKeeper,
|
||||
maccPerms map[string][]string, ac address.Codec, bech32Prefix, authority string,
|
||||
) AccountKeeper {
|
||||
permAddrs := make(map[string]types.PermissionsForAddress)
|
||||
for name, perms := range maccPerms {
|
||||
@ -131,12 +132,12 @@ func NewAccountKeeper(
|
||||
environment: env,
|
||||
proto: proto,
|
||||
cdc: cdc,
|
||||
AccountsModKeeper: accountsModKeeper,
|
||||
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 {
|
||||
@ -281,6 +282,43 @@ func (ak AccountKeeper) GetParams(ctx context.Context) (params types.Params) {
|
||||
return params
|
||||
}
|
||||
|
||||
func (ak AccountKeeper) NonAtomicMsgsExec(ctx context.Context, signer sdk.AccAddress, msgs []sdk.Msg) ([]*types.NonAtomicExecResult, error) {
|
||||
msgResponses := make([]*types.NonAtomicExecResult, 0, len(msgs))
|
||||
|
||||
for _, msg := range msgs {
|
||||
if m, ok := msg.(sdk.HasValidateBasic); ok {
|
||||
if err := m.ValidateBasic(); err != nil {
|
||||
value := &types.NonAtomicExecResult{Error: err.Error()}
|
||||
msgResponses = append(msgResponses, value)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if err := ak.environment.BranchService.Execute(ctx, func(ctx context.Context) error {
|
||||
result, err := ak.AccountsModKeeper.SendModuleMessageUntyped(ctx, signer, msg)
|
||||
if err != nil {
|
||||
// If an error occurs during message execution, append error response
|
||||
response := &types.NonAtomicExecResult{Resp: nil, Error: err.Error()}
|
||||
msgResponses = append(msgResponses, response)
|
||||
} else {
|
||||
resp, err := codectypes.NewAnyWithValue(result)
|
||||
if err != nil {
|
||||
response := &types.NonAtomicExecResult{Resp: nil, Error: err.Error()}
|
||||
msgResponses = append(msgResponses, response)
|
||||
}
|
||||
response := &types.NonAtomicExecResult{Resp: resp, Error: ""}
|
||||
msgResponses = append(msgResponses, response)
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return msgResponses, nil
|
||||
}
|
||||
|
||||
// Environment returns the module's environment.
|
||||
func (ak AccountKeeper) Environment() appmodule.Environment {
|
||||
return ak.environment
|
||||
|
||||
@ -3,6 +3,7 @@ package keeper_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
@ -12,6 +13,7 @@ import (
|
||||
"cosmossdk.io/x/auth"
|
||||
authcodec "cosmossdk.io/x/auth/codec"
|
||||
"cosmossdk.io/x/auth/keeper"
|
||||
authtestutil "cosmossdk.io/x/auth/testutil"
|
||||
"cosmossdk.io/x/auth/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
@ -40,10 +42,11 @@ type KeeperTestSuite struct {
|
||||
|
||||
ctx sdk.Context
|
||||
|
||||
queryClient types.QueryClient
|
||||
accountKeeper keeper.AccountKeeper
|
||||
msgServer types.MsgServer
|
||||
encCfg moduletestutil.TestEncodingConfig
|
||||
queryClient types.QueryClient
|
||||
accountKeeper keeper.AccountKeeper
|
||||
acctsModKeeper *authtestutil.MockAccountsModKeeper
|
||||
msgServer types.MsgServer
|
||||
encCfg moduletestutil.TestEncodingConfig
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) SetupTest() {
|
||||
@ -55,6 +58,11 @@ func (suite *KeeperTestSuite) SetupTest() {
|
||||
testCtx := testutil.DefaultContextWithDB(suite.T(), key, storetypes.NewTransientStoreKey("transient_test"))
|
||||
suite.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{})
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(suite.T())
|
||||
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
suite.acctsModKeeper = acctsModKeeper
|
||||
|
||||
maccPerms := map[string][]string{
|
||||
"fee_collector": nil,
|
||||
"mint": {"minter"},
|
||||
@ -68,11 +76,11 @@ func (suite *KeeperTestSuite) SetupTest() {
|
||||
env,
|
||||
suite.encCfg.Codec,
|
||||
types.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
types.NewModuleAddress("gov").String(),
|
||||
nil,
|
||||
)
|
||||
suite.msgServer = keeper.NewMsgServerImpl(suite.accountKeeper)
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.encCfg.InterfaceRegistry)
|
||||
|
||||
@ -2,9 +2,12 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/x/auth/types"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
||||
@ -20,6 +23,35 @@ func NewMsgServerImpl(ak AccountKeeper) types.MsgServer {
|
||||
}
|
||||
}
|
||||
|
||||
func (ms msgServer) NonAtomicExec(goCtx context.Context, msg *types.MsgNonAtomicExec) (*types.MsgNonAtomicExecResponse, error) {
|
||||
if msg.Signer == "" {
|
||||
return nil, errors.New("empty signer address string is not allowed")
|
||||
}
|
||||
|
||||
signer, err := ms.ak.AddressCodec().StringToBytes(msg.Signer)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid signer address: %s", err)
|
||||
}
|
||||
|
||||
if len(msg.Msgs) == 0 {
|
||||
return nil, sdkerrors.ErrInvalidRequest.Wrapf("messages cannot be empty")
|
||||
}
|
||||
|
||||
msgs, err := msg.GetMessages()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
results, err := ms.ak.NonAtomicMsgsExec(goCtx, signer, msgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.MsgNonAtomicExecResponse{
|
||||
Results: results,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (ms msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
|
||||
if ms.ak.authority != msg.Authority {
|
||||
return nil, fmt.Errorf(
|
||||
|
||||
@ -40,6 +40,7 @@ var (
|
||||
type AppModule struct {
|
||||
accountKeeper keeper.AccountKeeper
|
||||
randGenAccountsFn types.RandomGenesisAccountsFn
|
||||
accountsModKeeper types.AccountsModKeeper
|
||||
cdc codec.Codec
|
||||
}
|
||||
|
||||
@ -47,10 +48,11 @@ type AppModule struct {
|
||||
func (am AppModule) IsAppModule() {}
|
||||
|
||||
// NewAppModule creates a new AppModule object
|
||||
func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, randGenAccountsFn types.RandomGenesisAccountsFn) AppModule {
|
||||
func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, ak types.AccountsModKeeper, randGenAccountsFn types.RandomGenesisAccountsFn) AppModule {
|
||||
return AppModule{
|
||||
accountKeeper: accountKeeper,
|
||||
randGenAccountsFn: randGenAccountsFn,
|
||||
accountsModKeeper: ak,
|
||||
cdc: cdc,
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ syntax = "proto3";
|
||||
package cosmos.auth.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "cosmos/msg/v1/msg.proto";
|
||||
import "amino/amino.proto";
|
||||
@ -18,6 +19,9 @@ service Msg {
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
|
||||
|
||||
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
|
||||
rpc NonAtomicExec(MsgNonAtomicExec) returns (MsgNonAtomicExecResponse);
|
||||
}
|
||||
|
||||
// MsgUpdateParams is the Msg/UpdateParams request type.
|
||||
@ -41,3 +45,23 @@ message MsgUpdateParams {
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
message MsgUpdateParamsResponse {}
|
||||
|
||||
// MsgNonAtomicExec defines the Msg/NonAtomicExec request type.
|
||||
message MsgNonAtomicExec {
|
||||
option (cosmos.msg.v1.signer) = "signer";
|
||||
|
||||
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
repeated google.protobuf.Any msgs = 2 [(cosmos_proto.accepts_interface) = "cosmos.base.v1beta1.Msg"];
|
||||
}
|
||||
|
||||
// NonAtomicExecResult defines the response structure for executing a
|
||||
// MsgNonAtomicExec.
|
||||
message NonAtomicExecResult {
|
||||
string error = 1;
|
||||
google.protobuf.Any resp = 2;
|
||||
}
|
||||
|
||||
// MsgNonAtomicExecResponse defines the response of MsgNonAtomicExec.
|
||||
message MsgNonAtomicExecResponse {
|
||||
repeated NonAtomicExecResult results = 1;
|
||||
}
|
||||
|
||||
@ -3,7 +3,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/tx/config" // import as blank for app wiring``
|
||||
_ "cosmossdk.io/x/auth/vesting" // import as blank for app wiring
|
||||
_ "cosmossdk.io/x/bank" // import as blank for app wiring
|
||||
_ "cosmossdk.io/x/staking" // import as blank for app wiring
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
protoiface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
// MockBankKeeper is a mock of BankKeeper interface.
|
||||
@ -82,7 +83,6 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAd
|
||||
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
|
||||
@ -107,17 +107,30 @@ func (m *MockAccountsModKeeper) EXPECT() *MockAccountsModKeeperMockRecorder {
|
||||
}
|
||||
|
||||
// IsAccountsModuleAccount mocks base method.
|
||||
func (m *MockAccountsModKeeper) IsAccountsModuleAccount(ctx context.Context, addr []byte) bool {
|
||||
func (m *MockAccountsModKeeper) IsAccountsModuleAccount(ctx context.Context, accountAddr []byte) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsAccountsModuleAccount", ctx, addr)
|
||||
ret := m.ctrl.Call(m, "IsAccountsModuleAccount", ctx, accountAddr)
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsAccountsModuleAccount indicates an expected call of IsAccountsModuleAccount.
|
||||
func (mr *MockAccountsModKeeperMockRecorder) IsAccountsModuleAccount(ctx, addr interface{}) *gomock.Call {
|
||||
func (mr *MockAccountsModKeeperMockRecorder) IsAccountsModuleAccount(ctx, accountAddr interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAccountsModuleAccount", reflect.TypeOf((*MockAccountsModKeeper)(nil).IsAccountsModuleAccount), ctx, addr)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAccountsModuleAccount", reflect.TypeOf((*MockAccountsModKeeper)(nil).IsAccountsModuleAccount), ctx, accountAddr)
|
||||
}
|
||||
|
||||
// SendModuleMessageUntyped mocks base method.
|
||||
func (m *MockAccountsModKeeper) SendModuleMessageUntyped(ctx context.Context, sender []byte, msg protoiface.MessageV1) (protoiface.MessageV1, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendModuleMessageUntyped", ctx, sender, msg)
|
||||
ret0, _ := ret[0].(protoiface.MessageV1)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SendModuleMessageUntyped indicates an expected call of SendModuleMessageUntyped.
|
||||
func (mr *MockAccountsModKeeperMockRecorder) SendModuleMessageUntyped(ctx, sender, msg interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendModuleMessageUntyped", reflect.TypeOf((*MockAccountsModKeeper)(nil).SendModuleMessageUntyped), ctx, sender, msg)
|
||||
}
|
||||
|
||||
@ -58,5 +58,6 @@ func RegisterInterfaces(registrar registry.InterfaceRegistrar) {
|
||||
|
||||
registrar.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgUpdateParams{},
|
||||
&MsgNonAtomicExec{},
|
||||
)
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@ package types
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -15,5 +17,6 @@ type BankKeeper interface {
|
||||
|
||||
// AccountsModKeeper defines the contract for x/accounts APIs
|
||||
type AccountsModKeeper interface {
|
||||
SendModuleMessageUntyped(ctx context.Context, sender []byte, msg protoiface.MessageV1) (protoiface.MessageV1, error)
|
||||
IsAccountsModuleAccount(ctx context.Context, accountAddr []byte) bool
|
||||
}
|
||||
|
||||
20
x/auth/types/msgs.go
Normal file
20
x/auth/types/msgs.go
Normal file
@ -0,0 +1,20 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// GetMessages returns the cache values from the MsgNonAtomicExec.Msgs if present.
|
||||
func (msg MsgNonAtomicExec) GetMessages() ([]sdk.Msg, error) {
|
||||
msgs := make([]sdk.Msg, len(msg.Msgs))
|
||||
for i, msgAny := range msg.Msgs {
|
||||
msg, ok := msgAny.GetCachedValue().(sdk.Msg)
|
||||
if !ok {
|
||||
return nil, sdkerrors.ErrInvalidRequest.Wrapf("messages contains %T which is not a sdk.Msg", msgAny)
|
||||
}
|
||||
msgs[i] = msg
|
||||
}
|
||||
|
||||
return msgs, nil
|
||||
}
|
||||
@ -7,6 +7,7 @@ import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
types "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/tx/amino"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
@ -130,36 +131,203 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo
|
||||
|
||||
// MsgNonAtomicExec defines the Msg/NonAtomicExec request type.
|
||||
type MsgNonAtomicExec struct {
|
||||
Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"`
|
||||
Msgs []*types.Any `protobuf:"bytes,2,rep,name=msgs,proto3" json:"msgs,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExec) Reset() { *m = MsgNonAtomicExec{} }
|
||||
func (m *MsgNonAtomicExec) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgNonAtomicExec) ProtoMessage() {}
|
||||
func (*MsgNonAtomicExec) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c2d62bd9c4c212e5, []int{2}
|
||||
}
|
||||
func (m *MsgNonAtomicExec) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgNonAtomicExec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgNonAtomicExec.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *MsgNonAtomicExec) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgNonAtomicExec.Merge(m, src)
|
||||
}
|
||||
func (m *MsgNonAtomicExec) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgNonAtomicExec) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgNonAtomicExec.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgNonAtomicExec proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgNonAtomicExec) GetSigner() string {
|
||||
if m != nil {
|
||||
return m.Signer
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExec) GetMsgs() []*types.Any {
|
||||
if m != nil {
|
||||
return m.Msgs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// NonAtomicExecResult defines the response structure for executing a
|
||||
// MsgNonAtomicExec.
|
||||
type NonAtomicExecResult struct {
|
||||
Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
|
||||
Resp *types.Any `protobuf:"bytes,2,opt,name=resp,proto3" json:"resp,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NonAtomicExecResult) Reset() { *m = NonAtomicExecResult{} }
|
||||
func (m *NonAtomicExecResult) String() string { return proto.CompactTextString(m) }
|
||||
func (*NonAtomicExecResult) ProtoMessage() {}
|
||||
func (*NonAtomicExecResult) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c2d62bd9c4c212e5, []int{3}
|
||||
}
|
||||
func (m *NonAtomicExecResult) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *NonAtomicExecResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_NonAtomicExecResult.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *NonAtomicExecResult) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_NonAtomicExecResult.Merge(m, src)
|
||||
}
|
||||
func (m *NonAtomicExecResult) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *NonAtomicExecResult) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_NonAtomicExecResult.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_NonAtomicExecResult proto.InternalMessageInfo
|
||||
|
||||
func (m *NonAtomicExecResult) GetError() string {
|
||||
if m != nil {
|
||||
return m.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *NonAtomicExecResult) GetResp() *types.Any {
|
||||
if m != nil {
|
||||
return m.Resp
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MsgNonAtomicExecResponse defines the response of MsgNonAtomicExec.
|
||||
type MsgNonAtomicExecResponse struct {
|
||||
Results []*NonAtomicExecResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExecResponse) Reset() { *m = MsgNonAtomicExecResponse{} }
|
||||
func (m *MsgNonAtomicExecResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgNonAtomicExecResponse) ProtoMessage() {}
|
||||
func (*MsgNonAtomicExecResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c2d62bd9c4c212e5, []int{4}
|
||||
}
|
||||
func (m *MsgNonAtomicExecResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgNonAtomicExecResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgNonAtomicExecResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *MsgNonAtomicExecResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgNonAtomicExecResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgNonAtomicExecResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgNonAtomicExecResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgNonAtomicExecResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgNonAtomicExecResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgNonAtomicExecResponse) GetResults() []*NonAtomicExecResult {
|
||||
if m != nil {
|
||||
return m.Results
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgUpdateParams)(nil), "cosmos.auth.v1beta1.MsgUpdateParams")
|
||||
proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.auth.v1beta1.MsgUpdateParamsResponse")
|
||||
proto.RegisterType((*MsgNonAtomicExec)(nil), "cosmos.auth.v1beta1.MsgNonAtomicExec")
|
||||
proto.RegisterType((*NonAtomicExecResult)(nil), "cosmos.auth.v1beta1.NonAtomicExecResult")
|
||||
proto.RegisterType((*MsgNonAtomicExecResponse)(nil), "cosmos.auth.v1beta1.MsgNonAtomicExecResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmos/auth/v1beta1/tx.proto", fileDescriptor_c2d62bd9c4c212e5) }
|
||||
|
||||
var fileDescriptor_c2d62bd9c4c212e5 = []byte{
|
||||
// 336 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0xd6, 0x4f, 0x2c, 0x2d, 0xc9, 0xd0, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4,
|
||||
0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xea, 0x81, 0x64, 0xf5,
|
||||
0xa0, 0xb2, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x79, 0x7d, 0x10, 0x0b, 0xa2, 0x54, 0x4a,
|
||||
0x12, 0xa2, 0x34, 0x1e, 0x22, 0x01, 0xd5, 0x07, 0x91, 0x12, 0x87, 0xda, 0x91, 0x5b, 0x9c, 0xae,
|
||||
0x5f, 0x66, 0x08, 0xa2, 0xa0, 0x12, 0x82, 0x89, 0xb9, 0x99, 0x79, 0xf9, 0xfa, 0x60, 0x12, 0x2a,
|
||||
0x24, 0x87, 0xcd, 0x3d, 0x60, 0xeb, 0xc1, 0xf2, 0x4a, 0xfb, 0x19, 0xb9, 0xf8, 0x7d, 0x8b, 0xd3,
|
||||
0x43, 0x0b, 0x52, 0x12, 0x4b, 0x52, 0x03, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0x85, 0xcc, 0xb8, 0x38,
|
||||
0x41, 0x2a, 0xf2, 0x8b, 0x32, 0x4b, 0x2a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x9d, 0x24, 0x2e,
|
||||
0x6d, 0xd1, 0x15, 0x81, 0x3a, 0xc2, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x38, 0xb8, 0xa4, 0x28,
|
||||
0x33, 0x2f, 0x3d, 0x08, 0xa1, 0x54, 0xc8, 0x8e, 0x8b, 0xad, 0x00, 0x6c, 0x82, 0x04, 0x93, 0x02,
|
||||
0xa3, 0x06, 0xb7, 0x91, 0xb4, 0x1e, 0x16, 0xef, 0xea, 0x41, 0x2c, 0x71, 0xe2, 0x3c, 0x71, 0x4f,
|
||||
0x9e, 0x61, 0xc5, 0xf3, 0x0d, 0x5a, 0x8c, 0x41, 0x50, 0x5d, 0x56, 0x26, 0x4d, 0xcf, 0x37, 0x68,
|
||||
0x21, 0xcc, 0xeb, 0x7a, 0xbe, 0x41, 0x4b, 0x11, 0x62, 0x82, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, 0x05,
|
||||
0xc4, 0x13, 0x68, 0xae, 0x55, 0x92, 0xe4, 0x12, 0x47, 0x13, 0x0a, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf,
|
||||
0x2b, 0x4e, 0x35, 0x2a, 0xe0, 0x62, 0xf6, 0x2d, 0x4e, 0x17, 0x4a, 0xe2, 0xe2, 0x41, 0xf1, 0x9f,
|
||||
0x0a, 0x56, 0x77, 0xa1, 0x19, 0x22, 0xa5, 0x43, 0x8c, 0x2a, 0x98, 0x55, 0x52, 0xac, 0x0d, 0x20,
|
||||
0xaf, 0x38, 0x19, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c,
|
||||
0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x14, 0x34, 0x3e,
|
||||
0x8b, 0x53, 0xb2, 0xf5, 0x32, 0xf3, 0x61, 0x7e, 0x29, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03,
|
||||
0x47, 0x85, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x09, 0xbc, 0x34, 0x3c, 0x02, 0x00, 0x00,
|
||||
// 520 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x31, 0x6f, 0xd3, 0x40,
|
||||
0x18, 0xcd, 0xd1, 0x36, 0x28, 0x17, 0x10, 0xe0, 0x46, 0x6a, 0x9a, 0x22, 0x53, 0x22, 0x90, 0xa2,
|
||||
0x88, 0x9c, 0x49, 0x8a, 0x18, 0x3a, 0x20, 0xc5, 0x52, 0xc7, 0x20, 0x64, 0xd4, 0x85, 0x01, 0x64,
|
||||
0xc7, 0xc7, 0x61, 0xb5, 0xf6, 0x59, 0xf7, 0x5d, 0xaa, 0x64, 0x43, 0x8c, 0x4c, 0x8c, 0xfc, 0x04,
|
||||
0xc6, 0x0c, 0xdd, 0x59, 0x2b, 0xa6, 0x8a, 0x05, 0x26, 0x84, 0x92, 0x21, 0x7f, 0x03, 0xf9, 0xee,
|
||||
0xdc, 0x2a, 0x91, 0x51, 0xbb, 0xd8, 0xbe, 0x7b, 0xef, 0xfb, 0xbe, 0xf7, 0xee, 0x9d, 0xf1, 0xfd,
|
||||
0x21, 0x87, 0x98, 0x83, 0xe3, 0x8f, 0xe4, 0x07, 0xe7, 0xa4, 0x1b, 0x50, 0xe9, 0x77, 0x1d, 0x39,
|
||||
0x26, 0xa9, 0xe0, 0x92, 0x5b, 0x9b, 0x1a, 0x25, 0x19, 0x4a, 0x0c, 0xda, 0xa8, 0x31, 0xce, 0xb8,
|
||||
0xc2, 0x9d, 0xec, 0x4b, 0x53, 0x1b, 0xdb, 0x8c, 0x73, 0x76, 0x4c, 0x1d, 0xb5, 0x0a, 0x46, 0xef,
|
||||
0x1d, 0x3f, 0x99, 0xe4, 0x90, 0xee, 0xf2, 0x4e, 0xd7, 0x98, 0x96, 0x1a, 0xda, 0x32, 0xe3, 0x63,
|
||||
0x60, 0xce, 0x49, 0x37, 0x7b, 0x19, 0xe0, 0x9e, 0x1f, 0x47, 0x09, 0x77, 0xd4, 0xd3, 0x6c, 0xd9,
|
||||
0x45, 0x52, 0x95, 0x32, 0x85, 0x37, 0xbf, 0x23, 0x7c, 0x67, 0x00, 0xec, 0x30, 0x0d, 0x7d, 0x49,
|
||||
0x5f, 0xf9, 0xc2, 0x8f, 0xc1, 0x7a, 0x8e, 0x2b, 0x19, 0x83, 0x8b, 0x48, 0x4e, 0xea, 0x68, 0x17,
|
||||
0xb5, 0x2a, 0x6e, 0xfd, 0xe7, 0x69, 0xa7, 0x66, 0x44, 0xf4, 0xc3, 0x50, 0x50, 0x80, 0xd7, 0x52,
|
||||
0x44, 0x09, 0xf3, 0x2e, 0xa9, 0xd6, 0x0b, 0x5c, 0x4e, 0x55, 0x87, 0xfa, 0x8d, 0x5d, 0xd4, 0xaa,
|
||||
0xf6, 0x76, 0x48, 0xc1, 0x49, 0x10, 0x3d, 0xc4, 0xad, 0x9c, 0xfd, 0x79, 0x50, 0xfa, 0xb6, 0x98,
|
||||
0xb6, 0x91, 0x67, 0xaa, 0xf6, 0x9f, 0x7d, 0x5a, 0x4c, 0xdb, 0x97, 0xfd, 0x3e, 0x2f, 0xa6, 0xed,
|
||||
0x87, 0xba, 0x43, 0x07, 0xc2, 0x23, 0x67, 0xac, 0x4d, 0xac, 0xa8, 0x6d, 0x6e, 0xe3, 0xad, 0x95,
|
||||
0x2d, 0x8f, 0x42, 0xca, 0x13, 0xa0, 0xcd, 0xaf, 0x08, 0xdf, 0x1d, 0x00, 0x7b, 0xc9, 0x93, 0xbe,
|
||||
0xe4, 0x71, 0x34, 0x3c, 0x18, 0xd3, 0xa1, 0xf5, 0x14, 0x97, 0x21, 0x62, 0x09, 0x15, 0x57, 0x5a,
|
||||
0x33, 0x3c, 0xeb, 0x00, 0xaf, 0xc7, 0xc0, 0x32, 0x57, 0x6b, 0xad, 0x6a, 0xaf, 0x46, 0x74, 0x68,
|
||||
0x24, 0x0f, 0x8d, 0xf4, 0x93, 0x89, 0xbb, 0xf3, 0xe3, 0xb4, 0x63, 0x72, 0x21, 0x81, 0x0f, 0xf4,
|
||||
0xc2, 0xee, 0x00, 0x98, 0xa7, 0xca, 0xf7, 0xab, 0x99, 0x3d, 0xd3, 0xb3, 0x79, 0x88, 0x37, 0x97,
|
||||
0x64, 0x79, 0x14, 0x46, 0xc7, 0xd2, 0xaa, 0xe1, 0x0d, 0x2a, 0x04, 0x37, 0xda, 0x3c, 0xbd, 0xb0,
|
||||
0x5a, 0x78, 0x5d, 0x50, 0x48, 0xcd, 0xb1, 0x16, 0x0a, 0xf0, 0x14, 0xa3, 0xf9, 0x16, 0xd7, 0x57,
|
||||
0x0d, 0xe7, 0xa7, 0x61, 0xb9, 0xf8, 0xa6, 0x50, 0x53, 0xa0, 0x8e, 0x94, 0x93, 0x56, 0x61, 0x3e,
|
||||
0x05, 0xb2, 0xbc, 0xbc, 0xb0, 0xf7, 0x0b, 0xe1, 0xb5, 0x01, 0x30, 0x2b, 0xc0, 0xb7, 0x96, 0xae,
|
||||
0xcc, 0xa3, 0xc2, 0x56, 0x2b, 0xb9, 0x34, 0x9e, 0x5c, 0x87, 0x75, 0xa1, 0x97, 0xe2, 0xdb, 0xcb,
|
||||
0xc9, 0x3d, 0xfe, 0x5f, 0xf9, 0x12, 0xad, 0xd1, 0xb9, 0x16, 0x2d, 0x1f, 0xd3, 0xd8, 0xf8, 0x98,
|
||||
0x5d, 0x42, 0x77, 0xef, 0x6c, 0x66, 0xa3, 0xf3, 0x99, 0x8d, 0xfe, 0xce, 0x6c, 0xf4, 0x65, 0x6e,
|
||||
0x97, 0xce, 0xe7, 0x76, 0xe9, 0xf7, 0xdc, 0x2e, 0xbd, 0x31, 0x7f, 0x22, 0x84, 0x47, 0x24, 0xe2,
|
||||
0xf9, 0x2d, 0x94, 0x93, 0x94, 0x42, 0x50, 0x56, 0x11, 0xec, 0xfd, 0x0b, 0x00, 0x00, 0xff, 0xff,
|
||||
0xa1, 0x5a, 0xf2, 0x18, 0x11, 0x04, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -179,6 +347,8 @@ type MsgClient interface {
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
||||
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
|
||||
NonAtomicExec(ctx context.Context, in *MsgNonAtomicExec, opts ...grpc.CallOption) (*MsgNonAtomicExecResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@ -198,6 +368,15 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) NonAtomicExec(ctx context.Context, in *MsgNonAtomicExec, opts ...grpc.CallOption) (*MsgNonAtomicExecResponse, error) {
|
||||
out := new(MsgNonAtomicExecResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.auth.v1beta1.Msg/NonAtomicExec", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
type MsgServer interface {
|
||||
// UpdateParams defines a (governance) operation for updating the x/auth module
|
||||
@ -205,6 +384,8 @@ type MsgServer interface {
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
|
||||
// NonAtomicExec allows users to submit multiple messages for non-atomic execution.
|
||||
NonAtomicExec(context.Context, *MsgNonAtomicExec) (*MsgNonAtomicExecResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
|
||||
@ -214,6 +395,9 @@ type UnimplementedMsgServer struct {
|
||||
func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
|
||||
}
|
||||
func (*UnimplementedMsgServer) NonAtomicExec(ctx context.Context, req *MsgNonAtomicExec) (*MsgNonAtomicExecResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method NonAtomicExec not implemented")
|
||||
}
|
||||
|
||||
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
|
||||
s.RegisterService(&_Msg_serviceDesc, srv)
|
||||
@ -237,6 +421,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_NonAtomicExec_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgNonAtomicExec)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).NonAtomicExec(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.auth.v1beta1.Msg/NonAtomicExec",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).NonAtomicExec(ctx, req.(*MsgNonAtomicExec))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cosmos.auth.v1beta1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
@ -245,6 +447,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "UpdateParams",
|
||||
Handler: _Msg_UpdateParams_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "NonAtomicExec",
|
||||
Handler: _Msg_NonAtomicExec_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/auth/v1beta1/tx.proto",
|
||||
@ -313,6 +519,129 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExec) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExec) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Msgs) > 0 {
|
||||
for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTx(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if len(m.Signer) > 0 {
|
||||
i -= len(m.Signer)
|
||||
copy(dAtA[i:], m.Signer)
|
||||
i = encodeVarintTx(dAtA, i, uint64(len(m.Signer)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *NonAtomicExecResult) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *NonAtomicExecResult) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *NonAtomicExecResult) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.Resp != nil {
|
||||
{
|
||||
size, err := m.Resp.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTx(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Error) > 0 {
|
||||
i -= len(m.Error)
|
||||
copy(dAtA[i:], m.Error)
|
||||
i = encodeVarintTx(dAtA, i, uint64(len(m.Error)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExecResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExecResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExecResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Results) > 0 {
|
||||
for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Results[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTx(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovTx(v)
|
||||
base := offset
|
||||
@ -348,6 +677,57 @@ func (m *MsgUpdateParamsResponse) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExec) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Signer)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
if len(m.Msgs) > 0 {
|
||||
for _, e := range m.Msgs {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *NonAtomicExecResult) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Error)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
if m.Resp != nil {
|
||||
l = m.Resp.Size()
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgNonAtomicExecResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Results) > 0 {
|
||||
for _, e := range m.Results {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovTx(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
@ -519,6 +899,324 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgNonAtomicExec) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: MsgNonAtomicExec: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgNonAtomicExec: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Signer = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Msgs = append(m.Msgs, &types.Any{})
|
||||
if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTx(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *NonAtomicExecResult) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: NonAtomicExecResult: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: NonAtomicExecResult: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Error = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Resp", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Resp == nil {
|
||||
m.Resp = &types.Any{}
|
||||
}
|
||||
if err := m.Resp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTx(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgNonAtomicExecResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: MsgNonAtomicExecResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgNonAtomicExecResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Results = append(m.Results, &NonAtomicExecResult{})
|
||||
if err := m.Results[len(m.Results)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTx(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipTx(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
protoiface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
// MockBankKeeper is a mock of BankKeeper interface.
|
||||
@ -81,3 +82,55 @@ func (mr *MockBankKeeperMockRecorder) SendCoins(ctx, fromAddr, toAddr, amt inter
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoins", reflect.TypeOf((*MockBankKeeper)(nil).SendCoins), ctx, fromAddr, toAddr, 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, accountAddr []byte) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsAccountsModuleAccount", ctx, accountAddr)
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsAccountsModuleAccount indicates an expected call of IsAccountsModuleAccount.
|
||||
func (mr *MockAccountsModKeeperMockRecorder) IsAccountsModuleAccount(ctx, accountAddr interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAccountsModuleAccount", reflect.TypeOf((*MockAccountsModKeeper)(nil).IsAccountsModuleAccount), ctx, accountAddr)
|
||||
}
|
||||
|
||||
// SendModuleMessageUntyped mocks base method.
|
||||
func (m *MockAccountsModKeeper) SendModuleMessageUntyped(ctx context.Context, sender []byte, msg protoiface.MessageV1) (protoiface.MessageV1, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "SendModuleMessageUntyped", ctx, sender, msg)
|
||||
ret0, _ := ret[0].(protoiface.MessageV1)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// SendModuleMessageUntyped indicates an expected call of SendModuleMessageUntyped.
|
||||
func (mr *MockAccountsModKeeperMockRecorder) SendModuleMessageUntyped(ctx, sender, msg interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendModuleMessageUntyped", reflect.TypeOf((*MockAccountsModKeeper)(nil).SendModuleMessageUntyped), ctx, sender, msg)
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@ package types
|
||||
import (
|
||||
context "context"
|
||||
|
||||
"cosmossdk.io/x/auth/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -13,3 +15,7 @@ type BankKeeper interface {
|
||||
SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
BlockedAddr(addr sdk.AccAddress) bool
|
||||
}
|
||||
|
||||
type AccountsModKeeper interface {
|
||||
types.AccountsModKeeper
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
@ -14,6 +15,7 @@ import (
|
||||
"cosmossdk.io/x/auth/keeper"
|
||||
authtypes "cosmossdk.io/x/auth/types"
|
||||
"cosmossdk.io/x/auth/vesting"
|
||||
vestingtestutil "cosmossdk.io/x/auth/vesting/testutil"
|
||||
"cosmossdk.io/x/auth/vesting/types"
|
||||
|
||||
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
|
||||
@ -46,6 +48,10 @@ func (s *VestingAccountTestSuite) SetupTest() {
|
||||
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
|
||||
s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{})
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(&testing.T{})
|
||||
acctsModKeeper := vestingtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
|
||||
maccPerms := map[string][]string{
|
||||
"fee_collector": nil,
|
||||
"mint": {"minter"},
|
||||
@ -59,10 +65,11 @@ func (s *VestingAccountTestSuite) SetupTest() {
|
||||
env,
|
||||
encCfg.Codec,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
authcodec.NewBech32Codec("cosmos"),
|
||||
"cosmos",
|
||||
authtypes.NewModuleAddress("gov").String(), nil,
|
||||
authtypes.NewModuleAddress("gov").String(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -216,17 +216,3 @@ 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)
|
||||
}
|
||||
|
||||
@ -10,6 +10,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"
|
||||
@ -46,16 +47,22 @@ func TestFundsMigration(t *testing.T) {
|
||||
authority, err := addressCodec.BytesToString(authtypes.NewModuleAddress("gov"))
|
||||
require.NoError(t, err)
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(t)
|
||||
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
|
||||
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
|
||||
poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl)
|
||||
|
||||
// create account keeper
|
||||
accountKeeper := authkeeper.NewAccountKeeper(
|
||||
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger()),
|
||||
encCfg.Codec,
|
||||
authtypes.ProtoBaseAccount,
|
||||
acctsModKeeper,
|
||||
maccPerms,
|
||||
addressCodec,
|
||||
sdk.Bech32MainPrefix,
|
||||
authority,
|
||||
nil,
|
||||
)
|
||||
|
||||
// create bank keeper
|
||||
@ -67,11 +74,6 @@ func TestFundsMigration(t *testing.T) {
|
||||
authority,
|
||||
)
|
||||
|
||||
// gomock initializations
|
||||
ctrl := gomock.NewController(t)
|
||||
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
|
||||
poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl)
|
||||
|
||||
// create distribution keeper
|
||||
distrKeeper := keeper.NewKeeper(
|
||||
encCfg.Codec,
|
||||
|
||||
@ -103,10 +103,11 @@ func createOldPolicyAccount(ctx sdk.Context, storeKey storetypes.StoreKey, cdc c
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// gomock initializations
|
||||
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)
|
||||
accountKeeper := authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(storeKey.(*storetypes.KVStoreKey)), log.NewNopLogger()), cdc, authtypes.ProtoBaseAccount, acctsModKeeper, nil, addressCodec, sdk.Bech32MainPrefix, authorityStrAddr)
|
||||
|
||||
oldPolicyAccounts := make([]*authtypes.ModuleAccount, len(policies))
|
||||
for i, policyAddr := range policies {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user