Skip to content

Commit

Permalink
Update: Check translation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptonerdcn committed Dec 5, 2023
1 parent f26b42d commit e746a47
Showing 1 changed file with 177 additions and 7 deletions.
184 changes: 177 additions & 7 deletions po/zh-cn.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Starknet by Example\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2023-12-05 14:04+0900\n"
"PO-Revision-Date: 2023-12-05 14:16+0900\n"
"Last-Translator: StarknetAstro <[email protected]>\n"
"Language-Team: Language zh-cn\n"
"Language: zh_CN\n"
Expand Down Expand Up @@ -2457,7 +2457,7 @@ msgstr "# 调用其他合约"

#: src/ch00/interacting/calling_other_contracts.md:3
msgid "There are two different ways to call other contracts in Cairo."
msgstr ""
msgstr "在Cairo,有两种不同的方式可以调用其他合约。"

#: src/ch00/interacting/calling_other_contracts.md:5
msgid ""
Expand All @@ -2467,12 +2467,18 @@ msgid ""
"lang.org/ch99-02-02-contract-dispatcher-library-dispatcher-and-system-calls."
"html#contract-dispatcher)"
msgstr ""
"调用其他合约的最简单方法是使用要调用的合约的调度程序。\n"
"您可以在 [Cairo Book](https://book.cairo-lang.org/ch99-02-02-contract-"
"dispatcher-library-dispatcher-and-system-calls.html#contract-dispatcher) 中"
"阅读有关 Dispatchers 的更多信息"

#: src/ch00/interacting/calling_other_contracts.md:8
msgid ""
"The other way is to use the `starknet::call_contract_syscall` syscall "
"yourself. However, this method is not recommended."
msgstr ""
"另一种方法是自己使用`starknet::call_contract_syscall`系统调用。但是,不建议使"
"用此方法。"

#: src/ch00/interacting/calling_other_contracts.md:10
msgid ""
Expand All @@ -2481,6 +2487,9 @@ msgid ""
"interface]` attribute, and then import the `IContractDispatcher` and "
"`IContractDispatcherTrait` items in your contract."
msgstr ""
"为了使用调度程序调用其他合约,您需要将被调用合约的接口定义为使用 "
"`#[starknet::interface]` 属性注释的trait,然后将 `IContractDispatcher` 和 "
"`IContractDispatcherTrait` 项导入到合约中。"

#: src/ch00/interacting/calling_other_contracts.md:12
msgid ""
Expand All @@ -2507,6 +2516,28 @@ msgid ""
"}\n"
"```"
msgstr ""
"```rust\n"
"#[starknet::interface]\n"
"trait ICallee<TContractState> {\n"
" fn set_value(ref self: TContractState, value: u128) -> u128;\n"
"}\n"
"\n"
"#[starknet::contract]\n"
"mod Callee {\n"
" #[storage]\n"
" struct Storage {\n"
" value: u128,\n"
" }\n"
"\n"
" #[abi(embed_v0)]\n"
" impl ICalleeImpl of super::ICallee<ContractState> {\n"
" fn set_value(ref self: ContractState, value: u128) -> u128 {\n"
" self.value.write(value);\n"
" value\n"
" }\n"
" }\n"
"}\n"
"```"

#: src/ch00/interacting/calling_other_contracts.md:34
msgid ""
Expand All @@ -2517,6 +2548,12 @@ msgid ""
"blob/main/listings/ch00-getting-started/calling_other_contracts/src/callee."
"cairo)."
msgstr ""
"在 [Voyager](https://goerli.voyager.online/"
"contract/0x015c3Bb6D0DE26b64FEAF9A8f4655CfADb5c128bF4510398972704ee12775DB1) "
"上访问 合约 或在 [Remix](https://remix.ethereum.org/?"
"#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/"
"blob/main/listings/ch00-getting-started/calling_other_contracts/src/callee."
"cairo) 中尝试它。"

#: src/ch00/interacting/calling_other_contracts.md:36
msgid ""
Expand Down Expand Up @@ -2555,6 +2592,40 @@ msgid ""
"}\n"
"```"
msgstr ""
"```rust\n"
"use starknet::ContractAddress;\n"
"\n"
"// We need to have the interface of the callee contract defined\n"
"// so that we can import the Dispatcher.\n"
"#[starknet::interface]\n"
"trait ICallee<TContractState> {\n"
" fn set_value(ref self: TContractState, value: u128) -> u128;\n"
"}\n"
"\n"
"#[starknet::interface]\n"
"trait ICaller<TContractState> {\n"
" fn set_value_from_address(ref self: TContractState, addr: "
"ContractAddress, value: u128);\n"
"}\n"
"\n"
"#[starknet::contract]\n"
"mod Caller {\n"
" // We import the Dispatcher of the called contract\n"
" use super::{ICalleeDispatcher, ICalleeDispatcherTrait};\n"
" use starknet::ContractAddress;\n"
"\n"
" #[storage]\n"
" struct Storage {}\n"
"\n"
" #[abi(embed_v0)]\n"
" impl ICallerImpl of super::ICaller<ContractState> {\n"
" fn set_value_from_address(ref self: ContractState, addr: "
"ContractAddress, value: u128) {\n"
" ICalleeDispatcher { contract_address: addr }.set_value(value);\n"
" }\n"
" }\n"
"}\n"
"```"

#: src/ch00/interacting/calling_other_contracts.md:68
msgid ""
Expand All @@ -2565,27 +2636,36 @@ msgid ""
"blob/main/listings/ch00-getting-started/calling_other_contracts/src/caller."
"cairo)."
msgstr ""
"在 [Voyager](https://goerli.voyager.online/"
"contract/0x05fa8aF796343d2f22c53C17149386b67B7AC4aB52D9e308Aa507C185aA44778) "
"上访问合约或在 [Remix](https://remix.ethereum.org/?"
"#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/"
"blob/main/listings/ch00-getting-started/calling_other_contracts/src/caller."
"cairo) 中尝试它。"

#: src/ch00/interacting/factory.md:1
msgid "# Factory Pattern"
msgstr ""
msgstr "# 工厂模式"

#: src/ch00/interacting/factory.md:3
msgid ""
"The factory pattern is a well known pattern in object oriented programming. "
"It provides an abstraction on how to instantiate a class. "
msgstr ""
"工厂模式是面向对象编程中众所周知的模式。它提供了有关如何实例化类的抽象。"

#: src/ch00/interacting/factory.md:5
msgid ""
"In the case of smart contracts, we can use this pattern by defining a "
"factory contract that have the sole responsibility of creating and managing "
"other contracts."
msgstr ""
"在智能合约里,我们可以通过定义一个工厂合约来使用这种模式,该合约全权负责创建"
"和管理其他合约。"

#: src/ch00/interacting/factory.md:7
msgid "## Class hash and contract instance"
msgstr ""
msgstr "## 类哈希(Class hash)和合约实例"

#: src/ch00/interacting/factory.md:9
msgid ""
Expand All @@ -2595,29 +2675,34 @@ msgid ""
"class is identified by a class hash. When you want to add a new class to the "
"network, you first need to declare it."
msgstr ""
"在Starknet中,合约的类和实例是分开的。合约类充当蓝图,由底层 Cairo 字节码、合"
"约的入口点、ABI 和 Sierra 程序哈希定义。合约类由类哈希标识。当您想向网络添加"
"一个新类时,首先需要声明它。"

#: src/ch00/interacting/factory.md:11
msgid ""
"When deploying a contract, you need to specify the class hash of the "
"contract you want to deploy. Each instance of a contract has their own "
"storage regardless of the class hash."
msgstr ""
"部署合约时,需要指定要部署的合约的类哈希值。合约的每个实例都有自己的存储,这"
"与类哈希无关。"

#: src/ch00/interacting/factory.md:13
msgid ""
"Using the factory pattern, we can deploy multiple instances of the same "
"contract class and handle upgrades easily."
msgstr ""
msgstr "使用工厂模式,我们可以部署同一合约类的多个实例,并轻松处理升级。"

#: src/ch00/interacting/factory.md:15
msgid "## Minimal example"
msgstr ""
msgstr "## 最小范例"

#: src/ch00/interacting/factory.md:17
msgid ""
"Here's a minimal example of a factory contract that deploy the "
"`SimpleCounter` contract:"
msgstr ""
msgstr "下面是部署`SimpleCounter` 合约的工厂合约的最小范例:"

