Skip to content

Commit

Permalink
fix: return err if type not in manager (#8170)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddyMc authored Apr 29, 2024
1 parent 144e5e1 commit 8593293
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions x/smart-account/authenticator/composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 8593293

Please sign in to comment.