Skip to content
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

Transferrable subgraph ownership #497

Merged
merged 19 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
13a4149
feat: transferrable subgraphs using an NFT
abarmat Aug 30, 2021
396d06b
feat: add NFT descriptor for a subgraph
abarmat Oct 10, 2021
c152f48
fix: correct function doc
abarmat Oct 29, 2021
c66614a
feat: update subgraph authorization policy to only allow the NFT owne…
abarmat Oct 30, 2021
6ec4065
fix: correct typos
abarmat Oct 30, 2021
66d6e5e
refactor: use curator variable instead of msg.sender
abarmat Oct 30, 2021
321c29b
fix: validate nSignalToTokens reverting when subgraph is not published
abarmat Oct 30, 2021
3482568
fix: update the target deployment even if the Subgraph has never mint…
abarmat Nov 10, 2021
483add1
refactor: use SubgraphPublished event
abarmat Nov 10, 2021
237a26d
Merge pull request #520 from graphprotocol/audit/gns-ownership-n03
abarmat Dec 1, 2021
78b1e39
Merge pull request #521 from graphprotocol/audit/gns-ownership-n05
abarmat Dec 1, 2021
4d028de
Merge pull request #522 from graphprotocol/audit/gns-ownership-n01
abarmat Dec 1, 2021
2cf753f
Merge pull request #518 from graphprotocol/audit/gns-ownership-l01
abarmat Dec 1, 2021
6a86c16
Merge pull request #519 from graphprotocol/audit/gns-ownership-m01
abarmat Dec 1, 2021
af5f8a5
Merge pull request #523 from graphprotocol/audit/gns-ownership-x01
abarmat Dec 1, 2021
f31b65f
Merge pull request #524 from graphprotocol/audit/gns-ownership-x02
abarmat Dec 1, 2021
0719e54
chore: update deployment script to initialize the new GNS
abarmat Nov 10, 2021
1c15e48
docs: add audit report for transferrable subgraph
abarmat Dec 1, 2021
a3aa132
Merge branch 'dev' into ariel/gns-ownership
abarmat Dec 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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