Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOT MERGE BEFORE #26] Add supply indexing #28

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

jorgecuesta
Copy link
Collaborator

Summary

This pull request adds the Supply entity and updates the block entity.

Issue

This PR addresses improvements required for supply handling and indexing. The updates include:

  • Added a supplies field to the Block type to reference Supply entities.
  • Added new Supply type in schema.graphql.

Type of change

Select one or more:

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Documentation
  • Other (specify)

Sanity Checklist

  • I have tested my changes using the available tooling
  • I have commented my code
  • I have performed a self-review of my own code; both comments & source code
  • I create and reference any new tickets, if applicable
  • I have left TODOs throughout the codebase, if applicable

- Introduced a new `Supply` type in `schema.graphql`.
- Created `getSupply` function in `src/mappings/bank/supply.ts` to fetch total supply.
- Modified `handleGenesis` to store the initial supply from genesis state.
- Added `_handleSupply` function in `src/mappings/primitives.ts` to periodically index total supply.
- Updated the Genesis interface to include supply data.
- Introduced `supplies` field in `Block` type to reference `Supply` entities.
- Added new fields `denom` and `block` to `Supply` type.
- Replaced `getSupply` with `queryTotalSupply` and implement `getSupplyRecord`.
- Modified `_handleSupply` to create supply records with `getSupplyRecord` and avoid duplicates.
@jorgecuesta jorgecuesta added the enhancement New feature or request label Nov 12, 2024
@jorgecuesta jorgecuesta self-assigned this Nov 12, 2024
@jorgecuesta jorgecuesta changed the title Add supply indexing [NOT MERGE UNTIL #26] Add supply indexing Nov 12, 2024
@jorgecuesta jorgecuesta changed the title [NOT MERGE UNTIL #26] Add supply indexing [NOT MERGE BEFORE #26] Add supply indexing Nov 12, 2024
Copy link
Contributor

@bryanchriswhite bryanchriswhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one @jorgecuesta! 🚀

src/mappings/bank/supply.ts Outdated Show resolved Hide resolved
src/mappings/bank/supply.ts Outdated Show resolved Hide resolved
src/mappings/primitives.ts Outdated Show resolved Hide resolved
src/mappings/primitives.ts Outdated Show resolved Hide resolved
src/mappings/bank/supply.ts Outdated Show resolved Hide resolved
src/mappings/bank/supply.ts Outdated Show resolved Hide resolved
- Removed `_handleSupply` from `primitives.ts` and imported it from `supply.ts`.
- Reorganized `getSupplyRecord` in `supply.ts` to use `getSupplyId` for ID generation.
- Simplified supply concatenation logic in `queryTotalSupply` by using `push` instead of `concat`.
- Centralized total supply handling in `supply.ts` for clearer separation of concerns.
Copy link
Contributor

@bryanchriswhite bryanchriswhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preemptively approving! 🙌

Just a couple more last-minute suggestions and then I think this is good to go.

src/mappings/bank/supply.ts Show resolved Hide resolved
src/mappings/primitives.ts Show resolved Hide resolved
- Introduced new handler `handleBlockSupply` to link block with recent supply.
- Added `supply` field to `Block` entity in GraphQL schema.
- Ensured supply records in genesis block are handled properly.
- Modified `_handleSupply` and `_handleBlockSupply` to update and retrieve supply data.
- Updated `Genesis` interface to include supply information.
- Replaced the old block supply handler with a more robust tracking system.
- Introduced `SupplyDenom` and `BlockSupply` entities for better denomination supply tracking.
- Added logic to handle supply records creation for each block, adjusting for the genesis block.
- Adjusted schema to accommodate new entities and relationships.
- Removed unused functions and refactored supply-related code for clarity and efficiency.
@jorgecuesta
Copy link
Collaborator Author

@bryanchriswhite Please refer to the attached images to look how the structure looks at the database and also the same result on the graphql query.

I think now this achieve a proper handling of supply for any denomination on the block, which allows further updates on the protocol like IBC transactions without need to modify it.

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants