Skip to content

Commit

Permalink
Chapter 0 > Basics: wording + grammar fixes (#207)
Browse files Browse the repository at this point in the history
* sierra->Sierra + plural/singular form fixes

* ch00 > Missing attr. elems, wrong attr. names

* missing dot in messages + update how legacymap modulo format

* ch00 > errors > add indent to comment in complex section

* ch00 > events > wording, missing code quotes

* ch00 > syscalls > wording

* ch00 > bytearray > wording

* ch00 > stor.custom types > wording

* ch00 > cust.types in entrypoints > wording

* ch00 > documentation > wording

* Revert comment format changes

* Simplify panic_with_felt252 related comment in errors.md

* Fixes for ch00

* Wording in cheatsheet

* Comment update in type_casting

---------

Co-authored-by: Nenad <nenad@better.giving>
  • Loading branch information
0xNeshi and Nenad authored Jun 3, 2024
1 parent e836f09 commit bc223b4
Show file tree
Hide file tree
Showing 35 changed files with 144 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ fn array() -> bool {
let second_value = *arr.at(0);
assert(second_value == 20, 'second value should match');

// Returns true if an array is empty, then false if it isn't.
// Returns true if an array is empty, and false if it isn't.
arr.is_empty()
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn type_casting() {
let _new_u256: u256 = my_felt252.into();
let _new_felt252: felt252 = new_u16.into();

//note a usize is smaller than a felt so we use the try_into
// Note: usize is smaller than felt252, so we use try_into
let _new_usize: usize = my_felt252.try_into().unwrap();
// ANCHOR_END: sheet
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn while_let() {
// ANCHOR: sheet
let mut option = Option::Some(0_usize);

// "while `let` destructures `option` into `Some(i)`:
// "while `let` destructures `option` into `Some(i)`,
// evaluate the block (`{}`), else `break`
while let Option::Some(i) =
option {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub trait ISerdeCustomType<TContractState> {

// ANCHOR: contract
// Deriving the `Serde` trait allows us to use
// the Person type as an entrypoint parameter and return value
// the `Person` type as an entrypoint parameter and as a return value
#[derive(Drop, Serde)]
pub struct Person {
pub age: u8,
Expand Down
2 changes: 1 addition & 1 deletion listings/getting-started/events/src/counter.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod EventCounter {
#[event]
#[derive(Copy, Drop, Debug, PartialEq, starknet::Event)]
// The event enum must be annotated with the `#[event]` attribute.
// It must also derive atleast `Drop` and `starknet::Event` traits.
// It must also derive at least the `Drop` and `starknet::Event` traits.
pub enum Event {
CounterIncreased: CounterIncreased,
UserIncreaseCounter: UserIncreaseCounter
Expand Down
4 changes: 2 additions & 2 deletions listings/getting-started/testing_how_to/src/contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ mod tests_with_states {
assert_eq!(state.get_value(), initial_value);
assert_eq!(state.get_owner(), owner);

// Mutating the state from the contract change the testing state
// Mutating the state from the contract changes the testing state
set_contract_address(owner);
let new_value: u32 = 20;
contract.set_value(new_value);
set_contract_address(contract.contract_address);
assert_eq!(state.get_value(), new_value);

// Mutating the state from the testing state change the contract state
// Mutating the state from the testing state changes the contract state
set_caller_address(owner);
state.set_value(initial_value);
assert_eq!(contract.get_value(), initial_value);
Expand Down
12 changes: 6 additions & 6 deletions listings/getting-started/visibility/src/visibility.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ pub mod ExampleContract {
value: u32
}

// The `abi(embed_v0)` attribute indicates that all
// The `#[abi(embed_v0)]` attribute indicates that all
// the functions in this implementation can be called externally.
// Omitting this attribute would make all the functions internal.
#[abi(embed_v0)]
impl ExampleContract of super::IExampleContract<ContractState> {
// The `set` function can be called externally
// because it is written inside an implementation marked as `#[external]`.
// because it is written inside an implementation marked as `#[abi(embed_v0)]`.
// It can modify the contract's state as it is passed as a reference.
fn set(ref self: ContractState, value: u32) {
self.value.write(value);
}

// The `get` function can be called externally
// because it is written inside an implementation marked as `#[external]`.
// However, it can't modify the contract's state is passed as a snapshot
// because it is written inside an implementation marked as `#[abi(embed_v0)]`.
// However, it can't modify the contract's state, as it is passed as a snapshot
// -> It's only a "view" function.
fn get(self: @ContractState) -> u32 {
// We can call an internal function from any functions within the contract
PrivateFunctionsTrait::_read_value(self)
}
}

// The lack of the `external` attribute indicates that all the functions in
// The lack of the `#[abi(embed_v0)]` attribute indicates that all the functions in
// this implementation can only be called internally.
// We name the trait `PrivateFunctionsTrait` to indicate that it is an
// internal trait allowing us to call internal functions.
Expand All @@ -43,7 +43,7 @@ pub mod ExampleContract {
// The `_read_value` function is outside the implementation that is
// marked as `#[abi(embed_v0)]`, so it's an _internal_ function
// and can only be called from within the contract.
// However, it can't modify the contract's state is passed
// However, it can't modify the contract's state, as it is passed
// as a snapshot: it is only a "view" function.
fn _read_value(self: @ContractState) -> u32 {
self.value.read()
Expand Down
62 changes: 31 additions & 31 deletions po/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ msgstr ""

#: src/ch00/basics/storage.md:29
msgid ""
"> Actually these two contracts have the same underlying sierra program.\n"
"> Actually these two contracts have the same underlying Sierra program.\n"
"> From the compiler's perspective, the storage variables don't exist until "
"they are used."
msgstr ""
"> En realidad estos dos contratos tienen el mismo programa sierra "
"> En realidad estos dos contratos tienen el mismo programa Sierra "
"subyacente.\n"
"> Desde la perspectiva del compilador, las variables de almacenamiento no "
"existen hasta que se utilizan."
Expand Down Expand Up @@ -1004,23 +1004,23 @@ msgid ""
" }\n"
"\n"
"\n"
" // The `abi(embed_v0)` attribute indicates that all the functions in "
" // The `#[abi(embed_v0)]` attribute indicates that all the functions in "
"this implementation can be called externally.\n"
" // Omitting this attribute would make all the functions in this "
"implementation internal.\n"
" #[abi(embed_v0)]\n"
" impl ExampleContract of super::IExampleContract<ContractState> {\n"
" // The `set` function can be called externally because it is written "
"inside an implementation marked as `#[external]`.\n"
"inside an implementation marked as `#[abi(embed_v0)]`.\n"
" // It can modify the contract's state as it is passed as a "
"reference.\n"
" fn set(ref self: ContractState, value: u32) {\n"
" self.value.write(value);\n"
" }\n"
"\n"
" // The `get` function can be called externally because it is written "
"inside an implementation marked as `#[external]`.\n"
" // However, it can't modify the contract's state is passed as a "
"inside an implementation marked as `#[abi(embed_v0)]`.\n"
" // However, it can't modify the contract's state, as it is passed as a "
"snapshot: it is only a \"view\" function.\n"
" fn get(self: @ContractState) -> u32 {\n"
" // We can call an internal function from any functions within "
Expand All @@ -1038,7 +1038,7 @@ msgid ""
" // The `_read_value` function is outside the implementation that is "
"marked as `#[abi(embed_v0)]`, so it's an _internal_ function\n"
" // and can only be called from within the contract.\n"
" // However, it can't modify the contract's state is passed as a "
" // However, it can't modify the contract's state, as it is passed as a "
"snapshot: it is only a \"view\" function.\n"
" fn _read_value(self: @ContractState) -> u32 {\n"
" self.value.read()\n"
Expand All @@ -1062,23 +1062,23 @@ msgstr ""
" }\n"
"\n"
"\n"
" // The `abi(embed_v0)` attribute indicates that all the functions in "
" // The `#[abi(embed_v0)]` attribute indicates that all the functions in "
"this implementation can be called externally.\n"
" // Omitting this attribute would make all the functions in this "
"implementation internal.\n"
" #[abi(embed_v0)]\n"
" impl ExampleContract of super::IExampleContract<ContractState> {\n"
" // The `set` function can be called externally because it is written "
"inside an implementation marked as `#[external]`.\n"
"inside an implementation marked as `#[abi(embed_v0)]`.\n"
" // It can modify the contract's state as it is passed as a "
"reference.\n"
" fn set(ref self: ContractState, value: u32) {\n"
" self.value.write(value);\n"
" }\n"
"\n"
" // The `get` function can be called externally because it is written "
"inside an implementation marked as `#[external]`.\n"
" // However, it can't modify the contract's state is passed as a "
"inside an implementation marked as `#[abi(embed_v0)]`.\n"
" // However, it can't modify the contract's state, as it is passed as a "
"snapshot: it is only a \"view\" function.\n"
" fn get(self: @ContractState) -> u32 {\n"
" // We can call an internal function from any functions within "
Expand All @@ -1096,7 +1096,7 @@ msgstr ""
" // The `_read_value` function is outside the implementation that is "
"marked as `#[abi(embed_v0)]`, so it's an _internal_ function\n"
" // and can only be called from within the contract.\n"
" // However, it can't modify the contract's state is passed as a "
" // However, it can't modify the contract's state, as it is passed as a "
"snapshot: it is only a \"view\" function.\n"
" fn _read_value(self: @ContractState) -> u32 {\n"
" self.value.read()\n"
Expand Down Expand Up @@ -1298,7 +1298,7 @@ msgid ""
"hash and the final value is taken `mod2251−256`. You can learn more about "
"the contract storage layout in the [Starknet Documentation](https://docs."
"starknet.io/documentation/architecture_and_concepts/Smart_Contracts/contract-"
"storage/#storage_variables)"
"storage/#storage_variables)."
msgstr ""
"- Son posibles asignaciones key-value más complejas; por ejemplo, podríamos "
"usar `LegacyMap::<(ContractAddress, ContractAddress), Felt252>` para crear "
Expand All @@ -1310,7 +1310,7 @@ msgstr ""
"información sobre el diseño de almacenamiento por contrato en la "
"[Documentación de Starknet](https://docs.starknet.io/documentation/"
"architecture_and_concepts/Smart_Contracts/contract-storage/"
"#storage_variables)"
"#storage_variables)."

#: src/ch00/basics/mappings.md:13
msgid ""
Expand Down Expand Up @@ -4910,12 +4910,12 @@ msgstr "# Match"

#: src/ch00/cairo_cheatsheet/match.md:3
msgid ""
"The \"match\" expression in Cairo allows us to control the flow of our code "
"by comparing a felt data type or an enum against various patterns and then "
"The `match` expression in Cairo allows us to control the flow of our code "
"by comparing a `felt252` data type or an enum against various patterns and then "
"running specific code based on the pattern that matches.\n"
"For example:"
msgstr ""
"La expresión \"match\" en Cairo nos permite controlar el flujo de nuestro "
"La expresión `match` en Cairo nos permite controlar el flujo de nuestro "
"código comparando un tipo de datos sentido o una enumeración con varios "
"patrones y luego ejecutando código específico basado en el patrón que "
"coincide.\n"
Expand Down Expand Up @@ -5158,7 +5158,7 @@ msgid ""
" let new_u256: u256 = my_felt252.into();\n"
" let new_felt252: felt252 = new_u16.into();\n"
"\n"
" //note a usize is smaller than a felt so we use the try_into\n"
" // Note: usize is smaller than felt252, so we use try_into\n"
" let new_usize: usize = my_felt252.try_into().unwrap();\n"
"```"
msgstr ""
Expand Down Expand Up @@ -5188,7 +5188,7 @@ msgstr ""
" let new_u256: u256 = my_felt252.into();\n"
" let new_felt252: felt252 = new_u16.into();\n"
"\n"
" //note a usize is smaller than a felt so we use the try_into\n"
" // Note: usize is smaller than felt252, so we use try_into\n"
" let new_usize: usize = my_felt252.try_into().unwrap();\n"
"```"

Expand Down Expand Up @@ -11071,36 +11071,36 @@ msgstr ""
#~ "pasamos por referencia así: `ref self: ContractState`."

#~ msgid ""
#~ "// The `abi(embed_v0)` attribute indicates that all the functions in this "
#~ "// The `#[abi(embed_v0)]` attribute indicates that all the functions in this "
#~ "implementation can be called externally.\n"
#~ " // Omitting this attribute would make all the functions in this "
#~ "implementation internal.\n"
#~ msgstr ""
#~ "// The `abi(embed_v0)` attribute indicates that all the functions in this "
#~ "// The `#[abi(embed_v0)]` attribute indicates that all the functions in this "
#~ "implementation can be called externally.\n"
#~ " // Omitting this attribute would make all the functions in this "
#~ "implementation internal.\n"

#~ msgid ""
#~ "// The `set` function can be called externally because it is written "
#~ "inside an implementation marked as `#[external]`.\n"
#~ "inside an implementation marked as `#[abi(embed_v0)]`.\n"
#~ " // It can modify the contract's state as it is passed as a "
#~ "reference.\n"
#~ msgstr ""
#~ "// The `set` function can be called externally because it is written "
#~ "inside an implementation marked as `#[external]`.\n"
#~ "inside an implementation marked as `#[abi(embed_v0)]`.\n"
#~ " // It can modify the contract's state as it is passed as a "
#~ "reference.\n"

#~ msgid ""
#~ "// The `get` function can be called externally because it is written "
#~ "inside an implementation marked as `#[external]`.\n"
#~ " // However, it can't modify the contract's state is passed as a "
#~ "inside an implementation marked as `#[abi(embed_v0)]`.\n"
#~ " // However, it can't modify the contract's state, as it is passed as a "
#~ "snapshot: it is only a \"view\" function.\n"
#~ msgstr ""
#~ "// The `get` function can be called externally because it is written "
#~ "inside an implementation marked as `#[external]`.\n"
#~ " // However, it can't modify the contract's state is passed as a "
#~ "inside an implementation marked as `#[abi(embed_v0)]`.\n"
#~ " // However, it can't modify the contract's state, as it is passed as a "
#~ "snapshot: it is only a \"view\" function.\n"

#~ msgid ""
Expand All @@ -11125,13 +11125,13 @@ msgstr ""
#~ "// The `_read_value` function is outside the implementation that is "
#~ "marked as `#[abi(embed_v0)]`, so it's an _internal_ function\n"
#~ " // and can only be called from within the contract.\n"
#~ " // However, it can't modify the contract's state is passed as a "
#~ " // However, it can't modify the contract's state, as it is passed as a "
#~ "snapshot: it is only a \"view\" function.\n"
#~ msgstr ""
#~ "// The `_read_value` function is outside the implementation that is "
#~ "marked as `#[abi(embed_v0)]`, so it's an _internal_ function\n"
#~ " // and can only be called from within the contract.\n"
#~ " // However, it can't modify the contract's state is passed as a "
#~ " // However, it can't modify the contract's state, as it is passed as a "
#~ "snapshot: it is only a \"view\" function.\n"

#~ msgid ""
Expand Down Expand Up @@ -11421,8 +11421,8 @@ msgstr ""
#~ msgstr ""
#~ "// Since a felt252 is smaller than a u256, we can use the into() method\n"

#~ msgid "//note a usize is smaller than a felt so we use the try_into\n"
#~ msgstr "//note a usize is smaller than a felt so we use the try_into\n"
#~ msgid "// Note: usize is smaller than felt252, so we use try_into\n"
#~ msgstr "// Note: usize is smaller than felt252, so we use try_into\n"

#~ msgid "Modularity: Easily pluggable into multiple contracts."
#~ msgstr "Modularidad: Fácilmente conectable a múltiples contratos."
Expand Down
20 changes: 10 additions & 10 deletions po/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ msgstr ""

#: src/ch00/basics/storage.md:29
msgid ""
"Actually these two contracts have the same underlying sierra program. From "
"Actually these two contracts have the same underlying Sierra program. From "
"the compiler's perspective, the storage variables don't exist until they are "
"used."
msgstr ""
Expand Down Expand Up @@ -583,7 +583,7 @@ msgstr ""

#: src/ch00/basics/visibility-mutability.md:42
msgid ""
"// The `abi(embed_v0)` attribute indicates that all the functions in this "
"// The `#[abi(embed_v0)]` attribute indicates that all the functions in this "
"implementation can be called externally.\n"
" // Omitting this attribute would make all the functions in this "
"implementation internal.\n"
Expand All @@ -592,16 +592,16 @@ msgstr ""
#: src/ch00/basics/visibility-mutability.md:46
msgid ""
"// The `set` function can be called externally because it is written inside "
"an implementation marked as `#[external]`.\n"
"an implementation marked as `#[abi(embed_v0)]`.\n"
" // It can modify the contract's state as it is passed as a "
"reference.\n"
msgstr ""

#: src/ch00/basics/visibility-mutability.md:52
msgid ""
"// The `get` function can be called externally because it is written inside "
"an implementation marked as `#[external]`.\n"
" // However, it can't modify the contract's state is passed as a "
"an implementation marked as `#[abi(embed_v0)]`.\n"
" // However, it can't modify the contract's state, as it is passed as a "
"snapshot: it is only a \"view\" function.\n"
msgstr ""

Expand All @@ -623,7 +623,7 @@ msgid ""
"// The `_read_value` function is outside the implementation that is marked "
"as `#[abi(embed_v0)]`, so it's an _internal_ function\n"
" // and can only be called from within the contract.\n"
" // However, it can't modify the contract's state is passed as a "
" // However, it can't modify the contract's state, as it is passed as a "
"snapshot: it is only a \"view\" function.\n"
msgstr ""

Expand Down Expand Up @@ -719,7 +719,7 @@ msgid ""
"`h(...h(h(sn_keccak(variable_name),k_1),k_2),...,k_n)` where `ℎ` is the "
"Pedersen hash and the final value is taken `mod2251−256`. You can learn more "
"about the contract storage layout in the [Starknet "
"Documentation](https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-storage/#storage_variables)"
"Documentation](https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-storage/#storage_variables)."
msgstr ""

#: src/ch00/basics/mappings.md:28
Expand Down Expand Up @@ -1507,8 +1507,8 @@ msgstr ""

#: src/ch00/cairo_cheatsheet/match.md:3
msgid ""
"The \"match\" expression in Cairo allows us to control the flow of our code "
"by comparing a felt data type or an enum against various patterns and then "
"The `match` expression in Cairo allows us to control the flow of our code "
"by comparing a `felt252` data type or an enum against various patterns and then "
"running specific code based on the pattern that matches. For example:"
msgstr ""

Expand Down Expand Up @@ -1579,7 +1579,7 @@ msgid "// Since a felt252 is smaller than a u256, we can use the into() method\n
msgstr ""

#: src/ch00/cairo_cheatsheet/type_casting.md:29
msgid "//note a usize is smaller than a felt so we use the try_into\n"
msgid "// Note: usize is smaller than felt252, so we use try_into\n"
msgstr ""

#: src/ch01/upgradeable_contract.md:3
Expand Down
Loading

0 comments on commit bc223b4

Please sign in to comment.