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
fixed suggestions round 1
- Loading branch information
commit dd16fd608b31db669c9bc365ae76fb1b3fc239b8
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
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 |
|---|---|---|
|
|
@@ -231,7 +231,8 @@ impl<T: Trait> Module<T> { | |
| /// 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. |
||
| /// | ||
| /// Returns either `Updated` or `AccountKilled`. | ||
| /// Returns `Updated` if the account was successfully updated | ||
| /// or `AccountKilled` if the update has led to killing the account. | ||
| pub fn set_reserved_balance(who: &T::AccountId, balance: T::Balance) -> UpdateBalanceOutcome { | ||
| if balance < Self::existential_deposit() { | ||
| <ReservedBalance<T>>::insert(who, balance); | ||
|
|
@@ -249,7 +250,8 @@ impl<T: Trait> Module<T> { | |
| /// 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. | ||
| /// | ||
| /// Returns either `Updated` or `AccountKilled`. | ||
| /// Returns `Updated` if the account was successfully updated | ||
| /// or `AccountKilled` if the update has led to killing the account. | ||
| pub fn set_free_balance(who: &T::AccountId, balance: T::Balance) -> UpdateBalanceOutcome { | ||
| // Commented out for now - but consider it instructive. | ||
| // assert!(!Self::total_balance(who).is_zero()); | ||
|
|
@@ -268,7 +270,8 @@ impl<T: Trait> Module<T> { | |
| /// | ||
| /// Same as `set_free_balance`, but will create a new account. | ||
| /// | ||
| /// Returns either `Updated` or `AccountKilled`. | ||
| /// Returns `Updated` if the account was successfully updated | ||
| /// or `AccountKilled` if the update has led to killing the account. | ||
| pub fn set_free_balance_creating(who: &T::AccountId, balance: T::Balance) -> UpdateBalanceOutcome { | ||
| let ed = <Module<T>>::existential_deposit(); | ||
| // If the balance is too low, then the account is reaped. | ||
|
|
@@ -296,9 +299,11 @@ impl<T: Trait> Module<T> { | |
|
|
||
| /// Transfer some liquid free balance from one account to another. | ||
| /// | ||
| /// Enforces `ExistentialDeposit` law, reaping the sender's account if it's balance is | ||
| /// Enforces `ExistentialDeposit` law, reaping the sender's account if its balance is | ||
| /// too low as a result of the transfer. | ||
| /// | ||
| /// #NOTES | ||
| /// | ||
| /// Will create a new account for the destination if the account does not exist. | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub fn make_transfer(transactor: &T::AccountId, dest: &T::AccountId, value: T::Balance) -> Result { | ||
| let from_balance = Self::free_balance(transactor); | ||
|
|
@@ -371,14 +376,14 @@ impl<T: Trait> Module<T> { | |
| } | ||
| } | ||
|
|
||
| /// Increase `TotalIssuance` by `value`. | ||
| /// Increase stake by `value`. | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub fn increase_total_stake_by(value: T::Balance) { | ||
| if let Some(v) = <Module<T>>::total_issuance().checked_add(&value) { | ||
| <TotalIssuance<T>>::put(v); | ||
| } | ||
| } | ||
|
|
||
| /// Decrease `TotalIssuance` by `value`. | ||
| /// Decrease stake by `value`. | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub fn decrease_total_stake_by(value: T::Balance) { | ||
| if let Some(v) = <Module<T>>::total_issuance().checked_sub(&value) { | ||
| <TotalIssuance<T>>::put(v); | ||
|
|
||
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.