You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// We'll use this to track user balances in Part 1.
140
-
#[storage(slot(1), description ="balances")]
148
+
#[storage(description ="balances")]
141
149
balances:StorageMap,
142
150
}
143
151
@@ -185,18 +193,24 @@ Update the root `Cargo.toml` to reflect our renamed contract:
185
193
186
194
```toml title="Cargo.toml"
187
195
[workspace]
188
-
resolver = "2"
189
-
190
196
members = [
191
-
"contracts/bank-account",
192
-
"contracts/increment-note", # We'll replace this later
193
-
"integration",
197
+
"integration"
198
+
]
199
+
exclude = [
200
+
"contracts/",
194
201
]
202
+
resolver = "2"
203
+
204
+
[workspace.package]
205
+
edition = "2021"
195
206
196
207
[workspace.dependencies]
197
-
miden = { version = "0.8" }
198
208
```
199
209
210
+
:::info Contracts Are Excluded
211
+
In v0.13, contracts are excluded from the Cargo workspace and built independently by `cargo miden`. Each contract specifies its own `miden` dependency directly. Only the `integration` crate remains a workspace member.
212
+
:::
213
+
200
214
## Step 5: Build and Verify
201
215
202
216
Let's verify everything compiles correctly:
@@ -231,7 +245,7 @@ Let's create a simple test to verify the bank account can be created. Create a n
Unlike `Value::read()` which returns a `Word`, `StorageMap::get()` returns a single `Felt`. This is an important distinction.
141
141
:::
142
142
143
-
### Storage Slot Layout
143
+
### Storage Layout
144
144
145
145
Plan your storage layout carefully:
146
146
147
-
|Slot| Type | Purpose |
147
+
|Name| Type | Purpose |
148
148
|------|------|---------|
149
-
|0|`Value`| Initialization flag |
150
-
|1|`StorageMap`| Depositor balances |
149
+
|`initialized`|`Value`| Initialization flag |
150
+
|`balances`|`StorageMap`| Depositor balances |
151
151
152
-
The `description` attribute is for documentation and debugging - it doesn't affect runtime behavior.
152
+
The `description` attribute generates named slot identifiers (e.g., `miden::component::miden_bank_account::initialized`) used in tests to reference specific slots. The compiler auto-assigns slot numbers based on field order.
cargo test --package integration part1_account_test -- --nocapture
314
+
cargo test --package integration test_bank_account_storage -- --nocapture
306
315
```
307
316
308
317
<details>
@@ -330,7 +339,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored
330
339
:::tip Troubleshooting
331
340
**"cannot find function `build_project_in_dir`"**: Make sure your `integration/src/helpers.rs` exports this function and `integration/src/lib.rs` has `pub mod helpers;`.
332
341
333
-
**"StorageSlot::Map not found"**: Ensure you're using the correct imports: `use miden_client::account::StorageSlot;`
342
+
**"StorageSlot not found"**: Ensure you're using the correct imports: `use miden_client::account::{StorageSlot, StorageSlotName};`
334
343
:::
335
344
336
345
## Complete Code for This Part
@@ -354,12 +363,12 @@ use miden::*;
354
363
structBank {
355
364
/// Tracks whether the bank has been initialized (deposits enabled).
356
365
/// Word layout: [is_initialized (0 or 1), 0, 0, 0]
0 commit comments