Skip to content

Commit 29285f4

Browse files
juanmardefagotmigone
authored andcommitted
fix: add extra parameters to contract events (OZ SR-01)
1 parent da95d8b commit 29285f4

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

packages/horizon/contracts/interfaces/internal/IHorizonStakingMain.sol

+3-1
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,14 @@ interface IHorizonStakingMain {
189189
* @param verifier The address of the verifier
190190
* @param delegator The address of the delegator
191191
* @param tokens The amount of tokens undelegated
192+
* @param tokens The amount of shares undelegated
192193
*/
193194
event TokensUndelegated(
194195
address indexed serviceProvider,
195196
address indexed verifier,
196197
address indexed delegator,
197-
uint256 tokens
198+
uint256 tokens,
199+
uint256 shares
198200
);
199201

200202
/**

packages/horizon/contracts/staking/HorizonStaking.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
947947
pool.thawingNonce
948948
);
949949

950-
emit TokensUndelegated(_serviceProvider, _verifier, msg.sender, tokens);
950+
emit TokensUndelegated(_serviceProvider, _verifier, msg.sender, tokens, _shares);
951951
return thawRequestId;
952952
}
953953

packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest {
10101010
calcValues.thawRequestId
10111011
);
10121012
vm.expectEmit();
1013-
emit IHorizonStakingMain.TokensUndelegated(serviceProvider, verifier, delegator, calcValues.tokens);
1013+
emit IHorizonStakingMain.TokensUndelegated(serviceProvider, verifier, delegator, calcValues.tokens, shares);
10141014
if (legacy) {
10151015
staking.undelegate(serviceProvider, shares);
10161016
} else if (thawRequestType == IHorizonStakingTypes.ThawRequestType.Delegation) {

packages/subgraph-service/contracts/SubgraphService.sol

+8-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,14 @@ contract SubgraphService is
522522
}
523523
}
524524

525-
emit QueryFeesCollected(indexer, _signedRav.rav.payer, tokensCollected, tokensCurators);
525+
emit QueryFeesCollected(
526+
indexer,
527+
_signedRav.rav.payer,
528+
allocationId,
529+
subgraphDeploymentId,
530+
tokensCollected,
531+
tokensCurators
532+
);
526533
return tokensCollected;
527534
}
528535

packages/subgraph-service/contracts/interfaces/ISubgraphService.sol

+4
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ interface ISubgraphService is IDataServiceFees {
3434
* @notice Emitted when a subgraph service collects query fees from Graph Payments
3535
* @param serviceProvider The address of the service provider
3636
* @param payer The address paying for the query fees
37+
* @param allocationId The id of the allocation
38+
* @param subgraphDeploymentId The id of the subgraph deployment
3739
* @param tokensCollected The amount of tokens collected
3840
* @param tokensCurators The amount of tokens curators receive
3941
*/
4042
event QueryFeesCollected(
4143
address indexed serviceProvider,
4244
address indexed payer,
45+
address indexed allocationId,
46+
bytes32 subgraphDeploymentId,
4347
uint256 tokensCollected,
4448
uint256 tokensCurators
4549
);

packages/subgraph-service/test/subgraphService/SubgraphService.t.sol

+12-4
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,10 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
278278
bytes memory _data
279279
) private returns (uint256 paymentCollected) {
280280
IGraphTallyCollector.SignedRAV memory signedRav = abi.decode(_data, (IGraphTallyCollector.SignedRAV));
281-
Allocation.State memory allocation = subgraphService.getAllocation(
282-
address(uint160(uint256(signedRav.rav.collectionId)))
283-
);
281+
address allocationId = address(uint160(uint256(signedRav.rav.collectionId)));
282+
Allocation.State memory allocation = subgraphService.getAllocation(allocationId);
283+
bytes32 subgraphDeploymentId = allocation.subgraphDeploymentId;
284+
284285
address payer = graphTallyCollector.isAuthorized(signedRav.rav.payer, _recoverRAVSigner(signedRav))
285286
? signedRav.rav.payer
286287
: address(0);
@@ -298,7 +299,14 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
298299
uint256 tokensCurators = (paymentCollected - tokensProtocol).mulPPMRoundUp(queryFeeData.curationCut);
299300

300301
vm.expectEmit(address(subgraphService));
301-
emit ISubgraphService.QueryFeesCollected(_indexer, payer, paymentCollected, tokensCurators);
302+
emit ISubgraphService.QueryFeesCollected(
303+
_indexer,
304+
payer,
305+
allocationId,
306+
subgraphDeploymentId,
307+
paymentCollected,
308+
tokensCurators
309+
);
302310

303311
return paymentCollected;
304312
}

0 commit comments

Comments
 (0)