Skip to content

docs(solana): update HyperSync query API to the v0.2.0 shape - #1022

Open
JasoonS wants to merge 1 commit into
mainfrom
js/hypersync-solana-query-docs
Open

docs(solana): update HyperSync query API to the v0.2.0 shape#1022
JasoonS wants to merge 1 commit into
mainfrom
js/hypersync-solana-query-docs

Conversation

@JasoonS

@JasoonS JasoonS commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Updates the HyperSync Solana docs (docs/HyperSync/Solana/) to the latest query/response shape from hypersync-solana-net-types v0.2.0. Scoped to HyperSync only - no HyperIndex docs touched (HyperIndex is still on the old client and will be updated separately).

What changed

  • Renames (legacy names still accepted as input aliases; responses use the new names):
    • instructions -> instruction_calls (top-level query)
    • program_id -> executing_account (instruction selection + field)
    • field_selection.instruction -> instruction_call
    • accounts -> account_arguments (instruction field), plus new derived executing_account_index / account_index_arguments
    • Documented in a new "Renamed fields and compatibility" section.
  • is_committed instruction filter (server-side failed-transaction exclusion), derived from parent-tx success, plus new transaction_id / transaction_index transaction filters.
  • Unified account_activity table replacing the removed balances / token_balances tables: native SOL + SPL token merged per (transaction, account), decimal-string token amounts, header-derived position flags. Old balance / token_balance field-selection tables removed.
  • Strict envelope: unknown top-level / field_selection keys are now rejected (a removed table errors instead of silently widening the query).
  • Refreshed the curl examples and the overview table-model / stable-surface lists to match.

Do not merge yet

The public https://solana.hypersync.xyz endpoint is still serving the old client version. These docs describe the v0.2.0 shape (account_activity, strict envelope, new response field names), so they should land when that endpoint is upgraded. Staged as a PR per request; leaving merge timing to align with the endpoint rollout.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated Solana HyperSync guides and examples to reflect the latest instruction-call and account-activity APIs.
    • Added guidance for transaction filtering, pagination, account selection, validation, and committed-status semantics.
    • Clarified response fields, token balance formatting, compatibility aliases, and supported query selections.

Bring the Solana HyperSync docs up to the latest query/response shape:

- instruction_calls (was instructions), executing_account (was program_id),
  field_selection.instruction_call (was instruction), account_arguments
  (was accounts); legacy names still accepted as aliases, documented in a
  new "Renamed fields and compatibility" section.
- New server-side is_committed instruction filter for excluding failed
  transactions, plus transaction_id / transaction_index selection filters.
- Unified account_activity table replacing the removed balances /
  token_balances tables, with the native/token merge semantics and
  decimal-string token amounts.
- Strict envelope: unknown top-level / field_selection keys are now
  rejected (removed tables error instead of silently matching everything).
- Refresh curl examples and the overview table model to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
envio-docs Ready Ready Preview Jul 31, 2026 8:42am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Solana HyperSync documentation now uses instruction_call and unified account_activity schemas. Query reference material, curl examples, filters, response fields, compatibility aliases, and API overviews were updated.

Changes

Solana HyperSync documentation

Layer / File(s) Summary
Query schema and response model
docs/HyperSync/Solana/solana-query.md
The query reference adds account-activity selections, renamed instruction fields, validation rules, limits, response fields, commitment filters, and legacy input aliases.
Curl example migration
docs/HyperSync/Solana/solana-curl-examples.md
Examples use instruction-call selections, executing_account, account_arguments, unified account activity, OR filters, and updated pagination queries.
API overview alignment
docs/HyperSync/Solana/solana.md
The overview updates API coverage, request examples, filters, stable request shapes, and table names for instruction calls and account activity.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 clearly and concisely describes the Solana HyperSync documentation update to the v0.2.0 query API shape.
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.

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

@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: 4

🤖 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 `@docs/HyperSync/Solana/solana-curl-examples.md`:
- Around line 96-100: Update the OR-filter explanation in the Solana cURL
examples to refer to instruction_calls, matching the example payload. Keep
instructions identified only as the legacy input alias.

