-
Notifications
You must be signed in to change notification settings - Fork 3
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
Modify transfer in DomainToken #119
base: zns-zchain-final
Are you sure you want to change the base?
Changes from 19 commits
9254552
2f039d8
216448f
fccba5b
5c5a8c1
2661eae
ab0286b
9bc171a
511b248
d5ee145
203b90d
d6f3763
e9015ac
fbe4504
5831357
89232f2
dd8c2a7
46fd565
ddcdb97
96e6cc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
node: circleci/node@4.7.0 | ||
node: circleci/node@6.1.0 | ||
codecov: codecov/[email protected] | ||
|
||
defaults: &defaults | ||
working_directory: ~/repo | ||
docker: | ||
- image: cimg/node:18.20.3 | ||
- image: cimg/node:20.17.0 | ||
auth: | ||
username: $DOCKER_HUB_USERNAME | ||
password: $DOCKER_HUB_PASSWORD | ||
- image: mongo:7.0.0-rc5-jammy | ||
auth: | ||
username: $DOCKER_HUB_USERNAME | ||
password: $DOCKER_HUB_PASSWORD | ||
|
||
jobs: | ||
test and coverage: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,11 @@ abstract contract ZNSRoles { | |
*/ | ||
bytes32 public constant REGISTRAR_ROLE = keccak256("REGISTRAR_ROLE"); | ||
|
||
/** | ||
* @notice This role is here specifically for the ZNSDomainToken.sol contract | ||
*/ | ||
bytes32 public constant DOMAIN_TOKEN_ROLE = keccak256("DOMAIN_TOKEN_ROLE"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't we just use Registrar role for this? this way we don't need to upgrade all contracts just for this string... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually... we may have to upgrade all contracts anyway since they all have custom errors now... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's sort of a decision on the "proper" way this should be. It would definitely be the same effect to just assign the |
||
|
||
/** | ||
* @notice Executor can be here to future proof, if we need a new role | ||
* so we don't have to upgrade all contracts | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ pragma solidity 0.8.26; | |
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; | ||
import { IERC2981 } from "@openzeppelin/contracts/interfaces/IERC2981.sol"; | ||
|
||
|
||
interface IZNSDomainToken is IERC2981, IERC721 { | ||
|
||
/** | ||
|
@@ -26,12 +25,15 @@ interface IZNSDomainToken is IERC2981, IERC721 { | |
*/ | ||
event TokenURISet(uint256 indexed tokenId, string indexed tokenURI); | ||
|
||
error CallerNotOwner(); | ||
|
||
function initialize( | ||
address accessController, | ||
string calldata tokenName, | ||
string calldata tokenSymbol, | ||
address defaultRoyaltyReceiver, | ||
uint96 defaultRoyaltyFraction | ||
uint96 defaultRoyaltyFraction, | ||
address registry | ||
) external; | ||
|
||
function totalSupply() external view returns (uint256); | ||
|
@@ -55,11 +57,15 @@ interface IZNSDomainToken is IERC2981, IERC721 { | |
|
||
function setDefaultRoyalty(address receiver, uint96 royaltyFraction) external; | ||
|
||
function transferTokenFrom(address from, address to, uint256 tokenId) external; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe make a more clear name?... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I felt making it as close to the regular |
||
|
||
function setTokenRoyalty( | ||
uint256 tokenId, | ||
address receiver, | ||
uint96 royaltyFraction | ||
) external; | ||
|
||
function setRegistry(address registry_) external; | ||
|
||
function supportsInterface(bytes4 interfaceId) external view returns (bool); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,12 @@ pragma solidity 0.8.26; | |
|
||
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
import { ERC2981Upgradeable } from "@openzeppelin/contracts-upgradeable/token/common/ERC2981Upgradeable.sol"; | ||
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; | ||
import { ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; | ||
import { ERC721URIStorageUpgradeable } | ||
from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol"; | ||
import { IZNSDomainToken } from "./IZNSDomainToken.sol"; | ||
import { ARegistryWired } from "../registry/ARegistryWired.sol"; | ||
import { AAccessControlled } from "../access/AAccessControlled.sol"; | ||
|
||
|
||
|
@@ -20,6 +23,7 @@ contract ZNSDomainToken is | |
ERC721URIStorageUpgradeable, | ||
ERC2981Upgradeable, | ||
UUPSUpgradeable, | ||
ARegistryWired, | ||
IZNSDomainToken { | ||
|
||
/** | ||
|
@@ -51,11 +55,13 @@ contract ZNSDomainToken is | |
string memory name_, | ||
string memory symbol_, | ||
address defaultRoyaltyReceiver, | ||
uint96 defaultRoyaltyFraction | ||
uint96 defaultRoyaltyFraction, | ||
address registry_ | ||
) external override initializer { | ||
__ERC721_init(name_, symbol_); | ||
_setAccessController(accessController_); | ||
_setDefaultRoyalty(defaultRoyaltyReceiver, defaultRoyaltyFraction); | ||
_setRegistry(registry_); | ||
} | ||
|
||
/** | ||
|
@@ -160,6 +166,15 @@ contract ZNSDomainToken is | |
emit TokenRoyaltySet(tokenId, royaltyFraction); | ||
} | ||
|
||
/** | ||
* @notice Setter function for the `ZNSRegistry` address in state. | ||
* Only ADMIN in `ZNSAccessController` can call this function. | ||
* @param registry_ Address of the `ZNSRegistry` contract | ||
*/ | ||
function setRegistry(address registry_) public override(ARegistryWired, IZNSDomainToken) onlyAdmin { | ||
_setRegistry(registry_); | ||
} | ||
|
||
/** | ||
* @notice To allow for user extension of the protocol we have to | ||
* enable checking acceptance of new interfaces to ensure they are supported | ||
|
@@ -174,6 +189,37 @@ contract ZNSDomainToken is | |
return super.supportsInterface(interfaceId); | ||
} | ||
|
||
/** | ||
* @notice We override the standard transfer function to update the owner for both the `registry` and `token` | ||
* This non-standard transfer is to behave similarly to the default transfer that only updates the `token` | ||
* | ||
* @param from Owner of the token | ||
* @param to Address to send the token to | ||
* @param tokenId The token being transferred | ||
*/ | ||
function transferTokenFrom(address from, address to, uint256 tokenId) public override { | ||
super.transferFrom(from, to, tokenId); | ||
} | ||
|
||
/** | ||
* @notice Override the standard transferFrom function to update the owner for both the `registry` and `token` | ||
* | ||
* @dev See {IERC721-transferFrom} | ||
*/ | ||
function transferFrom( | ||
address from, | ||
address to, | ||
uint256 tokenId | ||
) public override(ERC721Upgradeable, IERC721) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm... what about all other transfer methods? there used to be 3 at least. those will not do what we want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Messaged you about this, but yes because the other two public |
||
// Transfer the token | ||
super.transferFrom(from, to, tokenId); | ||
|
||
// Update the registry | ||
// because `_transfer` already checks for `to == address(0)` we don't need to check it here | ||
// We `encodePacked` here to ensure that any values that result in leading zeros are converted correctly | ||
registry.updateDomainOwner(bytes32(abi.encodePacked(tokenId)), to); | ||
} | ||
|
||
/** | ||
* @notice Return the baseURI | ||
*/ | ||
|
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.
hmm.... this will require us to upgrade every single contract in ZNS for this change to work? is it possible to do this in a less invasive way?