snowbridge_pallet_system/api.rs
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
3//! Helpers for implementing runtime api
4
5use snowbridge_core::AgentId;
6use xcm::{prelude::*, VersionedLocation};
7
8use crate::{agent_id_of, Config};
9
10pub fn agent_id<Runtime>(location: VersionedLocation) -> Option<AgentId>
11where
12 Runtime: Config,
13{
14 let location: Location = location.try_into().ok()?;
15 agent_id_of::<Runtime>(&location).ok()
16}