Skip to content

Rename HyperSyncSolanaClient to SvmHyperSyncClient - #1309

Merged
DZakh merged 8 commits into
mainfrom
claude/great-shannon-7ied68
Jun 11, 2026
Merged

Rename HyperSyncSolanaClient to SvmHyperSyncClient#1309
DZakh merged 8 commits into
mainfrom
claude/great-shannon-7ied68

Conversation

@DZakh

@DZakh DZakh commented Jun 11, 2026

Copy link
Copy Markdown
Member

Rename the Solana HyperSync client module from HyperSyncSolanaClient to SvmHyperSyncClient for consistency with SVM (Solana Virtual Machine) naming conventions used throughout the codebase.

Key Changes

  • Module rename: HyperSyncSolanaClientSvmHyperSyncClient across all imports and type references
  • Query field selection refactor: Move from per-instruction includeTransaction/includeLogs/includeTokenBalances flags to a centralized fields object that explicitly lists requested columns for each table
    • Under the server's default merge mode, requesting a table's columns opts the matched result set into that join
    • Tables with empty field lists return no rows, so opted-into tables must have their columns spelled out
    • This fixes a bug where omitting transaction columns silently dropped instruction.transaction data
  • Test coverage: Add comprehensive regression test (SvmHyperSyncSource_test.res) verifying:
    • instruction.block.time correctly carries the slot's blockTime from the response
    • Transaction and log columns are requested when event configs opt in
  • Live test rename: Update HyperSyncSolanaClient_test.resSvmHyperSyncClient_test.res with updated query structure
  • Schema updates: Add lastUpdatedTime field to TokenMetadata schema and handler to track block timestamps
  • Handler updates: Populate lastUpdatedTime and lastTxSignature in instruction handlers

Implementation Details

The field selection change ensures that when includeTransaction is true on an event config, the query explicitly requests all transaction columns (Slot, TransactionIndex, Signatures, FeePayer, Success, Err, Fee, ComputeUnitsConsumed, AccountKeys, RecentBlockhash, Version). Similarly for logs and token balances. This prevents silent data loss and makes the query intent explicit.

https://claude.ai/code/session_013QfKfr5YDVHaomTUZLn6dG

Summary by CodeRabbit

  • New Features

    • Register instruction-level event handlers in indexers
    • Token metadata writes now record a last-updated timestamp
  • Improvements

    • Updated SVM hypersync integration for instruction/transaction parsing and block queries
  • Tests

    • Added SVM client/source live and regression tests; removed an obsolete live client test

claude added 4 commits June 10, 2026 15:08
…k.time

Investigation of the "blockTime = undefined" report: instruction.block.time
is joined correctly from the response's blocks table (verified live against
solana.hypersync.xyz for the Metaplex window). However, the server returns
rows for the transaction/log/token-balance tables only when the table's
field list is non-empty, so the per-selection include_transaction /
include_logs flags silently returned nothing and instruction.transaction /
instruction.logs were always undefined. Spell out the needed columns
whenever an event config opts into them.

- New mocked-client regression test covers the blockTime join and the
  field-selection shape of the outgoing query.
- The live Metaplex demo now persists instruction.block.time and asserts
  every write carries a sane block time and a transaction signature.
- The live client test additionally asserts every matched instruction's
  slot comes back with a blockTime.

https://claude.ai/code/session_013QfKfr5YDVHaomTUZLn6dG
…e mode

Mirrors the svm_hypersync_source naming on the Rust side:
HyperSyncSolanaClient -> SvmHyperSyncClient,
HyperSyncSolanaSource -> SvmHyperSyncSource (tests renamed to match).

The server's default merge mode is released, so the per-selection
include_transaction / include_logs / include_token_balances flags are no
longer needed: requesting a table's columns in the field selection is what
opts the matched result set into that join. Drop the flags from the built
query and lock the full query shape into the mocked-client test. Verified
live that transactions/logs/token balances come back scoped to the matched
instructions without the flags.

https://claude.ai/code/session_013QfKfr5YDVHaomTUZLn6dG
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1f860723-81e7-49d7-be93-20f58c0756d2

📥 Commits

Reviewing files that changed from the base of the PR and between 8353b8f and 1d0b8c6.

📒 Files selected for processing (3)
  • packages/envio/src/sources/SvmHyperSyncClient.res
  • scenarios/test_codegen/test/SvmHyperSyncClient_test.res
  • scenarios/test_codegen/test/SvmHyperSyncSource_test.res
🚧 Files skipped from review as they are similar to previous changes (2)
  • scenarios/test_codegen/test/SvmHyperSyncClient_test.res
  • scenarios/test_codegen/test/SvmHyperSyncSource_test.res

📝 Walkthrough

Walkthrough

This PR migrates SvmHyperSyncSource from the legacy HyperSyncSolanaClient to the newer SvmHyperSyncClient library, restructures instruction-selection queries, updates generated indexer API types for SVM, adds lastUpdatedTime tracking to Metaplex metadata handlers, and provides test coverage for the new client.

Changes

SVM HyperSync Client Migration and Feature Enhancements

