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

(1CT) Rename Modified Chain Properties #3302

Merged
merged 9 commits into from
Jun 8, 2024
Merged

Conversation

JoseRFelix
Copy link
Collaborator

@JoseRFelix JoseRFelix commented Jun 6, 2024

What is the purpose of the change:

This PR renames modified chain properties to fix the spend limit contract queries and session creation.

Linear Task

Linear Task URL

Copy link

vercel bot commented Jun 6, 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 Jun 7, 2024 10:09am
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 10:09am
osmosis-frontend-dev ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 10:09am
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) 💬 3 unresolved Jun 7, 2024 10:09am
osmosis-testnet ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 10:09am

Copy link
Contributor

coderabbitai bot commented Jun 6, 2024

Walkthrough

The overall changes focus on refining the One-Click Trading feature by removing the resetPeriod parameter and updating key names for consistency. This involves alterations to interfaces, function parameters, and component logic across various files. Additionally, minor enhancements such as adding a refetchInterval option and adjusting test cases are included to improve functionality and maintainability.

Changes

Files Change Summaries
packages/stores/src/account/base.ts Updated fromBase64 function call parameter from privateKey to sessionKey.
packages/stores/src/account/types.ts Renamed privateKey to sessionKey in OneClickTradingInfo interface and removed resetPeriod field.
packages/trpc/src/one-click-trading.ts Removed queryBaseAccount, adjusted parameters in oneClickTradingRouter, renamed getAccountPubKeyAndAuthenticators to getAuthenticators with simplified logic.
packages/types/src/autheticator-types.ts Renamed properties in RawNestedAuthenticator from Config to config and Type to type.
packages/types/src/one-click-trading-types.ts Removed resetPeriod field from OneClickTradingTransactionParams interface.
packages/utils/src/authenticator.ts Corrected property name casing in parseNestedAuthenticator function.
packages/web/components/one-click-trading/__tests__/one-click-trading-settings.spec.ts Removed resetPeriod field from test cases, adjusted string casing, and updated object keys in assertions.
packages/web/components/one-click-trading/one-click-trading-settings.tsx Removed ResetPeriodScreen component and associated logic, affecting UI and behavior related to reset period.
packages/web/components/one-click-trading/profile-one-click-trading-settings.tsx Added retry: false to useQuery hook configuration.
packages/web/components/swap-tool/index.tsx Removed loadingText prop assignment from SwapTool component.
packages/web/hooks/mutations/one-click-trading/__tests__/use-create-one-click-trading-session.spec.ts Removed resetPeriod variable, adjusted string casing, and changed object key casing in test assertions.
packages/web/hooks/mutations/one-click-trading/use-create-one-click-trading-session.tsx Removed getFirstAuthenticator function, renamed properties, updated parameters of getOneClickTradingSessionAuthenticator, and adjusted authenticator usage.
packages/web/hooks/one-click-trading/use-one-click-trading-params.ts Removed resetPeriod parameter from getParametersFromOneClickTradingInfo function.
packages/web/hooks/use-swap.tsx Added refetchInterval option with a value of 5_000 to useQueryRouterBestQuote function.

Poem

In the code, a change so bright,
Session keys now take flight.
Reset periods bid adieu,
One-click trades, streamlined anew.
With each tweak, our code does sing,
A better app, for all to bring.
🌟🐇✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bc19f28 and 2161204.

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 (14)
  • packages/stores/src/account/base.ts (1 hunks)
  • packages/stores/src/account/types.ts (3 hunks)
  • packages/trpc/src/one-click-trading.ts (4 hunks)
  • packages/types/src/autheticator-types.ts (1 hunks)
  • packages/types/src/one-click-trading-types.ts (1 hunks)
  • packages/utils/src/authenticator.ts (4 hunks)
  • packages/web/components/one-click-trading/tests/one-click-trading-settings.spec.ts (4 hunks)
  • packages/web/components/one-click-trading/one-click-trading-settings.tsx (5 hunks)
  • packages/web/components/one-click-trading/profile-one-click-trading-settings.tsx (1 hunks)
  • packages/web/components/swap-tool/index.tsx (1 hunks)
  • packages/web/hooks/mutations/one-click-trading/tests/use-create-one-click-trading-session.spec.ts (5 hunks)
  • packages/web/hooks/mutations/one-click-trading/use-create-one-click-trading-session.tsx (8 hunks)
  • packages/web/hooks/one-click-trading/use-one-click-trading-params.ts (1 hunks)
  • packages/web/hooks/use-swap.tsx (1 hunks)
Files skipped from review due to trivial changes (2)
  • packages/web/components/one-click-trading/tests/one-click-trading-settings.spec.ts
  • packages/web/hooks/mutations/one-click-trading/tests/use-create-one-click-trading-session.spec.ts
