snowbridge_pallet_system_v2/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 crate::Config;
6use sp_core::H256;
7use xcm::{prelude::*, VersionedLocation};
8
9pub fn agent_id<Runtime>(location: VersionedLocation) -> Option<H256>
10where
11 Runtime: Config,
12{
13 let location: Location = location.try_into().ok()?;
14 crate::Pallet::<Runtime>::location_to_message_origin(location).ok()
15}