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
Copy file name to clipboardExpand all lines: docs/docs/developers/docs/resources/migration_notes.md
+26-8Lines changed: 26 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,18 +90,25 @@ where
90
90
```
91
91
92
92
`PrivateImmutable`, `PrivateMutable` and `PrivateSet` got modified to directly contain the owner instead of implicitly "containing it" by including it in the storage slot via a `Map`.
93
-
Now the `Map` is redundant and the relevant state variable should be moved out of it:
93
+
These state variables now implement a newly introduced `OwnedStateVariable` trait (see docs of `OwnedStateVariable` for explanation of what it is).
94
+
These changes make the state variables incompatible with `Map` and now instead these should be wrapped in new `Owned` state variable:
Now we have an `at` method on the private state variables that scopes it to a given owner.
104
-
Given that we used to call `at` on the map and now we call it directly on the set if you so the above change it should not be required of you to do any further changes in your contract.
104
+
Note that even though the types of your state variables are changing from `Map<AztecAddress, T, Context>` to `Owned<T, Context>`, usage remains unchanged:
105
+
106
+
```
107
+
let nft_notes = self.storage.private_nfts.at(from).pop_notes(NoteGetterOptions::new().select(NFTNote::properties().token_id, Comparator.EQ, token_id).set_limit(1));
108
+
```
109
+
110
+
With this change the underlying notes will inherit the storage slot of the `Owned` state variable.
111
+
This is unlike `Map` where the nested state variable got the storage slot computed as `hash([map_storage_slot, key])`.
105
112
106
113
if you had `PrivateImmutable` or `PrivateMutable` defined out of a `Map`, e.g.:
107
114
@@ -113,12 +120,23 @@ struct Storage<Context> {
113
120
```
114
121
115
122
you were most likely dealing with some kind of admin flow where only the admin can modify the state variable.
116
-
Now, unfortunately, there is a bit of a regression and you will need to call `at` on the state var:
123
+
Now, unfortunately, there is a bit of a regression and you will need to wrap the state variable in `Owned` and call `at` on the state var:
f"Type {typ} implements OwnedStateVariable and hence cannot be placed in Storage struct without being wrapped in Owned. Define the type in storage as Owned<{typ}<..., Context>>, Context>.",
56
+
)
57
+
}
58
+
59
+
panic(
60
+
f"Type {typ} does not implement StateVariable and hence cannot be placed in Storage struct.",
0 commit comments