Skip to content

Commit 7dee19f

Browse files
f: rename Manager to StorageManager
1 parent 4c5573f commit 7dee19f

File tree

3 files changed

+45
-27
lines changed

3 files changed

+45
-27
lines changed

packages/subgraph-service/contracts/SubgraphService.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ contract SubgraphService is
4949
using Allocation for mapping(address => Allocation.State);
5050
using Allocation for Allocation.State;
5151
using TokenUtils for IGraphToken;
52-
using IndexingAgreement for IndexingAgreement.Manager;
52+
using IndexingAgreement for IndexingAgreement.StorageManager;
5353

5454
/**
5555
* @notice Checks that an indexer is registered
@@ -419,7 +419,7 @@ contract SubgraphService is
419419
onlyValidProvision(signedRCA.rca.serviceProvider)
420420
onlyRegisteredIndexer(signedRCA.rca.serviceProvider)
421421
{
422-
IndexingAgreement._getManager().accept(_allocations, allocationId, signedRCA);
422+
IndexingAgreement._getStorageManager().accept(_allocations, allocationId, signedRCA);
423423
}
424424

425425
/**
@@ -443,7 +443,7 @@ contract SubgraphService is
443443
onlyValidProvision(indexer)
444444
onlyRegisteredIndexer(indexer)
445445
{
446-
IndexingAgreement._getManager().update(indexer, signedRCAU);
446+
IndexingAgreement._getStorageManager().update(indexer, signedRCAU);
447447
}
448448

449449
/**
@@ -469,7 +469,7 @@ contract SubgraphService is
469469
onlyValidProvision(indexer)
470470
onlyRegisteredIndexer(indexer)
471471
{
472-
IndexingAgreement._getManager().cancel(indexer, agreementId);
472+
IndexingAgreement._getStorageManager().cancel(indexer, agreementId);
473473
}
474474

475475
/**
@@ -485,13 +485,13 @@ contract SubgraphService is
485485
* @param agreementId The id of the agreement
486486
*/
487487
function cancelIndexingAgreementByPayer(bytes16 agreementId) external whenNotPaused {
488-
IndexingAgreement._getManager().cancelByPayer(agreementId);
488+
IndexingAgreement._getStorageManager().cancelByPayer(agreementId);
489489
}
490490

491491
function getIndexingAgreement(
492492
bytes16 agreementId
493493
) external view returns (IndexingAgreement.AgreementWrapper memory) {
494-
return IndexingAgreement._getManager().get(agreementId);
494+
return IndexingAgreement._getStorageManager().get(agreementId);
495495
}
496496

497497
/// @inheritdoc ISubgraphService
@@ -554,7 +554,7 @@ contract SubgraphService is
554554
}
555555

556556
function _cancelAllocationIndexingAgreement(address _allocationId) internal {
557-
IndexingAgreement._getManager().cancelForAllocation(_allocationId);
557+
IndexingAgreement._getStorageManager().cancelForAllocation(_allocationId);
558558
}
559559

