Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 0 > Basics: wording + grammar fixes #207

Merged
merged 15 commits into from
Jun 3, 2024
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
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
48 changes: 24 additions & 24 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 @@ -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
14 changes: 7 additions & 7 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
24 changes: 12 additions & 12 deletions po/zh-cn.po
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,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 ""
"> 实际上,这两个合约的底层 sierra 程序是一样的。\n"
"> 实际上,这两个合约的底层 Sierra 程序是一样的。\n"
"> 从编译器的角度来看,存储变量在使用之前是不存在的。"

#: src/ch00/basics/storage.md:32
Expand Down Expand Up @@ -936,23 +936,23 @@ msgid ""
" }\n"
"\n"
"\n"
" // 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"
" #[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 the "
Expand All @@ -970,7 +970,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 @@ -994,23 +994,23 @@ msgstr ""
" }\n"
"\n"
"\n"
" // 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"
" #[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 the "
Expand All @@ -1028,7 +1028,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
4 changes: 2 additions & 2 deletions src/ch00/basics/bytearrays-strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Each character is encoded on 8 bits following the ASCII standard, so it's possib
Short strings are declared with single quotes, like this: `'Hello, World!'`.
See the [Felt](../cairo_cheatsheet/felt.md) section for more information about short strings with the `felt252` type.

> Notice that any short string only use up to 31 bytes, so it's possible to represent any short string with the `bytes31`.
> Notice that any short string only use up to 31 bytes, so it's possible to represent any short string with `bytes31`.

## ByteArray (Long strings)

The `ByteArray` struct is used to store strings of arbitrary length. It contain a field `data` of type `Array<bytes31>` to store a sequence of short strings.
The `ByteArray` struct is used to store strings of arbitrary length. It contains a field `data` of type `Array<bytes31>` to store a sequence of short strings.

ByteArrays are declared with double quotes, like this: `"Hello, World!"`.

Expand Down
Loading