-
Notifications
You must be signed in to change notification settings - Fork 11
Fix crash when adding contract tokens from stellar.expert search (#799) #801
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f2284a2
Fix crash when adding contract tokens from stellar.expert search (#799)
CassioMG c589c04
Cap CI Xcode version at 26.3 to fix iOS build
CassioMG 5d13f4f
Add tests for contract token parsing from stellar.expert
CassioMG d459f69
Prevent crash when swapping custom/Soroban tokens
CassioMG f0923b7
Fix infinite useEffect loop in SwapAmountScreen
CassioMG 12b5f6e
Fix tokenContractId selection to prefer explicit contract field
CassioMG 55b7344
add comment
CassioMG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { logger } from "config/logger"; | |
| import { PricedBalance } from "config/types"; | ||
| import { useDebugStore } from "ducks/debug"; | ||
| import { formatBigNumberForDisplay } from "helpers/formatAmount"; | ||
| import { isContractId } from "helpers/soroban"; | ||
| import { t } from "i18next"; | ||
| import { getTokenForPayment } from "services/transactionService"; | ||
| import { create } from "zustand"; | ||
|
|
@@ -184,6 +185,23 @@ export const useSwapStore = create<SwapState>((set) => ({ | |
| throw new Error(t("debug.debugMessages.swapPathFailure")); | ||
| } | ||
|
|
||
| // Custom/Soroban tokens cannot be swapped via Horizon's classic DEX | ||
| const isSourceCustom = | ||
| "contractId" in sourceBalance || | ||
| ("id" in sourceBalance && isContractId(sourceBalance.id ?? "")); | ||
| const isDestCustom = | ||
| "contractId" in destinationBalance || | ||
| ("id" in destinationBalance && | ||
| isContractId(destinationBalance.id ?? "")); | ||
|
|
||
| if (isSourceCustom || isDestCustom) { | ||
| set({ | ||
| isLoadingPath: false, | ||
| pathError: t("swapScreen.errors.customTokenSwapNotSupported"), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| }); | ||
| return; | ||
| } | ||
|
|
||
| // For now, we only support classic path payments | ||
| // TODO: Add Soroswap support for Testnet in future iteration | ||
| const pathResult = await findClassicSwapPath({ | ||
|
|
||
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
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
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
Oops, something went wrong.
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.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a possible response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean a response containing only
assetanddomain? It shouldn't happen. I think the main goal of this test case is asserting that the app is able to handle a search using the contract address + a response containing the contract address as theassetfieldThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, a response with just those 2 fields. I wasn't quite sure what this covers that stub above doesn't. Both have
assetas a contract id anddomainas a stringThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, was just curious