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

THEA Withdrawals #227

Merged
merged 13 commits into from
May 1, 2024
Merged

THEA Withdrawals #227

merged 13 commits into from
May 1, 2024

Conversation

ap211unitech
Copy link
Member

@ap211unitech ap211unitech commented Apr 30, 2024

Description

We have successfully added all the chains for cross chain transfer to Polkadex. In this task, we will be adding the withdraw logic for THEA so that user can withdraw thier assets from Polkadex network to other network.

  1. Polkadex to AssetHub - USDT, DED, PINK, USDC
  2. Polkadex to Astar - ASTR
  3. Polkadex to Moonbeam - GLMR
  4. Polkadex to Interlay - IBTC
  5. Polkadex to Unique - UNQ
  6. Polkadex to Polkadot - DOT
  7. Polkadex to Phala - PHA

Summary by CodeRabbit

  • New Features

    • Introduced the ability for users to withdraw assets from the Polkadex network to various other networks including AssetHub, Astar, Moonbeam, Interlay, Unique, Polkadot, and Phala.
    • Updated the asset and chain selection logic to enhance cross-chain transactions, including changing the default transaction asset and amounts.
  • Enhancements

    • Improved fee calculation and extrinsic methods for asset transfers, ensuring more accurate and efficient transaction processing across different blockchain networks.
  • Documentation

    • Updated internal documentation and configurations to align with the new cross-chain functionalities and fee structures.

Copy link

changeset-bot bot commented Apr 30, 2024

🦋 Changeset detected

Latest commit: a685cff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@polkadex/thea Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Apr 30, 2024

Walkthrough

This update enhances the Polkadex network by integrating withdrawal logic for THEA, allowing assets to be transferred across various blockchain networks like AssetHub, Astar, and Moonbeam. It includes updates to chain names, selected assets, and transaction amounts, along with the addition of new utility functions and configuration adjustments for handling these cross-chain transfers.

Changes

File Path Change Summary
.changeset/itchy-panthers-fly.md Introduces withdrawal logic for THEA in Polkadex.
apps/cross-chain/.../polkadotEco.tsx Updates chain and asset names, increases transaction amount.
packages/thea/src/.../builders/ExtrinsicBuilder.ts Adds theaExecuter module import and usage in ExtrinsicBuilderV2.
packages/thea/src/.../builders/pallets/theaExecuter.ts Adds functionality for building extrinsic configurations for theaExecutor pallet.
packages/thea/src/.../builders/pallets/theaExecuter.utils.ts Introduces utility function for generating beneficiary objects.
packages/thea/src/.../config/polkadex.ts Updates imports, fee amounts, and extrinsic methods for various assets.
packages/thea/src/sdk/substrate/polkadex.ts Enhances transfer configuration logic and handling in the Polkadex class.

Possibly related issues

🐰✨
Hop, hop, hooray! In the world of code,
Cross-chain magic, now on the road.
From Polkadex to Moonbeam's glow,
Assets fly where the blockchains flow.
Cheers to the devs, with each commit,
The blockchain rabbit does a little hop and sit!
🌟🚀


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 6aa9fbd and a685cff.
Files selected for processing (7)
  • .changeset/itchy-panthers-fly.md (1 hunks)
  • apps/cross-chain/app/components/polkadotEco.tsx (1 hunks)
  • packages/thea/src/config/substrate/builders/ExtrinsicBuilder.ts (1 hunks)
  • packages/thea/src/config/substrate/builders/pallets/theaExecuter.ts (1 hunks)
  • packages/thea/src/config/substrate/builders/pallets/theaExecuter.utils.ts (1 hunks)
  • packages/thea/src/config/substrate/config/polkadex.ts (10 hunks)
  • packages/thea/src/sdk/substrate/polkadex.ts (4 hunks)
Files skipped from review due to trivial changes (1)
  • packages/thea/src/config/substrate/builders/ExtrinsicBuilder.ts
Additional Context Used
LanguageTool (22)
.changeset/itchy-panthers-fly.md (22)

Near line 5: Possible spelling mistake found.
Context: ... the chains for cross chain transfer to Polkadex. In this task, we will be adding the wi...


Near line 5: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ...ex. In this task, we will be adding the withdraw logic for THEA so that user can withdra...


Near line 5: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...ing the withdraw logic for THEA so that user can withdraw thier assets from Polkadex...


Near line 5: Possible spelling mistake found.
Context: ...ogic for THEA so that user can withdraw thier assets from Polkadex network to other n...


Near line 5: Possible spelling mistake found.
Context: ...hat user can withdraw thier assets from Polkadex network to other network. 1. Polkadex ...


Near line 5: Use the plural noun, or add a word such as ‘the’ or ‘some’ in front of ‘other’.
Context: ...w thier assets from Polkadex network to other network. 1. Polkadex to AssetHub - USDT, DED, ...


