Skip to content

Conversation

@erikzhang
Copy link
Member

Description

Add NFT to TokenManagement

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit Testing
  • Run Application
  • Local Computer Tests
  • No Testing

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@github-actions github-actions bot added the N4 label Dec 5, 2025
/// </summary>
/// <param name="integer">The integer value to set.</param>
public void Set(BigInteger integer)
public BigInteger Set(BigInteger integer)
Copy link
Member

Choose a reason for hiding this comment

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

This can be void as before, just return the sum in the Add method

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

[ContractMethod(CpuFee = 1 << 17, StorageFee = 1 << 10, RequiredCallFlags = CallFlags.All)]
internal async Task<UInt160> MintNFT(ApplicationEngine engine, UInt160 assetId, UInt160 account, Map properties)
{
if (properties.Count > 8)
Copy link
Member

Choose a reason for hiding this comment

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

assetId is not checked

Copy link
Member Author

Choose a reason for hiding this comment

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

const FindOptions options = FindOptions.KeysOnly | FindOptions.RemovePrefix;
var prefixKey = CreateStorageKey(Prefix_NFTOwnerUniqueIdIndex, account);
var enumerator = snapshot.Find(prefixKey).GetEnumerator();
return new StorageIterator(enumerator, 21, options);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return new StorageIterator(enumerator, 21, options);
return new StorageIterator(enumerator, Prefix_NFTOwnerUniqueIdIndex, options);

Copy link
Member Author

Choose a reason for hiding this comment

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

21 is the prefix length to be removed.

Comment on lines 139 to 144
engine.SnapshotCache.Add(key, new(new NFTState
{
AssetId = assetId,
Owner = account,
Properties = properties
}));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
engine.SnapshotCache.Add(key, new(new NFTState
{
AssetId = assetId,
Owner = account,
Properties = properties
}));
var storageItem = new StorageItem(new NFTState
{
AssetId = assetId,
Owner = account,
Properties = properties
});
storageItem.Seal(); // Seal immediately to prevent post-validation mutations
engine.SnapshotCache.Add(key, storageItem);

Copy link
Member

Choose a reason for hiding this comment

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

properties can be changed. We need Seal() for storageItem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants