From dfef0d597d20b153c08dc571a9bacfb524e875d9 Mon Sep 17 00:00:00 2001 From: Shramee Srivastav Date: Tue, 9 May 2023 06:58:20 +0800 Subject: [PATCH] Dev review updates (#118) --- exercises/modules/modules1.cairo | 2 +- exercises/modules/modules2.cairo | 4 ++-- exercises/modules/readme.md | 2 +- exercises/starknet/README.md | 3 ++- info.toml | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/exercises/modules/modules1.cairo b/exercises/modules/modules1.cairo index 2bd3eb2397..59ed254628 100644 --- a/exercises/modules/modules1.cairo +++ b/exercises/modules/modules1.cairo @@ -18,7 +18,7 @@ fn test_mod_fn() { assert(order_result == 'order_taken', 'Order not taken'); } - +#[cfg(test)] mod tests { #[test] fn test_super_fn() { diff --git a/exercises/modules/modules2.cairo b/exercises/modules/modules2.cairo index 9be52236b1..36df3a504a 100644 --- a/exercises/modules/modules2.cairo +++ b/exercises/modules/modules2.cairo @@ -3,13 +3,13 @@ // Run `starklings hint modules2` or `hint` watch command for a hint. use debug::PrintTrait; -const YEAR: felt252 = 2050; +const YEAR: u16 = 2050; mod order { #[derive(Copy, Drop)] struct Order { name: felt252, - year: felt252, + year: u16, made_by_phone: bool, made_by_email: bool, item: felt252, diff --git a/exercises/modules/readme.md b/exercises/modules/readme.md index 7feaff183c..3046032935 100644 --- a/exercises/modules/readme.md +++ b/exercises/modules/readme.md @@ -6,7 +6,7 @@ Here's some code to show modules at play, ## Declaring modules -Modules can be declared in two way, +Modules can be declared in two ways, | Code | Description | | --------------- | ---------------------------- | diff --git a/exercises/starknet/README.md b/exercises/starknet/README.md index e6d2a7704b..5e6a77ad70 100644 --- a/exercises/starknet/README.md +++ b/exercises/starknet/README.md @@ -1,6 +1,6 @@ # Starknet Smart Contracts -A Starknet contract is pretty much a Cairo module, or rather, it's represented by one. +A Starknet contract can be created by annotating a Cairo module with the `#[contract]` attribute Starknet contract don't require a `main` function. Functions in the contract module may be annotated as a `#[view]` or an `#[external]` function. External/View functions can be called by the users of Starknet, and by other contracts. The functions without these annotations are internal and cannot be accessed by users nor by other contract. @@ -85,3 +85,4 @@ fn play() { ## Further information - For more details, check out [The Structure of a Cairo Smart Contract](https://book.starknet.io/chapter_2/structure.html) in [the Starknet book](https://book.starknet.io). +- [Cross-contract interactions](https://cairo-book.github.io/ch09-00-00-abis-and-cross-contract-interactions.html) diff --git a/info.toml b/info.toml index 211b2e4f8d..f2030af9c6 100644 --- a/info.toml +++ b/info.toml @@ -516,7 +516,7 @@ name = "modules2" path = "exercises/modules/modules2.cairo" mode = "test" hint = """ -While using functions/structs etc from outside the module, +While using functions/structs and other items from outside the module, you can use full paths or `use` keyword to create shortcuts. """