From 2ed4e954eb5840365c15d200d915205e71e93525 Mon Sep 17 00:00:00 2001 From: metricaez Date: Tue, 6 Feb 2024 14:41:37 -0300 Subject: [PATCH 1/2] feat: add bridged adapter --- runtime/trappist/Cargo.toml | 1 + runtime/trappist/src/xcm_config.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/runtime/trappist/Cargo.toml b/runtime/trappist/Cargo.toml index f8e3efb0..848ba265 100644 --- a/runtime/trappist/Cargo.toml +++ b/runtime/trappist/Cargo.toml @@ -107,6 +107,7 @@ pallet-tx-pause = { workspace = true } [features] default = ["std"] std = [ + "hex-literal", "parity-scale-codec/std", "serde", "scale-info/std", diff --git a/runtime/trappist/src/xcm_config.rs b/runtime/trappist/src/xcm_config.rs index 59c7506b..9a206a36 100644 --- a/runtime/trappist/src/xcm_config.rs +++ b/runtime/trappist/src/xcm_config.rs @@ -41,6 +41,7 @@ use xcm_builder::{ }; use xcm_executor::{traits::JustTry, XcmExecutor}; +use hex_literal::hex; use xcm_primitives::{AsAssetMultiLocation, ConvertedRegisteredAssetId, TrappistDropAssets}; use crate::{ @@ -62,6 +63,7 @@ parameter_types! { pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); pub SelfReserve: MultiLocation = MultiLocation::here(); + pub EthereumCurrencyLocation: MultiLocation = MultiLocation::new(2, X2(GlobalConsensus(Ethereum { chain_id: 11155111 }), AccountKey20{ network: None, key: hex!("c9F05326311bc2a55426761Bec20057685FB80f7") })); pub AssetsPalletLocation: MultiLocation = PalletInstance(::index() as u8).into(); // Be mindful with incoming teleports if you implement this @@ -113,6 +115,20 @@ pub type LocalAssetTransactor = CurrencyAdapter< (), >; +/// Means for transacting the native currency on this chain. +pub type BridgedLocalAssetTransactor = CurrencyAdapter< + // Use this currency: + Balances, + // Use this currency when it is a fungible asset matching the given location or name: + IsConcrete, + // Convert an XCM MultiLocation into a local account id: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We don't track any teleports. + (), +>; + /// Means for transacting assets besides the native currency on this chain. pub type LocalFungiblesTransactor = FungiblesAdapter< // Use this fungibles implementation: From 6af702e11bc3c6a7a3edacfc1f79008042757f8c Mon Sep 17 00:00:00 2001 From: metricaez Date: Wed, 7 Feb 2024 08:41:33 -0300 Subject: [PATCH 2/2] feat: add bridged currency transactor to asset transactors --- runtime/trappist/src/lib.rs | 6 +++--- runtime/trappist/src/xcm_config.rs | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/runtime/trappist/src/lib.rs b/runtime/trappist/src/lib.rs index 540770f4..9c7c2413 100644 --- a/runtime/trappist/src/lib.rs +++ b/runtime/trappist/src/lib.rs @@ -131,8 +131,8 @@ impl frame_support::traits::OnRuntimeUpgrade for FixStorageVersions { let mut writes = 0; - /// trappist-rococo runtime v.11000 has an incorrect on-chain storage version of 0 for the Uniques pallet - /// Set the Uniques pallet's storage version to 1 as expected. + // trappist-rococo runtime v.11000 has an incorrect on-chain storage version of 0 for the Uniques pallet + // Set the Uniques pallet's storage version to 1 as expected. if Uniques::on_chain_storage_version() == StorageVersion::new(0) { Uniques::current_storage_version().put::(); writes.saturating_inc(); @@ -142,7 +142,7 @@ impl frame_support::traits::OnRuntimeUpgrade for FixStorageVersions { } } -pub type Migrations = (FixStorageVersions); +pub type Migrations = FixStorageVersions; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< diff --git a/runtime/trappist/src/xcm_config.rs b/runtime/trappist/src/xcm_config.rs index 9a206a36..090da9a9 100644 --- a/runtime/trappist/src/xcm_config.rs +++ b/runtime/trappist/src/xcm_config.rs @@ -171,8 +171,12 @@ pub type ReservedFungiblesTransactor = FungiblesAdapter< >; /// Means for transacting assets on this chain. -pub type AssetTransactors = - (LocalAssetTransactor, ReservedFungiblesTransactor, LocalFungiblesTransactor); +pub type AssetTransactors = ( + LocalAssetTransactor, + BridgedLocalAssetTransactor, + ReservedFungiblesTransactor, + LocalFungiblesTransactor, +); /// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, /// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can