-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #497 from graphprotocol/ariel/gns-ownership
Transferrable subgraph ownership
- Loading branch information
Showing
12 changed files
with
942 additions
and
870 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
pragma solidity ^0.7.6; | ||
|
||
import "../discovery/IGNS.sol"; | ||
|
||
/// @title Describes subgraph NFT tokens via URI | ||
interface ISubgraphNFTDescriptor { | ||
/// @notice Produces the URI describing a particular token ID for a Subgraph | ||
/// @dev Note this URI may be a data: URI with the JSON contents directly inlined | ||
/// @param _gns GNS contract that holds the Subgraph data | ||
/// @param _subgraphID The ID of the subgraph NFT for which to produce a description, which may not be valid | ||
/// @return The URI of the ERC721-compliant metadata | ||
function tokenURI(IGNS _gns, uint256 _subgraphID) external view returns (string memory); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
pragma solidity ^0.7.6; | ||
|
||
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; | ||
|
||
import "./ISubgraphNFTDescriptor.sol"; | ||
|
||
abstract contract SubgraphNFT is ERC721Upgradeable { | ||
ISubgraphNFTDescriptor public tokenDescriptor; | ||
|
||
// -- Events -- | ||
|
||
event TokenDescriptorUpdated(address tokenDescriptor); | ||
|
||
// -- Functions -- | ||
|
||
/** | ||
* @dev Initializes the contract by setting a `name`, `symbol` and `descriptor` to the token collection. | ||
*/ | ||
function __SubgraphNFT_init(address _tokenDescriptor) internal initializer { | ||
__ERC721_init("Subgraph", "SG"); | ||
_setTokenDescriptor(address(_tokenDescriptor)); | ||
} | ||
|
||
/** | ||
* @dev Set the token descriptor contract used to create the ERC-721 metadata URI | ||
* @param _tokenDescriptor Address of the contract that creates the NFT token URI | ||
*/ | ||
function _setTokenDescriptor(address _tokenDescriptor) internal { | ||
require( | ||
_tokenDescriptor != address(0) && AddressUpgradeable.isContract(_tokenDescriptor), | ||
"NFT: Invalid token descriptor" | ||
); | ||
tokenDescriptor = ISubgraphNFTDescriptor(_tokenDescriptor); | ||
emit TokenDescriptorUpdated(_tokenDescriptor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
pragma solidity ^0.7.6; | ||
|
||
import "./ISubgraphNFTDescriptor.sol"; | ||
|
||
/// @title Describes subgraph NFT tokens via URI | ||
contract SubgraphNFTDescriptor is ISubgraphNFTDescriptor { | ||
/// @inheritdoc ISubgraphNFTDescriptor | ||
function tokenURI(IGNS _gns, uint256 _subgraphID) | ||
external | ||
view | ||
override | ||
returns (string memory) | ||
{ | ||
// TODO: fancy implementation | ||
// uint256 signal = _gns.subgraphSignal(_subgraphID); | ||
// uint256 tokens = _gns.subgraphTokens(_subgraphID); | ||
// id | ||
// owner | ||
return ""; | ||
} | ||
} |
Oops, something went wrong.