-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from InvArch/francisco-docs_rings
Rings documentation
- Loading branch information
Showing
3 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Rings Pallet | ||
|
||
## Overview | ||
|
||
The Rings pallet provides a cross-consensus message (XCM) abstraction layer for INV4 Cores, enabling them to manage assets effortlessly across multiple chains. It abstracts XCM complexities, facilitating easier handling of cross-chain transactions. | ||
|
||
## Key Features | ||
|
||
- **Maintenance Mode**: Chains can be put under maintenance, restricting certain operations to ensure system integrity during upgrades or when issues are detected. | ||
- **Cross-chain Calls**: Enables sending XCM calls to other chains, allowing for a wide range of interactions. | ||
- **Asset Transfers**: Supports transferring fungible assets between accounts across different chains. | ||
- **Asset Bridging**: Facilitates the bridging of assets between chains, enhancing liquidity and asset interoperability. | ||
|
||
## Traits Overview | ||
|
||
The pallet utilizes traits to abstract chain and asset locations: | ||
|
||
- [`ChainList`]: Provides an interface for referencing chains and retrieving their [`MultiLocation`] or main asset. | ||
- [`ChainAssetsList`]: Offers an interface for referencing chain assets and obtaining their [`MultiLocation`] or parent chain. | ||
|
||
## Dispatchable Functions | ||
|
||
### `set_maintenance_status` | ||
|
||
Sets the maintenance status of a chain. Requires `MaintenanceOrigin` authorization. | ||
|
||
- `chain`: The chain to modify. | ||
- `under_maintenance`: The desired maintenance status. | ||
|
||
### `send_call` | ||
|
||
Allows sending a XCM call to another chain. Can be initiated by a core. | ||
|
||
- `destination`: The target chain. | ||
- `weight`: The call's weight. | ||
- `fee_asset`: The asset used for fee payment. | ||
- `fee`: The fee amount. | ||
- `call`: The call data. | ||
|
||
### `transfer_assets` | ||
|
||
Allows transfers of fungible assets to another account in the destination chain. | ||
**Requires asset and fee_asset to be located in the same chain**. | ||
|
||
- `asset`: The asset to transfer. | ||
- `amount`: The amount to transfer. | ||
- `to`: The recipient account. | ||
- `fee_asset`: The asset used for fee payment. | ||
- `fee`: The fee amount. | ||
|
||
### `bridge_assets` | ||
|
||
Allows bridging of assets to another chain, with either the core account or a third-party account as the beneficiary. | ||
|
||
- `asset`: The asset to bridge and it's origin chain. | ||
- `destination`: The destination chain. | ||
- `fee`: The bridging fee. | ||
- `amount`: The amount to bridge. | ||
- `to`: Optional beneficiary account on the destination chain. (Defaults to the core account) | ||
|
||
## Events | ||
|
||
- `CallSent`: Emitted when a XCM call is sent to another chain. | ||
- `AssetsTransferred`: Emitted when assets are transferred to another account on a different chain. | ||
- `AssetsBridged`: Emitted when assets are bridged to another chain. | ||
- `ChainMaintenanceStatusChanged`: Indicates a change in a chain's maintenance status. | ||
|
||
## Errors | ||
|
||
- `SendingFailed`: Emitted when sending a XCM message fails. | ||
- `WeightTooHigh`: Emitted when the call's weight exceeds the maximum allowed. | ||
- `FailedToCalculateXcmFee`: Emitted when calculating the XCM fee fails. | ||
- `FailedToReanchorAsset`, `FailedToInvertLocation`: Errors related to asset reanchoring or location inversion. | ||
- `DifferentChains`, `ChainUnderMaintenance`: Indicate issues with the target chain or maintenance status. | ||
|
||
This pallet serves as a foundational component for building cross-chain solutions within the InvArch ecosystem, streamlining asset management and interoperability across diverse blockchain environments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,51 @@ | ||
//! Provides supporting traits for the rings pallet. | ||
//! | ||
//! ## Overview | ||
//! | ||
//! This module contains the traits responsible for creating an abstraction layer on top of XCM [`MultiLocation`] and allows | ||
//! easier handling of cross-chain transactions through XCM. | ||
//! | ||
//! The traits contained in this pallet require an appropriate runtime implementation. | ||
//! | ||
//! ## Traits overview: | ||
//! | ||
//! - [`ChainList`] - Trait used to opaquely refer to a chain, provides an interface to get the chain `MultiLocation` or the chain's main asset as `ChainAssetsList`. | ||
//! - [`ChainAssetsList`] - Trait used to opaquely refer to a chain's asset, provides an interface to get the chain asset `MultiLocation` or the chain as `ChainList`. | ||
|
||
use codec::MaxEncodedLen; | ||
use frame_support::Parameter; | ||
use xcm::latest::MultiLocation; | ||
|
||
/// A chain [`MultiLocation`] abstraction trait. | ||
/// | ||
/// It provides an interface for easily getting a chain's [`MultiLocation`] and to go back and forth between the chain and its assets. | ||
/// | ||
/// This should be implemented properly in the runtime. | ||
pub trait ChainList: Parameter + MaxEncodedLen { | ||
type Balance: Into<u128>; | ||
type ChainAssets: ChainAssetsList; | ||
|
||
/// Returns the chain's [`MultiLocation`]. | ||
fn get_location(&self) -> MultiLocation; | ||
|
||
/// Returns the chain's main asset as `ChainAssetsList`. | ||
fn get_main_asset(&self) -> Self::ChainAssets; | ||
|
||
#[cfg(feature = "runtime-benchmarks")] | ||
fn benchmark_mock() -> Self; | ||
} | ||
|
||
/// A chain asset [`MultiLocation`] abstraction trait. | ||
/// | ||
/// It provides an interface for easily getting a chain's asset [`MultiLocation`] and to go back and forth between the asset and its parent chain. | ||
/// | ||
/// This should be implemented properly in the runtime. | ||
pub trait ChainAssetsList: Parameter + MaxEncodedLen { | ||
type Chains: ChainList; | ||
|
||
/// Returns the asset's parent chain. | ||
fn get_chain(&self) -> Self::Chains; | ||
|
||
/// Returns the asset's [`MultiLocation`]. | ||
fn get_asset_location(&self) -> MultiLocation; | ||
} |