Skip to content

Commit 59735ef

Browse files
f: add extended interface
1 parent 2827f7f commit 59735ef

File tree

8 files changed

+41
-32
lines changed

8 files changed

+41
-32
lines changed

IndexingPaymentsTodo.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Still pending
22

3+
* Remove linter warnings
34
* Remove extension if I can fit everything in one service?
4-
* One Interface for all subgraph
55
* `require(provision.tokens != 0, DisputeManagerZeroTokens());` - Document or fix?
66
* Check code coverage
77
* Don't love cancel agreement on stop service / close stale allocation.
88
* Arbitration Charter: Update to support disputing IndexingFee.
99

1010
# Done
1111

12+
* DONE: ~~* One Interface for all subgraph~~
1213
* DONE: ~~* Missing Upgrade event for subgraph service~~
1314
* DONE: ~~* Check contract size~~
1415
* DONE: ~~Switch cancel event in recurring collector to use Enum~~

packages/subgraph-service/contracts/DisputeManager.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { IGraphToken } from "@graphprotocol/contracts/contracts/token/IGraphToke
55
import { IHorizonStaking } from "@graphprotocol/horizon/contracts/interfaces/IHorizonStaking.sol";
66
import { IDisputeManager } from "./interfaces/IDisputeManager.sol";
77
import { ISubgraphService } from "./interfaces/ISubgraphService.sol";
8-
import { ISubgraphServiceExtension } from "./interfaces/ISubgraphServiceExtension.sol";
8+
import { ISubgraphServiceExtended } from "./interfaces/ISubgraphServiceExtended.sol";
99

