-
-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Feature and its Use Cases
Problem
Critical event parameters are not indexed, making off-chain filtering inefficient for frontends, indexers, and analytics tools.
Current (inefficient):
// Factory.sol
event TNTCreated(address indexed owner, address tntAddress); // ❌ tntAddress not indexed
// TNT.sol
event TokenIssued(address indexed issuer, address indexed user, uint256 tokenId); // ❌ tokenId not indexed
event TokenRevoked(address indexed revoker, uint256 tokenId); // ❌ tokenId not indexedWithout indexing, clients must fetch ALL events and filter client-side:
// ❌ Inefficient: Download all events, filter locally
const all = await factory.queryFilter(factory.filters.TNTCreated());
const filtered = all.filter(e => e.args.tntAddress === myAddress);Solution
Add indexed to 3 parameters across 2 files:
// Factory.sol (Line ~15)
event TNTCreated(address indexed owner, address indexed tntAddress); // ✅
// TNT.sol (Lines ~38-39)
event TokenIssued(address indexed issuer, address indexed user, uint256 indexed tokenId); // ✅
event TokenRevoked(address indexed revoker, uint256 indexed tokenId); // ✅After (efficient):
// ✅ Filter at RPC/node level
const filtered = await factory.queryFilter(
factory.filters.TNTCreated(null, specificTNTAddress)
);Benefits
- Efficient Filtering - Query specific TNT addresses/token IDs at node level
- Improved Indexing - The Graph and similar tools can create DB indexes
- Reduced RPC Load - No need to download all events for client-side filtering
- Better Analytics - Track specific contracts/tokens without full scans
Gas Cost: +375 gas per indexed parameter (~1,125 gas total increase per TNT creation)
Testing
Create test/EventIndexing.test.js:
- Verify
TNTCreatedhas 3 topics (signature + 2 indexed params) - Verify
TokenIssuedhas 4 topics (signature + 3 indexed params) - Verify
TokenRevokedhas 3 topics (signature + 2 indexed params) - Test filtering by indexed parameters
- Measure gas cost increase
Technical Details
Files to modify:
contracts/src/Factory.sol- TNTCreated eventcontracts/src/TNT.sol- TokenIssued, TokenRevoked events
Additional Context
No response
Code of Conduct
- I have joined the Discord server and will post updates there
- I have searched existing issues to avoid duplicates
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request