Additional context used
Biome
packages/web/components/one-click-trading/profile-one-click-trading-settings.tsx

[error] 57-57: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

packages/web/components/one-click-trading/one-click-trading-settings.tsx

[error] 264-271: Provide a href attribute for the a element. (lint/a11y/useValidAnchor)

An anchor element should always have a href
Check this thorough explanation to better understand the context.


[error] 529-536: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

packages/web/components/swap-tool/index.tsx

[error] 363-386: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.


[error] 391-410: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.


[error] 977-978: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call


[error] 387-387: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset


[error] 596-617: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset


[error] 759-771: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

packages/web/hooks/use-swap.tsx

[error] 200-200: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call


[error] 519-519: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

packages/stores/src/account/base.ts

[error] 1208-1208: The catch clause that only rethrows the original error is redundant. (lint/complexity/noUselessCatch)

These unnecessary catch clauses can be confusing. It is recommended to remove them.

Additional comments not posted (9)
packages/types/src/autheticator-types.ts (1)

15-16: Confirmed renaming of Config and Type to config and type in RawNestedAuthenticator. Ensure all references to these properties are updated across the codebase.

packages/web/components/one-click-trading/profile-one-click-trading-settings.tsx (1)

36-36: Confirmed addition of retry: false to useQuery configuration. This change prevents unnecessary retries, which can enhance performance and reduce server load.

packages/trpc/src/one-click-trading.ts (2)

29-29: The addition of new parameters in getParameters aligns well with the PR's objectives.


78-84: Renaming and simplification of getAuthenticators function enhances clarity and focus.

packages/utils/src/authenticator.ts (1)

Line range hint 89-141: The changes to use lowercase for type and config in parseNestedAuthenticator are consistent with the PR's objectives and improve code consistency.

packages/stores/src/account/types.ts (1)

105-105: The changes in OneClickTradingInfo, including the addition of sessionKey, align with the PR's objectives and enhance security by not using privateKey.

packages/web/hooks/use-swap.tsx (2)

1235-1236: Refetch interval set to 5 seconds.

This ensures that the quote data is refreshed every 5 seconds, which is important for maintaining up-to-date information in a dynamic trading environment.


Line range hint 123-123: Utility functions for asset denomination fallbacks are correctly implemented.

The functions determineNextFallbackFromDenom and determineNextFallbackToDenom correctly handle various scenarios for asset denomination fallbacks, ensuring robustness in asset selection.

packages/stores/src/account/base.ts (1)

908-908: Update the parameter from privateKey to sessionKey in the fromBase64 function call.

This change aligns with the renaming of fields to enhance clarity and security by using more appropriate terminology.


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 Configration 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: 1

Outside diff range and nitpick comments (12)
packages/types/src/one-click-trading-types.ts (1)

[!TIP]
Codebase Verification

The resetPeriod field is still referenced in packages/web/components/one-click-trading/one-click-trading-settings.tsx. This indicates that the removal of resetPeriod from OneClickTradingTransactionParams is incomplete and may cause inconsistencies or errors.

  • packages/web/components/one-click-trading/one-click-trading-settings.tsx: Lines referencing resetPeriod.

Please ensure that all references to resetPeriod are removed or updated accordingly.

Analysis chain

Line range hint 1-20: Confirmed removal of resetPeriod from OneClickTradingTransactionParams. Ensure all references to this field are updated across the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `resetPeriod` is not used elsewhere in the codebase.

# Test: Search for the `resetPeriod` usage. Expect: No occurrences.
rg --type typescript $'resetPeriod'

Length of output: 69



Script:

#!/bin/bash
# Description: Verify that `resetPeriod` is not used elsewhere in the codebase.

# Test: Search for the `resetPeriod` usage. Expect: No occurrences.
rg --type ts $'resetPeriod'

Length of output: 474

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

[!TIP]
Codebase Verification

The resetPeriod parameter is still referenced in packages/web/components/one-click-trading/one-click-trading-settings.tsx on lines 75, 77, and 120. This indicates that the removal of resetPeriod from getParametersFromOneClickTradingInfo is inconsistent with its usage in other parts of the codebase.

  • Location of issues:
    • packages/web/components/one-click-trading/one-click-trading-settings.tsx:
      • Line 75
      • Line 77
      • Line 120

Please review these references and ensure that the removal of resetPeriod is handled consistently across the codebase.

Analysis chain

Line range hint 1-60: Confirmed removal of resetPeriod from getParametersFromOneClickTradingInfo. Ensure all references to this parameter are updated across the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `resetPeriod` is not used elsewhere in the codebase.

# Test: Search for the `resetPeriod` usage. Expect: No occurrences.
rg --type typescript $'resetPeriod'

Length of output: 69



Script:

#!/bin/bash
# Description: Verify that `resetPeriod` is not used elsewhere in the codebase.

