-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(template_lib): improve API for extracting data from NFTs (#897)
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 --- - [x] None - [ ] Requires data directory to be deleted - [ ] Other - Please specify
- Loading branch information
Showing
6 changed files
with
123 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters