backend: clean swakpit frontend/backend interaction#3961
Open
bznein wants to merge 1 commit intoBitBoxSwiss:staging-swapfrom
Open
backend: clean swakpit frontend/backend interaction#3961bznein wants to merge 1 commit intoBitBoxSwiss:staging-swapfrom
bznein wants to merge 1 commit intoBitBoxSwiss:staging-swapfrom
Conversation
thisconnect
approved these changes
Mar 30, 2026
Collaborator
thisconnect
left a comment
There was a problem hiding this comment.
frontend LGTM with one small change
Instead of returnign the whole response to the frontend, we only return what is needed to the frontend as QuoteRouteSummary. We also change the account code type in the backend api, to make it more aligned to what other handlers do.
c629742 to
8afa7ae
Compare
Collaborator
|
@Beerosagos PTAL |
Beerosagos
reviewed
Apr 8, 2026
| return result{ | ||
| Success: true, | ||
| Quote: quoteResponse, | ||
| Routes: swapkit.QuoteRouteSummariesFromResponse(quoteResponse), |
Collaborator
There was a problem hiding this comment.
nit: afaik we don't fetch quotes in any other place, so we could make swapkit.NewQuoteFromCoinCode return the object needed by the handler directly, and avoid the second helper
| func assetFromCoinCode(coinCode string) (string, bool) { | ||
| asset, ok := swapkitAssetByCoinCode[strings.ToLower(strings.TrimSpace(coinCode))] | ||
| func assetFromCoinCode(coinCode coinpkg.Code) (string, bool) { | ||
| asset, ok := swapkitAssetByCoinCode[strings.ToLower(strings.TrimSpace(string(coinCode)))] |
Collaborator
There was a problem hiding this comment.
can we remove ToLower and TrimSpace?
| if request.BuyAccountCode == "" { | ||
| return errorResult(swapkit.ErrInvalidRequest, "Missing buyAccountCode.") | ||
| } | ||
| if request.SellAccountCode == request.BuyAccountCode { |
Collaborator
There was a problem hiding this comment.
Maybe it would be better to move this check inside the swap logic? Comparing coins instead of accounts would be even better, I guess.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of returnign the whole response to the frontend, we only return what is needed to the frontend as QuoteRouteSummary.
We also change the account code type in the backend api, to make it more aligned to what other handlers do.
Before asking for reviews, here is a check list of the most common things you might need to consider: