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
use codec::{Decode, Encode, MaxEncodedLen};
use currency::Amount;
use frame_system::pallet_prelude::BlockNumberFor;
pub use primitives::issue::{IssueRequest, IssueRequestStatus};
use primitives::VaultId;
use scale_info::TypeInfo;
use vault_registry::types::CurrencyId;
use crate::Config;
#[derive(Encode, Decode, Eq, PartialEq, TypeInfo, MaxEncodedLen)]
pub enum Version {
V0,
V1,
V2,
V3,
V4,
}
pub(crate) type BalanceOf<T> = <T as currency::Config>::Balance;
pub(crate) type DefaultVaultId<T> = VaultId<<T as frame_system::Config>::AccountId, CurrencyId<T>>;
pub type DefaultIssueRequest<T> =
IssueRequest<<T as frame_system::Config>::AccountId, BlockNumberFor<T>, BalanceOf<T>, CurrencyId<T>>;
pub trait IssueRequestExt<T: Config> {
fn amount(&self) -> Amount<T>;
fn fee(&self) -> Amount<T>;
fn griefing_collateral(&self) -> Amount<T>;
}
impl<T: Config> IssueRequestExt<T> for DefaultIssueRequest<T> {
fn amount(&self) -> Amount<T> {
Amount::new(self.amount, self.vault.wrapped_currency())
}
fn fee(&self) -> Amount<T> {
Amount::new(self.fee, self.vault.wrapped_currency())
}
fn griefing_collateral(&self) -> Amount<T> {
Amount::new(self.griefing_collateral, self.griefing_currency)
}
}