-
Notifications
You must be signed in to change notification settings - Fork 559
Stylus ERC20 template for CLI #7192
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
WalkthroughThe changes introduce enhanced user interaction in the CLI for Stylus contract development. The build command now supports multiple contract ABIs, prompting the user to select one if several are detected. The project creation command adds a template selection step, allowing users to choose between a default or ERC20 template for new projects. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant FileSystem
participant Repo
User->>CLI: Run "stylus create"
CLI->>User: Prompt for project template (default or erc20)
User->>CLI: Selects template
alt default template
CLI->>FileSystem: Run "cargo stylus new <projectName>"
else erc20 template
CLI->>Repo: Clone "stylus-erc20-template.git"
Repo-->>CLI: Template files
end
CLI->>User: Show success message
sequenceDiagram
participant User
participant CLI
participant FileSystem
User->>CLI: Run "stylus build"
CLI->>FileSystem: Read ABI output
CLI->>CLI: Parse contract names from ABI
alt Multiple contracts found
CLI->>User: Prompt to select contract
User->>CLI: Selects contract
else One contract found
CLI->>CLI: Select contract automatically
end
CLI->>CLI: Extract ABI for selected contract
CLI->>User: Proceed with build using selected contract
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (8)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/thirdweb/src/cli/commands/stylus/create.ts (1)
63-63
: Consider using HTTPS URL instead of SSH for better compatibility.The hardcoded SSH URL may cause issues for users who haven't set up SSH keys with GitHub. Consider using HTTPS format for broader compatibility.
- const repoUrl = "git@github.com:thirdweb-example/stylus-erc20-template.git"; + const repoUrl = "https://github.com/thirdweb-example/stylus-erc20-template.git";packages/thirdweb/src/cli/commands/stylus/builder.ts (1)
105-127
: Consider adding validation for selectedIndex bounds checking.While the current implementation handles the case where no contract is selected, consider adding explicit bounds checking to ensure the selectedIndex is within the valid range of contractNames array.
const selectedIndex = response.contract; if (typeof selectedIndex !== "number") { spinner.fail("No contract selected."); process.exit(1); } + if (selectedIndex < 0 || selectedIndex >= contractNames.length) { + spinner.fail("Invalid contract selection."); + process.exit(1); + } selectedContractName = contractNames[selectedIndex]?.replace(/^I/, ""); selectedAbiContent = parts[selectedIndex];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/thirdweb/src/cli/commands/stylus/builder.ts
(5 hunks)packages/thirdweb/src/cli/commands/stylus/create.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Lint Packages
- GitHub Check: Size
- GitHub Check: Unit Tests
- GitHub Check: Build Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
packages/thirdweb/src/cli/commands/stylus/create.ts (2)
41-50
: LGTM! Template selection implementation is clean.The template selection prompt follows the established pattern and provides clear options for users.
53-72
:✅ Verification successful
Verify error handling consistency across both project creation paths.
Both paths have proper error handling with spinners, but ensure the error messages and exit behavior are consistent between the default cargo command and git clone operations.
🏁 Script executed:
#!/bin/bash # Description: Check if the thirdweb-example/stylus-erc20-template repository exists and is accessible # Test: Verify the repository exists and is publicly accessible curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/thirdweb-example/stylus-erc20-templateLength of output: 112
Error handling consistency confirmed
The ERC20 template repo is publicly accessible (HTTP 200), and both the
cargo stylus new
andgit clone
flows use the samespinner.fail("Failed to create Stylus project.");
message followed byprocess.exit(1)
. No changes required here.packages/thirdweb/src/cli/commands/stylus/builder.ts (3)
6-6
: LGTM! Import addition is appropriate.The prompts import is correctly added to support the new contract selection functionality.
99-137
: Excellent enhancement for multi-contract support with robust error handling.The implementation properly handles both single and multiple contract scenarios, with clear user prompts and comprehensive error checking. The logic flow is well-structured and maintains consistency with the existing codebase patterns.
216-220
:❓ Verification inconclusive
Validate the regex pattern for contract name extraction.
The regex pattern
/<stdin>:(I?[A-Za-z0-9_]+)/g
should be verified to ensure it correctly matches all valid Stylus contract name formats.
🏁 Script executed:
#!/bin/bash # Description: Search for examples of Stylus ABI export output to validate the regex pattern # Search for examples of contract name patterns in Stylus-related files rg -A 5 -B 5 "export-abi|<stdin>:" --type rustLength of output: 197
Please verify the regex against actual Stylus CLI output
I couldn’t find any example
export-abi
outputs in the repo to confirm that the pattern
/<stdin>:(I?[A-Za-z0-9_]+)/g
covers all valid contract names (interfaces, special characters, etc.).• No occurrences of
export-abi
or<stdin>:
were found in the codebase to test against.
• Please run the Stylus CLI (e.g.stylus export-abi …
) and share sample output.
• Confirm that your regex captures every contract name format (consider interfaces, dashes, numbers).
size-limit report 📦
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7192 +/- ##
=======================================
Coverage 55.67% 55.67%
=======================================
Files 904 904
Lines 58391 58391
Branches 4119 4116 -3
=======================================
Hits 32510 32510
+ Misses 25776 25775 -1
- Partials 105 106 +1
🚀 New features to boost your workflow:
|
Merge activity
|
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR enhances the `create.ts` and `builder.ts` files for the Stylus project by adding project type selection and improving contract name handling during ABI processing. It introduces prompts for user input and refines how contract names are extracted and utilized. ### Detailed summary - In `create.ts`, added prompts for selecting project type (Default or ERC20). - Updated project creation logic based on the selected type. - In `builder.ts`, improved contract name extraction to handle multiple contracts. - Added prompts for selecting the entrypoint if multiple contracts are found. - Refined usage of selected contract names throughout the build process. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for handling multiple contract ABIs, allowing users to select a contract entrypoint when more than one is present. - Introduced a prompt to select a project template type ("default" or "erc20") during project creation. - **Improvements** - Enhanced error handling and user guidance when no contract is selected or found. - Updated success messages and console output for improved clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
4b29c16
to
16482cf
Compare
PR-Codex overview
This PR enhances the
create.ts
andbuilder.ts
files in the Stylus project CLI by adding project type selection and improving contract name extraction from ABI output.Detailed summary
create.ts
, added prompts for selecting project type (Default or ERC20).builder.ts
, improved contract name selection from ABI output using prompts.extractContractNameFromExportAbi
toextractContractNamesFromExportAbi
to return multiple contract names.Summary by CodeRabbit
New Features
Improvements