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

refactor: add specific error code for solana custodian link mismatch #2665

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions services/wallet/controllers_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,18 +499,28 @@ func LinkSolanaAddress(s *Service) handlers.AppHandler {
switch {
case errors.Is(err, model.ErrWalletNotWhitelisted):
return handlers.WrapError(model.ErrWalletNotWhitelisted, "rewards wallet not whitelisted", http.StatusForbidden)

case errors.Is(err, model.ErrChallengeNotFound):
return handlers.WrapError(model.ErrChallengeNotFound, "linking challenge not found", http.StatusNotFound)

case errors.Is(err, model.ErrChallengeExpired):
return handlers.WrapError(model.ErrChallengeExpired, "linking challenge expired", http.StatusUnauthorized)

case errors.Is(err, model.ErrWalletNotFound):
return handlers.WrapError(model.ErrWalletNotFound, "rewards wallet not found", http.StatusNotFound)

case errors.Is(err, errDisabledRegion):
return handlers.WrapError(errDisabledRegion, "region is currently disabled for linking", http.StatusBadRequest)

case errors.Is(err, ErrTooManyCardsLinked):
return handlers.WrapError(ErrTooManyCardsLinked, "too many wallets linked", http.StatusConflict)

case errors.Is(err, errCustodianLinkMismatch):
return handlers.WrapError(errCustodianLinkMismatch, "wallet is linked to a different custodian", http.StatusBadRequest)

case errors.As(err, &solErr):
return handlers.WrapError(solErr, "invalid solana linking message", http.StatusUnauthorized)

default:
return handlers.WrapError(model.ErrInternalServer, "internal server error", http.StatusInternalServerError)
}
Expand Down
Loading