Skip to content

Commit

Permalink
⬆️ Upgrade to dojo v1
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Nov 11, 2024
1 parent 47eb7c1 commit 24ddc1d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

env:
DOJO_VERSION: v1.0.0-rc.1
DOJO_VERSION: v1.0.0
SCARB_VERSION: 2.8.4
WORKING_DIRECTORY: ./contracts

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

env:
DOJO_VERSION: v1.0.0-rc.1
DOJO_VERSION: v1.0.0
SCARB_VERSION: 2.8.4
WORKING_DIRECTORY: ./packages

Expand Down
8 changes: 4 additions & 4 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ dependencies = [

[[package]]
name = "dojo"
version = "1.0.0-rc.0"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.1#c789997f1a7cf5628d6b3fc01ce2851fca7a35bf"
version = "1.0.0"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0#74280d48fa2828095331487dede59f9b2e378cd3"
dependencies = [
"dojo_plugin",
]

[[package]]
name = "dojo_cairo_test"
version = "1.0.0-rc.0"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.1#c789997f1a7cf5628d6b3fc01ce2851fca7a35bf"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0#74280d48fa2828095331487dede59f9b2e378cd3"
dependencies = [
"dojo",
]

[[package]]
name = "dojo_plugin"
version = "2.8.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.1#c789997f1a7cf5628d6b3fc01ce2851fca7a35bf"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0#74280d48fa2828095331487dede59f9b2e378cd3"
4 changes: 2 additions & 2 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ cairo-version = "2.8.4"
version = "0.0.0"

[workspace.dependencies]
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-rc.1" }
dojo_cairo_test = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-rc.1" }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0" }
dojo_cairo_test = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0" }
starknet = "2.8.4"
cairo_test = "2.8.4"

Expand Down
4 changes: 2 additions & 2 deletions contracts/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ sierra-replace-ids = true
dev = "sozo clean && sozo build --typescript && sozo migrate plan && sozo migrate apply"

[dependencies]
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-rc.1" }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0" }
bushido_registry = { path = ".." }
starknet = "2.8.4"
cairo_test = "2.8.4"

[dev-dependencies]
dojo_cairo_test = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-rc.1" }
dojo_cairo_test = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0" }

[[target.starknet-contract]]
build-external-contracts = [
Expand Down
29 changes: 18 additions & 11 deletions packages/registry/src/tests/setup.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ mod setup {
// Dojo imports

use dojo::world::{WorldStorage, WorldStorageTrait};
use dojo_cairo_test::{spawn_test_world, NamespaceDef, TestResource, ContractDefTrait};
use dojo_cairo_test::{
spawn_test_world, NamespaceDef, ContractDef, TestResource, ContractDefTrait,
WorldStorageTestTrait
};

// Internal imports

Expand Down Expand Up @@ -57,26 +60,30 @@ mod setup {
fn setup_namespace() -> NamespaceDef {
NamespaceDef {
namespace: "namespace", resources: [
TestResource::Model(models::m_Game::TEST_CLASS_HASH.try_into().unwrap()),
TestResource::Model(models::m_Achievement::TEST_CLASS_HASH.try_into().unwrap()),
TestResource::Contract(
ContractDefTrait::new(Controller::TEST_CLASS_HASH, "Controller")
.with_writer_of([dojo::utils::bytearray_hash(@"namespace")].span())
),
TestResource::Contract(
ContractDefTrait::new(Registrer::TEST_CLASS_HASH, "Registrer")
.with_writer_of([dojo::utils::bytearray_hash(@"namespace")].span())
),
TestResource::Model(models::m_Game::TEST_CLASS_HASH),
TestResource::Model(models::m_Achievement::TEST_CLASS_HASH),
TestResource::Contract(Controller::TEST_CLASS_HASH),
TestResource::Contract(Registrer::TEST_CLASS_HASH),
].span()
}
}

fn setup_contracts() -> Span<ContractDef> {
[
ContractDefTrait::new(@"namespace", @"Controller")
.with_writer_of([dojo::utils::bytearray_hash(@"namespace")].span()),
ContractDefTrait::new(@"namespace", @"Registrer")
.with_writer_of([dojo::utils::bytearray_hash(@"namespace")].span()),
].span()
}

#[inline]
fn spawn_game() -> (WorldStorage, Systems, Context) {
// [Setup] World
set_contract_address(OWNER());
let namespace_def = setup_namespace();
let world = spawn_test_world([namespace_def].span());
world.sync_perms_and_inits(setup_contracts());
// [Setup] Systems
let (controller_address, _) = world.dns(@"Controller").unwrap();
let (registrer_address, _) = world.dns(@"Registrer").unwrap();
Expand Down
24 changes: 15 additions & 9 deletions packages/trophy/src/tests/setup.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ mod setup {
// Dojo imports

use dojo::world::{WorldStorage, WorldStorageTrait};
use dojo_cairo_test::{spawn_test_world, NamespaceDef, TestResource, ContractDefTrait};
use dojo_cairo_test::{
spawn_test_world, NamespaceDef, ContractDef, TestResource, ContractDefTrait,
WorldStorageTestTrait
};

// Internal imports

Expand Down Expand Up @@ -53,24 +56,27 @@ mod setup {
fn setup_namespace() -> NamespaceDef {
NamespaceDef {
namespace: "namespace", resources: [
TestResource::Event(events::e_TrophyCreation::TEST_CLASS_HASH.try_into().unwrap()),
TestResource::Event(
events::e_TrophyProgression::TEST_CLASS_HASH.try_into().unwrap()
),
TestResource::Contract(
ContractDefTrait::new(Achiever::TEST_CLASS_HASH, "Achiever")
.with_writer_of([dojo::utils::bytearray_hash(@"namespace")].span())
),
TestResource::Event(events::e_TrophyCreation::TEST_CLASS_HASH),
TestResource::Event(events::e_TrophyProgression::TEST_CLASS_HASH),
TestResource::Contract(Achiever::TEST_CLASS_HASH),
].span()
}
}

fn setup_contracts() -> Span<ContractDef> {
[
ContractDefTrait::new(@"namespace", @"Achiever")
.with_writer_of([dojo::utils::bytearray_hash(@"namespace")].span()),
].span()
}

#[inline]
fn spawn_game() -> (WorldStorage, Systems, Context) {
// [Setup] World
set_contract_address(OWNER());
let namespace_def = setup_namespace();
let world = spawn_test_world([namespace_def].span());
world.sync_perms_and_inits(setup_contracts());
// [Setup] Systems
let (achiever_address, _) = world.dns(@"Achiever").unwrap();
let systems = Systems {
Expand Down

0 comments on commit 24ddc1d

Please sign in to comment.