This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Documentation for balances module #1943
Merged
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
74bcfcb
comment updates
joepetrowski a544d4a
Merge branch 'master' into joe-balances-docs
joepetrowski 1cc5721
added rustdoc and readme
joepetrowski e4a3bf7
clarified LockableCurrency trait
joepetrowski 3e4b5e4
Currency trait rustdocs
joepetrowski 077cde2
fixed typo
joepetrowski dd16fd6
fixed suggestions round 1
joepetrowski ceeb172
UpdateBalanceOutcome docs (open for discussion)
joepetrowski 05894ab
rm description of enum, consolidation, rm ReclaimRebate
joepetrowski a654735
type clarification, examples overhaul, adoc formatting
joepetrowski 02110b2
adoc to md
joepetrowski 53680af
format change for rustdoc
joepetrowski f1b62a4
update links and fix typos
joepetrowski 499c239
typos and links
joepetrowski cf750f8
Merge remote-tracking branch 'origin/master' into joe-balances-docs
joepetrowski 2cf4009
updates according to comments
joepetrowski d863ff6
new example
joepetrowski 5e28748
small clarifications
joepetrowski c8ec45a
trait implementation section
joepetrowski 36b1689
missing ```
joepetrowski 3c157e4
small changes, ready for review
joepetrowski a0ef9b7
line width update
joepetrowski 2d28117
Merge branch 'master' into joe-balances-docs
joepetrowski df3ced9
Merge branch 'master' into joe-balances-docs
joepetrowski e42f6b6
small tweaks
joepetrowski e000871
Update srml/balances/src/lib.rs
gui1117 faccdbf
Update srml/balances/src/lib.rs
gui1117 513b377
Update srml/balances/src/lib.rs
gui1117 ce29349
Update srml/balances/src/lib.rs
gui1117 fa9f215
Update lib.rs
joepetrowski 28a1d33
address review by thiolliere
joepetrowski aa43b56
remove common warning
joepetrowski 191ecc0
Merge remote-tracking branch 'origin/master' into joe-balances-docs
gavofyork 665fa6b
Update docs
gavofyork 5f391ae
updated srml example
joepetrowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
small tweaks
- Loading branch information
commit e42f6b63ec23c2ac8e1443125d971a5938a26517
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,10 +48,10 @@ | |
| //! existential deposit then it will be deleted. | ||
| //! - **Imbalance:** A condition when some funds were created or deducted without equal and opposite accounting. Functions | ||
| //! that result in an imbalance will return an object of the `Imbalance` trait that must be handled. | ||
| //! - **Locks:** Locks enable the runtime to lock an account's balance until a specified block number. | ||
| //! - **Locks:** A freeze on an account's balance until a specified block number. | ||
| //! | ||
| //! ### Implementations | ||
| //! | ||
| //! | ||
| //! The balances module provides implementations for the following traits. If these traits provide the functionality | ||
| //! that you need, then you can avoid coupling with the balances module. | ||
| //! | ||
|
|
@@ -60,13 +60,13 @@ | |
| //! - [`LockableCurrency`](https://crates.parity.io/srml_support/traits/trait.LockableCurrency.html): Functions for | ||
| //! dealing with accounts that allow liquidity restrictions. | ||
| //! - [`Imbalance`]: Functions for handling imbalances between total issuance in the system and account balances. | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| //! Must be used when a function creates new funds (e.g. a reward) or destroys some funds (e.g. system fee). | ||
| //! Must be used when a function creates new funds (e.g. a reward) or destroys some funds (e.g. a system fee). | ||
| //! - [`MakePayent`]: Simple trait designed for hooking into a transaction payment. It operates over a single generic | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| //! `AccountId` type. | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| //! - [`IsDeadAccount`](https://crates.parity.io/srml_system/trait.IsDeadAccount.html): Determiner to say whether a | ||
| //! given account is unused. | ||
| //! | ||
| //! Example from the treasury module: | ||
| //! Example of using the `Currency` trait from the treasury module: | ||
| //! | ||
| //! ```rust,ignore | ||
| //! pub trait Trait: system::Trait { | ||
|
|
@@ -142,7 +142,7 @@ | |
| //! ## Genesis config | ||
| //! | ||
| //! The following storage items depend on the genesis config: | ||
| //! | ||
| //! | ||
| //! - `TotalIssuance` | ||
| //! - `ExistentialDeposit` | ||
| //! - `TransferFee` | ||
|
|
@@ -183,7 +183,7 @@ pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait { | |
| /// The balance of an account. | ||
| type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u64> + MaybeSerializeDebug; | ||
|
|
||
| /// A function which is invoked when the free-balance has fallen below the existential deposit and | ||
| /// A function that is invoked when the free-balance has fallen below the existential deposit and | ||
| /// has been reduced to zero. | ||
| /// | ||
| /// Gives a chance to clean up resources associated with the given account. | ||
|
|
@@ -197,7 +197,7 @@ pub trait Trait<I: Instance = DefaultInstance>: system::Trait { | |
| /// The balance of an account. | ||
| type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u64> + MaybeSerializeDebug; | ||
|
|
||
| /// A function which is invoked when the free-balance has fallen below the existential deposit and | ||
| /// A function that is invoked when the free-balance has fallen below the existential deposit and | ||
| /// has been reduced to zero. | ||
| /// | ||
| /// Gives a chance to clean up resources associated with the given account. | ||
|
|
@@ -314,7 +314,7 @@ decl_storage! { | |
| /// This is the only balance that matters in terms of most operations on tokens. It | ||
| /// alone is used to determine the balance when in the contract execution environment. When this | ||
| /// balance falls below the value of `ExistentialDeposit`, then the 'current account' is | ||
| /// deleted: specifically `FreeBalance`. Furthermore, `OnFreeBalanceZero` callback | ||
| /// deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback | ||
| /// is invoked, giving a chance to external modules to clean up data associated with | ||
| /// the deleted account. | ||
| /// | ||
|
|
@@ -370,7 +370,7 @@ decl_module! { | |
| /// Set the balances of a given account. | ||
| /// | ||
| /// This will alter `FreeBalance` and `ReservedBalance` in storage. | ||
| /// If the new free or reserved balance is below the existential deposit, | ||
| /// If the new free or reserved balance is below the existential deposit, | ||
| /// it will also decrease the total issuance of the system (`TotalIssuance`) | ||
| /// and reset the account nonce (`system::AccountNonce`). | ||
joepetrowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// | ||
|
|
@@ -406,9 +406,9 @@ impl<T: Trait<I>, I: Instance> Module<T, I> { | |
| /// Set the reserved balance of an account to some new value. Will enforce `ExistentialDeposit` | ||
| /// law, annulling the account as needed. | ||
| /// | ||
| /// Doesn't do any preparatory work for creating a new account, so should only be used when it | ||
| /// Doesn't do any preparatory work for creating a new account, so should only be used when it | ||
| /// is known that the account already exists. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better to have a standardized preconditions documentation section, many method here have preconditions that have to be meet in order to ensure consistency. |
||
| /// | ||
| /// | ||
| /// NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that | ||
| /// the caller will do this. | ||
| fn set_reserved_balance(who: &T::AccountId, balance: T::Balance) -> UpdateBalanceOutcome { | ||
|
|
@@ -422,8 +422,8 @@ impl<T: Trait<I>, I: Instance> Module<T, I> { | |
| } | ||
| } | ||
|
|
||
| /// Set the free balance of an account to some new value. Will enforce ExistentialDeposit | ||
| /// law annulling the account as needed. | ||
| /// Set the free balance of an account to some new value. Will enforce `ExistentialDeposit` | ||
| /// law, annulling the account as needed. | ||
| /// | ||
| /// Doesn't do any preparatory work for creating a new account, so should only be used when it | ||
| /// is known that the account already exists. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.