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): pallet + devnet runtime #339

Closed

Conversation

chungquantin
Copy link
Collaborator

@chungquantin chungquantin commented Oct 14, 2024

Description

Implement the runtime pallet pallet-api/nonfungibles for the #259. This implementation follows the discussed NFT spec with the forked pallet-nfts.

Linked PRs

Pallet: pallet-api/nonfungibles

  • Implement basic functionalities of the pallet-api/nonfungibles.
  • Configure pallet-nfts and pallet-api/nonfungibles to Test runtime in mock.rs
    • refactor: pallet tests of pallet-api/fungibles to use an updated Account instead of u8. (.e.g, account(ALICE))
  • pallet unit testing with pallet-nonfungibles.
  • Add non-fungibles feature to devnet. Merge this PR first: refactor: generic extension #218

@chungquantin chungquantin changed the title feat: add nonfungibles pallet implementation feat(devnet): add nonfungibles pallet implementation Oct 14, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 77.51310% with 472 lines in your changes missing coverage. Please review.

Project coverage is 71.63%. Comparing base (aff6408) to head (73f4994).

Files with missing lines Patch % Lines
pallets/nfts/src/weights.rs 7.18% 310 Missing ⚠️
pallets/api/src/nonfungibles/weights.rs 50.00% 64 Missing ⚠️
pallets/api/src/nonfungibles/mod.rs 72.72% 32 Missing and 13 partials ⚠️
pallets/api/src/mock.rs 8.69% 21 Missing ⚠️
pallets/nfts/src/features/approvals.rs 87.35% 3 Missing and 8 partials ⚠️
pallets/api/src/nonfungibles/benchmarking.rs 0.00% 5 Missing ⚠️
pallets/nfts/src/benchmarking.rs 80.95% 2 Missing and 2 partials ⚠️
runtime/devnet/src/config/api/mod.rs 96.15% 4 Missing ⚠️
pallets/api/src/nonfungibles/tests.rs 99.76% 1 Missing and 1 partial ⚠️
...lets/nfts/src/features/create_delete_collection.rs 80.00% 1 Missing and 1 partial ⚠️
... and 2 more
@@            Coverage Diff             @@
##             main     #339      +/-   ##
==========================================
+ Coverage   68.38%   71.63%   +3.24%     
==========================================
  Files          70       74       +4     
  Lines       11846    13495    +1649     
  Branches    11846    13495    +1649     
==========================================
+ Hits         8101     9667    +1566     
- Misses       3486     3545      +59     
- Partials      259      283      +24     
Files with missing lines Coverage Δ
pallets/nfts/src/common_functions.rs 84.61% <100.00%> (+4.61%) ⬆️
pallets/nfts/src/features/create_delete_item.rs 90.05% <100.00%> (+0.84%) ⬆️
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/assets.rs 100.00% <100.00%> (ø)
runtime/devnet/src/config/proxy.rs 0.00% <ø> (ø)
runtime/devnet/src/lib.rs 5.53% <ø> (ø)
pallets/api/src/nonfungibles/tests.rs 99.76% <99.76%> (ø)
...lets/nfts/src/features/create_delete_collection.rs 84.94% <80.00%> (+0.60%) ⬆️
pallets/nfts/src/features/transfer.rs 85.61% <89.47%> (+1.77%) ⬆️
... and 9 more

@chungquantin chungquantin changed the base branch from main to chungquantin/chore-pallet_nfts October 14, 2024 15:25
@chungquantin chungquantin force-pushed the chungquantin/feat-nonfungibles branch from 74ccaa7 to 8832470 Compare October 15, 2024 09:54
@chungquantin chungquantin changed the title feat(devnet): add nonfungibles pallet implementation feat(devnet): add nonfungibles runtime implementation Oct 17, 2024
@chungquantin chungquantin changed the title feat(devnet): add nonfungibles runtime implementation feat(nfts): add nonfungibles runtime implementation Oct 17, 2024
@chungquantin chungquantin self-assigned this Oct 22, 2024
@chungquantin chungquantin changed the title feat(nfts): add nonfungibles runtime implementation feat(api/nonfungibles): pallet + devnet runtime Nov 12, 2024
@chungquantin chungquantin force-pushed the chungquantin/feat-nonfungibles branch from d4c29fe to 507e7f8 Compare November 12, 2024 14:23
@chungquantin chungquantin changed the base branch from chungquantin/chore-pallet_nfts to chungquantin/fork-pallet_nfts November 13, 2024 02:44
@chungquantin chungquantin changed the base branch from chungquantin/fork-pallet_nfts to chungquantin/chore-fork_pallet_nfts November 13, 2024 10:40
@chungquantin chungquantin force-pushed the chungquantin/feat-nonfungibles branch from 032bb0c to 242e53b Compare November 13, 2024 10:45
@chungquantin chungquantin force-pushed the chungquantin/chore-fork_pallet_nfts branch from c69dd85 to b9fe4d8 Compare November 18, 2024 04:01
},
/// Details of a specified collection.
#[codec(index = 9)]
Collection(CollectionIdOf<T>),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

[NOT MENTIONED IN THE SPEC]

I added this Collection read query because I think it is necessary for the smart contract developer to get the details of the NFT collection.

Collection(CollectionIdOf<T>),
/// Next collection ID.
#[codec(index = 10)]
NextCollectionId,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

[NOT MENTIONED IN THE SPEC]

As discussed for the implementation of create pop-api method, we need this read to query and return from the pop-api contract method.

/// Details of a specified collection.
Collection(Option<CollectionDetailsFor<T>>),
/// Next collection ID.
NextCollectionId(Option<CollectionIdOf<T>>),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
NextCollectionId(Option<CollectionIdOf<T>>),
NextCollectionId(CollectionIdOf<T>),

If we suppose that T::CollectionId::initial_value() == 0, we could probably return a value instead of Option from this read.

/// - `approved` - The approval status of the collection item.
#[pallet::call_index(4)]
#[pallet::weight(
NftsWeightInfoOf::<T>::approve_transfer(item.is_some() as u32) +
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

[NOT MENTIONED IN THE SPEC]

The weight for the fn approve() method depends on branching logic determined by the states of approved and item. Refer to the updates in the benchmarking method for fn approve_transfer() and fn cancel_approval() to see these adjustments.

) -> DispatchResult {
let creator = ensure_signed(origin.clone())?;
// TODO: re-evaluate next collection id in nfts pallet. The `Incrementable` trait causes
// issues for setting it to xcm's `Location`. This can easily be done differently.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: re-evaluate next collection id in nfts pallet. The Incrementable trait cause issues for setting it to xcm's Location. This can easily be done differently.

Should this TODO be tackled in this PR?

chore: rename nfts instance

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

chore: rename nfts instance

fix(api/nonfungibles): pallet weight testing
…onfungibles' into chungquantin/feat-nonfungibles
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