#: src/ch00/interacting/factory.md:19
msgid ""
Expand Down Expand Up @@ -2696,31 +2781,112 @@ msgid ""
"}\n"
"```"
msgstr ""
"```rust\n"
"use starknet::{ContractAddress, ClassHash};\n"
"\n"
"#[starknet::interface]\n"
"trait ICounterFactory<TContractState> {\n"
" /// Create a new counter contract from stored arguments\n"
" fn create_counter(ref self: TContractState) -> ContractAddress;\n"
"\n"
" /// Create a new counter contract from the given arguments\n"
" fn create_counter_at(ref self: TContractState, init_value: u128) -> "
"ContractAddress;\n"
"\n"
" /// Update the argument\n"
" fn update_init_value(ref self: TContractState, init_value: u128);\n"
"\n"
" /// Update the class hash of the Counter contract to deploy when "
"creating a new counter\n"
" fn update_counter_class_hash(ref self: TContractState, "
"counter_class_hash: ClassHash);\n"
"}\n"
"\n"
"#[starknet::contract]\n"
"mod CounterFactory {\n"
" use starknet::{ContractAddress, ClassHash};\n"
" use starknet::syscalls::deploy_syscall;\n"
"\n"
" #[storage]\n"
" struct Storage {\n"
" /// Store the constructor arguments of the contract to deploy\n"
" init_value: u128,\n"
" /// Store the class hash of the contract to deploy\n"
" counter_class_hash: ClassHash,\n"
" }\n"
"\n"
" #[constructor]\n"
" fn constructor(ref self: ContractState, init_value: u128, class_hash: "
"ClassHash) {\n"
" self.init_value.write(init_value);\n"
" self.counter_class_hash.write(class_hash);\n"
" }\n"
"\n"
" #[abi(embed_v0)]\n"
" impl Factory of super::ICounterFactory<ContractState> {\n"
" fn create_counter_at(ref self: ContractState, init_value: u128) -> "
"ContractAddress {\n"
" // Contructor arguments\n"
" let mut constructor_calldata: Array::<felt252> = array!"
"[init_value.into()];\n"
"\n"
" // Contract deployment\n"
" let (deployed_address, _) = deploy_syscall(\n"
" self.counter_class_hash.read(), 0, constructor_calldata."
"span(), false\n"
" )\n"
" .expect('failed to deploy counter');\n"
"\n"
" deployed_address\n"
" }\n"
"\n"
" fn create_counter(ref self: ContractState) -> ContractAddress {\n"
" self.create_counter_at(self.init_value.read())\n"
" }\n"
"\n"
" fn update_init_value(ref self: ContractState, init_value: u128) {\n"
" self.init_value.write(init_value);\n"
" }\n"
"\n"
" fn update_counter_class_hash(ref self: ContractState, "
"counter_class_hash: ClassHash) {\n"
" self.counter_class_hash.write(counter_class_hash);\n"
" }\n"
" }\n"
"}\n"
"```"

#: src/ch00/interacting/factory.md:86
msgid ""
"<!-- This is not ready for \"Open in remix\" because we need multiple files "
"-->"
msgstr ""
"<!-- This is not ready for \"Open in remix\" because we need multiple files "
"-->"

#: src/ch00/interacting/factory.md:88
msgid ""
"This factory can be used to deploy multiple instances of the `SimpleCounter` "
"contract by calling the `create_counter` and `create_counter_at` functions."
msgstr ""
"此工厂可用于通过调用`SimpleCounter`和`create_counter`函数来部署"
"`create_counter_at`合约的多个实例。"

#: src/ch00/interacting/factory.md:90
msgid ""
"The `SimpleCounter` class hash is stored inside the factory, and can be "
"upgraded with the `update_counter_class_hash` function which allows to reuse "
"the same factory contract when the `SimpleCounter` contract is upgraded."
msgstr ""
"`SimpleCounter`类哈希存储在工厂内部,可以使用`update_counter_class_hash` 函数"
"进行升级,该函数允许在升级`SimpleCounter` 合约时重用相同的工厂合约。"

#: src/ch00/interacting/factory.md:92
msgid ""
"This minimal example lacks several useful features such as access control, "
"tracking of deployed contracts, events, ..."
msgstr ""
"这个最小的范例缺少几个有用的功能,例如访问控制、跟踪已部署的合约、事件......"

#: src/ch00/interacting/factory.md:94
msgid ""
Expand All @@ -2729,6 +2895,10 @@ msgid ""
"\n"
"<footer id=\"last-change\">Last change: 2023-10-19</footer>"
msgstr ""
"<!-- TODO maybe add a more complete example at the end of this section or in "
"the `Applications examples` chapter -->\n"
"\n"
"<footer id=\"last-change\">Last change: 2023-10-19</footer>"

#: src/ch00/testing/contract-testing.md:1
msgid "# Contract Testing"
Expand Down

0 comments on commit e746a47

Please sign in to comment.