-
Notifications
You must be signed in to change notification settings - Fork 707
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
Ref docs frame currency #2683
Ref docs frame currency #2683
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth defining a clear goal of what this ref doc should achieve, then outlining the sections and writing each sentence to ensure they are maximally fulfilling this goal.
I understood it as something to disambiguate the different traits, trait implementations, and terminology we have for handling tokens. We should be careful not to let the scope creep and start writing documentation for the actual traits / implementations here.
Indeed, we have different goals in mind for this document. We definitely don't want to talk (only) about the Currency trait here, but what is Currency in FRAME if not a very important use case of the fungible traits? |
Not sure what you mean here?
What is/was your goal for this doc?
Primarily I think the goal of an overarching doc for token traits and trait impls should be to allow a reader with zero prior knowledge of Substrate come away with
This could look something loosely like ## Tokens in Substrate
briefly explains
- how Substrate follows the pattern of traits and trait implementation for tokens
- why this approach was chosen
### Fungible Traits and Pallets
list and compare fungible traits and pallets
### Non-fungible Traits and Pallets
list and compare non-fungible traits and pallets I don't think this needs to be long. Each sentence should be genuinely informative and contribute to the goal of the document. Let me know what you think, I'm open to other ideas. |
This is supposed to be a Currency documentation, being currency a fungible token I think we should talk about both of them.
Give a high level overview of currency and fungible traits. ## Tokens in Substrate
briefly explains
- how Substrate follows the pattern of traits and trait implementation for tokens
- why this approach was chosen
### Fungible Traits and Pallets
list and compare fungible traits and pallets
### Non-fungible Traits and Pallets
list and compare non-fungible traits and pallets I don't think we should generalize it to "all" tokens, and therefore I wouldn't touch NFT in the Currency documentation, that should belong somewhere else.
|
The more broader/generic tokens document will be taken care of in paritytech/polkadot-sdk-docs#70 |
The CI pipeline was cancelled due to failure one of the required jobs. |
Just wanted to comment that we spent 2 days researching the move from currency to fungible/fungibles, and it was very hard to understand. Our main pain points that we had to clear up: Do freezes make the same changes to
|
Hey @JuaniRios thanks for your valuable input. We've loosely spoken about fungible/s traits in this doc as there's another one more specific to it paritytech/polkadot-sdk-docs#70. I am cc'ing @liamaharon as he's working on it |
Thank you @JuaniRios, this is super useful! I have a draft PR for token doc here #2802, will add a TODO there to make sure all these points have been covered. If you have any other suggestions for these docs you can comment in that pr :) |
//! financial operations. The key functions of | ||
//! [`pallet_balances`](../../../pallet_balances/index.html) include transferring tokens between | ||
//! accounts, checking account balances, and adjusting balances for staking or fees. This pallet | ||
//! implements the [`fungible`](../../../frame_support/traits/tokens/fungible/index.html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the most important detail came last; What I think is the most important piece of info here is that pallet-balances
and pallet-assets
provide implementations for all of the aforementioned traits. We can list those here (while linking to the proper impl
block in the rust-docs).
//! still using the [`Currency`](../../../frame_support/traits/tokens/currency/index.html) trait. | ||
//! There one could find the relevant code examples for upgrading. | ||
//! | ||
//! ## Fungible Traits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not going to briefly talk about Fungibles
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see fungibles
making sense in multiple assets scenario but not here, there is this other PR that covers more generic tokens topics
@@ -15,7 +15,26 @@ | |||
// See the License for the specific language governing permissions and | |||
// limitations under the License. | |||
|
|||
//! # Freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed the right place to document this. Any methods that can also be improved?
//! |__on_hold__|__ed__| | ||
//! ``` | ||
//! | ||
//! Freezes require a `Reason`, which is configurable and is expected to be an enum aggregated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly mention or link to the exact keyword of RuntimeFreezeReason
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start, but I expect a lot more substance on this particular topic. I expect this to be in #2802? if so, we can merge this already.
Yes, we have split the topic into two sections, this one focused only on "currency" as a native token, and a more generic one covered by that other PR |
//! Notes: | ||
//! Currency related traits in FRAME provide standardized interfaces for implementing various | ||
//! currency functionalities. The fundamental reason to have these traits is to allow pallets to | ||
//! utilize a token without relying on the implementation detail. Or else we could have a perfectly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! utilize a token without relying on the implementation detail. Or else we could have a perfectly | |
//! utilize tokens without relying on the implementation detail. Or else we could have a perfectly |
//! Notes: | ||
//! Currency related traits in FRAME provide standardized interfaces for implementing various | ||
//! currency functionalities. The fundamental reason to have these traits is to allow pallets to | ||
//! utilize a token without relying on the implementation detail. Or else we could have a perfectly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or else we could have a perfectly fine runtime without these traits.
I don't quite get what this sentence means to say. Could you elaborate/rephrase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be removed as it is redundant, what I meant is that you don't need these traits if your runtime doesn't require a currency
//! currency functionalities. The fundamental reason to have these traits is to allow pallets to | ||
//! utilize a token without relying on the implementation detail. Or else we could have a perfectly | ||
//! fine runtime without these traits. | ||
//! These traits enable developers to create, transfer, and manage different forms of digital assets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
different forms of digital assets
Nit but the first thing I thought when I read this was NFTs and I believe the Currency
traits are not the best abstractions.
//! - This footgun: <https://github.com/paritytech/polkadot-sdk/pull/1900#discussion_r1363783609> | ||
//! ## The Currency Trait | ||
//! | ||
//! The [`Currency`][4] trait was initially introduced in Substrate to manage the native token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[
Currency
][4]
Nit but this is the first time I'm seeing this type of referencing in our docs, maybe we should just add the URL in line? I find it easier to just click on the word/expression directly if I want more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a tradeoff... this format helps readability when there are long / too many links
#2683 (comment)
//! approach for single-asset operations. Fungible is currently preferred over currency as the | ||
//! latter is deprecated. | ||
//! | ||
//! #### Holds and Freezes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! #### Holds and Freezes | |
//! ### Holds and Freezes |
//! | ||
//! Learn more about this two concepts in | ||
//! [`frame_support::traits::tokens::fungible::hold`][1] and | ||
//! [`frame_support::traits::tokens::fungible::freeze`][2]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! [`frame_support::traits::tokens::fungible::freeze`][2]. | |
//! [`frame_support::traits::tokens::fungible::freeze`]. |
I believe the link is added automatically in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really as frame_support
is not a dependency of polkadot-sdk-docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to add it as a dep?
//! [`frame_support::traits::tokens::fungible::freeze`][2]. | ||
//! | ||
//! ## Balances Pallet | ||
//! The [`pallet_balances`](../../../pallet_balances/index.html) is a key component in FRAME. It |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This linking looks better to me, maybe we can stick with that and remove the references in the other cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed them where they made the lines too long or difficult to read
@@ -1,8 +1,55 @@ | |||
//! FRAME Currency Abstractions and Traits | |||
//! # FRAME Currency Abstractions and Traits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be useful to have a table with the comparing the Currency vs Fungible/s terms and a description on how they differ (e.g. locks vs holds, etc). This is usually a place where people get confused and it would be great if we could have a single place to refresh the memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we can improve this document by adding some more information, maybe we can keep that for another PR, wdyt?
@juangirini I wonder if you intend to finish the last bits of this, as there seems to be little left? else we can consider mentoring someone else to finish it. In case you do, feel free to leave your DOT address in the PR description :) |
@kianenigma, yes I'll finish the PR, there is very little left to do. Thanks for the reminder |
@gpestana I have addressed your comments on this other PR as I don't have write access anymore here |
@liamaharon is looking into how this PR can be incorporated into his more recent and broader PR around tokens, but nonetheless submitting a tip for gratitude. |
/tip medium |
@kianenigma A referendum for a medium (80 DOT) tip was successfully submitted for @juangirini (12zshjtBEmK43evpHZXyQEVHkfVhW7J5sUvs64EmusSCxPUp on polkadot). |
The referendum has appeared on Polkassembly. |
Closing, will absorb into #2802 |
Closes paritytech/polkadot-sdk-docs#70 WIP PR for an overview of how to develop tokens in FRAME. - [x] Tokens in Substrate Ref Doc - High-level overview of the token-related logic in FRAME - Improve docs with better explanation of how holds, freezes, ed, free balance, etc, all work - [x] Update `pallet_balances` docs - Clearly mark what is deprecated (currency) - [x] Write fungible trait docs - [x] Evaluate and if required update `pallet_assets`, `pallet_uniques`, `pallet_nfts` docs - [x] Absorb #2683 - [x] Audit individual trait method docs, and improve if possible Feel free to suggest additional TODOs for this PR in the comments --------- Co-authored-by: Bill Laboon <laboon@users.noreply.github.com> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
Closes paritytech/polkadot-sdk-docs#70 WIP PR for an overview of how to develop tokens in FRAME. - [x] Tokens in Substrate Ref Doc - High-level overview of the token-related logic in FRAME - Improve docs with better explanation of how holds, freezes, ed, free balance, etc, all work - [x] Update `pallet_balances` docs - Clearly mark what is deprecated (currency) - [x] Write fungible trait docs - [x] Evaluate and if required update `pallet_assets`, `pallet_uniques`, `pallet_nfts` docs - [x] Absorb #2683 - [x] Audit individual trait method docs, and improve if possible Feel free to suggest additional TODOs for this PR in the comments --------- Co-authored-by: Bill Laboon <laboon@users.noreply.github.com> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
Closes paritytech/polkadot-sdk-docs#70 WIP PR for an overview of how to develop tokens in FRAME. - [x] Tokens in Substrate Ref Doc - High-level overview of the token-related logic in FRAME - Improve docs with better explanation of how holds, freezes, ed, free balance, etc, all work - [x] Update `pallet_balances` docs - Clearly mark what is deprecated (currency) - [x] Write fungible trait docs - [x] Evaluate and if required update `pallet_assets`, `pallet_uniques`, `pallet_nfts` docs - [x] Absorb paritytech#2683 - [x] Audit individual trait method docs, and improve if possible Feel free to suggest additional TODOs for this PR in the comments --------- Co-authored-by: Bill Laboon <laboon@users.noreply.github.com> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
Closes paritytech/polkadot-sdk-docs#49
polkadot address: 12zshjtBEmK43evpHZXyQEVHkfVhW7J5sUvs64EmusSCxPUp