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

feat(api/nonfungibles): destroy collection witness data & weights #383

Conversation

chungquantin
Copy link
Collaborator

@chungquantin chungquantin commented Nov 14, 2024

Checklist

  • read weights and unit testing
  • ✅ fn destroy(): See the implementation breakdown below
  • ✅ fn approve_transfer(): Weight is adjusted to account for branch logic when item = None.
  • ✅ fn cancel_approval(): Weight is adjusted to account for branch logic when item = None.

destroy implementation breakdown

Pull requests add new fields to CollectionDetails as discussed here #335 (comment) for witnessing data on collection destroyed and correct weight calculation.

  • item_holders: Keep track of number of unique holders of the collection items. (Required for AccountBalance). Updated when:
    • Case 1 (Method: ✅ fn do_mint()): New collection item is minted which owned by the holder with account_balance = 0.
    • Case 2 (Method: ✅ fn do_burn()): Existing collection item is burnt which owned by the holder with account_balance = 1.
    • Case 3 (Method: ✅ fn do_transfer()): Existing collection item is transferred that reduces the balance of sender to 0 or increase the account balance of receiver from 0. (to 1)
  • allowances: Keep track of total number of allowances to spend the items within the collection. (Required for Allowances)
    • Case 1 (Method: ✅ fn do_approve_collection()): allowances is increased when the item is increased when a new Allowances record set.
    • Case 2 (Method: ✅ fn do_cancel_collection()): allowances is increased when the item is increased when an existing Allowances record removed.
    • Note: On transfer, the allowances field is not reset. It counts all the allowances made by all past owners and the current owner.

@chungquantin chungquantin changed the title feat(api/nonfungibles): destroy collection weights feat(api/nonfungibles): add new CollectionDetails fields to handle destroy collection weights Nov 14, 2024
@chungquantin chungquantin changed the title feat(api/nonfungibles): add new CollectionDetails fields to handle destroy collection weights feat(api/nonfungibles): add new CollectionDetails fields to handle destroy collection Nov 14, 2024
@chungquantin chungquantin changed the title feat(api/nonfungibles): add new CollectionDetails fields to handle destroy collection feat(api/nonfungibles): destroy collection witness data & weights Nov 14, 2024
@chungquantin chungquantin self-assigned this Nov 14, 2024
@chungquantin chungquantin force-pushed the chugnquantin/feat-nonfungibles/destroy_collection_weights branch from 159f245 to c7d0c35 Compare November 14, 2024 07:16
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 94.87179% with 6 lines in your changes missing coverage. Please review.

Project coverage is 70.87%. Comparing base (242e53b) to head (a78d717).

Files with missing lines Patch % Lines
pallets/nfts/src/features/approvals.rs 77.77% 0 Missing and 4 partials ⚠️
...lets/nfts/src/features/create_delete_collection.rs 75.00% 1 Missing and 1 partial ⚠️
@@                        Coverage Diff                         @@
##           chungquantin/feat-nonfungibles     #383      +/-   ##
==================================================================
+ Coverage                           70.40%   70.87%   +0.47%     
==================================================================
  Files                                  73       72       -1     
  Lines                               12921    12970      +49     
  Branches                            12921    12970      +49     
==================================================================
+ Hits                                 9097     9193      +96     
+ Misses                               3548     3496      -52     
- Partials                              276      281       +5     
Files with missing lines Coverage Δ
pallets/api/src/nonfungibles/tests.rs 100.00% <100.00%> (ø)
pallets/nfts/src/common_functions.rs 84.61% <100.00%> (+0.94%) ⬆️
pallets/nfts/src/features/create_delete_item.rs 90.05% <100.00%> (+0.49%) ⬆️
pallets/nfts/src/features/transfer.rs 85.61% <100.00%> (+0.83%) ⬆️
pallets/nfts/src/lib.rs 71.94% <ø> (ø)
pallets/nfts/src/tests.rs 99.89% <100.00%> (+<0.01%) ⬆️
pallets/nfts/src/types.rs 67.54% <100.00%> (+0.43%) ⬆️
runtime/devnet/src/config/api/mod.rs 90.07% <100.00%> (+0.44%) ⬆️
runtime/devnet/src/config/assets.rs 100.00% <ø> (ø)
...lets/nfts/src/features/create_delete_collection.rs 83.87% <75.00%> (-0.84%) ⬇️
... and 1 more

@chungquantin chungquantin merged commit 5dccecb into chungquantin/feat-nonfungibles Nov 16, 2024
11 of 13 checks passed
@chungquantin chungquantin deleted the chugnquantin/feat-nonfungibles/destroy_collection_weights branch November 16, 2024 10:53
chungquantin added a commit that referenced this pull request Nov 17, 2024
chore: rename nfts instance

feat(api/nonfungibles): destroy collection witness data & weights (#383)

chore: rename nfts instance

fix(api/nonfungibles): pallet weight testing
chungquantin added a commit that referenced this pull request Nov 18, 2024
chore: rename nfts instance

feat(api/nonfungibles): destroy collection witness data & weights (#383)

chore: rename nfts instance

fix(api/nonfungibles): pallet weight testing
chungquantin added a commit that referenced this pull request Nov 19, 2024
chore: rename nfts instance

feat(api/nonfungibles): destroy collection witness data & weights (#383)

chore: rename nfts instance

fix(api/nonfungibles): pallet weight testing
chungquantin added a commit that referenced this pull request Nov 19, 2024
chore: rename nfts instance

feat(api/nonfungibles): destroy collection witness data & weights (#383)

chore: rename nfts instance

fix(api/nonfungibles): pallet weight testing
chungquantin added a commit that referenced this pull request Nov 19, 2024
chore: rename nfts instance

feat(api/nonfungibles): destroy collection witness data & weights (#383)

chore: rename nfts instance

fix(api/nonfungibles): pallet weight testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants