Skip to content

Commit

Permalink
Merge pull request #5 from xj5027/leon_lee
Browse files Browse the repository at this point in the history
Leon lee
  • Loading branch information
HelloRWA authored Mar 12, 2024
2 parents b0116fe + 6623642 commit 3da24c6
Show file tree
Hide file tree
Showing 12 changed files with 293 additions and 316 deletions.
29 changes: 15 additions & 14 deletions src/zh/guides/aos/blueprints/chatroom.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
# Chatroom Blueprint
# 聊天室蓝图

The Chatroom Blueprint is a predesigned template that helps you quickly build a chatroom in `ao`. It is a great way to get started and can be customized to fit your needs.
聊天室蓝图是预先设计好的模板,可帮助您在 ao 中快速构建。蓝图是入门的绝佳方式,并且可以根据您的需求进行定制。

## Unpacking the Chatroom Blueprint
## 解析聊天室蓝图

- **Members**: The `Members` array is used to store the users who have registered to the chatroom.
- **成员**: `Members`数组用于存储已注册聊天室的用户。

- **Register Handler**: The `register` handler allows processes to join the chatroom. When a process sends a message with the tag `Action = "Register"`, the handler will add the process to the `Members` array and send a message back to the process confirming the registration.
- **注册 Handler**: `register` handler 支持进程加入聊天室。当进程发送带有标签 `Action = "Register"` 的消息时,handler会将进程添加到 `Members` 数组中,并向进程发送一条消息确认注册。
注册处理程序:

- **Broadcast Handler**: The `broadcast` handler allows processes to send messages to all the members of the chatroom. When a process sends a message with the tag `Action = "Broadcast"`, the handler will send the message to all the members of the chatroom.
- **广播 Handler**: `broadcast` handler支持进程向聊天室的所有成员发送消息。当进程发送带有标签 Action = "Broadcast" 的消息时,handler会将该消息发送给聊天室的所有成员。

### How To Use:
### 如何使用:

1. Open your preferred text editor.
2. Open the Terminal.
3. Start your `aos` process.
4. Type in `.load-blueprint chatroom`
1. 打开文本编辑器。
2. 打开终端。
3. 启动您的 `aos` 进程。
4. 输入 `.load-blueprint chatroom`

### Verify the Blueprint is Loaded:
### 验证蓝图是否已加载:

Type in `Handlers.list` to see the newly loaded handlers.
输入 `Handlers.list` 查看新加载的Handlers。

## What's in the Chatroom Blueprint:
## 聊天室蓝图中包含的内容:

```lua
Members = Members or {}
Expand Down
15 changes: 9 additions & 6 deletions src/zh/guides/aos/blueprints/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ next:
---

# Blueprints
# 蓝图

Blueprints are predesigned templates that help you quickly build in `ao`. They are a great way to get started and can be customized to fit your needs.
蓝图是预先设计好的模板,可帮助您在 ao 中快速构建。蓝图是入门的绝佳方式,并且可以根据您的需求进行定制。
## 可用蓝图

## Available Blueprints
- [代币蓝图](token)

- [Token](token)
- [Chatroom](chatroom)
- [Voting](voting)
- [Staking](staking)
- [聊天室蓝图](chatroom)

- [投票蓝图](voting)

- [质押蓝图](staking)
36 changes: 18 additions & 18 deletions src/zh/guides/aos/blueprints/staking.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# Staking Blueprint
# 质押蓝图

The Staking Blueprint is a predesigned template that helps you quickly build a staking system in `ao`. It is a great way to get started and can be customized to fit your needs.
质押蓝图是预先设计好的模板,可帮助您在 ao 中快速构建。蓝图是入门的绝佳方式,并且可以根据您的需求进行定制。
## 前提条件

## Prerequisites
质押蓝图要求先加载 [代币蓝图](./token.md)
## 解析投票蓝图

The Staking Blueprint requires the [Token Blueprint](./token.md) to be loaded, first.
- **质押**: `Stakers`数组用于存储参与者的质押代币。

## Unpacking the Staking Blueprint
- **解除质押**:`Unstaking` 数组用于存储参与者的解除质押请求。

- **Stakers**: The `Stakers` array is used to store the staked tokens of the participants.
- **质押操作 Handler**: `stake`handler支持进程质押代币。当进程发送带有标签`Action = "Stake"`的消息时,处理程序会将质押代币添加到`Stakers` 数组中,并向进程发送一条消息确认质押。

- **Unstaking**: The `Unstaking` array is used to store the unstaking requests of the participants.
- **解除质押操作 Handler**: `unstake` handler支持进程解除质押代币。当进程发送带有标签`Action = "Unstake"`的消息时,处理程序会将解除质押请求添加到 `Unstaking` 数组中,并向进程发送一条消息确认解除质押。

- **Stake Action Handler**: The `stake` handler allows processes to stake tokens. When a process sends a message with the tag `Action = "Stake"`, the handler will add the staked tokens to the `Stakers` array and send a message back to the process confirming the staking.
- **最终确定 Handler**: `finalize` handler支持进程完成质押过程。当进程发送带有标签 `Action = "Finalize"`的消息时,处理程序会处理解除质押请求并完成质押过程。
### 如何使用:

- **Unstake Action Handler**: The `unstake` handler allows processes to unstake tokens. When a process sends a message with the tag `Action = "Unstake"`, the handler will add the unstaking request to the `Unstaking` array and send a message back to the process confirming the unstaking.
1. 打开文本编辑器。

- **Finalization Handler**: The `finalize` handler allows processes to finalize the staking process. When a process sends a message with the tag `Action = "Finalize"`, the handler will process the unstaking requests and finalize the staking process.
2. 打开终端。

### How To Use:
3. 启动`aos`流程。

1. Open your preferred text editor.
2. Open the Terminal.
3. Start your `aos` process.
4. Type in `.load-blueprint staking`
4. 输入 `.load-blueprint staking`

### Verify the Blueprint is Loaded:
### 验证蓝图已加载:

Type in `Handlers.list` to see the newly loaded handlers.
输入`Handlers.list`查看新加载的Handler。

## What's in the Staking Blueprint:
## 质押蓝图中的内容:

```lua
Stakers = Stakers or {}
Expand Down
42 changes: 21 additions & 21 deletions src/zh/guides/aos/blueprints/token.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# Token Blueprint
# 代币蓝图

