Skip to content

Commit ad43983

Browse files
committed
add deposit method
1 parent 55f5a02 commit ad43983

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

runtime/src/lib.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ type MemberCount = u32;
8888

8989
pub type Nonce = u32;
9090

91+
// Method used to calculate the fee of an extrinsic
92+
pub const fn deposit(items: u32, bytes: u32) -> Balance {
93+
pub const ITEMS_FEE: Balance = 2_000 * 10_000;
94+
pub const BYTES_FEE: Balance = 100 * 10_000;
95+
items as Balance * ITEMS_FEE + bytes as Balance * BYTES_FEE
96+
}
97+
9198
// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
9299
// the specifics of the runtime. They can then be made to be agnostic over specific formats
93100
// of data like extrinsics, allowing for them to continue syncing the network through upgrades
@@ -474,9 +481,9 @@ impl pallet_sudo::Config for Runtime {
474481

475482
parameter_types! {
476483
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
477-
pub const DepositBase: Balance = (1) as Balance * 2_000 * 10_000 + (88 as Balance) * 100 * 10_000;
484+
pub const DepositBase: Balance = deposit(1, 88);
478485
// Additional storage item size of 32 bytes.
479-
pub const DepositFactor: Balance = (0) as Balance * 2_000 * 10_000 + (32 as Balance) * 100 * 10_000;
486+
pub const DepositFactor: Balance = deposit(0, 32);
480487
pub const MaxSignatories: u32 = 100;
481488
}
482489

@@ -493,15 +500,15 @@ impl pallet_multisig::Config for Runtime {
493500
// Proxy Pallet config
494501
parameter_types! {
495502
// One storage item; key size sizeof(AccountId) = 32, value sizeof(Balance) = 8; 40 total
496-
pub const ProxyDepositBase: Balance = (1) as Balance * 2_000 * 10_000 + (40 as Balance) * 100 * 10_000;
503+
pub const ProxyDepositBase: Balance = deposit(1, 40);;
497504
// Adding 32 bytes + sizeof(ProxyType) = 32 + 1
498-
pub const ProxyDepositFactor: Balance = (0) as Balance * 2_000 * 10_000 + (33 as Balance) * 100 * 10_000;
505+
pub const ProxyDepositFactor: Balance = deposit(0, 33);
499506
pub const MaxProxies: u32 = 20; // max num proxies per acct
500507
pub const MaxPending: u32 = 15 * 5; // max blocks pending ~15min
501508
// 16 bytes
502-
pub const AnnouncementDepositBase: Balance = (1) as Balance * 2_000 * 10_000 + (16 as Balance) * 100 * 10_000;
509+
pub const AnnouncementDepositBase: Balance = deposit(1, 16);
503510
// 68 bytes per announcement
504-
pub const AnnouncementDepositFactor: Balance = (0) as Balance * 2_000 * 10_000 + (68 as Balance) * 100 * 10_000;
511+
pub const AnnouncementDepositFactor: Balance = deposit(0, 68);
505512
}
506513

507514
#[derive(
@@ -584,6 +591,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
584591
(ProxyType::Any, _) => true,
585592
(_, ProxyType::Any) => false,
586593
(ProxyType::NonTransfer, _) => true,
594+
(ProxyType::Governance, ProxyType::Triumvirate | ProxyType::Senate) => true,
587595
_ => false,
588596
}
589597
}

0 commit comments

Comments
 (0)