Skip to content

lint: fix linting script #1180

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

Merged
merged 1 commit into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ contract GraphTallyCollector is EIP712, GraphDirectory, Authorizable, IGraphTall
bytes calldata _data,
uint256 _tokensToCollect
) private returns (uint256) {
(SignedRAV memory signedRAV, uint256 dataServiceCut, address receiverDestination) = abi.decode(_data, (SignedRAV, uint256, address));
(SignedRAV memory signedRAV, uint256 dataServiceCut, address receiverDestination) = abi.decode(
_data,
(SignedRAV, uint256, address)
);

// Ensure caller is the RAV data service
require(
Expand Down Expand Up @@ -153,7 +156,15 @@ contract GraphTallyCollector is EIP712, GraphDirectory, Authorizable, IGraphTall

if (tokensToCollect > 0) {
tokensCollected[dataService][collectionId][receiver][signedRAV.rav.payer] += tokensToCollect;
_graphPaymentsEscrow().collect(_paymentType, signedRAV.rav.payer, receiver, tokensToCollect, dataService, dataServiceCut, receiverDestination);
_graphPaymentsEscrow().collect(
_paymentType,
signedRAV.rav.payer,
receiver,
tokensToCollect,
dataService,
dataServiceCut,
receiverDestination
);
}

emit PaymentCollected(_paymentType, collectionId, signedRAV.rav.payer, receiver, dataService, tokensToCollect);
Expand Down
4 changes: 2 additions & 2 deletions packages/horizon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"lint": "pnpm lint:ts && pnpm lint:sol",
"lint:ts": "eslint '**/*.{js,ts}' --fix --no-warn-ignored",
"lint:sol": "pnpm lint:sol:prettier && pnpm lint:sol:solhint",
"lint:sol:prettier": "prettier --write contracts/**/*.sol test/**/*.sol",
"lint:sol:solhint": "solhint --noPrompt --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js",
"lint:sol:prettier": "prettier --write \"contracts/**/*.sol\" \"test/**/*.sol\"",
"lint:sol:solhint": "solhint --noPrompt --fix \"contracts/**/*.sol\" --config node_modules/solhint-graph-config/index.js",
"lint:sol:natspec": "natspec-smells --config natspec-smells.config.js",
"clean": "rm -rf build dist cache cache_forge typechain-types",
"build": "hardhat compile",
Expand Down
15 changes: 12 additions & 3 deletions packages/horizon/test/unit/escrow/GraphEscrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,17 @@ contract GraphEscrowTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest {
}

// Check receiver balance after payment
assertEq(afterBalances.receiverBalance - previousBalances.receiverBalance, collectTokensData.receiverExpectedPayment);
assertEq(
afterBalances.receiverBalance - previousBalances.receiverBalance,
collectTokensData.receiverExpectedPayment
);
assertEq(token.balanceOf(address(payments)), 0);

// Check delegation pool balance after payment
assertEq(afterBalances.delegationPoolBalance - previousBalances.delegationPoolBalance, collectTokensData.tokensDelegation);
assertEq(
afterBalances.delegationPoolBalance - previousBalances.delegationPoolBalance,
collectTokensData.tokensDelegation
);

// Check that the escrow account has been updated
assertEq(previousBalances.escrowBalance, afterBalances.escrowBalance + _tokens);
Expand All @@ -212,7 +218,10 @@ contract GraphEscrowTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest {
assertEq(previousBalances.paymentsBalance, afterBalances.paymentsBalance);

// Check data service balance after payment
assertEq(afterBalances.dataServiceBalance - previousBalances.dataServiceBalance, collectTokensData.tokensDataService);
assertEq(
afterBalances.dataServiceBalance - previousBalances.dataServiceBalance,
collectTokensData.tokensDataService
);

// Check payers escrow balance after payment
assertEq(previousBalances.payerEscrowBalance - _tokens, afterBalances.payerEscrowBalance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,12 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest {
_;
}

modifier useProvision(
uint256 tokens,
uint32 maxVerifierCut,
uint64 thawingPeriod
) virtual {
modifier useProvision(uint256 tokens, uint32 maxVerifierCut, uint64 thawingPeriod) virtual {
_useProvision(subgraphDataServiceAddress, tokens, maxVerifierCut, thawingPeriod);
_;
}

modifier useProvisionDataService(
address dataService,
uint256 tokens,
uint32 maxVerifierCut,
uint64 thawingPeriod
) {
modifier useProvisionDataService(address dataService, uint256 tokens, uint32 maxVerifierCut, uint64 thawingPeriod) {
_useProvision(dataService, tokens, maxVerifierCut, thawingPeriod);
_;
}
Expand Down
66 changes: 33 additions & 33 deletions packages/subgraph-service/contracts/SubgraphService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,17 @@ contract SubgraphService is
return _isOverAllocated(indexer, _delegationRatio);
}

/**
* @notice Sets the payments destination for an indexer to receive payments
* @dev Emits a {PaymentsDestinationSet} event
* @param _indexer The address of the indexer
* @param _paymentsDestination The address where payments should be sent
*/
function _setPaymentsDestination(address _indexer, address _paymentsDestination) internal {
paymentsDestination[_indexer] = _paymentsDestination;
emit PaymentsDestinationSet(_indexer, _paymentsDestination);
}

// -- Data service parameter getters --
/**
* @notice Getter for the accepted thawing period range for provisions
Expand Down Expand Up @@ -470,21 +481,21 @@ contract SubgraphService is
* Emits a {StakeClaimLocked} event.
* Emits a {QueryFeesCollected} event.
*
* @param indexer The address of the indexer
* @param data Encoded data:
* @param _indexer The address of the indexer
* @param _data Encoded data:
* - IGraphTallyCollector.SignedRAV `signedRav`: The signed RAV
* - uint256 `tokensToCollect`: The amount of tokens to collect. Allows partially collecting a RAV. If 0, the entire RAV will
* be collected.
* @return The amount of fees collected
*/
function _collectQueryFees(address indexer, bytes calldata data) private returns (uint256) {
function _collectQueryFees(address _indexer, bytes calldata _data) private returns (uint256) {
(IGraphTallyCollector.SignedRAV memory signedRav, uint256 tokensToCollect) = abi.decode(
data,
_data,
(IGraphTallyCollector.SignedRAV, uint256)
);
require(
signedRav.rav.serviceProvider == indexer,
SubgraphServiceIndexerMismatch(signedRav.rav.serviceProvider, indexer)
signedRav.rav.serviceProvider == _indexer,
SubgraphServiceIndexerMismatch(signedRav.rav.serviceProvider, _indexer)
);

// Check that collectionId (256 bits) is a valid address (160 bits)
Expand All @@ -497,11 +508,11 @@ contract SubgraphService is
Allocation.State memory allocation = _allocations.get(allocationId);

// Check RAV is consistent - RAV indexer must match the allocation's indexer
require(allocation.indexer == indexer, SubgraphServiceInvalidRAV(indexer, allocation.indexer));
require(allocation.indexer == _indexer, SubgraphServiceInvalidRAV(_indexer, allocation.indexer));
bytes32 subgraphDeploymentId = allocation.subgraphDeploymentId;

// release expired stake claims
_releaseStake(indexer, 0);
_releaseStake(_indexer, 0);

// Collect from GraphPayments - only curators cut is sent back to the subgraph service
uint256 tokensCollected;
Expand All @@ -523,7 +534,7 @@ contract SubgraphService is
if (tokensCollected > 0) {
// lock stake as economic security for fees
_lockStake(
indexer,
_indexer,
tokensCollected * stakeToFeesRatio,
block.timestamp + _disputeManager().getDisputePeriod()
);
Expand All @@ -539,7 +550,7 @@ contract SubgraphService is
}

emit QueryFeesCollected(
indexer,
_indexer,
signedRav.rav.payer,
allocationId,
subgraphDeploymentId,
Expand All @@ -551,31 +562,20 @@ contract SubgraphService is

/**
* @notice Collect indexing rewards
* @param indexer The address of the indexer
* @param data Encoded data:
* @param _indexer The address of the indexer
* @param _data Encoded data:
* - address `allocationId`: The id of the allocation
* - bytes32 `poi`: The POI being presented
* - bytes `poiMetadata`: The metadata associated with the POI. See {AllocationManager-_presentPOI} for more details.
* @return The amount of indexing rewards collected
*/
function _collectIndexingRewards(address indexer, bytes calldata data) private returns (uint256) {
(address allocationId, bytes32 poi_, bytes memory poiMetadata_) = abi.decode(data, (address, bytes32, bytes));
function _collectIndexingRewards(address _indexer, bytes calldata _data) private returns (uint256) {
(address allocationId, bytes32 poi_, bytes memory poiMetadata_) = abi.decode(_data, (address, bytes32, bytes));
require(
_allocations.get(allocationId).indexer == indexer,
SubgraphServiceAllocationNotAuthorized(indexer, allocationId)
_allocations.get(allocationId).indexer == _indexer,
SubgraphServiceAllocationNotAuthorized(_indexer, allocationId)
);
return _presentPOI(allocationId, poi_, poiMetadata_, _delegationRatio, paymentsDestination[indexer]);
}

/**
* @notice Sets the payments destination for an indexer to receive payments
* @dev Emits a {PaymentsDestinationSet} event
* @param _indexer The address of the indexer
* @param _paymentsDestination The address where payments should be sent
*/
function _setPaymentsDestination(address _indexer, address _paymentsDestination) internal {
paymentsDestination[_indexer] = _paymentsDestination;
emit PaymentsDestinationSet(_indexer, _paymentsDestination);
return _presentPOI(allocationId, poi_, poiMetadata_, _delegationRatio, paymentsDestination[_indexer]);
}

/**
Expand All @@ -591,14 +591,14 @@ contract SubgraphService is
/**
* @notice Encodes the data for the GraphTallyCollector
* @dev The purpose of this function is just to avoid stack too deep errors
* @param signedRav The signed RAV
* @param curationCut The curation cut
* @param _signedRav The signed RAV
* @param _curationCut The curation cut
* @return The encoded data
*/
function _encodeGraphTallyData(
IGraphTallyCollector.SignedRAV memory signedRav,
uint256 curationCut
IGraphTallyCollector.SignedRAV memory _signedRav,
uint256 _curationCut
) private view returns (bytes memory) {
return abi.encode(signedRav, curationCut, paymentsDestination[signedRav.rav.serviceProvider]);
return abi.encode(_signedRav, _curationCut, paymentsDestination[_signedRav.rav.serviceProvider]);
}
}
2 changes: 1 addition & 1 deletion packages/subgraph-service/contracts/mocks/imports.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ interface IServiceRegistryToolshed is IServiceRegistry {

interface IGNSToolshed is IGNS {
function subgraphNFT() external view returns (address);
}
}
4 changes: 2 additions & 2 deletions packages/subgraph-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"lint": "pnpm lint:ts && pnpm lint:sol",
"lint:ts": "eslint '**/*.{js,ts}' --fix --no-warn-ignored",
"lint:sol": "pnpm lint:sol:prettier && pnpm lint:sol:solhint",
"lint:sol:prettier": "prettier --write contracts/**/*.sol test/**/*.sol",
"lint:sol:solhint": "solhint --noPrompt --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js",
"lint:sol:prettier": "prettier --write \"contracts/**/*.sol\" \"test/**/*.sol\"",
"lint:sol:solhint": "solhint --noPrompt --fix \"contracts/**/*.sol\" --config node_modules/solhint-graph-config/index.js",
"lint:sol:natspec": "natspec-smells --config natspec-smells.config.js",
"clean": "rm -rf build dist cache cache_forge typechain-types",
"build": "hardhat compile",
Expand Down