You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Possible Bug The method getBlockAuthor uses a hardcoded DEFAULT_ACCOUNT_ID as a fallback, which could lead to incorrect author data being recorded. Consider handling this case more dynamically or ensuring that the correct data is always available.
Performance Issue The functions createAndSaveBlock, saveLog, createAndSaveSectionIfNotExists, createAndSaveExtrinsicModuleNameIfNotExists, createAndSaveEventModuleNameIfNotExists, createAndSaveExtrinsic, and createAndSaveEvent all use await inside loops or map iterations. This could lead to performance bottlenecks due to sequential execution. Consider refactoring to allow parallel execution where possible.
Code Smell The file contains large functions with multiple responsibilities (e.g., handleBlock, handleCall, handleEvent). Consider breaking these functions into smaller, more focused functions to improve maintainability and readability.
Handle potential null values from environment variables safely
Avoid using the TypeScript non-null assertion operator ('!') for environment variables as it may lead to runtime errors if the variables are not set. Instead, handle the potential null or undefined values gracefully.
-endpoint: process.env.GEMINI_3H_RPC!?.split(",") as string[] | string,-dictionary: process.env.DICTIONARY!,+endpoint: process.env.GEMINI_3H_RPC ? process.env.GEMINI_3H_RPC.split(",") as string[] | string : "default_endpoint",+dictionary: process.env.DICTIONARY || "default_dictionary",
Suggestion importance[1-10]: 9
Why: This suggestion addresses a possible runtime error by providing default values if environment variables are not set, which is crucial for application stability.
9
Add a check for 'process.env.GEMINI_3H_RPC' before using it to avoid runtime errors
Consider checking the return value of 'process.env.GEMINI_3H_RPC' before calling 'split' to prevent runtime errors in case the environment variable is not set.
-endpoint: process.env.GEMINI_3H_RPC!?.split(",") as string[] | string,+endpoint: process.env.GEMINI_3H_RPC ? process.env.GEMINI_3H_RPC.split(",") as string[] | string : ["default_endpoint"],
Suggestion importance[1-10]: 9
Why: This suggestion prevents potential runtime errors by ensuring the environment variable is checked before use, which is important for robust error handling.
9
Best practice
Specify a fixed version for '@subql/node' to ensure consistent behavior
Replace the wildcard version '*' for '@subql/node' with a specific version to ensure consistent behavior across different environments and avoid potential breaking changes from unexpected updates.
-version: "*",+version: "specific_version_number", # Replace 'specific_version_number' with the desired version
Suggestion importance[1-10]: 8
Why: Using a specific version instead of a wildcard ensures consistent behavior across environments and prevents potential issues from unexpected updates.
8
Maintainability
Ensure type safety by replacing '@ts-ignore' with specific type assertions
Replace the use of '@ts-ignore' which suppresses TypeScript errors, with a more specific type assertion or handling to maintain type safety.
-// @ts-ignore
types: {
Solution: {
- public_key: "AccountId32",- reward_address: "AccountId32",+ public_key: "AccountId32" as any, # Replace 'any' with the actual expected type if known+ reward_address: "AccountId32" as any,
},
SubPreDigest: {
- slot: "u64",- solution: "Solution",+ slot: "u64" as any,+ solution: "Solution" as any,
},
},
Suggestion importance[1-10]: 7
Why: Replacing '@ts-ignore' with specific type assertions improves code maintainability and type safety, although it may require additional type information.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Fix Consensus Sub Query Node
This add/fix the logic for basic indexing of all block, events, extrinsics and log with very similar schema as what we had before.
PR Type
enhancement, tests
Description
Changes walkthrough 📝
mappingHandlers.ts
Refactor and enhance block, extrinsic, and event handling
indexers/gemini-3h/consensus/src/mappings/mappingHandlers.ts
db.ts
Implement database operations for blockchain data
indexers/gemini-3h/consensus/src/mappings/db.ts
events.
utils.ts
Add utility functions for data processing
indexers/gemini-3h/consensus/src/mappings/utils.ts
helper.ts
Add helper function for block author retrieval
indexers/gemini-3h/consensus/src/mappings/helper.ts
schema.graphql
Update GraphQL schema for new data model
indexers/gemini-3h/consensus/schema.graphql
package.json
Add new scripts for development operations
indexers/package.json
project.ts
Update project configuration and data sources
indexers/gemini-3h/consensus/project.ts
package.json
Update package dependencies
indexers/gemini-3h/consensus/package.json