Polkadex-Substrate / Polkadex-Orderbook-Frontend

https://orderbook.polkadex.trade
3 stars 3 forks source link

Bridge Enhancements II #1312

Closed ap211unitech closed 3 months ago

ap211unitech commented 3 months ago

Description -

This PR aims to fix some more bugs mostly related to new Bridge page -

  1. Refetch transfer config if balance for selected asset is changed. Balance could change after occasional refetch (of 12s) or when a transfer happens.

  2. Remove this scroll area rather add a checkbox saying something like I agree to Terms & Conditions

    image



  3. Autoswap message:

    image

a. Do not make the user enter amount and click on bridge if they do not have enough PDEX in the destination address. Display the error message on the bridge page itself, not the pop-up. b. Show AutoSwap information by default

  1. Remove frozen balance from Free value for PDEX balance. (polkadex-ts)

  2. Check for Destination chain native balance on bridging token

https://github.com/Polkadex-Substrate/Polkadex-Orderbook-Frontend/assets/65214523/fca98683-d857-491b-bdf9-a5278097c14e

https://github.com/Polkadex-Substrate/Polkadex-Orderbook-Frontend/assets/65214523/053daec4-6b98-4c64-aeb3-1d8df1a9b6e7

Checklist

coderabbitai[bot] commented 3 months ago

[!IMPORTANT]

Review skipped

Review was skipped due to path filters

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`

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent changes enhance the Form and ConfirmTransaction components in the Hestia app by integrating the Polkadex asset selection and handling. This includes improved validation, error handling, and loading state management. Additionally, updates to hooks and constants ensure better balance calculations and error messages. The integration of terms and conditions with a checkbox also improves user interaction and validation.

Changes

File Path Change Summary
apps/hestia/src/components/thea/Form/index.tsx Added Polkadex asset selection, integrated useQueryPools, updated loading and validation logic.
apps/hestia/src/components/thea/confirmTransaction.tsx Updated asset handling, error conditions, and transaction display with parseScientific.
apps/hestia/src/components/ui/ConnectWallet/confirmTransaction.tsx Modified imports, added checkbox state management, adjusted disabled state calculation.
apps/hestia/src/components/ui/ReadyToUse/terms.tsx Enhanced Terms component with checkbox and link, updated props and rendering logic.
apps/hestia/src/hooks/useBridge.ts Added parameters for Polkadex handling, updated balance checks, and error messages.
packages/core/src/constants/index.ts Updated NOT_ENOUGH_LIQUIDITY error message in CrossChainError.
packages/core/src/helpers/fetchOnChainBalance.ts Changed balance calculation to subtract frozen from free balance.
packages/core/src/hooks/useTheaConfig.tsx Added refetchInterval property to useTheaConfig hook configuration.
packages/core/src/providers/user/thea/index.tsx Integrated selectedAssetIdPolkadex, added refetchTransferConfig to context provider.
packages/core/src/validations/index.ts Modified bridgeValidations function to include Polkadex-specific parameters and validation checks.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant FormComponent
    participant TheaProvider
    participant QueryPoolsHook
    participant ValidationSchema
    participant ConfirmTransactionComponent

    User->>FormComponent: Fill form and submit
    FormComponent->>TheaProvider: Get selectedAssetIdPolkadex, isDestinationPolkadex
    TheaProvider->>QueryPoolsHook: Fetch pools data
    QueryPoolsHook-->>FormComponent: Return pools, poolsLoading
    FormComponent->>ValidationSchema: Validate form data with pools and Polkadex info
    ValidationSchema-->>FormComponent: Return validation result
    FormComponent->>ConfirmTransactionComponent: Pass validated data
    ConfirmTransactionComponent->>TheaProvider: Get selectedAssetIdPolkadex
    ConfirmTransactionComponent->>parseScientific: Parse transaction amount
    parseScientific-->>ConfirmTransactionComponent: Return parsed amount
    ConfirmTransactionComponent->>User: Display transaction summary

Poem

In the code where assets flow, Polkadex now steals the show. With pools and terms, and checks so neat, Our Hestia app is quite the feat. Balances clear, errors refined, A smoother journey you will find. 🌟✨🐇


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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
netlify[bot] commented 3 months ago

Deploy Preview for stupendous-valkyrie-505e4a ready!

Name Link
Latest commit 84fa44fe252f45575f979324d7f2832719b71ac0
Latest deploy log https://app.netlify.com/sites/stupendous-valkyrie-505e4a/deploys/6659fbe45c1e0c00089cd4c7
Deploy Preview https://deploy-preview-1312--stupendous-valkyrie-505e4a.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

Lighthouse
1 paths audited
Performance: 24
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.