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(template_lib): improve API for extracting data from NFTs #897

Merged
merged 5 commits into from
Jan 16, 2024

Conversation

mrnaveira
Copy link
Collaborator

Description

  • Added new get_non_fungibles method to vaults and buckets in template_lib, that returns all the NonFungible objects contained within.
  • Added new engine operations to support the new method in both vaults and buckets

Motivation and Context

We expect templates to often read NFT data from buckets or vaults. Currently the only way to do it is doing something like:

 let seller_badge_id = &seller_badge_bucket.get_non_fungible_ids()[0];
 let seller_badge = ResourceManager::get(self.seller_badge_resource).get_non_fungible(&seller_badge_id);
 let nft_metadata = seller_badge.get_data::<Metadata>();

This PR adds a new method get_non_fungibles to vaults and buckets to we can write the previous example as:

 let seller_badge = seller_badge_bucket.get_non_fungibles()[0];
 let nft_metadata = seller_badge.get_mutable_data::<Metadata>();

How Has This Been Tested?

New unit test in the engine crate for the new methods

What process can a PR reviewer use to test or verify this change?

Call the new methods inside a template

Breaking Changes

  • None
  • Requires data directory to be deleted
  • Other - Please specify

@mrnaveira mrnaveira changed the title feat(template_lib): Improve API for extracting data from NFTs feat(template_lib): improve API for extracting data from NFTs Jan 15, 2024
Copy link

github-actions bot commented Jan 15, 2024

Test Results (CI)

195 tests  +1   195 ✅ +1   1h 25m 9s ⏱️ - 17m 40s
 52 suites ±0     0 💤 ±0 
  2 files   ±0     0 ❌ ±0 

Results for commit 1c60c30. ± Comparison against base commit 63a1563.

♻️ This comment has been updated with latest results.

Copy link
Member

@sdbondi sdbondi left a comment

Choose a reason for hiding this comment

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

utACK

@sdbondi sdbondi added this pull request to the merge queue Jan 16, 2024
Merged via the queue into tari-project:development with commit 33283f8 Jan 16, 2024
10 checks passed
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.

3 participants