Skip to content

add support for DataRegistry.FileAddedV2 event#6

Merged
dumedco merged 2 commits intomainfrom
feat/fileAddedV2-eduard
Aug 19, 2025
Merged

add support for DataRegistry.FileAddedV2 event#6
dumedco merged 2 commits intomainfrom
feat/fileAddedV2-eduard

Conversation

@dumedco
Copy link
Contributor

@dumedco dumedco commented Aug 18, 2025

Summary

This PR adds support for the new FileAddedV2 event in the DataRegistry V3 contract, which introduces schema-based file categorization. The implementation includes event handlers, comprehensive
tests, and maintains backward compatibility with the existing FileAdded event.

Changes

🎯 Core Implementation

  • New Event Handler: Added handleFileAddedV2V3 to process the FileAddedV2 event which includes a schemaId parameter
  • Event Registration: Updated all subgraph YAML configurations (moksha, vana-moksha, vana) to listen for the new event
  • Schema Support: Files can now be associated with specific data schemas, enabling better data categorization

🧪 Testing

  • Added createFileAddedV2Event test utility for simulating the new event
  • Created comprehensive test cases verifying:
    • Files created with FileAdded use default schema (ID: 0)
    • Files created with FileAddedV2 use the specified schema ID
    • Proper entity creation and field mapping

📊 Grafting Configuration

The subgraph includes grafting configuration to maintain historical data continuity:

  • Moksha: Grafts from block 3,980,000 (base: QmUKB4EiXUJRKVnR1pGHsULHw9WTGGmbzuCZ5EsvQQmsWe)
  • Vana: Grafts from block 4,450,000 (base: QmXerEfZuoYS7KaogbEacn4Ff996R2PSS8xdPwQpeRbtpD)

This ensures the subgraph retains all historical data while adding support for the new event going forward.

Technical Details

Event Signature

event FileAddedV2(
    indexed uint256 fileId,
    indexed address ownerAddress,
    string url,
    uint256 schemaId
)

Key Differences

- FileAdded: Creates files with default schema ID (0)
- FileAddedV2: Creates files with custom schema IDs for data categorization

Testing Instructions

1. Run yarn prepare:moksha or yarn prepare:vana to prepare the subgraph
2. Run yarn codegen to generate TypeScript types (requires Node.js >= 20.18.1)
3. Run yarn build to compile the subgraph
4. Run yarn test to execute all tests including the new FileAddedV2 test cases

Deployment Notes

- The grafting feature ensures no historical data is lost during deployment
- Both FileAdded and FileAddedV2 events will be processed concurrently
- Existing FileAdded events continue to work with default schema (backward compatible)

@dumedco dumedco merged commit d8b727a into main Aug 19, 2025
2 of 4 checks passed
@dumedco dumedco deleted the feat/fileAddedV2-eduard branch August 19, 2025 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments