Skip to content

Commit

Permalink
♻️ Refactor everything into 3 packages
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Nov 20, 2024
1 parent f53d028 commit e4ac732
Show file tree
Hide file tree
Showing 39 changed files with 829 additions and 425 deletions.
12 changes: 10 additions & 2 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ dependencies = [
]

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

[[package]]
name = "arcade_trophy"
name = "controller"
version = "0.0.0"
dependencies = [
"dojo",
Expand All @@ -45,3 +45,11 @@ dependencies = [
name = "dojo_plugin"
version = "2.8.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.1#d7335e6f5c76a1dda887ec00c594c2c019b4a05f"

[[package]]
name = "provider"
version = "0.0.0"
dependencies = [
"dojo",
"dojo_cairo_test",
]
7 changes: 6 additions & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[workspace]
members = ["packages/trophy", "packages/registry", "packages/slot"]
members = [
"packages/trophy",
"packages/registry",
"packages/provider",
"packages/controller",
]
description = "Dojo achievement library"
homepage = "https://github.com/cartridge-gg/arcade/"
cairo-version = "2.8.4"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "arcade_slot"
name = "controller"
version.workspace = true

[dependencies]
Expand Down
31 changes: 31 additions & 0 deletions packages/controller/src/components/controllable.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#[starknet::component]
mod ControllableComponent {
// Dojo imports

use dojo::world::WorldStorage;

// Internal imports

use controller::store::{Store, StoreTrait};
use controller::models::account::{Account, AccountTrait, AccountAssert};
use controller::models::controller::{Controller, ControllerTrait, ControllerAssert};
use controller::models::member::{Member, MemberTrait, MemberAssert};
use controller::models::signer::{Signer, SignerTrait, SignerAssert};
use controller::models::team::{Team, TeamTrait, TeamAssert};

// Storage

#[storage]
struct Storage {}

// Events

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

#[generate_trait]
impl InternalImpl<
TContractState, +HasComponent<TContractState>
> of InternalTrait<TContractState> {}
}
File renamed without changes.
20 changes: 6 additions & 14 deletions packages/slot/src/lib.cairo → packages/controller/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
mod constants;
mod store;

mod helpers {
mod json;
}

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

mod models {
mod index;
mod account;
mod team;
mod member;
mod controller;
mod member;
mod signer;
mod deployment;
mod service;
mod game;
mod team;
}

mod components {
mod controllable;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Intenral imports

use arcade_slot::models::index::Account;
use controller::models::index::Account;

// Errors

Expand Down Expand Up @@ -35,13 +35,13 @@ impl AccountImpl of AccountTrait {
#[generate_trait]
impl AccountAssert of AssertTrait {
#[inline]
fn assert_does_not_exist(self: Account) {
assert(self.name == 0, errors::ACCOUNT_ALREADY_EXISTS);
fn assert_does_not_exist(self: @Account) {
assert(self.name == @0, errors::ACCOUNT_ALREADY_EXISTS);
}

#[inline]
fn assert_does_exist(self: Account) {
assert(self.name != 0, errors::ACCOUNT_NOT_EXIST);
fn assert_does_exist(self: @Account) {
assert(self.name != @0, errors::ACCOUNT_NOT_EXIST);
}

#[inline]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Intenral imports

use arcade_slot::models::index::Controller;
use controller::models::index::Controller;

// Errors

Expand Down Expand Up @@ -46,13 +46,13 @@ impl ControllerImpl of ControllerTrait {
#[generate_trait]
impl ControllerAssert of AssertTrait {
#[inline]
fn assert_does_not_exist(self: Controller) {
assert(self.account_id == 0, errors::CONTROLLER_ALREADY_EXISTS);
fn assert_does_not_exist(self: @Controller) {
assert(self.account_id == @0, errors::CONTROLLER_ALREADY_EXISTS);
}

#[inline]
fn assert_does_exist(self: Controller) {
assert(self.account_id != 0, errors::CONTROLLER_NOT_EXIST);
fn assert_does_exist(self: @Controller) {
assert(self.account_id != @0, errors::CONTROLLER_NOT_EXIST);
}

#[inline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ pub struct Account {

#[derive(Clone, Drop, Serde)]
#[dojo::model]
pub struct Team {
pub struct Controller {
#[key]
account_id: felt252,
#[key]
id: felt252,
name: felt252,
description: ByteArray,
signers: u32,
address: felt252,
network: felt252,
constructor_calldata: ByteArray,
}

#[derive(Copy, Drop, Serde)]
Expand All @@ -31,65 +35,22 @@ pub struct Member {
role: u8,
}

#[derive(Clone, Drop, Serde)]
#[dojo::model]
pub struct Controller {
#[key]
account_id: felt252,
#[key]
id: felt252,
signers: u32,
address: felt252,
network: felt252,
constructor_calldata: ByteArray,
}

#[derive(Clone, Drop, Serde)]
#[dojo::model]
pub struct Signer {
#[key]
account_id: felt252,
#[key]
controller_id: felt252,
#[key]
id: felt252,
method: u8,
metadata: ByteArray,
}

#[derive(Clone, Drop, Serde)]
#[dojo::model]
pub struct Deployment {
#[key]
id: felt252,
#[key]
project: felt252,
status: u8,
branch: Option<felt252>,
service: u8,
tier: u8,
regions: felt252,
auto_upgrade: bool,
config: ByteArray,
}

#[derive(Copy, Drop, Serde)]
#[dojo::model]
pub struct Service {
#[key]
id: felt252,
version: felt252,
default_version: felt252,
}

#[derive(Clone, Drop, Serde)]
#[dojo::model]
pub struct Game {
pub struct Team {
#[key]
id: felt252,
name: felt252,
priority: u8,
socials: ByteArray,
metadata: ByteArray,
active: bool,
description: ByteArray,
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Intenral imports

use arcade_slot::models::index::Member;
use arcade_slot::types::role::Role;
use controller::models::index::Member;
use controller::types::role::Role;

// Errors

pub mod errors {
Expand All @@ -28,13 +29,13 @@ impl MemberImpl of MemberTrait {
#[generate_trait]
impl MemberAssert of AssertTrait {
#[inline]
fn assert_does_not_exist(self: Member) {
assert(self.role == Role::None.into(), errors::MEMBER_ALREADY_EXISTS);
fn assert_does_not_exist(self: @Member) {
assert(self.role == @Role::None.into(), errors::MEMBER_ALREADY_EXISTS);
}

#[inline]
fn assert_does_exist(self: Member) {
assert(self.role != Role::None.into(), errors::MEMBER_NOT_EXIST);
fn assert_does_exist(self: @Member) {
assert(self.role != @Role::None.into(), errors::MEMBER_NOT_EXIST);
}

#[inline]
Expand Down
Loading

0 comments on commit e4ac732

Please sign in to comment.