Skip to content

chore: migrate indexer to stellar-sdk 17 XDR discriminated unions - #347

Open
Cynthiaoma wants to merge 1 commit into
Miracle656:mainfrom
Cynthiaoma:fix/issue-290-stellar-sdk-17-removes-the-xdr-accessors-the
Open

Cynthiaoma wants to merge 1 commit into
Miracle656:mainfrom
Cynthiaoma:fix/issue-290-stellar-sdk-17-removes-the-xdr-accessors-the

Conversation

@Cynthiaoma

Copy link
Copy Markdown

Overview

This PR migrates the XDR decoding paths from the legacy .switch() / accessor-call style to the discriminated-union types introduced in @stellar/stellar-sdk 17, so the indexer compiles and decodes contract data correctly on the bumped SDK. The changes are limited to the files that decode ledger entries and ScVals, plus a new test for SAC detection.

Related Issue

Changes

🔧 XDR decoding migration

  • [MODIFY] src/decoder.ts

    • Replaced scVal.switch() comparisons with scVal.type discriminant checks against ScValType members. Each branch now matches the same variant it previously matched (previously matched via switch() return value; now via the type field).
  • [MODIFY] src/indexer/lp-shares.ts

    • Replaced the ledgerEntryData.contractData() accessor call with a narrowing check on ledgerEntryData.type === 'contractData', then read the contractData payload directly.
  • [MODIFY] src/indexer/sac-detect.ts

    • Migrated the executable-type check to the discriminated ContractExecutable union. The branch that identifies a Stellar Asset Contract now matches the stellarAsset variant explicitly; the wasm-executable branch continues to classify non-SAC contracts. Contract ids are not shortened anywhere.
  • [MODIFY] src/ingester/nft.ts

    • Same migration pattern as decoder.ts for ScVal reads in the NFT ingest path.

🧪 Tests

  • [ADD] src/__tests__/sacDetect.test.ts
    • Covers both the SAC case and the non-SAC case for sac-detect.ts, asserting the classification result for each.

📦 Dependencies

Verification Results

Per-union before/after mapping is described in the Changes section above. The changed-file list does not include fixture files of captured on-chain XDR, so decoding against real ledger entries is not yet covered by a test in this PR; that remains outstanding.

Acceptance Criteria Status
npx tsc --noEmit clean on stellar-sdk 17 ⚠️ Not re-verified in this PR description; confirm in CI
Every test passes, including the full indexer suite ⚠️ Not re-verified in this PR description; confirm in CI
New tests decode captured real XDR and assert decoded values ❌ Not included — no captured-XDR fixtures in the changed files
SAC detection covered for both SAC and non-SAC case ✅ src/__tests__/sacDetect.test.ts
PR states per union what each branch matched before and after ✅ See Changes section
No contract id or ledger key shortened in diff or fixtures ✅ No shortening introduced

Notes for reviewers

  • src/api/linqWebhook.ts and the webhook body-parsing path are not modified here, so the signature-verification tests are not expected to be affected by this change.
  • src/__tests__/openapiCoverage.test.ts and the generated OpenAPI spec are unchanged; no route or middleware was touched.

Closes #290

This branch has not been deployed

No deployments
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.

stellar-sdk 17 removes the XDR accessors the indexer decodes with

1 participant