Skip to content

Commit c66614a

Browse files
committed
feat: update subgraph authorization policy to only allow the NFT owner to operate
1 parent 396d06b commit c66614a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

contracts/discovery/GNS.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ contract GNS is GNSV2Storage, GraphUpgradeable, IGNS, Multicall {
131131
* @dev Modifier that allows only a subgraph operator to be the caller
132132
*/
133133
modifier onlySubgraphAuth(uint256 _subgraphID) {
134-
require(_isApprovedOrOwner(msg.sender, _subgraphID), "GNS: Must be authorized");
134+
require(ownerOf(_subgraphID) == msg.sender, "GNS: Must be authorized");
135135
_;
136136
}
137137

test/gns.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ describe('GNS', () => {
641641
newSubgraph1.subgraphDeploymentID,
642642
newSubgraph1.versionMetadata,
643643
)
644-
await expect(tx).revertedWith('ERC721: operator query for nonexistent token')
644+
await expect(tx).revertedWith('ERC721: owner query for nonexistent token')
645645
})
646646

647647
it('reject if not the owner', async function () {
@@ -696,7 +696,7 @@ describe('GNS', () => {
696696
newSubgraph1.versionMetadata,
697697
)
698698
// NOTE: deprecate burns the Subgraph NFT, when someone wants to publish a new version it won't find it
699-
await expect(tx).revertedWith('ERC721: operator query for nonexistent token')
699+
await expect(tx).revertedWith('ERC721: owner query for nonexistent token')
700700
})
701701
})
702702

@@ -722,13 +722,13 @@ describe('GNS', () => {
722722
newSubgraph1.versionMetadata,
723723
)
724724
// NOTE: deprecate burns the Subgraph NFT, when someone wants to publish a new version it won't find it
725-
await expect(tx).revertedWith('ERC721: operator query for nonexistent token')
725+
await expect(tx).revertedWith('ERC721: owner query for nonexistent token')
726726
})
727727

728728
it('reject if the subgraph does not exist', async function () {
729729
const subgraphID = randomHexBytes(32)
730730
const tx = gns.connect(me.signer).deprecateSubgraph(subgraphID)
731-
await expect(tx).revertedWith('ERC721: operator query for nonexistent token')
731+
await expect(tx).revertedWith('ERC721: owner query for nonexistent token')
732732
})
733733

734734
it('reject deprecate if not the owner', async function () {

0 commit comments

Comments
 (0)