1234567891011121314151617#![allow(missing_docs)]1819use super::{Config, Pallet, Call};20use frame_benchmarking::{benchmarks, account};21use frame_system::RawOrigin;22use crate::AssetMetadata;23use xcm::opaque::latest::Junction::Parachain;24use xcm::VersionedMultiLocation;25use frame_support::{26 traits::{Currency},27};28use sp_std::boxed::Box;2930benchmarks! {31 register_foreign_asset {32 let owner: T::AccountId = account("user", 0, 1);33 let location: VersionedMultiLocation = VersionedMultiLocation::from(Parachain(1000).into());34 let metadata: AssetMetadata<<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance> = AssetMetadata{35 name: "name".into(),36 symbol: "symbol".into(),37 decimals: 18,38 minimal_balance: 1u32.into()39 };40 let mut balance: <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance =41 4_000_000_000u32.into();42 balance = balance * balance;43 <T as Config>::Currency::make_free_balance_be(&owner,44 balance);45 }: _(RawOrigin::Root, owner, Box::new(location), Box::new(metadata))4647 update_foreign_asset {48 let owner: T::AccountId = account("user", 0, 1);49 let location: VersionedMultiLocation = VersionedMultiLocation::from(Parachain(2000).into());50 let metadata: AssetMetadata<<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance> = AssetMetadata{51 name: "name".into(),52 symbol: "symbol".into(),53 decimals: 18,54 minimal_balance: 1u32.into()55 };56 let metadata2: AssetMetadata<<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance> = AssetMetadata{57 name: "name2".into(),58 symbol: "symbol2".into(),59 decimals: 18,60 minimal_balance: 1u32.into()61 };62 let mut balance: <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance =63 4_000_000_000u32.into();64 balance = balance * balance;65 <T as Config>::Currency::make_free_balance_be(&owner, balance);66 Pallet::<T>::register_foreign_asset(RawOrigin::Root.into(), owner, Box::new(location.clone()), Box::new(metadata))?;67 }: _(RawOrigin::Root, 0, Box::new(location), Box::new(metadata2))68}