create-stylus 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/base/.vscode/settings.json +1 -1
- package/templates/base/package.json +1 -1
- package/templates/base/packages/nextjs/app/page.tsx +1 -1
- package/templates/base/packages/stylus/contracts/Cargo.toml +11 -0
- package/templates/base/packages/stylus/contracts/Stylus.toml +2 -0
- package/templates/base/packages/stylus/{your-contract → contracts/your-contract}/Cargo.toml +0 -9
- package/templates/base/packages/stylus/contracts/your-contract/Stylus.toml +2 -0
- package/templates/base/packages/stylus/package.json +1 -1
- package/templates/base/packages/stylus/scripts/deploy.ts +26 -7
- package/templates/base/packages/stylus/scripts/deploy_contract.ts +3 -2
- package/templates/base/packages/stylus/scripts/export_abi.ts +9 -5
- package/templates/base/packages/stylus/scripts/new_module.sh +132 -23
- package/templates/base/packages/stylus/scripts/test.ts +4 -8
- package/templates/base/packages/stylus/scripts/utils/contract.ts +2 -2
- package/templates/base/packages/stylus/scripts/utils/deployment.ts +1 -1
- package/templates/base/readme.md +9 -7
- /package/templates/base/packages/stylus/{your-contract → contracts}/Cargo.lock +0 -0
- /package/templates/base/packages/stylus/{your-contract → contracts}/rust-toolchain.toml +0 -0
- /package/templates/base/packages/stylus/{your-contract → contracts/your-contract}/.cargo/config.toml +0 -0
- /package/templates/base/packages/stylus/{your-contract → contracts/your-contract}/header.png +0 -0
- /package/templates/base/packages/stylus/{your-contract → contracts/your-contract}/src/lib.rs +0 -0
- /package/templates/base/packages/stylus/{your-contract → contracts/your-contract}/src/main.rs +0 -0
package/package.json
CHANGED
|
@@ -37,12 +37,3 @@ path = "src/main.rs"
|
|
|
37
37
|
[lib]
|
|
38
38
|
crate-type = ["lib", "cdylib"]
|
|
39
39
|
|
|
40
|
-
[profile.release]
|
|
41
|
-
codegen-units = 1
|
|
42
|
-
strip = true
|
|
43
|
-
lto = true
|
|
44
|
-
panic = "abort"
|
|
45
|
-
|
|
46
|
-
# If you need to reduce the binary size, it is advisable to try other
|
|
47
|
-
# optimization levels, such as "s" and "z"
|
|
48
|
-
opt-level = 3
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"deploy": "ts-node scripts/deploy_wrapper.ts",
|
|
12
12
|
"info:networks": "ts-node scripts/test_network.ts",
|
|
13
13
|
"export-abi": "ts-node scripts/export_abi.ts",
|
|
14
|
-
"clean-contracts": "git clean -xdf -e .env -e
|
|
14
|
+
"clean-contracts": "git clean -xdf -e .env -e contracts/ -e node_modules/",
|
|
15
15
|
"test": "ts-node scripts/test.ts",
|
|
16
16
|
"lint": "eslint scripts --ext .ts",
|
|
17
17
|
"lint:fix": "eslint scripts --ext .ts --fix",
|
|
@@ -29,18 +29,37 @@ export default async function deployScript(deployOptions: DeployOptions) {
|
|
|
29
29
|
console.log(`📁 Deployment directory: ${config.deploymentDir}`);
|
|
30
30
|
console.log(`\n`);
|
|
31
31
|
|
|
32
|
-
// Deploy a
|
|
32
|
+
// Deploy a contract. Each deployStylusContract() call deploys ONE contract
|
|
33
|
+
// (its own tx + address) and, on success, automatically:
|
|
34
|
+
// 1. saves the address/tx to packages/stylus/deployments/
|
|
35
|
+
// 2. runs 'cargo stylus export-abi' and writes the ABI + address into
|
|
36
|
+
// packages/nextjs/contracts/deployedContracts.ts (keyed by chainId + name),
|
|
37
|
+
// so the Next.js frontend picks it up immediately.
|
|
33
38
|
await deployStylusContract({
|
|
34
|
-
contract: "your-contract",
|
|
35
|
-
constructorArgs: [config.deployerAddress!],
|
|
39
|
+
contract: "your-contract", // folder name under packages/stylus/contracts/
|
|
40
|
+
constructorArgs: [config.deployerAddress!], // omit/empty if the contract has no #[constructor]
|
|
36
41
|
...deployOptions,
|
|
37
42
|
});
|
|
38
|
-
|
|
39
|
-
//
|
|
43
|
+
// ─── Deploying MULTIPLE contracts ─────────────────────────────────────────
|
|
44
|
+
// 1. Scaffold each new contract: yarn new-module <name>
|
|
45
|
+
// (creates packages/stylus/contracts/<name>/ and auto-registers it via members=["*"])
|
|
46
|
+
// 2. Add one deployStylusContract() call per contract below. They deploy
|
|
47
|
+
// sequentially in a single 'yarn deploy', and each is auto-added to
|
|
48
|
+
// deployedContracts.ts. (Stylus deploys one contract per tx/address — there is
|
|
49
|
+
// no single-tx multi-deploy; 'at once' means one command, not one transaction.)
|
|
50
|
+
//
|
|
51
|
+
// await deployStylusContract({
|
|
52
|
+
// contract: "counter",
|
|
53
|
+
// constructorArgs: ["42", config.deployerAddress!, true],
|
|
54
|
+
// pass your #[constructor] args in order
|
|
55
|
+
// ...deployOptions,
|
|
56
|
+
// });
|
|
57
|
+
//
|
|
58
|
+
// Deploy the SAME crate again under a different key using 'name':
|
|
40
59
|
// await deployStylusContract({
|
|
41
60
|
// contract: "your-contract",
|
|
42
|
-
//
|
|
43
|
-
//
|
|
61
|
+
// name: "your-contract-v2",
|
|
62
|
+
// constructorArgs: [config.deployerAddress!],
|
|
44
63
|
// ...deployOptions,
|
|
45
64
|
// });
|
|
46
65
|
|
|
@@ -15,6 +15,7 @@ import { DeployOptions } from "./utils/type";
|
|
|
15
15
|
import { buildDeployCommand } from "./utils/command";
|
|
16
16
|
import { Abi, createPublicClient, createWalletClient, http } from "viem";
|
|
17
17
|
import { privateKeyToAccount } from "viem/accounts";
|
|
18
|
+
import * as path from "path";
|
|
18
19
|
import { arbitrumNitro } from "../../nextjs/utils/scaffold-stylus/supportedChains";
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -39,7 +40,7 @@ export default async function deployStylusContract(
|
|
|
39
40
|
const deployCommand = await buildDeployCommand(config, deployOptions);
|
|
40
41
|
const deployOutput = await executeCommand(
|
|
41
42
|
deployCommand,
|
|
42
|
-
deployOptions.contract
|
|
43
|
+
path.join("contracts", deployOptions.contract!),
|
|
43
44
|
"Deploying contract with cargo stylus",
|
|
44
45
|
);
|
|
45
46
|
|
|
@@ -127,7 +128,7 @@ export default async function deployStylusContract(
|
|
|
127
128
|
try {
|
|
128
129
|
const output = await executeCommand(
|
|
129
130
|
`cargo stylus verify --endpoint=${getRpcUrlFromChain(config.chain)} --deployment-tx=${deploymentInfo.txHash}`,
|
|
130
|
-
deployOptions.contract
|
|
131
|
+
path.join("contracts", deployOptions.contract!),
|
|
131
132
|
"Verifying contract with cargo stylus",
|
|
132
133
|
);
|
|
133
134
|
console.log(output);
|
|
@@ -16,7 +16,9 @@ export async function exportStylusAbi(
|
|
|
16
16
|
) {
|
|
17
17
|
console.log("📄 Starting Stylus ABI export...");
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Resolve the actual filesystem path (contracts live under contracts/)
|
|
20
|
+
const fsPath = path.join("contracts", contractFolder);
|
|
21
|
+
const config = getExportConfig(fsPath, contractName, chainId);
|
|
20
22
|
|
|
21
23
|
if (!config.contractAddress) {
|
|
22
24
|
console.error(
|
|
@@ -36,8 +38,9 @@ export async function exportStylusAbi(
|
|
|
36
38
|
ensureDeploymentDirectory(config.deploymentDir);
|
|
37
39
|
|
|
38
40
|
// Export ABI
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
// cwd is now contracts/<contract>/, so ../../ reaches packages/stylus/
|
|
42
|
+
const exportCommand = `cargo stylus export-abi --output='../../${config.deploymentDir}/${config.contractFolder}' --json`;
|
|
43
|
+
await executeCommand(exportCommand, fsPath, "Exporting ABI");
|
|
41
44
|
|
|
42
45
|
console.log(
|
|
43
46
|
`📄 ABI file location: ${config.deploymentDir}/${config.contractFolder}`,
|
|
@@ -73,12 +76,13 @@ export async function exportStylusAbi(
|
|
|
73
76
|
|
|
74
77
|
if (require.main === module) {
|
|
75
78
|
// Get contract folder from command line args, default to 'your-contract'
|
|
76
|
-
const
|
|
79
|
+
const rawContract = process.argv[2] || "your-contract";
|
|
80
|
+
const contractFolder = path.join("contracts", rawContract);
|
|
77
81
|
if (!fs.existsSync(contractFolder)) {
|
|
78
82
|
console.error(`❌ Contract folder does not exist: ${contractFolder}`);
|
|
79
83
|
process.exit(1);
|
|
80
84
|
}
|
|
81
|
-
exportStylusAbi(
|
|
85
|
+
exportStylusAbi(rawContract, rawContract).catch(
|
|
82
86
|
(error) => {
|
|
83
87
|
console.error("Fatal error:", error);
|
|
84
88
|
process.exit(1);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
# Check if module name is provided
|
|
4
3
|
if [ -z "$1" ]; then
|
|
5
4
|
echo "Error: Module name is required"
|
|
6
5
|
echo "Usage: $0 <module_name>"
|
|
@@ -8,28 +7,138 @@ if [ -z "$1" ]; then
|
|
|
8
7
|
fi
|
|
9
8
|
|
|
10
9
|
MODULE_NAME="$1"
|
|
10
|
+
MODULE_NAME_UNDERSCORE=$(echo "$MODULE_NAME" | tr '-' '_')
|
|
11
|
+
# Convert underscore_separated to PascalCase (e.g. counter_test -> CounterTest)
|
|
12
|
+
MODULE_NAME_PASCAL=$(echo "$MODULE_NAME_UNDERSCORE" | perl -pe 's/(^|_)(.)/\u$2/g')
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if
|
|
17
|
-
|
|
18
|
-
# Remove unnecessary files
|
|
19
|
-
rm -rf .git .github ci .gitignore examples licenses .env.example header.png README.md
|
|
20
|
-
# Update Cargo.toml name field to $MODULE_NAME
|
|
21
|
-
if [ -f Cargo.toml ]; then
|
|
22
|
-
sed -i "s/^name = \".*\"/name = \"$MODULE_NAME\"/" Cargo.toml
|
|
23
|
-
fi
|
|
24
|
-
# Update main.rs module name in print_from_args call
|
|
25
|
-
if [ -f src/main.rs ]; then
|
|
26
|
-
MODULE_NAME_UNDERSCORE=$(echo "$MODULE_NAME" | tr '-' '_')
|
|
27
|
-
sed -i "s/^[[:space:]]*stylus_hello_world::print_from_args();/\t$MODULE_NAME_UNDERSCORE::print_from_args();/" src/main.rs
|
|
28
|
-
fi
|
|
29
|
-
cargo generate-lockfile
|
|
30
|
-
echo "New module created successfully"
|
|
31
|
-
else
|
|
32
|
-
echo "Error: Failed to create new module with '$CARGO_CMD'"
|
|
33
|
-
echo "$output"
|
|
14
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
15
|
+
WORKSPACE_ROOT="$(cd "$SCRIPT_DIR/../contracts" && pwd)"
|
|
16
|
+
MODULE_DIR="$WORKSPACE_ROOT/$MODULE_NAME"
|
|
17
|
+
|
|
18
|
+
if [ -d "$MODULE_DIR" ]; then
|
|
19
|
+
echo "Error: Directory '$MODULE_NAME' already exists"
|
|
34
20
|
exit 1
|
|
35
21
|
fi
|
|
22
|
+
|
|
23
|
+
echo "Creating new workspace member: $MODULE_NAME"
|
|
24
|
+
|
|
25
|
+
mkdir -p "$MODULE_DIR/src"
|
|
26
|
+
mkdir -p "$MODULE_DIR/.cargo"
|
|
27
|
+
|
|
28
|
+
# Write .cargo/config.toml
|
|
29
|
+
cat > "$MODULE_DIR/.cargo/config.toml" << 'CONFIGEOF'
|
|
30
|
+
[target.wasm32-unknown-unknown]
|
|
31
|
+
rustflags = [
|
|
32
|
+
"-C", "link-arg=-zstack-size=32768",
|
|
33
|
+
"-C", "target-feature=-reference-types",
|
|
34
|
+
"-C", "target-feature=+bulk-memory",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[target.aarch64-apple-darwin]
|
|
38
|
+
rustflags = [
|
|
39
|
+
"-C", "link-arg=-undefined",
|
|
40
|
+
"-C", "link-arg=dynamic_lookup",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[target.x86_64-apple-darwin]
|
|
44
|
+
rustflags = [
|
|
45
|
+
"-C", "link-arg=-undefined",
|
|
46
|
+
"-C", "link-arg=dynamic_lookup",
|
|
47
|
+
]
|
|
48
|
+
CONFIGEOF
|
|
49
|
+
|
|
50
|
+
# Write Cargo.toml
|
|
51
|
+
cat > "$MODULE_DIR/Cargo.toml" << CARGOEOF
|
|
52
|
+
[package]
|
|
53
|
+
name = "$MODULE_NAME"
|
|
54
|
+
version = "0.1.0"
|
|
55
|
+
edition = "2021"
|
|
56
|
+
license = "MIT OR Apache-2.0"
|
|
57
|
+
keywords = ["arbitrum", "ethereum", "stylus", "alloy"]
|
|
58
|
+
description = "Stylus contract scaffolded by scaffold-stylus"
|
|
59
|
+
|
|
60
|
+
[dependencies]
|
|
61
|
+
alloy-primitives = "=0.8.20"
|
|
62
|
+
alloy-sol-types = "=0.8.20"
|
|
63
|
+
stylus-sdk = "0.9.0"
|
|
64
|
+
hex = { version = "0.4", default-features = false }
|
|
65
|
+
openzeppelin-stylus = "0.3.0"
|
|
66
|
+
|
|
67
|
+
[dev-dependencies]
|
|
68
|
+
alloy-primitives = { version = "=0.8.20", features = ["sha3-keccak"] }
|
|
69
|
+
tokio = { version = "1.12.0", features = ["full"] }
|
|
70
|
+
ethers = "2.0"
|
|
71
|
+
eyre = "0.6.8"
|
|
72
|
+
stylus-sdk = { version = "0.9.0", features = ["stylus-test"] }
|
|
73
|
+
|
|
74
|
+
[features]
|
|
75
|
+
default = ["mini-alloc"]
|
|
76
|
+
export-abi = ["openzeppelin-stylus/export-abi"]
|
|
77
|
+
debug = ["stylus-sdk/debug"]
|
|
78
|
+
mini-alloc = ["stylus-sdk/mini-alloc"]
|
|
79
|
+
|
|
80
|
+
[[bin]]
|
|
81
|
+
name = "$MODULE_NAME"
|
|
82
|
+
path = "src/main.rs"
|
|
83
|
+
|
|
84
|
+
[lib]
|
|
85
|
+
crate-type = ["lib", "cdylib"]
|
|
86
|
+
CARGOEOF
|
|
87
|
+
|
|
88
|
+
# Write src/lib.rs
|
|
89
|
+
cat > "$MODULE_DIR/src/lib.rs" << LIBEOF
|
|
90
|
+
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]
|
|
91
|
+
#![cfg_attr(not(any(test, feature = "export-abi")), no_std)]
|
|
92
|
+
|
|
93
|
+
#[macro_use]
|
|
94
|
+
extern crate alloc;
|
|
95
|
+
|
|
96
|
+
use alloc::vec::Vec;
|
|
97
|
+
use stylus_sdk::{alloy_primitives::U256, prelude::*};
|
|
98
|
+
|
|
99
|
+
sol_storage! {
|
|
100
|
+
#[entrypoint]
|
|
101
|
+
pub struct $MODULE_NAME_PASCAL {
|
|
102
|
+
uint256 number;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#[public]
|
|
107
|
+
impl $MODULE_NAME_PASCAL {
|
|
108
|
+
pub fn number(&self) -> U256 {
|
|
109
|
+
self.number.get()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
pub fn set_number(&mut self, new_number: U256) {
|
|
113
|
+
self.number.set(new_number);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
LIBEOF
|
|
117
|
+
|
|
118
|
+
# Write src/main.rs
|
|
119
|
+
cat > "$MODULE_DIR/src/main.rs" << MAINEOF
|
|
120
|
+
#![cfg_attr(not(any(test, feature = "export-abi")), no_main)]
|
|
121
|
+
|
|
122
|
+
#[cfg(not(any(test, feature = "export-abi")))]
|
|
123
|
+
#[no_mangle]
|
|
124
|
+
pub extern "C" fn main() {}
|
|
125
|
+
|
|
126
|
+
#[cfg(feature = "export-abi")]
|
|
127
|
+
fn main() {
|
|
128
|
+
${MODULE_NAME_UNDERSCORE}::print_from_args();
|
|
129
|
+
}
|
|
130
|
+
MAINEOF
|
|
131
|
+
|
|
132
|
+
# Write Stylus.toml
|
|
133
|
+
cat > "$MODULE_DIR/Stylus.toml" << STYLUSEOF
|
|
134
|
+
[contract]
|
|
135
|
+
name = "$MODULE_NAME"
|
|
136
|
+
STYLUSEOF
|
|
137
|
+
|
|
138
|
+
echo "New workspace member '$MODULE_NAME' created successfully"
|
|
139
|
+
echo ""
|
|
140
|
+
echo "Next steps:"
|
|
141
|
+
echo " 1. Write your contract logic in $MODULE_NAME/src/lib.rs"
|
|
142
|
+
echo " 2. Deploy: yarn deploy --network sepolia --contract $MODULE_NAME"
|
|
143
|
+
echo ""
|
|
144
|
+
echo "Note: members=['*'] in contracts/Cargo.toml auto-discovers new modules — no manual wiring needed."
|
|
@@ -118,26 +118,22 @@ async function hasCargoToml(dirPath: string): Promise<boolean> {
|
|
|
118
118
|
* Find all Cargo projects in the stylus directory
|
|
119
119
|
*/
|
|
120
120
|
async function findCargoProjects(): Promise<string[]> {
|
|
121
|
-
const
|
|
121
|
+
const contractsDir = path.resolve(__dirname, "..", "contracts");
|
|
122
122
|
const cargoProjects: string[] = [];
|
|
123
123
|
|
|
124
124
|
try {
|
|
125
|
-
const entries = await fs.readdir(
|
|
125
|
+
const entries = await fs.readdir(contractsDir, { withFileTypes: true });
|
|
126
126
|
|
|
127
127
|
for (const entry of entries) {
|
|
128
128
|
if (entry.isDirectory()) {
|
|
129
129
|
const dirName = entry.name;
|
|
130
130
|
|
|
131
131
|
// Skip excluded directories
|
|
132
|
-
if (
|
|
133
|
-
dirName === "scripts" ||
|
|
134
|
-
dirName === "deployments" ||
|
|
135
|
-
dirName === "node_modules"
|
|
136
|
-
) {
|
|
132
|
+
if (dirName === "target") {
|
|
137
133
|
continue;
|
|
138
134
|
}
|
|
139
135
|
|
|
140
|
-
const dirPath = path.join(
|
|
136
|
+
const dirPath = path.join(contractsDir, dirName);
|
|
141
137
|
|
|
142
138
|
if (await hasCargoToml(dirPath)) {
|
|
143
139
|
cargoProjects.push(dirPath);
|
|
@@ -43,7 +43,7 @@ export function getContractNameFromCargoToml(contractFolder: string): string {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export function isContractHasConstructor(contractFolder: string): boolean {
|
|
46
|
-
const contractPath = path.resolve(contractFolder, "src/lib.rs");
|
|
46
|
+
const contractPath = path.resolve("contracts", contractFolder, "src/lib.rs");
|
|
47
47
|
if (!fs.existsSync(contractPath)) {
|
|
48
48
|
throw new Error(`lib.rs not found in contract folder: ${contractPath}`);
|
|
49
49
|
}
|
|
@@ -75,7 +75,7 @@ export function getExportConfig(
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
return {
|
|
78
|
-
contractFolder,
|
|
78
|
+
contractFolder: path.basename(contractFolder || ""),
|
|
79
79
|
contractName,
|
|
80
80
|
deploymentDir,
|
|
81
81
|
contractAddress: deploymentData.address as Address,
|
|
@@ -33,7 +33,7 @@ export function getDeploymentConfig(
|
|
|
33
33
|
try {
|
|
34
34
|
contractName =
|
|
35
35
|
deployOptions.name ||
|
|
36
|
-
getContractNameFromCargoToml(deployOptions.contract);
|
|
36
|
+
getContractNameFromCargoToml(path.join("contracts", deployOptions.contract!));
|
|
37
37
|
} catch (e) {
|
|
38
38
|
throw new Error(`❌ Could not read contract name from Cargo.toml: ${e}`);
|
|
39
39
|
}
|
package/templates/base/readme.md
CHANGED
|
@@ -67,13 +67,13 @@ Check the [Rust installation guide](https://www.rust-lang.org/tools/install) for
|
|
|
67
67
|
Then install the Stylus CLI tools:
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
|
-
cargo install --force --locked cargo-stylus@0.
|
|
70
|
+
cargo install --force --locked cargo-stylus@0.10.2
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
**Prerequisite:**
|
|
74
74
|
|
|
75
|
-
- `cargo-stylus` version `0.
|
|
76
|
-
- `rustc` version match with `packages/stylus/
|
|
75
|
+
- `cargo-stylus` version `0.10.2`
|
|
76
|
+
- `rustc` version match with `packages/stylus/contracts/rust-toolchain.toml`
|
|
77
77
|
|
|
78
78
|
Set default `toolchain` match `rust-toolchain.toml` and add the `wasm32-unknown-unknown` build target to your Rust compiler:
|
|
79
79
|
|
|
@@ -133,7 +133,7 @@ In your second terminal:
|
|
|
133
133
|
yarn deploy
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
This command deploys a test smart contract to the local network. The contract is located in `packages/stylus/your-contract/src` and can be modified to suit your needs. The `yarn deploy` command uses the deploy script located in `packages/stylus/scripts` to deploy the contract to the network. You can also customize the deploy script .
|
|
136
|
+
This command deploys a test smart contract to the local network. The contract is located in `packages/stylus/contracts/your-contract/src` and can be modified to suit your needs. The `yarn deploy` command uses the deploy script located in `packages/stylus/scripts` to deploy the contract to the network. You can also customize the deploy script .
|
|
137
137
|
|
|
138
138
|
### 6. Start your NextJS app
|
|
139
139
|
|
|
@@ -153,7 +153,7 @@ yarn stylus:test
|
|
|
153
153
|
|
|
154
154
|
## Development Workflow
|
|
155
155
|
|
|
156
|
-
- Edit your smart contract `lib.rs` in `packages/stylus/your-contract/src`
|
|
156
|
+
- Edit your smart contract `lib.rs` in `packages/stylus/contracts/your-contract/src`
|
|
157
157
|
- Edit your frontend in `packages/nextjs/app`
|
|
158
158
|
- Edit your deployment scripts in `packages/stylus/scripts`
|
|
159
159
|
|
|
@@ -169,14 +169,16 @@ Use the following command to create a new contract and customize it as needed:
|
|
|
169
169
|
yarn new-module <contract-name>
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
The generated contract will be located in `packages/stylus/<contract-name>`.
|
|
172
|
+
The generated contract will be located in `packages/stylus/contracts/<contract-name>`.
|
|
173
|
+
|
|
174
|
+
**Workspace structure:** `packages/stylus/contracts` is a Cargo workspace with `members = ["*"]`. `yarn new-module <name>` (via `scripts/new_module.sh`) scaffolds the new contract under `contracts/` — the glob auto-discovers it, no manual wiring needed.
|
|
173
175
|
|
|
174
176
|
### Step 2: Validate Your Contract Before Deployment
|
|
175
177
|
|
|
176
178
|
Before deploying, it's recommended to validate your contract size using `cargo stylus check`:
|
|
177
179
|
|
|
178
180
|
```bash
|
|
179
|
-
cd packages/stylus/<contract-name>
|
|
181
|
+
cd packages/stylus/contracts/<contract-name>
|
|
180
182
|
cargo stylus check
|
|
181
183
|
```
|
|
182
184
|
|
|
File without changes
|
|
File without changes
|
/package/templates/base/packages/stylus/{your-contract → contracts/your-contract}/.cargo/config.toml
RENAMED
|
File without changes
|
/package/templates/base/packages/stylus/{your-contract → contracts/your-contract}/header.png
RENAMED
|
File without changes
|
/package/templates/base/packages/stylus/{your-contract → contracts/your-contract}/src/lib.rs
RENAMED
|
File without changes
|
/package/templates/base/packages/stylus/{your-contract → contracts/your-contract}/src/main.rs
RENAMED
|
File without changes
|