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

change(kreivo-runtime): trust reserves from DOT #363

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ benchmark pallet="" extrinsic="*":

build-container:
#!/usr/bin/env nu
'FROM docker.io/paritytech/ci-linux:production as builder
'FROM docker.io/paritytech/ci-unified:latest as builder
WORKDIR /virto
COPY . /virto
RUN cargo build --release

FROM debian:bookworm-slim
FROM debian:bullseye-slim
VOLUME /data
COPY --from=builder /virto/{{ node }} /usr/bin
ENTRYPOINT ["/usr/bin/virto-node"]
Expand Down
23 changes: 19 additions & 4 deletions runtime/kreivo/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ parameter_types! {
pub AssetsPalletLocation: Location =
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
pub UniversalLocation: InteriorLocation = [
GlobalConsensus(NetworkId::Polkadot),
GlobalConsensus(NetworkId::Kusama),
Parachain(ParachainInfo::parachain_id().into()),
].into();
Expand All @@ -68,7 +69,7 @@ pub type LocationToAccountId = (
pub type LocationConvertedConcreteId = xcm_builder::MatchedConvertedConcreteId<
FungibleAssetLocation,
Balance,
StartsWith<AssetHubLocation>,
(StartsWith<AssetHubLocation>, StartsWith<PolkadotLocation>),
AsFungibleAssetLocation,
JustTry,
>;
Expand Down Expand Up @@ -168,7 +169,8 @@ pub type Barrier = (
pub type AssetTransactors = (FungibleTransactor, FungiblesTransactor);

parameter_types! {
pub AssetHubLocation: Location = Location::new(1, [Junction::Parachain(ASSET_HUB_ID)]);
pub AssetHubLocation: Location = Location::new(1, [Parachain(ASSET_HUB_ID)]);
pub PolkadotLocation: Location = Location::new(2, [GlobalConsensus(NetworkId::Polkadot)]);
}

//- From PR https://github.com/paritytech/cumulus/pull/936
Expand All @@ -183,9 +185,18 @@ fn matches_prefix(prefix: &Location, loc: &Location) -> bool {
}
pub struct ReserveAssetsFrom<T>(PhantomData<T>);
impl<Prefix: Get<Location>> ContainsPair<Asset, Location> for ReserveAssetsFrom<Prefix> {
fn contains(asset: &Asset, _origin: &Location) -> bool {
log::trace!(target: "xcm::AssetsFrom", "prefix: {:?}, origin: {:?}", Prefix::get(), _origin);
matches_prefix(&Prefix::get(), &asset.id.0)
}
}
pub struct ReserveForeignAssetsFrom<P, R>(PhantomData<(P, R)>);
impl<Prefix: Get<Location>, ReserveLocation: Get<Location>> ContainsPair<Asset, Location>
for ReserveForeignAssetsFrom<Prefix, ReserveLocation>
{
fn contains(asset: &Asset, origin: &Location) -> bool {
log::trace!(target: "xcm::AssetsFrom", "prefix: {:?}, origin: {:?}", Prefix::get(), origin);
&Prefix::get() == origin && matches_prefix(&Prefix::get(), &asset.id.0)
&ReserveLocation::get() == origin && matches_prefix(&Prefix::get(), &asset.id.0)
}
}

Expand All @@ -208,7 +219,11 @@ pub type Traders = (
UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ResolveTo<TreasuryAccount, Balances>>,
);

pub type Reserves = (NativeAsset, ReserveAssetsFrom<AssetHubLocation>);
pub type Reserves = (
NativeAsset,
ReserveAssetsFrom<AssetHubLocation>,
ReserveForeignAssetsFrom<PolkadotLocation, AssetHubLocation>,
);

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
Expand Down