560560
/**
@@ -739,7 +739,7 @@ contract SubgraphService is
739739
* @return The amount of fees collected
740740
*/
741741
function _collectIndexingFees(bytes16 _agreementId, bytes memory _data) private returns (uint256) {
742-
(address indexer, uint256 tokensCollected) = IndexingAgreement._getManager().collect(
742+
(address indexer, uint256 tokensCollected) = IndexingAgreement._getStorageManager().collect(
743743
_allocations,
744744
IndexingAgreement.CollectParams({
745745
agreementId: _agreementId,

packages/subgraph-service/contracts/libraries/IndexingAgreement.sol

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { SubgraphServiceLib } from "./SubgraphServiceLib.sol";
1212
import { Decoder } from "./Decoder.sol";
1313

1414
library IndexingAgreement {
15-
using IndexingAgreement for Manager;
15+
using IndexingAgreement for StorageManager;
1616
using Allocation for mapping(address => Allocation.State);
1717
using SubgraphServiceLib for mapping(address => Allocation.State);
1818

@@ -74,16 +74,16 @@ library IndexingAgreement {
7474
bytes data;
7575
}
7676

77-
/// @custom:storage-location erc7201:graphprotocol.subgraph-service.storage.Manager.IndexingAgreement
78-
struct Manager {
77+
/// @custom:storage-location erc7201:graphprotocol.subgraph-service.storage.StorageManager.IndexingAgreement
78+
struct StorageManager {
7979
mapping(bytes16 => State) agreements;
8080
mapping(bytes16 agreementId => IndexingAgreementTermsV1 data) termsV1;
8181
mapping(address allocationId => bytes16 agreementId) allocationToActiveAgreementId;
8282
}
8383

84-
// keccak256(abi.encode(uint256(keccak256("graphprotocol.subgraph-service.storage.Manager.IndexingAgreement")) - 1)) & ~bytes32(uint256(0xff))
85-
bytes32 private constant INDEXING_AGREEMENT_MANAGER_STORAGE_LOCATION =
86-
0xfdb6fb5d1a390e01387ce73642e517880d8e0fedd0e7e26ac9194788a7a85200;
84+
// keccak256(abi.encode(uint256(keccak256("graphprotocol.subgraph-service.storage.StorageManager.IndexingAgreement")) - 1)) & ~bytes32(uint256(0xff))
85+
bytes32 public constant INDEXING_AGREEMENT_STORAGE_MANAGER_LOCATION =
86+
0xb59b65b7215c7fb95ac34d2ad5aed7c775c8bc77ad936b1b43e17b95efc8e400;
8787

8888
/**
8989
* @notice Emitted when an indexer collects indexing fees from a V1 agreement
@@ -218,7 +218,7 @@ library IndexingAgreement {
218218
error IndexingAgreementNotAuthorized(bytes16 agreementId, address unauthorizedIndexer);
219219

220220
function accept(
221-
Manager storage self,
221+
StorageManager storage self,
222222
mapping(address allocationId => Allocation.State allocation) storage allocations,
223223
address allocationId,
224224
IRecurringCollector.SignedRCA calldata signedRCA
@@ -289,7 +289,7 @@ library IndexingAgreement {
289289
* @param signedRCAU The signed Recurring Collection Agreement Update
290290
*/
291291
function update(
292-
Manager storage self,
292+
StorageManager storage self,
293293
address indexer,
294294
IRecurringCollector.SignedRCAU calldata signedRCAU
295295
) external {
@@ -332,7 +332,7 @@ library IndexingAgreement {
332332
* @param indexer The indexer address
333333
* @param agreementId The id of the agreement to cancel
334334
*/
335-
function cancel(Manager storage self, address indexer, bytes16 agreementId) external {
335+
function cancel(StorageManager storage self, address indexer, bytes16 agreementId) external {
336336
AgreementWrapper memory wrapper = _get(self, agreementId);
337337
require(_isActive(wrapper), IndexingAgreementNotActive(agreementId));
338338
require(
@@ -348,7 +348,7 @@ library IndexingAgreement {
348348
);
349349
}
350350

351-
function cancelForAllocation(Manager storage self, address _allocationId) external {
351+
function cancelForAllocation(StorageManager storage self, address _allocationId) external {
352352
bytes16 agreementId = self.allocationToActiveAgreementId[_allocationId];
353353
if (agreementId == bytes16(0)) {
354354
return;
@@ -368,7 +368,7 @@ library IndexingAgreement {
368368
);
369369
}
370370

371-
function cancelByPayer(Manager storage self, bytes16 agreementId) external {
371+
function cancelByPayer(StorageManager storage self, bytes16 agreementId) external {
372372
AgreementWrapper memory wrapper = _get(self, agreementId);
373373
require(_isActive(wrapper), IndexingAgreementNotActive(agreementId));
374374
require(
@@ -385,7 +385,7 @@ library IndexingAgreement {
385385
}
386386

387387
function collect(
388-
Manager storage self,
388+
StorageManager storage self,
389389
mapping(address allocationId => Allocation.State allocation) storage allocations,
390390
CollectParams memory params
391391
) external returns (address, uint256) {
@@ -435,28 +435,28 @@ library IndexingAgreement {
435435
return (wrapper.collectorAgreement.serviceProvider, tokensCollected);
436436
}
437437

438-
function get(Manager storage self, bytes16 agreementId) external view returns (AgreementWrapper memory) {
438+
function get(StorageManager storage self, bytes16 agreementId) external view returns (AgreementWrapper memory) {
439439
AgreementWrapper memory wrapper = _get(self, agreementId);
440440
require(wrapper.collectorAgreement.dataService == address(this), IndexingAgreementNotActive(agreementId));
441441

442442
return wrapper;
443443
}
444444

445-
function _getManager() internal pure returns (Manager storage $) {
445+
function _getStorageManager() internal pure returns (StorageManager storage $) {
446446
// solhint-disable-next-line no-inline-assembly
447447
assembly {
448-
$.slot := INDEXING_AGREEMENT_MANAGER_STORAGE_LOCATION
448+
$.slot := INDEXING_AGREEMENT_STORAGE_MANAGER_LOCATION
449449
}
450450
}
451451

452-
function _setTermsV1(Manager storage _manager, bytes16 _agreementId, bytes memory _data) private {
452+
function _setTermsV1(StorageManager storage _manager, bytes16 _agreementId, bytes memory _data) private {
453453
IndexingAgreementTermsV1 memory newTerms = Decoder.decodeIndexingAgreementTermsV1(_data);
454454
_manager.termsV1[_agreementId].tokensPerSecond = newTerms.tokensPerSecond;
455455
_manager.termsV1[_agreementId].tokensPerEntityPerSecond = newTerms.tokensPerEntityPerSecond;
456456
}
457457

458458
function _cancel(
459-
Manager storage _manager,
459+
StorageManager storage _manager,
460460
bytes16 _agreementId,
461461
State memory _agreement,
462462
IRecurringCollector.AgreementData memory _collectorAgreement,
@@ -477,7 +477,7 @@ library IndexingAgreement {
477477
}
478478

479479
function _tokensToCollect(
480-
Manager storage _manager,
480+
StorageManager storage _manager,
481481
bytes16 _agreementId,
482482
IRecurringCollector.AgreementData memory _agreement,
483483
uint256 _entities
@@ -509,7 +509,7 @@ library IndexingAgreement {
509509
return SubgraphService(address(this));
510510
}
511511

512-
function _get(Manager storage self, bytes16 agreementId) private view returns (AgreementWrapper memory) {
512+
function _get(StorageManager storage self, bytes16 agreementId) private view returns (AgreementWrapper memory) {
513513
return
514514
AgreementWrapper({
515515
agreement: self.agreements[agreementId],
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity 0.8.27;
3+
4+
import { Test } from "forge-std/Test.sol";
5+
import { IndexingAgreement } from "../../../contracts/libraries/IndexingAgreement.sol";
6+
7+
contract IndexingAgreementTest is Test {
8+
function test_StorageManagerLocation() public pure {
9+
assertEq(
10+
IndexingAgreement.INDEXING_AGREEMENT_STORAGE_MANAGER_LOCATION,
11+
keccak256(
12+
abi.encode(
13+
uint256(keccak256("graphprotocol.subgraph-service.storage.StorageManager.IndexingAgreement")) - 1
14+
)
15+
) & ~bytes32(uint256(0xff))
16+
);
17+
}
18+
}

0 commit comments

Comments
 (0)