Skip to content

Commit

Permalink
♻️ Refactore package archi
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Oct 16, 2024
1 parent 6113b1a commit fdfb6e1
Show file tree
Hide file tree
Showing 30 changed files with 90 additions and 77 deletions.
12 changes: 6 additions & 6 deletions packages/Scarb.lock → Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
version = 1

[[package]]
name = "dojo"
version = "1.0.0-alpha.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.14#6bafcb55178888268d86aae9dccef8a1ba6e7542"

[[package]]
name = "quest"
name = "achievement"
version = "0.0.0"
dependencies = [
"dojo",
]

[[package]]
name = "dojo"
version = "1.0.0-alpha.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.14#6bafcb55178888268d86aae9dccef8a1ba6e7542"
17 changes: 17 additions & 0 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[workspace]
members = ["packages/achievement"]
version = "0.0.0"
description = "Dojo quest library"
homepage = "https://github.com/cartridge-gg/quest/"
cairo-version = "2.7.0"

[workspace.package]
version = "0.0.0"

[workspace.dependencies]
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.14" }
starknet = "^2.7.0"
cairo_test = "^2.7.0"

[workspace.tool.fmt]
sort-module-level-items = true
14 changes: 7 additions & 7 deletions contracts/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
version = 1

[[package]]
name = "dojo"
version = "1.0.0-alpha.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.14#6bafcb55178888268d86aae9dccef8a1ba6e7542"

[[package]]
name = "quest"
name = "achievement"
version = "0.0.0"
dependencies = [
"dojo",
]

[[package]]
name = "dojo"
version = "1.0.0-alpha.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.14#6bafcb55178888268d86aae9dccef8a1ba6e7542"

[[package]]
name = "quest_world"
version = "0.0.0"
dependencies = [
"achievement",
"dojo",
"quest",
]
2 changes: 1 addition & 1 deletion contracts/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sierra-replace-ids = true
dev = "sozo clean && sozo build --typescript && sozo migrate plan && sozo migrate apply"

[dependencies]
quest = { path = "../packages" }
achievement = { path = ".." }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.14" }

[[target.dojo]]
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/systems/actions.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ mod Actions {

// Component imports

use quest::components::controllable::ControllableComponent;
use quest::components::registrable::RegistrableComponent;
use achievement::components::controllable::ControllableComponent;
use achievement::components::registrable::RegistrableComponent;

// Local imports

Expand Down
15 changes: 0 additions & 15 deletions packages/Scarb.toml

This file was deleted.

File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions packages/achievement/Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "achievement"
version.workspace = true

[dependencies]
dojo.workspace = true
6 changes: 3 additions & 3 deletions packages/dojo_dev.toml → packages/achievement/dojo_dev.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[world]
name = "quest"
name = "achievement"
description = "Dojo Achievements Library"
website = "https://github.com/dojoengine/dojo-starter"
seed = "quest"
seed = "achievement"

[world.socials]
x = "https://x.com/ohayo_dojo"
Expand All @@ -11,7 +11,7 @@ github = "https://github.com/dojoengine/dojo-starter"
telegram = "https://t.me/dojoengine"

[namespace]
default = "quest"
default = "achievement"

[env]
rpc_url = "http://localhost:5050/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod AchievableComponent {

// Internal imports

use quest::store::{Store, StoreTrait};
use achievement::store::{Store, StoreTrait};

// Errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ mod ControllableComponent {

// Internal imports

use quest::store::{Store, StoreTrait};
use quest::models::game::{Game, GameTrait, GameAssert};
use achievement::store::{Store, StoreTrait};
use achievement::models::game::{Game, GameTrait, GameAssert};

// Storage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ mod RegistrableComponent {

// Internal imports

use quest::store::{Store, StoreTrait};
use quest::models::game::{Game, GameTrait, GameAssert};
use quest::models::achievement::{Achievement, AchievementTrait, AchievementAssert};
use achievement::store::{Store, StoreTrait};
use achievement::models::game::{Game, GameTrait, GameAssert};
use achievement::models::achievement::{Achievement, AchievementTrait, AchievementAssert};

// Storage

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Internal imports

use quest::events::index::AchievementCompletion;
use quest::constants;
use achievement::events::index::AchievementCompletion;
use achievement::constants;

// Errors

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Internal imports

use quest::events::index::AchievementCreation;
use quest::constants;
use achievement::events::index::AchievementCreation;
use achievement::constants;

// Errors

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Intenral imports

use quest::models::index::Achievement;
use quest::constants;
use achievement::models::index::Achievement;
use achievement::constants;

// Errors

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Intenral imports

use quest::models::index::Game;
use quest::constants;
use achievement::models::index::Game;
use achievement::constants;

// Errors

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait};

// Models imports

use quest::models::game::Game;
use quest::models::achievement::Achievement;
use achievement::models::game::Game;
use achievement::models::achievement::Achievement;

// Events imports

use quest::events::creation::{AchievementCreation, AchievementCreationTrait};
use quest::events::completion::{AchievementCompletion, AchievementCompletionTrait};
use achievement::events::creation::{AchievementCreation, AchievementCreationTrait};
use achievement::events::completion::{AchievementCompletion, AchievementCompletionTrait};

