osmosis-frontend icon indicating copy to clipboard operation
osmosis-frontend copied to clipboard

feat: 1ct review modal

Open Kyatros opened this issue 1 year ago • 6 comments

What is the purpose of the change:

This PR introduces a new call to action (CTA) for the "1-click trading" feature within the Swap modal in the Osmosis frontend. The goal is to increase user engagement and conversion for this feature by adding a more visible and accessible CTA. Additionally, this PR includes functionality to track and display the length of a session, as required by the acceptance criteria in the provided Figma design.

Linear Task

  • ?

Brief Changelog

-1-click trading CTA feature on Review Trade Modal. -Improve functionallity and performance in 1CT hook. -Feature of modifying 1ct session on Review Trade Modal.

Testing and Verifying

Tested locally

Use cases covered:

If the user does NOT have an active 1CT session:

  • The 1CT call to action appears with a switcher. The entire 1CT panel is clickable to activate or deactivate 1CT.
  • When activated, a session duration summary appears along with the option to "Change".
  • If the user clicks "Change", the 1CT configuration modal opens, and upon returning, they can proceed to confirm the transaction.
  • The ‘Confirm’ button first triggers the 1CT activation transaction.

If the user has an active 1CT session:

  • The current value of the limit is displayed, considering the next operation, and shows the limits.
  • Clicking limit value text navigates to 1CT settings screen in the same modal - back button from there returns to the review modal.
  • If the value exceeds the limit, "Exceeded" is displayed along with an "Edit" button.
  • Clicking "Edit" shows the 1CT settings options within the same modal.
  • All functionality has been verified and behaves as expected.

Kyatros avatar Oct 21 '24 20:10 Kyatros

@Kyatros is attempting to deploy a commit to the OsmoLabs Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Oct 21 '24 20:10 vercel[bot]

Walkthrough

This pull request introduces several new React components related to one-click trading functionality, including OneClickTradingRemainingAmount, OneClickTradingCallToAction, OneClickTradingInReviewModal, and OneClickTradingLimitRemaining. It also modifies existing components like OneClickTradingSettings and ProfileOneClickTradingSettings to enhance state management and user interaction. The useOneClickTradingParams and useOneClickTradingSession hooks are updated for improved data fetching and session management. Additionally, the ReviewOrder component is enhanced to integrate one-click trading settings and user feedback mechanisms.

Changes

File Path Change Summary
packages/web/components/one-click-trading/one-click-remaining-amount.tsx New component OneClickTradingRemainingAmount added to display remaining spending limit or session expiration message.
`packages/web/components/one-click-trading/one-click-trading-call-to-action.tsx New component OneClickTradingCallToAction added, enabling users to toggle one-click trading and log events.
`packages/web/components/one-click-trading/one-click-trading-in-review-modal.tsx New component OneClickTradingInReviewModal added for managing transaction reviews, incorporating session management and error handling.
`packages/web/components/one-click-trading/one-click-trading-limit-remaining.tsx New component OneClickTradingLimitRemaining added to show remaining limits and allow edits if exceeded.
`packages/web/components/one-click-trading/one-click-trading-settings.tsx Updated OneClickTradingSettings to add optional prop resetTransaction1CTParams, modify onClose prop, and simplify state management.
`packages/web/components/one-click-trading/profile-one-click-trading-settings.tsx Updated ProfileOneClickTradingSettings to refine boolean expressions and add resetTransaction1CTParams prop to OneClickTradingSettings.
packages/web/hooks/one-click-trading/use-one-click-trading-params.ts Updated useOneClickTradingParams hook to replace useEffect with useQuery for data fetching and state management, adding scopeKey parameter.
packages/web/hooks/one-click-trading/use-one-click-trading-session.ts Enhanced useOneClickTradingSession hook to include new queries for amount spent and session expiration logic, adding methods for calculating remaining limits.
`packages/web/modals/review-order.tsx Modified ReviewOrder component to integrate one-click trading settings and manage transaction triggering, including new state variables and updated rendering logic.

Possibly related PRs

  • #3843: This PR includes updates related to one-click trading, specifically enabling Ledger signing for one-click trading, which is relevant to the session management and user feedback aspects of the main PR.
  • #3861: Although primarily focused on removing old assets and dead code, this PR indirectly relates to the overall cleanup and restructuring of the codebase, which may impact components like OneClickTradingRemainingAmount that rely on a streamlined architecture.

Suggested reviewers

  • MaxMillington
  • DavideSegullo

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

coderabbitai[bot] avatar Oct 21 '24 20:10 coderabbitai[bot]

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 Oct 21, 2024 9:03pm

vercel[bot] avatar Oct 21 '24 21:10 vercel[bot]

@Kyatros translation is missing Screenshot from 2024-10-22 11-54-39

CryptoAssassin1 avatar Oct 22 '24 06:10 CryptoAssassin1

On mobile 1click trading is not getting enabled even after signed tx image

CryptoAssassin1 avatar Oct 22 '24 07:10 CryptoAssassin1

Going to review once changes are made from prior reviews

jonator avatar Oct 22 '24 19:10 jonator

@Kyatros looks like we still have some bugs on this feature. Are you able to come up with a working solution?

MaxMillington avatar Oct 28 '24 17:10 MaxMillington