Layer / File(s) Summary
SvmHyperSyncSource client migration
packages/envio/src/sources/SvmHyperSyncSource.res
Switches HyperSync client from HyperSyncSolanaClient to SvmHyperSyncClient. Instruction selections drop per-selection includeTransaction/includeLogs/includeTokenBalances flags; these are now computed request-wide via fieldSelection. All parsing helpers and response types are updated to use SvmHyperSyncClient.ResponseTypes.*. Client instantiation and block-range query both retargeted to new client.
Source factory and dispatch wiring
packages/envio/src/ChainFetcher.res, packages/envio/src/Main.res
ChainFetcher factory invocation switches from HyperSyncSolanaSource.make to SvmHyperSyncSource.make. Main.res comment updated to clarify SvmHyperSyncSource is the source and payload is svmInstruction.
Generated indexer API updates
scenarios/svm_test/src/Indexer.res
Transaction.t reshaped to SVM fields (slot, hash, time). New onInstructionOptions generic type introduced for instruction handler registration with instruction identity and optional where filter. Indexer type gains onInstruction registration method wired through Internal.genericHandler.
Metadata timestamp tracking feature
scenarios/svm_metaplex_demo/schema.graphql, scenarios/svm_metaplex_demo/src/handlers/TokenMetadataHandlers.ts, scenarios/svm_metaplex_demo/src/indexer.test.ts
TokenMetadataAccount schema adds required lastUpdatedTime: Int! field. CreateMetadataAccountV3 and UpdateMetadataAccountV2 handlers populate lastUpdatedTime from instruction block time. E2E test extended with BLOCK_TIME_FLOOR threshold and assertions that all metadata account writes include lastUpdatedTime above threshold and non-empty lastTxSignature.
Client test coverage
scenarios/test_codegen/test/SvmHyperSyncClient_test.res, scenarios/test_codegen/test/SvmHyperSyncSource_test.res, scenarios/svm_flow_xray/src/indexer.test.ts
Adds skipped live integration test for SvmHyperSyncClient validating recent slot queries, instruction/transaction presence, and blockTime above epoch threshold. Removes old HyperSyncSolanaClient test. Adds regression test for SvmHyperSyncSource.getItemsOrThrow mocking client response and verifying blockTime→timestamp mapping and transaction column inclusion on include-transaction events. Test comments updated to new source naming.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • enviodev/hyperindex#1287: Introduces foundational SVM indexing support; this PR builds on that by replacing the HyperSyncSolanaClient with the newer SvmHyperSyncClient implementation for production use.
  • enviodev/hyperindex#1307: Both PRs update HyperSync query construction to remove per-selection include flags and rely on request-level fieldSelection; changes are closely related to the instruction-selection restructure in this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the primary change: renaming HyperSyncSolanaClient to SvmHyperSyncClient, which is reflected across multiple source files and modules in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scenarios/test_codegen/test/SvmHyperSyncClient_test.res`:
- Around line 28-43: The test currently reads the first instruction with
Array.getUnsafe(0) (assigned to `first`) before checking `hasInstructions`,
which can throw on empty responses; change the logic to only access
`resp.data.instructions` when its length is > 0 (the same condition used for
`hasInstructions`) — e.g. compute `hasInstructions` first from
`resp.data.instructions->Array.length`, then conditionally obtain `first` (or
use a safe option-get) and only reference `first.programId` and `first.data`
when the option/conditional proves an instruction exists; update references in
the summary block accordingly so no unsafe indexing occurs.

In `@scenarios/test_codegen/test/SvmHyperSyncSource_test.res`:
- Around line 93-99: The test mutates global Core.addonRef to inject a mock
HypersyncSolanaClient and never restores it; wrap the setup so you save the
original value of Core.addonRef before assigning the mock (e.g.,
originalAddonRef = Core.addonRef), run SvmHyperSyncSource.make(...) and the
assertions, and then restore Core.addonRef back to originalAddonRef in a
finally/cleanup block (or use the test framework's afterEach/teardown) to avoid
leaking the mock into other tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e53a5981-e607-4b66-8501-8c55a304b2b6

📥 Commits

Reviewing files that changed from the base of the PR and between b0021f6 and 8353b8f.

📒 Files selected for processing (12)
  • packages/envio/src/ChainFetcher.res
  • packages/envio/src/Main.res
  • packages/envio/src/sources/SvmHyperSyncClient.res
  • packages/envio/src/sources/SvmHyperSyncSource.res
  • scenarios/svm_flow_xray/src/indexer.test.ts
  • scenarios/svm_metaplex_demo/schema.graphql
  • scenarios/svm_metaplex_demo/src/handlers/TokenMetadataHandlers.ts
  • scenarios/svm_metaplex_demo/src/indexer.test.ts
  • scenarios/svm_test/src/Indexer.res
  • scenarios/test_codegen/test/HyperSyncSolanaClient_test.res
  • scenarios/test_codegen/test/SvmHyperSyncClient_test.res
  • scenarios/test_codegen/test/SvmHyperSyncSource_test.res
💤 Files with no reviewable changes (1)
  • scenarios/test_codegen/test/HyperSyncSolanaClient_test.res

Comment thread scenarios/test_codegen/test/SvmHyperSyncClient_test.res Outdated
Comment thread scenarios/test_codegen/test/SvmHyperSyncSource_test.res Outdated
claude added 2 commits June 11, 2026 12:28
…7ied68

# Conflicts:
#	packages/envio/src/sources/SvmHyperSyncSource.res
#	scenarios/test_codegen/test/HyperSyncSolanaClient_test.res
Read the first instruction as an option so an empty live response fails
the shape assertion instead of throwing, and save/restore Core.addonRef
around the mocked client injection so the mock can't leak into other
tests sharing the process. Mock fromConfig now also takes the user-agent
argument added in client v0.0.7.

https://claude.ai/code/session_013QfKfr5YDVHaomTUZLn6dG
@DZakh
DZakh enabled auto-merge (squash) June 11, 2026 13:05
@DZakh
DZakh merged commit ad3d70d into main Jun 11, 2026
14 of 15 checks passed
@DZakh
DZakh deleted the claude/great-shannon-7ied68 branch June 11, 2026 13:15
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.

2 participants