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
Handler Redundancy The new handlers handleFarmerVoteRewardEvent and handleFarmerBlockRewardEvent seem to perform similar operations as handleTransferEvent. Consider refactoring to a common function to avoid code duplication.
Error Handling The functions createAndSaveAccountIfNotExists, createAndSaveBalanceHistory, and createAndSaveTransfer do not handle errors that might occur during database operations. Consider adding try-catch blocks to handle potential exceptions.
Timestamp Handling The calculation of timestamp in handleTransferEvent might lead to incorrect values due to the multiplication by 1000. Verify if the original timestamp is in seconds and needs conversion to milliseconds.
Add error handling for asynchronous operations in the handleTransferEvent function
Consider handling potential exceptions for the updateAccountBalance and createAndSaveAccountIfNotExists calls within the handleTransferEvent function. This can be done using try-catch blocks to ensure that errors are caught and handled appropriately, preventing the function from failing silently.
Why: The suggestion to add error handling using try-catch blocks for asynchronous operations in the handleTransferEvent function is valid and important. It improves the robustness of the code by ensuring that any errors during these operations are caught and logged, preventing silent failures.
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 Accounts Sub Query Node
This adds/fix the logic around indexing accounts, transfer and account balance changes
I also added Redis, Express and BullMQ to have a tasks board, allowing to create a task that will then be executed outside of the indexer worker
(especially useful for updating existing db entry, or to run long process
PR Type
enhancement, bug_fix
Description
project.ts
to streamline logic and improve efficiency.db.ts
for creating and saving account, balance history, and transfer records.utils.ts
for JSON handling and date management.Changes walkthrough 📝
6 files
project.ts
Refactor event handlers and add call handler
indexers/gemini-3h/accounts/project.ts
SubstrateHandlerKind.Call
.VoteReward
andBlockReward
events.db.ts
Add database helper functions for accounts and transfers
indexers/gemini-3h/accounts/src/mappings/db.ts
transfer records.
helper.ts
Implement account balance update helper function
indexers/gemini-3h/accounts/src/mappings/helper.ts
mappingHandlers.ts
Refactor mapping handlers and add new event handlers
indexers/gemini-3h/accounts/src/mappings/mappingHandlers.ts
handleTransferEvent
to use new helper functions.utils.ts
Add utility functions for JSON and date handling
indexers/gemini-3h/accounts/src/mappings/utils.ts
creation.
schema.graphql
Update GraphQL schema with new types and indices
indexers/gemini-3h/accounts/schema.graphql
Account
type with new fields and indices.BalanceHistory
type with fields and indices.Transfer
type with new indices.4 files
accounts_accounts.yaml
Define accounts table schema and permissions
indexers/db/metadata/databases/gemini_3h/tables/accounts_accounts.yaml
accounts_balance_histories.yaml
Define balance histories table schema and permissions
indexers/db/metadata/databases/gemini_3h/tables/accounts_balance_histories.yaml
accounts_transfers.yaml
Define transfers table schema and permissions
indexers/db/metadata/databases/gemini_3h/tables/accounts_transfers.yaml
tables.yaml
Update tables configuration to include new schemas
indexers/db/metadata/databases/gemini_3h/tables/tables.yaml
1 files
package.json
Add new dependencies for account management
indexers/gemini-3h/accounts/package.json
@autonomys/auto-consensus
and@autonomys/auto-utils
.