-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Update move-on-rooch relative docs (#1874)
- Loading branch information
Showing
14 changed files
with
183 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
docs/website/pages/build/rooch-framework/data-struct.en-US.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Data Struct | ||
|
||
import { Callout, FileTree } from 'nextra/components' | ||
|
||
`#[data_struct]` is a struct annotation used to mark a struct as a pure data struct, allowing it to be directly deserialized within a contract. This feature is designed to facilitate developers in retrieving data from external data sources. | ||
|
||
## Example | ||
|
||
```move | ||
module my_project::my_module { | ||
#[data_struct] | ||
struct MyData has copy, drop { | ||
value: u64, | ||
name: vector<u8>, | ||
} | ||
} | ||
``` | ||
|
||
With this annotation, developers can directly deserialize the `MyData` struct within a contract: | ||
|
||
```move | ||
let data: MyData = moveos_std::bcs::from_bytes(bytes); | ||
``` | ||
|
||
The `moveos_std::bcs::from_bytes` function also uses the `#[data_struct(T)]` annotation to ensure that `T` must be a `#[data_struct]` type. | ||
|
||
```move | ||
module moveos_std::bcs { | ||
#[data_struct(T)] | ||
/// Function to deserialize a type T. | ||
/// The `data_struct` annotation ensures that `T` must be a `#[data_struct]` type. | ||
public fun from_bytes<T>(bytes: vector<u8>): T; | ||
} | ||
``` | ||
|
||
## How It Works | ||
|
||
The `#[data_struct]` annotation is implemented based on the Move verifier, which checks the struct definition at compile time to ensure it meets the `data_struct` requirements. Additionally, the contract is re-verified during deployment. | ||
|
||
## Data Struct Specification | ||
|
||
<Callout> | ||
TODO: This part of the document needs improvement. | ||
</Callout> |
44 changes: 44 additions & 0 deletions
44
docs/website/pages/build/rooch-framework/data-struct.zh-CN.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# 数据结构体 | ||
|
||
import { Callout, FileTree } from 'nextra/components' | ||
|
||
`#[data_struct]` 是一个结构体注解,用于标记结构体为纯数据结构体,使其可以在合约中直接反序列化。这个特性旨在方便开发者从外部数据源获取数据。 | ||
|
||
## 示例 | ||
|
||
```move | ||
module my_project::my_module { | ||
#[data_struct] | ||
struct MyData has copy, drop { | ||
value: u64, | ||
name: vector<u8>, | ||
} | ||
} | ||
``` | ||
|
||
这样,开发者就可以在合约中直接反序列化 `MyData` 结构体: | ||
|
||
```move | ||
let data: MyData = moveos_std::bcs::from_bytes(bytes); | ||
``` | ||
|
||
`moveos_std::bcs::from_bytes` 函数也使用了 `#[data_struct(T)]` 注解,确保 `T` 必须是一个 `#[data_struct]` 类型。 | ||
|
||
```move | ||
module moveos_std::bcs { | ||
#[data_struct(T)] | ||
/// 反序列化类型 T 的函数。 | ||
/// `data_struct` 注解确保 `T` 必须是一个 `#[data_struct]` 类型。 | ||
public fun from_bytes<T>(bytes: vector<u8>): T; | ||
} | ||
``` | ||
|
||
## 工作原理 | ||
|
||
`#[data_struct]` 基于 Move 的验证器实现,在编译时检查结构体的定义是否符合 `data_struct` 的要求。同时,在合约部署时也会进行再次验证。 | ||
|
||
## 数据结构体规范 | ||
|
||
<Callout> | ||
TODO 这部分文档需要改进 | ||
</Callout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
docs/website/pages/learn/core-concepts/move-contracts/built-in-library.en-US.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
# Rooch's built-in library | ||
|
||
Rooch currently has three built-in standard libraries, namely `MoveStdlib`, `MoveosStdlib` and `RoochFramework`. | ||
Rooch currently has four built-in standard libraries, namely `MoveStdlib`, `MoveosStdlib`, `RoochFramework` and `BitcoinMove`. | ||
|
||
The addresses of the three libraries in Move are: | ||
The addresses of the four libraries in Move are: | ||
|
||
- `MoveStdlib`: `0x1` | ||
- `MoveosStdlib`: `0x2` | ||
- `RoochFramework`: `0x3` | ||
- `BitcoinMove`:`0x4` | ||
|
||
## Documentation link | ||
|
||
- [MoveStdlib](https://github.com/rooch-network/rooch/tree/main/frameworks/move-stdlib/doc) | ||
- [MoveosStdlib](https://github.com/rooch-network/rooch/tree/main/frameworks/moveos-stdlib/doc) | ||
- [RoochFramework](https://github.com/rooch-network/rooch/tree/main/frameworks/rooch-framework/doc) | ||
- [BitcoinMove](https://github.com/rooch-network/rooch/tree/main/frameworks/bitcoin-move/doc) |
6 changes: 4 additions & 2 deletions
6
docs/website/pages/learn/core-concepts/move-contracts/built-in-library.zh-CN.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
# Rooch 的内置库 | ||
|
||
Rooch 当前内置了三个标准库,分别是 `MoveStdlib`、`MoveosStdlib` 和 `RoochFramework`。 | ||
Rooch 当前内置了四个标准库,分别是 `MoveStdlib`、`MoveosStdlib`、`RoochFramework` 和 `BitcoinMove`。 | ||
|
||
三个库在 Move 中的地址分别是: | ||
四个库在 Move 中的地址分别是: | ||
|
||
- `MoveStdlib`:`0x1` | ||
- `MoveosStdlib`:`0x2` | ||
- `RoochFramework`:`0x3` | ||
- `BitcoinMove`:`0x4` | ||
|
||
## 文档链接 | ||
|
||
- [MoveStdlib](https://github.com/rooch-network/rooch/tree/main/frameworks/move-stdlib/doc) | ||
- [MoveosStdlib](https://github.com/rooch-network/rooch/tree/main/frameworks/moveos-stdlib/doc) | ||
- [RoochFramework](https://github.com/rooch-network/rooch/tree/main/frameworks/rooch-framework/doc) | ||
- [BitcoinMove](https://github.com/rooch-network/rooch/tree/main/frameworks/bitcoin-move/doc) |
Oops, something went wrong.