The Token Blueprint is a predesigned template that helps you quickly build a token in `ao`. It is a great way to get started and can be customized to fit your needs.
代币蓝图是预先设计好的模板,可帮助您在 ao 中快速构建。蓝图是入门的绝佳方式,并且可以根据您的需求进行定制。

## Unpacking the Token Blueprint
## 解析代币蓝图

- **Balances**: The `Balances` array is used to store the token balances of the participants.
- **余额**: `Balances` 数组用于存储参与者的代币余额。

- **Info Handler**: The `info` handler allows processes to retrieve the token parameters, like Name, Ticker, Logo, and Denomination.
- **信息 Handler**: `info` handler 支持流程进程检索代币参数,例如名称、代码、徽标和面值。

- **Balance Handler**: The `balance` handler allows processes to retrieve the token balance of a participant.
- **余额 Handler**: `balance` Handler支持进程检索参与者的代币余额。
:
- **总余额 Handler**: `balances` Handler支持进程检索所有参与者的代币余额。
:
- **转移 Handler**: `transfer` Handler支持进程向其他参与者发送代币。
:
- **铸币 Handler**: `mint` Handler支持进程铸造新的代币。
:
### 如何使用:

- **Balances Handler**: The `balances` handler allows processes to retrieve the token balances of all participants.
1. 打开您的文本编辑器。
2. 打开终端。
3. 启动您的`aos`进程.
4. 输入`.load-blueprint token`

- **Transfer Handler**: The `transfer` handler allows processes to send tokens to another participant.
### 验证蓝图是否已加载:

- **Mint Handler**: The `mint` handler allows processes to mint new tokens.
输入 `Handlers.list` 查看新加载的handlers。

### How To Use:

1. Open your preferred text editor.
2. Open the Terminal.
3. Start your `aos` process.
4. Type in `.load-blueprint token`

### Verify the Blueprint is Loaded:

Type in `Handlers.list` to see the newly loaded handlers.

## What's in the Token Blueprint:
## 代币蓝图包含的内容:

```lua
local bint = require('.bint')(256)
Expand Down
34 changes: 17 additions & 17 deletions src/zh/guides/aos/blueprints/voting.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# Voting Blueprint
# 投票蓝图

The Voting Blueprint is a predesigned template that helps you quickly build a voting system in `ao`. It is a great way to get started and can be customized to fit your needs.
投票蓝图是预先设计好的模板,可帮助您在 ao 中快速构建。蓝图是入门的绝佳方式,并且可以根据您的需求进行定制。

## Prerequisites
## 前提条件

The Staking Blueprint requires the [Token Blueprint](./token.md) to be loaded, first.
投票蓝图要求先加载 [Token 蓝图](./token.md)

## Unpacking the Voting Blueprint
## 解析投票蓝图

- **Balances**: The `Balances` array is used to store the token balances of the participants.
- **余额**: The `Balances` 数组用于存储参与者的代币余额。

- **Votes**: The `Votes` array is used to store the votes of the participants.
- **票数 **: `Votes` 数组用于存储参与者的投票信息。

- **Vote Action Handler**: The `vote` handler allows processes to vote. When a process sends a message with the tag `Action = "Vote"`, the handler will add the vote to the `Votes` array and send a message back to the process confirming the vote.
- **投票操作 Handler**: `vote` handler支持进程进行投票。当进程发送带有标记 Action = "Vote" 的消息时,handler会将投票信息添加到`Votes`数组中,并向流程发送消息,确认投票。

- **Finalization Handler**: The `finalize` handler allows processes to finalize the voting process. When a process sends a message with the tag `Action = "Finalize"`, the handler will process the votes and finalize the voting process.
- **最终确定 Handler**: `finalize` handler支持进程完成投票过程。当进程发送带有标签 `Action = "Finalize"`的消息时,Handler会处理投票信息并完成投票过程。

### How To Use:
### 如何使用:

1. Open your preferred text editor.
2. Open the Terminal.
3. Start your `aos` process.
4. Type in `.load-blueprint voting`
1. 打开您的文本编辑器。
2. 打开终端。
3. 启动您的`aos`进程.
4. 输入`.load-blueprint voting`

### Verify the Blueprint is Loaded:
### 验证蓝图是否已加载:

Type in `Handlers.list` to see the newly loaded handlers.
输入 `Handlers.list` 查看新加载的handlers。

## What's in the Voting Blueprint:
## 投票蓝图包含的内容:

```lua
Balances = Balances or {}
Expand Down
48 changes: 22 additions & 26 deletions src/zh/guides/aos/modules/ao.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# ao

Built in global library for sending messages, spawning processes, etc.
内置全局库,用于发送消息、生成进程等。

### Example usage

The global `ao` object is accessible anywhere in your process:
### 示例用法

全局对象`ao`在您的进程中的任何地方都可以访问:
```lua
-- sends a message to another process ("Transfer" action)
ao.send({
Expand All @@ -16,18 +15,17 @@ ao.send({
})
```

## Module variables

- `ao.id`: `{string}` Holds the Arweave ID of your process
- `ao.authorities`: `{table}` An array of optionally trusted callers
- `ao._module`: `{string}` The WASM base module of the process that is executed on each call
- `ao._ref`: `{number}` The counter of the messages sent out in one call instance
- `ao._version`: `{string}` The ao global library version
- `ao.env`: `{table}` The process environment from the initializing message
## 模块变量

- `ao.id`: `{string}` 保存您进程中的 Arweave ID
- `ao.authorities`: `{table}` 可选信任的调用者数组
- `ao._module`: `{string}` 每次调用都会执行进程的 WASM 基础模块。
- `ao._ref`: `{number}` 一个调用实例中发送的消息计数器。
- `ao._version`: `{string}` ao 全局库版本。
- `ao.env`: `{table}` 初始化消息中的进程环境。
### `ao.env`

The `ao.env` global variable holds informationg about the initializing message of the process. It follows the schema below:
全局变量`ao.env`保存了有关进程初始化消息的信息。它遵循以下结构:

```json
{
Expand Down Expand Up @@ -81,14 +79,13 @@ The `ao.env` global variable holds informationg about the initializing message o
}
```

## Module functions
## 模块函数

### `log()`

Appends the provided value/message to the `Results.Output` table which can later be read using the [`aoconnect`](/guides/aoconnect/aoconnect.html) library. Useful for debugging as well as returning an output value to a caller.

此功能将提供的值或消息附加到 `Results.Output` 表格中。该表格稍后可以使用 [`aoconnect`](/guides/aoconnect/aoconnect.html) 库进行读取。这对于调试和向调用者返回输出值都很有用。
- **Parameters:**
- `txt`: `{any}` The value/message to be appended to the output table
- `txt`: `{any}` 用于输出的数值/内容
- **Returns:** `{void}`

#### Examples
Expand All @@ -106,14 +103,13 @@ ao.log({

### `send()`

Sends a message to another process by inserting the provided message item into the process' outbox along with the _ao specs compliant_ message tags.

根据 AO 规范,将指定的消息内容连同消息标签一起放入目标进程的输出队列,从而向另一个进程发送消息。
- **Parameters:**
- `msg`: `{table}` The message to be sent
- **Returns:** The sent message item with the applied tags and `DataItem` fields.
- `msg`: `{table}` 待发送的消息
- **Returns:** 已发送的消息,包含已应用的标签和`DataItem`字段。

> **Note:** Each field of the `msg` table will be appended as a `DataItem` tag, except the following: `"Target"`, `"Data"`, `"Anchor"`, `"Tags"`. These fields are interpreted as root level `DataItem` fields.
`msg` 表的每个字段都会作为 `DataItem` 标签附加,但以下字段除外:`"Target"`, `"Data"`, `"Anchor"`, `"Tags"`,因为这些字段将直接作为根级别的`DataItem`字段使用。
#### Example

```lua
Expand All @@ -127,12 +123,12 @@ ao.send({

### `spawn()`

Allows spawning a new process, from within another process.
支持进程间创建新进程。

- **Parameters:**
- `module`: `{string}` Arweave transaction ID of the module used by the new process
- `msg`: `{table}` The message that initializes the process, with the format described [above](#send)
- **Returns:** The initializing message item
- `module`: `{string}` 新进程使用的模块的 Arweave 交易 ID
- `msg`: `{table}` 初始化进程的消息,格式[如上所述] (#send)
- **Returns:** 初始化消息项

#### Example

Expand Down
Loading

0 comments on commit 3da24c6

Please sign in to comment.