Skip to content

orml-xtokens #266

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

Closed
shaunxw opened this issue Aug 27, 2020 · 2 comments
Closed

orml-xtokens #266

shaunxw opened this issue Aug 27, 2020 · 2 comments
Assignees

Comments

@shaunxw
Copy link
Member

shaunxw commented Aug 27, 2020

Cross-chain token transfer support.

orml-xtokens assumes other parachains also use xtoken protocol, and their impl is trustworthy (or exactly orml-xtokens).

Chains using orml-xtokens might need to whitelist para_id's to ensure this.

Basic data structure

/// To identify different chain
enum ChainId {
    RelayChain,
    ParaChain(ParaId)
}

/// To identify currency type and it's 'owner' chain
struct XCurrencyId {
    /// The owner chain
    chain_id: ChainId, 
    currency_id: Vec<u8>, // more flexible compared to int
}

enum XCMPMessage {
    Transfer {
        currency_id: XCurrencyId,
        dest: AccountId,
        amount: Balance,
    }
}

Dispatchable calls

transfer

  • Prerequisite: must be aware of self para_id
  • do transfer
    • To relaychain
    • To parachain
      • Relaychain tokens.
      • Owned parachain tokens.
      • Non-owned known parachain tokens.
      • Non-owned unknown parachain tokens.

Message handling

Bookkeeping

  • Impl DownwardMessageHandler
  • Impl XCMPMessageHandler
@shaunxw shaunxw self-assigned this Aug 27, 2020
@shaunxw shaunxw mentioned this issue Sep 3, 2020
@xlc
Copy link
Member

xlc commented Sep 8, 2020

Also should refactor the current native relay balance conversion code to a more generic version that allow support precision conversion between other parachains.

Something like

trait BalanceConversion {
  fn convert(from: XCurrencyId, to: XCurrencyId, value: Balance) -> (Balance, Balance)   // (converted_value, pre_convert_dust_value)
}

@shaunxw
Copy link
Member Author

shaunxw commented Apr 7, 2021

Finished.

@shaunxw shaunxw closed this as completed Apr 7, 2021
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 a pull request may close this issue.

2 participants