Skip to content

Commit

Permalink
fix: wallet not found panic (#2721)
Browse files Browse the repository at this point in the history
This PR addresses a panic which can happen when a wallet is not found during the uphold linking process.
  • Loading branch information
clD11 authored Dec 3, 2024
1 parent 28be327 commit 8a78b42
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions services/wallet/controllers_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,20 +396,23 @@ func LinkUpholdDepositAccountV3(s *Service) func(w http.ResponseWriter, r *http.
)
}

// read post body
if err := inputs.DecodeAndValidateReader(ctx, cuw, r.Body); err != nil {
return cuw.HandleErrors(err)
}

// get the wallet
wallet, err := s.GetWallet(ctx, *id.UUID())
if err != nil {
if strings.Contains(err.Error(), "looking up wallet") {
return handlers.WrapError(err, "unable to find wallet", http.StatusNotFound)
}
l.Err(err).Msg("failed to get wallet")

return handlers.WrapError(err, "unable to get or create wallets", http.StatusServiceUnavailable)
}

if wallet == nil {
l.Err(model.ErrWalletNotFound).Msg("wallet not found")

return handlers.WrapError(err, "unable to find wallet", http.StatusNotFound)
}

var aa uuid.UUID

if cuw.AnonymousAddress != "" {
Expand Down

0 comments on commit 8a78b42

Please sign in to comment.