-
Notifications
You must be signed in to change notification settings - Fork 425
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
Remove transaction scan #3992
Remove transaction scan #3992
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
4 Skipped Deployments
|
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
packages/web/components/place-limit-tool/index.tsxOops! Something went wrong! :( ESLint: 8.50.0 ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct. The config "next/core-web-vitals" was referenced from the config file in "/packages/web/.eslintrc.json". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. WalkthroughThe pull request introduces significant changes to the handling of transaction scanning and fee estimation within the codebase. The Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
packages/web/components/place-limit-tool/index.tsx (4)
Line range hint
560-567
: Consider enhancing error handling robustnessThe wallet connection check improves UX, but consider these enhancements:
- Add type guards for error messages
- Handle edge cases where wallet connection status changes during error display
- if ( - swapState.error === "limitOrders.insufficientFunds" && - !account?.isWalletConnected - ) { + if ( + typeof swapState.error === "string" && + swapState.error === "limitOrders.insufficientFunds" && + !account?.isWalletConnected + ) {
Line range hint
565-600
: Refactor complex amount calculation logic for better maintainabilityThe
handleMarketTab
function contains nested ternary operators that make the code hard to read and maintain. Consider refactoring to improve clarity:- const handleMarketTab = () => { - if (tab === "sell") { - return focused === "fiat" - ? transformAmount( - getTrimmedAmount( - swapState.marketState.inAmountInput.inputAmount - ), - 10 - ) - : formatInputAsPrice( - swapState.marketState.outAmountInput.inputAmount - ); - } else { - return focused === "fiat" - ? transformAmount( - getTrimmedAmount( - swapState.marketState.outAmountInput.inputAmount - ), - 10 - ) - : formatInputAsPrice( - swapState.marketState.inAmountInput.inputAmount - ); - } - }; + const handleMarketTab = () => { + const isSellTab = tab === "sell"; + const input = isSellTab + ? swapState.marketState.inAmountInput + : swapState.marketState.outAmountInput; + const oppositeInput = isSellTab + ? swapState.marketState.outAmountInput + : swapState.marketState.inAmountInput; + + if (focused === "fiat") { + return transformAmount(getTrimmedAmount(input.inputAmount), 10); + } + return formatInputAsPrice(oppositeInput.inputAmount); + };
Line range hint
32-71
: Enhance input validation and transformationThe current input validation is spread across multiple functions. Consider:
- Centralizing validation logic into a single utility
- Adding input sanitization
- Using TypeScript's type system more effectively
+interface ValidationOptions { + decimalCount?: number; + rounding?: boolean; + allowNegative?: boolean; +} + +const validateAndTransformAmount = ( + value: string, + options: ValidationOptions = {} +): string | null => { + const { + decimalCount = 18, + rounding = false, + allowNegative = false + } = options; + + // Early validation + if (!value || value.length > 26) return null; + if (!allowNegative && value.startsWith('-')) return null; + + // Handle special cases + if (value === '.') return '0.0'; + if (value.startsWith('.')) return `0${value}`; + + // Validate numerical input + if (!isValidNumericalRawInput(value)) return null; + + // Apply decimal count and rounding + return rounding + ? roundUpToDecimal(parseFloat(value), decimalCount).toString() + : fixDecimalCount(value, decimalCount); +};
Line range hint
1-24
: Consider breaking down the component for better maintainabilityThe
PlaceLimitTool
component is quite large and handles multiple responsibilities. Consider:
- Breaking it down into smaller, focused components
- Extracting complex state management into custom hooks
- Adding proper documentation for props and callbacks
Example structure:
// Components const OrderInput: FC<OrderInputProps> = ... const PriceDisplay: FC<PriceDisplayProps> = ... const OrderActions: FC<OrderActionsProps> = ... // Hooks const useOrderValidation = (params: ValidationParams) => ... const usePriceCalculation = (params: PriceParams) => ... // Main component with reduced complexity export const PlaceLimitTool: FC<PlaceLimitToolProps> = ({ page, initialBaseDenom, initialQuoteDenom, onOrderSuccess, }) => { const validation = useOrderValidation(...) const pricing = usePriceCalculation(...) return ( <> <OrderInput {...validation} /> <PriceDisplay {...pricing} /> <OrderActions onSuccess={onOrderSuccess} /> </> ) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
packages/stores/src/account/base.ts
(0 hunks)packages/web/components/place-limit-tool/index.tsx
(1 hunks)packages/web/pages/api/transaction-scan.ts
(0 hunks)
💤 Files with no reviewable changes (2)
- packages/web/pages/api/transaction-scan.ts
- packages/stores/src/account/base.ts
What is the purpose of the change:
Linear Task
Removes transaction scan. See issue for details