Closed crnbarr93 closed 1 month ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
osmosis-frontend | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 3, 2024 5:55pm |
The changes enhance the useQueryRouterBestQuote
function in the packages/web/hooks/use-swap.tsx
file by adding a condition to check for zero amounts in quotes and modifying checks for token decimal values. These alterations ensure early returns for invalid quotes and clarify the intent of decimal checks, improving the overall handling of quote data.
Files | Change Summary |
---|---|
packages/web/hooks/use-swap.tsx | Enhanced useQueryRouterBestQuote by adding zero amount check for quotes and refining checks for token decimals to ensure valid data processing. Updated parameters for getSwapMessages with non-null assertions. |
sequenceDiagram
participant User
participant Hook
participant QuoteService
User->>Hook: Request quote
Hook->>QuoteService: Fetch quote
QuoteService-->>Hook: Return quote
Hook->>Hook: Check if quote.amount is zero
alt Valid quote
Hook->>Hook: Check token decimal values
Hook->>User: Return valid quote
else Invalid quote
Hook->>User: Return error
end
[!TIP] We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.
packages/web/hooks/use-swap.tsx (2)
`1572-1575`: **Ensure all required parameters are defined before calling `getSwapMessages`.** The code correctly checks that all required parameters are defined before calling `getSwapMessages`. This prevents potential errors due to undefined values. --- `1581-1582`: **Use non-null assertions only when values are guaranteed to be defined.** The non-null assertions (`!`) are used correctly here since the code checks that `tokenInCoinDecimals` and `tokenOutCoinDecimals` are not undefined before calling `getSwapMessages`.
What is the purpose of the change:
These changes fix an issue when a coin with 0 decimal places is used for a quote.
Linear Task
FE-1073
Brief Changelog
tokenInCoinDecimals/tokenOutCoinDecimals
check to check type rather than existence