-
Notifications
You must be signed in to change notification settings - Fork 1k
Add NFT to TokenManagement #4365
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
base: master
Are you sure you want to change the base?
Conversation
| { | ||
| Notify(engine, "NFTTransfer", uniqueId, from, to); | ||
| if (!callOnPayment || to is null || !ContractManagement.IsContract(engine.SnapshotCache, to)) return; | ||
| await engine.CallFromNativeContractAsync(Hash, to, "onNFTPayment", uniqueId, from, data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if the NFT creator wants to implement royalty, it will use this callback, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a callback to the receiver contract.
| if (nft.Owner != from) return false; | ||
| if (!engine.CheckWitnessInternal(from)) return false; | ||
| StorageKey key = CreateStorageKey(Prefix_TokenState, nft.AssetId); | ||
| TokenState token = engine.SnapshotCache.TryGet(key)!.GetInteroperable<TokenState>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| TokenState token = engine.SnapshotCache.TryGet(key)!.GetInteroperable<TokenState>(); | |
| TokenState token = engine.SnapshotCache.TryGet(key)!.GetInteroperable<TokenState>(); | |
| if (token.Type != TokenType.NonFungible) | |
| throw new InvalidOperationException("The asset id and the token type do not match"); |
Should not add a check like the fungible case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need. It is obtained through nft.AssetId.
| /// </summary> | ||
| /// <param name="integer">The integer value to set.</param> | ||
| public void Set(BigInteger integer) | ||
| public BigInteger Set(BigInteger integer) |
There was a problem hiding this comment.
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
| [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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assetId is not checked
| 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return new StorageIterator(enumerator, 21, options); | |
| return new StorageIterator(enumerator, Prefix_NFTOwnerUniqueIdIndex, options); |
Description
Add NFT to TokenManagement
Type of change
How Has This Been Tested?
Checklist: