Skip to content

feat: auto-generate TypeScript bindings for Stellar contracts#29

Open
Jopsan-gm wants to merge 1 commit into
wraith-protocol:developfrom
Jopsan-gm:feature/stellar-bindings
Open

feat: auto-generate TypeScript bindings for Stellar contracts#29
Jopsan-gm wants to merge 1 commit into
wraith-protocol:developfrom
Jopsan-gm:feature/stellar-bindings

Conversation

@Jopsan-gm
Copy link
Copy Markdown

PR Title: feat: auto-generate TypeScript bindings for Stellar contracts

Description

This Pull Request introduces auto-generated, type-safe TypeScript bindings for the four Soroban smart contracts in the stellar/ workspace directory: stealth-announcer, stealth-registry, stealth-sender, and wraith-names.

This guarantees strict type safety for downstream consumers (like the SDK) and completely prevents silent API drift.

Closes

Closes #8


🛠️ Summary of Changes

  1. Root Configurations & Dependencies:

    • Added a root package.json to expose workspace-level scripts (pnpm bindings:stellar and pnpm build:stellar).
    • Added a root tsconfig.json for strict module resolution and type checking.
    • Installed @stellar/stellar-sdk and other developer dependencies.
    • Added stellar/contract-ids.json to configure testnet contract IDs.
  2. Automated Generation Script (stellar/scripts/generate-bindings.ts):

    • Implemented a generation script that compiles Soroban contracts to WASM locally (Offline Mode) or generates bindings directly from deployed testnet contract IDs (On-Chain Mode).
    • Added an automatic path fallback for Windows users if the newly installed stellar-cli is not yet on the active session PATH.
    • Post-processes generated TS modules to replace default exports (export default class Client) with modern named exports (export class Client).
    • Generates a global index entrypoint file that bundles all 4 contract clients.
  3. CI Workflow Drift Detection:

    • Modified .github/workflows/ci.yml under the stellar job to setup Node, install dependencies, setup Stellar CLI, compile to target wasm32-unknown-unknown, run bindings generation, and check for uncommitted files using git diff --exit-code.
  4. Documentation:

    • Updated README.md with a detailed "Generated Bindings" section explaining the script workflows and when to regenerate.

🧪 Verification and Type Safety

We have successfully validated the changes locally:

  1. Compilation & Generation: Running pnpm bindings:stellar compiles the Rust contracts to WASM and extracts the TS clients perfectly.
  2. Type Safety Validation: Running npx tsc --noEmit yields 0 compiler errors, demonstrating complete type-safety.

📸 Screenshots / Evidence

image

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@Jopsan-gm Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Jopsan-gm
Copy link
Copy Markdown
Author

Hi @truthixify, PR ready for review!

@truthixify truthixify changed the base branch from main to develop June 1, 2026 15:05
@truthixify
Copy link
Copy Markdown
Contributor

The bindings work itself looks solid — generate-bindings.ts is the right shape, the per-contract packages with package.json + src/index.ts + tsconfig.json cleanly slot into a pnpm workspace, and re-exporting through a top-level stellar/bindings/typescript/index.ts is exactly what we want for SDK consumption.

The problem is the base — this PR was opened against an older main and now conflicts hard with develop. The diff currently shows it removing several files that landed in the last few PRs (the event-topic design doc, the announcement schema audit, the rescue tool, the property test snapshots, the nightly CI job). Merging as-is would undo that work.

Could you rebase onto develop?

git fetch origin
git rebase origin/develop
# resolve conflicts, mainly:
#  - .github/workflows/ci.yml (keep both the bindings job AND the stellar-nightly schedule)
#  - README.md (keep existing sections, add bindings docs alongside)
# don't delete: EVENT_TOPIC_DESIGN.md, ANNOUNCEMENT_SCHEMA.md, POSTMORTEMS.md, scripts/rescue-stealth-funds.ts, the test_snapshots/ entries, the tests/properties.rs files
git push --force-with-lease

Once that's clean I'll merge. Thanks @Jopsan-gm — really nice work on the codegen wiring.

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.

Auto-generate TypeScript bindings for Stellar contracts

2 participants