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

General fixes #3981

Merged
merged 2 commits into from
Dec 2, 2024
Merged

General fixes #3981

merged 2 commits into from
Dec 2, 2024

Conversation

JoseRFelix
Copy link
Collaborator

@JoseRFelix JoseRFelix commented Nov 30, 2024

What is the purpose of the change:

  • Fix incorrect deposit status display for different wallets
  • Fix misleading countdown phrasing for withdrawal progress
  • Fix confirm swap button is unclickable when 1CT is enabled
  • Fix transfers disappearing after 1 day
  • Change default Osmosis portfolio view from 1D to 7D

Linear Task

https://linear.app/osmosis/issue/FE-1262/fix-incorrect-deposit-status-display-for-different-wallets
https://linear.app/osmosis/issue/FE-1256/fix-misleading-countdown-phrasing-for-withdrawal-progress
https://linear.app/osmosis/issue/FE-1263/confirm-swap-button-unclickable-when-1ct-is-enabled
https://linear.app/osmosis/issue/FE-1264/fix-transfers-disappearing-after-1-day
https://linear.app/osmosis/issue/FE-1255/change-default-osmosis-portfolio-view-from-1d-to-7d

Copy link

vercel bot commented Nov 30, 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 Dec 2, 2024 4:06pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 4:06pm
osmosis-frontend-dev ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 4:06pm
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Dec 2, 2024 4:06pm
osmosis-testnet ⬜️ Ignored (Inspect) Visit Preview Dec 2, 2024 4:06pm

Copy link
Contributor

coderabbitai bot commented Nov 30, 2024

Walkthrough

This pull request consists of extensive formatting and style adjustments across multiple files in the codebase. The changes primarily involve standardizing string quotation marks from double quotes to single quotes, removing unnecessary semicolons in property declarations and method implementations, and modifying the structure of various components and test cases for consistency. No alterations to the underlying logic, functionality, or control flow have been made; the focus is strictly on improving code readability and maintaining stylistic uniformity.

Changes

File Path Change Summary
packages/e2e/pages/pool-page.ts Formatting changes: single quotes for strings, semicolons removed from property declarations and methods.
packages/e2e/pages/pools-page.ts Formatting changes: single quotes for strings, semicolons removed from property declarations and methods.
packages/e2e/pages/portfolio-page.ts Formatting changes: single-line declarations for properties, single quotes for strings, no functional changes.
packages/e2e/pages/swap-page.ts Formatting changes: single quotes for strings, semicolons removed from property declarations and methods.
packages/e2e/pages/trade-page.ts Formatting changes: single quotes for strings, semicolons removed from property declarations and methods.
packages/e2e/pages/transactions-page.ts Formatting changes: single quotes for strings, semicolons removed from property declarations and methods.
packages/e2e/tests/claim.spec.ts Formatting changes: single quotes for strings, no functional changes.
packages/e2e/tests/monitoring.limit.wallet.spec.ts Formatting changes: single quotes for strings, no functional changes.
packages/e2e/tests/monitoring.market.wallet.spec.ts Formatting changes: single quotes for strings, no functional changes.
packages/e2e/tests/monitoring.swap.wallet.spec.ts Formatting changes: single quotes for strings, no functional changes.
packages/e2e/tests/pools.spec.ts Formatting changes: single quotes for strings, semicolons removed, Page type added.
packages/e2e/tests/portfolio.wallet.spec.ts Formatting changes: single quotes for strings, Page type added.
packages/e2e/tests/select.spec.ts Formatting changes: single quotes for strings, no functional changes.
packages/e2e/tests/swap.wallet.spec.ts Formatting changes: single quotes for strings, no functional changes.
packages/e2e/tests/trade.wallet.spec.ts Formatting changes: single quotes for strings, no functional changes.
packages/e2e/tests/transactions.wallet.spec.ts Formatting changes: single quotes for strings, semicolons removed, Page type added.
packages/web/components/complex/portfolio/assets-overview.tsx Updated initial state for range from "1d" to "7d".
packages/web/components/nomic/nomic-pending-transfers.tsx Enhanced functionality: added useMemo, updated upsertTransaction method to accept an array.
packages/web/components/one-click-trading/one-click-remaining-time.tsx Updated displayHumanizedTime function to include delimitedBy parameter.
packages/web/hooks/one-click-trading/use-one-click-trading-session.ts Updated isEnabled property handling to default to false if undefined.
packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts Enhanced session management and loading states with new variables for clarity.
packages/web/modals/profile.tsx Updated className property in ModalBase for responsive design.
packages/web/server/api/routers/bridge-transfer.ts Added userOsmoAddress to response structure of getNomicPendingDeposits method.
packages/web/stores/__tests__/transfer-history.spec.tsx Updated translation key for time remaining in tests.
packages/web/stores/transfer-history.tsx Removed expired snapshot check in restoreSnapshots method, updated time display logic.

