Skip to content

Commit

Permalink
♻️ Finish refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Nov 21, 2024
1 parent e4ac732 commit 54011f5
Show file tree
Hide file tree
Showing 31 changed files with 1,315 additions and 1,127 deletions.
16 changes: 8 additions & 8 deletions Scarb.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "arcade_registry"
version = "0.0.0"
dependencies = [
"dojo",
"dojo_cairo_test",
]

[[package]]
name = "arcade_trophy"
version = "0.0.0"
Expand Down Expand Up @@ -53,3 +45,11 @@ dependencies = [
"dojo",
"dojo_cairo_test",
]

[[package]]
name = "registry"
version = "0.0.0"
dependencies = [
"dojo",
"dojo_cairo_test",
]
4 changes: 2 additions & 2 deletions contracts/src/systems/actions.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ mod Actions {

// Component imports

use arcade_registry::components::controllable::ControllableComponent;
use arcade_registry::components::registrable::RegistrableComponent;
use registry::components::controllable::ControllableComponent;
use registry::components::registrable::RegistrableComponent;

// Local imports

Expand Down
3 changes: 0 additions & 3 deletions packages/provider/src/components/deployable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ mod DeployableComponent {
use provider::models::deployment::{Deployment, DeploymentTrait, DeploymentAssert};
use provider::models::factory::{Factory, FactoryTrait, FactoryAssert};
use provider::types::service::{Service, ServiceTrait, SERVICE_COUNT};
use provider::types::metadata::{Metadata, MetadataTrait};
use provider::types::socials::{Socials, SocialsTrait};
use provider::types::status::Status;
use provider::types::tier::Tier;
use provider::helpers::json::JsonifiableTrait;

// Storage

Expand Down
6 changes: 0 additions & 6 deletions packages/provider/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
mod constants;
mod store;

mod helpers {
mod json;
}

mod elements {
mod services {
mod interface;
Expand All @@ -16,10 +12,8 @@ mod elements {

mod types {
mod tier;
mod socials;
mod service;
mod status;
mod metadata;
}

mod models {
Expand Down
8 changes: 4 additions & 4 deletions packages/provider/src/models/deployment.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod errors {
pub const DEPLOYMENT_INVALID_OWNER: felt252 = 'Deployment: invalid owner';
pub const DEPLOYMENT_INVALID_STATUS: felt252 = 'Deployment: invalid status';
pub const DEPLOYMENT_INVALID_TIER: felt252 = 'Deployment: invalid tier';
pub const DEPLOYMENT_NOT_OWNER: felt252 = 'Deployment: not owner';
pub const DEPLOYMENT_NOT_OWNER: felt252 = 'Deployment: caller is not owner';
}

#[generate_trait]
Expand Down Expand Up @@ -84,8 +84,8 @@ impl DeploymentAssert of AssertTrait {
}

#[inline]
fn assert_is_owner(self: @Deployment, owner: felt252) {
assert(@owner == self.owner, errors::DEPLOYMENT_NOT_OWNER);
fn assert_is_owner(self: @Deployment, caller: felt252) {
assert(@caller == self.owner, errors::DEPLOYMENT_NOT_OWNER);
}
}

Expand Down Expand Up @@ -133,7 +133,7 @@ mod tests {
}

#[test]
#[should_panic(expected: 'Deployment: not owner')]
#[should_panic(expected: 'Deployment: caller is not owner')]
fn test_deployment_revert_not_owner() {
let deployment = DeploymentTrait::new(SERVICE, PROJECT, OWNER, TIER, "");
deployment.assert_is_owner(NOT_OWNER);
Expand Down
158 changes: 0 additions & 158 deletions packages/provider/src/models/game.cairo

This file was deleted.

15 changes: 0 additions & 15 deletions packages/provider/src/models/index.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,3 @@ pub struct Factory {
version: felt252,
default_version: felt252,
}

#[derive(Clone, Drop, Serde)]
#[dojo::model]
pub struct Game {
#[key]
project: felt252,
owner: felt252,
world: felt252,
namespace: felt252,
name: felt252,
priority: u8,
socials: ByteArray,
metadata: ByteArray,
active: bool,
}
2 changes: 1 addition & 1 deletion packages/registry/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "arcade_registry"
name = "registry"
version.workspace = true

[dependencies]
Expand Down
52 changes: 0 additions & 52 deletions packages/registry/src/components/controllable.cairo

This file was deleted.

35 changes: 35 additions & 0 deletions packages/registry/src/components/initializable.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#[starknet::component]
mod InitializableComponent {
// Dojo imports

use dojo::world::WorldStorage;

// Internal imports

use registry::store::{Store, StoreTrait};
use registry::models::access::AccessTrait;
use registry::types::role::Role;

// Storage

#[storage]
struct Storage {}

// Events

#[event]
#[derive(Drop, starknet::Event)]
enum Event {}

#[generate_trait]
impl InternalImpl<
TContractState, +HasComponent<TContractState>
> of InternalTrait<TContractState> {
fn initialize(self: @ComponentState<TContractState>, world: WorldStorage, owner: felt252) {
// [Effect] Initialize component
let mut store = StoreTrait::new(world);
let access = AccessTrait::new(owner, Role::Owner);
store.set_access(@access);
}
}
}
Loading

0 comments on commit 54011f5

Please sign in to comment.