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

[fix] Fix some tutorial syntax errors #58

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 01_HelloCairo/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ WTF Academy 社群:[Discord](https://discord.gg/5akcruXrsk)|[微信群](http
3. 确认 Rust 被正确安装:

```shell
cargo test
rustup --version
```

确认Cagro被正确安装:
Expand Down
2 changes: 1 addition & 1 deletion 01_HelloCairo/readme_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ To use the `Cairo CLI`, we need to install Rust and clone the Cairo repo.
3. Verify that Rust is installed correctly:

```shell
cargo test
rustup --version
```

4. Clone the Cairo repo locally:
Expand Down
13 changes: 7 additions & 6 deletions 02_PrimitiveTypes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ let x = 6;

## felt

`felt`([域元素](https://en.wikipedia.org/wiki/Field_(mathematics)))是 Cairo 中最基本的数据类型,也是其他数据类型的构建基石。它的取值范围为0&le;x&lt;P中的整数,其中P为一个非常大的素数,p=2<sup>251</sup>+17*2<sup>192</sup>。当值超过这个范围时,会发生溢出(或下溢),结果会模P。
`felt`([域元素](https://en.wikipedia.org/wiki/Field_(mathematics)))是 Cairo 中最基本的数据类型,也是其他数据类型的构建基石。它的取值范围为0&le;x&lt;P中的整数,其中P为一个非常大的素数,p=2<sup>251</sup>+17*2<sup>192</sup>+1。当值超过这个范围时,会发生溢出(或下溢),结果会模P。

```rust
fn overflow(self: @ContractState) -> felt252 {
let x: felt252 = -1;
//0x800000000000011000000000000000000000000000000000000000000000000
//=2^251+17⋅2^192
return x;
// max value of felt252
let x: felt252 = 3618502788666131213697322783095070105623107215331596699973092056135872020480;
let y: felt252 = 1;
assert(x + y == 0, 'P == 0 (mod P)');
return x + y;
}
```

Expand Down Expand Up @@ -111,7 +112,7 @@ let x_string_in_hex = 0x5754462041636164656D79;
在Cairo2.4.0中添加ByteArray结构后,不再局限于31个字符。这些字符串用双引号书写:

```rust
// 用 felt 表示短字符串
// 用 ByteArray 表示长字符串
let x_long_string: ByteArray = "this is a string which has more than 31 characters";
```

Expand Down
2 changes: 1 addition & 1 deletion 09_Enum/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WTF Academy 社群:[Discord](https://discord.gg/5akcruXrsk)|[微信群](http

## Cairo 中的枚举

Cairo 中的枚举由一组固定的命名值(变量)组成,或者可以说时多个子类型公用一个枚举类型,其中每个值都是不同的,并且具有特定的含义。使用枚举可以提高代码的可读性并减少错误。
Cairo 中的枚举由一组固定的命名值(变量)组成,或者可以说是多个子类型公用一个枚举类型,其中每个值都是不同的,并且具有特定的含义。使用枚举可以提高代码的可读性并减少错误。

Cairo中枚举的用法为:首先给出`derive`关键字表明该枚举对象的特性,然后使用`enum`关键字定义枚举,并在其后给出一个首字母大写的名称,最后在`{}`中给出枚举变量及其关联的值。

Expand Down