-
Notifications
You must be signed in to change notification settings - Fork 143
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: add NFT mint/transfer/burn event standard #256
Conversation
Hey, I feel that we should define our standards to be as slim as possible. This standard extension still makes sense, but from what I have heard, there are too many ways of how tokens can be minted/burned, so it feels that those cannot be limited to just certain method names (it can be implemented that way, but it might just feel unnatural. As per my #254 (comment), I feel there are just 3 high-level scenarios that need to be standardized:
Batch operations are great, but I would keep them an extension. I find this current proposal to be quite complicated in terms of the interface, and at the same time, it might limit some other use-cases. Batch interfaces are not required by any of the listed scenarios, and while it might address my concerns about observability, I have heard that it is not realistic to expect people to create workarounds with cross-contract calls just to make sure to have a call with Thus, I suggest we discuss the observability in #254 and consider if these interfaces still need to be defined. |
just commenting here to ask if approval makes sense as an event @frol @evergreen-trading-systems, then downstream subscribers like app market places know when approval changes. They could just subscribe to the events when the approval happens. Otherwise they'd need to poll the chain. I think revocation isn't as important because if you're going to make tx assuming revocation, can just do an The erc-721 event is :
I think we'd need approval_id, approved_account , owner, token_id . Although approval_id is not strictly necessary. I see this more as an ability for listening systems to be able to respond to approvals. What do you all think? I think for #245 we're looking at the same thing. |
@zcstarr Maybe no This whole need for event logs started because different people had different ways of doing the same thing and the wallet only displayed certain formats. The 3 main things every NFT marketplace is doing and already being logged are
but only in a specific format so not every marketplace are seeing their transactions on the wallet. That's why |
My thinking on With regards to events in general, Implementers are always going to do things differently and in unexpected places. Events are the proper tool to share knowledge about contract state changes in a uniform way, while allowing developers the freedom to write their contracts in the ways that make sense for their use case. |
I agree with you @zcstarr . Anything that is useful to index should have an event. Currently, the only implementors active in this conversation are the wallet developers. They are concerned with the 3 events like I said. Others may concerned with others. I see the need for 2 prs
This separates the concern of events only being useful to wallet indexers and starts to be useful for all kinds of indexers. I will make the pr. |
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.
Thanks for the patience, will rally other folks now.
Co-authored-by: Mike Purvis <[email protected]>
Co-authored-by: Mike Purvis <[email protected]>
Co-authored-by: Mike Purvis <[email protected]>
Co-authored-by: Mike Purvis <[email protected]>
Co-authored-by: Mike Purvis <[email protected]>
Co-authored-by: Mike Purvis <[email protected]>
## Motivation | ||
|
||
NFT-driven apps such as marketplaces regularly perform many | ||
of the same actions such as `minting`, `burning` and `transferring`. |
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.
It's better to write one sentence per line
https://asciidoctor.org/docs/asciidoc-recommended-practices/#one-sentence-per-line
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.
Even though I like the ascii docs I don't agree here because in markdown a line break continues a paragraph which helps word wrapping. Asciidocs are not a standard that governs markdown files. To comply I will update.
If this is the standard of NEPs can we make it official.
Co-authored-by: Mike Purvis <[email protected]>
Added @mikedotexe I must have forgotten. Approval events and others will be separate prs. This is ready to merge. |
Co-authored-by: Olga Telezhnaya <[email protected]>
Co-authored-by: Olga Telezhnaya <[email protected]>
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.
I believe this document is good enough to be merged. It addresses the observability problem for Indexers to pick up the information about common NFT operations.
interface EventJsonLog { | ||
// Takes `EventLogData` and returns | ||
// `EVENT_JSON: <EVENT_LOG_DATA>` | ||
(e:EventLogData):string |
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.
It's important to mention here that string representation of json should not contain line breaks (Ideally: get rid of all space symbols unless they are in string fields).
When Indexer parses these lines, for each line, it just cuts off "EVENT_JSON:", trims everything else, and passes the result into json parsing library.
If you pass
EVENT_JSON: {
"my_valid_json": true
}
It will give an error because there are 3 lines instead of 1, where the first line contains invalid json, second and third lines do not start from "EVENT_JSON:".
We also need to decide, are we OK with other messages here (without "EVENT_JSON:" at the beginning). We need to say explicitly in the NEP, whether we ignore or restrict them
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.
Are we sure that we don't want to put everything into json with the structure like
{
"type": "event_json",
"data": [...] // here could be all events
}
?
It simplifies everything, we don't need to overcomplicate this doc, Indexer does not need the logic with cutting/trimming.
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.
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.
@telezhnaya Individual calls to near_sdk::env::log
are recorded as individual strings in the logs
array of the execution outcome, so we don't care about new lines inside. We only want to specify that each event should be a separate call to the log host function.
Proof: https://explorer.testnet.near.org/transactions/326HmzvgRYND7skVCdTpCnHMji6qiU8JFhQMNuvS2b74
Contract:
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::{near_bindgen, setup_alloc};
setup_alloc!();
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, Default)]
pub struct Test {}
#[near_bindgen]
impl Test {
pub fn test_log(&mut self) {
near_sdk::env::log(r#"EVENT_JSON:{
"standard": "nep",
"version": "1.0.0",
"event": "mint",
"data": [
{"owner_id": "frol.near", "token_ids": ["house"]}
]
}"#.as_bytes());
near_sdk::env::log("EVENT_JSON:{\"standard\": \"nep\", \n \"version\": \"1.0.0\", \n \"event\": \"burn\", \"data\": [{\"owner_id\": \"frol.near\", \"token_ids\": [\"house\"]}]}".as_bytes());
}
}
@evergreen-trading-systems Please, review my latest commit (I wanted to make a proposed change, but it was really hard to read, so I decided to commit it (if that is too much, we can always revert the commit) |
Thanks @frol your changes made this document much more concise. 1 question. Is it true you can have a valid event log without data field i.e. |
I don't have any strong opinion about it, but I feel that it is fine to allow it being optional (hence |
Cool makes sense. There is no strong need for it to be now so agree with case-by-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.
Thank you @evergreen-trading-systems and @frol, great job!
There is no Event NEP yet, so this standard paves the road to that. | ||
|
||
Events use standard logs capability of NEAR and defined as a convention. | ||
Events are log entries that start with `EVENT_JSON:` prefix followed by a single valid JSON document of the following interface: |
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.
I like this, sounds much clearer!
Co-authored-by: Mike Purvis <[email protected]>
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.
Great work everyone
No description provided.