Possibly related PRs

Suggested reviewers

  • jonator

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts

Oops! 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.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3d288ea and f6bf847.

📒 Files selected for processing (2)
  • packages/e2e/pages/trade-page.ts (1 hunks)
  • packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/e2e/pages/trade-page.ts
  • packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts

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.

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 and nitpick comments (4)
packages/web/components/one-click-trading/one-click-remaining-time.tsx (1)

58-63: LGTM! Consider adding a comment explaining the delimiter choice.

The addition of the delimitedBy parameter improves the readability of time display when using short units. This change aligns well with fixing the misleading countdown phrasing mentioned in the PR objectives.

Consider adding a brief comment explaining why space delimiter is used for short units:

      {displayHumanizedTime({
        humanizedTime,
        t,
+       // Use space delimiter for short units (e.g., "1 h 30 m") for better readability
        delimitedBy: useShortTimeUnits ? " " : undefined,
      })}{" "}
      {t("remaining")}
packages/web/stores/__tests__/transfer-history.spec.tsx (1)

91-93: Consider adding more test cases for time transitions

While the test verifies the "Unknown time remaining" state, consider adding test cases for:

  • Edge case when time transitions from known to unknown
  • Different time ranges (minutes to seconds)
  it("updates the time remaining text", () => {
    const estimatedArrivalUnix = dayjs().add(5, "minutes").unix();

    render(
      <PendingTransferCaption
        isWithdraw={true}
        amount="10 OSMO"
        chainPrettyName="Osmosis"
        estimatedArrivalUnix={estimatedArrivalUnix}
      />
    );

    jest.advanceTimersByTime(300000); // Advance time by 5 minutes
    expect(screen.getByText(/Unknown time remaining/)).toBeInTheDocument();
+
+   // Test transition from known to unknown time
+   const transitionEstimatedArrival = dayjs().add(2, "seconds").unix();
+   render(
+     <PendingTransferCaption
+       isWithdraw={true}
+       amount="10 OSMO"
+       chainPrettyName="Osmosis"
+       estimatedArrivalUnix={transitionEstimatedArrival}
+     />
+   );
+
+   expect(screen.getByText(/2 seconds remaining/)).toBeInTheDocument();
+   jest.advanceTimersByTime(1500);
+   expect(screen.getByText(/Unknown time remaining/)).toBeInTheDocument();
  });
packages/web/stores/transfer-history.tsx (1)

431-432: LGTM: Improved time remaining display logic

The change from 5 seconds to 1 second threshold provides more accurate feedback to users and aligns with the PR objective of fixing misleading countdown phrasing.

Consider adding a constant for the threshold value to make it more maintainable:

