Skip to content

Commit

Permalink
add "UniformValue" events
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Oct 19, 2023
1 parent 4ceb226 commit 26ea0d7
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions EIPS/eip-7496.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ Trait values for non-fungible tokens are often stored offchain. This makes it di

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174.

Contracts implementing this EIP MUST include the events, getters, and setters as defined below, and MUST return `true` for [ERC-165](./eip-165.md) `supportsInterface` for `0x12345678(placeholder, to be set when finalized)`, the 4 byte `interfaceId` for this ERC.
Contracts implementing this EIP MUST include the events, getters, and setters as defined below, and MUST return `true` for [ERC-165](./eip-165.md) `supportsInterface` for `0xaf332f3e`, the 4 byte `interfaceId` for this ERC.

```solidity
interface IERC7496 {
interface IERC7496 is IERC165 {
/* Events */
event TraitUpdated(bytes32 indexed traitKey, uint256 tokenId, bytes32 traitValue);
event TraitUpdatedBulkRange(bytes32 indexed traitKey, uint256 fromTokenId, uint256 toTokenId, bytes32 traitValue);
event TraitUpdatedBulkList(bytes32 indexed traitKey, uint256[] tokenIds, bytes32 traitValue);
event TraitUpdatedRange(bytes32 indexed traitKey, uint256 fromTokenId, uint256 toTokenId);
event TraitUpdatedRangeUniformValue(bytes32 indexed traitKey, uint256 fromTokenId, uint256 toTokenId, bytes32 traitValue);
event TraitUpdatedList(bytes32 indexed traitKey, uint256[] tokenIds);
event TraitUpdatedListUniformValue(bytes32 indexed traitKey, uint256[] tokenIds, bytes32 traitValue);
event TraitMetadataURIUpdated();
/* Getters */
Expand Down Expand Up @@ -163,13 +165,19 @@ The `dataType` object MAY have a `valueMappings` object defined. If the `valueMa

### Events

Updating traits MUST either emit the `TraitUpdated`, `TraitUpdatedBulkRange` or `TraitUpdatedBulkList` event.
Updating traits MUST emit one of:

For the event `TraitUpdatedBulkRange`, the `fromTokenId` and `toTokenId` MUST be a consecutive range of tokens IDs and MUST be treated as an inclusive range.
- `TraitUpdated`
- `TraitUpdatedRange`
- `TraitUpdatedRangeUniformValue`
- `TraitUpdatedList`
- `TraitUpdatedListUniformValue`

For the event `TraitUpdatedBulkList`, the `tokenIds` MAY be in any order.
For the `Range` events, the `fromTokenId` and `toTokenId` MUST be a consecutive range of tokens IDs and MUST be treated as an inclusive range.

For `TraitUpdatedBulkRange` and `TraitUpdatedBulkList`, if the `traitValue` is the same for all updated tokens, it is RECOMMENDED to provide the `traitValue` so offchain indexers don't have to fetch each token ID and can more quickly process bulk updates. If the magic value `keccak256("FETCH_EACH_TRAIT_VALUE")` is provided then the indexers will fetch each token's value individually.
For the `List` events, the `tokenIds` MAY be in any order.

It is RECOMMENDED to use the `UniformValue` events when the trait value is uniform across all token ids, so offchain indexers can more quickly process bulk updates rather than fetching each trait value individually.

Updating the trait metadata URI MUST emit the event `TraitMetadataURIUpdated` so offchain indexers can be notified to query the contract for the latest changes via `getTraitMetadataURI()`.

Expand Down

0 comments on commit 26ea0d7

Please sign in to comment.