1010
import { TokenUtils } from "@graphprotocol/contracts/contracts/utils/TokenUtils.sol";
1111
import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol";
@@ -536,7 +536,7 @@ contract DisputeManager is
536536
uint256 _entities,
537537
uint256 _blockNumber
538538
) private returns (bytes32) {
539-
IndexingAgreement.AgreementWrapper memory wrapper = _getSubgraphServiceExtension().getIndexingAgreement(
539+
IndexingAgreement.AgreementWrapper memory wrapper = _getSubgraphServiceExtended().getIndexingAgreement(
540540
_agreementId
541541
);
542542

@@ -769,13 +769,13 @@ contract DisputeManager is
769769
}
770770

771771
/**
772-
* @notice Get the address of the subgraph service extension
772+
* @notice Get the address of the extended subgraph service
773773
* @dev Will revert if the subgraph service is not set
774-
* @return The subgraph service address
774+
* @return The extended subgraph service address
775775
*/
776-
function _getSubgraphServiceExtension() private view returns (ISubgraphServiceExtension) {
776+
function _getSubgraphServiceExtended() private view returns (ISubgraphServiceExtended) {
777777
require(address(subgraphService) != address(0), DisputeManagerSubgraphServiceNotSet());
778-
return ISubgraphServiceExtension(address(subgraphService));
778+
return ISubgraphServiceExtended(address(subgraphService));
779779
}
780780

781781
/**

packages/subgraph-service/contracts/SubgraphServiceExtension.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import { ProvisionManagerLib } from "@graphprotocol/horizon/contracts/data-servi
88

99
import { IndexingAgreement } from "./libraries/IndexingAgreement.sol";
1010
import { SubgraphService } from "./SubgraphService.sol";
11+
import { ISubgraphServiceExtension } from "./interfaces/ISubgraphServiceExtension.sol";
1112

12-
contract SubgraphServiceExtension is PausableUpgradeable {
13+
contract SubgraphServiceExtension is PausableUpgradeable, ISubgraphServiceExtension {
1314
using IndexingAgreement for IndexingAgreement.Manager;
1415

1516
modifier onlyValid(address indexer) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
pragma solidity 0.8.27;
3+
4+
import { ISubgraphService } from "./ISubgraphService.sol";
5+
import { ISubgraphServiceExtension } from "./ISubgraphServiceExtension.sol";
6+
7+
interface ISubgraphServiceExtended is ISubgraphService, ISubgraphServiceExtension {}

packages/subgraph-service/test/unit/subgraphService/indexing-agreement/base.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ contract SubgraphServiceIndexingAgreementBaseTest is SubgraphServiceIndexingAgre
1717

1818
vm.expectRevert(TransparentUpgradeableProxy.ProxyDeniedAdminAccess.selector);
1919
resetPrank(address(operator));
20-
_getSubgraphServiceExtension().cancelIndexingAgreement(indexer, agreementId);
20+
_getSubgraphServiceExtended().cancelIndexingAgreement(indexer, agreementId);
2121
}
2222

2323
function test_SubgraphService_Revert_WhenUnsafeAddress_WhenGraphProxyAdmin(uint256 unboundedTokens) public {

packages/subgraph-service/test/unit/subgraphService/indexing-agreement/cancel.t.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
2525

2626
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
2727
resetPrank(rando);
28-
_getSubgraphServiceExtension().cancelIndexingAgreementByPayer(agreementId);
28+
_getSubgraphServiceExtended().cancelIndexingAgreementByPayer(agreementId);
2929
}
3030

3131
function test_SubgraphService_CancelIndexingAgreementByPayer_Revert_WhenNotAuthorized(
@@ -42,7 +42,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
4242
);
4343
vm.expectRevert(expectedErr);
4444
resetPrank(rando);
45-
_getSubgraphServiceExtension().cancelIndexingAgreementByPayer(accepted.rca.agreementId);
45+
_getSubgraphServiceExtended().cancelIndexingAgreementByPayer(accepted.rca.agreementId);
4646
}
4747

4848
function test_SubgraphService_CancelIndexingAgreementByPayer_Revert_WhenNotAccepted(
@@ -58,7 +58,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
5858
agreementId
5959
);
6060
vm.expectRevert(expectedErr);
61-
_getSubgraphServiceExtension().cancelIndexingAgreementByPayer(agreementId);
61+
_getSubgraphServiceExtended().cancelIndexingAgreementByPayer(agreementId);
6262
}
6363

6464
function test_SubgraphService_CancelIndexingAgreementByPayer_Revert_WhenCanceled(
@@ -79,7 +79,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
7979
accepted.rca.agreementId
8080
);
8181
vm.expectRevert(expectedErr);
82-
_getSubgraphServiceExtension().cancelIndexingAgreementByPayer(accepted.rca.agreementId);
82+
_getSubgraphServiceExtended().cancelIndexingAgreementByPayer(accepted.rca.agreementId);
8383
}
8484

8585
function test_SubgraphService_CancelIndexingAgreementByPayer(Seed memory seed) public {
@@ -105,7 +105,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
105105

106106
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
107107
resetPrank(operator);
108-
_getSubgraphServiceExtension().cancelIndexingAgreement(indexer, agreementId);
108+
_getSubgraphServiceExtended().cancelIndexingAgreement(indexer, agreementId);
109109
}
110110

111111
function test_SubgraphService_CancelIndexingAgreement_Revert_WhenNotAuthorized(
@@ -121,7 +121,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
121121
operator
122122
);
123123
vm.expectRevert(expectedErr);
124-
_getSubgraphServiceExtension().cancelIndexingAgreement(indexer, agreementId);
124+
_getSubgraphServiceExtended().cancelIndexingAgreement(indexer, agreementId);
125125
}
126126

127127
function test_SubgraphService_CancelIndexingAgreement_Revert_WhenInvalidProvision(
@@ -142,7 +142,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
142142
maximumProvisionTokens
143143
);
144144
vm.expectRevert(expectedErr);
145-
_getSubgraphServiceExtension().cancelIndexingAgreement(indexer, agreementId);
145+
_getSubgraphServiceExtended().cancelIndexingAgreement(indexer, agreementId);
146146
}
147147

148148
function test_SubgraphService_CancelIndexingAgreement_Revert_WhenIndexerNotRegistered(
@@ -159,7 +159,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
159159
indexer
160160
);
161161
vm.expectRevert(expectedErr);
162-
_getSubgraphServiceExtension().cancelIndexingAgreement(indexer, agreementId);
162+
_getSubgraphServiceExtended().cancelIndexingAgreement(indexer, agreementId);
163163
}
164164

165165
function test_SubgraphService_CancelIndexingAgreement_Revert_WhenNotAccepted(
@@ -175,7 +175,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
175175
agreementId
176176
);
177177
vm.expectRevert(expectedErr);
178-
_getSubgraphServiceExtension().cancelIndexingAgreement(indexerState.addr, agreementId);
178+
_getSubgraphServiceExtended().cancelIndexingAgreement(indexerState.addr, agreementId);
179179
}
180180

181181
function test_SubgraphService_CancelIndexingAgreement_Revert_WhenCanceled(
@@ -196,7 +196,7 @@ contract SubgraphServiceIndexingAgreementCancelTest is SubgraphServiceIndexingAg
196196
accepted.rca.agreementId
197197
);
198198
vm.expectRevert(expectedErr);
199-
_getSubgraphServiceExtension().cancelIndexingAgreement(indexerState.addr, accepted.rca.agreementId);
199+
_getSubgraphServiceExtended().cancelIndexingAgreement(indexerState.addr, accepted.rca.agreementId);
200200
}
201201

202202
function test_SubgraphService_CancelIndexingAgreement_OK(Seed memory seed) public {

packages/subgraph-service/test/unit/subgraphService/indexing-agreement/shared.t.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { IRecurringCollector } from "@graphprotocol/horizon/contracts/interfaces
55
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
66

77
import { IndexingAgreement } from "../../../../contracts/libraries/IndexingAgreement.sol";
8-
import { ISubgraphServiceExtension } from "../../../../contracts/interfaces/ISubgraphServiceExtension.sol";
8+
import { ISubgraphServiceExtended } from "../../../../contracts/interfaces/ISubgraphServiceExtended.sol";
99

1010
import { Bounder } from "@graphprotocol/horizon/test/unit/utils/Bounder.t.sol";
1111
import { RecurringCollectorHelper } from "@graphprotocol/horizon/test/unit/payments/recurring-collector/RecurringCollectorHelper.t.sol";
@@ -110,10 +110,10 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun
110110

111111
if (byIndexer) {
112112
_subgraphServiceSafePrank(_indexer);
113-
_getSubgraphServiceExtension().cancelIndexingAgreement(_indexer, _agreementId);
113+
_getSubgraphServiceExtended().cancelIndexingAgreement(_indexer, _agreementId);
114114
} else {
115115
_subgraphServiceSafePrank(_ctx.payer.signer);
116-
_getSubgraphServiceExtension().cancelIndexingAgreementByPayer(_agreementId);
116+
_getSubgraphServiceExtended().cancelIndexingAgreementByPayer(_agreementId);
117117
}
118118
}
119119

@@ -309,8 +309,8 @@ contract SubgraphServiceIndexingAgreementSharedTest is SubgraphServiceTest, Boun
309309
);
310310
}
311311

312-
function _getSubgraphServiceExtension() internal view returns (ISubgraphServiceExtension) {
313-
return ISubgraphServiceExtension(address(subgraphService));
312+
function _getSubgraphServiceExtended() internal view returns (ISubgraphServiceExtended) {
313+
return ISubgraphServiceExtended(address(subgraphService));
314314
}
315315

316316
function _newAcceptIndexingAgreementMetadataV1(

packages/subgraph-service/test/unit/subgraphService/indexing-agreement/update.t.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA
2626

2727
resetPrank(operator);
2828
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
29-
_getSubgraphServiceExtension().updateIndexingAgreement(operator, signedRCAU);
29+
_getSubgraphServiceExtended().updateIndexingAgreement(operator, signedRCAU);
3030
}
3131

3232
function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenNotAuthorized(
@@ -42,7 +42,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA
4242
notAuthorized
4343
);
4444
vm.expectRevert(expectedErr);
45-
_getSubgraphServiceExtension().updateIndexingAgreement(indexer, signedRCAU);
45+
_getSubgraphServiceExtended().updateIndexingAgreement(indexer, signedRCAU);
4646
}
4747

4848
function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenInvalidProvision(
@@ -63,7 +63,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA
6363
maximumProvisionTokens
6464
);
6565
vm.expectRevert(expectedErr);
66-
_getSubgraphServiceExtension().updateIndexingAgreement(indexer, signedRCAU);
66+
_getSubgraphServiceExtended().updateIndexingAgreement(indexer, signedRCAU);
6767
}
6868

6969
function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenIndexerNotRegistered(
@@ -81,7 +81,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA
8181
indexer
8282
);
8383
vm.expectRevert(expectedErr);
84-
_getSubgraphServiceExtension().updateIndexingAgreement(indexer, signedRCAU);
84+
_getSubgraphServiceExtended().updateIndexingAgreement(indexer, signedRCAU);
8585
}
8686

8787
function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenNotAccepted(Seed memory seed) public {
@@ -98,7 +98,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA
9898
);
9999
vm.expectRevert(expectedErr);
100100
resetPrank(indexerState.addr);
101-
_getSubgraphServiceExtension().updateIndexingAgreement(indexerState.addr, acceptableUpdate);
101+
_getSubgraphServiceExtended().updateIndexingAgreement(indexerState.addr, acceptableUpdate);
102102
}
103103

104104
function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenNotAuthorizedForAgreement(
@@ -117,7 +117,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA
117117
);
118118
vm.expectRevert(expectedErr);
119119
resetPrank(indexerStateB.addr);
120-
_getSubgraphServiceExtension().updateIndexingAgreement(indexerStateB.addr, acceptableUpdate);
120+
_getSubgraphServiceExtended().updateIndexingAgreement(indexerStateB.addr, acceptableUpdate);
121121
}
122122

123123
function test_SubgraphService_UpdateIndexingAgreement_Revert_WhenInvalidMetadata(Seed memory seed) public {
@@ -139,7 +139,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA
139139
);
140140
vm.expectRevert(expectedErr);
141141
resetPrank(indexerState.addr);
142-
_getSubgraphServiceExtension().updateIndexingAgreement(indexerState.addr, unacceptableUpdate);
142+
_getSubgraphServiceExtended().updateIndexingAgreement(indexerState.addr, unacceptableUpdate);
143143
}
144144

145145
function test_SubgraphService_UpdateIndexingAgreement_OK(Seed memory seed) public {
@@ -164,7 +164,7 @@ contract SubgraphServiceIndexingAgreementUpgradeTest is SubgraphServiceIndexingA
164164
);
165165

166166
resetPrank(indexerState.addr);
167-
_getSubgraphServiceExtension().updateIndexingAgreement(indexerState.addr, acceptableUpdate);
167+
_getSubgraphServiceExtended().updateIndexingAgreement(indexerState.addr, acceptableUpdate);
168168
}
169169
/* solhint-enable graph/func-name-mixedcase */
170170
}

0 commit comments

Comments
 (0)