diff --git a/.tool-versions b/.tool-versions index 50187399..ceff2dc7 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -scarb 2.9.4 -starknet-foundry 0.37.0 +scarb 2.10.1 +starknet-foundry 0.38.0 diff --git a/Scarb.lock b/Scarb.lock index 26cde18f..c337f67b 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -10,6 +10,10 @@ dependencies = [ "snforge_std", ] +[[package]] +name = "cairo_cheatsheet" +version = "0.1.0" + [[package]] name = "calling_other_contracts" version = "0.1.0" @@ -242,15 +246,15 @@ dependencies = [ [[package]] name = "snforge_scarb_plugin" -version = "0.37.0" +version = "0.38.0" source = "registry+https://scarbs.xyz/" -checksum = "sha256:9dbb114f853decc27b2d6d53e2ddd207217ce63c2d24a47c5c48d5f475b0b9a5" +checksum = "sha256:c4d128eedb5fca4362be38a84e5f5a85bd94ec1557bab7c045d48de0163e406c" [[package]] name = "snforge_std" -version = "0.37.0" +version = "0.38.0" source = "registry+https://scarbs.xyz/" -checksum = "sha256:f5702c4a6d54e3563b4aa78c834de6ddcf18ef8ca8fd35dc1bceb7ece58e9571" +checksum = "sha256:8b3eaff778105c313b78708974c253cd927ecf5c896f4557a0ea4f10f427b554" dependencies = [ "snforge_scarb_plugin", ] diff --git a/Scarb.toml b/Scarb.toml index 99652d60..7569dcb3 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -12,10 +12,10 @@ test = "$(git rev-parse --show-toplevel)/scripts/test_resolver.sh" [workspace.tool.snforge] [workspace.dependencies] -starknet = "2.9.4" -cairo_test = "2.9.4" -assert_macros = "2.9.4" -snforge_std = "0.37.0" +starknet = "2.10.1" +cairo_test = "2.10.1" +assert_macros = "2.10.1" +snforge_std = "0.38.0" openzeppelin_account = "1.0.0" openzeppelin_introspection = "1.0.0" openzeppelin_presets = "1.0.0" diff --git a/listings/cairo_cheatsheet/listing/Scarb.lock b/listings/cairo_cheatsheet/Scarb.lock similarity index 100% rename from listings/cairo_cheatsheet/listing/Scarb.lock rename to listings/cairo_cheatsheet/Scarb.lock diff --git a/listings/cairo_cheatsheet/listing/Scarb.toml b/listings/cairo_cheatsheet/Scarb.toml similarity index 100% rename from listings/cairo_cheatsheet/listing/Scarb.toml rename to listings/cairo_cheatsheet/Scarb.toml diff --git a/listings/cairo_cheatsheet/listing/.gitignore b/listings/cairo_cheatsheet/listing/.gitignore deleted file mode 100644 index eb5a316c..00000000 --- a/listings/cairo_cheatsheet/listing/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target diff --git a/listings/cairo_cheatsheet/listing/src/array_example.cairo b/listings/cairo_cheatsheet/src/array_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/array_example.cairo rename to listings/cairo_cheatsheet/src/array_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/dict_example.cairo b/listings/cairo_cheatsheet/src/dict_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/dict_example.cairo rename to listings/cairo_cheatsheet/src/dict_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/enum_example.cairo b/listings/cairo_cheatsheet/src/enum_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/enum_example.cairo rename to listings/cairo_cheatsheet/src/enum_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/felt_example.cairo b/listings/cairo_cheatsheet/src/felt_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/felt_example.cairo rename to listings/cairo_cheatsheet/src/felt_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/if_let_example.cairo b/listings/cairo_cheatsheet/src/if_let_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/if_let_example.cairo rename to listings/cairo_cheatsheet/src/if_let_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/lib.cairo b/listings/cairo_cheatsheet/src/lib.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/lib.cairo rename to listings/cairo_cheatsheet/src/lib.cairo diff --git a/listings/cairo_cheatsheet/listing/src/loop_example.cairo b/listings/cairo_cheatsheet/src/loop_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/loop_example.cairo rename to listings/cairo_cheatsheet/src/loop_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/mapping_example.cairo b/listings/cairo_cheatsheet/src/mapping_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/mapping_example.cairo rename to listings/cairo_cheatsheet/src/mapping_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/match_example.cairo b/listings/cairo_cheatsheet/src/match_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/match_example.cairo rename to listings/cairo_cheatsheet/src/match_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/struct_example.cairo b/listings/cairo_cheatsheet/src/struct_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/struct_example.cairo rename to listings/cairo_cheatsheet/src/struct_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/tuple_example.cairo b/listings/cairo_cheatsheet/src/tuple_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/tuple_example.cairo rename to listings/cairo_cheatsheet/src/tuple_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/type_casting_example.cairo b/listings/cairo_cheatsheet/src/type_casting_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/type_casting_example.cairo rename to listings/cairo_cheatsheet/src/type_casting_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/while_example.cairo b/listings/cairo_cheatsheet/src/while_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/while_example.cairo rename to listings/cairo_cheatsheet/src/while_example.cairo diff --git a/listings/cairo_cheatsheet/listing/src/while_let_example.cairo b/listings/cairo_cheatsheet/src/while_let_example.cairo similarity index 100% rename from listings/cairo_cheatsheet/listing/src/while_let_example.cairo rename to listings/cairo_cheatsheet/src/while_let_example.cairo diff --git a/listings/getting-started/testing_how_to/src/lib.cairo b/listings/getting-started/testing_how_to/src/lib.cairo index 1eccea76..e7bdb055 100644 --- a/listings/getting-started/testing_how_to/src/lib.cairo +++ b/listings/getting-started/testing_how_to/src/lib.cairo @@ -2,3 +2,6 @@ mod contract; pub use contract::{ InventoryContract, IInventoryContractDispatcher, IInventoryContractDispatcherTrait, }; + +#[cfg(test)] +mod test_contract; diff --git a/listings/getting-started/testing_how_to/tests/test_contract.cairo b/listings/getting-started/testing_how_to/src/test_contract.cairo similarity index 100% rename from listings/getting-started/testing_how_to/tests/test_contract.cairo rename to listings/getting-started/testing_how_to/src/test_contract.cairo diff --git a/pages/cairo_cheatsheet/arrays.md b/pages/cairo_cheatsheet/arrays.md index 4a54ab89..23b3d794 100644 --- a/pages/cairo_cheatsheet/arrays.md +++ b/pages/cairo_cheatsheet/arrays.md @@ -20,5 +20,5 @@ trait ArrayTrait { For example: ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/array_example.cairo] +// [!include ~/listings/cairo_cheatsheet/src/array_example.cairo] ``` diff --git a/pages/cairo_cheatsheet/dict.md b/pages/cairo_cheatsheet/dict.md index fc5bd0b2..d7bd1248 100644 --- a/pages/cairo_cheatsheet/dict.md +++ b/pages/cairo_cheatsheet/dict.md @@ -8,5 +8,5 @@ A dictionary is a data structure used to store key-value pairs, enabling efficie For example: ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/dict_example.cairo:sheet] +// [!include ~/listings/cairo_cheatsheet/src/dict_example.cairo:sheet] ``` diff --git a/pages/cairo_cheatsheet/enums.md b/pages/cairo_cheatsheet/enums.md index 81d192dc..23b85766 100644 --- a/pages/cairo_cheatsheet/enums.md +++ b/pages/cairo_cheatsheet/enums.md @@ -5,7 +5,7 @@ Just like other programming languages, enums (enumerations) are used in cairo to In cairo, `enum variants` can hold different data types (the unit type, structs, other enums, tuples, default core library types, arrays, dictionaries, ...), as shown in the code snippet below. Furthermore, as a quick reminder, enums are expressions, meaning they can return values. ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/enum_example.cairo:enums] +// [!include ~/listings/cairo_cheatsheet/src/enum_example.cairo:enums] ``` Enums can be declared both inside and outside a contract. If declared outside, they need to be imported inside using the `use` keyword, just like other imports. @@ -24,5 +24,5 @@ Enums can be declared both inside and outside a contract. If declared outside, t Here is an example of a contract illustrating the above statements : ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/enum_example.cairo:enum_contract] +// [!include ~/listings/cairo_cheatsheet/src/enum_example.cairo:enum_contract] ``` diff --git a/pages/cairo_cheatsheet/felt.md b/pages/cairo_cheatsheet/felt.md index e4ce25d1..27d4e93d 100644 --- a/pages/cairo_cheatsheet/felt.md +++ b/pages/cairo_cheatsheet/felt.md @@ -6,5 +6,5 @@ For example: ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/felt_example.cairo:sheet] +// [!include ~/listings/cairo_cheatsheet/src/felt_example.cairo:sheet] ``` diff --git a/pages/cairo_cheatsheet/if_let.md b/pages/cairo_cheatsheet/if_let.md index 7496a5a6..d4904664 100644 --- a/pages/cairo_cheatsheet/if_let.md +++ b/pages/cairo_cheatsheet/if_let.md @@ -3,7 +3,7 @@ A `if let` statement is a combination of an `if` statement and a `let` statement. It allows you to execute the block only if the pattern matches. It's a cleaner way to handle a `match` statement with only one pattern that you want to handle. ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/if_let_example.cairo:sheet] +// [!include ~/listings/cairo_cheatsheet/src/if_let_example.cairo:sheet] ``` ### See also diff --git a/pages/cairo_cheatsheet/loop.md b/pages/cairo_cheatsheet/loop.md index 70fbd1a3..a15fe539 100644 --- a/pages/cairo_cheatsheet/loop.md +++ b/pages/cairo_cheatsheet/loop.md @@ -5,7 +5,7 @@ A `loop` specifies a block of code that will run repetitively until a halting co For example: ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/loop_example.cairo:sheet] +// [!include ~/listings/cairo_cheatsheet/src/loop_example.cairo:sheet] ``` ### See also diff --git a/pages/cairo_cheatsheet/mapping.md b/pages/cairo_cheatsheet/mapping.md index 9c61e48d..e32a4d05 100644 --- a/pages/cairo_cheatsheet/mapping.md +++ b/pages/cairo_cheatsheet/mapping.md @@ -3,5 +3,5 @@ The `Map` type can be used to represent a collection of key-value. ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/mapping_example.cairo] +// [!include ~/listings/cairo_cheatsheet/src/mapping_example.cairo] ``` diff --git a/pages/cairo_cheatsheet/match.md b/pages/cairo_cheatsheet/match.md index 0f2b7d29..1a5048cf 100644 --- a/pages/cairo_cheatsheet/match.md +++ b/pages/cairo_cheatsheet/match.md @@ -5,5 +5,5 @@ The `match` expression in Cairo allows us to control the flow of our code by com For example: ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/match_example.cairo] +// [!include ~/listings/cairo_cheatsheet/src/match_example.cairo] ``` diff --git a/pages/cairo_cheatsheet/struct.md b/pages/cairo_cheatsheet/struct.md index 16fd879b..f4938402 100644 --- a/pages/cairo_cheatsheet/struct.md +++ b/pages/cairo_cheatsheet/struct.md @@ -5,5 +5,5 @@ A struct is a data type similar to a tuple. Like tuples, they can be used to hol For example: ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/struct_example.cairo] +// [!include ~/listings/cairo_cheatsheet/src/struct_example.cairo] ``` diff --git a/pages/cairo_cheatsheet/tuples.md b/pages/cairo_cheatsheet/tuples.md index 77251500..d438f646 100644 --- a/pages/cairo_cheatsheet/tuples.md +++ b/pages/cairo_cheatsheet/tuples.md @@ -5,5 +5,5 @@ Tuples is a data type to group a fixed number of items of potentially different For example: ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/tuple_example.cairo:sheet] +// [!include ~/listings/cairo_cheatsheet/src/tuple_example.cairo:sheet] ``` diff --git a/pages/cairo_cheatsheet/type_casting.md b/pages/cairo_cheatsheet/type_casting.md index cd24d670..ad49878c 100644 --- a/pages/cairo_cheatsheet/type_casting.md +++ b/pages/cairo_cheatsheet/type_casting.md @@ -6,5 +6,5 @@ The `into` method is used for conversion from a smaller data type to a larger da For example: ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/type_casting_example.cairo:sheet] +// [!include ~/listings/cairo_cheatsheet/src/type_casting_example.cairo:sheet] ``` diff --git a/pages/cairo_cheatsheet/while.md b/pages/cairo_cheatsheet/while.md index 8708df02..9c923fc0 100644 --- a/pages/cairo_cheatsheet/while.md +++ b/pages/cairo_cheatsheet/while.md @@ -3,7 +3,7 @@ A `while` loop allows you to specify a condition that must be true for the loop to continue. ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/while_example.cairo:sheet] +// [!include ~/listings/cairo_cheatsheet/src/while_example.cairo:sheet] ``` ### See also diff --git a/pages/cairo_cheatsheet/while_let.md b/pages/cairo_cheatsheet/while_let.md index 8b77510a..f6013a94 100644 --- a/pages/cairo_cheatsheet/while_let.md +++ b/pages/cairo_cheatsheet/while_let.md @@ -3,7 +3,7 @@ A `while let` loop is a combination of a `while` loop and a `let` statement. It allows you to execute the loop body only if the pattern matches. ```cairo -// [!include ~/listings/cairo_cheatsheet/listing/src/while_let_example.cairo:sheet] +// [!include ~/listings/cairo_cheatsheet/src/while_let_example.cairo:sheet] ``` ### See also diff --git a/pages/getting-started/syscalls.md b/pages/getting-started/syscalls.md index 07a1edb8..03006778 100644 --- a/pages/getting-started/syscalls.md +++ b/pages/getting-started/syscalls.md @@ -248,4 +248,4 @@ The system call does not add any padding and the input needs to be a multiple of ## Additional Resources - [Official Syscalls Documentation](https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/system-calls-cairo1/) -- [Source Code](https://github.com/starkware-libs/cairo/blob/v2.9.4/corelib/src/starknet/syscalls.cairo) +- [Source Code](https://github.com/starkware-libs/cairo/blob/v2.10.1/corelib/src/starknet/syscalls.cairo) diff --git a/pages/getting-started/testing/testing.mdx b/pages/getting-started/testing/index.mdx similarity index 72% rename from pages/getting-started/testing/testing.mdx rename to pages/getting-started/testing/index.mdx index 34104054..0b2ce18d 100644 --- a/pages/getting-started/testing/testing.mdx +++ b/pages/getting-started/testing/index.mdx @@ -7,8 +7,8 @@ There's two main *test runners* for Cairo:
| Test Runner | Scope | Best For | |----------------------------------------------------|---------------------|-------------------------------| -| **[Snforge](./testing/testing-snforge.md)** | Starknet contracts | Full smart contract testing with blockchain state | -| **[Cairo Test](./testing/testing-cairo-test.md)** | Pure Cairo packages | Non-blockchain-state logic validation / testing | +| **[Snforge](/getting-started/testing/testing-snforge)** | Starknet contracts | Full smart contract testing with blockchain state | +| **[Cairo Test](/getting-started/testing/testing-cairo-test)** | Pure Cairo packages | Non-blockchain-state logic validation / testing |
:::warning[Recommendation] diff --git a/pages/getting-started/testing/testing-cairo-test.md b/pages/getting-started/testing/testing-cairo-test.md index fa2a6ffb..2bd3be8d 100644 --- a/pages/getting-started/testing/testing-cairo-test.md +++ b/pages/getting-started/testing/testing-cairo-test.md @@ -9,7 +9,7 @@ Cairo-test is the included testing framework from Cairo, and can be run with `sc You need to add it as a dev dependency with the following line in your `Scarb.toml`: ```toml [dev-dependencies] -cairo_test = "2.9.4" // Version should be same as your Starknet/Scarb version +cairo_test = "2.10.1" // Version should be same as your Starknet/Scarb version ``` Testing is done similarly as shown in the [Testing with Snforge](/getting-started/testing/testing-snforge) section, but all the snforge specific features are not available. diff --git a/pages/getting-started/testing/testing-snforge.md b/pages/getting-started/testing/testing-snforge.md index 08f5458a..38c95db8 100644 --- a/pages/getting-started/testing/testing-snforge.md +++ b/pages/getting-started/testing/testing-snforge.md @@ -39,7 +39,7 @@ Each test function requires the `#[test]` attribute. For tests that should verif Here's a comprehensive test example: ```cairo -// [!include ~/listings/getting-started/testing_how_to/tests/test_contract.cairo:tests] +// [!include ~/listings/getting-started/testing_how_to/src/test_contract.cairo:tests] ``` ## Testing Techniques @@ -49,7 +49,7 @@ Here's a comprehensive test example: For testing specific storage scenarios, snforge provides `load` and `store` functions: ```cairo -// [!include ~/listings/getting-started/testing_how_to/tests/test_contract.cairo:tests_with_direct_storage_access] +// [!include ~/listings/getting-started/testing_how_to/src/test_contract.cairo:tests_with_direct_storage_access] ``` ### Contract State Testing @@ -57,7 +57,7 @@ For testing specific storage scenarios, snforge provides `load` and `store` func Use `Contract::contract_state_for_testing` to access internal contract state: ```cairo -// [!include ~/listings/getting-started/testing_how_to/tests/test_contract.cairo:tests_with_contract_state] +// [!include ~/listings/getting-started/testing_how_to/src/test_contract.cairo:tests_with_contract_state] ``` ### Event Testing @@ -65,7 +65,7 @@ Use `Contract::contract_state_for_testing` to access internal contract state: To verify event emissions: ```cairo -// [!include ~/listings/getting-started/testing_how_to/tests/test_contract.cairo:tests_with_events] +// [!include ~/listings/getting-started/testing_how_to/src/test_contract.cairo:tests_with_events] ``` :::info diff --git a/pages/index.mdx b/pages/index.mdx index 0e7aed02..01935a14 100644 --- a/pages/index.mdx +++ b/pages/index.mdx @@ -47,9 +47,9 @@ To deepen your knowledge: The current version of this book uses: ```md -cairo 2.9.4 +cairo 2.10.1 edition 2024_07 -sierra 1.6.0 +sierra 1.7.0 // .tool-versions: // [!include ~/.tool-versions] ``` diff --git a/routes.ts b/routes.ts index dfd1d7be..18e7cca1 100644 --- a/routes.ts +++ b/routes.ts @@ -80,7 +80,7 @@ const config: Sidebar = [ }, { text: "Testing contracts", - link: "/getting-started/testing/testing", + link: "/getting-started/testing/", items: [ { text: "With Snforge",