1
// Copyright 2019-2025 PureStake Inc.
2
// This file is part of Moonbeam.
3

            
4
// Moonbeam is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Moonbeam is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Moonbeam.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
#![cfg_attr(rustfmt, rustfmt_skip)]
18
#![allow(unused_parens)]
19
#![allow(unused_imports)]
20

            
21
use frame_support::{traits::Get, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}};
22
use sp_std::marker::PhantomData;
23
use xcm::latest::Asset;
24

            
25
// Values copied from statemint benchmarks
26
const ASSET_MINT_MAX_PROOF_SIZE: u64 = 7242;
27
const ASSET_TRANSFER_MAX_PROOF_SIZE: u64 = 13412;
28

            
29
/// Weights for `pallet_xcm_benchmarks::fungible`.
30
pub struct WeightInfo<T>(PhantomData<T>);
31
impl<T: frame_system::Config + pallet_erc20_xcm_bridge::Config + pallet_moonbeam_foreign_assets::Config> WeightInfo<T> {
32
122
	pub(crate) fn withdraw_asset(asset: &Asset) -> Weight {
33
122
		if pallet_erc20_xcm_bridge::Pallet::<T>::is_erc20_asset(asset) {
34
			pallet_erc20_xcm_bridge::Pallet::<T>::weight_of_erc20_transfer(&asset.id)
35
		} else {
36
122
			pallet_moonbeam_foreign_assets::Pallet::<T>::weight_of_erc20_burn()
37
		}
38
122
	}
39
18
	pub(crate) fn transfer_asset(asset: &Asset) -> Weight {
40
18
		if pallet_erc20_xcm_bridge::Pallet::<T>::is_erc20_asset(asset) {
41
			pallet_erc20_xcm_bridge::Pallet::<T>::weight_of_erc20_transfer(&asset.id)
42
		} else {
43
18
			pallet_moonbeam_foreign_assets::Pallet::<T>::weight_of_erc20_transfer()
44
		}
45
18
	}
46
	pub(crate) fn transfer_reserve_asset(asset: &Asset) -> Weight {
47
		if pallet_erc20_xcm_bridge::Pallet::<T>::is_erc20_asset(asset) {
48
			pallet_erc20_xcm_bridge::Pallet::<T>::weight_of_erc20_transfer(&asset.id)
49
		} else {
50
			Weight::from_parts(200_000_000 as u64, ASSET_TRANSFER_MAX_PROOF_SIZE)
51
		}
52
	}
53
	pub(crate) fn receive_teleported_asset() -> Weight {
54
		// Instruction disabled
55
		Weight::MAX
56
	}
57
	pub(crate) fn deposit_asset() -> Weight {
58
		pallet_moonbeam_foreign_assets::Pallet::<T>::weight_of_erc20_mint()
59
	}
60
	pub(crate) fn deposit_reserve_asset() -> Weight {
61
		Weight::from_parts(200_000_000 as u64, ASSET_MINT_MAX_PROOF_SIZE)
62
	}
63
	pub(crate) fn initiate_teleport() -> Weight {
64
		// Instruction disabled
65
		Weight::MAX
66
	}
67
	pub(crate) fn reserve_asset_deposited() -> Weight {
68
		// This instruction is a no-op for PoV (no storage access)
69
		Weight::from_parts(200_000_000 as u64, 0)
70
	}
71
}