-
Notifications
You must be signed in to change notification settings - Fork 559
Stylus CLI updates #7502
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
Stylus CLI updates #7502
Changes from all commits
c01e0a8
54826fa
6e9a9ad
3fdb5be
feb0e4d
99b7764
c9dfa00
c37aff8
11149a3
a041415
16cabef
a9771c4
58fda78
3f976f6
4962bbc
2479b4c
764e808
62af2fc
16fdd1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[ | ||
"function activateProgram(address program) returns (uint16,uint256)" | ||
"function activateProgram(address program) returns (uint16,uint256)", | ||
"function codehashVersion(bytes32 codehash) external view returns (uint16 version)" | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
"function stylus_constructor()" | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
"function deploy(bytes calldata bytecode,bytes calldata initData,uint256 initValue,bytes32 salt) public payable returns (address)", | ||
"event ContractDeployed(address deployedContract)" | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { spawnSync } from "node:child_process"; | ||
import type { Ora } from "ora"; | ||
|
||
export function checkPrerequisites( | ||
spinner: Ora, | ||
cmd: string, | ||
args: string[] = ["--version"], | ||
name = cmd, | ||
) { | ||
try { | ||
const res = spawnSync(cmd, args, { encoding: "utf-8" }); | ||
|
||
if (res.error && (res.error as NodeJS.ErrnoException).code === "ENOENT") { | ||
spinner.fail( | ||
`Error: ${name} is not installed or not in PATH.\n` + | ||
`Install it and try again.`, | ||
); | ||
process.exit(1); | ||
} | ||
|
||
if (res.status !== 0) { | ||
spinner.fail( | ||
`Error: ${name} returned a non-zero exit code (${res.status}).`, | ||
); | ||
process.exit(1); | ||
} | ||
|
||
const ver = res.stdout.trim().split("\n")[0]; | ||
spinner.succeed(`${name} detected (${ver}).`); | ||
} catch (err) { | ||
spinner.fail(`Error while checking ${name}: ${err}`); | ||
process.exit(1); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
import { spawnSync } from "node:child_process"; | ||
import ora from "ora"; | ||
import prompts from "prompts"; | ||
import { checkPrerequisites } from "./check-prerequisites.js"; | ||
|
||
export async function createStylusProject() { | ||
const spinner = ora(); | ||
|
||
checkPrerequisites(spinner, "cargo", ["--version"], "Rust (cargo)"); | ||
checkPrerequisites(spinner, "rustc", ["--version"], "Rust compiler (rustc)"); | ||
checkPrerequisites( | ||
spinner, | ||
"solc", | ||
["--version"], | ||
"Solidity compiler (solc)", | ||
); | ||
|
||
// Step 1: Ensure cargo is installed | ||
const cargoCheck = spawnSync("cargo", ["--version"]); | ||
if (cargoCheck.status !== 0) { | ||
|
@@ -23,7 +33,7 @@ export async function createStylusProject() { | |
} | ||
spinner.succeed("Stylus installed."); | ||
|
||
spawnSync("rustup", ["default", "1.83"], { | ||
spawnSync("rustup", ["default", "1.87"], { | ||
stdio: "inherit", | ||
}); | ||
spawnSync("rustup", ["target", "add", "wasm32-unknown-unknown"], { | ||
|
@@ -43,32 +53,77 @@ export async function createStylusProject() { | |
choices: [ | ||
{ title: "Default", value: "default" }, | ||
{ title: "ERC20", value: "erc20" }, | ||
{ title: "ERC721", value: "erc721" }, | ||
{ title: "ERC1155", value: "erc1155" }, | ||
{ title: "Airdrop ERC20", value: "airdrop20" }, | ||
{ title: "Airdrop ERC721", value: "airdrop721" }, | ||
{ title: "Airdrop ERC1155", value: "airdrop1155" }, | ||
], | ||
message: "Select a template:", | ||
name: "projectType", | ||
type: "select", | ||
}); | ||
|
||
// Step 5: Create the project | ||
// biome-ignore lint/suspicious/noImplicitAnyLet: <> | ||
let newProject; | ||
if (projectType === "default") { | ||
spinner.start(`Creating new Stylus project: ${projectName}...`); | ||
const newProject = spawnSync("cargo", ["stylus", "new", projectName], { | ||
newProject = spawnSync("cargo", ["stylus", "new", projectName], { | ||
stdio: "inherit", | ||
}); | ||
if (newProject.status !== 0) { | ||
spinner.fail("Failed to create Stylus project."); | ||
process.exit(1); | ||
} | ||
} else if (projectType === "erc20") { | ||
const repoUrl = "[email protected]:thirdweb-example/stylus-erc20-template.git"; | ||
spinner.start(`Creating new ERC20 Stylus project: ${projectName}...`); | ||
const clone = spawnSync("git", ["clone", repoUrl, projectName], { | ||
newProject = spawnSync("git", ["clone", repoUrl, projectName], { | ||
stdio: "inherit", | ||
}); | ||
} else if (projectType === "erc721") { | ||
const repoUrl = | ||
"[email protected]:thirdweb-example/stylus-erc721-template.git"; | ||
spinner.start(`Creating new ERC721 Stylus project: ${projectName}...`); | ||
newProject = spawnSync("git", ["clone", repoUrl, projectName], { | ||
stdio: "inherit", | ||
}); | ||
} else if (projectType === "erc1155") { | ||
const repoUrl = | ||
"[email protected]:thirdweb-example/stylus-erc1155-template.git"; | ||
spinner.start(`Creating new ERC1155 Stylus project: ${projectName}...`); | ||
newProject = spawnSync("git", ["clone", repoUrl, projectName], { | ||
stdio: "inherit", | ||
}); | ||
} else if (projectType === "airdrop20") { | ||
const repoUrl = | ||
"[email protected]:thirdweb-example/stylus-airdrop-erc20-template.git"; | ||
spinner.start( | ||
`Creating new Airdrop ERC20 Stylus project: ${projectName}...`, | ||
); | ||
newProject = spawnSync("git", ["clone", repoUrl, projectName], { | ||
stdio: "inherit", | ||
}); | ||
if (clone.status !== 0) { | ||
spinner.fail("Failed to create Stylus project."); | ||
process.exit(1); | ||
} | ||
} else if (projectType === "airdrop721") { | ||
const repoUrl = | ||
"[email protected]:thirdweb-example/stylus-airdrop-erc721-template.git"; | ||
spinner.start( | ||
`Creating new Airdrop ERC721 Stylus project: ${projectName}...`, | ||
); | ||
newProject = spawnSync("git", ["clone", repoUrl, projectName], { | ||
stdio: "inherit", | ||
}); | ||
} else if (projectType === "airdrop1155") { | ||
const repoUrl = | ||
"[email protected]:thirdweb-example/stylus-airdrop-erc1155-template.git"; | ||
spinner.start( | ||
`Creating new Airdrop ERC1155 Stylus project: ${projectName}...`, | ||
); | ||
newProject = spawnSync("git", ["clone", repoUrl, projectName], { | ||
stdio: "inherit", | ||
}); | ||
} | ||
|
||
if (!newProject || newProject.status !== 0) { | ||
spinner.fail("Failed to create Stylus project."); | ||
process.exit(1); | ||
} | ||
|
||
spinner.succeed("Project created successfully."); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,11 @@ export { | |
type ActivateStylusContractOptions, | ||
activateStylusContract, | ||
} from "../../extensions/stylus/write/activateStylusContract.js"; | ||
export { | ||
type DeployWithStylusConstructorOptions, | ||
deployWithStylusConstructor, | ||
} from "../../extensions/stylus/write/deployWithStylusConstructor.js"; | ||
Comment on lines
+8
to
+11
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. 💡 Verification agent 🧩 Analysis chainVerify TSDoc compliance for the new export. The export structure follows the established pattern correctly. However, per the coding guidelines, every public symbol must have comprehensive TSDoc with at least one 🏁 Script executed: #!/bin/bash
# Description: Check if deployWithStylusConstructor has proper TSDoc documentation
# Expected: TSDoc comments with @example block and annotation tags
rg -A 20 "export.*deployWithStylusConstructor" --type ts Length of output: 2307 🏁 Script executed: #!/bin/bash
# Check for existing TSDoc above the deployWithStylusConstructor function
rg -B5 -n "export function deployWithStylusConstructor" packages/thirdweb/src/extensions/stylus/write/deployWithStylusConstructor.ts Length of output: 275 🏁 Script executed: #!/bin/bash
# Display TSDoc for deployWithStylusConstructor function
echo "===== deployWithStylusConstructor.ts (first 50 lines) ====="
head -n 50 packages/thirdweb/src/extensions/stylus/write/deployWithStylusConstructor.ts
# Display exports file to check for file-level TSDoc
echo "===== stylus.ts exports file (first 20 lines) ====="
head -n 20 packages/thirdweb/src/exports/extensions/stylus.ts Length of output: 2570 Add missing custom annotation tag to deployWithStylusConstructor TSDoc The • In /**
* Deploy stylus contract with constructor params
* @beta ← add one of: @beta | @experimental | @internal
* @param options – The options for deploying a contract with constructor
* @returns Prepared transaction to call stylus deployer
* @example
* …
*/
export function deployWithStylusConstructor(…) • (Optional) Enhance the file-level TSDoc in 🤖 Prompt for AI Agents
|
||
export { | ||
type IsContractActivatedOptions, | ||
isContractActivated, | ||
} from "../../extensions/stylus/write/isContractActivated.js"; | ||
Comment on lines
+12
to
+15
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. 💡 Verification agent 🧩 Analysis chainVerify TSDoc compliance for the new export. The export structure is consistent with the existing pattern. Ensure the source function has proper TSDoc documentation as required. 🏁 Script executed: #!/bin/bash
# Description: Check if isContractActivated has proper TSDoc documentation
# Expected: TSDoc comments with @example block and annotation tags
rg -A 20 "export.*isContractActivated" --type ts Length of output: 1947 Add comprehensive TSDoc for The /**
* Checks whether a given contract’s bytecode has been activated.
*
* @remarks
* This uses the ArbWasm precompile contract to verify the runtime bytecode version.
*
* @param options - Configuration options for the activation check.
* @param options.chain - The target blockchain.
* @param options.client - The RPC client instance.
* @param options.bytecode - The contract’s runtime bytecode.
*
* @returns A promise that resolves to `true` if activated, otherwise `false`.
*
* @example
* ```ts
* const activated = await isContractActivated({
* chain: "arbitrum",
* client: myRpcClient,
* bytecode: myContractBytecode,
* });
* console.log(activated); // true
* ```
*
* @beta
*/
export async function isContractActivated(
options: IsContractActivatedOptions,
): Promise<boolean> { … }
🤖 Prompt for AI Agents
|
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.
Add explicit type annotation to comply with coding guidelines.
The variable declaration violates the coding guidelines which require explicit types and avoiding
any
. The implicitany
type should be replaced with the proper return type.📝 Committable suggestion
🤖 Prompt for AI Agents