-
Notifications
You must be signed in to change notification settings - Fork 345
Port Binding Generation #1287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Port Binding Generation #1287
Changes from 55 commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
0ac31c1
add contract bindings generation
Ryang-21 a802b40
add cli for binding generation
Ryang-21 b348428
change cli name to avoid naming conflict with stellar-cli
Ryang-21 ee062fe
fix scSymbol type conversion to string
Ryang-21 c03ae81
extract duplicated typedef parsing and create util for generating imp…
Ryang-21 2fcf367
include null in Option union type and Address for scVal Address
Ryang-21 e5ca345
fix parsing of ts type for scVoid
Ryang-21 d4c571e
simplify type generation
Ryang-21 b320cde
set option field for contract methods to be type MethodOptions
Ryang-21 7a0b1f5
sanitize names of functions,interfaces, and enums for js reserved key…
Ryang-21 f065fe7
add js docs to contract method interface
Ryang-21 095f164
replace sh -> js script for fetching sac spec
Ryang-21 33e8b6c
cleanup redundant code
Ryang-21 dcd94cf
Merge branch 'master' into binding-gen
Ryang-21 d38ddeb
fix wasm parser import
Ryang-21 98b0ba0
use --network option for setting passphrase in cli
Ryang-21 c4b6ad3
fix linter errors
Ryang-21 f0497dd
parse scVoid typedef as null
Ryang-21 08974d5
handle nested option types when parsing typedef
Ryang-21 cb59a14
fix export of types in index file
Ryang-21 3a8bad2
dedeplicate import formatting from client and type generator
Ryang-21 5e5b562
refactor import generation
Ryang-21 6709e01
fortify cleaning of jsdoc
Ryang-21 d8dcfab
fix formatting
Ryang-21 0f4bbd3
sanitize method names for dynamic method generation and sanitize meth…
Ryang-21 8fcf247
change method name from sanitizeName -> sanitizeIdentifier
Ryang-21 174278c
restrict binding exports to strictly BindingGenerator
Ryang-21 4e158ea
add testing for binding generation and cli functionalites
Ryang-21 0ccb076
fix changed method name
Ryang-21 c777522
improve jsdocs for BindingGeneration class
Ryang-21 6f6cb68
add cli documentation
Ryang-21 f11ea04
Merge branch 'master' into binding-gen
Ryang-21 0437123
allow RpcServer options to be passed into cli
Ryang-21 ff2bc97
sort functions and types by name for deterministic generation
Ryang-21 05c25bf
Revert "sort functions and types by name for deterministic generation"
Ryang-21 8a873ff
update stellar-cli for e2e CI testing
Ryang-21 d2741ad
replace snapshot testing for a e2e generation -> compile -> execution…
Ryang-21 695eb39
rename binding e2e test file name
Ryang-21 ecd3f41
update docs for CLI's optional args
Ryang-21 8eb6376
include all options in --network description
Ryang-21 8a09e56
log message from error cause
Ryang-21 b57ca2d
provide default rpc-urls for tesntet, futurenet, and localnet
Ryang-21 e6e1744
update test-contracts submodule hash
Ryang-21 a3bab12
add snapshot tests for generated bindings
Ryang-21 fc776f0
update quickstart container hash
Ryang-21 3bfb72e
run snapshot binding test on fixed wasm
Ryang-21 058a140
sanitize jsdoc escapes with a space
Ryang-21 58409a1
change Val type parsing from xdr.ScVal to any for drop in replacement
Ryang-21 0fe49c5
add values: void field to nonvalue unions for cli generation parity
Ryang-21 e99d97d
implement specific generation for tuple structs for cli generation pa…
Ryang-21 21d140f
port all cli binding gen method tests
Ryang-21 916abe3
update changelog
Ryang-21 07c3842
remove log
Ryang-21 55be278
cleanup interface instantiation
Ryang-21 9eb10e5
update submodule to 17190efb9833cb7e4a92059202dfdac41662d6e1
Ryang-21 d1e7b8d
Fix rpc name from Soroban -> Stellar
Ryang-21 cc697d8
set SAC spec download to a pinned hash
Ryang-21 1ff86bf
refactor: simplify WASM fetching logic and config generation
Ryang-21 6784ed0
refactor binding generator to take rpc server instance
Ryang-21 caf34bd
refactor: have cli utilize BindingGenerator for wasm fetching
Ryang-21 0ddb24f
fix jsdoc returns statement
Ryang-21 30e6181
Merge branch 'master' into binding-gen
Ryang-21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/usr/bin/env node | ||
|
Ryang-21 marked this conversation as resolved.
|
||
|
|
||
| // Entry point for the stellar CLI | ||
| require("../lib/cli/index.js").runCli(); | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import https from "https"; | ||
| import fs from "fs"; | ||
| import path from "path"; | ||
| import { fileURLToPath } from "url"; | ||
|
|
||
| // Get __dirname equivalent in ESM | ||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = path.dirname(__filename); | ||
|
|
||
| // Get repo root | ||
| const REPO_ROOT = path.join(__dirname, ".."); | ||
|
|
||
| // URLs and paths | ||
| const REPO_URL = | ||
| "https://raw.githubusercontent.com/stellar/stellar-asset-contract-spec/main/stellar-asset-spec.xdr"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be a specific commit SHA? |
||
| const TS_FILE = path.join(REPO_ROOT, "src/bindings/sac-spec.ts"); | ||
|
|
||
| console.log("Downloading Stellar Asset Contract spec from GitHub..."); | ||
|
|
||
| // Download file | ||
| https | ||
| .get(REPO_URL, (response) => { | ||
| if (response.statusCode !== 200) { | ||
| console.error(`✗ Failed to download: HTTP ${response.statusCode}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const chunks = []; | ||
|
|
||
| response.on("data", (chunk) => { | ||
| chunks.push(chunk); | ||
| }); | ||
|
|
||
| response.on("end", () => { | ||
| const buffer = Buffer.concat(chunks); | ||
|
|
||
| // Verify file has content | ||
| if (buffer.length === 0) { | ||
| console.error("✗ Downloaded file is empty"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log("✓ Successfully downloaded file"); | ||
| console.log(` Size: ${buffer.length} bytes`); | ||
|
|
||
| // Convert to base64 | ||
| console.log("Converting to base64..."); | ||
| const base64Content = buffer.toString("base64"); | ||
|
|
||
| if (!base64Content) { | ||
| console.error("✗ Base64 conversion failed"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| // Update TypeScript file | ||
| console.log(`Updating ${path.relative(REPO_ROOT, TS_FILE)}...`); | ||
| const tsContent = [ | ||
| "// Auto-generated by scripts/download-sac-spec.sh", | ||
|
Ryang-21 marked this conversation as resolved.
Outdated
|
||
| "// Do not edit manually - run the script to update", | ||
| `export const SAC_SPEC = "${base64Content}";`, | ||
| "", // trailing newline | ||
| ].join("\n"); | ||
|
|
||
| try { | ||
| fs.writeFileSync(TS_FILE, tsContent, "utf8"); | ||
| console.log( | ||
| `✓ Successfully updated ${path.relative(REPO_ROOT, TS_FILE)}`, | ||
| ); | ||
| } catch (error) { | ||
| console.error(`✗ Failed to write file: ${error.message}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log("✓ Done"); | ||
| }); | ||
| }) | ||
| .on("error", (error) => { | ||
| console.error(`✗ Error: ${error.message}`); | ||
| process.exit(1); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call to make this a generic subcommand of the CLI. Gives us space to add other things in the future.