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

Bifrost XCM Integration #248

Merged
merged 6 commits into from
May 20, 2024
Merged

Bifrost XCM Integration #248

merged 6 commits into from
May 20, 2024

Conversation

ap211unitech
Copy link
Member

@ap211unitech ap211unitech commented May 20, 2024

Description

As of now, We have Polkadot, AssetHub and some more chains in THEA. We can make deposits and withdrawls between these chains and Polkadex Network. Now, our next target is to add Bifrost Network in frontend so that more users can bring thier BNC and vDOT tokens in polkadex chain and trade in orderbook.

BNC - Subscan

vDOT - Subscan

✅ Tasks

  • Bifrost Network XCM Integration for BNC and vDOT token

🤔 Expected Behavior

  • New chains must be added to list that could be switched by users.
  • User must be able to make deposits & withdrawls from selected chain and Polkadex main network and vice-versa.
  • User must be able to see native balance (balance avaliable on Polkadex network), foreign chain balance (balance avaliable on selected foreign chain) for all supported assets.

Summary by CodeRabbit

  • New Features

    • Added support for Deposit/Withdrawal for THEA on the Bifrost chain.
    • Introduced asset configurations for BNC and vDOT tokens.
  • Improvements

    • Enhanced chain configuration to include Bifrost and Polkadex assets.
    • Updated asset transfer functionalities to support BNC and vDOT tokens.
  • Bug Fixes

    • Improved chain connector logic to handle Bifrost chain.
  • Refactor

    • Streamlined configuration files to better organize chain and asset details.
    • Simplified method for retrieving all chains by removing unnecessary inclusions.

Copy link

changeset-bot bot commented May 20, 2024

🦋 Changeset detected

Latest commit: 209e392

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

This PR includes changesets to release 2 packages
Name Type
@polkadex/polkadex-api Minor
@polkadex/thea Minor

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 May 20, 2024

Walkthrough

This update introduces support for Deposit/Withdrawal of BNC and vDOT tokens on the Bifrost chain within the Polkadex ecosystem. It includes adding new assets, updating configurations, and enhancing the SDK to handle the new chain and assets.

Changes

File Path Summary of Changes
.changeset/honest-teachers-shout.md Introduces support for Deposit/Withdrawal for THEA on the Bifrost chain, enabling transactions with BNC and vDOT tokens.
packages/polkadex-api/src/modules/constants.ts Added BNC and vDOT assets to the ASSETS array.
packages/thea/src/config/genesis.ts Added BIFROST_GENESIS constant.
packages/thea/src/config/substrate/assets.ts Added bnc and vdot to the list of exported entities and substrateAssets array.
packages/thea/src/config/substrate/builders/pallets/xTokens.ts Removed imports of getExtrinsicArgumentVersion and modified the getArgs function within the transfer constant.
packages/thea/src/config/substrate/chains.ts Added BIFROST_GENESIS, bifrost chain, and updated polkadex with bnc and vdot assets data.
packages/thea/src/config/substrate/config/bifrost.ts Introduced configurations for asset transfers between chains using Moonbeam Network's XCM framework for BNC and VDOT tokens.
packages/thea/src/config/substrate/config/index.ts Added bifrostConfig to imports and chainsConfig array.
packages/thea/src/config/substrate/config/polkadex.ts Added configurations for bifrost and vdot assets to polkadexConfig.
packages/thea/src/config/theaConfig.ts Modified getAllChains() to remove evmChains from the return statement.
packages/thea/src/sdk/helpers.ts Added support for BIFROST_GENESIS in getChainConnector function.
packages/thea/src/sdk/substrate/bifrost.ts Added Bifrost class with methods for handling chain adaptation, asset transfers, and balance retrieval.
packages/thea/src/sdk/substrate/index.ts Exported bifrost from the substrate module.

Possibly related issues

In fields of code where rabbits play,
New assets hop in bright array.
BNC and vDOT take the stage,
On Bifrost's chain, they now engage.
A dance of bytes, a transfer's cheer,
Polkadex grows, the path is clear. 🌟🐇


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 linked an issue May 20, 2024 that may be closed by this pull request
1 task
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: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between f02d972 and 209e392.
Files selected for processing (13)
  • .changeset/honest-teachers-shout.md (1 hunks)
  • packages/polkadex-api/src/modules/constants.ts (1 hunks)
  • packages/thea/src/config/genesis.ts (1 hunks)
  • packages/thea/src/config/substrate/assets.ts (2 hunks)
  • packages/thea/src/config/substrate/builders/pallets/xTokens.ts (2 hunks)
  • packages/thea/src/config/substrate/chains.ts (5 hunks)
  • packages/thea/src/config/substrate/config/bifrost.ts (1 hunks)
  • packages/thea/src/config/substrate/config/index.ts (2 hunks)
  • packages/thea/src/config/substrate/config/polkadex.ts (4 hunks)
  • packages/thea/src/config/theaConfig.ts (1 hunks)
  • packages/thea/src/sdk/helpers.ts (3 hunks)
  • packages/thea/src/sdk/substrate/bifrost.ts (1 hunks)
  • packages/thea/src/sdk/substrate/index.ts (1 hunks)
Files skipped from review due to trivial changes (4)
  • .changeset/honest-teachers-shout.md
  • packages/thea/src/config/genesis.ts
  • packages/thea/src/config/substrate/assets.ts
  • packages/thea/src/sdk/substrate/index.ts
