Skip to content

Fix JS/TS docs snippets with invalid SDK syntax, missing imports, and undefined variables - #31

Draft
kaankacar with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-broken-js-sdk-code-snippets
Draft

Fix JS/TS docs snippets with invalid SDK syntax, missing imports, and undefined variables#31
kaankacar with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-broken-js-sdk-code-snippets

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown

This PR addresses copy-paste failures in JS/TS snippets across Horizon, RPC, contract, and token docs where examples had invalid syntax, missing imports, or undefined identifiers. The updates are scoped to snippet correctness and consistency so examples parse and run as written.

  • Horizon error-handling examples

    • Corrected Horizon server construction to current SDK form (new StellarSdk.Horizon.Server(...)).
    • Replaced non-JS time.sleep(...) with async JS delay.
    • Normalized inconsistent sdk vs StellarSdk usage in touched snippets.
    • Added a direct cross-link to the JS SDK error-handling guide.
  • Contract interaction/simulation snippets

    • Fixed CommonJS destructuring alias syntax (rpc: StellarRpc).
    • Added missing imports used in snippets (BASE_FEE, nativeToScVal, Address).
    • Fixed missing new Server(...) usage and an undefined variable reference in auth-entry TTL logic.
  • Token issuance and transaction guide fixes

    • Replaced curly quotes in fromSecret(...) with valid string quotes.
    • Added missing early import * as StellarSdk from "@stellar/stellar-sdk"; where global SDK usage was assumed.
    • Fixed undefined SERVER usage in path payments.
    • Fixed undefined tmpStatus/status references in shared submitTx helper snippet.
    • Fixed undefined networkPassPhrase/returnContractResponse references in automate-reset-data snippet.
  • RPC/getLedgerEntries and archival snippets

    • Added explicit imports for Server (RPC) and AssetType/related SDK types where used.
    • Fixed empty TypeScript return type and added missing xdr import in restore-contract example.
// Before
const s = Server("https://soroban-testnet.stellar.org");
throw tmpStatus;

// After
const s = new Server("https://soroban-testnet.stellar.org");
throw finalStatus;

Co-authored-by: kaankacar <103106776+kaankacar@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix broken JS SDK code snippets for documentation Fix JS/TS docs snippets with invalid SDK syntax, missing imports, and undefined variables Jul 16, 2026
Copilot AI requested a review from kaankacar July 16, 2026 17:36
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.

Fix broken JS SDK code snippets (invalid syntax, missing imports, undefined variables)

2 participants