Near line 7: Possible spelling mistake found.
Context: ... Polkadex network to other network. 1. Polkadex to AssetHub - USDT, DED, PINK, USDC 2. ...


Near line 7: Possible spelling mistake found.
Context: ...twork to other network. 1. Polkadex to AssetHub - USDT, DED, PINK, USDC 2. Polkadex to ...


Near line 7: Possible spelling mistake found.
Context: ...twork. 1. Polkadex to AssetHub - USDT, DED, PINK, USDC 2. Polkadex to Astar - ASTR...


Near line 7: Possible spelling mistake found.
Context: ...Polkadex to AssetHub - USDT, DED, PINK, USDC 2. Polkadex to Astar - ASTR 3. Polkadex...


Near line 8: Possible spelling mistake found.
Context: ... to AssetHub - USDT, DED, PINK, USDC 2. Polkadex to Astar - ASTR 3. Polkadex to Moonbeam...


Near line 8: Possible spelling mistake found.
Context: ... - USDT, DED, PINK, USDC 2. Polkadex to Astar - ASTR 3. Polkadex to Moonbeam - GLMR 4...


Near line 8: Possible spelling mistake found.
Context: ... DED, PINK, USDC 2. Polkadex to Astar - ASTR 3. Polkadex to Moonbeam - GLMR 4. Polka...


Near line 9: Possible spelling mistake found.
Context: ...NK, USDC 2. Polkadex to Astar - ASTR 3. Polkadex to Moonbeam - GLMR 4. Polkadex to Inter...


Near line 10: Possible spelling mistake found.
Context: ... ASTR 3. Polkadex to Moonbeam - GLMR 4. Polkadex to Interlay - IBTC 5. Polkadex to Uniqu...


Near line 10: Possible spelling mistake found.
Context: ...onbeam - GLMR 4. Polkadex to Interlay - IBTC 5. Polkadex to Unique - UNQ 6. Polkadex...


Near line 11: Possible spelling mistake found.
Context: ... GLMR 4. Polkadex to Interlay - IBTC 5. Polkadex to Unique - UNQ 6. Polkadex to Polkadot...


Near line 11: Possible spelling mistake found.
Context: ...Interlay - IBTC 5. Polkadex to Unique - UNQ 6. Polkadex to Polkadot - DOT 7. Polkad...


Near line 12: Possible spelling mistake found.
Context: ...y - IBTC 5. Polkadex to Unique - UNQ 6. Polkadex to Polkadot - DOT 7. Polkadex to Phala ...


Near line 12: Possible spelling mistake found.
Context: ...Polkadex to Unique - UNQ 6. Polkadex to Polkadot - DOT 7. Polkadex to Phala - PHA


Near line 13: Possible spelling mistake found.
Context: ... - UNQ 6. Polkadex to Polkadot - DOT 7. Polkadex to Phala - PHA


Near line 13: Possible spelling mistake found.
Context: ...lkadex to Polkadot - DOT 7. Polkadex to Phala - PHA

Additional comments not posted (3)
packages/thea/src/config/substrate/builders/pallets/theaExecuter.ts (1)

13-67: Validate the use of boolean literals in function arguments.

Please verify that the use of true and false directly in the function arguments is intentional and correctly implements the desired logic.

apps/cross-chain/app/components/polkadotEco.tsx (1)

7-13: Confirm the correctness of constants and their impact on functionality.

Please ensure that the constants SOURCE_CHAIN, DESTINATION_CHAIN, SELECTED_ASSET, and amount are correctly used and reflect the intended functionality.

Verification successful

The verification process has successfully identified the usage of the constants SOURCE_CHAIN, DESTINATION_CHAIN, SELECTED_ASSET, and amount within the PolkadotEco component. Each constant is utilized in a manner that appears to align with their intended functionality:

  • SOURCE_CHAIN and DESTINATION_CHAIN are used to find specific chain configurations and are involved in error handling if the chains are not found. They are also used in a string that likely represents a log or display message indicating a transfer between these chains.
  • SELECTED_ASSET is used to find a specific asset, presumably to handle transactions involving this asset.
  • amount is used in a function call that seems to be related to transferring assets, and it is also part of the transfer message string.

Based on this information, it can be concluded that the constants are correctly used and reflect the intended functionality within the PolkadotEco component.

Conclusion:

  • The constants SOURCE_CHAIN, DESTINATION_CHAIN, SELECTED_ASSET, and amount are utilized appropriately throughout the PolkadotEco component.
  • The usage of these constants supports their roles in facilitating asset transfers between chains, which is consistent with the component's functionality.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the constants `SOURCE_CHAIN`, `DESTINATION_CHAIN`, `SELECTED_ASSET`, and `amount` are correctly used throughout the component.

# Search for the usage of these constants in the `PolkadotEco` component.
rg --files-with-matches --type tsx $'const SOURCE_CHAIN = "Polkadex";\nconst DESTINATION_CHAIN = "AssetHub";\nconst SELECTED_ASSET = "USDT";\nconst amount = 0.1;' "apps/cross-chain/app/components/polkadotEco.tsx"

