Skip to content

Commit

Permalink
Revert "Rename SerdeLen to ComponentSize and derive with Component (#868
Browse files Browse the repository at this point in the history
)"

This reverts commit e1a70e3.
  • Loading branch information
tarrencev committed Sep 15, 2023
1 parent 29da319 commit 47c0cbc
Show file tree
Hide file tree
Showing 25 changed files with 208 additions and 440 deletions.
126 changes: 0 additions & 126 deletions crates/dojo-core/src/database/storage.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -60,129 +60,3 @@ fn set_many(address_domain: u32, keys: Span<felt252>, offset: u8, mut value: Spa
};
};
}


trait StorageSize<T> {
fn unpacked_size() -> usize;
fn packed_size() -> usize;
}

impl StorageSizeFelt252 of StorageSize<felt252> {
#[inline(always)]
fn unpacked_size() -> usize {
1
}

#[inline(always)]
fn packed_size() -> usize {
252
}
}

impl StorageSizeBool of StorageSize<bool> {
#[inline(always)]
fn unpacked_size() -> usize {
1
}

#[inline(always)]
fn packed_size() -> usize {
1
}
}

impl StorageSizeU8 of StorageSize<u8> {
#[inline(always)]
fn unpacked_size() -> usize {
1
}

#[inline(always)]
fn packed_size() -> usize {
8
}
}

impl StorageSizeU16 of StorageSize<u16> {
#[inline(always)]
fn unpacked_size() -> usize {
1
}

#[inline(always)]
fn packed_size() -> usize {
16
}
}

impl StorageSizeU32 of StorageSize<u32> {
#[inline(always)]
fn unpacked_size() -> usize {
1
}

#[inline(always)]
fn packed_size() -> usize {
32
}
}

impl StorageSizeU64 of StorageSize<u64> {
#[inline(always)]
fn unpacked_size() -> usize {
1
}

#[inline(always)]
fn packed_size() -> usize {
64
}
}

impl StorageSizeU128 of StorageSize<u128> {
#[inline(always)]
fn unpacked_size() -> usize {
1
}

#[inline(always)]
fn packed_size() -> usize {
128
}
}

impl StorageSizeU256 of StorageSize<u256> {
#[inline(always)]
fn unpacked_size() -> usize {
2
}

#[inline(always)]
fn packed_size() -> usize {
256
}
}

impl StorageSizeContractAddress of StorageSize<starknet::ContractAddress> {
#[inline(always)]
fn unpacked_size() -> usize {
1
}

#[inline(always)]
fn packed_size() -> usize {
256
}
}

impl StorageSizeClassHash of StorageSize<starknet::ClassHash> {
#[inline(always)]
fn unpacked_size() -> usize {
1
}

#[inline(always)]
fn packed_size() -> usize {
256
}
}
2 changes: 1 addition & 1 deletion crates/dojo-core/src/executor_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use starknet::class_hash::Felt252TryIntoClassHash;
use dojo::executor::{executor, IExecutorDispatcher, IExecutorDispatcherTrait};
use dojo::world::{Context, IWorldDispatcher};

#[derive(Component, Copy, Drop, Serde)]
#[derive(Component, Copy, Drop, Serde, SerdeLen)]
struct Foo {
#[key]
id: felt252,
Expand Down
8 changes: 3 additions & 5 deletions crates/dojo-core/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
mod database;
use database::storage::StorageSize;
#[cfg(test)]
mod database_test;
mod executor;
#[cfg(test)]
mod executor_test;
mod component;
mod packing;
#[cfg(test)]
mod packing_test;
mod serde;
use serde::SerdeLen;
mod traits;
mod world;
#[cfg(test)]
mod world_test;
Expand Down
145 changes: 0 additions & 145 deletions crates/dojo-core/src/packing.cairo

This file was deleted.

25 changes: 0 additions & 25 deletions crates/dojo-core/src/packing_test.cairo

This file was deleted.

Loading

0 comments on commit 47c0cbc

Please sign in to comment.