1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use codec::{Decode, Encode};
use frame_support::{sp_runtime::traits::AtLeast32BitUnsigned, RuntimeDebug};
use xcm::v1::{AssetId, Fungibility, Junction, Junctions, MultiAsset, MultiLocation};
#[derive(Default, Encode, Decode, Clone, PartialEq, RuntimeDebug, scale_info::TypeInfo)]
pub struct XcmStakingMessageCount {
pub bond_extra: u32,
pub unbond: u32,
pub withdraw_unbonded: u32,
}
#[derive(Default, Encode, Decode, Clone, PartialEq, RuntimeDebug, scale_info::TypeInfo)]
pub struct AssetLedger<Balance> {
pub deposited: Balance,
pub pending_redemption: Balance,
}
impl<Balance> AssetLedger<Balance>
where
Balance: AtLeast32BitUnsigned + Copy,
{
pub fn consolidate(&mut self) {
let deposited = self.deposited;
self.deposited = self.deposited.saturating_sub(self.pending_redemption);
self.pending_redemption = self.pending_redemption.saturating_sub(deposited);
}
}
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, scale_info::TypeInfo)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct StatemintConfig {
pub parachain_id: u32,
pub enabled: bool,
}
impl StatemintConfig {
pub fn parahain_location(&self) -> MultiLocation {
MultiLocation::new(1, Junctions::X1(Junction::Parachain(self.parachain_id)))
}
}
impl StatemintConfig {
pub fn multi_asset(&self, amount: u128) -> MultiAsset {
MultiAsset { id: AssetId::Concrete(MultiLocation::here()), fun: Fungibility::Fungible(amount) }
}
}