Repository navigation
Closed
Labels
Description
Context
@stellar/stellar-sdk 17 moved its XDR types to plain classes with property access. The method-style getters are gone: union arms (.switch(), .v1(), .contractData(), .accountId()), struct fields (.val(), .key(), .instance(), .claimants()), and enum constructors (xdr.ContractDataDurability.persistent()). Unions now expose .type and .value, struct fields are plain properties, and enum members are properties. See the XDR migration guide.
#2932 fixed this for the fee-payer sorobanData snippets. The JS snippets below still use the old getters and throw ... is not a function on 17.x. Checked against 17.4.0:
FAIL scAddr.switch() scAddr.switch is not a function
OK scAddr.type scAddressTypeAccount
FAIL scAddr.accountId() scAddr.accountId is not a function
FAIL asset.value.assetCode() asset.value.assetCode is not a function
OK asset.value.assetCode AssetCode4
The other open js-sdk-v17 issues (#2560, #2561, #2562, #2563, #2564, #2965, #2968) don't cover this.
Checklist
Line numbers are pinned to b5f22fb.
-
docs/build/apps/guestbook/frontend.mdxL395-397:message.val.contractData().key()and.contractData().val(). The guestbook template repo has the same code, so keep the two in sync (see Guestbook frontend: use the SDK's token amount helper instead of dividing by 1e7 #2965). -
docs/build/guides/archival/extend-persistent-entry-js.mdx -
docs/build/guides/archival/restore-contract-js.mdxL72:entry.val().instance().wasmHash() -
docs/build/guides/basics/verify-trustlines.mdxL162:entries[0].val.trustLine(), plus any field getters that follow it. -
docs/build/guides/dapps/state-archival.mdxL338:entry.val().instance().wasmHash() -
docs/build/guides/rpc/retrieve-contract-code-js.mdxL71-75:.contractData().val().instance().executable().wasmHash() -
docs/build/guides/transactions/claimable-balances.mdx -
docs/build/guides/transactions/clawbacks.mdx -
docs/data/apis/rpc/api-reference/methods/getLedgerEntries.mdxL525, L694, L733-766:.switch(),.val().instance().executable().wasmHash(),.contractData(),.contractCode().code() -
docs/learn/fundamentals/contract-development/contract-interactions/stellar-transaction.mdxL562:entry.switch() -
docs/learn/fundamentals/contract-development/storage/state-archival.mdxL371:entry.val().instance().wasmHash() -
docs/learn/fundamentals/data-format/xdr.mdxL91-147: this is the conceptual section on unions.- Both TypeScript examples use
scAddr.switch()andscAddr.accountId(). - Rewrite them around
.typeand.value. The Python tab already uses that shape. - The JS reference link points at
js-stellar-basecurr.d.ts. Point it at the SDK docs instead (see Reflect stellar-base fold-in (SDK v16): stop pointing readers at js-stellar-base and js-soroban-client #2560).
- Both TypeScript examples use
Notes for the fix
- Run each rewritten snippet against
@stellar/stellar-sdk17.x. Don't just pattern-replace: some chains pass through a union (.valon a ledger entry result, then.valuefor the arm), and the right property path depends on the type. fromXDRstill works on 17, so it doesn't need changing in these snippets.- Out of scope:
docs/data/analytics/hubble/developer-guide/backfill/JS-UDF.mdxusestxe.feeBump().tx(), but it runs against a pinnedStellarBasebundle inside a BigQuery UDF, not the current SDK. - Also out of scope: Rust
env.storage().instance()andKeypair.accountId()calls aren't XDR getters.
Reacted by stellar-doxie
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
stellar-doxie commentedon Nov 9, 2026
🤖 Automated message from the Stellar Triage Bot.
Working this because @ElliotFriend added bot:take.
I am checking each listed snippet against
@stellar/stellar-sdk17.x now. I will report back with a PR or a question.stellar-doxie commentedon Nov 9, 2026
🤖 Automated message from the Stellar Triage Bot.
Working this because @ElliotFriend added bot:take.
PR #3083 ports every checklist item to
@stellar/stellar-sdk17.x. Thechecksjob passes.^16.4.1and uses the old getters. It needs the same change.Keep the guestbook frontend page on v16 getters
Port JS snippets to stellar-sdk v17 XDR property access (#3083)