-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
cairo-version = "2.1.1" | ||
name = "types_test" | ||
version = "0.1.0" | ||
|
||
[cairo] | ||
sierra-replace-ids = true | ||
|
||
[dependencies] | ||
dojo = { path = "../../../../../dojo-core" } | ||
|
||
[[target.dojo]] | ||
|
||
[tool.dojo] | ||
initializer_class_hash = "0xbeef" | ||
|
||
[tool.dojo.env] | ||
rpc_url = "http://localhost:5050/" | ||
# Default account for katana with seed = 0 | ||
account_address = "0x3ee9e18edc71a6df30ac3aca2e0b02a198fbce19b7480a63a0d71cbd76652e0" | ||
private_key = "0x300001800000000300000180000000000030000000000003006001800006600" | ||
# world_address = "0x789c94ef39aeebc7f8c4c4633030faefb8bee454e358ae53d06ced36136d7d6" | ||
# keystore_password = "password" | ||
# keystore_path = "../keystore.json" |
18 changes: 18 additions & 0 deletions
18
crates/torii/graphql/src/tests/types-test/src/components.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use array::ArrayTrait; | ||
use starknet::{ContractAddress, ClassHash}; | ||
|
||
#[derive(Component, Copy, Drop, Serde, SerdeLen)] | ||
struct Record { | ||
#[key] | ||
record_id: u32, | ||
type_u8: u8, | ||
type_u16: u16, | ||
type_u32: u32, | ||
type_u64: u64, | ||
type_u128: u128, | ||
type_u256: u256, | ||
type_bool: bool, | ||
type_felt: felt252, | ||
type_class_hash: ClassHash, | ||
type_contract_address: ContractAddress, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod components; | ||
mod systems; |
43 changes: 43 additions & 0 deletions
43
crates/torii/graphql/src/tests/types-test/src/systems.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#[system] | ||
mod spawn { | ||
use array::ArrayTrait; | ||
use box::BoxTrait; | ||
use option::OptionTrait; | ||
use traits::{Into, TryInto}; | ||
use starknet::class_hash::{Felt252TryIntoClassHash}; | ||
|
||
use dojo::world::Context; | ||
use types_test::components::Record; | ||
|
||
fn execute(ctx: Context, num_records: u8) { | ||
let mut curr_record = 0; | ||
loop { | ||
if curr_record == num_records { | ||
break(); | ||
} | ||
curr_record = curr_record + 1; | ||
|
||
let record_id = ctx.world.uuid(); | ||
let curr_felt: felt252 = curr_record.into(); | ||
set !( | ||
ctx.world, | ||
( | ||
Record { | ||
record_id, | ||
type_u8: curr_record.into(), | ||
type_u16: curr_record.into(), | ||
type_u32: curr_record.into(), | ||
type_u64: curr_record.into(), | ||
type_u128: curr_record.into(), | ||
type_u256: curr_record.into(), | ||
type_bool: if curr_record % 2 == 0 { true } else { false }, | ||
type_felt: curr_felt, | ||
type_class_hash: curr_felt.try_into().unwrap(), | ||
type_contract_address: curr_felt.try_into().unwrap(), | ||
} | ||
) | ||
); | ||
}; | ||
return (); | ||
} | ||
} |