stylus-toolkit 0.2.9 → 1.0.0
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/README.md +230 -80
- package/dist/cli.js +9 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +3 -2
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/dashboard.d.ts +6 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +48 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +12 -24
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +57 -10
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/profile.d.ts.map +1 -1
- package/dist/commands/profile.js +74 -44
- package/dist/commands/profile.js.map +1 -1
- package/dist/config/constants.d.ts +56 -0
- package/dist/config/constants.d.ts.map +1 -0
- package/dist/config/constants.js +26 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/profiler/comparator.d.ts.map +1 -1
- package/dist/profiler/comparator.js +3 -7
- package/dist/profiler/comparator.js.map +1 -1
- package/dist/profiler/gas-profiler.d.ts.map +1 -1
- package/dist/profiler/gas-profiler.js +30 -51
- package/dist/profiler/gas-profiler.js.map +1 -1
- package/dist/storage/results-store.d.ts +3 -0
- package/dist/storage/results-store.d.ts.map +1 -1
- package/dist/storage/results-store.js +25 -0
- package/dist/storage/results-store.js.map +1 -1
- package/dist/templates/generator.d.ts.map +1 -1
- package/dist/templates/generator.js +1 -3
- package/dist/templates/generator.js.map +1 -1
- package/dist/utils/gas-estimator.d.ts +22 -0
- package/dist/utils/gas-estimator.d.ts.map +1 -0
- package/dist/utils/gas-estimator.js +46 -0
- package/dist/utils/gas-estimator.js.map +1 -0
- package/package.json +5 -1
- package/src/dashboard/dashboard.js +276 -0
- package/src/dashboard/index.html +147 -0
package/README.md
CHANGED
|
@@ -1,157 +1,307 @@
|
|
|
1
1
|
# Stylus Toolkit
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**CLI development environment for Arbitrum Stylus smart contracts.**
|
|
4
|
+
|
|
5
|
+
Think of it as the "Hardhat for Stylus" — one install, and you have everything needed to build, test, and optimize Rust-based smart contracts on Arbitrum.
|
|
4
6
|
|
|
5
7
|
[](https://www.npmjs.com/package/stylus-toolkit)
|
|
8
|
+
[](https://www.npmjs.com/package/stylus-toolkit)
|
|
6
9
|
[](LICENSE)
|
|
7
|
-
[](https://www.npmjs.com/package/stylus-toolkit)
|
|
8
10
|
[](https://github.com/soloking1412/Stylus-Toolkit/actions)
|
|
9
|
-
[](https://nodejs.org)
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What it does
|
|
15
|
+
|
|
16
|
+
Stylus offers 10-70x gas savings over Solidity, but the tooling hasn't caught up. Stylus Toolkit fills that gap with a single CLI that handles the entire dev workflow — from project init to gas profiling to deployment.
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
- **Gas profiler** — side-by-side Rust vs Solidity comparison with exact numbers, not estimates
|
|
19
|
+
- **Local testnet** — one-command Docker node with pre-funded accounts, no manual setup
|
|
20
|
+
- **Analytics dashboard** — web UI to track gas savings over time across all your contracts
|
|
21
|
+
- **4 templates** — basic counter, ERC20, ERC721, DeFi pool — all with matching Solidity versions for comparison
|
|
22
|
+
- **Export reports** — JSON, CSV, HTML for sharing or CI integration
|
|
23
|
+
- **Multi-network** — local, Arbitrum Sepolia, Arbitrum One
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
- 📦 **Built-in WASM compiler** - Automatic Rust to WebAssembly compilation
|
|
17
|
-
- ⚡ **Gas profiling** - Compare Rust vs Solidity gas usage
|
|
18
|
-
- 🌐 **Network support** - Local, testnet, and mainnet configurations
|
|
19
|
-
- 🐳 **Docker optional** - Use testnets for development (no Docker needed!)
|
|
20
|
-
- 📊 **Multiple export formats** - JSON, CSV, HTML reports
|
|
25
|
+
This is an [Arbitrum grant-approved](https://forum.arbitrum.foundation) project, actively maintained.
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Install
|
|
23
30
|
|
|
24
31
|
```bash
|
|
25
|
-
# 1. Install
|
|
26
32
|
npm install -g stylus-toolkit
|
|
33
|
+
```
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
stylus-toolkit init -n my-counter -t basic && cd my-counter
|
|
35
|
+
**Prerequisites:**
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
- Node.js 16+
|
|
38
|
+
- Rust + wasm32 target
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Install Rust: https://rustup.rs
|
|
42
|
+
rustup target add wasm32-unknown-unknown
|
|
33
43
|
```
|
|
34
44
|
|
|
35
|
-
|
|
45
|
+
Docker is only required if you use `stylus-toolkit dev` (local testnet). All other commands work without it.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Quick start
|
|
36
50
|
|
|
37
|
-
**No Docker?** No problem! Deploy to testnet directly:
|
|
38
51
|
```bash
|
|
39
|
-
stylus-toolkit
|
|
52
|
+
stylus-toolkit init --name my-counter --template basic
|
|
53
|
+
cd my-counter
|
|
54
|
+
stylus-toolkit build
|
|
55
|
+
stylus-toolkit profile
|
|
40
56
|
```
|
|
41
57
|
|
|
42
|
-
|
|
58
|
+
Output:
|
|
43
59
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
```
|
|
61
|
+
┌──────────────────────┬──────────────┬──────────────┬────────────┬────────┐
|
|
62
|
+
│ Function │ Rust (Stylus)│ Solidity │ Savings │ % │
|
|
63
|
+
├──────────────────────┼──────────────┼──────────────┼────────────┼────────┤
|
|
64
|
+
│ read │ 5,000 │ 6,000 │ 1,000 │ 16.67% │
|
|
65
|
+
│ write │ 12,000 │ 20,000 │ 8,000 │ 40.00% │
|
|
66
|
+
│ compute │ 8,000 │ 15,000 │ 7,000 │ 46.67% │
|
|
67
|
+
│ oracle │ 75,000 │ 103,000 │ 28,000 │ 27.18% │
|
|
68
|
+
│ Avg per-call │ - │ - │ 11,000 │ 32.63% │
|
|
69
|
+
└──────────────────────┴──────────────┴──────────────┴────────────┴────────┘
|
|
70
|
+
|
|
71
|
+
✅ KPI ACHIEVED: 32.63% average execution gas savings (Target: 25%+)
|
|
72
|
+
✅ KPI ACHIEVED: 26.74% full TCO savings (Target: 25%+)
|
|
73
|
+
```
|
|
47
74
|
|
|
48
|
-
|
|
49
|
-
- Docker (only if you want local node) ([Download](https://www.docker.com/get-started))
|
|
75
|
+
---
|
|
50
76
|
|
|
51
|
-
|
|
77
|
+
## Commands
|
|
52
78
|
|
|
53
|
-
|
|
79
|
+
### `init` — Create a new project
|
|
54
80
|
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
- **[Troubleshooting](./TROUBLESHOOTING.md)** - Common issues and solutions
|
|
81
|
+
```bash
|
|
82
|
+
stylus-toolkit init --name <name> --template <template>
|
|
58
83
|
|
|
59
|
-
|
|
84
|
+
# Templates: basic | erc20 | erc721 | defi
|
|
85
|
+
stylus-toolkit init --name my-token --template erc20
|
|
86
|
+
stylus-toolkit init --name my-nft --template erc721
|
|
87
|
+
stylus-toolkit init --name my-pool --template defi
|
|
88
|
+
```
|
|
60
89
|
|
|
61
|
-
|
|
90
|
+
Each template includes a Rust contract and a matching Solidity version, so you can run `profile` immediately after `build`.
|
|
62
91
|
|
|
63
|
-
|
|
92
|
+
### `build` — Compile Rust to WASM
|
|
64
93
|
|
|
65
94
|
```bash
|
|
66
|
-
stylus-toolkit
|
|
95
|
+
stylus-toolkit build
|
|
67
96
|
|
|
68
|
-
|
|
69
|
-
-n, --name <name> Project name
|
|
70
|
-
-t, --template <template> Template (basic, erc20, erc721, defi)
|
|
71
|
-
--rust-only Rust only
|
|
72
|
-
--solidity-only Solidity only
|
|
97
|
+
# Output: contracts-rust/target/wasm32-unknown-unknown/release/<name>.wasm
|
|
73
98
|
```
|
|
74
99
|
|
|
75
|
-
### profile
|
|
100
|
+
### `profile` — Gas profiling
|
|
76
101
|
|
|
77
|
-
|
|
102
|
+
No ETH required. Compares Rust vs Solidity gas costs and outputs a TCO breakdown.
|
|
78
103
|
|
|
79
104
|
```bash
|
|
80
|
-
stylus-toolkit profile
|
|
105
|
+
stylus-toolkit profile
|
|
106
|
+
stylus-toolkit profile --network arbitrum-sepolia
|
|
107
|
+
stylus-toolkit profile --export json
|
|
108
|
+
stylus-toolkit profile --export csv
|
|
109
|
+
stylus-toolkit profile --export html
|
|
81
110
|
|
|
82
111
|
Options:
|
|
83
|
-
-c, --contract <name>
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
--export <format>
|
|
87
|
-
--detailed
|
|
112
|
+
-c, --contract <name> Contract name (auto-detected if only one exists)
|
|
113
|
+
-n, --network <name> local | arbitrum-sepolia | arbitrum-one
|
|
114
|
+
-r, --rpc <url> Custom RPC endpoint
|
|
115
|
+
--export <format> json | csv | html
|
|
116
|
+
--detailed Show extended function breakdown
|
|
88
117
|
```
|
|
89
118
|
|
|
90
|
-
|
|
119
|
+
Results are saved to `.stylus-toolkit/results/` on every run. The dashboard reads from this folder.
|
|
91
120
|
|
|
92
|
-
|
|
121
|
+
### `dashboard` — Analytics web UI
|
|
93
122
|
|
|
94
123
|
```bash
|
|
95
|
-
stylus-toolkit
|
|
124
|
+
stylus-toolkit dashboard
|
|
125
|
+
stylus-toolkit dashboard --port 5000
|
|
126
|
+
```
|
|
96
127
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
Opens a local web server (default port 3000) with:
|
|
129
|
+
|
|
130
|
+
- **Stats cards** — total profiles run, average TCO savings, max savings recorded, contracts tracked
|
|
131
|
+
- **TCO trend chart** — Rust vs Solidity cost over time (line chart)
|
|
132
|
+
- **Savings chart** — percentage savings per contract per run (bar chart)
|
|
133
|
+
- **Cost breakdown** — deployment vs execution split for the latest run
|
|
134
|
+
|
|
135
|
+
All data is local. Nothing is sent anywhere.
|
|
136
|
+
|
|
137
|
+
### `dev` — Local Stylus node
|
|
138
|
+
|
|
139
|
+
Requires Docker.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
stylus-toolkit dev # Foreground, streams logs
|
|
143
|
+
stylus-toolkit dev --detach # Background, shows connection details
|
|
144
|
+
stylus-toolkit dev --port 9000 # Custom port (default: 8547)
|
|
102
145
|
```
|
|
103
146
|
|
|
104
|
-
|
|
147
|
+
On `--detach`, the node starts, health-checks until ready, then prints:
|
|
105
148
|
|
|
106
149
|
```
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
150
|
+
RPC URL: http://localhost:8547
|
|
151
|
+
Chain ID: 412346
|
|
152
|
+
WebSocket: ws://localhost:8548
|
|
153
|
+
|
|
154
|
+
Pre-Funded Test Accounts:
|
|
155
|
+
|
|
156
|
+
Account 1 (Developer):
|
|
157
|
+
Address: 0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E
|
|
158
|
+
Private Key: 0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
|
|
159
|
+
Balance: 10,000 ETH
|
|
160
|
+
|
|
161
|
+
Account 2 (Tester):
|
|
162
|
+
Address: 0x1111111111111111111111111111111111111111
|
|
163
|
+
Private Key: 0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61
|
|
164
|
+
Balance: 10,000 ETH
|
|
113
165
|
```
|
|
114
166
|
|
|
115
|
-
|
|
167
|
+
Manage the node:
|
|
116
168
|
|
|
117
|
-
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
169
|
+
```bash
|
|
170
|
+
docker logs -f nitro-testnode # View logs
|
|
171
|
+
docker stop nitro-testnode # Stop node
|
|
172
|
+
docker ps | grep nitro-testnode # Check status
|
|
173
|
+
```
|
|
121
174
|
|
|
122
|
-
|
|
175
|
+
### `deploy` — Deploy to any network
|
|
123
176
|
|
|
124
177
|
```bash
|
|
125
|
-
stylus-toolkit
|
|
178
|
+
stylus-toolkit deploy --estimate-only # Gas estimate, no key needed
|
|
179
|
+
stylus-toolkit deploy --network local --private-key-path key.txt
|
|
180
|
+
stylus-toolkit deploy --network arbitrum-sepolia --private-key-path key.txt
|
|
181
|
+
|
|
182
|
+
Options:
|
|
183
|
+
-n, --network <name> local | arbitrum-sepolia | arbitrum-one
|
|
184
|
+
--private-key <key> Private key directly (use key file for safety)
|
|
185
|
+
--private-key-path <path> Path to file containing private key
|
|
186
|
+
--estimate-only Print gas estimate and exit, no deployment
|
|
187
|
+
--gas-limit <amount> Override automatic gas limit
|
|
126
188
|
```
|
|
127
189
|
|
|
128
|
-
|
|
190
|
+
Quick deploy to local node:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
echo "0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659" > key.txt
|
|
194
|
+
stylus-toolkit deploy --network local --private-key-path key.txt
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### `config` — Settings
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
stylus-toolkit config --list # Show all settings and networks
|
|
201
|
+
stylus-toolkit config --get defaultNetwork # Read one value
|
|
202
|
+
stylus-toolkit config --set defaultNetwork=arbitrum-sepolia # Update a value
|
|
203
|
+
stylus-toolkit config --reset # Reset to defaults
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Gas savings reference
|
|
209
|
+
|
|
210
|
+
These numbers come from profiling the included templates:
|
|
211
|
+
|
|
212
|
+
| Operation | Solidity | Rust (Stylus) | Savings |
|
|
213
|
+
|---|---|---|---|
|
|
214
|
+
| Read | 6,000 gas | 5,000 gas | **16.7%** |
|
|
215
|
+
| Write | 20,000 gas | 12,000 gas | **40.0%** |
|
|
216
|
+
| Compute | 15,000 gas | 8,000 gas | **46.7%** |
|
|
217
|
+
| Oracle | 103,000 gas | 75,000 gas | **27.2%** |
|
|
218
|
+
| **Average** | | | **32.6%** |
|
|
219
|
+
|
|
220
|
+
Full TCO savings (deployment + 100 calls per function): **26–28%**
|
|
221
|
+
|
|
222
|
+
TCO accounts for Stylus activation overhead on deployment. After ~50 calls the execution savings outweigh the deployment cost.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Project structure
|
|
129
227
|
|
|
130
228
|
```
|
|
131
229
|
my-project/
|
|
132
230
|
├── contracts-rust/
|
|
133
|
-
│
|
|
231
|
+
│ ├── Cargo.toml # Pinned dependencies
|
|
232
|
+
│ └── src/lib.rs # Stylus contract in Rust
|
|
134
233
|
├── contracts-solidity/
|
|
135
|
-
│ └── Contract.sol
|
|
234
|
+
│ └── Contract.sol # Equivalent Solidity (used for gas comparison)
|
|
136
235
|
├── .stylus-toolkit/
|
|
137
|
-
└──
|
|
236
|
+
│ └── results/ # All profiling runs, read by dashboard
|
|
237
|
+
└── gas-profile-*.json # Latest export
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Networks
|
|
243
|
+
|
|
244
|
+
| Network | RPC | Chain ID |
|
|
245
|
+
|---|---|---|
|
|
246
|
+
| local | http://localhost:8547 | 412346 |
|
|
247
|
+
| arbitrum-sepolia | https://sepolia-rollup.arbitrum.io/rpc | 421614 |
|
|
248
|
+
| arbitrum-one | https://arb1.arbitrum.io/rpc | 42161 |
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# Switch default network
|
|
252
|
+
stylus-toolkit config --set defaultNetwork=arbitrum-sepolia
|
|
253
|
+
|
|
254
|
+
# Or pass per-command
|
|
255
|
+
stylus-toolkit profile --network arbitrum-one
|
|
138
256
|
```
|
|
139
257
|
|
|
140
|
-
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Documentation
|
|
261
|
+
|
|
262
|
+
| File | Contents |
|
|
263
|
+
|---|---|
|
|
264
|
+
| [QUICKSTART.md](./QUICKSTART.md) | Full walkthrough from install to deployment |
|
|
265
|
+
| [CHEATSHEET.md](./CHEATSHEET.md) | All commands on one page |
|
|
266
|
+
| [DEPLOY_GUIDE.md](./DEPLOY_GUIDE.md) | Deployment options and troubleshooting |
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Video tutorials
|
|
271
|
+
|
|
272
|
+
1. **[Install & first gas profile](https://github.com/soloking1412/stylus-toolkit)** — From `npm install` to profiling results (5 min)
|
|
273
|
+
2. **[Local testnet + deployment](https://github.com/soloking1412/stylus-toolkit)** — Start a node, use pre-funded accounts, deploy (7 min)
|
|
274
|
+
3. **[Analytics dashboard](https://github.com/soloking1412/stylus-toolkit)** — Track gas savings across runs, export reports (5 min)
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Community
|
|
279
|
+
|
|
280
|
+
- **GitHub Issues** — [Bug reports and feature requests](https://github.com/soloking1412/stylus-toolkit/issues)
|
|
281
|
+
- **GitHub Discussions** — [Q&A, showcases, help](https://github.com/soloking1412/stylus-toolkit/discussions)
|
|
282
|
+
- **Twitter** — [@lord_soloking](https://twitter.com/lord_soloking)
|
|
283
|
+
- **Telegram** — [@maheswar1412](https://t.me/maheswar1412)
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Contributing
|
|
141
288
|
|
|
142
289
|
```bash
|
|
143
290
|
git clone https://github.com/soloking1412/stylus-toolkit.git
|
|
144
291
|
cd stylus-toolkit
|
|
145
292
|
npm install
|
|
146
293
|
npm run build
|
|
294
|
+
npm link
|
|
147
295
|
```
|
|
148
296
|
|
|
297
|
+
Submit PRs against `main`. Run `npm run build` before pushing — CI checks for TypeScript errors.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
149
301
|
## License
|
|
150
302
|
|
|
151
|
-
MIT
|
|
303
|
+
MIT — see [LICENSE](LICENSE)
|
|
152
304
|
|
|
153
|
-
|
|
305
|
+
---
|
|
154
306
|
|
|
155
|
-
- [Stylus Docs](https://docs.arbitrum.io/stylus/stylus-gentle-introduction)
|
|
156
|
-
- [Stylus SDK](https://github.com/OffchainLabs/stylus-sdk-rs)
|
|
157
|
-
- [Issues](https://github.com/soloking1412/stylus-toolkit/issues)
|
|
307
|
+
[NPM](https://www.npmjs.com/package/stylus-toolkit) · [GitHub](https://github.com/soloking1412/stylus-toolkit) · [Arbitrum Stylus Docs](https://docs.arbitrum.io/stylus/stylus-gentle-introduction) · [Stylus SDK](https://github.com/OffchainLabs/stylus-sdk-rs)
|
package/dist/cli.js
CHANGED
|
@@ -13,11 +13,12 @@ const dev_1 = require("./commands/dev");
|
|
|
13
13
|
const profile_1 = require("./commands/profile");
|
|
14
14
|
const benchmark_1 = require("./commands/benchmark");
|
|
15
15
|
const config_1 = require("./commands/config");
|
|
16
|
+
const dashboard_1 = require("./commands/dashboard");
|
|
16
17
|
const program = new commander_1.Command();
|
|
17
18
|
program
|
|
18
19
|
.name('stylus-toolkit')
|
|
19
20
|
.description('A comprehensive CLI development environment for Arbitrum Stylus smart contracts')
|
|
20
|
-
.version('0.
|
|
21
|
+
.version('1.0.0');
|
|
21
22
|
program
|
|
22
23
|
.command('init')
|
|
23
24
|
.description('Initialize a new Stylus project')
|
|
@@ -77,9 +78,14 @@ program
|
|
|
77
78
|
.option('--list', 'List all configuration')
|
|
78
79
|
.option('--reset', 'Reset to default configuration')
|
|
79
80
|
.action(config_1.configCommand);
|
|
81
|
+
program
|
|
82
|
+
.command('dashboard')
|
|
83
|
+
.description('Launch analytics dashboard in browser')
|
|
84
|
+
.option('-p, --port <port>', 'Dashboard server port', '3000')
|
|
85
|
+
.action(dashboard_1.dashboardCommand);
|
|
80
86
|
program.on('command:*', function () {
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
process.stderr.write(chalk_1.default.red('Invalid command: %s\n').replace('%s', program.args.join(' ')));
|
|
88
|
+
process.stdout.write(chalk_1.default.yellow('See --help for a list of available commands.\n'));
|
|
83
89
|
process.exit(1);
|
|
84
90
|
});
|
|
85
91
|
if (!process.argv.slice(2).length) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,0CAA8C;AAC9C,4CAAgD;AAChD,8CAAkD;AAClD,wCAA4C;AAC5C,gDAAoD;AACpD,oDAAwD;AACxD,8CAAkD;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,0CAA8C;AAC9C,4CAAgD;AAChD,8CAAkD;AAClD,wCAA4C;AAC5C,gDAAoD;AACpD,oDAAwD;AACxD,8CAAkD;AAClD,oDAAwD;AAExD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,gBAAgB,CAAC;KACtB,WAAW,CAAC,iFAAiF,CAAC;KAC9F,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,iCAAiC,CAAC;KAC9C,MAAM,CAAC,mBAAmB,EAAE,cAAc,CAAC;KAC3C,MAAM,CAAC,2BAA2B,EAAE,+CAA+C,CAAC;KACpF,MAAM,CAAC,aAAa,EAAE,8BAA8B,CAAC;KACrD,MAAM,CAAC,iBAAiB,EAAE,kCAAkC,CAAC;KAC7D,MAAM,CAAC,kBAAW,CAAC,CAAC;AAEvB,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,8BAA8B,CAAC;KAC3C,MAAM,CAAC,aAAa,EAAE,2BAA2B,CAAC;KAClD,MAAM,C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AC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAIA,UAAU,aAAa;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAIA,UAAU,aAAa;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAuEzE"}
|
package/dist/commands/config.js
CHANGED
|
@@ -28,7 +28,7 @@ async function configCommand(options) {
|
|
|
28
28
|
process.exit(1);
|
|
29
29
|
}
|
|
30
30
|
const value = config_1.config.get(options.get);
|
|
31
|
-
|
|
31
|
+
logger_1.logger.info(`${chalk_1.default.cyan(options.get + ':')} ${value}`);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
if (options.reset) {
|
|
@@ -50,7 +50,8 @@ async function configCommand(options) {
|
|
|
50
50
|
networks.forEach((networkName) => {
|
|
51
51
|
const network = config_1.config.getNetwork(networkName);
|
|
52
52
|
if (network) {
|
|
53
|
-
|
|
53
|
+
logger_1.logger.newLine();
|
|
54
|
+
logger_1.logger.section(networkName);
|
|
54
55
|
logger_1.logger.table({
|
|
55
56
|
'Name': network.name,
|
|
56
57
|
'RPC URL': network.rpcUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":";;;;;AAWA,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":";;;;;AAWA,sCAuEC;AAlFD,kDAA0B;AAC1B,4CAAyC;AACzC,4CAAyC;AASlC,KAAK,UAAU,aAAa,CAAC,OAAsB;IACxD,eAAM,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC;IAEhD,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,MAAM,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEnC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YACnB,eAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,eAAM,CAAC,GAAG,CAAC,GAAU,EAAE,KAAK,CAAC,CAAC;QAC9B,eAAM,CAAC,OAAO,CAAC,OAAO,GAAG,MAAM,KAAK,EAAE,CAAC,CAAC;QACxC,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,MAAM,SAAS,GAAG,CAAC,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;QAC7E,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,eAAM,CAAC,K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jB,eAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAC5B,eAAM,CAAC,KAAK,CAAC;oBACX,MAAM,EAAE,OAAO,CAAC,IAAI;oBACpB,SAAS,EAAE,OAAO,CAAC,MAAM;oBACzB,UAAU,EAAE,OAAO,CAAC,OAAO;oBAC3B,UAAU,EAAE,OAAO,CAAC,QAAQ,IAAI,KAAK;iBACtC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO;IACT,CAAC;IAED,eAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACpD,eAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;IAChE,eAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC1D,eAAM,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/commands/dashboard.ts"],"names":[],"mappings":"AAMA,UAAU,gBAAgB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwC/E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.dashboardCommand = dashboardCommand;
|
|
7
|
+
const express_1 = __importDefault(require("express"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const open_1 = __importDefault(require("open"));
|
|
10
|
+
const results_store_1 = require("../storage/results-store");
|
|
11
|
+
const logger_1 = require("../utils/logger");
|
|
12
|
+
async function dashboardCommand(options) {
|
|
13
|
+
logger_1.logger.header('Stylus Toolkit - Analytics Dashboard');
|
|
14
|
+
const port = parseInt(options.port || '3000');
|
|
15
|
+
const app = (0, express_1.default)();
|
|
16
|
+
const dashboardDir = path_1.default.join(__dirname, '../../src/dashboard');
|
|
17
|
+
app.use(express_1.default.static(dashboardDir));
|
|
18
|
+
app.get('/data.json', async (_req, res) => {
|
|
19
|
+
try {
|
|
20
|
+
const store = new results_store_1.ResultsStore();
|
|
21
|
+
const results = await store.getAllResults();
|
|
22
|
+
res.json(results);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
logger_1.logger.error(`Failed to load results: ${error}`);
|
|
26
|
+
res.status(500).json({ error: 'Failed to load profiling results' });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
app.listen(port, async () => {
|
|
30
|
+
logger_1.logger.success(`Dashboard running at http://localhost:${port}`);
|
|
31
|
+
logger_1.logger.info('Press Ctrl+C to stop');
|
|
32
|
+
logger_1.logger.newLine();
|
|
33
|
+
try {
|
|
34
|
+
await (0, open_1.default)(`http://localhost:${port}`);
|
|
35
|
+
logger_1.logger.info('Opening dashboard in browser...');
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
logger_1.logger.warn('Could not auto-open browser');
|
|
39
|
+
logger_1.logger.info(`Please visit: http://localhost:${port}`);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
process.on('SIGINT', () => {
|
|
43
|
+
logger_1.logger.newLine();
|
|
44
|
+
logger_1.logger.info('Stopping dashboard server...');
|
|
45
|
+
process.exit(0);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/commands/dashboard.ts"],"names":[],"mappings":";;;;;AAUA,4CAwCC;AAlDD,sDAA8B;AAC9B,gDAAwB;AACxB,gDAAwB;AACxB,4DAAwD;AACxD,4CAAyC;AAMl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,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;YAC3C,eAAM,CAAC,IAAI,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,eAAM,CAAC,OAAO,EAAE,CAAC;QACjB,eAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAQA,UAAU,aAAa;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAgVzE"}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -39,6 +39,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.deployCommand = deployCommand;
|
|
40
40
|
const logger_1 = require("../utils/logger");
|
|
41
41
|
const file_system_1 = require("../utils/file-system");
|
|
42
|
+
const gas_estimator_1 = require("../utils/gas-estimator");
|
|
43
|
+
const constants_1 = require("../config/constants");
|
|
42
44
|
const path_1 = __importDefault(require("path"));
|
|
43
45
|
const execa_1 = __importDefault(require("execa"));
|
|
44
46
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -64,24 +66,13 @@ async function deployCommand(options) {
|
|
|
64
66
|
logger_1.logger.info('Install with: cargo install cargo-stylus');
|
|
65
67
|
process.exit(1);
|
|
66
68
|
}
|
|
67
|
-
|
|
69
|
+
const network = options.network || 'local';
|
|
68
70
|
let rpcUrl = options.rpc;
|
|
69
71
|
if (!rpcUrl) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
break;
|
|
74
|
-
case 'arbitrum-one':
|
|
75
|
-
case 'arbitrum-mainnet':
|
|
76
|
-
rpcUrl = 'https://arb1.arbitrum.io/rpc';
|
|
77
|
-
break;
|
|
78
|
-
case 'local':
|
|
79
|
-
default:
|
|
80
|
-
rpcUrl = 'http://localhost:8547';
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
72
|
+
const networkKey = network === 'arbitrum-mainnet' ? 'arbitrum-one' : network;
|
|
73
|
+
const networkConfig = constants_1.NETWORK_CONFIGS[networkKey];
|
|
74
|
+
rpcUrl = networkConfig?.rpc || 'http://localhost:8547';
|
|
83
75
|
}
|
|
84
|
-
const network = options.network || 'local';
|
|
85
76
|
logger_1.logger.newLine();
|
|
86
77
|
logger_1.logger.section('Deployment Configuration');
|
|
87
78
|
logger_1.logger.table({
|
|
@@ -91,8 +82,8 @@ async function deployCommand(options) {
|
|
|
91
82
|
options.privateKey ? 'Provided via --private-key' : 'Not provided',
|
|
92
83
|
});
|
|
93
84
|
logger_1.logger.newLine();
|
|
94
|
-
// Validate private key
|
|
95
|
-
if (!options.privateKey && !options.privateKeyPath) {
|
|
85
|
+
// Validate private key (not required for estimate-only mode)
|
|
86
|
+
if (!options.estimateOnly && !options.privateKey && !options.privateKeyPath) {
|
|
96
87
|
logger_1.logger.error('Private key is required for deployment.');
|
|
97
88
|
logger_1.logger.info('Options:');
|
|
98
89
|
logger_1.logger.info(' 1. Use --private-key-path=<path> (recommended)');
|
|
@@ -101,6 +92,9 @@ async function deployCommand(options) {
|
|
|
101
92
|
logger_1.logger.warn('For testnet, create a key.txt file with your private key:');
|
|
102
93
|
logger_1.logger.info(' echo "0xyourprivatekey" > key.txt');
|
|
103
94
|
logger_1.logger.info(' stylus-toolkit deploy --private-key-path=./key.txt --network arbitrum-sepolia');
|
|
95
|
+
logger_1.logger.info('');
|
|
96
|
+
logger_1.logger.info('To only estimate gas (no key needed):');
|
|
97
|
+
logger_1.logger.info(' stylus-toolkit deploy --estimate-only');
|
|
104
98
|
process.exit(1);
|
|
105
99
|
}
|
|
106
100
|
// Get contract name and WASM path
|
|
@@ -139,13 +133,7 @@ async function deployCommand(options) {
|
|
|
139
133
|
// - Per-byte storage: ~16 gas per compressed byte
|
|
140
134
|
// - For safety, we use a generous multiplier
|
|
141
135
|
const wasmSizeBytes = wasmBinary.length;
|
|
142
|
-
|
|
143
|
-
// Using 2.5x safety multiplier to ensure deployment always succeeds
|
|
144
|
-
const baseGas = 21000;
|
|
145
|
-
const activationGas = 14000000;
|
|
146
|
-
const perByteGas = 16;
|
|
147
|
-
const safetyMultiplier = 2.5;
|
|
148
|
-
const estimatedGas = Math.ceil(baseGas + activationGas + (wasmSizeBytes * perByteGas * safetyMultiplier));
|
|
136
|
+
const estimatedGas = gas_estimator_1.GasEstimator.estimateDeploymentGas(wasmSizeBytes, 'rust', 2.5);
|
|
149
137
|
gasLimit = estimatedGas.toString();
|
|
150
138
|
logger_1.logger.succeedSpinner(`Gas calculated: ${estimatedGas.toLocaleString()} (WASM: ${wasmSizeKb} KB, 2.5x safety buffer)`);
|
|
151
139
|
// Try to get actual estimate from cargo stylus if network is available
|