From 4dd96eba09d54778096fcfb071497ed28cf44b1e Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 9 Jun 2022 16:58:34 -0400 Subject: [PATCH] Revert "fix: add base account getter (backport #12154) (#12161)" (#12213) --- CHANGELOG.md | 1 - x/auth/vesting/msg_server.go | 16 +++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09b8b1374..fb38a03d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,7 +51,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#10947](https://github.com/cosmos/cosmos-sdk/pull/10947) Add `AllowancesByGranter` query to the feegrant module * [\#9639](https://github.com/cosmos/cosmos-sdk/pull/9639) Check store keys length before accessing them by making sure that `key` is of length `m+1` (for `key[n:m]`) * [\#11983](https://github.com/cosmos/cosmos-sdk/pull/11983) (x/feegrant, x/authz) rename grants query commands to `grants-by-grantee`, `grants-by-granter` cmds. -* (types) [#12154](https://github.com/cosmos/cosmos-sdk/pull/12154) Add `baseAccountGetter` to avoid invalid account error when create vesting account. ## Improvements diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 21d4dba97..795fc2c60 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -19,10 +19,6 @@ type msgServer struct { types.BankKeeper } -type baseAccountGetter interface { - GetBaseAccount() *authtypes.BaseAccount -} - // NewMsgServerImpl returns an implementation of the vesting MsgServer interface, // wrapping the corresponding AccountKeeper and BankKeeper. func NewMsgServerImpl(k keeper.AccountKeeper, bk types.BankKeeper) types.MsgServer { @@ -57,18 +53,12 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress) } - account := ak.NewAccountWithAddress(ctx, to) - baseAccount, ok := account.(*authtypes.BaseAccount) - if !ok { - if getter, ok := account.(baseAccountGetter); ok { - baseAccount = getter.GetBaseAccount() - } - } - if baseAccount == nil { + baseAccount := ak.NewAccountWithAddress(ctx, to) + if _, ok := baseAccount.(*authtypes.BaseAccount); !ok { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid account type; expected: BaseAccount, got: %T", baseAccount) } - baseVestingAccount := types.NewBaseVestingAccount(baseAccount, msg.Amount.Sort(), msg.EndTime) + baseVestingAccount := types.NewBaseVestingAccount(baseAccount.(*authtypes.BaseAccount), msg.Amount.Sort(), msg.EndTime) var acc authtypes.AccountI