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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use crate::{
constants::currency::{deposit, TDFY},
types::{AccountId, Balance, BlockNumber},
Balances, OriginCaller, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, System,
TreasuryPalletId,
};
use frame_support::{parameter_types, traits::EnsureOrigin};
use frame_system::RawOrigin;
use sp_runtime::traits::{AccountIdConversion, BlockNumberProvider};
impl pallet_utility::Config for Runtime {
type PalletsOrigin = OriginCaller;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type WeightInfo = crate::weights::pallet_utility::WeightInfo<Runtime>;
}
parameter_types! {
pub const DepositBase: Balance = deposit(1, 88);
pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u16 = 100;
pub MinVestedTransfer: Balance = TDFY;
pub const MaxVestingSchedules: u32 = 300;
}
impl pallet_multisig::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = crate::weights::pallet_multisig::WeightInfo<Runtime>;
}
pub struct EnsureRootOrTreasury;
impl EnsureOrigin<RuntimeOrigin> for EnsureRootOrTreasury {
type Success = AccountId;
fn try_origin(o: RuntimeOrigin) -> Result<Self::Success, RuntimeOrigin> {
Into::<Result<RawOrigin<AccountId>, RuntimeOrigin>>::into(o).and_then(|o| match o {
RawOrigin::Root => Ok(TreasuryPalletId::get().into_account_truncating()),
RawOrigin::Signed(caller) => {
if caller == TreasuryPalletId::get().into_account_truncating() {
Ok(caller)
} else {
Err(RuntimeOrigin::from(Some(caller)))
}
}
r => Err(RuntimeOrigin::from(r)),
})
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<RuntimeOrigin, ()> {
Ok(RuntimeOrigin::from(RawOrigin::Signed(
TreasuryPalletId::get().into_account_truncating(),
)))
}
}
pub struct SusbtrateBlockNumberProvider;
impl BlockNumberProvider for SusbtrateBlockNumberProvider {
type BlockNumber = BlockNumber;
fn current_block_number() -> Self::BlockNumber {
System::block_number()
}
}
impl pallet_vesting::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type MinVestedTransfer = MinVestedTransfer;
type VestedTransferOrigin = EnsureRootOrTreasury;
type WeightInfo = pallet_vesting::SubstrateWeight<Runtime>;
type MaxVestingSchedules = MaxVestingSchedules;
type BlockNumberProvider = SusbtrateBlockNumberProvider;
}