Skip to content

Feature: Add Graphql API Implementation. - #390

Merged
LaGodxy merged 15 commits into
MettaChain:mainfrom
Lansa-18:feature/add-graghql-api
Apr 28, 2026
Merged

Feature: Add Graphql API Implementation.#390
LaGodxy merged 15 commits into
MettaChain:mainfrom
Lansa-18:feature/add-graghql-api

Conversation

@Lansa-18

Copy link
Copy Markdown
Contributor

Closes #171

Feature: GraphQL API for PropChain Indexer (#171)

Goal

Add a GraphQL endpoint to the existing propchain-indexer Axum server so clients can query blockchain events and contracts with field selection, complex filtering, and schema introspection — without replacing the existing REST API.


📁 Files Modified

File Change
indexer/Cargo.toml Added async-graphql = { version = "7", features = ["chrono", "uuid"] }
indexer/src/graphql.rs New file — full GraphQL schema, types, resolvers, and handlers
indexer/src/main.rs Added mod graphql, built the schema, mounted /graphql routes

What Was Achieved

  • GqlEvent — a SimpleObject GraphQL output type mapped from the existing IndexedEvent db type, with camelCase field exposure
  • EventFilterInput — a GraphQL InputObject mirroring EventQuery, supporting filtering by contract, event type, topic, timestamp range, block range, limit, and offset
  • QueryRoot with two resolvers:
    • events(filter) — queries contract_events with all filter options
    • contracts — returns a distinct list of indexed contract addresses
  • POST /graphql — executes GraphQL queries (via native Axum Json extractor, without the async-graphql-axum crate)
  • GET /graphql — serves the GraphiQL in-browser IDE playground
  • The GraphQL router is cleanly separated from the REST router and merged into the same Axum app

Notable deviation: The implementation used Json<async_graphql::Request> / Json<async_graphql::Response> directly instead of the async-graphql-axum crate, so async-graphql-axum was not added as a dependency.

- redirect property-management to use propchain-traits for ReentrancyGuard
  instead of propchain-contracts, eliminating duplicate __ink_generate_metadata
  linker error when building the cdylib
- fix set_liquidity_mining_campaign missing admin timelock guard
- fix execute_governance_proposal not applying new_fee_bips on passed proposals
- fix limit order auto-execution blocked by reentrancy guard; extract
  execute_order_core so process_executable_limit_orders can call it without
  double-locking the non_reentrant guard
@drips-wave

drips-wave Bot commented Apr 26, 2026

Copy link
Copy Markdown

@Lansa-18 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@LaGodxy

LaGodxy commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

@Lansa-18 fix CI.

Lansa-18 and others added 11 commits April 27, 2026 19:53
- Add burn() function allowing contract admin to burn tokens
- Only admin can burn tokens for supply management
- Checks token exists and is not locked in bridge operation
- Decrements total_supply counter
- Clears token ownership, approvals, and balances
- Emits Transfer event (to zero address) and TokenBurned event
- TokenBurned event includes reason field for audit trail
- Add TokenBurned event with token_id, burned_by, and reason fields

Use cases:
- Supply management and tokenomics control
- Regulatory compliance requirements
- Removing tokens from circulation
- Managing token economics
- Add ShareStakeInfo struct and LockPeriod enum to types.rs
- Add share_reward_pool storage field to PropertyToken
- Initialize all staking storage fields in constructor
- Fix type mismatch in snapshot total_supply (u64 to u128 cast)
- Add REWARD_RATE_PRECISION constant for staking calculations
- Fix ShareLockPeriod references to use LockPeriod
- Add #[allow(clippy::too_many_arguments)] to vesting function
- Remove unnecessary casts in vesting calculations
- Fix non_reentrant macro ambiguity in escrow contract
- Add #[allow(clippy::too_many_arguments)] to audit functions

All compilation errors fixed. Property-token and escrow contracts
now pass cargo check, cargo fmt, and cargo clippy.
@Lansa-18

Copy link
Copy Markdown
Contributor Author

@LaGodxy Fixed the CI errors.

@LaGodxy
LaGodxy merged commit 9e36795 into MettaChain:main Apr 28, 2026
11 of 14 checks passed
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.

API: Implement GraphQL API

4 participants