From 81e405ba9742d2b13f576fcee4f60f8d7b7d5d7d Mon Sep 17 00:00:00 2001 From: PaddyMc Date: Sun, 28 Apr 2024 21:28:30 +0100 Subject: [PATCH] fix: return err if type not in manager --- x/smart-account/authenticator/composite.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x/smart-account/authenticator/composite.go b/x/smart-account/authenticator/composite.go index 22ad9c626d4..cbdad3c330d 100644 --- a/x/smart-account/authenticator/composite.go +++ b/x/smart-account/authenticator/composite.go @@ -56,6 +56,9 @@ func onSubAuthenticatorsAdded(ctx sdk.Context, account sdk.AccAddress, data []by subAuthenticatorCount := 0 for id, initData := range initDatas { authenticatorCode := am.GetAuthenticatorByType(initData.Type) + if authenticatorCode == nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "sub-authenticator failed to be added in function `OnAuthenticatorAdded` as type is not registered in manager") + } subId := compositeId(baseId, id) err := authenticatorCode.OnAuthenticatorAdded(ctx, account, initData.Config, subId) if err != nil { @@ -82,6 +85,9 @@ func onSubAuthenticatorsRemoved(ctx sdk.Context, account sdk.AccAddress, data [] baseId := authenticatorId for id, initData := range initDatas { authenticatorCode := am.GetAuthenticatorByType(initData.Type) + if authenticatorCode == nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "sub-authenticator failed to be removed in function `OnAuthenticatorRemoved` as type is not registered in manager") + } subId := compositeId(baseId, id) err := authenticatorCode.OnAuthenticatorRemoved(ctx, account, initData.Config, subId) if err != nil {