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

[xcm] runtime api for LocationToAccount conversions #4857

Merged
merged 32 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
374e427
Initial implementation of `LocationToAccountApi` runtime API
bkontur Jun 21, 2024
87e231b
Add it to the AssetHubWestend
bkontur Jun 21, 2024
db24e91
Nits
bkontur Jun 24, 2024
5cdf57a
Use `xcm::VersionedLocation` instead of `xcm::latest::Location`
bkontur Jun 25, 2024
36eedd5
Added to the all testnets
bkontur Jun 25, 2024
c9684b3
Merge remote-tracking branch 'origin/master' into bko-xcm-runtime-api
bkontur Jun 25, 2024
eb547b3
Change to workspace deps
bkontur Jun 25, 2024
098d1fb
One more
bkontur Jun 25, 2024
5eff80c
taplo zepter
bkontur Jun 25, 2024
bd99b8d
clippy imports
bkontur Jun 25, 2024
0a7b5de
prdoc
bkontur Jun 25, 2024
208d24c
Again import
bkontur Jun 25, 2024
6d7b3fc
Fix umbrella
bkontur Jun 25, 2024
e4f5f0b
Umbrella?
bkontur Jun 25, 2024
de7147a
Merge branch 'master' into bko-xcm-runtime-api
bkontur Jun 25, 2024
e9da1da
Update polkadot/xcm/xcm-runtime-api/tests/conversions.rs
bkontur Jun 25, 2024
fe41925
Update polkadot/xcm/xcm-runtime-api/src/conversions.rs
bkontur Jun 25, 2024
b5d8faa
Merge branch 'master' into bko-xcm-runtime-api
bkontur Jun 25, 2024
7b83b94
Simplify XCM runtime API
bkontur Jun 25, 2024
6f3a41c
More cleaning
bkontur Jun 25, 2024
f695e7a
Import
bkontur Jun 25, 2024
ab63f0d
Merge `xcm-fee-payment-runtime-api` to `xcm-runtime-api`
bkontur Jun 26, 2024
d28ae13
Merge remote-tracking branch 'origin/master' into bko-xcm-runtime-api
bkontur Jun 26, 2024
e782950
prdoc
bkontur Jun 26, 2024
829060a
prdoc
bkontur Jun 26, 2024
f950a5a
Merge remote-tracking branch 'origin/master' into bko-xcm-runtime-api
bkontur Jun 26, 2024
4511ecd
Update cumulus/parachains/runtimes/collectives/collectives-westend/sr…
bkontur Jun 26, 2024
18a9918
Update prdoc/pr_4857.prdoc
bkontur Jun 26, 2024
1089020
Update polkadot/xcm/xcm-runtime-api/src/conversions.rs
bkontur Jun 26, 2024
e39e6e7
Reflect review comments
bkontur Jun 26, 2024
540433c
More review comments
bkontur Jun 26, 2024
6457a41
Merge remote-tracking branch 'origin/master' into bko-xcm-runtime-api
bkontur Jun 26, 2024
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
64 changes: 32 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ members = [
"polkadot/xcm/xcm-builder",
"polkadot/xcm/xcm-executor",
"polkadot/xcm/xcm-executor/integration-tests",
"polkadot/xcm/xcm-fee-payment-runtime-api",
"polkadot/xcm/xcm-runtime-apis",
"polkadot/xcm/xcm-simulator",
"polkadot/xcm/xcm-simulator/example",
"polkadot/xcm/xcm-simulator/fuzzer",
Expand Down Expand Up @@ -1337,8 +1337,8 @@ xcm-builder = { path = "polkadot/xcm/xcm-builder", default-features = false, pac
xcm-docs = { path = "polkadot/xcm/docs" }
xcm-emulator = { path = "cumulus/xcm/xcm-emulator", default-features = false }
xcm-executor = { path = "polkadot/xcm/xcm-executor", default-features = false, package = "staging-xcm-executor" }
xcm-fee-payment-runtime-api = { path = "polkadot/xcm/xcm-fee-payment-runtime-api", default-features = false }
xcm-procedural = { path = "polkadot/xcm/procedural", default-features = false }
xcm-runtime-apis = { path = "polkadot/xcm/xcm-runtime-apis", default-features = false }
xcm-simulator = { path = "polkadot/xcm/xcm-simulator", default-features = false }
zeroize = { version = "1.7.0", default-features = false }
zstd = { version = "0.12.4", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ polkadot-primitives = { workspace = true }
westend-runtime-constants = { workspace = true }
westend-runtime = { workspace = true }
xcm = { workspace = true }
xcm-fee-payment-runtime-api = { workspace = true }
xcm-runtime-apis = { workspace = true }

# Cumulus
parachains-common = { workspace = true, default-features = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ polkadot-runtime-common = { workspace = true, default-features = true }
xcm = { workspace = true }
xcm-executor = { workspace = true }
pallet-xcm = { workspace = true }
xcm-fee-payment-runtime-api = { workspace = true }
xcm-runtime-apis = { workspace = true }
westend-runtime = { workspace = true }

# Cumulus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use crate::imports::*;

use frame_system::RawOrigin;
use xcm_fee_payment_runtime_api::{
use xcm_runtime_apis::{
dry_run::runtime_decl_for_dry_run_api::DryRunApiV1,
fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-fee-payment-runtime-api = { workspace = true }
xcm-runtime-apis = { workspace = true }

# Cumulus
cumulus-pallet-aura-ext = { workspace = true }
Expand Down Expand Up @@ -139,7 +139,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm-fee-payment-runtime-api/runtime-benchmarks",
"xcm-runtime-apis/runtime-benchmarks",
]
try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
Expand Down Expand Up @@ -250,7 +250,7 @@ std = [
"testnet-parachains-constants/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm-fee-payment-runtime-api/std",
"xcm-runtime-apis/std",
"xcm/std",
]

Expand Down
22 changes: 17 additions & 5 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ use xcm::{
latest::prelude::{AssetId, BodyId},
VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
};
use xcm_fee_payment_runtime_api::{
use xcm_runtime_apis::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
fees::Error as XcmPaymentApiError,
};
Expand Down Expand Up @@ -1322,7 +1322,7 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::fees::XcmPaymentApi<Block> for Runtime {
impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
let acceptable_assets = vec![AssetId(xcm_config::TokenLocation::get())];
PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
Expand All @@ -1335,11 +1335,11 @@ impl_runtime_apis! {
Ok(WeightToFee::weight_to_fee(&weight))
},
Ok(asset_id) => {
log::trace!(target: "xcm::xcm_fee_payment_runtime_api", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!");
log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!");
Err(XcmPaymentApiError::AssetNotFound)
},
Err(_) => {
log::trace!(target: "xcm::xcm_fee_payment_runtime_api", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!");
log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!");
Err(XcmPaymentApiError::VersionedConversionFailed)
}
}
Expand All @@ -1354,7 +1354,7 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
}
Expand All @@ -1364,6 +1364,18 @@ impl_runtime_apis! {
}
}

impl xcm_runtime_apis::conversions::LocationToAccountApi<Block, AccountId> for Runtime {
fn convert_location(location: VersionedLocation) -> Result<
AccountId,
xcm_runtime_apis::conversions::Error
> {
xcm_runtime_apis::conversions::LocationToAccountHelper::<
AccountId,
xcm_config::LocationToAccountId,
>::convert_location(location)
}
}

impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
ParachainSystem::collect_collation_info(header)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ westend-runtime-constants = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-fee-payment-runtime-api = { workspace = true }
xcm-runtime-apis = { workspace = true }

# Cumulus
cumulus-pallet-aura-ext = { workspace = true }
Expand Down Expand Up @@ -138,7 +138,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm-fee-payment-runtime-api/runtime-benchmarks",
"xcm-runtime-apis/runtime-benchmarks",
]
try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
Expand Down Expand Up @@ -249,7 +249,7 @@ std = [
"westend-runtime-constants/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm-fee-payment-runtime-api/std",
"xcm-runtime-apis/std",
"xcm/std",
]

Expand Down
Loading
Loading