fix(tonco-dex): fix GraphQL bugs in pool stats and positions tools#143
Merged
xlabtg merged 3 commits intoxlabtg:mainfrom Apr 11, 2026
Merged
fix(tonco-dex): fix GraphQL bugs in pool stats and positions tools#143xlabtg merged 3 commits intoxlabtg:mainfrom
xlabtg merged 3 commits intoxlabtg:mainfrom
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: xlabtg#141
Bug 1 (tonco_get_pool_stats): When pool_address was missing or empty,
normalizeToRaw() returned undefined, JSON serialization silently dropped
the field, and the indexer returned ALL pools instead of erroring. Added
explicit early-return validation before normalizeToRaw().
Bug 2 (tonco_get_positions): The TONCO indexer's Position.pool field is
a String! (pool address scalar), NOT an embedded object type. The old
query selected subfields on it (pool { address version fee ... }), causing
a GraphQL validation error: "Field 'pool' must not have a selection since
type 'String!' has no subfields." Fixed by:
- Querying pool as a bare scalar field
- Using Position's own jetton0/jetton1 fields for token info
- Adding a separate pools query to fetch tick/version/fee for in-range calc
- Fixing creationTime parsing (indexer returns ISO string, not Unix timestamp)
Added regression tests for both bugs in index.test.js.
Fixes xlabtg#141
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $1.323729📊 Context and tokens usage:
Total: (85.7K + 2.5M cached) input tokens, 17.7K output tokens, $1.323729 cost 🤖 Models used:
📎 Log file uploaded as Gist (1454KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
Author
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit df50292.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes two critical GraphQL bugs reported in #141.
Bug 1:
tonco_get_pool_stats— silent wrong-result whenpool_addressmissingRoot cause: When
pool_addresswasundefined/empty,normalizeToRaw()returnedundefined. JSON serialization silently dropsundefinedfields, so{ address: undefined }became{}— the indexer then returned all pools instead of the requested one. The first pool in the response was silently used.Fix: Added explicit early-return validation before
normalizeToRaw():Bug 2:
tonco_get_positions— GraphQL validation error onpoolsubfieldRoot cause: The TONCO indexer's
Position.poolfield is aString!(raw pool address), not an embedded object type. The old query selected subfields on it:This caused:
"Field 'pool' must not have a selection since type 'String!' has no subfields."Fix:
poolas a bare scalar string (the pool address)Position's ownjetton0/jetton1fields (which ARE object types) for token infopoolsquery to fetchtick,version,fee,tickSpacingfor in-range calculationcreationTimeparsing: the indexer returns ISO date strings, not Unix timestampsHow to reproduce the issues
Bug 1:
Bug 2:
Tests
Regression tests added in
plugins/tonco-dex/tests/index.test.js:Bug #141 fix: tonco_get_pool_stats validates pool_address— 3 testsBug #141 fix: tonco_get_positions uses correct GraphQL schema— 3 testsAll 37 tests pass (
node --test plugins/tonco-dex/tests/index.test.js).Fixes #141