-
Notifications
You must be signed in to change notification settings - Fork 17
Non-fungible contract according to erc-721 standard #7
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?
Non-fungible contract according to erc-721 standard #7
Conversation
|
Hey! Overall, looking good! I briefly looked over the code but at the moment, I'm unfamiliar with the erc-721 standard. Give me some time to look over that and pull this PR in locally and I can review on a more granular level. |
|
A few things I noticed whilst using the sct tool: see comments on files. |
| /// <summary> | ||
| /// A non fungible token contract. | ||
| /// </summary> | ||
| public class NonFungibleToken : SmartContract, INonFungibleToken, ISupportsInterface |
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.
Why are multiple files and interfaces on the smartcontract class not supported by sct? Hard to keep things reusable and structured otherwise. I can create an abstract base class but interfaces are way nicer to work with and are easily copied between projects.
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.
We tried to keep the amount of functionality minimal in the first iteration. I definitely hear what you're saying about the interfaces, this is something we could look into support for.
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.
What should I do about this now? Leave it out?
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.
Also look into namespaces, why can't that work if the class is public?
| if (this.PersistentState.IsContract(to)) | ||
| { | ||
| ITransferResult result = this.Call(to, 0, "OnNonFungibleTokenReceived", new object[] { this.Message.Sender, from, tokenId, data }, 0); | ||
| Assert(Convert.ToBoolean(result.ReturnValue)); |
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.
From SCT:
System.Convert is not supported so I also have no way of converting this with a system class.
Why does Call return an result.ReturnValue object which I can't cast in any way too a bool? I also don't have a generic type of any sorts to pass an assumed value.
I can also not cast to Nullable < bool > to resolve the compiler error I get thus making it pretty hard to work with.
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.
You should be able to cast it using (bool)result.ReturnValue.
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.
Done, see commit after this comment.
|
After some more changes, removing the namespace and the interfaces this now validates: |
| } | ||
| catch (Exception ex) | ||
| { | ||
| if (ex is InvalidCastException || ex is NullReferenceException) |
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.
try catching also not supported, well then, the framework can deal with it.
codingupastorm
left a comment
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.
Sorry this has taken me so long to have a look at, I wasn't even aware of it.
Looks great to me, can't fault it.
This pull request hopes to deliver a smart contract sample that implements the erc-721 standard as a stratis smart contract equivalent.
Notes:
and try it on a local testnet sidechain.