Skip to content

v0.7.0-alpha.4

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 24 May 00:27
· 596 commits to main since this release
aa5b534

⚠️ Breaking changes ⚠️

Before diving into the storage layout in detail, some breaking changes and features:

  1. Models are now defined with an attribute instead of a derive. #[dojo::model]. This will allow in the future to have some additional inputs to this attribute. Example in spawn-and-move.
  2. Before, the models were identified by their name. Now, they are identified by the selector of their name. This breaks the storage slot computation for a model. We will present in a subsequent PR/documentation how backward compatibility can be achieved if it’s still necessary.
  3. Sozo now supports from prefixes to pass a call data: u256, sstr for short string, str for ByteArray. sozo execute --help for details and examples. If you need an other prefix, please don't hesitate to open a PR by implementing the decode trait as shown here or an issue.

Important notes on the storage layout

The book will also be updated once the version is stabilized.

  1. You can now use ByteArray, Array and Option into models as show in the example. The nested level for array is for now 1 dimension (Torii limitation), but will soon be unlocked for arrays with multiple dimensions.
  2. Enumerations can now have variants with different types (including the new supported types).
  3. Introspect is now automatically derived for any struct with the model attributes. However, if you want to have the same behavior as the dojo storage before (all the fields packed sequentially), you should derive IntrospectPacked instead.
  4. At the moment, you can't have a model inside an other model. You should use intermediate structs instead.
  5. Models keys are only primitive type for now. You can’t use a ByteArray, Array or an other structure as key. ByteArray should be unlocked in the future.
  6. In an Option<T>, the inner type T can’t be a tuple. An easy workaround is to use a struct instead.
  7. GraphQL is still in iteration to support any type combination, please report any model that is not indexed by Torii and served correctly with GraphQL schemas. Here are some example of new type query. Tuples are different than array, you must use the index prefixed with _.
# Array<Vec2>
array {
  x
  y
}

# Option<Vec2>
enum {
  # inner type
  Some {
    x
    y  
  }
  option
}

# (u8, Vec2)
tuple {
  _0
  _1 {
    x
    y
  }
}

# ByteArray
bytearray
  1. #1989 will be re-open targeting main to add new sozo commands and give more insights on the storage layout and schema for a model to ensure you can inspect how models are stored precisely.

Targeted features for for the 0.7.0 (which will ends up being the first iteration for 1.0):

  • Cairo 2.6 support (currently only a CI problem to be fixed to ensure correct publication of the releases.
  • New storage layout [1/2] with: Nested structs, Array<T>, ByteArray.
  • New storage layout [2/2] with: Enums rework to fully support custom enumeration without the same type limitation we currently have.
  • Sozo support for constructor / initializer pattern with arguments (#1964)
  • Update of Torii to support the new types + the new storage layout.
  • Starknet foundry for testing
  • Namespaces to register / access models.

What's Changed

  • Remove sozo as a dependency of katana-runner crate by @kariy in #1988
  • Update devcontainer image: v0.7.0-alpha.3 by @tarrencev in #1961
  • [Katana] Allow choosing the class in the genesis file without affecting the actual class hash by @Yogalholic in #1975
  • refactor(katana): replace cursor-based api with by block basis for simplicity by @kariy in #1986
  • Refactor saya to fetch the traces using the new API by @kariy in #1987
  • Add doc comments for L1HandlerTx by @kariy in #1980
  • fix(katana): l1/l2 messaging hash computations by @kariy in #1981
  • feat: new layout support by @Larkooo in #1970
  • Prepare release: v0.7.0-alpha.4 by @tarrencev in #1990

New Contributors

Full Changelog: v0.7.0-alpha.3...v0.7.0-alpha.4