Repository navigation
chore: migrate indexer to stellar-sdk 17 XDR discriminated unions - #347
Open
Cynthiaoma wants to merge 1 commit into
Open
Cynthiaoma wants to merge 1 commit into
Cynthiaoma wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Overview
This PR migrates the XDR decoding paths from the legacy
.switch()/ accessor-call style to the discriminated-union types introduced in@stellar/stellar-sdk17, so the indexer compiles and decodes contract data correctly on the bumped SDK. The changes are limited to the files that decode ledger entries andScVals, plus a new test for SAC detection.Related Issue
Changes
🔧 XDR decoding migration
[MODIFY]
src/decoder.tsscVal.switch()comparisons withscVal.typediscriminant checks againstScValTypemembers. Each branch now matches the same variant it previously matched (previously matched viaswitch()return value; now via thetypefield).[MODIFY]
src/indexer/lp-shares.tsledgerEntryData.contractData()accessor call with a narrowing check onledgerEntryData.type === 'contractData', then read thecontractDatapayload directly.[MODIFY]
src/indexer/sac-detect.tsContractExecutableunion. The branch that identifies a Stellar Asset Contract now matches thestellarAssetvariant explicitly; the wasm-executable branch continues to classify non-SAC contracts. Contract ids are not shortened anywhere.[MODIFY]
src/ingester/nft.tsdecoder.tsforScValreads in the NFT ingest path.🧪 Tests
src/__tests__/sacDetect.test.tssac-detect.ts, asserting the classification result for each.📦 Dependencies
package.json,package-lock.json@stellar/stellar-sdkfrom 15.0.1 to 17.2.1 (Dependabot chore(deps): bump @stellar/stellar-sdk from 15.0.1 to 17.2.1 #233).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.
npx tsc --noEmitclean on stellar-sdk 17src/__tests__/sacDetect.test.tsNotes for reviewers
src/api/linqWebhook.tsand 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.tsand the generated OpenAPI spec are unchanged; no route or middleware was touched.Closes #290