# Test: Search for the `resetPeriod` usage. Expect: No occurrences.
rg --type ts $'resetPeriod'

Length of output: 474



Script:

#!/bin/bash
# Description: Extract lines containing `resetPeriod` from `one-click-trading-settings.tsx`.

# Test: Display lines with `resetPeriod` for review.
rg --type ts --line-number --context 5 $'resetPeriod' packages/web/components/one-click-trading/one-click-trading-settings.tsx

Length of output: 1028

packages/web/components/one-click-trading/one-click-trading-settings.tsx (2)

Line range hint 264-271: Add a href attribute to the anchor element to ensure it is accessible.

- <a className={buttonVariants({ variant: "link", className: "!inline w-auto !px-0 !text-body2 !font-body2 text-wosmongton-300", })}>
+ <a href="#" className={buttonVariants({ variant: "link", className: "!inline w-auto !px-0 !text-body2 !font-body2 text-wosmongton-300", })}>

Line range hint 529-536: Ensure keyboard accessibility by adding keyboard event handlers to clickable elements.

- <div className="group flex cursor-pointer items-center justify-between border-b border-osmoverse-700 px-8 py-3.5 last:border-none" onClick={isDisabled ? noop : onClick}>
+ <div className="group flex cursor-pointer items-center justify-between border-b border-osmoverse-700 px-8 py-3.5 last:border-none" onClick={isDisabled ? noop : onClick} onKeyUp={isDisabled ? noop : onClick} onKeyDown={isDisabled ? noop : onClick}>
packages/web/components/swap-tool/index.tsx (4)

Line range hint 363-386: Add keyboard event handlers to ensure accessibility for keyboard-only users.

- <button onClick={() => swapState.switchAssets()} aria-label="Switch assets">
+ <button onClick={() => swapState.switchAssets()} onKeyUp={() => swapState.switchAssets()} onKeyDown={() => swapState.switchAssets()} aria-label="Switch assets">

Line range hint 391-410: Ensure keyboard accessibility by adding keyboard event handlers to clickable elements.

- <button onClick={() => { if (isQuoteDetailRelevant) setShowEstimateDetails((show) => !show); }}>
+ <button onClick={() => { if (isQuoteDetailRelevant) setShowEstimateDetails((show) => !show); }} onKeyUp={() => { if (isQuoteDetailRelevant) setShowEstimateDetails((show) => !show); }} onKeyDown={() => { if (isQuoteDetailRelevant) setShowEstimateDetails((show) => !show); }}>

Line range hint 977-978: Remove redundant Boolean call for cleaner code.

- (account?.walletStatus === WalletStatus.Connected && (swapState.inAmountInput.isEmpty || !Boolean(swapState.quote) || isSwapToolLoading || Boolean(swapState.error) || Boolean(swapState.networkFeeError)))
+ (account?.walletStatus === WalletStatus.Connected && (swapState.inAmountInput.isEmpty || !swapState.quote || isSwapToolLoading || swapState.error || swapState.networkFeeError))

Line range hint 387-387: Specify the type attribute for buttons to prevent unintended form submissions.

- <button onClick={() => { ... }}>
+ <button type="button" onClick={() => { ... }}>

- <button onClick={() => { ... }}>
+ <button type="button" onClick={() => { ... }}>

- <button onClick={() => { ... }}>
+ <button type="button" onClick={() => { ... }}>

Also applies to: 596-617, 759-771

packages/web/hooks/use-swap.tsx (3)

Line range hint 200-200: Remove redundant Boolean calls.

-    Boolean(quote?.amount.toDec().isPositive()) &&
+    quote?.amount.toDec().isPositive() &&
-    Boolean(quoteForCurrentBalance) &&
+    quoteForCurrentBalance &&

The Boolean function is redundant here as the values are already being coerced to boolean in the conditional expressions.

Also applies to: 519-519


Line range hint 123-123: Consider refactoring useSwap for improved readability and maintainability.

The useSwap hook handles multiple responsibilities. Consider breaking it down into smaller hooks or functions to improve readability and maintainability. This could also make unit testing easier.


Line range hint 123-123: Improve error handling in useQueryRouterBestQuote.

Consider enhancing the error handling in useQueryRouterBestQuote to provide more descriptive and user-friendly error messages. This could improve the user experience by making the errors more understandable.

packages/stores/src/account/base.ts (1)

Line range hint 1208-1208: Remove the redundant catch clause.

- catch (error: any) {
-   throw error;
- }

This catch clause is redundant as it only rethrows the caught error without any modification or additional handling. Removing it simplifies the code and reduces unnecessary complexity.

@JoseRFelix JoseRFelix merged commit b4efdce into stage Jun 8, 2024
27 of 28 checks passed
@JoseRFelix JoseRFelix deleted the jose/test-one-click-trading branch June 8, 2024 06:08
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