From 35e32f745c80c51424dd77d723490789b3a83122 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Thu, 7 Mar 2019 17:02:05 +0100 Subject: [PATCH 01/42] WIP - SRML Assets Module README --- srml/assets/README.adoc | 111 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 srml/assets/README.adoc diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc new file mode 100644 index 0000000000000..5e8b22c30c7ed --- /dev/null +++ b/srml/assets/README.adoc @@ -0,0 +1,111 @@ +# Assets Module + +## Overview + +The assets module provides functionality for asset management of fungible asset classes with a fixed supply, including: + +* Asset Issuance +* Asset Transfer +* Asset Destruction + +The SRML Support Module implements the `Currency` trait abstraction over the SRML Assets Module's fungible assets system. + +### Types + +- AssetId + +## Public Interface + +### Supported Origins + +`signed` - Used to issue, transfer, and destroy an asset holding. + +### Public Immutable functions (getters) + +#### `balance(id: AssetId, who: T::AccountId) -> T::Balance` + +#### `total_supply(id: AssetId) -> T::Balance` + +### Public Mutable functions (changing state) + +#### `issue(origin, #[compact] total: T::Balance)` + +#### `transfer(origin, #[compact] id: AssetId, target: ::Source, #[compact] amount: T::Balance)` + +#### `destroy(origin, #[compact] id: AssetId)` + +### Events: + +#### `Issued(AssetId, AccountId, Balance)` + +#### `Transferred(AssetId, AccountId, AccountId, Balance)` + +#### `Destroyed(AssetId, AccountId, Balance)` + +## Usage + +The following example shows how to use the Asset Module in your custom module to query an account's asset holding, and query the total supply of an asset and an account's asset holding balance. + +**1. Import Asset Module and Types** + +Import the `assets` module and derive your custom module configuration traits from the `assets` module trait. + +```rust +use assets; + +pub trait Trait: assets::Trait { } +``` + +**2. Import Accounts** + +```rust +const ALICE: u64 = 1; +const BOB: u64 = 2; + // Initial Asset ID is 0 +const INITIAL_ASSET_ID: u32 = >::next_asset_id(); +const FIXED_SUPPLY: u64 = 100; +``` + +**3. Issue a new Fungible Asset to an Account** + +Issue the `total` amount of a new class of fungible asset with a fixed supply of units to a signed sender's (`origin`) account (i.e. Alice) and trigger the `Issued` event that contains the generated `AssetId`. + +```rust +>::issue(Origin::signed(&ALICE), FIXED_SUPPLY); +``` + +**4. Transfer a Fungible Asset between Accounts** + +Transfer a signed sender's (i.e. Alice) account holding of an asset's `AssetId` to a `target` recipient account (i.e. Bob) using the public call `transfer`. It only triggers the `Transferred` event if the transfer is valid. + +```rust +>::transfer(Origin::signed(&ALICE), INITIAL_ASSET_ID, BOB, FIXED_SUPPLY); +``` + +**5. Destroy the Fungible Asset holding of an Account** + +Destroy a signed sender's (i.e. Alice) entire account holding of a fungible asset and trigger the `Destroyed` event if they have a non-zero balance. + +```rust +>::destroy(Origin::signed(&ALICE), INITIAL_ASSET_ID); +``` + +**6. Query the Fungible Asset holding of an Account** + +Query an account's holding balance (i.e. Alice) of a fungible asset by calling the asset module's `balance` function. + +```rust +let balance = >::balance(INITIAL_ASSET_ID, Origin::signed(&ALICE)); +``` + +**7. Query the Total Supply of a Fungible Asset** + +Query the total supply of a fungible asset that has been issued by calling the asset module's `total_supply` function. + +```rust +let total_supply = >::total_supply(INITIAL_ASSET_ID); +``` + +## Dependencies + +The Assets Module depends on the `system` and `srml_support` modules as well as Substrate Core libraries and the Rust standard library. \ No newline at end of file From 2b11c74d771b7fadfebd2925d3384f3e2c4bc0b0 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Thu, 7 Mar 2019 17:07:48 +0100 Subject: [PATCH 02/42] docs: Tweaks for consistency --- srml/assets/README.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc index 5e8b22c30c7ed..55d9964483a93 100644 --- a/srml/assets/README.adoc +++ b/srml/assets/README.adoc @@ -12,7 +12,7 @@ The SRML Support Module implements the `Currency` trait abstraction over the SRM ### Types -- AssetId +* AssetId ## Public Interface @@ -95,7 +95,7 @@ Destroy a signed sender's (i.e. Alice) entire account holding of a fungible asse Query an account's holding balance (i.e. Alice) of a fungible asset by calling the asset module's `balance` function. ```rust -let balance = >::balance(INITIAL_ASSET_ID, Origin::signed(&ALICE)); +const balance = >::balance(INITIAL_ASSET_ID, Origin::signed(&ALICE)); ``` **7. Query the Total Supply of a Fungible Asset** @@ -103,7 +103,7 @@ let balance = >::balance(INITIAL_ASSET_ID, Origin::signed(&ALI Query the total supply of a fungible asset that has been issued by calling the asset module's `total_supply` function. ```rust -let total_supply = >::total_supply(INITIAL_ASSET_ID); +const total_supply = >::total_supply(INITIAL_ASSET_ID); ``` ## Dependencies From 7fadb7677b314cdaf5dfc80da6fc5406ad3e2559 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Thu, 7 Mar 2019 17:15:33 +0100 Subject: [PATCH 03/42] docs: Add missing newline --- srml/assets/README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc index 55d9964483a93..ea2157045416e 100644 --- a/srml/assets/README.adoc +++ b/srml/assets/README.adoc @@ -108,4 +108,4 @@ const total_supply = >::total_supply(INITIAL_ASSET_ID); ## Dependencies -The Assets Module depends on the `system` and `srml_support` modules as well as Substrate Core libraries and the Rust standard library. \ No newline at end of file +The Assets Module depends on the `system` and `srml_support` modules as well as Substrate Core libraries and the Rust standard library. From 14d701ddf06e9c7e9ddad3de0f5f082939adccde Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Fri, 8 Mar 2019 15:53:45 +0100 Subject: [PATCH 04/42] review-fix: Remove non-SRML trait dependencies --- srml/assets/README.adoc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc index ea2157045416e..4a63616a7c30b 100644 --- a/srml/assets/README.adoc +++ b/srml/assets/README.adoc @@ -105,7 +105,3 @@ Query the total supply of a fungible asset that has been issued by calling the a ```rust const total_supply = >::total_supply(INITIAL_ASSET_ID); ``` - -## Dependencies - -The Assets Module depends on the `system` and `srml_support` modules as well as Substrate Core libraries and the Rust standard library. From bc16608b143844f89d878c2c5c6a604afbcdb4cf Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Fri, 8 Mar 2019 15:55:12 +0100 Subject: [PATCH 05/42] review-fix: Replace const with let --- srml/assets/README.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc index 4a63616a7c30b..53782cc96c769 100644 --- a/srml/assets/README.adoc +++ b/srml/assets/README.adoc @@ -95,7 +95,7 @@ Destroy a signed sender's (i.e. Alice) entire account holding of a fungible asse Query an account's holding balance (i.e. Alice) of a fungible asset by calling the asset module's `balance` function. ```rust -const balance = >::balance(INITIAL_ASSET_ID, Origin::signed(&ALICE)); +let balance = >::balance(INITIAL_ASSET_ID, Origin::signed(&ALICE)); ``` **7. Query the Total Supply of a Fungible Asset** @@ -103,5 +103,5 @@ const balance = >::balance(INITIAL_ASSET_ID, Origin::signed(&A Query the total supply of a fungible asset that has been issued by calling the asset module's `total_supply` function. ```rust -const total_supply = >::total_supply(INITIAL_ASSET_ID); +let total_supply = >::total_supply(INITIAL_ASSET_ID); ``` From eaedc6c23dafab8f13bac51045b496461a50dc0b Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Fri, 8 Mar 2019 15:57:06 +0100 Subject: [PATCH 06/42] review-fix: Remove use of compact in signature --- srml/assets/README.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc index 53782cc96c769..52de5e31ab177 100644 --- a/srml/assets/README.adoc +++ b/srml/assets/README.adoc @@ -28,11 +28,11 @@ The SRML Support Module implements the `Currency` trait abstraction over the SRM ### Public Mutable functions (changing state) -#### `issue(origin, #[compact] total: T::Balance)` +#### `issue(origin, total: T::Balance)` -#### `transfer(origin, #[compact] id: AssetId, target: ::Source, #[compact] amount: T::Balance)` +#### `transfer(origin, id: AssetId, target: ::Source, amount: T::Balance)` -#### `destroy(origin, #[compact] id: AssetId)` +#### `destroy(origin, id: AssetId)` ### Events: From b8fa0a7f4a0ba43a6329a46c27c592415d74b790 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Fri, 8 Mar 2019 16:08:19 +0100 Subject: [PATCH 07/42] review-fix: Change const to let since cannot use result of function call --- srml/assets/README.adoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc index 52de5e31ab177..2d6e00ba47687 100644 --- a/srml/assets/README.adoc +++ b/srml/assets/README.adoc @@ -61,8 +61,9 @@ pub trait Trait: assets::Trait { } ```rust const ALICE: u64 = 1; const BOB: u64 = 2; - // Initial Asset ID is 0 -const INITIAL_ASSET_ID: u32 = >::next_asset_id(); + +// Initial Asset ID is 0 +let initial_asset_id: u32 = >::next_asset_id(); const FIXED_SUPPLY: u64 = 100; ``` From dd6993505ff6dd2635a9bf876bcd88ee6cd2d0bb Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Fri, 8 Mar 2019 16:09:16 +0100 Subject: [PATCH 08/42] fix: Add backticks around type and mention type it derives from --- srml/assets/README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc index 2d6e00ba47687..48feb1e83b2d4 100644 --- a/srml/assets/README.adoc +++ b/srml/assets/README.adoc @@ -12,7 +12,7 @@ The SRML Support Module implements the `Currency` trait abstraction over the SRM ### Types -* AssetId +* `AssetId`: `u32` ## Public Interface From 94d2f3e9aba38505cb19fba1db3556c1d1cf43b5 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Fri, 8 Mar 2019 16:11:01 +0100 Subject: [PATCH 09/42] review-fix: Update variable names since changed to lowercase since using let --- srml/assets/README.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc index 48feb1e83b2d4..f722bf0c9f3d9 100644 --- a/srml/assets/README.adoc +++ b/srml/assets/README.adoc @@ -80,7 +80,7 @@ Issue the `total` amount of a new class of fungible asset with a fixed supply of Transfer a signed sender's (i.e. Alice) account holding of an asset's `AssetId` to a `target` recipient account (i.e. Bob) using the public call `transfer`. It only triggers the `Transferred` event if the transfer is valid. ```rust ->::transfer(Origin::signed(&ALICE), INITIAL_ASSET_ID, BOB, FIXED_SUPPLY); +>::transfer(Origin::signed(&ALICE), initial_asset_id, BOB, FIXED_SUPPLY); ``` **5. Destroy the Fungible Asset holding of an Account** @@ -88,7 +88,7 @@ Transfer a signed sender's (i.e. Alice) account holding of an asset's `AssetId` Destroy a signed sender's (i.e. Alice) entire account holding of a fungible asset and trigger the `Destroyed` event if they have a non-zero balance. ```rust ->::destroy(Origin::signed(&ALICE), INITIAL_ASSET_ID); +>::destroy(Origin::signed(&ALICE), initial_asset_id); ``` **6. Query the Fungible Asset holding of an Account** @@ -96,7 +96,7 @@ Destroy a signed sender's (i.e. Alice) entire account holding of a fungible asse Query an account's holding balance (i.e. Alice) of a fungible asset by calling the asset module's `balance` function. ```rust -let balance = >::balance(INITIAL_ASSET_ID, Origin::signed(&ALICE)); +let balance = >::balance(initial_asset_id, Origin::signed(&ALICE)); ``` **7. Query the Total Supply of a Fungible Asset** @@ -104,5 +104,5 @@ let balance = >::balance(INITIAL_ASSET_ID, Origin::signed(&ALI Query the total supply of a fungible asset that has been issued by calling the asset module's `total_supply` function. ```rust -let total_supply = >::total_supply(INITIAL_ASSET_ID); +let total_supply = >::total_supply(initial_asset_id); ``` From 0383d9bef6e7343fa69b57e423138d592daf7c98 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Fri, 8 Mar 2019 16:19:28 +0100 Subject: [PATCH 10/42] fix: Change type to bold instead of code --- srml/assets/README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc index f722bf0c9f3d9..981b4d2a04907 100644 --- a/srml/assets/README.adoc +++ b/srml/assets/README.adoc @@ -18,7 +18,7 @@ The SRML Support Module implements the `Currency` trait abstraction over the SRM ### Supported Origins -`signed` - Used to issue, transfer, and destroy an asset holding. +**signed** - Used to issue, transfer, and destroy an asset holding. ### Public Immutable functions (getters) From 33465e1a498ea4f114cb30be04affe19b6924b39 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Wed, 20 Mar 2019 11:47:48 +0100 Subject: [PATCH 11/42] review-fix: Update Asset module --- srml/assets/README.adoc | 108 ---------------------------- srml/assets/src/lib.rs | 151 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 108 deletions(-) delete mode 100644 srml/assets/README.adoc diff --git a/srml/assets/README.adoc b/srml/assets/README.adoc deleted file mode 100644 index 981b4d2a04907..0000000000000 --- a/srml/assets/README.adoc +++ /dev/null @@ -1,108 +0,0 @@ -# Assets Module - -## Overview - -The assets module provides functionality for asset management of fungible asset classes with a fixed supply, including: - -* Asset Issuance -* Asset Transfer -* Asset Destruction - -The SRML Support Module implements the `Currency` trait abstraction over the SRML Assets Module's fungible assets system. - -### Types - -* `AssetId`: `u32` - -## Public Interface - -### Supported Origins - -**signed** - Used to issue, transfer, and destroy an asset holding. - -### Public Immutable functions (getters) - -#### `balance(id: AssetId, who: T::AccountId) -> T::Balance` - -#### `total_supply(id: AssetId) -> T::Balance` - -### Public Mutable functions (changing state) - -#### `issue(origin, total: T::Balance)` - -#### `transfer(origin, id: AssetId, target: ::Source, amount: T::Balance)` - -#### `destroy(origin, id: AssetId)` - -### Events: - -#### `Issued(AssetId, AccountId, Balance)` - -#### `Transferred(AssetId, AccountId, AccountId, Balance)` - -#### `Destroyed(AssetId, AccountId, Balance)` - -## Usage - -The following example shows how to use the Asset Module in your custom module to query an account's asset holding, and query the total supply of an asset and an account's asset holding balance. - -**1. Import Asset Module and Types** - -Import the `assets` module and derive your custom module configuration traits from the `assets` module trait. - -```rust -use assets; - -pub trait Trait: assets::Trait { } -``` - -**2. Import Accounts** - -```rust -const ALICE: u64 = 1; -const BOB: u64 = 2; - -// Initial Asset ID is 0 -let initial_asset_id: u32 = >::next_asset_id(); -const FIXED_SUPPLY: u64 = 100; -``` - -**3. Issue a new Fungible Asset to an Account** - -Issue the `total` amount of a new class of fungible asset with a fixed supply of units to a signed sender's (`origin`) account (i.e. Alice) and trigger the `Issued` event that contains the generated `AssetId`. - -```rust ->::issue(Origin::signed(&ALICE), FIXED_SUPPLY); -``` - -**4. Transfer a Fungible Asset between Accounts** - -Transfer a signed sender's (i.e. Alice) account holding of an asset's `AssetId` to a `target` recipient account (i.e. Bob) using the public call `transfer`. It only triggers the `Transferred` event if the transfer is valid. - -```rust ->::transfer(Origin::signed(&ALICE), initial_asset_id, BOB, FIXED_SUPPLY); -``` - -**5. Destroy the Fungible Asset holding of an Account** - -Destroy a signed sender's (i.e. Alice) entire account holding of a fungible asset and trigger the `Destroyed` event if they have a non-zero balance. - -```rust ->::destroy(Origin::signed(&ALICE), initial_asset_id); -``` - -**6. Query the Fungible Asset holding of an Account** - -Query an account's holding balance (i.e. Alice) of a fungible asset by calling the asset module's `balance` function. - -```rust -let balance = >::balance(initial_asset_id, Origin::signed(&ALICE)); -``` - -**7. Query the Total Supply of a Fungible Asset** - -Query the total supply of a fungible asset that has been issued by calling the asset module's `total_supply` function. - -```rust -let total_supply = >::total_supply(initial_asset_id); -``` diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index ad78dd50855e0..118f802aee0b1 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -14,7 +14,156 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . +//! # Assets Module +//! +//! //! A simple, secure module for dealing with fungible assets. +//! +//! Run `cargo doc --package srml-assets --open` to view this module's documentation. +//! +//! ## Overview +//! +//! The assets module provides functionality for asset management of fungible asset classes with a fixed supply, including: +//! +//! * Asset Issuance +//! * Asset Transfer +//! * Asset Destruction +//! +//! To use it in your module, you need to implement the assets [`Trait`].
+//! The supported dispatchable functions are documented in the [`Call`] enum. +//! +//! ## Terminology +//! +//! - **Asset issuance:** The process of an account issuing a total fixed supply of a new asset class. +//! - **Asset transfer:** The process of an account transfering units of their holding of an asset to a recipient. +//! - **Asset destruction:** The process of an account destroying their entire holding of an asset. +//! - **Fungible asset:** An asset that may be interchanged into an identical equivalent. +//! - **Non-fungible asset:** An asset that is scarce and offers unique characteristics. +//! +//! ## Goals +//! +//! +//! +//! The assets system in Substrate is designed to achieve the following goals: +//! - It should be possible to create a unique fungible asset. +//! - It should be possible to issue fungible assets that are controlled by a cold wallet. +//! - It should be possible to transfer fungible assets between cold wallets. +//! - It should be possible to destroy a proportion of fungible assets that are controlled by a cold wallet. +//! +//! ## Interface +//! +//! ### Supported Origins +//! +//! **signed** - Used to issue, transfer, and destroy an asset holding. +//! +//! ### Types +//! +//! * `AssetId`: `u32` +//! +//! ### Dispatchable Functions ([`Call`]) +//! +//! * `issue` - Issues the total supply of a new fungible asset to the account of the caller of the function. +//! +//! * `transfer` - Transfers an `amount` of units of a fungible asset `id` from the balance of the sender's account (`origin`) that called the function to a `target` account. +//! +//! * `destroy` - Destroys the entire holding of a fungible asset `id` associated with the account that called the function from its total supply. +//! +//! Please refer to the [`Call`] enum and its associated variants for a detailed list of dispatchable functions. +//! +//! ### Public Functions ([`Module`]) +//! +//! +//! * `balance` - Get the asset `id` balance of `who`. +//! +//! * `total_supply` - Get the total supply of an asset `id`. +//! +//! Please refer to the [`Module`] enum for details of publicly available functions. +//! +//! +//! Note that when using the publicly exposed functions, you (the runtime developer) are responsible for implementing any necessary checks (e.g. that the sender is the signer) before calling a function that will affect storage. +//! +//! ### Storage Items: +//! +//! * Balances +//! +//! * NextAssetId +//! +//! * TotalSupply +//! +//! Please refer to the `decl_storage!` block in the Asset SRML source code for details of storage items. +//! +//! ### Events: +//! +//! * [`Issued`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) +//! +//! * [`Transferred`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) +//! +//! * [`Destroyed`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) +//! +//! Please refer to the [`RawEvent`] enum and its associated variants for a detailed list of events. +//! +//! ## Usage +//! +//! The following example shows how to use the Asset Module in your custom module by exposing public functions to: +//! - Issue a new fungible asset for a token distribution event (airdrop). +//! - Query the fungible asset holding balance of an account. +//! - Query the total supply of a fungible asset that has been issued. +//! +//! ### Prerequisites +//! +//! Import the `assets` module and types and derive your custom module configuration traits from the `assets` module trait. +//! +//! ### Simple Code Snippet +//! +//! +//! ```rust,ignore +//! use support::{decl_module, dispatch::Result}; +//! use system::ensure_signed; +//! +//! pub trait Trait: assets::Trait { } +//! +//! decl_module! { +//! pub struct Module for enum Call where origin: T::Origin { +//! pub fn get_time(origin) -> Result { +//! let _sender = ensure_signed(origin)?; +//! let _now = >::get(); +//! Ok(()) +//! } +//! +//! pub fn issue_token_airdrop(origin) -> Results { +//! const ACCOUNT_ALICE: u64 = 1; +//! const ACCOUNT_BOB: u64 = 2; +//! const COUNT_AIRDROP_RECIPIENTS = 2; +//! const TOKENS_FIXED_SUPPLY: u64 = 100; +//! let _sender = ensure_signed(origin)?; +//! let _asset_id = Self::next_asset_id(); +//! +//! >::mutate(|_asset_id| *_asset_id += 1); +//! >::insert((_asset_id, &ACCOUNT_ALICE), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); +//! >::insert((_asset_id, &ACCOUNT_BOB), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); +//! >::insert(_asset_id, TOKENS_FIXED_SUPPLY); +//! +//! Self::deposit_event(RawEvent::Issued(_asset_id, origin, TOKENS_FIXED_SUPPLY)); +//! Ok(()) +//! } +//! +//! pub fn get_balance(asset_id, who) -> Result { +//! let _balance = >::balance::get(asset_id, who); +//! Ok(()) +//! } +//! +//! pub fn get_total_supply(asset_id) -> Result { +//! let _total_supply = >::total_supply::get(asset_id); +//! Ok(()) +//! } +//! } +//! } +//! ``` +//! +//! ## Related Modules +//! +//! * [`System`](https://crates.parity.io/srml_system/index.html) +//! * [`Support`](https://crates.parity.io/srml_support/index.html) // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] @@ -23,6 +172,7 @@ use srml_support::{StorageValue, StorageMap, Parameter, decl_module, decl_event, use primitives::traits::{Member, SimpleArithmetic, Zero, StaticLookup}; use system::ensure_signed; +/// The module configuration trait pub trait Trait: system::Trait { /// The overarching event type. type Event: From> + Into<::Event>; @@ -96,6 +246,7 @@ decl_event!( } ); +/// BLAH decl_storage! { trait Store for Module as Assets { /// The number of units of assets held by any given account. From 93024da39797a18bad00bca34ebda48e12093780 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Wed, 20 Mar 2019 12:22:28 +0100 Subject: [PATCH 12/42] refactor: Consistent bullet points. Remove whitespace between items --- srml/assets/src/lib.rs | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 118f802aee0b1..7b6fd8850e287 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -34,21 +34,21 @@ //! //! ## Terminology //! -//! - **Asset issuance:** The process of an account issuing a total fixed supply of a new asset class. -//! - **Asset transfer:** The process of an account transfering units of their holding of an asset to a recipient. -//! - **Asset destruction:** The process of an account destroying their entire holding of an asset. -//! - **Fungible asset:** An asset that may be interchanged into an identical equivalent. -//! - **Non-fungible asset:** An asset that is scarce and offers unique characteristics. +//! * **Asset issuance:** The process of an account issuing a total fixed supply of a new asset class. +//! * **Asset transfer:** The process of an account transfering units of their holding of an asset to a recipient. +//! * **Asset destruction:** The process of an account destroying their entire holding of an asset. +//! * **Fungible asset:** An asset that may be interchanged into an identical equivalent. +//! * **Non-fungible asset:** An asset that is scarce and offers unique characteristics. //! //! ## Goals //! //! //! //! The assets system in Substrate is designed to achieve the following goals: -//! - It should be possible to create a unique fungible asset. -//! - It should be possible to issue fungible assets that are controlled by a cold wallet. -//! - It should be possible to transfer fungible assets between cold wallets. -//! - It should be possible to destroy a proportion of fungible assets that are controlled by a cold wallet. +//! * It should be possible to create a unique fungible asset. +//! * It should be possible to issue fungible assets that are controlled by a cold wallet. +//! * It should be possible to transfer fungible assets between cold wallets. +//! * It should be possible to destroy a proportion of fungible assets that are controlled by a cold wallet. //! //! ## Interface //! @@ -63,9 +63,7 @@ //! ### Dispatchable Functions ([`Call`]) //! //! * `issue` - Issues the total supply of a new fungible asset to the account of the caller of the function. -//! //! * `transfer` - Transfers an `amount` of units of a fungible asset `id` from the balance of the sender's account (`origin`) that called the function to a `target` account. -//! //! * `destroy` - Destroys the entire holding of a fungible asset `id` associated with the account that called the function from its total supply. //! //! Please refer to the [`Call`] enum and its associated variants for a detailed list of dispatchable functions. @@ -74,7 +72,6 @@ //! //! //! * `balance` - Get the asset `id` balance of `who`. -//! //! * `total_supply` - Get the total supply of an asset `id`. //! //! Please refer to the [`Module`] enum for details of publicly available functions. @@ -85,9 +82,7 @@ //! ### Storage Items: //! //! * Balances -//! //! * NextAssetId -//! //! * TotalSupply //! //! Please refer to the `decl_storage!` block in the Asset SRML source code for details of storage items. @@ -95,9 +90,7 @@ //! ### Events: //! //! * [`Issued`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) -//! //! * [`Transferred`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) -//! //! * [`Destroyed`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) //! //! Please refer to the [`RawEvent`] enum and its associated variants for a detailed list of events. @@ -105,9 +98,9 @@ //! ## Usage //! //! The following example shows how to use the Asset Module in your custom module by exposing public functions to: -//! - Issue a new fungible asset for a token distribution event (airdrop). -//! - Query the fungible asset holding balance of an account. -//! - Query the total supply of a fungible asset that has been issued. +//! * Issue a new fungible asset for a token distribution event (airdrop). +//! * Query the fungible asset holding balance of an account. +//! * Query the total supply of a fungible asset that has been issued. //! //! ### Prerequisites //! From 9d0c1bbb0f4ac18689837f8c74bb484805b9946e Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Sat, 23 Mar 2019 05:14:46 +0100 Subject: [PATCH 13/42] review-fix: Remove useless blah --- srml/assets/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 7b6fd8850e287..55f63787e1f56 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -239,7 +239,6 @@ decl_event!( } ); -/// BLAH decl_storage! { trait Store for Module as Assets { /// The number of units of assets held by any given account. From f8ffceef15a061a524a92a7117f0c470143de720 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Sun, 24 Mar 2019 15:27:42 +0100 Subject: [PATCH 14/42] review-fix: Remove Storage Items --- srml/assets/src/lib.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 55f63787e1f56..2f9a0c275f62d 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -79,14 +79,6 @@ //! //! Note that when using the publicly exposed functions, you (the runtime developer) are responsible for implementing any necessary checks (e.g. that the sender is the signer) before calling a function that will affect storage. //! -//! ### Storage Items: -//! -//! * Balances -//! * NextAssetId -//! * TotalSupply -//! -//! Please refer to the `decl_storage!` block in the Asset SRML source code for details of storage items. -//! //! ### Events: //! //! * [`Issued`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) From 4852b4df7bf54c6a4e26f7e63d0f8633ed9216af Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Sun, 24 Mar 2019 15:28:25 +0100 Subject: [PATCH 15/42] review-fix: Remove Types --- srml/assets/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 2f9a0c275f62d..add9ea123c1c1 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -56,10 +56,6 @@ //! //! **signed** - Used to issue, transfer, and destroy an asset holding. //! -//! ### Types -//! -//! * `AssetId`: `u32` -//! //! ### Dispatchable Functions ([`Call`]) //! //! * `issue` - Issues the total supply of a new fungible asset to the account of the caller of the function. From 0b63d4a6bfbb245b8578c3eb5d8c0fba2eeafea5 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Sun, 24 Mar 2019 15:29:07 +0100 Subject: [PATCH 16/42] review-fix: Remove duplicate instructions --- srml/assets/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index add9ea123c1c1..e60d572e0e1e0 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -19,8 +19,6 @@ //! //! A simple, secure module for dealing with fungible assets. //! -//! Run `cargo doc --package srml-assets --open` to view this module's documentation. -//! //! ## Overview //! //! The assets module provides functionality for asset management of fungible asset classes with a fixed supply, including: From 5979ba9f15243fb910ad3cd63705083d9d575893 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 14:54:06 +0100 Subject: [PATCH 17/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index e60d572e0e1e0..fc0f421c82f17 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -32,7 +32,7 @@ //! //! ## Terminology //! -//! * **Asset issuance:** The process of an account issuing a total fixed supply of a new asset class. +//! * **Asset issuance:** The creation of a new asset, whose total supply will belong to the account that issues the asset. //! * **Asset transfer:** The process of an account transfering units of their holding of an asset to a recipient. //! * **Asset destruction:** The process of an account destroying their entire holding of an asset. //! * **Fungible asset:** An asset that may be interchanged into an identical equivalent. From 372271f841820e55791261420d9dc384c32c0395 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 14:55:09 +0100 Subject: [PATCH 18/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index fc0f421c82f17..747847c065b1d 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -33,7 +33,7 @@ //! ## Terminology //! //! * **Asset issuance:** The creation of a new asset, whose total supply will belong to the account that issues the asset. -//! * **Asset transfer:** The process of an account transfering units of their holding of an asset to a recipient. +//! * **Asset transfer:** The action of transferring assets from one account to another. //! * **Asset destruction:** The process of an account destroying their entire holding of an asset. //! * **Fungible asset:** An asset that may be interchanged into an identical equivalent. //! * **Non-fungible asset:** An asset that is scarce and offers unique characteristics. From e53434d9740fa994a9eaf37cea5596fbc47473e0 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:00:09 +0100 Subject: [PATCH 19/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 747847c065b1d..ef6b0e04937c9 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -36,7 +36,7 @@ //! * **Asset transfer:** The action of transferring assets from one account to another. //! * **Asset destruction:** The process of an account destroying their entire holding of an asset. //! * **Fungible asset:** An asset that may be interchanged into an identical equivalent. -//! * **Non-fungible asset:** An asset that is scarce and offers unique characteristics. +//! * **Non-fungible asset:** An asset for which each unit has unique characteristics. //! //! ## Goals //! From 9bbd04ea26d33319cb4bd320e3df3c1f98d9f4af Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:05:25 +0100 Subject: [PATCH 20/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index ef6b0e04937c9..c9eb9cc7f49f0 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -34,7 +34,7 @@ //! //! * **Asset issuance:** The creation of a new asset, whose total supply will belong to the account that issues the asset. //! * **Asset transfer:** The action of transferring assets from one account to another. -//! * **Asset destruction:** The process of an account destroying their entire holding of an asset. +//! * **Asset destruction:** The process of an account removing its entire holding of an asset. //! * **Fungible asset:** An asset that may be interchanged into an identical equivalent. //! * **Non-fungible asset:** An asset for which each unit has unique characteristics. //! From 8814fc9cfb871050b9d0354be91e8f2eb02634a9 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:06:09 +0100 Subject: [PATCH 21/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index c9eb9cc7f49f0..32a0bfe9c1262 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -35,7 +35,7 @@ //! * **Asset issuance:** The creation of a new asset, whose total supply will belong to the account that issues the asset. //! * **Asset transfer:** The action of transferring assets from one account to another. //! * **Asset destruction:** The process of an account removing its entire holding of an asset. -//! * **Fungible asset:** An asset that may be interchanged into an identical equivalent. +//! * **Fungible asset:** An asset whose units are interchangeable. //! * **Non-fungible asset:** An asset for which each unit has unique characteristics. //! //! ## Goals From d335b65e94a79986c02fa5c27eb0af68bccba5cb Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:11:07 +0100 Subject: [PATCH 22/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 32a0bfe9c1262..1c1ab1133e65d 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -30,7 +30,7 @@ //! To use it in your module, you need to implement the assets [`Trait`].
//! The supported dispatchable functions are documented in the [`Call`] enum. //! -//! ## Terminology +//! ### Terminology //! //! * **Asset issuance:** The creation of a new asset, whose total supply will belong to the account that issues the asset. //! * **Asset transfer:** The action of transferring assets from one account to another. From e6e4391be455082fa8b20c08f4d3e4e5ef53a7a6 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:14:15 +0100 Subject: [PATCH 23/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 1c1ab1133e65d..ecd81eafd1663 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -46,7 +46,7 @@ //! * It should be possible to create a unique fungible asset. //! * It should be possible to issue fungible assets that are controlled by a cold wallet. //! * It should be possible to transfer fungible assets between cold wallets. -//! * It should be possible to destroy a proportion of fungible assets that are controlled by a cold wallet. +//! * It should be possible to destroy a portion of fungible assets that are controlled by a cold wallet. //! //! ## Interface //! From e0f123fb938cf299b2d229c683da0487e5c9deee Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:16:57 +0100 Subject: [PATCH 24/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index ecd81eafd1663..1a6f44d3add56 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -58,7 +58,7 @@ //! //! * `issue` - Issues the total supply of a new fungible asset to the account of the caller of the function. //! * `transfer` - Transfers an `amount` of units of a fungible asset `id` from the balance of the sender's account (`origin`) that called the function to a `target` account. -//! * `destroy` - Destroys the entire holding of a fungible asset `id` associated with the account that called the function from its total supply. +//! * `destroy` - Destroys the entire holding of a fungible asset `id` associated with the account that called the function. //! //! Please refer to the [`Call`] enum and its associated variants for a detailed list of dispatchable functions. //! From d9e4284a0976812c669a7ed5c5ed0dd585cbf055 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:19:10 +0100 Subject: [PATCH 25/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 1a6f44d3add56..a896db7ce0418 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -57,7 +57,7 @@ //! ### Dispatchable Functions ([`Call`]) //! //! * `issue` - Issues the total supply of a new fungible asset to the account of the caller of the function. -//! * `transfer` - Transfers an `amount` of units of a fungible asset `id` from the balance of the sender's account (`origin`) that called the function to a `target` account. +//! * `transfer` - Transfers an `amount` of units of fungible asset `id` from the balance of the function caller's account (`origin`) to a `target` account. //! * `destroy` - Destroys the entire holding of a fungible asset `id` associated with the account that called the function. //! //! Please refer to the [`Call`] enum and its associated variants for a detailed list of dispatchable functions. From b91d52ac4454042b418b192873731b1e1d90e2d4 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:20:00 +0100 Subject: [PATCH 26/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index a896db7ce0418..04049b46c6776 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -70,7 +70,7 @@ //! //! Please refer to the [`Module`] enum for details of publicly available functions. //! -//! +//! //! Note that when using the publicly exposed functions, you (the runtime developer) are responsible for implementing any necessary checks (e.g. that the sender is the signer) before calling a function that will affect storage. //! //! ### Events: From d71442457dbf29400cff539b00d2dcdf7af68c59 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:20:38 +0100 Subject: [PATCH 27/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 04049b46c6776..98358cbfb9774 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -83,7 +83,7 @@ //! //! ## Usage //! -//! The following example shows how to use the Asset Module in your custom module by exposing public functions to: +//! The following example shows how to use the Assets Module in your custom module by exposing public functions to: //! * Issue a new fungible asset for a token distribution event (airdrop). //! * Query the fungible asset holding balance of an account. //! * Query the total supply of a fungible asset that has been issued. From 75b04b1b7cf063f26547c0fe63cac3bedc65bdb6 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:24:59 +0100 Subject: [PATCH 28/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 98358cbfb9774..6443644f887b6 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -109,7 +109,7 @@ //! Ok(()) //! } //! -//! pub fn issue_token_airdrop(origin) -> Results { +//! pub fn issue_token_airdrop(origin) -> Result { //! const ACCOUNT_ALICE: u64 = 1; //! const ACCOUNT_BOB: u64 = 2; //! const COUNT_AIRDROP_RECIPIENTS = 2; From 8f2d0b9c6d287596348479dfeeb46c16a2a17f26 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:25:30 +0100 Subject: [PATCH 29/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 6443644f887b6..b4591dd8ab4cb 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -124,7 +124,7 @@ //! //! Self::deposit_event(RawEvent::Issued(_asset_id, origin, TOKENS_FIXED_SUPPLY)); //! Ok(()) -//! } +//! } //! //! pub fn get_balance(asset_id, who) -> Result { //! let _balance = >::balance::get(asset_id, who); From 31b8ad33f9696fde4b3c686f6eae028dcd84b8d0 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:26:09 +0100 Subject: [PATCH 30/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index b4591dd8ab4cb..0490a00efe577 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -112,7 +112,7 @@ //! pub fn issue_token_airdrop(origin) -> Result { //! const ACCOUNT_ALICE: u64 = 1; //! const ACCOUNT_BOB: u64 = 2; -//! const COUNT_AIRDROP_RECIPIENTS = 2; +//! const COUNT_AIRDROP_RECIPIENTS = 2; //! const TOKENS_FIXED_SUPPLY: u64 = 100; //! let _sender = ensure_signed(origin)?; //! let _asset_id = Self::next_asset_id(); From a2dab4de18cc037d178d6ffd86ad76f295b02d5e Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 25 Mar 2019 15:27:01 +0100 Subject: [PATCH 31/42] Update srml/assets/src/lib.rs Co-Authored-By: ltfschoen --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 0490a00efe577..b78a83894f358 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -127,7 +127,7 @@ //! } //! //! pub fn get_balance(asset_id, who) -> Result { -//! let _balance = >::balance::get(asset_id, who); +//! let _balance = >::balance::get(asset_id, who); //! Ok(()) //! } //! From 0a80973444a288b64d4deab4f8e6f64e2c4ab11c Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Mon, 25 Mar 2019 15:31:58 +0100 Subject: [PATCH 32/42] review-fix: Remove since will be replaced after macro expansion #2068 as per comment --- srml/assets/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index b78a83894f358..0c439e8e764df 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -211,9 +211,6 @@ decl_module! { } } -/// An event in this module. Events are simple means of reporting specific conditions and -/// circumstances that have happened that users, Dapps and/or chain explorers would find -/// interesting and otherwise difficult to detect. decl_event!( pub enum Event where ::AccountId, ::Balance { /// Some assets were issued. From cf3083e0f7b3b67ca670197085bf1000c0ccd4a1 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Mon, 25 Mar 2019 15:32:34 +0100 Subject: [PATCH 33/42] review-fix: Move Goals within overview --- srml/assets/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 0c439e8e764df..1ad6a7ba26691 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -38,7 +38,7 @@ //! * **Fungible asset:** An asset whose units are interchangeable. //! * **Non-fungible asset:** An asset for which each unit has unique characteristics. //! -//! ## Goals +//! ### Goals //! //! //! From 57f99cf7fc9cd576cffd9e29e7ad6523d0b6d750 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Mon, 25 Mar 2019 15:56:32 +0100 Subject: [PATCH 34/42] fix: Fix indentation --- srml/assets/src/lib.rs | 72 ++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 1ad6a7ba26691..ef01bb561ff1d 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -102,40 +102,44 @@ //! pub trait Trait: assets::Trait { } //! //! decl_module! { -//! pub struct Module for enum Call where origin: T::Origin { -//! pub fn get_time(origin) -> Result { -//! let _sender = ensure_signed(origin)?; -//! let _now = >::get(); -//! Ok(()) -//! } -//! -//! pub fn issue_token_airdrop(origin) -> Result { -//! const ACCOUNT_ALICE: u64 = 1; -//! const ACCOUNT_BOB: u64 = 2; -//! const COUNT_AIRDROP_RECIPIENTS = 2; -//! const TOKENS_FIXED_SUPPLY: u64 = 100; -//! let _sender = ensure_signed(origin)?; -//! let _asset_id = Self::next_asset_id(); -//! -//! >::mutate(|_asset_id| *_asset_id += 1); -//! >::insert((_asset_id, &ACCOUNT_ALICE), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); -//! >::insert((_asset_id, &ACCOUNT_BOB), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); -//! >::insert(_asset_id, TOKENS_FIXED_SUPPLY); -//! -//! Self::deposit_event(RawEvent::Issued(_asset_id, origin, TOKENS_FIXED_SUPPLY)); -//! Ok(()) -//! } -//! -//! pub fn get_balance(asset_id, who) -> Result { -//! let _balance = >::balance::get(asset_id, who); -//! Ok(()) -//! } -//! -//! pub fn get_total_supply(asset_id) -> Result { -//! let _total_supply = >::total_supply::get(asset_id); -//! Ok(()) -//! } -//! } +//! pub struct Module for enum Call where origin: T::Origin { +//! pub fn get_time(origin) -> Result { +//! let _sender = ensure_signed(origin)?; +//! let _now = >::get(); +//! Ok(()) +//! } +//! +//! pub fn issue_token_airdrop(origin) -> Result { +//! const ACCOUNT_ALICE: u64 = 1; +//! const ACCOUNT_BOB: u64 = 2; +//! const COUNT_AIRDROP_RECIPIENTS = 2; +//! const TOKENS_FIXED_SUPPLY: u64 = 100; +//! +//! +//! ensure!(!COUNT_AIRDROP_RECIPIENTS.is_zero(), "Divide by zero error."); +//! +//! let _sender = ensure_signed(origin)?; +//! let _asset_id = Self::next_asset_id(); +//! +//! >::mutate(|_asset_id| *_asset_id += 1); +//! >::insert((_asset_id, &ACCOUNT_ALICE), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); +//! >::insert((_asset_id, &ACCOUNT_BOB), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); +//! >::insert(_asset_id, TOKENS_FIXED_SUPPLY); +//! +//! Self::deposit_event(RawEvent::Issued(_asset_id, origin, TOKENS_FIXED_SUPPLY)); +//! Ok(()) +//! } +//! +//! pub fn get_balance(asset_id, who) -> Result { +//! let _balance = >::balance::get(asset_id, who); +//! Ok(()) +//! } +//! +//! pub fn get_total_supply(asset_id) -> Result { +//! let _total_supply = >::total_supply::get(asset_id); +//! Ok(()) +//! } +//! } //! } //! ``` //! From d7d65cffdcb4848c1f0603e947e97f415e9a853b Mon Sep 17 00:00:00 2001 From: joepetrowski Date: Mon, 1 Apr 2019 10:59:53 +0200 Subject: [PATCH 35/42] style and a few minor changes --- srml/assets/src/lib.rs | 137 ++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 70 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index a10456a46900d..39475c38e18d6 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -21,14 +21,16 @@ //! //! ## Overview //! -//! The assets module provides functionality for asset management of fungible asset classes with a fixed supply, including: +//! The assets module provides functionality for asset management of fungible asset classes +//! with a fixed supply, including: //! //! * Asset Issuance //! * Asset Transfer //! * Asset Destruction //! -//! To use it in your module, you need to implement the assets [`Trait`].
-//! The supported dispatchable functions are documented in the [`Call`] enum. +//! To use it in your module, you need to implement the assets [`Trait`](./trait.Trait.html). +//! +//! The supported dispatchable functions are documented in the [`Call`](./enum.Call.html) enum. //! //! ### Terminology //! @@ -42,25 +44,24 @@ //! //! //! -//! The assets system in Substrate is designed to achieve the following goals: -//! * It should be possible to create a unique fungible asset. -//! * It should be possible to issue fungible assets that are controlled by a cold wallet. -//! * It should be possible to transfer fungible assets between cold wallets. -//! * It should be possible to destroy a portion of fungible assets that are controlled by a cold wallet. -//! -//! ## Interface +//! The assets system in Substrate is designed to make the following possible: //! -//! ### Supported Origins +//! * Create a unique, fungible asset. +//! * Issue fungible assets that are controlled by a cold wallet. +//! * Transfer fungible assets between cold wallets. +//! * Destroy a portion of fungible assets that are controlled by a cold wallet. //! -//! **signed** - Used to issue, transfer, and destroy an asset holding. +//! ## Interface //! -//! ### Dispatchable Functions ([`Call`]) +//! ### Dispatchable Functions //! //! * `issue` - Issues the total supply of a new fungible asset to the account of the caller of the function. -//! * `transfer` - Transfers an `amount` of units of fungible asset `id` from the balance of the function caller's account (`origin`) to a `target` account. -//! * `destroy` - Destroys the entire holding of a fungible asset `id` associated with the account that called the function. -//! -//! Please refer to the [`Call`] enum and its associated variants for a detailed list of dispatchable functions. +//! * `transfer` - Transfers an `amount` of units of fungible asset `id` from the balance of +//! the function caller's account (`origin`) to a `target` account. +//! * `destroy` - Destroys the entire holding of a fungible asset `id` associated with the account +//! that called the function. +//! +//! Please refer to the [`Call`](./enum.Call.html) enum and its associated variants for documentation on each function. //! //! ### Public Functions ([`Module`]) //! @@ -68,29 +69,27 @@ //! * `balance` - Get the asset `id` balance of `who`. //! * `total_supply` - Get the total supply of an asset `id`. //! -//! Please refer to the [`Module`] enum for details of publicly available functions. -//! -//! -//! Note that when using the publicly exposed functions, you (the runtime developer) are responsible for implementing any necessary checks (e.g. that the sender is the signer) before calling a function that will affect storage. +//! Please refer to the [`Module`](./struct.Module.html) struct for details on publicly available functions. //! //! ### Events: //! -//! * [`Issued`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) -//! * [`Transferred`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) -//! * [`Destroyed`](https://crates.parity.io/srml_system/enum.RawEvent.html#variants) +//! * [`Issued`](../srml_system/enum.RawEvent.html#variants) +//! * [`Transferred`](../srml_system/enum.RawEvent.html#variants) +//! * [`Destroyed`](../srml_system/enum.RawEvent.html#variants) //! //! Please refer to the [`RawEvent`] enum and its associated variants for a detailed list of events. //! //! ## Usage //! -//! The following example shows how to use the Assets Module in your custom module by exposing public functions to: +//! The following example shows how to use the assets module in your custom module by exposing public functions to: +//! //! * Issue a new fungible asset for a token distribution event (airdrop). //! * Query the fungible asset holding balance of an account. //! * Query the total supply of a fungible asset that has been issued. //! //! ### Prerequisites //! -//! Import the `assets` module and types and derive your custom module configuration traits from the `assets` module trait. +//! Import the assets module and types and derive your custom module configuration traits from the assets module trait. //! //! ### Simple Code Snippet //! @@ -102,51 +101,50 @@ //! pub trait Trait: assets::Trait { } //! //! decl_module! { -//! pub struct Module for enum Call where origin: T::Origin { -//! pub fn get_time(origin) -> Result { -//! let _sender = ensure_signed(origin)?; -//! let _now = >::get(); -//! Ok(()) -//! } -//! -//! pub fn issue_token_airdrop(origin) -> Result { -//! const ACCOUNT_ALICE: u64 = 1; -//! const ACCOUNT_BOB: u64 = 2; -//! const COUNT_AIRDROP_RECIPIENTS = 2; -//! const TOKENS_FIXED_SUPPLY: u64 = 100; -//! -//! -//! ensure!(!COUNT_AIRDROP_RECIPIENTS.is_zero(), "Divide by zero error."); -//! -//! let _sender = ensure_signed(origin)?; -//! let _asset_id = Self::next_asset_id(); -//! -//! >::mutate(|_asset_id| *_asset_id += 1); -//! >::insert((_asset_id, &ACCOUNT_ALICE), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); -//! >::insert((_asset_id, &ACCOUNT_BOB), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); -//! >::insert(_asset_id, TOKENS_FIXED_SUPPLY); -//! -//! Self::deposit_event(RawEvent::Issued(_asset_id, origin, TOKENS_FIXED_SUPPLY)); -//! Ok(()) -//! } -//! -//! pub fn get_balance(asset_id, who) -> Result { -//! let _balance = >::balance::get(asset_id, who); -//! Ok(()) -//! } -//! -//! pub fn get_total_supply(asset_id) -> Result { -//! let _total_supply = >::total_supply::get(asset_id); -//! Ok(()) -//! } -//! } +//! pub struct Module for enum Call where origin: T::Origin { +//! pub fn get_time(origin) -> Result { +//! let _sender = ensure_signed(origin)?; +//! let _now = >::get(); +//! Ok(()) +//! } +//! +//! pub fn issue_token_airdrop(origin) -> Result { +//! const ACCOUNT_ALICE: u64 = 1; +//! const ACCOUNT_BOB: u64 = 2; +//! const COUNT_AIRDROP_RECIPIENTS = 2; +//! const TOKENS_FIXED_SUPPLY: u64 = 100; +//! +//! ensure!(!COUNT_AIRDROP_RECIPIENTS.is_zero(), "Divide by zero error."); +//! +//! let _sender = ensure_signed(origin)?; +//! let _asset_id = Self::next_asset_id(); +//! +//! >::mutate(|_asset_id| *_asset_id += 1); +//! >::insert((_asset_id, &ACCOUNT_ALICE), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); +//! >::insert((_asset_id, &ACCOUNT_BOB), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); +//! >::insert(_asset_id, TOKENS_FIXED_SUPPLY); +//! +//! Self::deposit_event(RawEvent::Issued(_asset_id, origin, TOKENS_FIXED_SUPPLY)); +//! Ok(()) +//! } +//! +//! pub fn get_balance(asset_id, who) -> Result { +//! let _balance = >::balance::get(asset_id, who); +//! Ok(()) +//! } +//! +//! pub fn get_total_supply(asset_id) -> Result { +//! let _total_supply = >::total_supply::get(asset_id); +//! Ok(()) +//! } +//! } //! } //! ``` //! //! ## Related Modules //! -//! * [`System`](https://crates.parity.io/srml_system/index.html) -//! * [`Support`](https://crates.parity.io/srml_support/index.html) +//! * [`System`](../srml_system/index.html) +//! * [`Support`](../srml_support/index.html) // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] @@ -155,7 +153,7 @@ use srml_support::{StorageValue, StorageMap, Parameter, decl_module, decl_event, use primitives::traits::{Member, SimpleArithmetic, Zero, StaticLookup}; use system::ensure_signed; -/// The module configuration trait +/// The module configuration trait. pub trait Trait: system::Trait { /// The overarching event type. type Event: From> + Into<::Event>; @@ -167,7 +165,6 @@ pub trait Trait: system::Trait { type AssetId = u32; decl_module! { - // Simple declaration of the `Module` type. Lets the macro know what its working on. pub struct Module for enum Call where origin: T::Origin { fn deposit_event() = default; /// Issue a new class of fungible assets. There are, and will only ever be, `total` @@ -232,7 +229,7 @@ decl_storage! { Balances: map (AssetId, T::AccountId) => T::Balance; /// The next asset identifier up for grabs. NextAssetId get(next_asset_id): AssetId; - /// The total unit supply of an asset + /// The total unit supply of an asset. TotalSupply: map AssetId => T::Balance; } } @@ -246,7 +243,7 @@ impl Module { >::get((id, who)) } - // Get the total supply of an asset `id` + /// Get the total supply of an asset `id`. pub fn total_supply(id: AssetId) -> T::Balance { >::get(id) } From 0c4dcb78163127d926a65cba8b811d09de361938 Mon Sep 17 00:00:00 2001 From: joepetrowski Date: Mon, 1 Apr 2019 11:15:30 +0200 Subject: [PATCH 36/42] remove Events --- srml/assets/src/lib.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 39475c38e18d6..d31c37b8f878e 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -71,14 +71,6 @@ //! //! Please refer to the [`Module`](./struct.Module.html) struct for details on publicly available functions. //! -//! ### Events: -//! -//! * [`Issued`](../srml_system/enum.RawEvent.html#variants) -//! * [`Transferred`](../srml_system/enum.RawEvent.html#variants) -//! * [`Destroyed`](../srml_system/enum.RawEvent.html#variants) -//! -//! Please refer to the [`RawEvent`] enum and its associated variants for a detailed list of events. -//! //! ## Usage //! //! The following example shows how to use the assets module in your custom module by exposing public functions to: From a3948e8e27233ca034c7bf002970046aa84e85ef Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Fri, 5 Apr 2019 10:04:33 +0200 Subject: [PATCH 37/42] capitalization --- srml/assets/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index d31c37b8f878e..aee2a2e794108 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -21,14 +21,14 @@ //! //! ## Overview //! -//! The assets module provides functionality for asset management of fungible asset classes +//! The Assets module provides functionality for asset management of fungible asset classes //! with a fixed supply, including: //! //! * Asset Issuance //! * Asset Transfer //! * Asset Destruction //! -//! To use it in your module, you need to implement the assets [`Trait`](./trait.Trait.html). +//! To use it in your runtime, you need to implement the assets [`Trait`](./trait.Trait.html). //! //! The supported dispatchable functions are documented in the [`Call`](./enum.Call.html) enum. //! @@ -41,7 +41,7 @@ //! * **Non-fungible asset:** An asset for which each unit has unique characteristics. //! //! ### Goals -//! +//! //! //! //! The assets system in Substrate is designed to make the following possible: @@ -63,7 +63,7 @@ //! //! Please refer to the [`Call`](./enum.Call.html) enum and its associated variants for documentation on each function. //! -//! ### Public Functions ([`Module`]) +//! ### Public Functions //! //! //! * `balance` - Get the asset `id` balance of `who`. @@ -73,7 +73,7 @@ //! //! ## Usage //! -//! The following example shows how to use the assets module in your custom module by exposing public functions to: +//! The following example shows how to use the Assets module in your runtime by exposing public functions to: //! //! * Issue a new fungible asset for a token distribution event (airdrop). //! * Query the fungible asset holding balance of an account. @@ -81,7 +81,7 @@ //! //! ### Prerequisites //! -//! Import the assets module and types and derive your custom module configuration traits from the assets module trait. +//! Import the Assets module and types and derive your runtime's configuration traits from the Assets module trait. //! //! ### Simple Code Snippet //! From 319d7632eb0c4eaa547d030202cfd8adfc5fb951 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Sat, 13 Apr 2019 21:18:20 +0200 Subject: [PATCH 38/42] docs: Reword the Goals to remove mention of cold wallets based on discussion with Joe --- srml/assets/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index aee2a2e794108..0195dc02e8200 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -46,10 +46,9 @@ //! //! The assets system in Substrate is designed to make the following possible: //! -//! * Create a unique, fungible asset. -//! * Issue fungible assets that are controlled by a cold wallet. -//! * Transfer fungible assets between cold wallets. -//! * Destroy a portion of fungible assets that are controlled by a cold wallet. +//! * Issue a unique asset to its creators' account. +//! * Move assets between accounts. +//! * Remove an accounts' balance of an asset from its total supply when requested by that accounts owner. //! //! ## Interface //! From 43345319152eaddbfc0a0a3ab743c78e78a5d610 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Mon, 15 Apr 2019 12:00:07 +0200 Subject: [PATCH 39/42] Wording --- srml/assets/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 0195dc02e8200..5036b16bbcc5a 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -46,9 +46,9 @@ //! //! The assets system in Substrate is designed to make the following possible: //! -//! * Issue a unique asset to its creators' account. +//! * Issue a unique asset to its creator's account. //! * Move assets between accounts. -//! * Remove an accounts' balance of an asset from its total supply when requested by that accounts owner. +//! * Remove an account's balance of an asset when requested by that account's owner and update the asset's total supply. //! //! ## Interface //! From ef9f20056464ea94dfd9df4566e49841c8622e7f Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 23 Apr 2019 19:53:16 +0200 Subject: [PATCH 40/42] Update lib.rs --- srml/assets/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 5036b16bbcc5a..78c6c9979d35a 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -15,7 +15,6 @@ // along with Substrate. If not, see . //! # Assets Module -//! //! //! A simple, secure module for dealing with fungible assets. //! From 0b754485746e0c3556e673385957d68ba4be9ea3 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 23 Apr 2019 19:54:31 +0200 Subject: [PATCH 41/42] Update lib.rs --- srml/assets/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 78c6c9979d35a..5527f6a2b0996 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -40,8 +40,6 @@ //! * **Non-fungible asset:** An asset for which each unit has unique characteristics. //! //! ### Goals -//! -//! //! //! The assets system in Substrate is designed to make the following possible: //! From 17094277e2f498f4098190d979a2c31d1f2d18bb Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 23 Apr 2019 19:56:39 +0200 Subject: [PATCH 42/42] Update lib.rs --- srml/assets/src/lib.rs | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 5527f6a2b0996..3f7c1b3efc153 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -80,7 +80,6 @@ //! Import the Assets module and types and derive your runtime's configuration traits from the Assets module trait. //! //! ### Simple Code Snippet -//! //! //! ```rust,ignore //! use support::{decl_module, dispatch::Result}; @@ -90,12 +89,6 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn get_time(origin) -> Result { -//! let _sender = ensure_signed(origin)?; -//! let _now = >::get(); -//! Ok(()) -//! } -//! //! pub fn issue_token_airdrop(origin) -> Result { //! const ACCOUNT_ALICE: u64 = 1; //! const ACCOUNT_BOB: u64 = 2; @@ -104,25 +97,15 @@ //! //! ensure!(!COUNT_AIRDROP_RECIPIENTS.is_zero(), "Divide by zero error."); //! -//! let _sender = ensure_signed(origin)?; -//! let _asset_id = Self::next_asset_id(); +//! let sender = ensure_signed(origin)?; +//! let asset_id = Self::next_asset_id(); //! -//! >::mutate(|_asset_id| *_asset_id += 1); -//! >::insert((_asset_id, &ACCOUNT_ALICE), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); -//! >::insert((_asset_id, &ACCOUNT_BOB), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); -//! >::insert(_asset_id, TOKENS_FIXED_SUPPLY); -//! -//! Self::deposit_event(RawEvent::Issued(_asset_id, origin, TOKENS_FIXED_SUPPLY)); -//! Ok(()) -//! } -//! -//! pub fn get_balance(asset_id, who) -> Result { -//! let _balance = >::balance::get(asset_id, who); -//! Ok(()) -//! } +//! >::mutate(|asset_id| *asset_id += 1); +//! >::insert((asset_id, &ACCOUNT_ALICE), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); +//! >::insert((asset_id, &ACCOUNT_BOB), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); +//! >::insert(asset_id, TOKENS_FIXED_SUPPLY); //! -//! pub fn get_total_supply(asset_id) -> Result { -//! let _total_supply = >::total_supply::get(asset_id); +//! Self::deposit_event(RawEvent::Issued(asset_id, sender, TOKENS_FIXED_SUPPLY)); //! Ok(()) //! } //! }