Skip to content

Port JS snippets to stellar-sdk v17 XDR property access - #3083

Merged
ElliotFriend merged 2 commits into
mainfrom
docs-agent/3082-xdr-v17-property-access
Nov 10, 2026
Merged

ElliotFriend merged 2 commits into
mainfrom
docs-agent/3082-xdr-v17-property-access

Conversation

@stellar-doxie

@stellar-doxie stellar-doxie Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Automated message from the Stellar Triage Bot.

Closes #3082

Working this because @ElliotFriend added bot:take. This PR ports the JS snippets that use v16 XDR getters to @stellar/stellar-sdk 17.x.

What changes:

  • Getters become properties (entry.val.trustLine, claimant.v0.destination). Int64 fields are already bigint, so .toBigInt() goes.
  • .switch() becomes a .type check. TypeScript snippets narrow with xdr.expectUnionVariant.
  • Enum factories and union constructors use the v17 forms (xdr.ContractEventType.contract, xdr.ContractEventBody.v0(...)).
  • Byte wrappers get .toBytes() before StrKey.

Beyond the checklist (the same v17 break, or a bug in a block this PR rewrites):

  • create-account.mdx, pooled-accounts-muxed-accounts-memos.mdx and more clawbacks.mdx lines call balance().toBigInt().
  • events.mdx: fullEventLog used ContractEventType.contract() and new ContractEventBody(0, ...). It now wraps the ID in xdr.ContractId, because v17 humanizeEvents calls contractId.toBytes().
  • create-restoration-footprint-js.mdx: new xdr.SorobanTransactionDataExt(0) throws on v17.
  • The three restore snippets (restore-contract-js.mdx, both state-archival.mdx pages) never put the Wasm code key in the footprint. They now read the instance entry, get its Wasm hash and restore both keys. The restore-contract-js.mdx intro said getFootprint() covers the Wasm code. It does not, so I reworded it and repointed its two js-soroban-client links (item 4 of Reflect stellar-base fold-in (SDK v16): stop pointing readers at js-stellar-base and js-soroban-client #2560).
  • getLedgerEntries.mdx: LedgerKey.ledgerKeyAccount and ledgerKeyTrustLine do not exist (account, trustline). The TS tab now fetches the trustline, like the Python tab. The request JSON lacked a comma. All edits are below the generated block.
  • stellar-transaction.mdx: the auth check read entry.switch() instead of the entry's credentials, and the async map returned promises. It now uses Promise.all.
  • xdr.mdx: the extractEvent excerpt now copies the v17.4.0 source, so the Structures section agrees with the new Unions section. The Python imports in that section were invalid.

Verification: every property, arm name and factory comes from the 17.4.0 typings on unpkg and the v17 XDR migration guide. I could not run the snippets here (no Node), and pnpm check did not run. The checks job covers formatting.

Notes:

  • The guestbook template (ElliotFriend/ye-olde-guestbook, src/lib/server/getLedgerEntries.ts) still pins ^16.4.1 and uses the old getters. It needs the same change plus the SDK bump.
  • Not changed: wallet/sep7.mdx:26 uses toXDR().toString("base64"), but through the wallet SDK's own stellar-sdk.
  • No overlap with open docs-agent PRs. Fill gaps from assistant conversations: clarify TTL vs auto-restore #3077 edits a different section of the learn state-archival.mdx.

Replace the method-style XDR getters, enum factory calls and union constructors that v17 removed with property access, .type checks and xdr.expectUnionVariant. Also fix the restore snippets so the footprint holds the instance and its Wasm code key.
@mintlify

mintlify Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
stellar-docs 🟢 Ready View Preview Nov 9, 2026, 10:30 PM

@ElliotFriend ElliotFriend 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.

Thanks for this. I ran the new accessors against @stellar/stellar-sdk 17.4.0, using XDR objects decoded with fromXdr, and they all work: expectUnionVariant and isUnionVariant, the LedgerKey.account and LedgerKey.trustline factories, the Wasm hash chains (including the TypeError for a Stellar Asset Contract), claimant.v0.destination.ed25519.toBytes(), tr.createClaimableBalanceResult.balanceId.toXdr("hex"), SorobanTransactionDataExt.v0(), and the rebuilt ContractEvent through humanizeEvents. The extractEvent excerpt also matches src/base/events.ts at v17.4.0.

One change before this merges:

  • Drop the docs/build/apps/guestbook/frontend.mdx hunk. That page mirrors the companion app (ElliotFriend/ye-olde-guestbook), which still pins @stellar/stellar-sdk ^16.4.1. The v17 property access won't work there. We'll update the page and the app together when the app moves to 17. Please leave the rest of the PR as it is, and don't remove the guestbook item from #3082 either; we'll track it there.

The page mirrors ElliotFriend/ye-olde-guestbook, which still pins @stellar/stellar-sdk ^16.4.1. The page and the app move to v17 together, tracked in #3082.
@stellar-doxie stellar-doxie Bot added the bot:ready-to-merge Bot verified and approved; waiting for a maintainer to merge label Nov 9, 2026
@stellar-doxie

stellar-doxie Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Automated message from the Stellar Triage Bot.

Back on this because @ElliotFriend requested changes.

Ready to merge once your change request is cleared.

@ElliotFriend
ElliotFriend merged commit 0678e4d into main Nov 10, 2026
8 checks passed
@ElliotFriend
ElliotFriend deleted the docs-agent/3082-xdr-v17-property-access branch November 10, 2026 16:49

This branch was successfully deployed

1 active deployment
staging — 878edb5f Deployed Nov 9, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:ready-to-merge Bot verified and approved; waiting for a maintainer to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update JS snippets that use XDR method getters removed in stellar-sdk v17

1 participant