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

Adding tokens from karura, moonriver and shiden to tinkernet rings #144

Merged
merged 11 commits into from
Mar 15, 2024
59 changes: 59 additions & 0 deletions tinkernet/runtime/src/rings/karura.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use super::RingsChain;
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::BoundedSlice;
use scale_info::TypeInfo;
use xcm::latest::{Junction, Junctions, MultiLocation};

pub struct Karura;

#[allow(non_camel_case_types)]
#[derive(Encode, Decode, Clone, Eq, PartialEq, MaxEncodedLen, Debug, TypeInfo)]
pub enum KaruraAssets {
KAR,
LKSM,
tKSM,
KSM,
}

impl RingsChain for Karura {
type Assets = KaruraAssets;

fn get_asset_location(asset: &Self::Assets) -> MultiLocation {
use KaruraAssets::*;
match asset {
KAR => MultiLocation {
parents: 0,
interior: Junctions::X1(Junction::from(BoundedSlice::truncate_from(&[
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,
]))),
},
LKSM => MultiLocation {
parents: 0,
interior: Junctions::X1(Junction::from(BoundedSlice::truncate_from(&[
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131,
]))),
},
tKSM => MultiLocation {
parents: 0,
interior: Junctions::X1(Junction::from(BoundedSlice::truncate_from(&[
0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 130, 0, 0, 0, 0, 131,
]))),
},
KSM => MultiLocation {
parents: 1,
interior: Junctions::Here,
},
}
}

fn get_location() -> MultiLocation {
MultiLocation {
parents: 1,
interior: Junctions::X1(Junction::Parachain(2000)),
}
}

fn get_main_asset() -> Self::Assets {
KaruraAssets::KAR
}
}
24 changes: 24 additions & 0 deletions tinkernet/runtime/src/rings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ mod picasso;
use picasso::Picasso;
mod asset_hub;
use asset_hub::AssetHub;
mod shiden;
use shiden::Shiden;
mod karura;
use karura::Karura;
mod moonriver;
use moonriver::Moonriver;

parameter_types! {
pub MaxXCMCallLength: u32 = 100_000;
Expand All @@ -38,13 +44,19 @@ pub enum Chains {
Basilisk,
Picasso,
AssetHub,
Shiden,
Karura,
Moonriver,
}

#[derive(Encode, Decode, Clone, Eq, PartialEq, MaxEncodedLen, Debug, TypeInfo)]
pub enum ChainAssets {
Basilisk(<Basilisk as RingsChain>::Assets),
Picasso(<Picasso as RingsChain>::Assets),
AssetHub(<AssetHub as RingsChain>::Assets),
Shiden(<Shiden as RingsChain>::Assets),
Karura(<Karura as RingsChain>::Assets),
Moonriver(<Moonriver as RingsChain>::Assets),
}

impl ChainAssetsList for ChainAssets {
Expand All @@ -55,6 +67,9 @@ impl ChainAssetsList for ChainAssets {
Self::Basilisk(_) => Chains::Basilisk,
Self::Picasso(_) => Chains::Picasso,
Self::AssetHub(_) => Chains::AssetHub,
Self::Shiden(_) => Chains::Shiden,
Self::Karura(_) => Chains::Karura,
Self::Moonriver(_) => Chains::Moonriver,
}
}

Expand All @@ -63,6 +78,9 @@ impl ChainAssetsList for ChainAssets {
Self::Basilisk(asset) => Basilisk::get_asset_location(asset),
Self::Picasso(asset) => Picasso::get_asset_location(asset),
Self::AssetHub(asset) => AssetHub::get_asset_location(asset),
Self::Shiden(asset) => Shiden::get_asset_location(asset),
Self::Karura(asset) => Karura::get_asset_location(asset),
Self::Moonriver(asset) => Moonriver::get_asset_location(asset),
}
}
}
Expand All @@ -76,6 +94,9 @@ impl ChainList for Chains {
Self::Basilisk => Basilisk::get_location(),
Self::Picasso => Picasso::get_location(),
Self::AssetHub => AssetHub::get_location(),
Self::Shiden => Shiden::get_location(),
Self::Karura => Karura::get_location(),
Self::Moonriver => Moonriver::get_location(),
}
}

Expand All @@ -84,6 +105,9 @@ impl ChainList for Chains {
Self::Basilisk => ChainAssets::Basilisk(Basilisk::get_main_asset()),
Self::Picasso => ChainAssets::Picasso(Picasso::get_main_asset()),
Self::AssetHub => ChainAssets::AssetHub(AssetHub::get_main_asset()),
Self::Shiden => ChainAssets::Shiden(Shiden::get_main_asset()),
Self::Karura => ChainAssets::Karura(Karura::get_main_asset()),
Self::Moonriver => ChainAssets::Moonriver(Moonriver::get_main_asset()),
}
}

Expand Down
22 changes: 22 additions & 0 deletions tinkernet/runtime/src/rings/moonriver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ use xcm::latest::{Junction, Junctions, MultiLocation};

pub struct Moonriver;

#[allow(non_camel_case_types)]
#[derive(Encode, Decode, Clone, Eq, PartialEq, MaxEncodedLen, Debug, TypeInfo)]
pub enum MoonriverAssets {
MOVR,
xcKSM,
xcTNKR,
Erc20([u8; 20]),
arrudagates marked this conversation as resolved.
Show resolved Hide resolved
}

impl RingsChain for Moonriver {
Expand All @@ -20,6 +24,24 @@ impl RingsChain for Moonriver {
parents: 0,
interior: Junctions::X1(Junction::PalletInstance(3)),
},
xcKSM => MultiLocation {
parents: 1,
interior: Junctions::Here,
},
xcTNKR => MultiLocation {
parents: 0,
arrudagates marked this conversation as resolved.
Show resolved Hide resolved
interior: Junctions::X2(Junction::Parachain(2125), Junction::GeneralIndex(0)),
},
Erc20(erc_20) => MultiLocation {
parents: 0,
interior: Junctions::X2(
Junction::PalletInstance(48),
Junction::AccountKey20 {
network: None,
key: *erc_20,
arrudagates marked this conversation as resolved.
Show resolved Hide resolved
},
),
},
}
}

Expand Down
5 changes: 5 additions & 0 deletions tinkernet/runtime/src/rings/shiden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub struct Shiden;
#[derive(Encode, Decode, Clone, Eq, PartialEq, MaxEncodedLen, Debug, TypeInfo)]
pub enum ShidenAssets {
SDN,
KSM,
}

impl RingsChain for Shiden {
Expand All @@ -20,6 +21,10 @@ impl RingsChain for Shiden {
parents: 0,
interior: Junctions::Here,
},
KSM => MultiLocation {
parents: 1,
interior: Junctions::Here,
},
}
}

Expand Down
Loading