-
Notifications
You must be signed in to change notification settings - Fork 184
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
56 changed files
with
9,998 additions
and
296 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
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,6 @@ | ||
/// Compute the poseidon hash of a serialized ByteArray | ||
fn hash(data: @ByteArray) -> felt252 { | ||
let mut serialized = ArrayTrait::new(); | ||
Serde::serialize(data, ref serialized); | ||
poseidon::poseidon_hash_span(serialized.span()) | ||
} |
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,17 @@ | ||
#[derive(Drop, Copy, Serde)] | ||
#[dojo::model(namespace: "my namespace")] | ||
struct MyModel { | ||
#[key] | ||
x: u8, | ||
y: u8 | ||
} | ||
|
||
#[test] | ||
fn test_hash_computation() { | ||
// Be sure that the namespace hash computed in `dojo-lang` in Rust is equal | ||
// to the one computed in Cairo by dojo::utils:hash | ||
let namespace = dojo::model::Model::<MyModel>::namespace(); | ||
let namespace_selector = dojo::model::Model::<MyModel>::namespace_selector(); | ||
|
||
assert(dojo::utils::hash(@namespace) == namespace_selector, 'invalid computed hash'); | ||
} |
Oops, something went wrong.