Repository navigation
Open
Labels
Description
Context
An audit of JS SDK content across the docs found snippets that fail if copied as written. Each item below is a concrete fix with an exact location. These are copy-paste bugs, not API staleness; the surrounding pages are otherwise current.
Checklist
docs/data/apis/horizon/api-reference/errors/error-handling.mdx
- Line 69:
let server = sdk.Server("https://horizon-testnet.stellar.org");uses the pre-v10 constructor withoutnewand without theHorizonnamespace. Change tolet server = new sdk.Horizon.Server("https://horizon-testnet.stellar.org"); - Line 97:
time.sleep(5 * time.Second);is Go code inside a JS block. Replace withawait new Promise((resolve) => setTimeout(resolve, 5000)); - Line 138:
let server = Horizon.Server(...)is missingnew. Also normalize the inconsistentsdk.vsStellarSdk.naming across the page's snippets. - While in the file, cross-link the SDK error handling guide: https://stellar.github.io/js-stellar-sdk/guides/05-handle-errors/
docs/learn/fundamentals/contract-development/contract-interactions/stellar-transaction.mdx
- Line 48:
rpc as StellarRpcappears inside a CommonJSrequire()destructure.asaliasing is import-statement syntax; in a destructure it must berpc: StellarRpc(or convert the block to an ESM import).
docs/learn/fundamentals/contract-development/contract-interactions/transaction-simulation.mdx
- Line 75 and line 129:
const s = Server("https://soroban-testnet.stellar.org");is missingnew. - The snippets use
BASE_FEE,nativeToScVal, andAddresswithout importing them. Add them to the import statements.
docs/tokens/how-to-issue-an-asset.mdx
- Line 118: the secret key is wrapped in curly quotes (
‘...’), which is a syntax error if copied. Replace with straight quotes. - Early snippets on the page use a global
StellarSdkwith no import shown; add theimport * as StellarSdk from "@stellar/stellar-sdk";line (the full sample at the bottom already has it).
docs/build/guides/transactions/path-payments.mdx
- Line 77:
await SERVER.submitTransaction(transaction)references an undefinedSERVER. Use the Horizon server variable defined earlier in the snippet.
docs/data/apis/rpc/api-reference/methods/getLedgerEntries.mdx
- Line 387:
const s = new Server(...)with no import shown and no namespace. Showimport { Server } from "@stellar/stellar-sdk/rpc";(and theAssetTypeimport used nearby).
Secondary (undefined variables, verify while in the file)
-
docs/build/guides/basics/automate-reset-data.mdxline 180:networkPassPhraseis never defined (casing mismatch); line 264:returnContractResponseis never defined. The script also usesAssetandnativeToScValwithout importing them. -
docs/build/guides/transactions/submit-transaction-wait-js.mdxline 36:throw tmpStatus;references an undefined variable. Note this page defines the sharedsubmitTxhelper reused by several other guides, so fix carefully. -
docs/build/guides/archival/restore-contract-js.mdxline 69:function getWasmLedgerKey(entry: xdr.ContractDataEntry): {has an empty return type annotation (syntax error), and the file usesxdr.*without importingxdr.
Acceptance criteria
- Every JS/TS snippet touched parses (paste into a TS playground or run
npx tsc --noEmiton extracted snippets). - No JS block contains non-JS code.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
kalepail commentedon Nov 2, 2026
Raven rechecked the contract-restoration example on 2026-11-02 and found more defects than this issue lists. The empty return type and the missing
xdrimport onrestore-contract-jsline 69 are still present. The same function is also on the state-archival page line 365.Additional defects in the same example:
getWasmLedgerKey(instance)receives theLedgerKeyfromc.getFootprint(), but reads it as aContractDataEntry. The instance ledger key holds no WASM hash. The hash is in the instance ledger entry. With@stellar/stellar-sdk17.4.0 the path isresponse.entries[0].val.value.val.value.executable.value, after a check that the executable iscontractExecutableWasm.getLedgerEntriesresponse intosetReadWrite([instance, wasmEntry]). The footprint needs twoLedgerKeyvalues.restore-data-js, line 43 declaresconst { Api, assembleTransaction } = StellarRpc;. The guide tells readers to reusesubmitTxfromsubmit-transaction-wait-js, which importsApifrom@stellar/stellar-sdk/rpc. The combined code fails TypeScript withTS2440: Import declaration conflicts with local declaration of 'Api'.A local check with SDK 17.4.0 read the instance entry through that path, built the contract-code key, put both keys in the read-write footprint, set time bounds, and signed the transaction. No transaction was submitted.
Source record (immutable): https://github.com/stellar-experimental/stellar-raven/blob/9e3ec615e64d6223d3d5f090b36e1ef46a9c7ea8/improvements/stellar-docs/sd-081-contract-restoration-example-obsolete-xdr.md
kalepail commentedon Nov 6, 2026
Verified a partial fix on 2026-11-06: both contract-restoration examples now call
.setTimeout(30)before.build().The missing-time-bounds item in my earlier comment is therefore complete.
The remaining problems still reproduce on restore-contract-js and state-archival:
getWasmLedgerKeyhas an empty return type, andxdris not imported.LedgerKeybut reads it as an instance entry containing the WASM hash.getLedgerEntriesresponse instead of a secondLedgerKey.The separate
Apiredeclaration also remains when combining the data-restoration example with its linked polling helper.Raven retains sd-081 for these residuals and has removed the completed time-bounds recommendation.
kalepail commentedon Nov 17, 2026
Raven rechecked the contract-restoration examples on 2026-11-17.
PR #3083 fixed most of the defects listed here. The
-jspage paths now redirect torestore-contract and
restore-data.
Fixed:
getWasmLedgerKeyreturnsxdr.LedgerKey, andxdris imported.getLedgerEntries(instance). The footprint holds twoLedgerKeyvalues.@stellar/stellar-sdk17.4.0.Still failing:
restore-datadeclaresconst { Api, assembleTransaction } = StellarRpc;on line 42.The
submitTxhelper that the guide reuses importsApifrom@stellar/stellar-sdk/rpc.The two blocks combined report
TS2440: Import declaration conflicts with local declaration of 'Api'.with SDK 17.4.0.
Smallest fix: change line 42 of
restore-datatoconst { assembleTransaction } = StellarRpc;.