Skip to content

Commit

Permalink
Merge pull request #497 from graphprotocol/ariel/gns-ownership
Browse files Browse the repository at this point in the history
Transferrable subgraph ownership
  • Loading branch information
abarmat authored Dec 1, 2021
2 parents 2e84093 + a3aa132 commit acc3993
Show file tree
Hide file tree
Showing 12 changed files with 942 additions and 870 deletions.
Binary file not shown.
1 change: 1 addition & 0 deletions cli/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let allContracts = [
'GraphCurationToken',
'ServiceRegistry',
'Curation',
'SubgraphNFTDescriptor',
'GNS',
'Staking',
'RewardsManager',
Expand Down
15 changes: 15 additions & 0 deletions contracts/base/ISubgraphNFTDescriptor.sol
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);
}
38 changes: 38 additions & 0 deletions contracts/base/SubgraphNFT.sol
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);
}
}
23 changes: 23 additions & 0 deletions contracts/base/SubgraphNFTDescriptor.sol
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 "";
}
}
Loading

0 comments on commit acc3993

Please sign in to comment.