Skip to content

Commit 309acdf

Browse files
committed
i18n: sync and fix instructino introspection course for Simplified Chinese
1 parent 6326e5a commit 309acdf

File tree

2 files changed

+6
-8
lines changed
  • src/app/content/courses/instruction-introspection/introduction

2 files changed

+6
-8
lines changed

src/app/content/courses/instruction-introspection/introduction/en.mdx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ import { ArticleSection } from "../../../../components/ArticleSection/ArticleSec
44

55
![Instruction Introspection](/graphics/course-banners/instruction-introspection.png)
66

7-
Instruction introspection is a powerful capability on Solana that allows a program to analyze other instructions
8-
within the same transaction, including those not yet executed. This enables you to dynamically respond to or augment
9-
these instructions — for example, by injecting safeguards, validating behavior, or integrating instructions from
10-
external programs into your own logic.
7+
Instruction introspection is a powerful capability on Solana that allows a program to analyze other instructions within the same transaction, including those not yet executed. This enables you to dynamically respond to or augment these instructions — for example, by injecting safeguards, validating behavior, or integrating instructions from external programs into your own logic.
118

129
This is made possible by a special system account called the `Instructions` sysvar. Sysvars are read-only accounts maintained by the Solana runtime that expose internal state to programs (e.g., clock, rent, epoch schedule, etc.). The Instructions sysvar specifically exposes the full list of instructions in the current transaction, along with their metadata and serialized data.
1310

14-
Heres how Solana serializes this information at runtime:
11+
Here's how Solana serializes this information at runtime:
1512

1613
```rust
1714
// First encode the number of instructions:
@@ -63,7 +60,7 @@ fn serialize_instructions(instructions: &[BorrowedInstruction]) -> Vec<u8> {
6360

6461
This means that by reading the `Instructions` sysvar account inside your program, you can access all the instructions included in the current transaction.
6562

66-
You dont need to parse the raw bytes manually. Solana provides helper functions:
63+
You don't need to parse the raw bytes manually. Solana provides helper functions:
6764
- `load_current_index_checked`: returns the index of the currently executing instruction.
6865
- `load_instruction_at_checked`: lets you load a specific instruction by its index in a parsed, deserialized format.
6966

@@ -101,7 +98,6 @@ When using instruction introspection, it’s essential to enforce strict constra
10198

10299
By applying these constraints, you ensure that your program is responding only to valid and trusted instructions, making your logic more robust, composable, and secure.
103100

104-
Together with transaction atomicity, these checks allow you to build robust, composable logic that can safely interact
105-
with other programs and instructions within the same transaction.
101+
Together with transaction atomicity, these checks allow you to build robust, composable logic that can safely interact with other programs and instructions within the same transaction.
106102

107103
> Remember, transactions in Solana are atomic. If any instruction fails, the entire transaction is rolled back.

src/app/content/courses/instruction-introspection/introduction/zh-CN.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { ArticleSection } from "../../../../components/ArticleSection/ArticleSec
22

33
# 指令内省
44

5+
![指令内省](/graphics/course-banners/instruction-introspection.png)
6+
57
指令内省是 Solana 上的一项强大功能,它允许程序分析同一事务中的其他指令,包括尚未执行的指令。这使您能够动态响应或增强这些指令,例如通过注入保护措施、验证行为或将外部程序的指令集成到您自己的逻辑中。
68

79
这得益于一个特殊的系统账户,称为 `Instructions` sysvar。Sysvar 是由 Solana 运行时维护的只读账户,向程序公开内部状态(例如,时钟、租金、纪元计划等)。Instructions sysvar 专门公开当前事务中的完整指令列表,以及它们的元数据和序列化数据。

0 commit comments

Comments
 (0)