Fair-Squares / fair-squares

Fair housing for all
http://www.fair-squares.nl
Apache License 2.0
16 stars 8 forks source link

Added a storage to track owners and their shares #183

Closed ndkazu closed 2 years ago

ndkazu commented 2 years ago

Added a new storage `Tokens = StorageMap< _, Blake2_128Concat, T::AccountId,
Owners, OptionQuery,

; it uses the virtual account to retrieve the structOwners. this struct contains the following fields: pub struct Owners {
pub owners: Vec<(T::AccountId,::Balance)>, ///Creation Blocknumber pub created: BlockNumberOf, ///TokenId pub token_id: ::AssetId, ///Total supply of tokens pub supply: ::Balance }` All related functions and tests have been updated.

This PR also solves a Round-down problem that occurs when calculating the number of tokens: Using Percent::from_rational will ALWAYS do a rounding-down, hence the missing tokens. Instead we use Percent::from_rational_with_rounding, which uses the closest value with a preference for rounding-up if we're at *.5

codecov-commenter commented 2 years ago

Codecov Report

Merging #183 (93e18b7) into main (4a98e40) will increase coverage by 0.16%. The diff coverage is 94.54%.

@@            Coverage Diff             @@
##             main     #183      +/-   ##
==========================================
+ Coverage   78.12%   78.28%   +0.16%     
==========================================
  Files          49       49              
  Lines        4388     4416      +28     
==========================================
+ Hits         3428     3457      +29     
+ Misses        960      959       -1     
Impacted Files Coverage Δ
pallets/share_distributor/src/mock.rs 87.50% <ø> (ø)
pallets/share_distributor/src/lib.rs 91.66% <75.00%> (+0.75%) :arrow_up:
pallets/share_distributor/src/functions.rs 93.33% <92.30%> (+3.58%) :arrow_up:
pallets/share_distributor/src/tests.rs 100.00% <100.00%> (ø)
pallets/share_distributor/src/types.rs 100.00% <100.00%> (ø)
pallets/nft/src/lib.rs 73.84% <0.00%> (-1.87%) :arrow_down:
pallets/onboarding/src/lib.rs 88.20% <0.00%> (-0.59%) :arrow_down:
pallets/housing_fund/src/lib.rs 90.90% <0.00%> (-0.21%) :arrow_down:

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