Skip to content
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

add contract_metadata_update event #423

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions specs/Standards/Tokens/NonFungibleToken/Event.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ Extension of [NEP-297](../../EventsFormat.md)

## Motivation

NEAR and third-party applications need to track `mint`, `transfer`, `burn` events for all NFT-driven apps consistently.
NEAR and third-party applications need to track `mint`, `transfer`, `burn` and `contract_metadata_update` events for all NFT-driven apps consistently.
This extension addresses that.

Keep in mind that applications, including NEAR Wallet, could require implementing additional methods to display the NFTs correctly, such as [`nft_metadata`](Metadata.md) and [`nft_tokens_for_owner`](Enumeration.md).

## Interface

Non-Fungible Token Events MUST have `standard` set to `"nep171"`, standard version set to `"1.0.0"`, `event` value is one of `nft_mint`, `nft_burn`, `nft_transfer`, and `data` must be of one of the following relavant types: `NftMintLog[] | NftTransferLog[] | NftBurnLog[]`:
Non-Fungible Token Events MUST have `standard` set to `"nep171"`, standard version set to `"1.0.0"`, `event` value is one of `nft_mint`, `nft_burn`, `nft_transfer`, `contract_metadata_update`, and `data` must be of one of the following relavant types: `NftMintLog[] | NftTransferLog[] | NftBurnLog[] | NftContractMetadataUpdateLog[]`:

```ts
interface NftEventLogData {
standard: "nep171",
version: "1.0.0",
version: "1.1.0",
event: "nft_mint" | "nft_burn" | "nft_transfer",
data: NftMintLog[] | NftTransferLog[] | NftBurnLog[],
data: NftMintLog[] | NftTransferLog[] | NftBurnLog[] | NftContractMetadataUpdateLog[],
}
```

Expand Down Expand Up @@ -66,6 +66,13 @@ interface NftTransferLog {
token_ids: string[],
memo?: string
}

// An event log to capture contract metadata updates. Note that the updated contract metadata is not included in the log, as it could easily exceed the 16KB log size limit. Listeners can query `nft_metadata` to get the updated contract metadata.
// Arguments
// * `memo`: optional message
interface NftContractMetadataUpdateLog {
lachlanglen marked this conversation as resolved.
Show resolved Hide resolved
memo?: string
}
```

## Examples
Expand All @@ -75,7 +82,7 @@ Single owner batch minting (pretty-formatted for readability purposes):
```js
EVENT_JSON:{
"standard": "nep171",
"version": "1.0.0",
"version": "1.1.0",
"event": "nft_mint",
"data": [
{"owner_id": "foundation.near", "token_ids": ["aurora", "proximitylabs"]}
Expand All @@ -88,7 +95,7 @@ Different owners batch minting:
```js
EVENT_JSON:{
"standard": "nep171",
"version": "1.0.0",
"version": "1.1.0",
"event": "nft_mint",
"data": [
{"owner_id": "foundation.near", "token_ids": ["aurora", "proximitylabs"]},
Expand All @@ -102,7 +109,7 @@ Different events (separate log entries):
```js
EVENT_JSON:{
"standard": "nep171",
"version": "1.0.0",
"version": "1.1.0",
"event": "nft_burn",
"data": [
{"owner_id": "foundation.near", "token_ids": ["aurora", "proximitylabs"]},
Expand All @@ -113,7 +120,7 @@ EVENT_JSON:{
```js
EVENT_JSON:{
"standard": "nep171",
"version": "1.0.0",
"version": "1.1.0",
"event": "nft_transfer",
"data": [
{"old_owner_id": "user1.near", "new_owner_id": "user2.near", "token_ids": ["meme"], "memo": "have fun!"}
Expand All @@ -126,20 +133,31 @@ Authorized id:
```js
EVENT_JSON:{
"standard": "nep171",
"version": "1.0.0",
"version": "1.1.0",
"event": "nft_burn",
"data": [
{"owner_id": "owner.near", "token_ids": ["goodbye", "aurevoir"], "authorized_id": "thirdparty.near"}
]
}
```

Contract metadata update:

```js
EVENT_JSON:{
"standard": "nep171",
"version": "1.1.0",
lachlanglen marked this conversation as resolved.
Show resolved Hide resolved
"event": "contract_metadata_update",
"data": []
}
```

## Further methods

Note that the example events covered above cover two different kinds of events:
1. Events that are not specified in the NFT Standard (`nft_mint`, `nft_burn`)
1. Events that are not specified in the NFT Standard (`nft_mint`, `nft_burn`, `contract_metadata_update`)
2. An event that is covered in the [NFT Core Standard](Core.md). (`nft_transfer`)

This event standard also applies beyond the three events highlighted here, where future events follow the same convention of as the second type. For instance, if an NFT contract uses the [approval management standard](ApprovalManagement.md), it may emit an event for `nft_approve` if that's deemed as important by the developer community.
This event standard also applies beyond the four events highlighted here, where future events follow the same convention of as the second type. For instance, if an NFT contract uses the [approval management standard](ApprovalManagement.md), it may emit an event for `nft_approve` if that's deemed as important by the developer community.

Please feel free to open pull requests for extending the events standard detailed here as needs arise.