From 96a5eeff88f80166d559ba7d8482a4765af742c2 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 3 May 2024 10:37:15 +0800 Subject: [PATCH] Apply suggestions from code review --- x/e2ee/keeper/keeper.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/x/e2ee/keeper/keeper.go b/x/e2ee/keeper/keeper.go index 1fbb763105..0365889263 100644 --- a/x/e2ee/keeper/keeper.go +++ b/x/e2ee/keeper/keeper.go @@ -32,9 +32,6 @@ func (k Keeper) RegisterEncryptionKey( ctx context.Context, req *types.MsgRegisterEncryptionKey, ) (*types.MsgRegisterEncryptionKeyResponse, error) { - if err := req.ValidateBasic(); err != nil { - return nil, err - } bz, err := k.addressCodec.StringToBytes(req.Address) if err != nil { return nil, err @@ -49,10 +46,14 @@ func (k Keeper) InitGenesis( state *types.GenesisState, ) error { for _, key := range state.Keys { - if _, err := k.RegisterEncryptionKey(ctx, &types.MsgRegisterEncryptionKey{ + m := types.MsgRegisterEncryptionKey{ Address: key.Address, Key: key.Key, - }); err != nil { + } + if err := m.ValidateBasic(); err != nil { + return err + } + if _, err := k.RegisterEncryptionKey(ctx, &m); err != nil { return err } }