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

Order History Amount Fix and THEA package upgrade #1325

Merged
merged 6 commits into from
Jun 13, 2024

Conversation

ap211unitech
Copy link
Member

Description

This PR includes -

  1. Fix Amount ticker in Order history tables
  2. Upgrade THEA packages so that criss-cross transfers are allowed from UI

Checklist

  • Included link to corresponding Polkadex Orderbook Frontend Issue.
  • I have tested these changes thoroughly.
  • I have requested a review from at least one other contributor.

@ap211unitech ap211unitech self-assigned this Jun 12, 2024
Copy link

coderabbitai bot commented Jun 12, 2024

Walkthrough

The recent changes in the hestia app streamline numerical parsing and balance matching logic across various components. Key updates include improved scientific number formatting in columns for order history and transactions, and refined balance matching using strict equality for tickers in asset selection. Additionally, minor clean-ups, such as the removal of commented-out code, ensure a neater codebase.

Changes

File Path Change Summary
...he/assets/selectAsset.tsx Adjusted find method logic for ticker matching from includes to ===.
...rading/Orders/OrderHistory/columns.tsx Introduced parseScientific function to parse numerical values and updated rendering logic for columns.
...s/transactions/OrderHistory/columns.tsx Implemented parseScientific for parsing numerical values in order history columns.
...mponents/thea/Form/index.tsx Removed commented-out <HoverInformation.Arrow /> element for cleaner code.

In realms of code, the numbers dance,
With scientific parsing, they now enhance.
An asset's tickers align precise,
Order history sparkles, clean and nice.
Hover no more, the arrows fly,
In the Hestia app, improvements sky-high.
🌟✨🐇


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

netlify bot commented Jun 12, 2024

Deploy Preview for stupendous-valkyrie-505e4a ready!

Name Link
🔨 Latest commit defcf9f
🔍 Latest deploy log https://app.netlify.com/sites/stupendous-valkyrie-505e4a/deploys/666ad8e1148c0e0008656d83
😎 Deploy Preview https://deploy-preview-1325--stupendous-valkyrie-505e4a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 23
Accessibility: 75
Best Practices: 92
SEO: 92
PWA: 70
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@ap211unitech ap211unitech linked an issue Jun 12, 2024 that may be closed by this pull request
Copy link

@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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c407253 and 2e020b2.

Files ignored due to path filters (3)
  • apps/hestia/package.json is excluded by !**/*.json
  • packages/core/package.json is excluded by !**/*.json
  • yarn.lock is excluded by !**/*.lock, !**/*.lock
Files selected for processing (4)
  • apps/hestia/src/components/thea/Form/index.tsx (1 hunks)
  • apps/hestia/src/components/thea/selectAsset.tsx (1 hunks)
  • apps/hestia/src/components/trading/Orders/OrderHistory/columns.tsx (4 hunks)
  • apps/hestia/src/components/transactions/OrderHistory/columns.tsx (4 hunks)
Files skipped from review due to trivial changes (1)
  • apps/hestia/src/components/thea/Form/index.tsx
Additional comments not posted (7)
apps/hestia/src/components/thea/selectAsset.tsx (1)

67-67: Ensure strict equality check aligns with business requirements.

Verification successful

The verification script results show that the codebase consistently uses strict equality checks (=== and !==) for comparing ticker values. This implies that the use of strict equality in the provided code snippet aligns with the existing codebase practices.

  • packages/core/src/providers/user/thea/index.tsx
  • apps/hestia/src/hooks/useTheaTransactions.ts
  • apps/hestia/src/hooks/useBridge.ts
  • apps/hestia/src/components/thea/selectAsset.tsx
  • apps/hestia/src/components/thea/Form/index.tsx
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if strict equality check for asset selection is intended.

# Test: Search for the previous loose equality check usage in the codebase to ensure consistency.
rg --type typescript $'x.ticker.includes(e.ticker)'

Length of output: 87



Script:

#!/bin/bash
# Description: Verify if strict equality check for asset selection is intended.

# Test: Search for the previous loose equality check usage in the codebase to ensure consistency.
rg --type ts $'x.ticker.includes(e.ticker)'

Length of output: 44



Script:

#!/bin/bash
# Description: Verify if strict equality check for asset selection is intended.

# Test: Search for any loose equality checks involving `ticker` in the codebase to ensure consistency.
rg --type ts '\.ticker\s*==\s*' 
rg --type ts '\.ticker\s*!=\s*' 

Length of output: 1172

apps/hestia/src/components/trading/Orders/OrderHistory/columns.tsx (3)

1-1: Ensure new import is used effectively across the module.


143-143: Check consistency in the use of parseScientific across similar fields.

Verification successful

The usage of parseScientific appears consistent across similar numerical fields in the file, as it is applied to quantity, filledQuantity, and fee.

  • quantity: {parseScientific((+quantity).toString())}{" "}
  • filledQuantity: {parseScientific((+e.getValue().filledQuantity).toString())}{" "}
  • fee: {parseScientific(e.getValue().fee.toString())} {ticker}
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure consistent use of `parseScientific` for similar numerical fields.

