Skip to content

Commit 8ffbbdd

Browse files
committed
fix: resolve lint issues and centralize interface ID generation
Lint Fixes: - Restore missing NatSpec documentation for IRewardsIssuer interface - Remove TODO comment from MockIssuanceAllocator - Add solhint-disable for named-parameters-mapping rule (not supported in Solidity 0.7.6) Interface ID Centralization: - Add IIssuanceAllocator and IRewardsEligibilityOracle to interfaces package InterfaceIdExtractor - Update interfaces package generation script to include all interface IDs - Remove duplicate interface ID generation from issuance package: * Delete InterfaceIdExtractor.sol * Delete generateInterfaceIds.py script * Delete local interfaceIds.ts helper * Remove generate:interfaces script from package.json - Update issuance package to import interface IDs from @graphprotocol/interfaces - Simplify interface compliance tests (remove redundant consistency checks) All lint checks now pass (0 warnings) and all tests pass (161/161). Interface IDs are now centrally managed in the interfaces package for consistency.
1 parent afbb544 commit 8ffbbdd

File tree

9 files changed

+32
-218
lines changed

9 files changed

+32
-218
lines changed

packages/contracts/contracts/tests/MockIssuanceAllocator.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
pragma solidity 0.7.6;
44
pragma abicoder v2;
55

6-
// TODO: Re-enable and fix issues when publishing a new version
7-
// solhint-disable gas-increment-by-one, gas-indexed-events, gas-small-strings, use-natspec
6+
// solhint-disable gas-increment-by-one, gas-indexed-events, gas-small-strings, use-natspec, named-parameters-mapping
87

98
import { ERC165 } from "@openzeppelin/contracts/introspection/ERC165.sol";
109
import {

packages/interfaces/contracts/contracts/rewards/IRewardsIssuer.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
pragma solidity ^0.7.6 || 0.8.27;
44

5+
/**
6+
* @title Rewards Issuer Interface
7+
* @author Edge & Node
8+
* @notice Interface for contracts that issue rewards based on allocation data
9+
*/
510
interface IRewardsIssuer {
611
/**
7-
* @dev Get allocation data to calculate rewards issuance
12+
* @notice Get allocation data to calculate rewards issuance
813
*
914
* @param allocationId The allocation Id
1015
* @return isActive Whether the allocation is active or not

packages/interfaces/contracts/utils/InterfaceIdExtractor.sol

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ pragma solidity 0.7.6;
33

44
import { IRewardsManager } from "../contracts/rewards/IRewardsManager.sol";
55
import { IIssuanceTarget } from "../issuance/allocate/IIssuanceTarget.sol";
6+
import { IIssuanceAllocator } from "../issuance/allocate/IIssuanceAllocator.sol";
7+
import { IRewardsEligibilityOracle } from "../issuance/eligibility/IRewardsEligibilityOracle.sol";
68
import { IERC165 } from "@openzeppelin/contracts/introspection/IERC165.sol";
79

810
/**
@@ -30,6 +32,22 @@ contract InterfaceIdExtractor {
3032
return type(IIssuanceTarget).interfaceId;
3133
}
3234

35+
/**
36+
* @notice Returns the ERC-165 interface ID for IIssuanceAllocator
37+
* @return The interface ID as calculated by Solidity
38+
*/
39+
function getIIssuanceAllocatorId() external pure returns (bytes4) {
40+
return type(IIssuanceAllocator).interfaceId;
41+
}
42+
43+
/**
44+
* @notice Returns the ERC-165 interface ID for IRewardsEligibilityOracle
45+
* @return The interface ID as calculated by Solidity
46+
*/
47+
function getIRewardsEligibilityOracleId() external pure returns (bytes4) {
48+
return type(IRewardsEligibilityOracle).interfaceId;
49+
}
50+
3351
/**
3452
* @notice Returns the ERC-165 interface ID for IERC165
3553
* @return The interface ID as calculated by Solidity

packages/interfaces/scripts/generateInterfaceIds.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def run_hardhat_task():
3131
const results = {
3232
IRewardsManager: await extractor.getIRewardsManagerId(),
3333
IIssuanceTarget: await extractor.getIIssuanceTargetId(),
34+
IIssuanceAllocator: await extractor.getIIssuanceAllocatorId(),
35+
IRewardsEligibilityOracle: await extractor.getIRewardsEligibilityOracleId(),
3436
IERC165: await extractor.getIERC165Id(),
3537
}
3638

packages/issuance/contracts/test/InterfaceIdExtractor.sol

Lines changed: 0 additions & 40 deletions
This file was deleted.

packages/issuance/test/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@
4545
"scripts": {
4646
"build": "pnpm build:dep && pnpm build:self",
4747
"build:dep": "pnpm --filter '@graphprotocol/issuance-test^...' run build:self",
48-
"build:self": "tsc --build && pnpm generate:interfaces",
48+
"build:self": "tsc --build",
4949
"build:coverage": "pnpm build:dep:coverage && pnpm build:self",
5050
"build:dep:coverage": "pnpm --filter '@graphprotocol/issuance-test^...' run build:coverage",
51-
"generate:interfaces": "python3 scripts/generateInterfaceIds.py --silent",
5251
"clean": "rm -rf .eslintcache artifacts/",
5352
"test": "pnpm build && pnpm test:self",
5453
"test:self": "cd .. && hardhat test test/tests/*.test.ts test/tests/**/*.test.ts",

packages/issuance/test/scripts/generateInterfaceIds.py

Lines changed: 0 additions & 149 deletions
This file was deleted.

packages/issuance/test/tests/consolidated/InterfaceCompliance.test.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import { expect } from 'chai'
22
const { ethers } = require('hardhat')
33

44
const { shouldSupportERC165Interface } = require('../../utils/testPatterns')
5+
// Import generated interface IDs from the interfaces package
6+
import { IIssuanceAllocator, IIssuanceTarget, IRewardsEligibilityOracle } from '@graphprotocol/interfaces'
7+
58
import {
69
deployDirectAllocation,
710
deployIssuanceAllocator,
811
deployRewardsEligibilityOracle,
912
deployTestGraphToken,
1013
getTestAccounts,
1114
} from '../helpers/fixtures'
12-
// Import generated interface IDs
13-
import { IIssuanceAllocator, IIssuanceTarget, IRewardsEligibilityOracle } from '../helpers/interfaceIds'
1415

1516
/**
1617
* Consolidated ERC-165 Interface Compliance Tests
@@ -62,17 +63,7 @@ describe('ERC-165 Interface Compliance', () => {
6263
),
6364
)
6465

65-
describe('Interface ID Consistency', () => {
66-
it('should have consistent interface IDs with Solidity calculations', async () => {
67-
const InterfaceIdExtractorFactory = await ethers.getContractFactory('InterfaceIdExtractor')
68-
const extractor = await InterfaceIdExtractorFactory.deploy()
69-
70-
// Verify each interface ID matches what Solidity calculates
71-
expect(await extractor.getIIssuanceAllocatorId()).to.equal(IIssuanceAllocator)
72-
expect(await extractor.getIRewardsEligibilityOracleId()).to.equal(IRewardsEligibilityOracle)
73-
expect(await extractor.getIIssuanceTargetId()).to.equal(IIssuanceTarget)
74-
})
75-
66+
describe('Interface ID Validation', () => {
7667
it('should have valid interface IDs (not zero)', () => {
7768
expect(IIssuanceAllocator).to.not.equal('0x00000000')
7869
expect(IRewardsEligibilityOracle).to.not.equal('0x00000000')

packages/issuance/test/tests/helpers/interfaceIds.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)