Length of output: 400



Script:

#!/bin/bash
# Description: Verify that the constants `SOURCE_CHAIN`, `DESTINATION_CHAIN`, `SELECTED_ASSET`, and `amount` are correctly used throughout the component.

# Search for the usage of these constants in the `PolkadotEco` component using multiline mode.
rg -U 'const SOURCE_CHAIN = "Polkadex";\nconst DESTINATION_CHAIN = "AssetHub";\nconst SELECTED_ASSET = "USDT";\nconst amount = 0.1;' "apps/cross-chain/app/components/polkadotEco.tsx"

Length of output: 182



Script:

#!/bin/bash
# Description: Verify the usage of each constant individually in the `PolkadotEco` component.

# Search for the usage of `SOURCE_CHAIN` constant.
echo "Searching for SOURCE_CHAIN usage:"
rg 'SOURCE_CHAIN' "apps/cross-chain/app/components/polkadotEco.tsx"

# Search for the usage of `DESTINATION_CHAIN` constant.
echo "Searching for DESTINATION_CHAIN usage:"
rg 'DESTINATION_CHAIN' "apps/cross-chain/app/components/polkadotEco.tsx"

# Search for the usage of `SELECTED_ASSET` constant.
echo "Searching for SELECTED_ASSET usage:"
rg 'SELECTED_ASSET' "apps/cross-chain/app/components/polkadotEco.tsx"

# Search for the usage of `amount` constant.
echo "Searching for amount usage:"
rg 'amount' "apps/cross-chain/app/components/polkadotEco.tsx"

Length of output: 1413

packages/thea/src/sdk/substrate/polkadex.ts (1)

63-183: Ensure robust error handling and validate the use of external APIs.

Please ensure that error handling is robust and that external APIs are used correctly to prevent potential issues.

Verification successful

The verification process has successfully identified the use of error handling and external API calls within the getTransferConfig method of the Polkadex class. The method includes a throw new Error statement for handling invalid inputs, and it utilizes an await expression for asynchronous API calls, specifically when calling this.sdk.getTransferData.

This confirms that the method has robust error handling for invalid parameters and correctly uses asynchronous calls to external APIs, which are crucial for the functionality of transferring assets across chains.

Conclusion:

  • The error handling within the getTransferConfig method is robust, as it properly throws an error for invalid destination chains or assets.
  • The method correctly uses external APIs asynchronously, ensuring that the data needed for the transfer configuration is fetched properly.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the robustness of error handling in the `getTransferConfig` method and the correct use of external APIs.

# Search for the usage of external APIs and error handling patterns in the `getTransferConfig` method.
ast-grep --lang javascript --pattern $'getTransferConfig($_, $_, $_, $_) {
  $$$
  throw new Error($_),
  $$$
}' "packages/thea/src/sdk/substrate/polkadex.ts"

Length of output: 652



Script:

#!/bin/bash
# Description: Verify the robustness of error handling in the `getTransferConfig` method and the correct use of external APIs.

# Corrected search for the usage of external APIs and error handling patterns in the `getTransferConfig` method.
ast-grep --lang javascript --pattern $'method_definition[name="getTransferConfig"] {
  $$$
  throw_statement,
  $$$
}' "packages/thea/src/sdk/substrate/polkadex.ts"

Length of output: 664



Script:

#!/bin/bash
# Description: Attempt a simpler verification of error handling and API usage in the `getTransferConfig` method using grep.

# Use grep to search for 'throw new Error' and external API calls in the `getTransferConfig` method.
grep -A 30 -B 30 "getTransferConfig" "packages/thea/src/sdk/substrate/polkadex.ts" | grep -E "throw new Error|await"

Length of output: 235


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@ap211unitech ap211unitech self-assigned this Apr 30, 2024
@ap211unitech ap211unitech linked an issue Apr 30, 2024 that may be closed by this pull request
Base automatically changed from feat/integrate-remaining-chains to main April 30, 2024 12:40
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

Out of diff range and nitpick comments (2)
.changeset/itchy-panthers-fly.md (1)

13-13: Ensure the file ends with a newline character.

Please add a newline character at the end of the file to adhere to common coding standards.

packages/thea/src/config/substrate/config/polkadex.ts (1)

Line range hint 30-262: Review and finalize the TODO comments regarding fee amounts.

- amount: 0, // TODO: Change it later
+ amount: <appropriate_fee_amount>, // Replace <appropriate_fee_amount> with the actual fee amount after finalizing.

Please review and finalize the fee amounts mentioned in the TODO comments to ensure they are set appropriately before deployment.

@nuel77 nuel77 merged commit 6c4850d into main May 1, 2024
2 checks passed
@nuel77 nuel77 deleted the feat/thea-withdrawals branch May 1, 2024 09:28
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.

THEA withdrawal
2 participants