// Structs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub mod Achiever {

// Internal imports

use quest::components::achievable::AchievableComponent;
use achievement::components::achievable::AchievableComponent;

// Local imports

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait IController<TContractState> {
pub mod Controller {
// Internal imports

use quest::components::controllable::ControllableComponent;
use achievement::components::controllable::ControllableComponent;

// Local imports

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub mod Registrer {

// Internal imports

use quest::components::registrable::RegistrableComponent;
use achievement::components::registrable::RegistrableComponent;

// Local imports

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ mod setup {

// Internal imports

use quest::models::index;
use quest::tests::mocks::achiever::{Achiever, IAchiever, IAchieverDispatcher};
use quest::tests::mocks::controller::{Controller, IController, IControllerDispatcher};
use quest::tests::mocks::registrer::{Registrer, IRegistrer, IRegistrerDispatcher};
use achievement::models::index;
use achievement::tests::mocks::achiever::{Achiever, IAchiever, IAchieverDispatcher};
use achievement::tests::mocks::controller::{Controller, IController, IControllerDispatcher};
use achievement::tests::mocks::registrer::{Registrer, IRegistrer, IRegistrerDispatcher};

// Constant

Expand Down Expand Up @@ -58,7 +58,7 @@ mod setup {
// [Setup] World
set_contract_address(OWNER());
let models = array![index::game::TEST_CLASS_HASH, index::achievement::TEST_CLASS_HASH,];
let world = spawn_test_world(array!["quest"].span(), models.span());
let world = spawn_test_world(array!["achievement"].span(), models.span());

// [Setup] Systems
let achiever_address = world
Expand All @@ -72,10 +72,10 @@ mod setup {
controller: IControllerDispatcher { contract_address: controller_address },
registrer: IRegistrerDispatcher { contract_address: registrer_address },
};
world.grant_writer(dojo::utils::bytearray_hash(@"quest"), achiever_address);
world.grant_writer(dojo::utils::bytearray_hash(@"quest"), controller_address);
world.grant_writer(dojo::utils::bytearray_hash(@"quest"), registrer_address);
world.grant_writer(dojo::utils::bytearray_hash(@"quest"), OWNER());
world.grant_writer(dojo::utils::bytearray_hash(@"achievement"), achiever_address);
world.grant_writer(dojo::utils::bytearray_hash(@"achievement"), controller_address);
world.grant_writer(dojo::utils::bytearray_hash(@"achievement"), registrer_address);
world.grant_writer(dojo::utils::bytearray_hash(@"achievement"), OWNER());

// [Setup] Context
let context = Context { player_id: PLAYER().into() };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use starknet::testing;

// Internal imports

use quest::events::index::{AchievementCreation, AchievementCompletion};
use quest::tests::mocks::achiever::{Achiever, IAchieverDispatcher, IAchieverDispatcherTrait};
use quest::tests::setup::setup::{spawn_game, clear_events, Systems, PLAYER};
use achievement::events::index::{AchievementCreation, AchievementCompletion};
use achievement::tests::mocks::achiever::{Achiever, IAchieverDispatcher, IAchieverDispatcherTrait};
use achievement::tests::setup::setup::{spawn_game, clear_events, Systems, PLAYER};

// Constants

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use starknet::testing;

// Internal imports

use quest::store::{Store, StoreTrait};
use quest::models::game::{Game, GameTrait};
use quest::models::achievement::{Achievement, AchievementTrait};
use quest::tests::mocks::controller::{
use achievement::store::{Store, StoreTrait};
use achievement::models::game::{Game, GameTrait};
use achievement::models::achievement::{Achievement, AchievementTrait};
use achievement::tests::mocks::controller::{
Controller, IControllerDispatcher, IControllerDispatcherTrait
};
use quest::tests::setup::setup::{spawn_game, Systems, Context, OWNER, PLAYER};
use achievement::tests::setup::setup::{spawn_game, Systems, Context, OWNER, PLAYER};

// Constants

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ use starknet::testing;

// Internal imports

use quest::store::{Store, StoreTrait};
use quest::models::game::{Game, GameTrait};
use quest::models::achievement::{Achievement, AchievementTrait};
use quest::tests::mocks::registrer::{Registrer, IRegistrerDispatcher, IRegistrerDispatcherTrait};
use quest::tests::setup::setup::{spawn_game, Systems, Context, PLAYER};
use achievement::store::{Store, StoreTrait};
use achievement::models::game::{Game, GameTrait};
use achievement::models::achievement::{Achievement, AchievementTrait};
use achievement::tests::mocks::registrer::{
Registrer, IRegistrerDispatcher, IRegistrerDispatcherTrait
};
use achievement::tests::setup::setup::{spawn_game, Systems, Context, PLAYER};

// Constants

Expand Down
3 changes: 3 additions & 0 deletions target/CACHEDIR.TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by sozo.
# For information about cache directory tags see https://bford.info/cachedir/

0 comments on commit fdfb6e1

Please sign in to comment.