From 65d9aa0faf95f88d28632cbaf02333479b67d3ff Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 18 Jun 2024 05:44:50 +0200 Subject: [PATCH 1/5] add key_features --- config.json | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/config.json b/config.json index b13e422c..683f6b41 100644 --- a/config.json +++ b/config.json @@ -38,7 +38,33 @@ "practice": [] }, "concepts": [], - "key_features": [], + "key_features": [ + { + "icon": "easy", + "title": "Developer-friendly", + "content": "Write Rust-like code and generate proofs for program execution—math isn’t a barrier." + }, + { + "icon": "safe", + "title": "Provable", + "content": "Cairo allows for the creation of provable programs, which is a significant advantage in cryptographic and blockchain applications." + }, + { + "icon": "fast", + "title": "Efficient", + "content": "Cairo compiles down to an ad-hoc assembly, which was engineered specifically for efficient proof generation." + }, + { + "icon": "immutable", + "title": "Immutable", + "content": "Cairo uses the immutable memory model, improving data integrity and security." + }, + { + "icon": "evolving", + "title": "Innovative", + "content": "Unshackled by EVM, Cairo is a fast-growing language that keeps delivering new and exciting features to its developers." + } + ], "tags": [ "paradigm/functional", "paradigm/imperative", From 49b0dd431ff11376a2114bada58aceca0aaaa496 Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 18 Jun 2024 05:58:04 +0200 Subject: [PATCH 2/5] update gitignore with Cairo-specific files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 6a513a06..68ccd3f3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .DS_Store bin/configlet bin/configlet.exe +**/target +exercises/*/*/Scarb.lock From 643955e255015b6f24aa37623919c1c35e16dc65 Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 18 Jun 2024 06:20:05 +0200 Subject: [PATCH 3/5] add hello-world exercise + format config.json --- config.json | 48 ++++++++++++------- .../hello-world/.docs/instructions.md | 16 +++++++ .../practice/hello-world/.meta/config.json | 20 ++++++++ .../practice/hello-world/.meta/example.cairo | 3 ++ .../practice/hello-world/.meta/tests.toml | 13 +++++ exercises/practice/hello-world/Scarb.toml | 4 ++ exercises/practice/hello-world/src/lib.cairo | 7 +++ .../practice/hello-world/src/tests.cairo | 5 ++ 8 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 exercises/practice/hello-world/.docs/instructions.md create mode 100644 exercises/practice/hello-world/.meta/config.json create mode 100644 exercises/practice/hello-world/.meta/example.cairo create mode 100644 exercises/practice/hello-world/.meta/tests.toml create mode 100644 exercises/practice/hello-world/Scarb.toml create mode 100644 exercises/practice/hello-world/src/lib.cairo create mode 100644 exercises/practice/hello-world/src/tests.cairo diff --git a/config.json b/config.json index 683f6b41..cc48790a 100644 --- a/config.json +++ b/config.json @@ -34,48 +34,60 @@ ] }, "exercises": { - "concept": [], - "practice": [] + "practice": [ + { + "slug": "hello-world", + "name": "Hello World", + "uuid": "1a0e23d9-e8f9-493a-af46-2be040173b64", + "practices": [ + "strings" + ], + "prerequisites": [], + "difficulty": 1, + "topics": [ + "test_driven_development" + ] + } + ] }, - "concepts": [], "key_features": [ { - "icon": "easy", "title": "Developer-friendly", - "content": "Write Rust-like code and generate proofs for program execution—math isn’t a barrier." + "content": "Write Rust-like code and generate proofs for program execution—math isn’t a barrier.", + "icon": "easy" }, { - "icon": "safe", "title": "Provable", - "content": "Cairo allows for the creation of provable programs, which is a significant advantage in cryptographic and blockchain applications." + "content": "Cairo allows for the creation of provable programs, which is a significant advantage in cryptographic and blockchain applications.", + "icon": "safe" }, { - "icon": "fast", "title": "Efficient", - "content": "Cairo compiles down to an ad-hoc assembly, which was engineered specifically for efficient proof generation." + "content": "Cairo compiles down to an ad-hoc assembly, which was engineered specifically for efficient proof generation.", + "icon": "fast" }, { - "icon": "immutable", "title": "Immutable", - "content": "Cairo uses the immutable memory model, improving data integrity and security." + "content": "Cairo uses the immutable memory model, improving data integrity and security.", + "icon": "immutable" }, { - "icon": "evolving", "title": "Innovative", - "content": "Unshackled by EVM, Cairo is a fast-growing language that keeps delivering new and exciting features to its developers." + "content": "Unshackled by EVM, Cairo is a fast-growing language that keeps delivering new and exciting features to its developers.", + "icon": "evolving" } ], "tags": [ + "execution_mode/compiled", "paradigm/functional", "paradigm/imperative", "paradigm/procedural", - "typing/static", - "typing/strong", - "execution_mode/compiled", - "platform/windows", - "platform/mac", "platform/linux", + "platform/mac", + "platform/windows", "runtime/standalone_executable", + "typing/static", + "typing/strong", "used_for/artificial_intelligence", "used_for/backends", "used_for/financial_systems", diff --git a/exercises/practice/hello-world/.docs/instructions.md b/exercises/practice/hello-world/.docs/instructions.md new file mode 100644 index 00000000..c9570e48 --- /dev/null +++ b/exercises/practice/hello-world/.docs/instructions.md @@ -0,0 +1,16 @@ +# Instructions + +The classical introductory exercise. +Just say "Hello, World!". + +["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. + +The objectives are simple: + +- Modify the provided code so that it produces the string "Hello, World!". +- Run the test suite and make sure that it succeeds. +- Submit your solution and check it at the website. + +If everything goes well, you will be ready to fetch your first real exercise. + +[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program diff --git a/exercises/practice/hello-world/.meta/config.json b/exercises/practice/hello-world/.meta/config.json new file mode 100644 index 00000000..c7e88cfb --- /dev/null +++ b/exercises/practice/hello-world/.meta/config.json @@ -0,0 +1,20 @@ +{ + "authors": [ + "misicnenad" + ], + "files": { + "solution": [ + "src/lib.cairo", + "Scarb.toml" + ], + "test": [ + "src/tests.cairo" + ], + "example": [ + ".meta/example.cairo" + ] + }, + "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", + "source": "This is an exercise to introduce users to using Exercism", + "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" +} diff --git a/exercises/practice/hello-world/.meta/example.cairo b/exercises/practice/hello-world/.meta/example.cairo new file mode 100644 index 00000000..d203326b --- /dev/null +++ b/exercises/practice/hello-world/.meta/example.cairo @@ -0,0 +1,3 @@ +fn hello() -> ByteArray { + "Hello, World!" +} diff --git a/exercises/practice/hello-world/.meta/tests.toml b/exercises/practice/hello-world/.meta/tests.toml new file mode 100644 index 00000000..73466d67 --- /dev/null +++ b/exercises/practice/hello-world/.meta/tests.toml @@ -0,0 +1,13 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[af9ffe10-dc13-42d8-a742-e7bdafac449d] +description = "Say Hi!" diff --git a/exercises/practice/hello-world/Scarb.toml b/exercises/practice/hello-world/Scarb.toml new file mode 100644 index 00000000..c09a6b38 --- /dev/null +++ b/exercises/practice/hello-world/Scarb.toml @@ -0,0 +1,4 @@ +[package] +name = "hello_world" +version = "0.1.0" +edition = "2023_11" diff --git a/exercises/practice/hello-world/src/lib.cairo b/exercises/practice/hello-world/src/lib.cairo new file mode 100644 index 00000000..53b70a0c --- /dev/null +++ b/exercises/practice/hello-world/src/lib.cairo @@ -0,0 +1,7 @@ +// ByteArray is a string that's not limited to 31 characters, you'll learn more about this later +fn hello() -> ByteArray { + "Goodbye, Mars!" +} + +#[cfg(test)] +mod tests; diff --git a/exercises/practice/hello-world/src/tests.cairo b/exercises/practice/hello-world/src/tests.cairo new file mode 100644 index 00000000..31353571 --- /dev/null +++ b/exercises/practice/hello-world/src/tests.cairo @@ -0,0 +1,5 @@ +#[test] +fn test_hello_world() { + assert_eq!(hello_world::hello(), "Hello, World!"); +} + From ebd748dcb2e0806ca1592cd427cfc159957ded7d Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 18 Jun 2024 07:33:14 +0200 Subject: [PATCH 4/5] update key_features to include 6 items --- config.json | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/config.json b/config.json index cc48790a..8334d857 100644 --- a/config.json +++ b/config.json @@ -53,17 +53,17 @@ "key_features": [ { "title": "Developer-friendly", - "content": "Write Rust-like code and generate proofs for program execution—math isn’t a barrier.", + "content": "Write Rust-like code and generate proofs for program execution - math isn't a barrier.", "icon": "easy" - }, + }, { "title": "Provable", - "content": "Cairo allows for the creation of provable programs, which is a significant advantage in cryptographic and blockchain applications.", + "content": "Produces provable programs, making it possible to compute trustworthy values on untrusted machines.", "icon": "safe" }, { "title": "Efficient", - "content": "Cairo compiles down to an ad-hoc assembly, which was engineered specifically for efficient proof generation.", + "content": "Cairo compiles down to an ad-hoc assembly engineered specifically for efficient proof generation.", "icon": "fast" }, { @@ -71,9 +71,14 @@ "content": "Cairo uses the immutable memory model, improving data integrity and security.", "icon": "immutable" }, + { + "title": "General purpose", + "content": "From onchain gaming to provable ML, Cairo makes building trustless applications possible.", + "icon": "general-purpose" + }, { "title": "Innovative", - "content": "Unshackled by EVM, Cairo is a fast-growing language that keeps delivering new and exciting features to its developers.", + "content": "Cairo is a fast-growing language that keeps delivering new and exciting features to its developers.", "icon": "evolving" } ], From 24bd474eb77b1a813e73aad9adce54ec4bdd7bd0 Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 18 Jun 2024 08:25:39 +0200 Subject: [PATCH 5/5] Create strings concept --- concepts/strings/.meta/config.json | 7 +++++++ concepts/strings/about.md | 1 + concepts/strings/introduction.md | 3 +++ concepts/strings/links.json | 14 ++++++++++++++ config.json | 7 +++++++ exercises/practice/hello-world/src/tests.cairo | 1 - 6 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 concepts/strings/.meta/config.json create mode 100644 concepts/strings/about.md create mode 100644 concepts/strings/introduction.md create mode 100644 concepts/strings/links.json diff --git a/concepts/strings/.meta/config.json b/concepts/strings/.meta/config.json new file mode 100644 index 00000000..ebb4b627 --- /dev/null +++ b/concepts/strings/.meta/config.json @@ -0,0 +1,7 @@ +{ + "blurb": "ByteArray is a sequence of ASCII characters longer than 31 characters, written using double quotes", + "authors": [ + "misicnenad" + ], + "contributors": [] +} diff --git a/concepts/strings/about.md b/concepts/strings/about.md new file mode 100644 index 00000000..2c0923c4 --- /dev/null +++ b/concepts/strings/about.md @@ -0,0 +1 @@ +# String diff --git a/concepts/strings/introduction.md b/concepts/strings/introduction.md new file mode 100644 index 00000000..d5e1124b --- /dev/null +++ b/concepts/strings/introduction.md @@ -0,0 +1,3 @@ +# Introduction + +In Cairo, there's no native type for strings. Instead, you can use a single `felt252` to store a short string of up to 31 characters, or a `ByteArray` for strings of arbitrary length. Short strings use single quotes and `ByteArray` uses double quotes. All characters must follow the ASCII standard. diff --git a/concepts/strings/links.json b/concepts/strings/links.json new file mode 100644 index 00000000..fe904e3b --- /dev/null +++ b/concepts/strings/links.json @@ -0,0 +1,14 @@ +[ + { + "url": "https://book.cairo-lang.org/ch02-02-data-types.html#string-types", + "description": "String types in the Cairo book" + }, + { + "url": "https://starknet-by-example.voyager.online/getting-started/basics/bytearrays-strings.html", + "description": "Starknet by Example section on Strings and ByteArrays" + }, + { + "url": "https://docs.starknet.io/architecture-and-concepts/smart-contracts/serialization-of-cairo-types/#serialization_of_byte_arrays", + "description": "Starknet docs explaining how ByteArray is implemented and how it's serialized" + } +] diff --git a/config.json b/config.json index 8334d857..33a2726b 100644 --- a/config.json +++ b/config.json @@ -50,6 +50,13 @@ } ] }, + "concepts": [ + { + "uuid": "4eb800f7-f6c5-4b28-8492-229b6a51829e", + "slug": "strings", + "name": "Strings" + } + ], "key_features": [ { "title": "Developer-friendly", diff --git a/exercises/practice/hello-world/src/tests.cairo b/exercises/practice/hello-world/src/tests.cairo index 31353571..b7c248e9 100644 --- a/exercises/practice/hello-world/src/tests.cairo +++ b/exercises/practice/hello-world/src/tests.cairo @@ -2,4 +2,3 @@ fn test_hello_world() { assert_eq!(hello_world::hello(), "Hello, World!"); } -