+const TIME_REMAINING_THRESHOLD_SECONDS = 1;
+
 export const PendingTransferCaption: FunctionComponent<{
   // ...
 }> = ({ isWithdraw, amount, chainPrettyName, estimatedArrivalUnix }) => {
   // ...
   const updateTime = () => {
     // ...
     if (progressRef.current) {
       progressRef.current.textContent =
-        date.diff(dayjs(), "seconds") < 1
+        date.diff(dayjs(), "seconds") < TIME_REMAINING_THRESHOLD_SECONDS
           ? t("unknownTimeRemaining")
           : `${t("estimated")} ${displayHumanizedTime({
packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts (1)

250-258: Consider simplifying the loading state logic.

While the loading state logic is now more comprehensive and fixes the unclickable button issue, the nested ternary expression could be simplified for better readability.

Consider refactoring the loading state calculation like this:

-  const isLoading = shouldSend1CTTx
-    ? isLoadingOneClickMessages ||
-      (shouldFetchExistingSessionAuthenticator &&
-      !sessionAuthenticatorError &&
-      enabledFetchingSessionAuthenticator
-        ? isLoadingSessionAuthenticator
-        : false) ||
-      isLoadingInfo
-    : false;
+  const isLoadingSessionAuth =
+    shouldFetchExistingSessionAuthenticator &&
+    !sessionAuthenticatorError &&
+    enabledFetchingSessionAuthenticator &&
+    isLoadingSessionAuthenticator;
+
+  const isLoading = shouldSend1CTTx
+    ? isLoadingOneClickMessages || isLoadingSessionAuth || isLoadingInfo
+    : false;

Also applies to: 263-263

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c787085 and 3d288ea.

⛔ Files ignored due to path filters (17)
  • packages/web/localizations/de.json is excluded by !**/*.json
  • packages/web/localizations/en.json is excluded by !**/*.json
  • packages/web/localizations/es.json is excluded by !**/*.json
  • packages/web/localizations/fa.json is excluded by !**/*.json
  • packages/web/localizations/fr.json is excluded by !**/*.json
  • packages/web/localizations/gu.json is excluded by !**/*.json
  • packages/web/localizations/hi.json is excluded by !**/*.json
  • packages/web/localizations/ja.json is excluded by !**/*.json
  • packages/web/localizations/ko.json is excluded by !**/*.json
  • packages/web/localizations/pl.json is excluded by !**/*.json
  • packages/web/localizations/pt-br.json is excluded by !**/*.json
  • packages/web/localizations/ro.json is excluded by !**/*.json
  • packages/web/localizations/ru.json is excluded by !**/*.json
  • packages/web/localizations/tr.json is excluded by !**/*.json
  • packages/web/localizations/zh-cn.json is excluded by !**/*.json
  • packages/web/localizations/zh-hk.json is excluded by !**/*.json
  • packages/web/localizations/zh-tw.json is excluded by !**/*.json
📒 Files selected for processing (25)
  • packages/e2e/pages/pool-page.ts (1 hunks)
  • packages/e2e/pages/pools-page.ts (1 hunks)
  • packages/e2e/pages/portfolio-page.ts (1 hunks)
  • packages/e2e/pages/swap-page.ts (1 hunks)
  • packages/e2e/pages/trade-page.ts (1 hunks)
  • packages/e2e/pages/transactions-page.ts (1 hunks)
  • packages/e2e/tests/claim.spec.ts (1 hunks)
  • packages/e2e/tests/monitoring.limit.wallet.spec.ts (1 hunks)
  • packages/e2e/tests/monitoring.market.wallet.spec.ts (1 hunks)
  • packages/e2e/tests/monitoring.swap.wallet.spec.ts (1 hunks)
  • packages/e2e/tests/pools.spec.ts (1 hunks)
  • packages/e2e/tests/portfolio.wallet.spec.ts (1 hunks)
  • packages/e2e/tests/select.spec.ts (1 hunks)
  • packages/e2e/tests/swap.wallet.spec.ts (1 hunks)
  • packages/e2e/tests/trade.wallet.spec.ts (1 hunks)
  • packages/e2e/tests/transactions.wallet.spec.ts (1 hunks)
  • packages/web/components/complex/portfolio/assets-overview.tsx (1 hunks)
  • packages/web/components/nomic/nomic-pending-transfers.tsx (6 hunks)
  • packages/web/components/one-click-trading/one-click-remaining-time.tsx (1 hunks)
  • packages/web/hooks/one-click-trading/use-one-click-trading-session.ts (1 hunks)
  • packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts (2 hunks)
  • packages/web/modals/profile.tsx (1 hunks)
  • packages/web/server/api/routers/bridge-transfer.ts (1 hunks)
  • packages/web/stores/__tests__/transfer-history.spec.tsx (2 hunks)
  • packages/web/stores/transfer-history.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (17)
  • packages/e2e/tests/monitoring.swap.wallet.spec.ts
  • packages/e2e/tests/portfolio.wallet.spec.ts
  • packages/e2e/tests/monitoring.market.wallet.spec.ts
  • packages/e2e/tests/claim.spec.ts
  • packages/web/modals/profile.tsx
  • packages/e2e/tests/monitoring.limit.wallet.spec.ts
  • packages/e2e/tests/select.spec.ts
  • packages/e2e/tests/pools.spec.ts
  • packages/e2e/tests/transactions.wallet.spec.ts
  • packages/e2e/tests/trade.wallet.spec.ts
  • packages/e2e/pages/pool-page.ts
  • packages/e2e/tests/swap.wallet.spec.ts
  • packages/e2e/pages/portfolio-page.ts
  • packages/e2e/pages/transactions-page.ts
  • packages/e2e/pages/pools-page.ts
  • packages/e2e/pages/swap-page.ts
  • packages/e2e/pages/trade-page.ts
🧰 Additional context used
📓 Learnings (1)
packages/web/hooks/one-click-trading/use-one-click-trading-session.ts (1)
Learnt from: greg-nagy
PR: osmosis-labs/osmosis-frontend#3954
File: packages/web/hooks/one-click-trading/use-one-click-trading-session.ts:89-92
Timestamp: 2024-11-22T11:02:18.859Z
Learning: In the `useOneClickTradingSession` hook within `packages/web/hooks/one-click-trading/use-one-click-trading-session.ts`, storing the expired flag in the store is not desirable as it introduces unnecessary persistence without real usage. The `isExpired` status should be calculated rather than stored.
🔇 Additional comments (11)
packages/web/components/one-click-trading/one-click-remaining-time.tsx (1)

58-63: Verify consistent time display formatting across the application.

Let's ensure this time display formatting change is consistent with other uses of displayHumanizedTime in the codebase.

✅ Verification successful

Time display formatting is consistent across the application

The verification shows that the displayHumanizedTime function in packages/web/utils/date.ts is designed to handle an optional delimitedBy parameter, and all usages across the codebase are consistent with this implementation:

  • Most usages pass only humanizedTime and t parameters, defaulting to the " and " delimiter
  • The one-click-trading component specifically uses the optional delimitedBy parameter for short format
  • All implementations correctly use the function signature and expected parameters
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other uses of displayHumanizedTime to verify consistency
rg "displayHumanizedTime" --type ts --type tsx -B 2 -A 2

Length of output: 84


Script:

#!/bin/bash
# Search for other uses of displayHumanizedTime using ripgrep without file type restrictions
rg "displayHumanizedTime" -B 2 -A 2

Length of output: 5518


Script:

#!/bin/bash
# Find the implementation of displayHumanizedTime function using ast-grep
ast-grep --pattern 'function displayHumanizedTime($_) {
  $$$
}'

Length of output: 779


Script:

#!/bin/bash
# Find the file containing displayHumanizedTime implementation
fd "displayHumanizedTime"

Length of output: 25

packages/web/stores/__tests__/transfer-history.spec.tsx (1)

24-26: LGTM: Translation key addition aligns with UI improvements

The addition of the unknownTimeRemaining translation key supports the improved handling of transfer progress display.

packages/web/hooks/one-click-trading/use-one-click-trading-session.ts (1)

106-107: LGTM: Improved null handling for isEnabled flag

The addition of the null coalescing operator ?? provides better handling of undefined values, making the code more robust.

packages/web/components/nomic/nomic-pending-transfers.tsx (3)

104-110: LGTM: Clean state management setup

The use of useShallow with useNomicTransactionsStore is a good practice for optimizing re-renders.


141-145: Performance improvement with memoized filtering

Good use of useMemo to prevent unnecessary re-filtering of transactions. The filtering by userOsmoAddress ensures that only relevant transactions are displayed.


178-231: Verify transaction display logic

The transaction display logic looks correct, but let's verify the calculations and display of fees.

✅ Verification successful

Based on the search results, I can now generate the final response:

Fee calculation logic is correctly implemented

The fee calculations in the pending transfers display are properly implemented and consistent with the rest of the codebase:

  • The network and provider fee subtractions are handled consistently with the bridge transfer data model (packages/bridge/src/interface.ts)
  • The fee calculations follow the same pattern across different components that handle transfers
  • Both fiat value and amount calculations properly account for network and provider fees using the sub() operation
  • The display format matches the localization patterns found in the translation files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent fee calculation patterns across the codebase

# Look for similar fee calculations
ast-grep --pattern 'fiatValue?.sub($_, $_)'

# Check for other instances of network and provider fee handling
rg -A 2 'networkFee|providerFee' --type typescript

Length of output: 133


Script:

#!/bin/bash
# Search for fee-related calculations in TypeScript/JavaScript files
rg -t js -t jsx -t ts -t tsx "networkFee|providerFee" -A 2

# Look for similar fee calculations with optional chaining
rg -t js -t jsx -t ts -t tsx "fiatValue\?\.sub\(" -A 2

# Find other instances of fee calculations in the codebase
ast-grep --pattern 'amount.sub($_, $_)'

Length of output: 215


Script:

#!/bin/bash
# Search for fee-related calculations using ripgrep without file type specifications
rg "networkFee|providerFee" -A 2

# Look for similar fee calculations with optional chaining
rg "fiatValue\?\.sub\(" -A 2

# Search for amount subtraction patterns
rg "amount\.sub\(" -A 2

Length of output: 48907

packages/web/server/api/routers/bridge-transfer.ts (1)

738-738: LGTM: Added user address tracking to deposits

Adding userOsmoAddress to the pending deposits response is a good addition that enables proper filtering of transactions per user in the frontend.

packages/web/components/complex/portfolio/assets-overview.tsx (1)

160-160: LGTM: Default portfolio view successfully changed to 7 days

The change correctly implements the PR objective by updating the default portfolio view from 1 day to 7 days. The implementation is type-safe and maintains all component functionality.

packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts (3)

164-166: LGTM! Clear and descriptive variable extraction.

The introduction of enabledFetchingSessionAuthenticator improves code readability by consolidating the conditions for session authenticator fetching into a well-named variable.


170-170: LGTM! Enhanced error handling.

The addition of sessionAuthenticatorError improves error handling and prevents the UI from getting stuck in loading states when session authentication fails.


177-177: LGTM! Simplified query configuration.

Using the extracted enabledFetchingSessionAuthenticator variable improves the readability of the query configuration.

@JoseRFelix JoseRFelix merged commit 3f1f4c1 into stage Dec 2, 2024
33 checks passed
@JoseRFelix JoseRFelix deleted the jose/many-fixes branch December 2, 2024 16:07
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.

3 participants