Skip to content

Commit

Permalink
yan
Browse files Browse the repository at this point in the history
  • Loading branch information
yanning committed Jul 25, 2022
1 parent 25f5ebb commit 7f2238f
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
30 changes: 15 additions & 15 deletions EIPS/eip-5327.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
eip: 5327
title: Rental NFT, 721 User And Expires And Level Extension
eip: 5334
title: 721 User And Expires And Level Extension
description: Add a time-limited role with restricted permissions to ERC-721 tokens.
author: Yan (@yan253319066)
discussions-to: https://ethereum-magicians.org/t/erc-721-user-and-expires-and-level-extension/10097
Expand Down Expand Up @@ -28,10 +28,10 @@ Furthermore, applications of this model (such as renting) often demand that user
The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY" and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

### Contract Interface
Solidity Interface with NatSpec & OpenZeppelin v4 Interfaces (also available at [IERC5327.sol](../assets/eip-5327/contracts/IERC5327.sol)):
Solidity Interface with NatSpec & OpenZeppelin v4 Interfaces (also available at [IERC5334.sol](../assets/eip-5334/contracts/IERC5334.sol)):

```solidity
interface IERC5327 {
interface IERC5334 {
// Logged when the user of a NFT is changed or expires and level is changed
/// @notice Emitted when the `user` of an NFT or the `expires` of the `user` is changed or the user `level` is changed
Expand Down Expand Up @@ -103,18 +103,18 @@ In addition, new functions introduced in this standard have many similarities wi
## Test Cases

### Test Contract
ERC5327Demo Implementation: [ERC5327Demo.sol](../assets/eip-5327/contracts/ERC5327Demo.sol)
ERC5334Demo Implementation: [ERC5334Demo.sol](../assets/eip-5334/contracts/ERC5334Demo.sol)

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;
import "./ERC5327.sol";
import "./ERC5334.sol";
contract ERC5327Demo is ERC5327 {
contract ERC5334Demo is ERC5334 {
constructor(string memory name, string memory symbol)
ERC5327(name,symbol)
ERC5334(name,symbol)
{
}
Expand All @@ -126,12 +126,12 @@ contract ERC5327Demo is ERC5327 {
```

### Test Code
[test.js](../assets/eip-5327/test/test.js)
[test.js](../assets/eip-5334/test/test.js)

```JavaScript
const { assert } = require("chai");

const ERC5327Demo = artifacts.require("ERC5327Demo");
const ERC5334Demo = artifacts.require("ERC5334Demo");

contract("test", async accounts => {

Expand All @@ -140,7 +140,7 @@ contract("test", async accounts => {
const Alice = accounts[0];
const Bob = accounts[1];

const instance = await ERC5327Demo.deployed("T", "T");
const instance = await ERC5334Demo.deployed("T", "T");
const demo = instance;

await demo.mint(1, Alice);
Expand Down Expand Up @@ -174,15 +174,15 @@ truffle test ./test/test.js
```

## Reference Implementation
ERC5327 Implementation: [ERC5327.sol](../assets/eip-5327/contracts/ERC5327.sol)
ERC5334 Implementation: [ERC5334.sol](../assets/eip-5334/contracts/ERC5334.sol)
```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "./IERC5327.sol";
import "./IERC5334.sol";
contract ERC5327 is ERC721, IERC5327 {
contract ERC5334 is ERC721, IERC5334 {
struct UserInfo
{
address user; // address of user role
Expand Down Expand Up @@ -243,7 +243,7 @@ contract ERC5327 is ERC721, IERC5327 {
/// @dev See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC5327).interfaceId || super.supportsInterface(interfaceId);
return interfaceId == type(IERC5334).interfaceId || super.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(
Expand Down
6 changes: 0 additions & 6 deletions assets/eip-5327/migrations/1_initial_migration.js

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions assets/eip-5327/README.md → assets/eip-5334/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# EIP-5327
EIP-5327 is an extension of ERC-721. It proposes an additional role **user** and a valid duration indicator **expires** and **level**. It allows users and developers manage the use right more simple and efficient.
# EIP-5334
EIP-5334 is an extension of ERC-721. It proposes an additional role **user** and a valid duration indicator **expires** and **level**. It allows users and developers manage the use right more simple and efficient.

### Tools
* [Visual Studio Code](https://code.visualstudio.com/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "./IERC5327.sol";
import "./IERC5334.sol";

contract ERC5327 is ERC721, IERC5327 {
contract ERC5334 is ERC721, IERC5334 {
struct UserInfo
{
address user; // address of user role
Expand Down Expand Up @@ -65,7 +65,7 @@ contract ERC5327 is ERC721, IERC5327 {

/// @dev See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC5327).interfaceId || super.supportsInterface(interfaceId);
return interfaceId == type(IERC5334).interfaceId || super.supportsInterface(interfaceId);
}

function _beforeTokenTransfer(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;

import "./ERC5327.sol";
import "./ERC5334.sol";

contract ERC5327Demo is ERC5327 {
contract ERC5334Demo is ERC5334 {

constructor(string memory name_, string memory symbol_)
ERC4907(name_,symbol_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.0;

interface IERC5327 {
interface IERC5334 {
// Logged when the user of a token assigns a new user or updates expires
/// @notice Emitted when the `user` of an NFT or the `expires` of the `user` is changed or the `level` of the `user` is changed
/// The zero address for user indicates that there is no user address
Expand Down
6 changes: 6 additions & 0 deletions assets/eip-5334/migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const ERC5334Demo = artifacts.require("ERC5334Demo");

module.exports = function (deployer) {
deployer.deploy(ERC5334Demo,'ERC5334Demo','ERC5334Demo');
};

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ERC-5327",
"name": "ERC-5334",
"version": "1.0.0",
"description": "",
"main": "truffle-config.js",
Expand Down
4 changes: 2 additions & 2 deletions assets/eip-5327/test/test.js → assets/eip-5334/test/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { assert } = require("chai");

const ERC5327Demo = artifacts.require("ERC5327Demo");
const ERC5334Demo = artifacts.require("ERC5334Demo");

contract("test", async accounts => {

Expand All @@ -9,7 +9,7 @@ contract("test", async accounts => {
const Alice = accounts[0];
const Bob = accounts[1];

const instance = await ERC5327Demo.deployed("T", "T");
const instance = await ERC5334Demo.deployed("T", "T");
const demo = instance;

await demo.mint(1, Alice);
Expand Down
File renamed without changes.

0 comments on commit 7f2238f

Please sign in to comment.