In `@docs/HyperSync/Solana/solana-query.md`:
- Line 64: Update the wording in the is_committed documentation so “land on
chain” uses the hyphenated form “land on-chain,” leaving the surrounding
explanation unchanged.
- Line 149: Update the documentation paragraph describing pre_token_balance and
post_token_balance to remove the claim that Token-2022 amounts can exceed
u64::MAX. Keep their raw base-unit decimal-string representation and state that
consumers interpret them using token_decimals; note that Token-2022 account and
instruction amounts use u64 and values above u64::MAX require a documented wider
endpoint type.
- Around line 31-32: Remove the unsupported include_account_activity field from
both envelope examples in the Solana query documentation, while leaving the
account_activity examples and all other query fields unchanged.
🪄 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: 734e6cd2-d8a0-455e-a664-09a0c034155d

📥 Commits

Reviewing files that changed from the base of the PR and between 43388cd and f293bd6.

📒 Files selected for processing (3)
  • docs/HyperSync/Solana/solana-curl-examples.md
  • docs/HyperSync/Solana/solana-query.md
  • docs/HyperSync/Solana/solana.md

Comment on lines +96 to +100
"instruction_call": ["slot", "executing_account", "data", "d8"]
},
"instructions": [
{ "program_id": ["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"] },
{ "program_id": ["whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"] }
"instruction_calls": [
{ "executing_account": ["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"] },
{ "executing_account": ["whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"] }

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use instruction_calls in the OR-filter explanation.

The example uses instruction_calls, but the description still says instructions. instructions is documented as the legacy input alias.

-Each object in `instructions` is OR-ed.
+Each object in `instruction_calls` is OR-ed.
🤖 Prompt for 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.

In `@docs/HyperSync/Solana/solana-curl-examples.md` around lines 96 - 100, Update
the OR-filter explanation in the Solana cURL examples to refer to
instruction_calls, matching the example payload. Keep instructions identified
only as the legacy input alias.

Comment on lines +31 to +32
"account_activity": [ ... ],
"include_account_activity": false,

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/sh
set -eu
: "${URL:?set URL}"
: "${TOKEN:?set TOKEN}"
: "${FROM_SLOT:?set FROM_SLOT}"
: "${TO_SLOT:?set TO_SLOT}"

curl -sS "$URL/query" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"from_slot\":$FROM_SLOT,\"to_slot\":$TO_SLOT,\"include_account_activity\":false,\"field_selection\":{\"account_activity\":[\"slot\"]}}" |
  jq .

Repository: enviodev/docs

Length of output: 178


🏁 Script executed:

#!/bin/sh
set -eu
printf '%s\n' '--- candidate files ---'
git ls-files | grep -E '(^|/)(solana-query\.md|.*hyper.*solana.*|.*net-types.*)$' | head -80
printf '%s\n' '--- document context ---'
sed -n '1,90p' docs/HyperSync/Solana/solana-query.md
printf '%s\n' '--- field references ---'
rg -n -i 'include_account_activity|account_activity|hypersync-solana-net-types|unknown.*key|validation' .

Repository: enviodev/docs

Length of output: 50371


🌐 Web query:

hypersync-solana-net-types v0.2.0 include_account_activity

💡 Result:

The field include_account_activity is not a valid or currently supported field in the hypersync-solana-net-types crate. Development history of the Envio Solana HyperSync tooling indicates that per-selection include_* flags (which were previously used to gate whether specific data, such as transactions or logs, were attached to emitted items) were removed in version 0.0.7 of the hypersync-solana-net-types and hypersync-client-solana crates [1][2]. In these newer versions, the server automatically applies a default data join based on the field_selection provided in the query, rendering explicit include_* flags unnecessary and obsolete [1][2]. If you are looking for specific account-related data, Envio's HyperIndex and HyperSync documentation clarifies that there is no dedicated onAccount or "account activity" handler [3]. Instead, account state is accessed via the accounts referenced within specific instructions, or through transaction-level data such as token balance changes [3]. You should structure your queries using field_selection and appropriate instruction filters (e.g., matching by program ID and discriminator) to retrieve the relevant data [4][1][2].

Citations:


🏁 Script executed:

#!/bin/sh
set -eu
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

printf '%s\n' '--- crates.io metadata ---'
curl -fsSL https://crates.io/api/v1/crates/hypersync-solana-net-types/0.2.0 |
  jq '{name,version,dl主: .version.dl_path, crate_size: .version.crate_size}'

printf '%s\n' '--- crate source references ---'
url="$(curl -fsSL https://crates.io/api/v1/crates/hypersync-solana-net-types/0.2.0 |
  jq -r '.version.dl_path')"
curl -fsSL "https://crates.io${url}" -o "$tmpdir/crate.tgz"
tar -xzf "$tmpdir/crate.tgz" -C "$tmpdir"
rg -n -i 'include_account_activity|include_.*activity|account_activity|deny_unknown_fields|Query' "$tmpdir" || true

printf '%s\n' '--- cited upstream change ---'
curl -fsSL https://api.github.com/repos/enviodev/hyperindex/pulls/1307 |
  jq '{title,state,body,merged_at,html_url}'
curl -fsSL https://api.github.com/repos/enviodev/hyperindex/commits/b0021f6ab8331146286a8348e8ea414c2d967e84 |
  jq '{sha:.sha,message:.commit.message,html_url}'

Repository: enviodev/docs

Length of output: 641


🏁 Script executed:

#!/bin/sh
set -eu
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

printf '%s\n' '--- crates.io metadata ---'
curl -fsSL -A 'Mozilla/5.0' \
  https://crates.io/api/v1/crates/hypersync-solana-net-types/0.2.0 |
  jq '{name, version: .version.num, download_path: .version.dl_path, crate_size: .version.crate_size}'

printf '%s\n' '--- crate source ---'
curl -fsSL -A 'Mozilla/5.0' \
  https://static.crates.io/crates/hypersync-solana-net-types/hypersync-solana-net-types-0.2.0.crate \
  -o "$tmpdir/crate.tgz"
tar -xzf "$tmpdir/crate.tgz" -C "$tmpdir"
rg -n -i 'include_account_activity|include_.*activity|account_activity|deny_unknown_fields|Query' "$tmpdir" || true

printf '%s\n' '--- cited upstream change ---'
curl -fsSL -A 'Mozilla/5.0' \
  https://api.github.com/repos/enviodev/hyperindex/pulls/1307 |
  jq '{title,state,body,merged_at,html_url}'
curl -fsSL -A 'Mozilla/5.0' \
  https://api.github.com/repos/enviodev/hyperindex/commits/b0021f6ab8331146286a8348e8ea414c2d967e84 |
  jq '{sha:.sha,message:.commit.message,html_url}'

Repository: enviodev/docs

Length of output: 299


🏁 Script executed:

#!/bin/sh
set -eu
printf '%s\n' '--- all occurrences in the document ---'
rg -n -C8 'include_account_activity|account_activity' docs/HyperSync/Solana/solana-query.md

printf '%s\n' '--- upstream references ---'
for url in \
  'https://raw.githubusercontent.com/enviodev/hyperindex/main/packages/hypersync-solana-net-types/src/lib.rs' \
  'https://raw.githubusercontent.com/enviodev/hyperindex/main/packages/hypersync-solana-net-types/src/query.rs' \
  'https://raw.githubusercontent.com/enviodev/hyperindex/b0021f6ab8331146286a8348e8ea414c2d967e84/packages/hypersync-solana-net-types/src/lib.rs' \
  'https://raw.githubusercontent.com/enviodev/hyperindex/b0021f6ab8331146286a8348e8ea414c2d967e84/packages/hypersync-solana-net-types/src/query.rs'
do
  printf '\n--- %s ---\n' "$url"
  curl -fsSL "$url" 2>/dev/null | rg -n -i 'include_account_activity|include_.*activity|account_activity|query' || true
done

printf '%s\n' '--- repository tree matches from GitHub API ---'
curl -fsSL 'https://api.github.com/repos/enviodev/hyperindex/git/trees/main?recursive=1' |
  jq -r '.tree[]?.path' |
  grep -Ei 'solana|hypersync.*types|net-types' |
  head -100

Repository: enviodev/docs

Length of output: 9017


Remove include_account_activity from the envelope examples.

hypersync-solana-net-types v0.2.0 does not support this top-level field. The strict query schema rejects it. Apply this change to both examples.

🤖 Prompt for 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.

In `@docs/HyperSync/Solana/solana-query.md` around lines 31 - 32, Remove the
unsupported include_account_activity field from both envelope examples in the
Solana query documentation, while leaving the account_activity examples and all
other query fields unchanged.

| `is_inner` | `true` = inner only, `false` = outer only, **omitted** = both. |
| `is_committed` | `true` = only instructions of successful transactions, `false` = only instructions of failed transactions, **omitted** = both. See the note below. |

**`is_committed`:** Failed transactions still land on chain, and their instructions (up to the point of failure) are served. `is_committed` is derived from the parent transaction's success, so consumers that count on-chain effects should set `"is_committed": true` to filter failed transactions **server-side** rather than dropping them after the fact.

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the hyphenated form on-chain.

Change “land on chain” to “land on-chain”.

Proposed wording fix
-Failed transactions still land on chain
+Failed transactions still land on-chain
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
**`is_committed`:** Failed transactions still land on chain, and their instructions (up to the point of failure) are served. `is_committed` is derived from the parent transaction's success, so consumers that count on-chain effects should set `"is_committed": true` to filter failed transactions **server-side** rather than dropping them after the fact.
**`is_committed`:** Failed transactions still land on-chain, and their instructions (up to the point of failure) are served. `is_committed` is derived from the parent transaction's success, so consumers that count on-chain effects should set `"is_committed": true` to filter failed transactions **server-side** rather than dropping them after the fact.
🧰 Tools
🪛 LanguageTool

[grammar] ~64-~64: Use a hyphen to join words.
Context: ...ed`:** Failed transactions still land on chain, and their instructions (up to the...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for 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.

In `@docs/HyperSync/Solana/solana-query.md` at line 64, Update the wording in the
is_committed documentation so “land on chain” uses the hyphenated form “land
on-chain,” leaving the surrounding explanation unchanged.

Source: Linters/SAST tools

- **Native side** (`pre_balance`, `post_balance`, in lamports) is populated when the account's SOL balance changed in this transaction, null otherwise.
- **Token side** (`mint`, `owner`, `token_decimals`, `pre_token_balance`, `post_token_balance`, `pre_program_id`, `post_program_id`) is populated when the account appears in the transaction's token-balance metadata, null otherwise.

A row commonly carries **both** sides, since a token account also holds lamports; the native and token amounts are independent axes, not two encodings of one value (for wrapped SOL, lamports equal the token amount plus the rent-exempt reserve). `pre_token_balance` / `post_token_balance` are raw base-unit **decimal strings** (scaled by `token_decimals`), not numbers, because Token-2022 amounts can exceed `u64::MAX`. `account_index` is the account's position in the transaction's resolved key list (`account_keys` ++ ALT writable ++ ALT readonly); the flags (`is_signer`, `is_writable`, `is_fee_payer`, `from_lookup_table`) are derived from the message header and are null where a source could not supply them.

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- target lines ---'
sed -n '135,160p' docs/HyperSync/Solana/solana-query.md
printf '%s\n' '--- repository references ---'
rg -n -S 'pre_token_balance|post_token_balance|token_decimals|Token-2022|u64|v0\.2\.0' . \
  -g '!node_modules' -g '!dist' -g '!build' | head -250

Repository: enviodev/docs

Length of output: 9410


🌐 Web query:

docs.rs spl-token-2022-interface Account amount u64 token instruction amount u64 Token-2022

💡 Result:

In the Token-2022 (SPL Token 2022) program, the amount field in the Account state structure is defined as a u64 [1][2][3][4]. This field represents the raw number of tokens held by the account [5][2][3][4]. Similarly, for instruction data involving token transfers, minting, or burning (such as Transfer, MintTo, Burn, TransferChecked, etc.), the amount parameter is also defined as a u64 [6]. Key points regarding the use of u64 for token amounts in Token-2022: 1. Account Structure: The spl_token_2022_interface::state::Account (and its counterpart in the spl_token_2022 crate) stores the balance as a u64 [1][2][3]. It is serialized and deserialized using little-endian byte ordering [5][3][4]. 2. Instruction Data: Token-2022 instructions that require an amount to be specified (e.g., to indicate how many tokens to transfer or mint) use u64 in their instruction enums [6]. 3. Pod Types: When using the Pod (Plain Old Data) traits for account structures, the amount field is represented as a U64 type (a pod-compatible 64-bit unsigned integer) [7]. 4. UI Conversion: The SPL Token-2022 library provides utility functions like ui_amount_to_amount and amount_to_ui_amount which facilitate the conversion between human-readable UI amounts (often represented as floats or strings) and the raw u64 amounts used by the on-chain program [8][9]. The use of u64 limits the maximum raw token balance to 2^64 - 1 for any individual account [1][2][3].

Citations:


🌐 Web query:

Solana transaction token balance metadata amount string decimals u64 Token-2022

💡 Result:

In the Solana Token-2022 program, token amounts are represented as 64-bit unsigned integers (u64) in the instruction data for operations like transfer, mint, and burn [1][2][3]. These u64 values represent the atomic, base units of the token, not the human-readable UI amount [1][2]. Key technical details regarding these amounts and metadata: Atomic Amounts (u64): Instruction variants such as TransferChecked, MintToChecked, and BurnChecked use a u64 field for the amount and a u8 field for decimals [2][3]. The program uses the decimals field to verify that the client is interacting with the correct token scale [2]. For example, if a token has 6 decimals, transferring 1 unit of the token requires an amount of 1,000,000 to be specified in the u64 field [1][2]. Metadata Strings: Unlike the legacy Metaplex metadata standard, which uses fixed-size padded fields, the Token-2022 Token Metadata extension uses true Borsh-encoded strings [4]. Each string (such as name, symbol, or URI) consists of a 4-byte little-endian u32 length prefix followed by the exact number of UTF-8 encoded bytes, with no padding [4]. Utilities and Conversions: The SPL Token program library provides utilities for converting between raw amounts (u64) and UI representations (float or string). - Conversion functions (e.g., amount_to_ui_amount_string) handle the division by 10^decimals to produce human-readable strings [5][6]. - These functions often rely on floating-point arithmetic, which is noted in documentation to have potential consistency issues for complex extensions (like interest-bearing tokens), so users are advised to be cautious when performing these conversions in sensitive contexts [7]. Instruction Data Layout: Token-2022 maintains compatibility with standard SPL Token instruction layouts [1]. The instruction data typically begins with a 1-byte discriminator [2]. For "Checked" variants, the layout is: [1-byte discriminator] + [8-byte u64 amount] + [1-byte u8 decimals] [1][2].

Citations:


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path
from urllib.request import urlopen

doc = Path("docs/HyperSync/Solana/solana-query.md").read_text()
needle = "pre_token_balance` / `post_token_balance` are raw base-unit **decimal strings**"
assert needle in doc
assert "because Token-2022 amounts can exceed `u64::MAX`" in doc

url = "https://docs.rs/spl-token-2022-interface/latest/src/spl_token_2022_interface/state.rs.html"
html = urlopen(url, timeout=10).read().decode("utf-8", "replace")
assert "amount" in html and "u64" in html
print("local serialization wording: present")
print("local overflow claim: present")
print("authoritative Token-2022 state source contains amount and u64: present")
PY

Repository: enviodev/docs

Length of output: 2438


Remove the Token-2022 overflow claim. Keep the decimal-string serialization, but state that the raw base-unit amounts must be interpreted with token_decimals. Token-2022 account and instruction amounts use u64, so values above u64::MAX require a documented wider endpoint type.

🤖 Prompt for 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.

In `@docs/HyperSync/Solana/solana-query.md` at line 149, Update the documentation
paragraph describing pre_token_balance and post_token_balance to remove the
claim that Token-2022 amounts can exceed u64::MAX. Keep their raw base-unit
decimal-string representation and state that consumers interpret them using
token_decimals; note that Token-2022 account and instruction amounts use u64 and
values above u64::MAX require a documented wider endpoint type.

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.

1 participant