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

Unwire the legacy router #3757

Merged
merged 11 commits into from
Aug 19, 2024
Merged

Unwire the legacy router #3757

merged 11 commits into from
Aug 19, 2024

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Aug 18, 2024

What is the purpose of the change:

  • Unwire the legacy router
  • Always return default Sidecar router
  • Remove indexer pools
  • Remove old feature flags

Next PR:

  • Remove the actual implementation of the legacy router

Copy link

vercel bot commented Aug 18, 2024

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 Aug 19, 2024 3:58pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Visit Preview Aug 19, 2024 3:58pm
osmosis-frontend-dev ⬜️ Ignored (Inspect) Visit Preview Aug 19, 2024 3:58pm
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Aug 19, 2024 3:58pm
osmosis-testnet ⬜️ Ignored (Inspect) Visit Preview Aug 19, 2024 3:58pm

@p0mvn p0mvn requested a review from jonator August 18, 2024 02:44
@p0mvn p0mvn marked this pull request as ready for review August 18, 2024 02:44
@p0mvn p0mvn marked this pull request as draft August 18, 2024 02:44
Copy link
Contributor

coderabbitai bot commented Aug 18, 2024

Walkthrough

The recent changes streamline module exports and simplify router management across the codebase. Key updates include the removal of specific exports, the introduction of a default router function, and the elimination of the preferredRouter parameter from the swapRouter input schema. These adjustments enhance maintainability and reduce complexity, leading to a more coherent architecture and improved error handling.

Changes

Files Change Summary
.../complex/pools/index.ts, .../complex/pools/providers/index.ts Removed exports from ./route-token-out-given-in and ./indexer, while maintaining the export from ./sidecar, altering the public API of the modules.
.../complex/swap-routers.ts Removed availableRoutersSchema and getRouters function, introducing getDefaultRouter for simplified router management.
.../trpc/src/swap.ts, .../trpc/src/__tests_e2e__/swap-router.spec.ts Removed preferredRouter parameter from swapRouter input schema and updated tests, simplifying usage and type management.
.../components/swap-tool/alt.tsx, .../components/swap-tool/index.tsx Removed the router property from event logging in AltSwapTool and the main SwapTool component, indicating a change in routing information handling.
.../hooks/limit-orders/use-place-limit.ts, .../hooks/use-swap.tsx Modified functions to eliminate router properties, streamlining parameter management and enhancing clarity in error handling and data retrieval logic.
.../queries/osmosis/poolmanager/pools.ts Renamed the function queryPools to queryPoolsChain, updating the exported function name without changing its functionality.
.../queries/index.ts, .../queries/sidecar/index.ts Added new export statements to enhance module accessibility by exporting all from ./sidecar and ./router.
.../queries/sidecar/router.ts Introduced getSidecarRouter and modified OsmosisSidecarRemoteRouter by removing its implementation of the TokenOutGivenInRouter interface.
.../pools/src/router/routes.ts, .../pools/src/router/types.ts Removed TokenOutGivenInRouter interface and its method, simplifying routing logic and class implementations.
.../hooks/use-feature-flags.ts Updated AvailableFlags type, removed specific flags, and simplified defaultFlags definition, changing useFeatureFlags from constant to function export.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3887238 and acc2b9a.

Files selected for processing (1)
  • packages/web/hooks/use-feature-flags.ts (5 hunks)
Additional comments not posted (4)
packages/web/hooks/use-feature-flags.ts (4)

Line range hint 34-55: Simplified flag management approved.

The change to use AvailableFlags as the key type for defaultFlags simplifies the flag management system. Ensure that the default values align with the intended application behavior.


64-64: Function export style change approved.

Changing the function declaration from a constant export to a function export is a stylistic improvement that can enhance readability and maintainability.


112-115: Expanded return type approved.

Including "_isInitialized" and "_isClientIDPresent" in the return type ensures these flags are part of the feature flag logic, which is beneficial for managing initialization and client ID presence.


Line range hint 10-31: LGTM! Verify the removal of unused flags.

The removal of "sidecarRouter", "legacyRouter", and "tfmRouter" from AvailableFlags aligns with the PR objectives. Ensure these flags are not referenced elsewhere in the codebase.

Verification successful

Verification Successful: Removed flags are not referenced elsewhere

The flags "sidecarRouter", "legacyRouter", and "tfmRouter" have been successfully removed from the AvailableFlags type and are not referenced elsewhere in the codebase. This aligns with the PR objectives.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removed flags are not referenced elsewhere in the codebase.

# Test: Search for the removed flags. Expect: No occurrences.
rg --type javascript --type typescript '"sidecarRouter"|"legacyRouter"|"tfmRouter"'

Length of output: 120


Script:

#!/bin/bash
# Description: Verify that the removed flags are not referenced elsewhere in the codebase.

# Test: Search for the removed flags. Expect: No occurrences.
rg --type js --type ts '"sidecarRouter"|"legacyRouter"|"tfmRouter"'

Length of output: 69


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we should go further and just call the SQS out-given-in query function and not even conform to the TokenOutGivenInRouter interface. We should be able to delete the pools package entirely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I will try

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

packages/web/hooks/use-swap.tsx Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Member

@jonator jonator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good cleanup step.

Without spending tons of time digging into the code, I think the next step to evetually delete the pools package (or help us be ready to) would be to copy over any imports directly from the pools package into /packages/server/src/queries/sidecar/router.ts (like error types, the router interface, etc).

Basically removing references into the pools package. Then when the tRPC migration is complete and all legacy pools queries are deleted, we can just delete that package in entirety.

@p0mvn
Copy link
Member Author

p0mvn commented Aug 19, 2024

This is a good cleanup step.

Without spending tons of time digging into the code, I think the next step to evetually delete the pools package (or help us be ready to) would be to copy over any imports directly from the pools package into /packages/server/src/queries/sidecar/router.ts (like error types, the router interface, etc).

Basically removing references into the pools package. Then when the tRPC migration is complete and all legacy pools queries are deleted, we can just delete that package in entirety.

Thanks for suggestions - tracked here: #3764

@p0mvn
Copy link
Member Author

p0mvn commented Aug 19, 2024

Merging - appreciate the reviews

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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, codebase verification and nitpick comments (1)
packages/trpc/src/__tests_e2e__/swap-router.spec.ts (1)

20-20: Impact of Removing RouterInputs

The RouterInputs type is used in several files across the codebase. Removing it could lead to type-related issues in these files:

  • packages/web/utils/trpc.ts
  • packages/web/hooks/use-swap.tsx
  • packages/web/hooks/mutations/one-click-trading/use-create-one-click-trading-session.tsx
  • packages/web/components/table/asset-info.tsx
  • packages/web/components/bridge/use-bridge-quotes.ts
  • packages/web/components/table/asset-balances.tsx

Please ensure that these usages are addressed to maintain type safety.

Analysis chain

Verify the impact of removing RouterInputs.

The RouterInputs type declaration has been removed. Ensure that this does not affect type safety or lead to any type-related issues in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing `RouterInputs` type declaration.

# Test: Search for the usage of `RouterInputs` in the codebase. Expect: No occurrences.
rg --type typescript 'RouterInputs'

Length of output: 70


Script:

#!/bin/bash
# Description: Verify the impact of removing `RouterInputs` type declaration.

# Test: Search for the usage of `RouterInputs` in the codebase. Expect: No occurrences.
rg --type ts 'RouterInputs'

Length of output: 1422

@p0mvn p0mvn merged commit fa5fa80 into stage Aug 19, 2024
31 of 32 checks passed
@p0mvn p0mvn deleted the roman/begin-remove-legacy-router branch August 19, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants