Skip to content

Commit

Permalink
chore: add example for balance AccountStore (#10361)
Browse files Browse the repository at this point in the history
* chore: modified example for balance AccountStore

* add example for account store balance

* add example for account store balance

* Update frame/balances/src/lib.rs

* Update frame/balances/src/lib.rs

* balance account store example

* balance account store example

* Update frame/balances/src/lib.rs

* Update frame/balances/src/lib.rs

* balance account store example

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 25, 2022
1 parent 2881900 commit 31d90c2
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,29 @@ pub mod pallet {
#[pallet::getter(fn total_issuance)]
pub type TotalIssuance<T: Config<I>, I: 'static = ()> = StorageValue<_, T::Balance, ValueQuery>;

/// The balance of an account.
/// The Balances pallet example of storing the balance of an account.
///
/// # Example
///
/// ```nocompile
/// impl pallet_balances::Config for Runtime {
/// type AccountStore = StorageMapShim<Self::Account<Runtime>, frame_system::Provider<Runtime>, AccountId, Self::AccountData<Balance>>
/// }
/// ```
///
/// You can also store the balance of an account in the `System` pallet.
///
/// # Example
///
/// ```nocompile
/// impl pallet_balances::Config for Runtime {
/// type AccountStore = System
/// }
/// ```
///
/// But this comes with tradeoffs, storing account balances in the system pallet stores
/// `frame_system` data alongside the account data contrary to storing account balances in the
/// `Balances` pallet, which uses a `StorageMap` to store balances data only.
/// NOTE: This is only used in the case that this pallet is used to store balances.
#[pallet::storage]
pub type Account<T: Config<I>, I: 'static = ()> = StorageMap<
Expand Down

0 comments on commit 31d90c2

Please sign in to comment.