Skip to content

Commit

Permalink
move to edition 2024_07
Browse files Browse the repository at this point in the history
  • Loading branch information
remybar committed Jul 23, 2024
1 parent 1b5953b commit cce09e4
Show file tree
Hide file tree
Showing 28 changed files with 261 additions and 213 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.6.3"
scarb-version: "2.7.0-rc.3"
- run: |
scarb --manifest-path examples/spawn-and-move/Scarb.toml fmt --check
scarb --manifest-path crates/dojo-core/Scarb.toml fmt --check
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scarb 2.6.4
scarb 2.7.0-rc.3
2 changes: 1 addition & 1 deletion crates/dojo-core/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
cairo-version = "2.7.0-rc.3"
edition = "2023_11"
edition = "2024_07"
description = "The Dojo Core library for autonomous worlds."
name = "dojo"
version = "0.7.3"
Expand Down
3 changes: 2 additions & 1 deletion crates/dojo-core/src/contract/base_contract.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[starknet::contract]
pub mod base {
use starknet::{ClassHash, get_caller_address};
use starknet::{ClassHash, ContractAddress, get_caller_address};
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};

use dojo::contract::upgradeable::upgradeable as upgradeable_component;
use dojo::world::{IWorldProvider, IWorldDispatcher, IWorldDispatcherTrait};
Expand Down
2 changes: 1 addition & 1 deletion crates/dojo-core/src/contract/upgradeable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod upgradeable {
use dojo::world::{IWorldProvider, IWorldProviderDispatcher, IWorldDispatcher};

#[storage]
struct Storage {}
pub struct Storage {}

#[event]
#[derive(Drop, starknet::Event)]
Expand Down
4 changes: 3 additions & 1 deletion crates/dojo-core/src/model/layout.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ pub enum Layout {
Enum: Span<FieldLayout>,
}

// TODO RBA
/// Compute the full size in bytes of a layout, when all the fields
/// are bit-packed.
/// Could be None if at least a field has a dynamic size.
pub fn compute_packed_size(layout: Layout) -> Option<usize> {
if let Layout::Fixed(layout) = layout {
let mut span_layout = layout;
Expand Down
2 changes: 1 addition & 1 deletion crates/dojo-core/src/storage/database.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn fill_with_zeroes(ref values: Array<felt252>, size: u32) {
}

/// Compute the internal storage key from a table selector and a key.
///
///
/// # Arguments
/// * `table` - the table selector
/// * `key` - a key to identify a record in the table
Expand Down
6 changes: 4 additions & 2 deletions crates/dojo-core/src/storage/packing.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ pub fn pack_inner(
assert(packing_offset <= PACKING_MAX_BITS, 'Invalid packing offset');
assert(size <= PACKING_MAX_BITS, 'Invalid layout size');

// Cannot use all 252 bits because some bit arrangements (eg. 11111...11111) are not valid felt252 values.
// Cannot use all 252 bits because some bit arrangements (eg. 11111...11111) are not valid
// felt252 values.
// Thus only 251 bits are used. ^-252 times-^
// One could optimize by some conditional alligment mechanism, but it would be an at most 1/252 space-wise improvement.
// One could optimize by some conditional alligment mechanism, but it would be an at most 1/252
// space-wise improvement.
let remaining_bits: u8 = (PACKING_MAX_BITS - packing_offset).into();

// If we have less remaining bits than the current item size,
Expand Down
3 changes: 2 additions & 1 deletion crates/dojo-core/src/tests/world.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ trait Ibar<TContractState> {
mod bar {
use core::traits::Into;
use starknet::{get_caller_address, ContractAddress};

use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};
use dojo::model::{Model, ModelIndex};

use super::{Foo, IWorldDispatcher, IWorldDispatcherTrait, Introspect};
Expand Down Expand Up @@ -855,6 +855,7 @@ trait IWorldUpgrade<TContractState> {
#[starknet::contract]
mod worldupgrade {
use super::{IWorldUpgrade, IWorldDispatcher, ContractAddress};
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};

#[storage]
struct Storage {
Expand Down
10 changes: 5 additions & 5 deletions crates/dojo-core/src/utils/utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn entity_id_from_keys(keys: Span<felt252>) -> felt252 {
poseidon_hash_span(keys)
}

/// TODO RBA
/// find a field with its selector in a list of layouts
pub fn find_field_layout(
field_selector: felt252, field_layouts: Span<FieldLayout>
) -> Option<Layout> {
Expand All @@ -48,14 +48,14 @@ pub fn find_field_layout(
}

/// Find the layout of a model field based on its selector.
///
///
/// # Arguments
///
///
/// * `model_layout` - The full model layout (must be a Layout::Struct).
/// * `member_selector` - The model field selector.
///
///
/// # Returns
/// Some(Layout) if the field layout has been found, None otherwise.
/// Some(Layout) if the field layout has been found, None otherwise.
pub fn find_model_field_layout(model_layout: Layout, member_selector: felt252) -> Option<Layout> {
match model_layout {
Layout::Struct(field_layouts) => { find_field_layout(member_selector, field_layouts) },
Expand Down
3 changes: 2 additions & 1 deletion crates/dojo-core/src/world/config.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub mod Config {
use starknet::ContractAddress;
use starknet::get_caller_address;
use starknet::event::EventEmitter;
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};

use super::errors;
use super::IConfig;
Expand Down Expand Up @@ -76,7 +77,7 @@ pub mod Config {
}

#[storage]
struct Storage {
pub struct Storage {
differ_program_hash: felt252,
merger_program_hash: felt252,
facts_registry: ContractAddress,
Expand Down
Loading

0 comments on commit cce09e4

Please sign in to comment.