Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AHM] Make pallet types public #7579

Merged
merged 14 commits into from
Feb 17, 2025
6 changes: 3 additions & 3 deletions polkadot/runtime/common/src/claims/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Default for StatementKind {
#[derive(
Clone, Copy, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen,
)]
pub struct EthereumAddress([u8; 20]);
pub struct EthereumAddress(pub [u8; 20]);

impl Serialize for EthereumAddress {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand Down Expand Up @@ -239,11 +239,11 @@ pub mod pallet {

/// The statement kind that must be signed, if any.
#[pallet::storage]
pub(super) type Signing<T> = StorageMap<_, Identity, EthereumAddress, StatementKind>;
pub type Signing<T> = StorageMap<_, Identity, EthereumAddress, StatementKind>;

/// Pre-claimed Ethereum accounts, by the Account ID that they are claimed to.
#[pallet::storage]
pub(super) type Preclaims<T: Config> = StorageMap<_, Identity, T::AccountId, EthereumAddress>;
pub type Preclaims<T: Config> = StorageMap<_, Identity, T::AccountId, EthereumAddress>;

#[pallet::genesis_config]
#[derive(DefaultNoBound)]
Expand Down
6 changes: 3 additions & 3 deletions polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ pub mod mock_msg_queue {
type XcmExecutor: ExecuteXcm<Self::RuntimeCall>;
}

#[pallet::call]
impl<T: Config> Pallet<T> {}

#[pallet::pallet]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

#[pallet::call]
impl<T: Config> Pallet<T> {}

#[pallet::storage]
#[pallet::getter(fn parachain_id)]
pub(super) type ParachainId<T: Config> = StorageValue<_, ParaId, ValueQuery>;
Expand Down
57 changes: 57 additions & 0 deletions prdoc/pr_7579.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
title: '[AHM] Make pallet types public'
doc:
- audience: Runtime Dev
description: Preparation for AHM and making stuff public.
crates:
- name: cumulus-pallet-dmp-queue
bump: minor
- name: cumulus-pallet-xcm
bump: minor
- name: polkadot-runtime-common
bump: minor
- name: polkadot-runtime-parachains
bump: minor
- name: pallet-bags-list
bump: minor
- name: pallet-conviction-voting
bump: minor
- name: pallet-fast-unstake
bump: minor
- name: pallet-multisig
bump: minor
- name: pallet-nomination-pools
bump: minor
- name: pallet-preimage
bump: minor
- name: pallet-scheduler
bump: minor
- name: pallet-vesting
bump: minor
- name: staging-parachain-info
bump: minor
- name: xcm-simulator
bump: minor
- name: pallet-asset-conversion
bump: minor
- name: pallet-assets-freezer
bump: minor
- name: pallet-assets
bump: minor
- name: pallet-authority-discovery
bump: minor
- name: pallet-core-fellowship
bump: minor
- name: pallet-delegated-staking
bump: minor
- name: pallet-example-view-functions
bump: minor
- name: pallet-salary
bump: minor
- name: pallet-society
bump: minor
- name: frame-support
bump: minor
- name: pallet-treasury
bump: minor
- name: pallet-uniques
bump: minor
2 changes: 1 addition & 1 deletion substrate/frame/asset-conversion/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use sp_runtime::traits::TryConvert;
/// 1. `asset(asset1, amount_in)` take from `user` and move to the pool(asset1, asset2);
/// 2. `asset(asset2, amount_out2)` transfer from pool(asset1, asset2) to pool(asset2, asset3);
/// 3. `asset(asset3, amount_out3)` move from pool(asset2, asset3) to `user`.
pub(super) type BalancePath<T> = Vec<(<T as Config>::AssetKind, <T as Config>::Balance)>;
pub type BalancePath<T> = Vec<(<T as Config>::AssetKind, <T as Config>::Balance)>;

/// Credit of [Config::Assets].
pub type CreditOf<T> = Credit<<T as frame_system::Config>::AccountId, <T as Config>::Assets>;
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/assets-freezer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub mod pallet {

/// A map that stores freezes applied on an account for a given AssetId.
#[pallet::storage]
pub(super) type Freezes<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
pub type Freezes<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
_,
Blake2_128Concat,
T::AssetId,
Expand All @@ -120,7 +120,7 @@ pub mod pallet {

/// A map that stores the current total frozen balance for every account on a given AssetId.
#[pallet::storage]
pub(super) type FrozenBalances<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
pub type FrozenBalances<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
_,
Blake2_128Concat,
T::AssetId,
Expand Down
8 changes: 4 additions & 4 deletions substrate/frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ pub mod pallet {

#[pallet::storage]
/// Details of an asset.
pub(super) type Asset<T: Config<I>, I: 'static = ()> = StorageMap<
pub type Asset<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Blake2_128Concat,
T::AssetId,
Expand All @@ -428,7 +428,7 @@ pub mod pallet {

#[pallet::storage]
/// The holdings of a specific account for a specific asset.
pub(super) type Account<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
pub type Account<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
_,
Blake2_128Concat,
T::AssetId,
Expand All @@ -441,7 +441,7 @@ pub mod pallet {
/// Approved balance transfers. First balance is the amount approved for transfer. Second
/// is the amount of `T::Currency` reserved for storing this.
/// First key is the asset ID, second key is the owner and third key is the delegate.
pub(super) type Approvals<T: Config<I>, I: 'static = ()> = StorageNMap<
pub type Approvals<T: Config<I>, I: 'static = ()> = StorageNMap<
_,
(
NMapKey<Blake2_128Concat, T::AssetId>,
Expand All @@ -453,7 +453,7 @@ pub mod pallet {

#[pallet::storage]
/// Metadata of an asset.
pub(super) type Metadata<T: Config<I>, I: 'static = ()> = StorageMap<
pub type Metadata<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Blake2_128Concat,
T::AssetId,
Expand Down
76 changes: 38 additions & 38 deletions substrate/frame/assets/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ use frame_support::{
};
use sp_runtime::{traits::Convert, FixedPointNumber, FixedU128};

pub(super) type DepositBalanceOf<T, I = ()> =
pub type DepositBalanceOf<T, I = ()> =
<<T as Config<I>>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance;
pub(super) type AssetAccountOf<T, I> = AssetAccount<
pub type AssetAccountOf<T, I> = AssetAccount<
<T as Config<I>>::Balance,
DepositBalanceOf<T, I>,
<T as Config<I>>::Extra,
<T as SystemConfig>::AccountId,
>;
pub(super) type ExistenceReasonOf<T, I> =
pub type ExistenceReasonOf<T, I> =
ExistenceReason<DepositBalanceOf<T, I>, <T as SystemConfig>::AccountId>;

/// AssetStatus holds the current state of the asset. It could either be Live and available for use,
/// or in a Destroying state.
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
pub(super) enum AssetStatus {
pub enum AssetStatus {
/// The asset is active and able to be used.
Live,
/// Whether the asset is frozen for non-admin transfers.
Expand All @@ -51,40 +51,40 @@ pub(super) enum AssetStatus {
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
pub struct AssetDetails<Balance, AccountId, DepositBalance> {
/// Can change `owner`, `issuer`, `freezer` and `admin` accounts.
pub(super) owner: AccountId,
pub owner: AccountId,
/// Can mint tokens.
pub(super) issuer: AccountId,
pub issuer: AccountId,
/// Can thaw tokens, force transfers and burn tokens from any account.
pub(super) admin: AccountId,
pub admin: AccountId,
/// Can freeze tokens.
pub(super) freezer: AccountId,
pub freezer: AccountId,
/// The total supply across all accounts.
pub(super) supply: Balance,
pub supply: Balance,
/// The balance deposited for this asset. This pays for the data stored here.
pub(super) deposit: DepositBalance,
pub deposit: DepositBalance,
/// The ED for virtual accounts.
pub(super) min_balance: Balance,
pub min_balance: Balance,
/// If `true`, then any account with this asset is given a provider reference. Otherwise, it
/// requires a consumer reference.
pub(super) is_sufficient: bool,
pub is_sufficient: bool,
/// The total number of accounts.
pub(super) accounts: u32,
pub accounts: u32,
/// The total number of accounts for which we have placed a self-sufficient reference.
pub(super) sufficients: u32,
pub sufficients: u32,
/// The total number of approvals.
pub(super) approvals: u32,
pub approvals: u32,
/// The status of the asset
pub(super) status: AssetStatus,
pub status: AssetStatus,
}

/// Data concerning an approval.
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, Default, MaxEncodedLen, TypeInfo)]
pub struct Approval<Balance, DepositBalance> {
/// The amount of funds approved for the balance transfer from the owner to some delegated
/// target.
pub(super) amount: Balance,
pub amount: Balance,
/// The amount reserved on the owner's account to hold this item in storage.
pub(super) deposit: DepositBalance,
pub deposit: DepositBalance,
}

#[test]
Expand Down Expand Up @@ -118,7 +118,7 @@ impl<Balance, AccountId> ExistenceReason<Balance, AccountId>
where
AccountId: Clone,
{
pub(crate) fn take_deposit(&mut self) -> Option<Balance> {
pub fn take_deposit(&mut self) -> Option<Balance> {
if !matches!(self, ExistenceReason::DepositHeld(_)) {
return None
}
Expand All @@ -131,7 +131,7 @@ where
}
}

pub(crate) fn take_deposit_from(&mut self) -> Option<(AccountId, Balance)> {
pub fn take_deposit_from(&mut self) -> Option<(AccountId, Balance)> {
if !matches!(self, ExistenceReason::DepositFrom(..)) {
return None
}
Expand Down Expand Up @@ -163,11 +163,11 @@ pub enum AccountStatus {
}
impl AccountStatus {
/// Returns `true` if frozen or blocked.
pub(crate) fn is_frozen(&self) -> bool {
pub fn is_frozen(&self) -> bool {
matches!(self, AccountStatus::Frozen | AccountStatus::Blocked)
}
/// Returns `true` if blocked.
pub(crate) fn is_blocked(&self) -> bool {
pub fn is_blocked(&self) -> bool {
matches!(self, AccountStatus::Blocked)
}
}
Expand All @@ -178,29 +178,29 @@ pub struct AssetAccount<Balance, DepositBalance, Extra, AccountId> {
///
/// The part of the `balance` may be frozen by the [`Config::Freezer`]. The on-hold portion is
/// not included here and is tracked by the [`Config::Holder`].
pub(super) balance: Balance,
pub balance: Balance,
/// The status of the account.
pub(super) status: AccountStatus,
pub status: AccountStatus,
/// The reason for the existence of the account.
pub(super) reason: ExistenceReason<DepositBalance, AccountId>,
pub reason: ExistenceReason<DepositBalance, AccountId>,
/// Additional "sidecar" data, in case some other pallet wants to use this storage item.
pub(super) extra: Extra,
pub extra: Extra,
}

#[derive(Clone, Encode, Decode, Eq, PartialEq, Default, RuntimeDebug, MaxEncodedLen, TypeInfo)]
pub struct AssetMetadata<DepositBalance, BoundedString> {
/// The balance deposited for this metadata.
///
/// This pays for the data stored in this struct.
pub(super) deposit: DepositBalance,
pub deposit: DepositBalance,
/// The user friendly name of this asset. Limited in length by `StringLimit`.
pub(super) name: BoundedString,
pub name: BoundedString,
/// The ticker symbol for this asset. Limited in length by `StringLimit`.
pub(super) symbol: BoundedString,
pub symbol: BoundedString,
/// The number of decimals this asset uses to represent one unit.
pub(super) decimals: u8,
pub decimals: u8,
/// Whether the asset metadata may be changed by a non Force origin.
pub(super) is_frozen: bool,
pub is_frozen: bool,
}

/// Trait for allowing a minimum balance on the account to be specified, beyond the
Expand Down Expand Up @@ -275,28 +275,28 @@ impl<AssetId, AccountId, Balance> BalanceOnHold<AssetId, AccountId, Balance> for
}

#[derive(Copy, Clone, PartialEq, Eq)]
pub(super) struct TransferFlags {
pub struct TransferFlags {
/// The debited account must stay alive at the end of the operation; an error is returned if
/// this cannot be achieved legally.
pub(super) keep_alive: bool,
pub keep_alive: bool,
/// Less than the amount specified needs be debited by the operation for it to be considered
/// successful. If `false`, then the amount debited will always be at least the amount
/// specified.
pub(super) best_effort: bool,
pub best_effort: bool,
/// Any additional funds debited (due to minimum balance requirements) should be burned rather
/// than credited to the destination account.
pub(super) burn_dust: bool,
pub burn_dust: bool,
}

#[derive(Copy, Clone, PartialEq, Eq)]
pub(super) struct DebitFlags {
pub struct DebitFlags {
/// The debited account must stay alive at the end of the operation; an error is returned if
/// this cannot be achieved legally.
pub(super) keep_alive: bool,
pub keep_alive: bool,
/// Less than the amount specified needs be debited by the operation for it to be considered
/// successful. If `false`, then the amount debited will always be at least the amount
/// specified.
pub(super) best_effort: bool,
pub best_effort: bool,
}

impl From<TransferFlags> for DebitFlags {
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/authority-discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ pub mod pallet {

#[pallet::storage]
/// Keys of the current authority set.
pub(super) type Keys<T: Config> =
pub type Keys<T: Config> =
StorageValue<_, WeakBoundedVec<AuthorityId, T::MaxAuthorities>, ValueQuery>;

#[pallet::storage]
/// Keys of the next authority set.
pub(super) type NextKeys<T: Config> =
pub type NextKeys<T: Config> =
StorageValue<_, WeakBoundedVec<AuthorityId, T::MaxAuthorities>, ValueQuery>;

#[derive(frame_support::DefaultNoBound)]
Expand Down
5 changes: 2 additions & 3 deletions substrate/frame/bags-list/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ pub mod pallet {
///
/// Nodes store links forward and back within their respective bags.
#[pallet::storage]
pub(crate) type ListNodes<T: Config<I>, I: 'static = ()> =
pub type ListNodes<T: Config<I>, I: 'static = ()> =
CountedStorageMap<_, Twox64Concat, T::AccountId, list::Node<T, I>>;

/// A bag stored in storage.
///
/// Stores a `Bag` struct, which stores head and tail pointers to itself.
#[pallet::storage]
pub(crate) type ListBags<T: Config<I>, I: 'static = ()> =
pub type ListBags<T: Config<I>, I: 'static = ()> =
StorageMap<_, Twox64Concat, T::Score, list::Bag<T, I>>;

#[pallet::event]
Expand All @@ -273,7 +273,6 @@ pub mod pallet {
}

#[pallet::error]
#[cfg_attr(test, derive(PartialEq))]
pub enum Error<T, I = ()> {
/// A error in the list interface implementation.
List(ListError),
Expand Down
Loading
Loading