# Test: Search for usage of `parseScientific` in other numerical fields in the module.
rg --type typescript $'parseScientific' apps/hestia/src/components/trading/Orders/OrderHistory/columns.tsx

Length of output: 140



Script:

#!/bin/bash
# Description: Ensure consistent use of `parseScientific` for similar numerical fields.

# Test: Search for usage of `parseScientific` in other numerical fields in the module.
rg 'parseScientific' apps/hestia/src/components/trading/Orders/OrderHistory/columns.tsx

Length of output: 346


177-177: Validate the correctness of fee calculations.

Verification successful

The parseScientific function is implemented to handle scientific notation correctly and convert it to a standard string representation. This ensures that the fee values are processed accurately when passed to this function.

  • parseScientific is defined in packages/core/src/helpers/Utils.ts and is correctly imported and used in apps/hestia/src/components/trading/Orders/OrderHistory/columns.tsx.

Based on the gathered information, the fee calculations appear to be handled correctly within the context of the provided code.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Confirm that fee calculations are accurate and consistent.

# Test: Search for other instances where fee is calculated differently.
rg --type typescript $'fee' apps/hestia/src/components/trading/Orders/OrderHistory/columns.tsx

Length of output: 128



Script:

#!/bin/bash
# Description: Confirm that fee calculations are accurate and consistent.

# Test: Search for other instances where fee is calculated differently.
rg --type ts $'fee' apps/hestia/src/components/trading/Orders/OrderHistory/columns.tsx

Length of output: 284



Script:

#!/bin/bash
# Description: Locate the definition of the `Order` class or type and inspect the calculation or assignment of `fee`.

# Find the definition of the `Order` class or type.
rg 'type Order' --type ts

# Search for `fee` within the `Order` type definition to understand its calculation or assignment.
rg 'fee' --type ts

Length of output: 13557



Script:

#!/bin/bash
# Description: Locate the implementation of the `parseScientific` function and inspect its usage.

# Find the implementation of the `parseScientific` function.
rg 'function parseScientific' --type ts

# Search for any import statements for `parseScientific`.
rg 'parseScientific' --type ts

Length of output: 3112



Script:

#!/bin/bash
# Description: Extract the implementation of the `parseScientific` function from `packages/core/src/helpers/Utils.ts` and analyze it.

# Display the implementation of the `parseScientific` function.
rg 'export function parseScientific' --type ts --context 10 packages/core/src/helpers/Utils.ts

Length of output: 957

apps/hestia/src/components/transactions/OrderHistory/columns.tsx (3)

1-1: Good use of parseScientific to handle numerical data.


224-224: Check for potential precision issues in fee calculations.


157-162: Ensure numerical values are handled correctly in market buy conditions.

Verification successful

The search results indicate several instances where 'market' is used in conjunction with numerical values. These instances include handling of 'quantity', 'price', and 'ticker'. Based on the provided context, it appears that numerical values are handled consistently across different market conditions, including market buy conditions.

  • Line 157: const { side, type, quantity, market } = e.getValue();
  • Line 159: const isMarketBuy = type === "MARKET" && side === "Bid";
  • Line 161: return ( <Typography.Text size="xs"> {parseScientific((+quantity).toString())} {isMarketBuy ? market.quoteAsset.ticker : market.baseAsset.ticker}

These lines indicate that the handling of numerical values, particularly 'quantity', involves parsing scientific notation and converting it to a string, which is then used to determine the appropriate ticker based on the market condition.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the handling of numerical values in market buy conditions.

# Test: Check if the numerical handling differs in other market conditions.
rg --type typescript $'market buy' apps/hestia/src/components/transactions/OrderHistory/columns.tsx

Length of output: 135



Script:

#!/bin/bash
# Description: Verify the handling of numerical values in market buy conditions.

# Test: Check if the numerical handling differs in other market conditions.
rg --type ts 'market buy' apps/hestia/src/components/transactions/OrderHistory/columns.tsx

Length of output: 92



Script:

#!/bin/bash
# Description: Verify the handling of numerical values in market conditions.

# Test: Check if the numerical handling differs in various market conditions.
rg --type ts 'market' apps/hestia/src/components/transactions/OrderHistory/columns.tsx

Length of output: 635

@ap211unitech ap211unitech linked an issue Jun 13, 2024 that may be closed by this pull request
Copy link
Member

@minikas minikas left a comment

Choose a reason for hiding this comment

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

Screenshot 2024-06-13 at 19 58 35

@ap211unitech please hide the skeleton of available amount if the user hasn't connected their wallet

@ap211unitech
Copy link
Member Author

Screenshot 2024-06-13 at 19 58 35 @ap211unitech please hide the skeleton of available amount if the user hasn't connected their wallet

Fixed it.

Copy link
Member

@minikas minikas left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2e020b2 and defcf9f.

Files selected for processing (1)
  • apps/hestia/src/components/thea/Form/index.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/hestia/src/components/thea/Form/index.tsx

@minikas minikas merged commit b6019f7 into internal Jun 13, 2024
5 checks passed
@minikas minikas deleted the fix/order-history-and-thea-update branch June 13, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Available balance of DOT displayed incorrectly Order History Amount Fix and THEA package upgrade
3 participants