TextDAO Subgraph Development Guide
This guide provides essential information for developers working on the TextDAO subgraph. It covers setup, development workflow, testing, and deployment processes.
Development Environment Setup
Prerequisites
- node.js: version 18 or later
- Docker: Latest stable version (required for running tests)
Setup flow
-
Clone the TextDAO monorepo and navigate to the subgraph package:
git clone [email protected]:ecdysisxyz/textdao-monorepo.git
cd textdao-monorepo/packages/subgraph -
Install dependencies:
bun install -
Generate types:
bun codegen -
Build the subgraph:
bun run build -
Test the subgraph with matchstick-as (ensure Docker is running):
bun run test -
Deploy the subgraph (replace
<subgraph-name>andversion-labelwith your actual value):bun deploy <subgraph-name> -l <version-label>
Development Workflow
- Update the schema in
schema.graphqlif new entities or fields are required. - Modify or create handler files in the
src/event-handlers/orsrc/file-data-handlers/directory to handle events and update entities. - Update the
subgraph.yamlfile if new data sources or event handlers are added. - Generate AssemblyScript types:
bun codegen - Build the subgraph:
bun run build - Run tests (see Test Strategy for more details):
bun test
Coding Standards
All code and tests are written in AssemblyScript. Be mindful of its differences from TypeScript.
Please refer to the Coding Standards document for detailed guidelines on code style, best practices, and conventions specific to subgraph development.
Testing
Comprehensive testing is crucial for maintaining the reliability and accuracy of the subgraph. See the Test Strategy document for information on writing and running tests.
Deployment
To deploy the subgraph to The Graph's hosted service:
- Authenticate with The Graph:
graph auth https://api.thegraph.com/deploy/ <your-access-token> - Deploy the subgraph:
bun deploy <subgraph-name> -l <version-label>
For detailed deployment instructions and environment-specific configurations, please refer to the deployment guide (coming soon).
Troubleshooting
Common issues and their solutions:
- Handler compilation errors: Ensure all imported modules are correctly referenced and AssemblyScript types are properly used.
- Subgraph indexing failures: Check the subgraph logs for specific error messages. Common causes include incorrect ABI definitions or mismatched event signatures.
- Query performance issues: Review entity relationships and consider adding derived fields or denormalized data for frequently accessed information.
Contributing
Contributions to the TextDAO subgraph are welcome. Please follow these steps:
- Fork the repository and create a new branch for your feature or bug fix.
- Make your changes, ensuring they adhere to the coding standards.
- Write or update tests as necessary.
- Submit a pull request with a clear description of your changes.
For more detailed contribution guidelines, please refer to the CONTRIBUTING.md file in the root of the monorepo.
Additional Resources
If you encounter any issues or have questions not covered in this guide, please reach out to the TextDAO development team or open an issue in the repository.