Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return err if type not in manager #8170

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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