feat: generate TypeScript contract bindings from Soroban WASM (#174)#189
Open
DammyAji wants to merge 1 commit into
Open
feat: generate TypeScript contract bindings from Soroban WASM (#174)#189DammyAji wants to merge 1 commit into
DammyAji wants to merge 1 commit into
Conversation
…way#174) - Add sdk/codegen/ tool that reads contractspecv0 section from WASM - Parse all funcs, structs, unions, enums, and error cases - Generate typed interfaces and client interface in generated-client.ts - Add codegen:build and codegen scripts to sdk/package.json - Add codegen CI job that builds WASM, runs codegen, uploads artifact - Fix pre-existing compile errors in token and admin contracts
|
@DammyAji 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #174
Summary
Implements issue #174 — a code generation tool that reads a compiled Soroban contract's ABI from the WASM and generates type-safe TypeScript client code.
Changes
sdk/codegen/(new)src/parse-abi.ts— reads thecontractspecv0custom section from a.wasmfile viacontract.Client.fromWasm, extracts all functions, structs, unions, enums, and error casessrc/generate.ts— maps allScSpecTypevariants to TypeScript types; generates interfaces, union types, enums, error enum, and a typed client interfacesrc/index.ts— CLI entry point:bc-forge-codegen <wasm-path> [output-path] [--name <Name>]sdk/src/generated-client.ts(new)Output from running codegen against
bc_forge_token.wasm: 37 typed method signatures, 4 struct interfaces, 5 union types,BcForgeTokenErrorenum with 6 error codes.sdk/package.jsonAdded
codegen:buildandcodegenscripts..github/workflows/ci.ymlAdded
codegenjob that builds the WASM, runs the codegen tool, and uploadsgenerated-client.tsas a CI artifact.Contract fixes
Fixed pre-existing compile errors in
contracts/admin/src/lib.rs(spuriousaction_typefield) andcontracts/token/src/lib.rs(duplicate enum variant and garbled merge conflict blocks).Checklist
sdk/codegen/directory createdsdk/src/generated-client.ts