Additional comments not posted (11)
packages/thea/src/config/theaConfig.ts (1)

11-11: LGTM! Ensure the exclusion of EVM chains is intentional as this change focuses on substrate chains.

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

11-11: LGTM! The addition of bifrostConfig aligns with the integration objectives.

Also applies to: 22-22

packages/thea/src/sdk/helpers.ts (1)

33-34: LGTM! The addition of the Bifrost case in getChainConnector aligns with the integration of the Bifrost chain.

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

42-45: LGTM! The bifrostConfig is well-defined and aligns with the integration requirements. Verify the correctness of asset IDs and decimal places.

packages/polkadex-api/src/modules/constants.ts (1)

81-94: LGTM! The addition of BNC and vDOT to the ASSETS array is correctly implemented. Verify the uniqueness and correctness of the asset IDs.

packages/thea/src/config/substrate/builders/pallets/xTokens.ts (1)

36-37: LGTM! The update to the getArgs function for X3 transfer type aligns with XCM Version 3 specifications. Verify compatibility with XCM Version 3.

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

185-206: LGTM! The addition of the Bifrost chain configuration is well-defined and aligns with the integration requirements. Verify the correctness of asset details and chain settings.

Verification successful

The verification process has confirmed the following details:

  • The bnc and vdot assets are defined in packages/thea/src/config/substrate/assets.ts.
  • The BIFROST_GENESIS value is correctly set to "0x262e1b2ad728475fd6fe88e62d34c200abe6fd693931ddad144059b1eb884e5b".
  • The parachainId, ss58Format, and ws settings for the Bifrost chain are correctly configured.

The addition of the Bifrost chain configuration is well-defined and aligns with the integration requirements.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness of asset details and chain settings for the Bifrost chain.

# Test: Check asset details and chain settings against a trusted source or documentation.
echo "Verify asset details and chain settings for the Bifrost chain."

Length of output: 134



Script:

#!/bin/bash
# Description: Verify the correctness of asset details and chain settings for the Bifrost chain.

# Search for the definition of bnc and vdot assets in the codebase.
echo "Searching for bnc asset definition..."
bnc_definition=$(rg -A 5 'const bnc' | head -n 10)
echo "$bnc_definition"

echo "Searching for vdot asset definition..."
vdot_definition=$(rg -A 5 'const vdot' | head -n 10)
echo "$vdot_definition"

# Search for the genesisHash, parachainId, ss58Format, and ws settings in the codebase.
echo "Searching for BIFROST_GENESIS definition..."
genesis_hash=$(rg 'const BIFROST_GENESIS' | head -n 1)
echo "$genesis_hash"

echo "Searching for parachainId, ss58Format, and ws settings..."
parachain_settings=$(rg -A 5 'parachainId: 2030' | head -n 10)
echo "$parachain_settings"

Length of output: 2077



Script:

#!/bin/bash
# Description: Verify the correctness of asset details and chain settings for the Bifrost chain.

# Search for the definition of bnc and vdot assets in the codebase more broadly.
echo "Searching for bnc asset definition..."
bnc_definition=$(rg 'bnc' | head -n 20)
echo "$bnc_definition"

echo "Searching for vdot asset definition..."
vdot_definition=$(rg 'vdot' | head -n 20)
echo "$vdot_definition"

# Verify the BIFROST_GENESIS value.
echo "Verifying BIFROST_GENESIS value..."
genesis_value=$(rg 'export const BIFROST_GENESIS' packages/thea/src/config/genesis.ts)
echo "$genesis_value"

# Verify the parachainId, ss58Format, and ws settings.
echo "Verifying parachainId, ss58Format, and ws settings..."
parachain_settings=$(rg -A 5 'parachainId: 2030' packages/thea/src/config/substrate/chains.ts)
echo "$parachain_settings"

Length of output: 7611



Script:

#!/bin/bash
# Description: Verify the correctness of asset details and chain settings for the Bifrost chain.

# Search for the definition of bnc and vdot assets in the assets.ts file.
echo "Searching for bnc asset definition in assets.ts..."
bnc_definition=$(rg 'bnc' packages/thea/src/config/substrate/assets.ts)
echo "$bnc_definition"

echo "Searching for vdot asset definition in assets.ts..."
vdot_definition=$(rg 'vdot' packages/thea/src/config/substrate/assets.ts)
echo "$vdot_definition"

# Verify the full BIFROST_GENESIS value.
echo "Verifying full BIFROST_GENESIS value..."
genesis_value=$(rg 'export const BIFROST_GENESIS' packages/thea/src/config/genesis.ts -A 1)
echo "$genesis_value"

Length of output: 1458

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

20-211: LGTM! The Bifrost class is well-implemented and aligns with the integration requirements. Verify the correctness of method implementations and data handling.

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

14-14: Import of bifrost is correctly added for use in asset configurations.


28-29: Import of bnc and vdot assets is correctly added for use in asset configurations.


324-324: Inclusion of toBifrost in polkadexConfig is correctly implemented, ensuring that the new assets are part of the overall chain configuration.

@nuel77 nuel77 merged commit 3c6fb4b into main May 20, 2024
2 checks passed
@nuel77 nuel77 deleted the feat/bifrost-integration branch May 20, 2024 08:54
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.

Bifrost XCM integration
3 participants