Skip to content
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

156 share distributor tokens #157

Merged
merged 9 commits into from
Sep 22, 2022
Merged

156 share distributor tokens #157

merged 9 commits into from
Sep 22, 2022

Conversation

ndkazu
Copy link
Contributor

@ndkazu ndkazu commented Sep 19, 2022

Motivation

Two helpers functions were added to:

  • Collect the list of the NFT owners and their contribution to the bid in pallet housing_fund
  • Create token class/Mint 100 tokens to the virtual account

Suggested Solution

  • 1 Storage Value TokenId storing u32, and initialised at 0. it is tracking the Assets class ID
  • In Runtime implementation of share_distributor, 'type AssetId = u32` was added in order to apply the advice received on stackexchange ==> https://substrate.stackexchange.com/questions/2857/how-do-i-hardcode-asset-ids
  • In type.rs the token_id field was added to struct Ownership with the type <T as pallet::Config>::AssetId
  • In functions.rs, 2 functions:
  1. fn owner_and_shares(collection_id,item_id) -> owner_and_shares(collection_id: T::NftCollectionId, item_id: T::NftItemId) -> Vec<(T::AccountId, f64)>
  2. fn create_tokens(origin: OriginFor<T>, account: T::AccountId)

In the next step tokens distribution to the owners by the virtual account will be implemented.

@ndkazu ndkazu added the enhancement New feature or request label Sep 19, 2022
@ndkazu ndkazu added this to the M3 milestone Sep 19, 2022
@ndkazu ndkazu self-assigned this Sep 19, 2022
@ndkazu ndkazu linked an issue Sep 19, 2022 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Sep 19, 2022

Codecov Report

Merging #157 (4e77d0a) into main (f028948) will decrease coverage by 0.13%.
The diff coverage is 87.20%.

@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
- Coverage   70.58%   70.45%   -0.14%     
==========================================
  Files          49       49              
  Lines        3424     3503      +79     
==========================================
+ Hits         2417     2468      +51     
- Misses       1007     1035      +28     
Impacted Files Coverage Δ
pallets/share_distributor/src/mock.rs 75.00% <ø> (+6.25%) ⬆️
runtime/src/lib.rs 7.40% <ø> (ø)
pallets/share_distributor/src/lib.rs 15.38% <50.00%> (-79.62%) ⬇️
pallets/share_distributor/src/functions.rs 88.57% <85.45%> (-11.43%) ⬇️
pallets/share_distributor/src/tests.rs 100.00% <100.00%> (ø)
pallets/share_distributor/src/types.rs 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ndkazu ndkazu closed this Sep 21, 2022
@ndkazu ndkazu reopened this Sep 21, 2022
Copy link
Contributor

@letodunc letodunc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job. A good variable naming act as a comment. Try to do it in the code.

pub fn owner_and_shares(collection_id: T::NftCollectionId, item_id: T::NftItemId) -> Vec<(T::AccountId, Percent)>{

//Get owners and their reserved contribution to the bid
let infos = HousingFund::Reservations::<T>::get((collection_id,item_id)).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a test to ensure that the (collection_id, item_id) is present in the storage before the unwrap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

collection_id and item_id are parameters passed by the bidding pallet to the share_distributor pallet.


//Get owners and their reserved contribution to the bid
let infos = HousingFund::Reservations::<T>::get((collection_id,item_id)).unwrap();
let vec0 = infos.contributions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give name more meaningful names

pallets/share_distributor/src/functions.rs Show resolved Hide resolved
pallets/share_distributor/src/functions.rs Show resolved Hide resolved
pallets/share_distributor/src/functions.rs Outdated Show resolved Hide resolved
@ndkazu ndkazu merged commit 83febc5 into main Sep 22, 2022
@ndkazu ndkazu deleted the 156-share_distributor-tokens branch September 22, 2022 10:57
cuteolaf pushed a commit to cuteolaf/fair-squares that referenced this pull request Oct 7, 2022
…ibutor-tokens

156 share distributor tokens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Share_Distributor Tokens
3 participants