feat(auth): support accounts from auth (#21688)

This commit is contained in:
testinginprod
2024-09-17 18:12:45 +00:00
committed by GitHub
parent ffc16099aa
commit 81ec7ea9e7
35 changed files with 3130 additions and 249 deletions
+1
View File
@@ -60,6 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#18817](https://github.com/cosmos/cosmos-sdk/pull/18817) SigVerification, GasConsumption, IncreaseSequence ante decorators have all been joined into one SigVerification decorator. Gas consumption during TX validation flow has reduced.
* [#19093](https://github.com/cosmos/cosmos-sdk/pull/19093) SetPubKeyDecorator was merged into SigVerification, gas consumption is almost halved for a simple tx.
* [#19535](https://github.com/cosmos/cosmos-sdk/pull/19535) Remove vesting account creation when the chain is running. The accounts module is required for creating [#vesting accounts](../accounts/defaults/lockup/README.md) on a running chain.
* [#21688](https://github.com/cosmos/cosmos-sdk/pull/21688) Allow x/accounts to be queriable from the `AccountInfo` and `Account` gRPC endpoints
### Bug Fixes
+35 -2
View File
@@ -80,7 +80,11 @@ func (s queryServer) Account(ctx context.Context, req *types.QueryAccountRequest
}
account := s.k.GetAccount(ctx, addr)
if account == nil {
return nil, status.Errorf(codes.NotFound, "account %s not found", req.Address)
xAccount, err := s.getFromXAccounts(ctx, addr)
if err != nil {
return nil, status.Errorf(codes.NotFound, "account %s not found", req.Address)
}
return &types.QueryAccountResponse{Account: xAccount.Account}, nil
}
any, err := codectypes.NewAnyWithValue(account)
@@ -224,7 +228,13 @@ func (s queryServer) AccountInfo(ctx context.Context, req *types.QueryAccountInf
account := s.k.GetAccount(ctx, addr)
if account == nil {
return nil, status.Errorf(codes.NotFound, "account %s not found", req.Address)
xAccount, err := s.getFromXAccounts(ctx, addr)
// account info is nil it means that the account can be encapsulated into a
// legacy account representation but not a base account one.
if err != nil || xAccount.Info == nil {
return nil, status.Errorf(codes.NotFound, "account %s not found", req.Address)
}
return &types.QueryAccountInfoResponse{Info: xAccount.Info}, nil
}
// if there is no public key, avoid serializing the nil value
@@ -246,3 +256,26 @@ func (s queryServer) AccountInfo(ctx context.Context, req *types.QueryAccountInf
},
}, nil
}
var (
errNotXAccount = errors.New("not an x/account")
errInvalidLegacyAccountImpl = errors.New("invalid legacy account implementation")
)
func (s queryServer) getFromXAccounts(ctx context.Context, address []byte) (*types.QueryLegacyAccountResponse, error) {
if !s.k.AccountsModKeeper.IsAccountsModuleAccount(ctx, address) {
return nil, errNotXAccount
}
// attempt to check if it can be queried for a legacy account representation.
resp, err := s.k.AccountsModKeeper.Query(ctx, address, &types.QueryLegacyAccount{})
if err != nil {
return nil, err
}
typedResp, ok := resp.(*types.QueryLegacyAccountResponse)
if !ok {
return nil, errInvalidLegacyAccountImpl
}
return typedResp, nil
}
+2
View File
@@ -8,6 +8,7 @@ import (
"sort"
"github.com/cosmos/gogoproto/proto"
"github.com/golang/mock/gomock"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -135,6 +136,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccount() {
for _, tc := range testCases {
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
suite.SetupTest() // reset
suite.acctsModKeeper.EXPECT().IsAccountsModuleAccount(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
tc.malleate()
res, err := suite.queryClient.Account(suite.ctx, req)
@@ -0,0 +1,27 @@
syntax = "proto3";
package cosmos.auth.v1beta1;
import "google/protobuf/any.proto";
import "cosmos/auth/v1beta1/auth.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";
// QueryLegacyAccount defines a query that can be implemented by an x/account
// to return an auth understandable representation of an account.
// This query is only used for accounts retro-compatibility at gRPC
// level, the state machine must not make any assumptions around this.
message QueryLegacyAccount {}
// QueryLegacyAccountResponse defines the response type of the
// `QueryLegacyAccount` query.
message QueryLegacyAccountResponse {
// account represents the google.Protobuf.Any wrapped account
// the type wrapped by the any does not need to comply with the
// sdk.AccountI interface.
google.protobuf.Any account = 1;
// info represents the account as a BaseAccount, this can return
// nil if the account cannot be represented as a BaseAccount.
// This is used in the gRPC QueryAccountInfo method.
BaseAccount base = 2;
}
+15
View File
@@ -149,6 +149,21 @@ func (mr *MockAccountsModKeeperMockRecorder) NextAccountNumber(ctx interface{})
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NextAccountNumber", reflect.TypeOf((*MockAccountsModKeeper)(nil).NextAccountNumber), ctx)
}
// Query mocks base method.
func (m *MockAccountsModKeeper) Query(ctx context.Context, accountAddr []byte, queryRequest transaction.Msg) (transaction.Msg, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Query", ctx, accountAddr, queryRequest)
ret0, _ := ret[0].(transaction.Msg)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Query indicates an expected call of Query.
func (mr *MockAccountsModKeeperMockRecorder) Query(ctx, accountAddr, queryRequest interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockAccountsModKeeper)(nil).Query), ctx, accountAddr, queryRequest)
}
// SendModuleMessage mocks base method.
func (m *MockAccountsModKeeper) SendModuleMessage(ctx context.Context, sender []byte, msg transaction.Msg) (transaction.Msg, error) {
m.ctrl.T.Helper()
+523
View File
@@ -0,0 +1,523 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/auth/v1beta1/accounts.proto
package types
import (
fmt "fmt"
proto "github.com/cosmos/gogoproto/proto"
any "github.com/cosmos/gogoproto/types/any"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// QueryLegacyAccount defines a query that can be implemented by an x/account
// to return an auth understandable representation of an account.
// This query is only used for accounts retro-compatibility at gRPC
// level, the state machine must not make any assumptions around this.
type QueryLegacyAccount struct {
}
func (m *QueryLegacyAccount) Reset() { *m = QueryLegacyAccount{} }
func (m *QueryLegacyAccount) String() string { return proto.CompactTextString(m) }
func (*QueryLegacyAccount) ProtoMessage() {}
func (*QueryLegacyAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_25696478f9b3e7f4, []int{0}
}
func (m *QueryLegacyAccount) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryLegacyAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryLegacyAccount.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 *QueryLegacyAccount) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryLegacyAccount.Merge(m, src)
}
func (m *QueryLegacyAccount) XXX_Size() int {
return m.Size()
}
func (m *QueryLegacyAccount) XXX_DiscardUnknown() {
xxx_messageInfo_QueryLegacyAccount.DiscardUnknown(m)
}
var xxx_messageInfo_QueryLegacyAccount proto.InternalMessageInfo
// QueryLegacyAccountResponse defines the response type of the
// `QueryLegacyAccount` query.
type QueryLegacyAccountResponse struct {
// account represents the google.Protobuf.Any wrapped account
// the type wrapped by the any does not need to comply with the
// sdk.AccountI interface.
Account *any.Any `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
// info represents the account as a BaseAccount, this can return
// nil if the account cannot be represented as a base account.
// This is used in the gRPC QueryAccountInfo method.
Info *BaseAccount `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"`
}
func (m *QueryLegacyAccountResponse) Reset() { *m = QueryLegacyAccountResponse{} }
func (m *QueryLegacyAccountResponse) String() string { return proto.CompactTextString(m) }
func (*QueryLegacyAccountResponse) ProtoMessage() {}
func (*QueryLegacyAccountResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_25696478f9b3e7f4, []int{1}
}
func (m *QueryLegacyAccountResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryLegacyAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryLegacyAccountResponse.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 *QueryLegacyAccountResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryLegacyAccountResponse.Merge(m, src)
}
func (m *QueryLegacyAccountResponse) XXX_Size() int {
return m.Size()
}
func (m *QueryLegacyAccountResponse) XXX_DiscardUnknown() {
xxx_messageInfo_QueryLegacyAccountResponse.DiscardUnknown(m)
}
var xxx_messageInfo_QueryLegacyAccountResponse proto.InternalMessageInfo
func (m *QueryLegacyAccountResponse) GetAccount() *any.Any {
if m != nil {
return m.Account
}
return nil
}
func (m *QueryLegacyAccountResponse) GetInfo() *BaseAccount {
if m != nil {
return m.Info
}
return nil
}
func init() {
proto.RegisterType((*QueryLegacyAccount)(nil), "cosmos.auth.v1beta1.QueryLegacyAccount")
proto.RegisterType((*QueryLegacyAccountResponse)(nil), "cosmos.auth.v1beta1.QueryLegacyAccountResponse")
}
func init() {
proto.RegisterFile("cosmos/auth/v1beta1/accounts.proto", fileDescriptor_25696478f9b3e7f4)
}
var fileDescriptor_25696478f9b3e7f4 = []byte{
// 247 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0xcf, 0xb1, 0x4e, 0xc3, 0x30,
0x10, 0x06, 0xe0, 0x18, 0x21, 0x90, 0xcc, 0x16, 0x3a, 0x94, 0x0c, 0x56, 0x95, 0x09, 0x06, 0xce,
0x2a, 0xf0, 0x02, 0x2d, 0x2b, 0x0b, 0x1d, 0xd9, 0x1c, 0xe3, 0xa6, 0x15, 0xd4, 0x17, 0xf5, 0x6c,
0x84, 0x57, 0x9e, 0x80, 0xc7, 0x62, 0xec, 0xc8, 0x88, 0x92, 0x17, 0x41, 0xb5, 0x93, 0xa9, 0x9d,
0x2c, 0xd9, 0x9f, 0xef, 0xfe, 0x9f, 0x97, 0x1a, 0x69, 0x83, 0x24, 0x95, 0x77, 0x2b, 0xf9, 0x31,
0xad, 0x8c, 0x53, 0x53, 0xa9, 0xb4, 0x46, 0x6f, 0x1d, 0x41, 0xb3, 0x45, 0x87, 0xf9, 0x65, 0x32,
0xb0, 0x37, 0xd0, 0x9b, 0xe2, 0xaa, 0x46, 0xac, 0xdf, 0x8d, 0x8c, 0xa4, 0xf2, 0x4b, 0xa9, 0x6c,
0x48, 0xbe, 0x10, 0x47, 0x67, 0xee, 0x3f, 0xc7, 0xf7, 0x72, 0xc4, 0xf3, 0x67, 0x6f, 0xb6, 0xe1,
0xc9, 0xd4, 0x4a, 0x87, 0x59, 0x5a, 0x56, 0x7e, 0x31, 0x5e, 0x1c, 0x5e, 0x2f, 0x0c, 0x35, 0x68,
0xc9, 0xe4, 0xc0, 0xcf, 0xfb, 0x58, 0x63, 0x36, 0x61, 0xd7, 0x17, 0x77, 0x23, 0x48, 0x09, 0x60,
0x48, 0x00, 0x33, 0x1b, 0x16, 0x03, 0xca, 0x1f, 0xf8, 0xe9, 0xda, 0x2e, 0x71, 0x7c, 0x12, 0xf1,
0x04, 0x8e, 0x74, 0x80, 0xb9, 0x22, 0x33, 0xec, 0x89, 0x7a, 0xfe, 0xf8, 0xd3, 0x0a, 0xb6, 0x6b,
0x05, 0xfb, 0x6b, 0x05, 0xfb, 0xee, 0x44, 0xb6, 0xeb, 0x44, 0xf6, 0xdb, 0x89, 0xec, 0xe5, 0xa6,
0x5e, 0xbb, 0x95, 0xaf, 0x40, 0xe3, 0x46, 0xf6, 0xfd, 0xd2, 0x71, 0x4b, 0xaf, 0x6f, 0xf2, 0x33,
0x95, 0x75, 0xa1, 0x31, 0x54, 0x9d, 0xc5, 0x44, 0xf7, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdf,
0x0d, 0xc9, 0xcb, 0x5c, 0x01, 0x00, 0x00,
}
func (m *QueryLegacyAccount) 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 *QueryLegacyAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryLegacyAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func (m *QueryLegacyAccountResponse) 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 *QueryLegacyAccountResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryLegacyAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Info != nil {
{
size, err := m.Info.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintAccounts(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
if m.Account != nil {
{
size, err := m.Account.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintAccounts(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func encodeVarintAccounts(dAtA []byte, offset int, v uint64) int {
offset -= sovAccounts(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *QueryLegacyAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func (m *QueryLegacyAccountResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Account != nil {
l = m.Account.Size()
n += 1 + l + sovAccounts(uint64(l))
}
if m.Info != nil {
l = m.Info.Size()
n += 1 + l + sovAccounts(uint64(l))
}
return n
}
func sovAccounts(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozAccounts(x uint64) (n int) {
return sovAccounts(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *QueryLegacyAccount) 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 ErrIntOverflowAccounts
}
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: QueryLegacyAccount: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryLegacyAccount: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipAccounts(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthAccounts
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *QueryLegacyAccountResponse) 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 ErrIntOverflowAccounts
}
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: QueryLegacyAccountResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryLegacyAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAccounts
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthAccounts
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthAccounts
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Account == nil {
m.Account = &any.Any{}
}
if err := m.Account.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAccounts
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthAccounts
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthAccounts
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Info == nil {
m.Info = &BaseAccount{}
}
if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipAccounts(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthAccounts
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipAccounts(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAccounts
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAccounts
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAccounts
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthAccounts
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupAccounts
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthAccounts
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthAccounts = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowAccounts = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupAccounts = fmt.Errorf("proto: unexpected end of group")
)
+7
View File
@@ -21,6 +21,13 @@ type AccountsModKeeper interface {
IsAccountsModuleAccount(ctx context.Context, accountAddr []byte) bool
NextAccountNumber(ctx context.Context) (accNum uint64, err error)
// Query is used to query an account
Query(
ctx context.Context,
accountAddr []byte,
queryRequest transaction.Msg,
) (transaction.Msg, error)
// InitAccountNumberSeqUnsafe is use to set accounts module account number with value
// of auth module current account number
InitAccountNumberSeqUnsafe(ctx context.Context, currentAccNum uint64) error
@@ -8,7 +8,6 @@ import (
context "context"
reflect "reflect"
transaction "cosmossdk.io/core/transaction"
types "github.com/cosmos/cosmos-sdk/types"
gomock "github.com/golang/mock/gomock"
)
@@ -82,84 +81,3 @@ 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
}
// InitAccountNumberSeqUnsafe mocks base method.
func (m *MockAccountsModKeeper) InitAccountNumberSeqUnsafe(ctx context.Context, currentAccNum uint64) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "InitAccountNumberSeqUnsafe", ctx, currentAccNum)
ret0, _ := ret[0].(error)
return ret0
}
// InitAccountNumberSeqUnsafe indicates an expected call of InitAccountNumberSeqUnsafe.
func (mr *MockAccountsModKeeperMockRecorder) InitAccountNumberSeqUnsafe(ctx, currentAccNum interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitAccountNumberSeqUnsafe", reflect.TypeOf((*MockAccountsModKeeper)(nil).InitAccountNumberSeqUnsafe), ctx, currentAccNum)
}
// 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)
}
// NextAccountNumber mocks base method.
func (m *MockAccountsModKeeper) NextAccountNumber(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NextAccountNumber", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// NextAccountNumber indicates an expected call of NextAccountNumber.
func (mr *MockAccountsModKeeperMockRecorder) NextAccountNumber(ctx interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NextAccountNumber", reflect.TypeOf((*MockAccountsModKeeper)(nil).NextAccountNumber), ctx)
}
// SendModuleMessage mocks base method.
func (m *MockAccountsModKeeper) SendModuleMessage(ctx context.Context, sender []byte, msg transaction.Msg) (transaction.Msg, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SendModuleMessage", ctx, sender, msg)
ret0, _ := ret[0].(transaction.Msg)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SendModuleMessage indicates an expected call of SendModuleMessage.
func (mr *MockAccountsModKeeperMockRecorder) SendModuleMessage(ctx, sender, msg interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendModuleMessage", reflect.TypeOf((*MockAccountsModKeeper)(nil).SendModuleMessage), ctx, sender, msg)
}
-5
View File
@@ -4,7 +4,6 @@ import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
// BankKeeper defines the expected interface contract the vesting module requires
@@ -14,7 +13,3 @@ 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
}
+2 -3
View File
@@ -21,9 +21,9 @@ import (
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtestutil "github.com/cosmos/cosmos-sdk/x/auth/vesting/testutil"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
)
@@ -50,7 +50,6 @@ func (s *VestingAccountTestSuite) SetupTest() {
// gomock initializations
ctrl := gomock.NewController(&testing.T{})
acctsModKeeper := vestingtestutil.NewMockAccountsModKeeper(ctrl)
maccPerms := map[string][]string{
"fee_collector": nil,
@@ -65,7 +64,7 @@ func (s *VestingAccountTestSuite) SetupTest() {
env,
encCfg.Codec,
authtypes.ProtoBaseAccount,
acctsModKeeper,
authtestutil.NewMockAccountsModKeeper(ctrl),
maccPerms,
authcodec.NewBech32Codec("cosmos"),
"cosmos",