Skip to content

Commit acc3993

Browse files
authored
Merge pull request #497 from graphprotocol/ariel/gns-ownership
Transferrable subgraph ownership
2 parents 2e84093 + a3aa132 commit acc3993

File tree

12 files changed

+942
-870
lines changed

12 files changed

+942
-870
lines changed
Binary file not shown.

cli/commands/migrate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ let allContracts = [
2525
'GraphCurationToken',
2626
'ServiceRegistry',
2727
'Curation',
28+
'SubgraphNFTDescriptor',
2829
'GNS',
2930
'Staking',
3031
'RewardsManager',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
pragma solidity ^0.7.6;
4+
5+
import "../discovery/IGNS.sol";
6+
7+
/// @title Describes subgraph NFT tokens via URI
8+
interface ISubgraphNFTDescriptor {
9+
/// @notice Produces the URI describing a particular token ID for a Subgraph
10+
/// @dev Note this URI may be a data: URI with the JSON contents directly inlined
11+
/// @param _gns GNS contract that holds the Subgraph data
12+
/// @param _subgraphID The ID of the subgraph NFT for which to produce a description, which may not be valid
13+
/// @return The URI of the ERC721-compliant metadata
14+
function tokenURI(IGNS _gns, uint256 _subgraphID) external view returns (string memory);
15+
}

contracts/base/SubgraphNFT.sol

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
pragma solidity ^0.7.6;
4+
5+
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
6+
7+
import "./ISubgraphNFTDescriptor.sol";
8+
9+
abstract contract SubgraphNFT is ERC721Upgradeable {
10+
ISubgraphNFTDescriptor public tokenDescriptor;
11+
12+
// -- Events --
13+
14+
event TokenDescriptorUpdated(address tokenDescriptor);
15+
16+
// -- Functions --
17+
18+
/**
19+
* @dev Initializes the contract by setting a `name`, `symbol` and `descriptor` to the token collection.
20+
*/
21+
function __SubgraphNFT_init(address _tokenDescriptor) internal initializer {
22+
__ERC721_init("Subgraph", "SG");
23+
_setTokenDescriptor(address(_tokenDescriptor));
24+
}
25+
26+
/**
27+
* @dev Set the token descriptor contract used to create the ERC-721 metadata URI
28+
* @param _tokenDescriptor Address of the contract that creates the NFT token URI
29+
*/
30+
function _setTokenDescriptor(address _tokenDescriptor) internal {
31+
require(
32+
_tokenDescriptor != address(0) && AddressUpgradeable.isContract(_tokenDescriptor),
33+
"NFT: Invalid token descriptor"
34+
);
35+
tokenDescriptor = ISubgraphNFTDescriptor(_tokenDescriptor);
36+
emit TokenDescriptorUpdated(_tokenDescriptor);
37+
}
38+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
pragma solidity ^0.7.6;
4+
5+
import "./ISubgraphNFTDescriptor.sol";
6+
7+
/// @title Describes subgraph NFT tokens via URI
8+
contract SubgraphNFTDescriptor is ISubgraphNFTDescriptor {
9+
/// @inheritdoc ISubgraphNFTDescriptor
10+
function tokenURI(IGNS _gns, uint256 _subgraphID)
11+
external
12+
view
13+
override
14+
returns (string memory)
15+
{
16+
// TODO: fancy implementation
17+
// uint256 signal = _gns.subgraphSignal(_subgraphID);
18+
// uint256 tokens = _gns.subgraphTokens(_subgraphID);
19+
// id
20+
// owner
21+
return "";
22+
}
23+
}

0 commit comments

Comments
 (0)