From 2f7b499cd47596ee62fe0e6abfba1a5e634714be Mon Sep 17 00:00:00 2001 From: cryptonerdcn Date: Thu, 7 Dec 2023 17:00:32 +0900 Subject: [PATCH 1/3] Fix: typos, --- po/zh-cn.po | 120 +++++++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 53 deletions(-) diff --git a/po/zh-cn.po b/po/zh-cn.po index aedc9584..7442b154 100644 --- a/po/zh-cn.po +++ b/po/zh-cn.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: Starknet by Example\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2023-12-05 18:26+0900\n" +"PO-Revision-Date: 2023-12-07 16:56+0900\n" "Last-Translator: StarknetAstro \n" "Language-Team: Language zh-cn\n" "Language: zh_CN\n" @@ -207,14 +207,24 @@ msgstr "" "写可证明的程序,将 zk-STARK 证明系统从程序员手中抽象出来。" #: src/starknet-by-example.md:9 -msgid "The current version of this book use `scarb 2.3.1`" -msgstr "本书当前版本使用 `scarb 2.3.1`" +msgid "The current version of this book use:" +msgstr "本书当前版本使用:" -#: src/starknet-by-example.md:11 +#: src/starknet-by-example.md:10 +msgid "" +"```\n" +"scarb 2.3.1\n" +"```" +msgstr "" +"```\n" +"scarb 2.3.1\n" +"```" + +#: src/starknet-by-example.md:14 msgid "## For whom is this for?" msgstr "## 谁该读这本书?" -#: src/starknet-by-example.md:13 +#: src/starknet-by-example.md:16 msgid "" "Starknet By Example is for anyone who wants to quickly learn how to write " "smart contracts on Starknet using Cairo with some technical background in " @@ -223,7 +233,7 @@ msgstr "" "Starknet By Example适合想要快速学习如何使用 Cairo 在 Starknet 上编写智能合约," "并具有一定编程和区块链技术背景的人。" -#: src/starknet-by-example.md:15 +#: src/starknet-by-example.md:18 msgid "" "The first chapters will give you a basic understanding of the Cairo " "programming language and how to write, deploy and use smart contracts on " @@ -235,11 +245,11 @@ msgstr "" "约。\n" "后面的章节将涉及更高级的主题,并向你展示如何编写更复杂的智能合约。" -#: src/starknet-by-example.md:18 +#: src/starknet-by-example.md:21 msgid "## Further reading" msgstr "## 进一步阅读" -#: src/starknet-by-example.md:20 +#: src/starknet-by-example.md:23 msgid "" "If you want to learn more about the Cairo programming language, you can read " "the [Cairo Book](https://book.cairo-lang.org).\n" @@ -252,11 +262,11 @@ msgstr "" "如果你想进一步了解星网,可以阅读[Starknet documentation](https://docs." "starknet.io/) 和[Starknet Book](https://book.starknet.io/zh-cn/index.html)。" -#: src/starknet-by-example.md:23 +#: src/starknet-by-example.md:26 msgid "Here's a list of other resources that you might find useful:" msgstr "以下是您可能会用到的其他资源清单:" -#: src/starknet-by-example.md:24 +#: src/starknet-by-example.md:27 msgid "" "- [Starklings](https://github.com/shramee/starklings-cairo1): An interactive " "tutorial to get you up and running with Cairo v1 and Starknet \n" @@ -271,13 +281,9 @@ msgstr "" "的博客\n" "- [Cairo by example](https://cairo-by-example.com/):Cairo 简介,附带简单示例" -#: src/starknet-by-example.md:28 -#: src/ch00/interacting/calling_other_contracts.md:69 -#: src/ch00/cairo_cheatsheet/felt.md:15 src/ch00/cairo_cheatsheet/loop.md:23 -#: src/ch00/cairo_cheatsheet/tuples.md:18 -#: src/ch00/cairo_cheatsheet/type_casting.md:33 -msgid "
Last change: 2023-11-30
" -msgstr "
Last change: 2023-11-30
" +#: src/starknet-by-example.md:31 src/ch00/testing/contract-testing.md:176 +msgid "
Last change: 2023-12-06
" +msgstr "
Last change: 2023-12-06
" #: src/ch00/basics/introduction.md:1 msgid "# Basics of Smart Contracts in Cairo" @@ -293,10 +299,9 @@ msgstr "以下章节将向你介绍Starknet智能合约以及如何用Cairo编 #: src/ch00/basics/mappings.md:46 src/ch00/basics/errors.md:139 #: src/ch00/basics/events.md:68 src/ch00/basics/storing-custom-types.md:39 #: src/ch00/basics/custom-types-in-entrypoints.md:39 -#: src/ch00/testing/contract-testing.md:176 src/ch01/upgradeable_contract.md:117 -#: src/ch01/simple_vault.md:114 src/ch02/write_to_any_slot.md:58 -#: src/ch02/storing_arrays.md:105 src/ch02/struct-mapping-key.md:46 -#: src/ch02/optimisations/optimisations.md:5 +#: src/ch01/upgradeable_contract.md:117 src/ch01/simple_vault.md:114 +#: src/ch02/write_to_any_slot.md:58 src/ch02/storing_arrays.md:105 +#: src/ch02/struct-mapping-key.md:46 src/ch02/optimisations/optimisations.md:5 #: src/ch02/optimisations/store_using_packing.md:90 msgid "
Last change: 2023-10-12
" msgstr "
Last change: 2023-10-12
" @@ -749,7 +754,7 @@ msgid "" "returns the address of the current contract." msgstr "" "例如,`get_caller_address`函数返回当前事务的调用者地址,`get_contract_address`" -"函数返回当前合同的地址。" +"函数返回当前合约的地址。" #: src/ch00/basics/variables.md:102 msgid "" @@ -1187,7 +1192,7 @@ msgid "" "important to note that the `LegacyMap` type can only be used inside the " "`Storage` struct of a contract and that it can't be used elsewhere." msgstr "" -"映射是一种键值数据结构,用于在智能合约中存储数据。在开罗,它们使用 " +"映射是一种键值数据结构,用于在智能合约中存储数据。在Cairo,它们使用 " "`LegacyMap` 类型实现。值得注意的是,`LegacyMap`类型只能在合约的 `Storage`结构" "中使用,不能用在其他地方。" @@ -2049,8 +2054,8 @@ msgid "" "purpose and functionality of the contract entry points. You can follow this " "template:" msgstr "" -"在智能合约中,你通常会有一个定义合约接口的trait(带有'#[starknet::" -"interface]')。\n" +"在智能合约中,你通常会有一个定义合约接口的trait(即带有`#[starknet::" +"interface]`)。\n" "这是包含详细文档的理想场所,这些文档解释了合约入口点的用途和功能。您可以遵循以" "下模板:" @@ -2139,8 +2144,8 @@ msgid "" "html)." msgstr "" "合约接口定义合约的结构和行为,充当合约的公共 ABI。它们列出了合约公开的所有函数" -"签名。接口的详细说明可以参考 [Cairo之书](https://book.cairo-lang.org/" -"ch99-01-02-a-simple-contract.html)。" +"签名。接口的详细说明可以参考 [Cairo之书](https://book.cairo-lang.org/" +"ch99-01-02-a-simple-contract.html)。" #: src/ch00/interacting/interfaces-traits.md:5 msgid "" @@ -2653,6 +2658,13 @@ msgstr "" "blob/main/listings/ch00-getting-started/calling_other_contracts/src/caller." "cairo) 中尝试它。" +#: src/ch00/interacting/calling_other_contracts.md:69 +#: src/ch00/cairo_cheatsheet/felt.md:15 src/ch00/cairo_cheatsheet/loop.md:23 +#: src/ch00/cairo_cheatsheet/tuples.md:18 +#: src/ch00/cairo_cheatsheet/type_casting.md:33 +msgid "
Last change: 2023-11-30
" +msgstr "
Last change: 2023-11-30
" + #: src/ch00/interacting/factory.md:1 msgid "# Factory Pattern" msgstr "# 工厂模式" @@ -3028,7 +3040,7 @@ msgid "" "mod tests {\n" " // Import the interface and dispatcher to be able to interact with the " "contract.\n" -" use sbe_testing::contract::{\n" +" use testing_how_to::contract::{\n" " ISimpleContract, SimpleContract, ISimpleContractDispatcher, " "ISimpleContractDispatcherTrait\n" " };\n" @@ -3114,13 +3126,14 @@ msgstr "" "```rust\n" "#[cfg(test)]\n" "mod tests {\n" -" // 导入接口和调度器,以便能够与合约进行交互\n" -" use sbe_testing::contract::{\n" +" // Import the interface and dispatcher to be able to interact with the " +"contract.\n" +" use testing_how_to::contract::{\n" " ISimpleContract, SimpleContract, ISimpleContractDispatcher, " "ISimpleContractDispatcherTrait\n" " };\n" "\n" -" //导入部署 deploy_syscall,以便能够部署合约\n" +" // Import the deploy syscall to be able to deploy the contract.\n" " use starknet::class_hash::Felt252TryIntoClassHash;\n" " use starknet::{\n" " deploy_syscall, ContractAddress, get_caller_address, " @@ -3128,24 +3141,25 @@ msgstr "" " contract_address_const\n" " };\n" "\n" -" // 使用 starknet 测试工具来模拟上下文交易\n" +" // Use starknet test utils to fake the transaction context.\n" " use starknet::testing::{set_caller_address, set_contract_address};\n" "\n" -" // 部署合约并返回其调度器\n" +" // Deploy the contract and return its dispatcher.\n" " fn deploy(initial_value: u32) -> ISimpleContractDispatcher {\n" " // Set up constructor arguments.\n" " let mut calldata = ArrayTrait::new();\n" " initial_value.serialize(ref calldata);\n" "\n" -" // 声明并部署合约\n" +" // Declare and deploy\n" " let (contract_address, _) = deploy_syscall(\n" " SimpleContract::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata." "span(), false\n" " )\n" " .unwrap();\n" "\n" -" // 返回调度器\n" -" // 调度器允许根据合约的接口与其进行交互\n" +" // Return the dispatcher.\n" +" // The dispatcher allows to interact with the contract based on its " +"interface.\n" " ISimpleContractDispatcher { contract_address }\n" " }\n" "\n" @@ -3155,28 +3169,28 @@ msgstr "" " let initial_value: u32 = 10;\n" " let contract = deploy(initial_value);\n" "\n" -" assert(contract.get_value() == initial_value, ‘wrong initial " -"value’);\n" -" assert(contract.get_owner() == get_contract_address(), ‘wrong " -"owner’);\n" +" assert(contract.get_value() == initial_value, 'wrong initial " +"value');\n" +" assert(contract.get_owner() == get_contract_address(), 'wrong " +"owner');\n" " }\n" "\n" " #[test]\n" " #[available_gas(2000000000)]\n" " fn test_set_as_owner() {\n" -" // 将调用者地址设置为地址1\n" +" // Fake the caller address to address 1\n" " let owner = contract_address_const::<1>();\n" " set_contract_address(owner);\n" "\n" " let contract = deploy(10);\n" -" assert(contract.get_owner() == owner, ‘wrong owner’);\n" +" assert(contract.get_owner() == owner, 'wrong owner');\n" "\n" -" // 将合约地址设置为地址1\n" +" // Fake the contract address to address 1\n" " set_contract_address(owner);\n" " let new_value: u32 = 20;\n" " contract.set_value(new_value);\n" "\n" -" assert(contract.get_value() == new_value, ‘wrong value’);\n" +" assert(contract.get_value() == new_value, 'wrong value');\n" " }\n" "\n" " #[test]\n" @@ -3201,11 +3215,11 @@ msgstr "" msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/testing/src/lib.cairo)." +"blob/main/listings/ch00-getting-started/testing_how_to/src/lib.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." "com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" -"testing/src/lib.cairo) 中与这个合约进行互动。" +"testing_how_to/src/lib.cairo) 中与这个合约进行互动。" #: src/ch00/testing/contract-testing.md:134 msgid "" @@ -3610,15 +3624,15 @@ msgstr "" " arr.append(20);\n" " arr.append(30);\n" "\n" -" assert(arr.len() == 3, ‘array length should be 3’);\n" +" assert(arr.len() == 3, 'array length should be 3');\n" "\n" " let first_value = arr.pop_front().unwrap();\n" -" assert(first_value == 10, ‘first value should match’);\n" +" assert(first_value == 10, 'first value should match');\n" "\n" " let second_value = *arr.at(0);\n" -" assert(second_value == 20, ‘second value should match’);\n" +" assert(second_value == 20, 'second value should match');\n" "\n" -" // 如果数组为空,返回 true;如果不为空,返回 false。\n" +" // Returns true if an array is empty, then false if it isn't.\n" " arr.is_empty()\n" "}\n" "```" @@ -6357,9 +6371,9 @@ msgid "" "felt value. This is done by using the bits of the felt value to store " "multiple values." msgstr "" -"当存储多个值时,我们可以使用一种称为**打包(packing)**的技术。打包是一种允许我" -"们在单个 felt 值中存储多个值的技术。这是通过使用 felt 值的位来存储多个值来实现" -"的。" +"当存储多个值时,我们可以使用一种称为 **打包(packing)** 的技术。打包是一种允许" +"我们在单个 felt 值中存储多个值的技术。这是通过使用 felt 值的位来存储多个值来实" +"现的。" #: src/ch02/optimisations/store_using_packing.md:13 msgid "" From fb6af205e7735a4a193ef8f480ac11e1fad44bc8 Mon Sep 17 00:00:00 2001 From: cryptonerdcn Date: Fri, 8 Dec 2023 14:39:27 +0900 Subject: [PATCH 2/3] New po file. --- po/zh-cn.po | 1147 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 711 insertions(+), 436 deletions(-) diff --git a/po/zh-cn.po b/po/zh-cn.po index 7442b154..af3218e9 100644 --- a/po/zh-cn.po +++ b/po/zh-cn.po @@ -124,55 +124,64 @@ msgstr "结构体" msgid "Type casting" msgstr "类型转换" +#: src/SUMMARY.md:35 +msgid "Components" +msgstr "" + #: src/SUMMARY.md:36 -msgid "Applications examples" +msgid "Components How-To" +msgstr "" + +#: src/SUMMARY.md:39 +#, fuzzy +msgid "Applications" msgstr "应用实例" -#: src/SUMMARY.md:37 +#: src/SUMMARY.md:40 msgid "Upgradeable Contract" msgstr "可升级合约" -#: src/SUMMARY.md:38 +#: src/SUMMARY.md:41 msgid "Defi Vault" msgstr "Defi Vault" -#: src/SUMMARY.md:39 +#: src/SUMMARY.md:42 msgid "ERC20 Token" msgstr "ERC20 代币" -#: src/SUMMARY.md:40 +#: src/SUMMARY.md:43 msgid "Constant Product AMM" msgstr "恒定产品 AMM" -#: src/SUMMARY.md:43 +#: src/SUMMARY.md:46 msgid "Advanced concepts" msgstr "高级概念" -#: src/SUMMARY.md:44 +#: src/SUMMARY.md:47 msgid "Writing to any storage slot" msgstr "写入任何存储槽" -#: src/SUMMARY.md:45 +#: src/SUMMARY.md:48 msgid "Storing Arrays" msgstr "存储数组" -#: src/SUMMARY.md:46 +#: src/SUMMARY.md:49 msgid "Struct as mapping key" msgstr "结构体作为映射键" -#: src/SUMMARY.md:47 +#: src/SUMMARY.md:50 msgid "Hash Solidity Compatible" msgstr "兼容Hash Solidity" -#: src/SUMMARY.md:48 +#: src/SUMMARY.md:51 msgid "Optimisations" msgstr "优化" -#: src/SUMMARY.md:49 +#: src/SUMMARY.md:52 msgid "Storage Optimisations" msgstr "存储优化" -#: src/SUMMARY.md:50 +#: src/SUMMARY.md:53 msgid "List" msgstr "列表" @@ -185,7 +194,8 @@ msgid "" "Starknet By Example is a collection of examples of how to use the Cairo " "programming language to create smart contracts on Starknet." msgstr "" -"Starknet By Example是如何使用Cairo编程语言在Starknet上创建智能合约的范例集。\n" +"Starknet By Example是如何使用Cairo编程语言在Starknet上创建智能合约的范例" +"集。\n" "中文版由 [StarknetAstro](https://twitter.com/StarkNetAstroCN) 社区翻译。" #: src/starknet-by-example.md:5 @@ -199,12 +209,12 @@ msgstr "" #: src/starknet-by-example.md:7 msgid "" -"Starknet smart contracts are written in the Cairo language. Cairo is a Turing-" -"complete programming language designed to write provable programs, " +"Starknet smart contracts are written in the Cairo language. Cairo is a " +"Turing-complete programming language designed to write provable programs, " "abstracting the zk-STARK proof system away from the programmer." msgstr "" -"Starknet智能合约是用Cairo语言编写的。Cairo语言是一种图灵完备的编程语言,旨在编" -"写可证明的程序,将 zk-STARK 证明系统从程序员手中抽象出来。" +"Starknet智能合约是用Cairo语言编写的。Cairo语言是一种图灵完备的编程语言,旨在" +"编写可证明的程序,将 zk-STARK 证明系统从程序员手中抽象出来。" #: src/starknet-by-example.md:9 msgid "The current version of this book use:" @@ -221,19 +231,27 @@ msgstr "" "```" #: src/starknet-by-example.md:14 +msgid "" +"> ⚠️ The examples have not been audited and are not intended for production " +"use.\n" +"> The authors are not responsible for any damages caused by the use of the " +"code provided in this book." +msgstr "" + +#: src/starknet-by-example.md:17 msgid "## For whom is this for?" msgstr "## 谁该读这本书?" -#: src/starknet-by-example.md:16 +#: src/starknet-by-example.md:19 msgid "" "Starknet By Example is for anyone who wants to quickly learn how to write " "smart contracts on Starknet using Cairo with some technical background in " "programming and blockchain." msgstr "" -"Starknet By Example适合想要快速学习如何使用 Cairo 在 Starknet 上编写智能合约," -"并具有一定编程和区块链技术背景的人。" +"Starknet By Example适合想要快速学习如何使用 Cairo 在 Starknet 上编写智能合" +"约,并具有一定编程和区块链技术背景的人。" -#: src/starknet-by-example.md:18 +#: src/starknet-by-example.md:21 msgid "" "The first chapters will give you a basic understanding of the Cairo " "programming language and how to write, deploy and use smart contracts on " @@ -245,11 +263,11 @@ msgstr "" "约。\n" "后面的章节将涉及更高级的主题,并向你展示如何编写更复杂的智能合约。" -#: src/starknet-by-example.md:21 +#: src/starknet-by-example.md:24 msgid "## Further reading" msgstr "## 进一步阅读" -#: src/starknet-by-example.md:23 +#: src/starknet-by-example.md:26 msgid "" "If you want to learn more about the Cairo programming language, you can read " "the [Cairo Book](https://book.cairo-lang.org).\n" @@ -262,27 +280,33 @@ msgstr "" "如果你想进一步了解星网,可以阅读[Starknet documentation](https://docs." "starknet.io/) 和[Starknet Book](https://book.starknet.io/zh-cn/index.html)。" -#: src/starknet-by-example.md:26 -msgid "Here's a list of other resources that you might find useful:" -msgstr "以下是您可能会用到的其他资源清单:" - -#: src/starknet-by-example.md:27 -msgid "" -"- [Starklings](https://github.com/shramee/starklings-cairo1): An interactive " -"tutorial to get you up and running with Cairo v1 and Starknet \n" -"- [Cairopractice](https://cairopractice.com/): A blog with a series of " -"articles about Cairo and Starknet\n" -"- [Cairo by example](https://cairo-by-example.com/): An introduction to " -"Cairo, with simple examples" -msgstr "" -"- [Starklings](https://github.com/shramee/starklings-cairo1):让您使用 Cairo " -"v1 和Starknet互动的教程\n" -"- [Cairopractice](https://cairopractice.com/):关于Cairo和Starknet的一系列文章" -"的博客\n" -"- [Cairo by example](https://cairo-by-example.com/):Cairo 简介,附带简单示例" - -#: src/starknet-by-example.md:31 src/ch00/testing/contract-testing.md:176 -msgid "
Last change: 2023-12-06
" +#: src/starknet-by-example.md:29 +msgid "" +"For more resources, check [Awesome Starknet](https://github.com/keep-" +"starknet-strange/awesome-starknet)." +msgstr "" + +#: src/starknet-by-example.md:31 src/ch00/basics/storage.md:34 +#: src/ch00/basics/constructor.md:27 src/ch00/basics/variables.md:126 +#: src/ch00/basics/visibility-mutability.md:75 src/ch00/basics/counter.md:56 +#: src/ch00/basics/mappings.md:46 src/ch00/basics/errors.md:139 +#: src/ch00/basics/events.md:68 src/ch00/basics/storing-custom-types.md:39 +#: src/ch00/basics/custom-types-in-entrypoints.md:39 +#: src/ch00/interacting/interfaces-traits.md:129 +#: src/ch00/interacting/calling_other_contracts.md:69 +#: src/ch00/testing/contract-testing.md:176 +#: src/ch00/cairo_cheatsheet/felt.md:15 src/ch00/cairo_cheatsheet/mapping.md:58 +#: src/ch00/cairo_cheatsheet/arrays.md:42 src/ch00/cairo_cheatsheet/loop.md:23 +#: src/ch00/cairo_cheatsheet/match.md:59 src/ch00/cairo_cheatsheet/tuples.md:18 +#: src/ch00/cairo_cheatsheet/struct.md:15 +#: src/ch00/cairo_cheatsheet/type_casting.md:33 src/components/how_to.md:114 +#: src/ch01/upgradeable_contract.md:117 src/ch01/simple_vault.md:114 +#: src/ch01/erc20.md:228 src/ch01/constant-product-amm.md:275 +#: src/ch02/write_to_any_slot.md:58 src/ch02/storing_arrays.md:105 +#: src/ch02/struct-mapping-key.md:46 src/ch02/hash-solidity-compatible.md:46 +#: src/ch02/optimisations/store_using_packing.md:90 src/ch02/list.md:139 +#, fuzzy +msgid "
Last change: 2023-12-07
" msgstr "
Last change: 2023-12-06
" #: src/ch00/basics/introduction.md:1 @@ -291,18 +315,11 @@ msgstr "# Cairo的智能合约基础知识" #: src/ch00/basics/introduction.md:3 msgid "" -"The following chapters will introduce you to Starknet smart contracts and how " -"to write them in Cairo." +"The following chapters will introduce you to Starknet smart contracts and " +"how to write them in Cairo." msgstr "以下章节将向你介绍Starknet智能合约以及如何用Cairo编写这些合约。" -#: src/ch00/basics/introduction.md:5 src/ch00/basics/constructor.md:27 -#: src/ch00/basics/mappings.md:46 src/ch00/basics/errors.md:139 -#: src/ch00/basics/events.md:68 src/ch00/basics/storing-custom-types.md:39 -#: src/ch00/basics/custom-types-in-entrypoints.md:39 -#: src/ch01/upgradeable_contract.md:117 src/ch01/simple_vault.md:114 -#: src/ch02/write_to_any_slot.md:58 src/ch02/storing_arrays.md:105 -#: src/ch02/struct-mapping-key.md:46 src/ch02/optimisations/optimisations.md:5 -#: src/ch02/optimisations/store_using_packing.md:90 +#: src/ch00/basics/introduction.md:5 src/ch02/optimisations/optimisations.md:5 msgid "
Last change: 2023-10-12
" msgstr "
Last change: 2023-10-12
" @@ -336,8 +353,8 @@ msgstr "" msgid "" "Storage is a struct annoted with `#[storage]`. Every contract must have one " "and only one storage.\n" -"It's a key-value store, where each key will be mapped to a storage address of " -"the contract's storage space." +"It's a key-value store, where each key will be mapped to a storage address " +"of the contract's storage space." msgstr "" "存储是一个结构体,用 `#[storage]`标注。每个合约必须有且仅有一个存储空间。\n" "它是一个键值存储空间,其中每个键都将映射到合约存储空间的存储地址。" @@ -390,11 +407,6 @@ msgid "" "You can also read about [storing custom types](./storing-custom-types.md)" msgstr "您还可以阅读有关 [存储自定义类型](./storing-custom-types.md) 的内容。" -#: src/ch00/basics/storage.md:34 src/ch00/basics/variables.md:126 -#: src/ch01/constant-product-amm.md:275 -msgid "
Last change: 2023-11-20
" -msgstr "
Last change: 2023-11-20
" - #: src/ch00/basics/constructor.md:1 msgid "# Constructor" msgstr "# 构造函数" @@ -407,17 +419,17 @@ msgid "" "constructor function must be annotated with the `#[constructor]` attribute. " "Also, a good practice consists in naming that function `constructor`." msgstr "" -"构造函数是一种特殊类型的函数,只在部署合约时运行一次,可用于初始化合约的状态。" -"你的合约不能有一个以上的构造函数,而且构造函数必须使用 `#[constructor]` 属性注" -"释。此外,一个好的做法是将该函数命名为 `constructor`。" +"构造函数是一种特殊类型的函数,只在部署合约时运行一次,可用于初始化合约的状" +"态。你的合约不能有一个以上的构造函数,而且构造函数必须使用 `#[constructor]` " +"属性注释。此外,一个好的做法是将该函数命名为 `constructor`。" #: src/ch00/basics/constructor.md:5 msgid "" "Here's a simple example that demonstrates how to initialize the state of a " "contract on deployment by defining logic inside a constructor." msgstr "" -"下面是一个简单的示例,演示如何通过在构造函数中定义逻辑,在部署时初始化合约的状" -"态。" +"下面是一个简单的示例,演示如何通过在构造函数中定义逻辑,在部署时初始化合约的" +"状态。" #: src/ch00/basics/constructor.md:7 msgid "" @@ -462,12 +474,13 @@ msgstr "" "```" #: src/ch00/basics/constructor.md:25 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x017fd6558e67451dA583d123D77F4e2651E91502D08F8F8432355293b11e1f8F) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/constructor/src/constructor.cairo)." +"blob/main/listings/getting-started/constructor/src/constructor.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" "contract/0x017fd6558e67451dA583d123D77F4e2651E91502D08F8F8432355293b11e1f8F) " @@ -512,12 +525,12 @@ msgstr "## 局部变量" #: src/ch00/basics/variables.md:17 msgid "" -"Local variables are used and accessed within the scope of a specific function " -"or block of code. They are temporary and exist only for the duration of that " -"particular function or block execution." +"Local variables are used and accessed within the scope of a specific " +"function or block of code. They are temporary and exist only for the " +"duration of that particular function or block execution." msgstr "" -"局部变量在特定函数或代码块的范围内使用和访问。它们是临时的,只在特定函数或代码" -"块执行期间存在。" +"局部变量在特定函数或代码块的范围内使用和访问。它们是临时的,只在特定函数或代" +"码块执行期间存在。" #: src/ch00/basics/variables.md:19 msgid "" @@ -527,9 +540,9 @@ msgid "" "a specific context. They also make the code more readable by giving names to " "intermediate values." msgstr "" -"局部变量存储在内存中,不会存储在区块链上。这就意味着在执行过程中无法访问它们。" -"局部变量可用于存储仅在特定上下文中相关的临时数据。通过为中间值命名,它们还能使" -"代码更具可读性。" +"局部变量存储在内存中,不会存储在区块链上。这就意味着在执行过程中无法访问它" +"们。局部变量可用于存储仅在特定上下文中相关的临时数据。通过为中间值命名,它们" +"还能使代码更具可读性。" #: src/ch00/basics/variables.md:21 msgid "Here's a simple example of a contract with only local variables:" @@ -600,12 +613,13 @@ msgstr "" "```" #: src/ch00/basics/variables.md:50 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x015B3a10F9689BeD741Ca3C210017BC097122CeF76f3cAA191A20ff8b9b56b96) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/variables/src/local_variables.cairo)." +"blob/main/listings/getting-started/variables/src/local_variables.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" "contract/0x015B3a10F9689BeD741Ca3C210017BC097122CeF76f3cAA191A20ff8b9b56b96) " @@ -621,16 +635,16 @@ msgstr "## 存储用变量" #: src/ch00/basics/variables.md:54 msgid "" "Storage variables are persistent data stored on the blockchain. They can be " -"accessed from one execution to another, allowing the contract to remember and " -"update information over time." +"accessed from one execution to another, allowing the contract to remember " +"and update information over time." msgstr "" -"存储变量是存储在区块链上的持久数据。它们可以在不同的执行过程中被访问,从而使合" -"约能够保存和更新信息。" +"存储变量是存储在区块链上的持久数据。它们可以在不同的执行过程中被访问,从而使" +"合约能够保存和更新信息。" #: src/ch00/basics/variables.md:56 msgid "" -"To write or update a storage variable, you need to interact with the contract " -"through an external entrypoint by sending a transaction." +"To write or update a storage variable, you need to interact with the " +"contract through an external entrypoint by sending a transaction." msgstr "要写入或更新存储变量,需要通过外部入口点发送交易与合约交互。" #: src/ch00/basics/variables.md:58 @@ -712,13 +726,13 @@ msgstr "" "```" #: src/ch00/basics/variables.md:92 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x06eA827B32875483709b785A7F9e846a52776Cd8D42C3fE696218c2624b0DCCa) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/variables/src/storage_variables." -"cairo)." +"blob/main/listings/getting-started/variables/src/storage_variables.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" "contract/0x06eA827B32875483709b785A7F9e846a52776Cd8D42C3fE696218c2624b0DCCa) " @@ -734,11 +748,11 @@ msgstr "## 全局变量" #: src/ch00/basics/variables.md:96 msgid "" "Global variables are predefined variables that provide information about the " -"blockchain and the current execution environment. They can be accessed at any " -"time and from anywhere!" +"blockchain and the current execution environment. They can be accessed at " +"any time and from anywhere!" msgstr "" -"全局变量是预定义变量,可提供有关区块链和当前执行环境的信息。可以随时随地访问它" -"们!" +"全局变量是预定义变量,可提供有关区块链和当前执行环境的信息。可以随时随地访问" +"它们!" #: src/ch00/basics/variables.md:98 msgid "" @@ -753,8 +767,8 @@ msgid "" "caller of the current transaction, and the `get_contract_address` function " "returns the address of the current contract." msgstr "" -"例如,`get_caller_address`函数返回当前事务的调用者地址,`get_contract_address`" -"函数返回当前合约的地址。" +"例如,`get_caller_address`函数返回当前事务的调用者地址," +"`get_contract_address`函数返回当前合约的地址。" #: src/ch00/basics/variables.md:102 msgid "" @@ -809,19 +823,20 @@ msgstr "" "```" #: src/ch00/basics/variables.md:125 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x05bD2F3943bd4e030f85678b55b2EC2C1be939e32388530FB20ED967B3Be433F) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/variables/src/global_variables.cairo)." +"blob/main/listings/getting-started/variables/src/global_variables.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" "contract/0x05bD2F3943bd4e030f85678b55b2EC2C1be939e32388530FB20ED967B3Be433F) " "上的合约,或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/variables/src/global_variables.cairo) " -"中尝试它。" +"blob/main/listings/ch00-getting-started/variables/src/global_variables." +"cairo) 中尝试它。" #: src/ch00/basics/visibility-mutability.md:1 msgid "# Visibility and Mutability" @@ -846,18 +861,18 @@ msgstr "" #: src/ch00/basics/visibility-mutability.md:10 msgid "" -"These functions are also typically divided into two different implementations " -"blocks. The first `impl` block for externally accessible functions is " -"explicitly annotated with an `#[abi(embed_v0)]` attribute. This indicates " -"that all the functions inside this block can be called either as a " +"These functions are also typically divided into two different " +"implementations blocks. The first `impl` block for externally accessible " +"functions is explicitly annotated with an `#[abi(embed_v0)]` attribute. This " +"indicates that all the functions inside this block can be called either as a " "transaction or as a view function. The second `impl` block for internally " "accessible functions is not annotated with any attribute, which means that " "all the functions inside this block are private by default." msgstr "" -"这些函数通常也分为两个不同的实现块。第一个`impl`块用于外部访问的函数,明确标注" -"了 `#[abi(embed_v0)]`属性。这表明该代码块中的所有函数都可以作为交易或视图函数" -"调用。第二个用于内部可访问函数的 `impl` 块没有注释任何属性,这意味着该块中的所" -"有函数默认都是私有的。" +"这些函数通常也分为两个不同的实现块。第一个`impl`块用于外部访问的函数,明确标" +"注了 `#[abi(embed_v0)]`属性。这表明该代码块中的所有函数都可以作为交易或视图函" +"数调用。第二个用于内部可访问函数的 `impl` 块没有注释任何属性,这意味着该块中" +"的所有函数默认都是私有的。" #: src/ch00/basics/visibility-mutability.md:12 msgid "## State Mutability" @@ -872,8 +887,8 @@ msgid "" "adding it as the first parameter of the function. This can be done in two " "different ways:" msgstr "" -"无论函数是内部函数还是外部函数,它都可以修改或不修改合约的状态。当我们在智能合" -"约中声明与存储变量交互的函数时,\n" +"无论函数是内部函数还是外部函数,它都可以修改或不修改合约的状态。当我们在智能" +"合约中声明与存储变量交互的函数时,\n" "我们需要将 `ContractState`添加为函数的第一个参数,明确说明我们正在访问 合约的" "状态。这有两种不同的方法:" @@ -903,8 +918,8 @@ msgstr "" #: src/ch00/basics/visibility-mutability.md:23 msgid "" -"Internal functions can't be called externally, but the same principle applies " -"regarding state mutability." +"Internal functions can't be called externally, but the same principle " +"applies regarding state mutability." msgstr "内部函数不能被外部调用,同样的原则也适用于状态可变性。" #: src/ch00/basics/visibility-mutability.md:25 @@ -928,8 +943,8 @@ msgid "" " }\n" "\n" "\n" -" // The `abi(embed_v0)` attribute indicates that all the functions in this " -"implementation can be called externally.\n" +" // The `abi(embed_v0)` attribute indicates that all the functions in " +"this implementation can be called externally.\n" " // Omitting this attribute would make all the functions in this " "implementation internal.\n" " #[abi(embed_v0)]\n" @@ -947,8 +962,8 @@ msgid "" " // However, it can't modify the contract's state is passed as a " "snapshot: it is only a \"view\" function.\n" " fn get(self: @ContractState) -> u32 {\n" -" // We can call an internal function from any functions within the " -"contract\n" +" // We can call an internal function from any functions within " +"the contract\n" " PrivateFunctionsTrait::_read_value(self)\n" " }\n" " }\n" @@ -986,8 +1001,8 @@ msgstr "" " }\n" "\n" "\n" -" // The `abi(embed_v0)` attribute indicates that all the functions in this " -"implementation can be called externally.\n" +" // The `abi(embed_v0)` attribute indicates that all the functions in " +"this implementation can be called externally.\n" " // Omitting this attribute would make all the functions in this " "implementation internal.\n" " #[abi(embed_v0)]\n" @@ -1005,8 +1020,8 @@ msgstr "" " // However, it can't modify the contract's state is passed as a " "snapshot: it is only a \"view\" function.\n" " fn get(self: @ContractState) -> u32 {\n" -" // We can call an internal function from any functions within the " -"contract\n" +" // We can call an internal function from any functions within " +"the contract\n" " PrivateFunctionsTrait::_read_value(self)\n" " }\n" " }\n" @@ -1030,12 +1045,13 @@ msgstr "" "```" #: src/ch00/basics/visibility-mutability.md:73 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x0071dE3093AB58053b0292C225aa0eED40293e7694A0042685FF6D813d39889F) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/visibility/src/visibility.cairo)." +"blob/main/listings/getting-started/visibility/src/visibility.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" "contract/0x0071dE3093AB58053b0292C225aa0eED40293e7694A0042685FF6D813d39889F) " @@ -1044,11 +1060,6 @@ msgstr "" "blob/main/listings/ch00-getting-started/visibility/src/visibility.cairo) 中尝" "试它。" -#: src/ch00/basics/visibility-mutability.md:75 -#: src/ch00/interacting/interacting.md:4 -msgid "
Last change: 2023-10-19
" -msgstr "
Last change: 2023-10-19
" - #: src/ch00/basics/counter.md:1 msgid "# Simple Counter" msgstr "# 简单计数器" @@ -1163,12 +1174,13 @@ msgstr "" "```" #: src/ch00/basics/counter.md:54 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x01664a69Fe701a1df7Bb0ae4A353792d0cf4E27146ee860075cbf6108b1D5718) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/counter/src/contracts.cairo)." +"blob/main/listings/getting-started/counter/src/contracts.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" "contract/0x01664a69Fe701a1df7Bb0ae4A353792d0cf4E27146ee860075cbf6108b1D5718) " @@ -1177,10 +1189,6 @@ msgstr "" "blob/main/listings/ch00-getting-started/counter/src/contracts.cairo) 中尝试" "它。" -#: src/ch00/basics/counter.md:56 -msgid "
Last change: 2023-11-04
" -msgstr "
Last change: 2023-11-04
" - #: src/ch00/basics/mappings.md:1 msgid "# Mappings" msgstr "# 映射" @@ -1200,8 +1208,8 @@ msgstr "" msgid "" "Here we demonstrate how to use the `LegacyMap` type within a Cairo contract, " "to map between a key of type `ContractAddress` and value of type `felt252`. " -"The key-value types are specified within angular brackets <>. We write to the " -"map by calling the `write()` method, passing in both the key and value. " +"The key-value types are specified within angular brackets <>. We write to " +"the map by calling the `write()` method, passing in both the key and value. " "Similarly, we can read the value associated with a given key by calling the " "`read()` method and passing in the relevant key." msgstr "" @@ -1222,19 +1230,19 @@ msgid "" "\n" "- In mappings, the address of the value at key `k_1,...,k_n` is `h(..." "h(h(sn_keccak(variable_name),k_1),k_2),...,k_n)` where `ℎ` is the Pedersen " -"hash and the final value is taken `mod2251−256`. You can learn more about the " -"contract storage layout in the [Starknet Documentation](https://docs.starknet." -"io/documentation/architecture_and_concepts/Contracts/contract-storage/" -"#storage_variables)" +"hash and the final value is taken `mod2251−256`. You can learn more about " +"the contract storage layout in the [Starknet Documentation](https://docs." +"starknet.io/documentation/architecture_and_concepts/Contracts/contract-" +"storage/#storage_variables)" msgstr "" "- 也有更复杂的键值对映射,例如,我们可以使用 `LegacyMap::<(ContractAddress, " "ContractAddress), felt252>` 在 ERC20 代币合约上创建一个代币授权许可。\n" "\n" "- 在映射中,键`k_1,...,k_n`处的值的地址是`h(...h(h(sn_keccak(variable_name)," "k_1),k_2),...,k_n)`,其中 `ℎ` 是 Pedersen 哈希值,最终值取`mod2251-256`。有关" -"合约存储布局的更多信息,请参阅 [Starknet Documentation](https://docs.starknet." -"io/documentation/architecture_and_concepts/Contracts/contract-storage/" -"#storage_variables)。" +"合约存储布局的更多信息,请参阅 [Starknet Documentation](https://docs." +"starknet.io/documentation/architecture_and_concepts/Contracts/contract-" +"storage/#storage_variables)。" #: src/ch00/basics/mappings.md:13 msgid "" @@ -1260,8 +1268,8 @@ msgid "" "\n" " #[abi(embed_v0)]\n" " impl MapContractImpl of super::IMapContract {\n" -" fn set(ref self: ContractState, key: ContractAddress, value: felt252) " -"{\n" +" fn set(ref self: ContractState, key: ContractAddress, value: " +"felt252) {\n" " self.map.write(key, value);\n" " }\n" "\n" @@ -1294,8 +1302,8 @@ msgstr "" "\n" " #[abi(embed_v0)]\n" " impl MapContractImpl of super::IMapContract {\n" -" fn set(ref self: ContractState, key: ContractAddress, value: felt252) " -"{\n" +" fn set(ref self: ContractState, key: ContractAddress, value: " +"felt252) {\n" " self.map.write(key, value);\n" " }\n" "\n" @@ -1307,12 +1315,13 @@ msgstr "" "```" #: src/ch00/basics/mappings.md:44 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x06214AB4c23Cc545bf2221D465eB83aFb7412779AD498BD48a724B3F645E3505) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/mappings/src/mappings.cairo)." +"blob/main/listings/getting-started/mappings/src/mappings.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" "contract/0x06214AB4c23Cc545bf2221D465eB83aFb7412779AD498BD48a724B3F645E3505) " @@ -1330,11 +1339,12 @@ msgid "" "Errors can be used to handle validation and other conditions that may occur " "during the execution of a smart contract.\n" "If an error is thrown during the execution of a smart contract call, the " -"execution is stopped and any changes made during the transaction are reverted." +"execution is stopped and any changes made during the transaction are " +"reverted." msgstr "" "错误可用于处理智能合约执行过程中可能发生的验证和其他条件。\n" -"如果在执行智能合约调用期间抛出错误,则将停止执行,并恢复在交易期间所做的任何更" -"改。" +"如果在执行智能合约调用期间抛出错误,则将停止执行,并恢复在交易期间所做的任何" +"更改。" #: src/ch00/basics/errors.md:6 msgid "To throw an error, use the `assert` or `panic` functions:" @@ -1427,19 +1437,20 @@ msgstr "" "```" #: src/ch00/basics/errors.md:46 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x0022664463FF0b711CC9B549a9E87d65A0882bB1D29338C4108696B8F2216a40) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/errors/src/simple_errors.cairo)." +"blob/main/listings/getting-started/errors/src/simple_errors.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" "contract/0x0022664463FF0b711CC9B549a9E87d65A0882bB1D29338C4108696B8F2216a40) " "上访问合约或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/errors/src/simple_errors.cairo) 中尝试" -"它。" +"blob/main/listings/ch00-getting-started/errors/src/simple_errors.cairo) 中尝" +"试它。" #: src/ch00/basics/errors.md:48 msgid "## Custom errors" @@ -1447,8 +1458,8 @@ msgstr "## 自定义错误" #: src/ch00/basics/errors.md:50 msgid "" -"You can make error handling easier by defining your error codes in a specific " -"module." +"You can make error handling easier by defining your error codes in a " +"specific module." msgstr "您可以通过在特定模块中定义错误代码来简化错误处理。" #: src/ch00/basics/errors.md:52 @@ -1473,7 +1484,8 @@ msgid "" " struct Storage {}\n" "\n" " #[abi(embed_v0)]\n" -" impl CustomErrorsExample of super::ICustomErrorsExample {\n" +" impl CustomErrorsExample of super::ICustomErrorsExample " +"{\n" " fn test_assert(self: @ContractState, i: u256) {\n" " assert(i > 0, Errors::NOT_POSITIVE);\n" " }\n" @@ -1507,7 +1519,8 @@ msgstr "" " struct Storage {}\n" "\n" " #[abi(embed_v0)]\n" -" impl CustomErrorsExample of super::ICustomErrorsExample {\n" +" impl CustomErrorsExample of super::ICustomErrorsExample " +"{\n" " fn test_assert(self: @ContractState, i: u256) {\n" " assert(i > 0, Errors::NOT_POSITIVE);\n" " }\n" @@ -1522,19 +1535,20 @@ msgstr "" "```" #: src/ch00/basics/errors.md:85 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x0501CD5da5B453a18515B5A20b8029bd7583DFE7a399ad9f79c284F7829e4A57) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/errors/src/custom_errors.cairo)." +"blob/main/listings/getting-started/errors/src/custom_errors.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" "contract/0x0501CD5da5B453a18515B5A20b8029bd7583DFE7a399ad9f79c284F7829e4A57) " "上访问 contract 或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/errors/src/custom_errors.cairo) 中尝试" -"它。" +"blob/main/listings/ch00-getting-started/errors/src/custom_errors.cairo) 中尝" +"试它。" #: src/ch00/basics/errors.md:87 msgid "## Vault example" @@ -1643,12 +1657,13 @@ msgstr "" "```" #: src/ch00/basics/errors.md:137 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x020C2da26F42A28Ef54ED428eF1810FE433784b055f9bF315C5d992b1579C268) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/errors/src/vault_errors.cairo)." +"blob/main/listings/getting-started/errors/src/vault_errors.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" "contract/0x020C2da26F42A28Ef54ED428eF1810FE433784b055f9bF315C5d992b1579C268) " @@ -1673,9 +1688,9 @@ msgid "" msgstr "" "事件是从合约发出数据的一种方式。所有事件都必须在`Event`枚举中定义,该枚举必须" "使用`#[event]`属性进行注释。\n" -"事件被定义为派生`#[starknet::Event]`特征的结构。该结构的字段对应于将要发出的数" -"据。可以对事件编制索引,以便在以后查询数据时轻松快速地访问。可以通过向字段成员" -"添加`#[key]` 属性来索引事件数据。" +"事件被定义为派生`#[starknet::Event]`特征的结构。该结构的字段对应于将要发出的" +"数据。可以对事件编制索引,以便在以后查询数据时轻松快速地访问。可以通过向字段" +"成员添加`#[key]` 属性来索引事件数据。" #: src/ch00/basics/events.md:6 msgid "" @@ -1720,7 +1735,8 @@ msgid "" "\n" " #[derive(Drop, starknet::Event)]\n" " struct UserIncreaseCounter {\n" -" // The `#[key]` attribute indicates that this event will be indexed.\n" +" // The `#[key]` attribute indicates that this event will be " +"indexed.\n" " #[key]\n" " user: ContractAddress,\n" " new_value: u128,\n" @@ -1782,7 +1798,8 @@ msgstr "" "\n" " #[derive(Drop, starknet::Event)]\n" " struct UserIncreaseCounter {\n" -" // The `#[key]` attribute indicates that this event will be indexed.\n" +" // The `#[key]` attribute indicates that this event will be " +"indexed.\n" " #[key]\n" " user: ContractAddress,\n" " new_value: u128,\n" @@ -1812,12 +1829,13 @@ msgstr "" "```" #: src/ch00/basics/events.md:66 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x022e3B59518EA04aBb5da671ea04ecC3a154400f226d2Df38eFE146741b9E2F6) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/events/src/counter.cairo)." +"blob/main/listings/getting-started/events/src/counter.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" "contract/0x022e3B59518EA04aBb5da671ea04ecC3a154400f226d2Df38eFE146741b9E2F6) " @@ -1834,14 +1852,14 @@ msgid "" "While native types can be stored in a contract's storage without any " "additional work, custom types require a bit more work. This is because at " "compile time, the compiler does not know how to store custom types in " -"storage. To solve this, we need to implement the `Store` trait for our custom " -"type. Hopefully, we can just derive this trait for our custom type - unless " -"it contains arrays or dictionaries." +"storage. To solve this, we need to implement the `Store` trait for our " +"custom type. Hopefully, we can just derive this trait for our custom type - " +"unless it contains arrays or dictionaries." msgstr "" -"虽然本机类型可以存储在合约的存储中,而无需任何额外的工作,但自定义类型需要更多" -"的工作。这是因为在编译时,编译器不知道如何在存储中存储自定义类型。为了解决这个" -"问题,我们需要为我们的自定义类型实现 `Store`特征。希望我们可以为我们的自定义类" -"型派生这个特征 - 除非它包含数组或字典。" +"虽然本机类型可以存储在合约的存储中,而无需任何额外的工作,但自定义类型需要更" +"多的工作。这是因为在编译时,编译器不知道如何在存储中存储自定义类型。为了解决" +"这个问题,我们需要为我们的自定义类型实现 `Store`特征。希望我们可以为我们的自" +"定义类型派生这个特征 - 除非它包含数组或字典。" #: src/ch00/basics/storing-custom-types.md:5 msgid "" @@ -1910,11 +1928,11 @@ msgstr "" "```" #: src/ch00/basics/storing-custom-types.md:37 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/storing_custom_types/src/contract." -"cairo)." +"blob/main/listings/getting-started/storing_custom_types/src/contract.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." "com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" @@ -1933,10 +1951,10 @@ msgid "" "entrypoint, we need to be able to serialize it into an array of `felt252`.\n" "Thankfully, we can just derive the `Serde` trait for our custom type." msgstr "" -"在入口点中使用自定义类型需要我们的类型来实现`Serde`trait。这是因为在调用入口点" -"时,输入以`felt252` 数组的形式发送到入口点,我们需要能够将其反序列化为我们的自" -"定义类型。同样,当从入口点返回自定义类型时,我们需要能够将其序列化为`felt252` " -"数组。\n" +"在入口点中使用自定义类型需要我们的类型来实现`Serde`trait。这是因为在调用入口" +"点时,输入以`felt252` 数组的形式发送到入口点,我们需要能够将其反序列化为我们" +"的自定义类型。同样,当从入口点返回自定义类型时,我们需要能够将其序列化为" +"`felt252` 数组。\n" "值得庆幸的是,我们可以为我们的自定义类型派生`Serde` 特征。" #: src/ch00/basics/custom-types-in-entrypoints.md:6 @@ -2006,10 +2024,11 @@ msgstr "" "```" #: src/ch00/basics/custom-types-in-entrypoints.md:37 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/custom_type_serde/src/contract.cairo)." +"blob/main/listings/getting-started/custom_type_serde/src/contract.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." "com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" @@ -2056,8 +2075,8 @@ msgid "" msgstr "" "在智能合约中,你通常会有一个定义合约接口的trait(即带有`#[starknet::" "interface]`)。\n" -"这是包含详细文档的理想场所,这些文档解释了合约入口点的用途和功能。您可以遵循以" -"下模板:" +"这是包含详细文档的理想场所,这些文档解释了合约入口点的用途和功能。您可以遵循" +"以下模板:" #: src/ch00/basics/documentation.md:16 msgid "" @@ -2098,8 +2117,8 @@ msgstr "" #: src/ch00/basics/documentation.md:33 msgid "" "Keep in mind that this should not describe the implementation details of the " -"function, but rather the high-level purpose and functionality of the contract " -"from the perspective of a user." +"function, but rather the high-level purpose and functionality of the " +"contract from the perspective of a user." msgstr "" "请记住,这不应该描述函数的实现细节,而应该从用户的角度描述合约的高级目的和功" "能。" @@ -2116,7 +2135,8 @@ msgstr "在编写合约逻辑时,可以添加注释来描述函数的技术实 #: src/ch00/basics/documentation.md:39 msgid "" -"> Avoid over-commenting: Comments should provide additional value and clarity." +"> Avoid over-commenting: Comments should provide additional value and " +"clarity." msgstr "> 避免过度注释:注释应提供额外的价值和清晰度。" #: src/ch00/basics/documentation.md:41 @@ -2131,6 +2151,10 @@ msgstr "# 部署合约并与合约交互" msgid "In this chapter, we will see how to deploy and interact with contracts." msgstr "在本章中,我们将了解如何部署合约并与之交互。" +#: src/ch00/interacting/interacting.md:4 +msgid "
Last change: 2023-10-19
" +msgstr "
Last change: 2023-10-19
" + #: src/ch00/interacting/interfaces-traits.md:1 msgid "# Contract interfaces and Traits generation" msgstr "# 合约接口和Trait生成" @@ -2143,8 +2167,8 @@ msgid "" "the [Cairo Book](https://book.cairo-lang.org/ch99-01-02-a-simple-contract." "html)." msgstr "" -"合约接口定义合约的结构和行为,充当合约的公共 ABI。它们列出了合约公开的所有函数" -"签名。接口的详细说明可以参考 [Cairo之书](https://book.cairo-lang.org/" +"合约接口定义合约的结构和行为,充当合约的公共 ABI。它们列出了合约公开的所有函" +"数签名。接口的详细说明可以参考 [Cairo之书](https://book.cairo-lang.org/" "ch99-01-02-a-simple-contract.html)。" #: src/ch00/interacting/interfaces-traits.md:5 @@ -2179,9 +2203,9 @@ msgid "" "l1 handler." msgstr "" "您可以使用`#[generate_trait]`属性隐式生成特定实现块的特征。此属性会自动生成一" -"个特征,其功能与已实现块中的函数相同,将`self`参数替换为通用的`TContractState`" -"参数。但是,您需要使用`#[abi(per_item)]` 属性注释块,并且每个函数都具有适当的" -"属性,具体取决于它是外部函数、构造函数还是 l1 处理程序。" +"个特征,其功能与已实现块中的函数相同,将`self`参数替换为通用的" +"`TContractState`参数。但是,您需要使用`#[abi(per_item)]` 属性注释块,并且每个" +"函数都具有适当的属性,具体取决于它是外部函数、构造函数还是 l1 处理程序。" #: src/ch00/interacting/interfaces-traits.md:11 msgid "In summary, there's two ways to handle interfaces:" @@ -2261,10 +2285,11 @@ msgstr "" "```" #: src/ch00/interacting/interfaces-traits.md:45 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/interfaces_traits/src/explicit.cairo)." +"blob/main/listings/getting-started/interfaces_traits/src/explicit.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." "com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" @@ -2325,10 +2350,11 @@ msgstr "" "```" #: src/ch00/interacting/interfaces-traits.md:73 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/interfaces_traits/src/implicit.cairo)." +"blob/main/listings/getting-started/interfaces_traits/src/implicit.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." "com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" @@ -2340,8 +2366,8 @@ msgid "" "contract::{GeneratedContractInterface}`. However, the `Dispatcher` will not " "be generated automatically." msgstr "" -"> 注意:您可以使用`use contract::{GeneratedContractInterface}`导入隐式生成的合" -"约接口。但是,`Dispatcher`不会自动生成。" +"> 注意:您可以使用`use contract::{GeneratedContractInterface}`导入隐式生成的" +"合约接口。但是,`Dispatcher`不会自动生成。" #: src/ch00/interacting/interfaces-traits.md:77 msgid "## Internal functions" @@ -2354,8 +2380,8 @@ msgid "" "pure functions as well (functions without the `self` parameter)." msgstr "" "您还可以将`#[generate_trait]`用于内部函数。\n" -"由于此特征是在合约的上下文中生成的,因此您也可以定义纯函数(没有“self”参数的函" -"数)。" +"由于此特征是在合约的上下文中生成的,因此您也可以定义纯函数(没有“self”参数的" +"函数)。" #: src/ch00/interacting/interfaces-traits.md:82 msgid "" @@ -2452,20 +2478,17 @@ msgstr "" "```" #: src/ch00/interacting/interfaces-traits.md:127 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/interfaces_traits/src/" -"implicit_internal.cairo)." +"blob/main/listings/getting-started/interfaces_traits/src/implicit_internal." +"cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." "com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" "interfaces_traits/src/implicit_internal.cairo) 中尝试这个合约。" -#: src/ch00/interacting/interfaces-traits.md:129 -msgid "
Last change: 2023-11-26
" -msgstr "
Last change: 2023-11-26
" - #: src/ch00/interacting/calling_other_contracts.md:1 msgid "# Calling other contracts" msgstr "# 调用其他合约" @@ -2484,8 +2507,8 @@ msgid "" msgstr "" "调用其他合约的最简单方法是使用要调用的合约的调度程序。\n" "您可以在 [Cairo Book](https://book.cairo-lang.org/ch99-02-02-contract-" -"dispatcher-library-dispatcher-and-system-calls.html#contract-dispatcher) 中阅" -"读有关 Dispatchers 的更多信息" +"dispatcher-library-dispatcher-and-system-calls.html#contract-dispatcher) 中" +"阅读有关 Dispatchers 的更多信息" #: src/ch00/interacting/calling_other_contracts.md:8 msgid "" @@ -2502,8 +2525,8 @@ msgid "" "interface]` attribute, and then import the `IContractDispatcher` and " "`IContractDispatcherTrait` items in your contract." msgstr "" -"为了使用调度程序调用其他合约,您需要将被调用合约的接口定义为使用 `#[starknet::" -"interface]` 属性注释的trait,然后将 `IContractDispatcher` 和 " +"为了使用调度程序调用其他合约,您需要将被调用合约的接口定义为使用 " +"`#[starknet::interface]` 属性注释的trait,然后将 `IContractDispatcher` 和 " "`IContractDispatcherTrait` 项导入到合约中。" #: src/ch00/interacting/calling_other_contracts.md:12 @@ -2555,13 +2578,13 @@ msgstr "" "```" #: src/ch00/interacting/calling_other_contracts.md:34 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x015c3Bb6D0DE26b64FEAF9A8f4655CfADb5c128bF4510398972704ee12775DB1) " "or play with it in [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)." +"blob/main/listings/getting-started/calling_other_contracts/src/callee.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" "contract/0x015c3Bb6D0DE26b64FEAF9A8f4655CfADb5c128bF4510398972704ee12775DB1) " @@ -2643,13 +2666,13 @@ msgstr "" "```" #: src/ch00/interacting/calling_other_contracts.md:68 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x05fa8aF796343d2f22c53C17149386b67B7AC4aB52D9e308Aa507C185aA44778) " "or play with it in [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)." +"blob/main/listings/getting-started/calling_other_contracts/src/caller.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" "contract/0x05fa8aF796343d2f22c53C17149386b67B7AC4aB52D9e308Aa507C185aA44778) " @@ -2658,13 +2681,6 @@ msgstr "" "blob/main/listings/ch00-getting-started/calling_other_contracts/src/caller." "cairo) 中尝试它。" -#: src/ch00/interacting/calling_other_contracts.md:69 -#: src/ch00/cairo_cheatsheet/felt.md:15 src/ch00/cairo_cheatsheet/loop.md:23 -#: src/ch00/cairo_cheatsheet/tuples.md:18 -#: src/ch00/cairo_cheatsheet/type_casting.md:33 -msgid "
Last change: 2023-11-30
" -msgstr "
Last change: 2023-11-30
" - #: src/ch00/interacting/factory.md:1 msgid "# Factory Pattern" msgstr "# 工厂模式" @@ -2678,12 +2694,12 @@ 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." +"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" @@ -2691,24 +2707,24 @@ msgstr "## 类哈希(Class hash)和合约实例" #: src/ch00/interacting/factory.md:9 msgid "" -"In Starknet, there's a separation between contract's classes and instances. A " -"contract class serves as a blueprint, defined by the underling Cairo " +"In Starknet, there's a separation between contract's classes and instances. " +"A contract class serves as a blueprint, defined by the underling Cairo " "bytecode, contract's entrypoints, ABI and Sierra program hash. The contract " "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 程序哈希定义。合约类由类哈希标识。当您想向网络添加一" -"个新类时,首先需要声明它。" +"约的入口点、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." +"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 "" @@ -2743,8 +2759,8 @@ msgid "" " /// 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" +" /// 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" @@ -2818,8 +2834,8 @@ msgstr "" " /// 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" +" /// 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" @@ -2880,11 +2896,11 @@ msgstr "" #: src/ch00/interacting/factory.md:86 msgid "" -"" msgstr "" -"" #: src/ch00/interacting/factory.md:88 msgid "" @@ -2911,11 +2927,12 @@ msgstr "" "这个最小的范例缺少几个有用的功能,例如访问控制、跟踪已部署的合约、事件......" #: src/ch00/interacting/factory.md:94 +#, fuzzy msgid "" "\n" "\n" -"
Last change: 2023-10-19
" +"
Last change: 2023-12-07
" msgstr "" "\n" @@ -2932,8 +2949,8 @@ msgid "" "contracts. In this section, we'll guide you through the basics of testing a " "smart contract on Starknet with `scarb`." msgstr "" -"测试在软件开发中起着至关重要的作用,尤其是对于智能合约而言。在本节中,我们将通" -"过Starknet上的`scarb` ,引导你了解智能合约测试的基础知识。" +"测试在软件开发中起着至关重要的作用,尤其是对于智能合约而言。在本节中,我们将" +"通过Starknet上的`scarb` ,引导你了解智能合约测试的基础知识。" #: src/ch00/testing/contract-testing.md:5 msgid "Let's start with a simple smart contract as an example:" @@ -3212,10 +3229,11 @@ msgstr "" "```" #: src/ch00/testing/contract-testing.md:132 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/testing_how_to/src/lib.cairo)." +"blob/main/listings/getting-started/testing_how_to/src/lib.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." "com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" @@ -3223,20 +3241,20 @@ msgstr "" #: src/ch00/testing/contract-testing.md:134 msgid "" -"To define our test, we use scarb, which allows us to create a separate module " -"guarded with `#[cfg(test)]`. This ensures that the test module is only " -"compiled when running tests using `scarb test`." +"To define our test, we use scarb, which allows us to create a separate " +"module guarded with `#[cfg(test)]`. This ensures that the test module is " +"only compiled when running tests using `scarb test`." msgstr "" -"为了定义我们的测试,我们使用 scarb,它允许我们创建一个被 `#[cfg(test)]` 保护的" -"独立模块。这样可以确保测试模块只在使用 `scarb test` 运行测试时被编译。" +"为了定义我们的测试,我们使用 scarb,它允许我们创建一个被 `#[cfg(test)]` 保护" +"的独立模块。这样可以确保测试模块只在使用 `scarb test` 运行测试时被编译。" #: src/ch00/testing/contract-testing.md:136 msgid "" -"Each test is defined as a function with the `#[test]` attribute. You can also " -"check if a test panics using the `#[should_panic]` attribute." +"Each test is defined as a function with the `#[test]` attribute. You can " +"also check if a test panics using the `#[should_panic]` attribute." msgstr "" -"每个测试都被定义为带有 `#[test]` 属性的函数。您还可以使用 `#[should_panic]` 属" -"性检查测试是否会引发 panic。" +"每个测试都被定义为带有 `#[test]` 属性的函数。您还可以使用 `#[should_panic]` " +"属性检查测试是否会引发 panic。" #: src/ch00/testing/contract-testing.md:138 msgid "" @@ -3268,8 +3286,8 @@ msgstr "" #: src/ch00/testing/contract-testing.md:146 msgid "" -"To make testing more convenient, the `testing` module of the corelib provides " -"some helpful functions:" +"To make testing more convenient, the `testing` module of the corelib " +"provides some helpful functions:" msgstr "为了使测试更加方便,corelib 的 `testing` 模块提供了一些有用的函数:" #: src/ch00/testing/contract-testing.md:147 @@ -3319,8 +3337,8 @@ msgid "" "book - Chapter 8](https://book.cairo-lang.org/ch08-01-how-to-write-tests." "html)." msgstr "" -"你可以在 [Starknet Corelib 仓库](https://github.com/starkware-libs/cairo/tree/" -"main/corelib/src/starknet) 中找到完整的函数列表。\n" +"你可以在 [Starknet Corelib 仓库](https://github.com/starkware-libs/cairo/" +"tree/main/corelib/src/starknet) 中找到完整的函数列表。\n" "你还可以在 [Cairo book 第8章](https://book.cairo-lang.org/ch08-01-how-to-" "write-tests.html) 中找到有关在 cairo 中进行测试的详细说明。" @@ -3338,8 +3356,8 @@ msgid "" "Starknet. It offers support for testing Starknet smart contracts on top of " "`scarb` with the `Forge` tool." msgstr "" -"Starknet Foundry是在Starknet上开发智能合约的强大工具包。它提供了对使用`Forge` " -"工具在 `scarb` 上测试Starknet智能合约的支持。" +"Starknet Foundry是在Starknet上开发智能合约的强大工具包。它提供了对使用" +"`Forge` 工具在 `scarb` 上测试Starknet智能合约的支持。" #: src/ch00/testing/contract-testing.md:172 msgid "" @@ -3349,8 +3367,8 @@ msgid "" "Starknet Foundry and incorporating it into your projects." msgstr "" "使用 `snforge` 进行测试与我们刚刚描述的过程类似,但更简化。此外,还有其他功能" -"正在开发中,包括作弊码或并行测试执行。我们强烈推荐探索Starknet Foundry并将其纳" -"入您你的项目中。" +"正在开发中,包括作弊码或并行测试执行。我们强烈推荐探索Starknet Foundry并将其" +"纳入您你的项目中。" #: src/ch00/testing/contract-testing.md:174 msgid "" @@ -3373,9 +3391,6 @@ msgid "" msgstr "本章旨在为最常见的Cairo结构提供快速参考。" #: src/ch00/cairo_cheatsheet/cairo_cheatsheet.md:5 -#: src/ch00/cairo_cheatsheet/mapping.md:58 -#: src/ch00/cairo_cheatsheet/arrays.md:42 src/ch00/cairo_cheatsheet/match.md:59 -#: src/ch00/cairo_cheatsheet/struct.md:15 msgid "
Last change: 2023-10-31
" msgstr "
Last change: 2023-10-31
" @@ -3387,8 +3402,8 @@ msgstr "# Felt252" msgid "" "Felt252 is a fundamental data type in Cairo from which all other data types " "are derived.\n" -"Felt252 can also be used to store short-string representations with a maximum " -"length of 31 characters." +"Felt252 can also be used to store short-string representations with a " +"maximum length of 31 characters." msgstr "" "Felt252是Cairo中的基本数据类型,所有其他数据类型都派生自它。\n" "Felt252也可以用于存储最多31个字符长度的短字符串表示。" @@ -3436,8 +3451,8 @@ msgid "" " ref self: TContractState, student_add: ContractAddress, subject: " "felt252, score: u16\n" " );\n" -" fn view_student_name(self: @TContractState, student_add: ContractAddress) " -"-> felt252;\n" +" fn view_student_name(self: @TContractState, student_add: " +"ContractAddress) -> felt252;\n" " fn view_student_score(\n" " self: @TContractState, student_add: ContractAddress, subject: " "felt252\n" @@ -3500,8 +3515,8 @@ msgstr "" " ref self: TContractState, student_add: ContractAddress, subject: " "felt252, score: u16\n" " );\n" -" fn view_student_name(self: @TContractState, student_add: ContractAddress) " -"-> felt252;\n" +" fn view_student_name(self: @TContractState, student_add: " +"ContractAddress) -> felt252;\n" " fn view_student_score(\n" " self: @TContractState, student_add: ContractAddress, subject: " "felt252\n" @@ -3559,8 +3574,8 @@ msgstr "# 数组" #: src/ch00/cairo_cheatsheet/arrays.md:3 msgid "" "Arrays are collections of elements of the same type.\n" -"The possible operations on arrays are defined with the `array::ArrayTrait` of " -"the corelib:" +"The possible operations on arrays are defined with the `array::ArrayTrait` " +"of the corelib:" msgstr "" "数组是相同类型元素的集合。\n" "可以使用 corelib 的 `array::ArrayTrait` 来定义可能的数组操作:" @@ -3820,9 +3835,9 @@ msgid "" "created, its size cannot change.\n" "For example:" msgstr "" -"元组是一种数据类型,用于将固定数量的不同类型的项组合成一个单一的复合结构。与数" -"组不同,元组具有固定的长度,并且可以包含不同类型的元素。一旦创建了元组,其大小" -"就无法更改。\n" +"元组是一种数据类型,用于将固定数量的不同类型的项组合成一个单一的复合结构。与" +"数组不同,元组具有固定的长度,并且可以包含不同类型的元素。一旦创建了元组,其" +"大小就无法更改。\n" "例如:" #: src/ch00/cairo_cheatsheet/tuples.md:6 @@ -3895,13 +3910,13 @@ msgid "" "Cairo supports the conversion from one scalar types to another by using the " "into and try_into methods.\n" "`traits::Into` is used for conversion from a smaller data type to a larger " -"data type, while `traits::TryInto` is used when converting from a larger to a " -"smaller type that might not fit. \n" +"data type, while `traits::TryInto` is used when converting from a larger to " +"a smaller type that might not fit. \n" "For example:" msgstr "" "Cairo支持使用into和try_into方法将一个标量类型转换为另一个类型。\n" -"`traits::Into` 用于从较小的数据类型转换为较大的数据类型,而 `traits::TryInto` " -"用于从较大的数据类型转换为较小的数据类型,可能会发生溢出的情况。\n" +"`traits::Into` 用于从较小的数据类型转换为较大的数据类型,而 `traits::" +"TryInto` 用于从较大的数据类型转换为较小的数据类型,可能会发生溢出的情况。\n" "例如:" #: src/ch00/cairo_cheatsheet/type_casting.md:7 @@ -3910,7 +3925,8 @@ msgid "" " let a_number: u32 = 15;\n" " let my_felt252 = 15;\n" "\n" -" // Since a u32 might not fit in a u8 and a u16, we need to use try_into,\n" +" // Since a u32 might not fit in a u8 and a u16, we need to use " +"try_into,\n" " // then unwrap the Option type thats returned.\n" " let new_u8: u8 = a_number.try_into().unwrap();\n" " let new_u16: u16 = a_number.try_into().unwrap();\n" @@ -3920,8 +3936,8 @@ msgid "" " // or use the .into() method.\n" " let new_u32: u32 = a_number;\n" "\n" -" // When typecasting from a smaller size to an equal or larger size we use " -"the .into() method.\n" +" // When typecasting from a smaller size to an equal or larger size we " +"use the .into() method.\n" " // Note: u64 and u128 are larger than u32, so a u32 type will always fit " "into them.\n" " let new_u64: u64 = a_number.into();\n" @@ -3948,8 +3964,8 @@ msgstr "" " // 或使用 .into() 方法\n" " let new_u32: u32 = a_number;\n" "\n" -" // 当从较小的大小类型强制转换为相等或较大的大小类型时,我们使用 .into() 方" -"法\n" +" // 当从较小的大小类型强制转换为相等或较大的大小类型时,我们使用 .into() " +"方法\n" " // 注意:u64 和 u128 大于 u32,所以 u32 类型将始终适合其中\n" " let new_u64: u64 = a_number.into();\n" " let new_u128: u128 = a_number.into();\n" @@ -3962,6 +3978,214 @@ msgstr "" " let new_usize: usize = my_felt252.try_into().unwrap();\n" "```" +#: src/components/how_to.md:1 +msgid "# Components How-To" +msgstr "" + +#: src/components/how_to.md:3 +msgid "" +"Components are like modular addons that can be snapped into contracts to add " +"reusable logic, storage, and events.\n" +"They are used to separate the core logic from common functionalities, " +"simplifying the contract's code and making it easier to read and maintain.\n" +"It also reduces the risk of bugs and vulnerabilities by using well-tested " +"components." +msgstr "" + +#: src/components/how_to.md:7 +msgid "Key characteristics:" +msgstr "" + +#: src/components/how_to.md:8 +msgid "" +"- Modularity: Easily pluggable into multiple contracts.\n" +"- Reusable Logic: Encapsulates specific functionalities.\n" +"- Not Standalone: Cannot be declared or deployed independently." +msgstr "" + +#: src/components/how_to.md:12 +msgid "## How to create a component" +msgstr "" + +#: src/components/how_to.md:14 +msgid "" +"The following example shows a simple `Switch` component that can be used to " +"turn a boolean on or off.\n" +"It contains a storage variable `value`, a function `switch` and an event " +"`Switch`." +msgstr "" + +#: src/components/how_to.md:17 +#, fuzzy +msgid "" +"```rust\n" +"#[starknet::interface]\n" +"trait ISwitchComponent {\n" +" fn value(self: @TContractState) -> bool;\n" +" fn switch(ref self: TContractState);\n" +"}\n" +"\n" +"#[starknet::component]\n" +"mod switch_component {\n" +" #[storage]\n" +" struct Storage {\n" +" value: bool,\n" +" }\n" +"\n" +" #[derive(Drop, starknet::Event)]\n" +" struct SwitchEvent {}\n" +"\n" +" #[event]\n" +" #[derive(Drop, starknet::Event)]\n" +" enum Event {\n" +" SwitchEvent: SwitchEvent,\n" +" }\n" +"\n" +" #[embeddable_as(Switch)]\n" +" impl SwitchImpl<\n" +" TContractState, +HasComponent\n" +" > of super::ISwitchComponent> {\n" +" fn value(self: @ComponentState) -> bool {\n" +" self.value.read()\n" +" }\n" +"\n" +" fn switch(ref self: ComponentState) {\n" +" self.value.write(!self.value.read());\n" +" self.emit(Event::SwitchEvent(SwitchEvent {}));\n" +" }\n" +" }\n" +"\n" +" #[generate_trait]\n" +" impl InternalSwitchImpl<\n" +" TContractState, +HasComponent\n" +" > of InternalSwitchTrait {\n" +" fn _off(ref self: ComponentState) {\n" +" self.value.write(false);\n" +" }\n" +" }\n" +"}\n" +"```" +msgstr "" +"```rust\n" +"#[starknet::interface]\n" +"trait ISimpleCounter {\n" +" fn get_current_count(self: @TContractState) -> u128;\n" +" fn increment(ref self: TContractState);\n" +" fn decrement(ref self: TContractState);\n" +"}\n" +"\n" +"#[starknet::contract]\n" +"mod SimpleCounter {\n" +" #[storage]\n" +" struct Storage {\n" +" // Counter variable\n" +" counter: u128,\n" +" }\n" +"\n" +" #[constructor]\n" +" fn constructor(ref self: ContractState, init_value: u128) {\n" +" // Store initial value\n" +" self.counter.write(init_value);\n" +" }\n" +"\n" +" #[abi(embed_v0)]\n" +" impl SimpleCounter of super::ISimpleCounter {\n" +" fn get_current_count(self: @ContractState) -> u128 {\n" +" return self.counter.read();\n" +" }\n" +"\n" +" fn increment(ref self: ContractState) {\n" +" // Store counter value + 1\n" +" let counter = self.counter.read() + 1;\n" +" self.counter.write(counter);\n" +" }\n" +" fn decrement(ref self: ContractState) {\n" +" // Store counter value - 1\n" +" let counter = self.counter.read() - 1;\n" +" self.counter.write(counter);\n" +" }\n" +" }\n" +"}\n" +"```" + +#: src/components/how_to.md:65 +msgid "" +"A component in itself is really similar to a contract, it *can* also have:" +msgstr "" + +#: src/components/how_to.md:66 +msgid "" +"- An interface defining entrypoints (`ISwitchComponent`)\n" +"- A Storage struct\n" +"- Events\n" +"- Internal functions" +msgstr "" + +#: src/components/how_to.md:71 +msgid "" +"It don't have a constructor, but you can create a `_init` internal function " +"and call it from the contract's constructor. In the previous example, the " +"`_off` function is used this way." +msgstr "" + +#: src/components/how_to.md:73 +msgid "## How to use a component" +msgstr "" + +#: src/components/how_to.md:75 +msgid "" +"Now that we have a component, we can use it in a contract.\n" +"The following contract incorporates the `Switch` component:" +msgstr "" + +#: src/components/how_to.md:78 +msgid "" +"```rust\n" +"#[starknet::contract]\n" +"mod SwitchContract {\n" +" use components::switch::switch_component;\n" +" // This is needed to be able to use internal functions of the switch " +"component.\n" +" use components::switch::switch_component::InternalSwitchImpl;\n" +"\n" +" component!(path: switch_component, storage: switch, event: " +"SwitchEvent);\n" +"\n" +" #[abi(embed_v0)]\n" +" impl SwitchImpl = switch_component::Switch;\n" +" impl SwitchInternalImpl = switch_component::" +"InternalSwitchImpl;\n" +"\n" +" #[storage]\n" +" struct Storage {\n" +" #[substorage(v0)]\n" +" switch: switch_component::Storage,\n" +" }\n" +"\n" +" #[constructor]\n" +" fn constructor(ref self: ContractState) {\n" +" self.switch._off();\n" +" }\n" +"\n" +" #[event]\n" +" #[derive(Drop, starknet::Event)]\n" +" enum Event {\n" +" SwitchEvent: switch_component::Event\n" +" }\n" +"}\n" +"```" +msgstr "" + +#: src/components/how_to.md:110 +msgid "## Deep dive into components" +msgstr "" + +#: src/components/how_to.md:112 +msgid "" +"You can find more in-depth information about components in the [Cairo book - " +"Components](https://book.cairo-lang.org/ch99-01-05-00-components.html)." +msgstr "" + #: src/ch01/upgradeable_contract.md:1 msgid "# Upgradeable Contract" msgstr "# 可升级合约" @@ -4011,8 +4235,8 @@ msgid "" "name in an object-oriented programming language. A contract instance is a " "deployed contract corresponding to a class." msgstr "" -"每个类由其类哈希值标识,类似于面向对象编程语言中的类名。合约实例是对应于某个类" -"的已部署合约。" +"每个类由其类哈希值标识,类似于面向对象编程语言中的类名。合约实例是对应于某个" +"类的已部署合约。" #: src/ch01/upgradeable_contract.md:20 msgid "" @@ -4023,8 +4247,8 @@ msgid "" "the data stored in the contract will remain the same." msgstr "" "当调用`replace_class_syscall`函数,你可以将已部署的合约升级到更新的版本。通过" -"使用这个函数,你可以更新与已部署合约相关联的类哈希,从而有效地升级合约的实现。" -"然而,这不会修改合约中的存储,因此合约中存储的所有数据将保持不变。" +"使用这个函数,你可以更新与已部署合约相关联的类哈希,从而有效地升级合约的实" +"现。然而,这不会修改合约中的存储,因此合约中存储的所有数据将保持不变。" #: src/ch01/upgradeable_contract.md:22 msgid "" @@ -4034,14 +4258,14 @@ msgid "" "send a transaction that invokes the `upgrade` function, with the class hash " "of `UpgradeableContract_V1` as parameter to upgrade the class hash of the " "deployed contract to the `UpgradeableContract_V1` one. Then, call the " -"`version` method on the contract to see that the contract was upgraded to the " -"V1 version." +"`version` method on the contract to see that the contract was upgraded to " +"the V1 version." msgstr "" "为了说明这个概念,让我们以两个合约为例:`UpgradeableContract_V0`和" "`UpgradeableContract_V1`。\n" "首先,部署`UpgradeableContract_V0`作为初始版本。接下来,发送一个调用`upgrade`" -"函数的交易,将部署合约的类哈希升级为`UpgradeableContract_V1`的类哈希。然后,调" -"用合约上的`version`方法,查看合约是否已升级到V1版本。" +"函数的交易,将部署合约的类哈希升级为`UpgradeableContract_V1`的类哈希。然后," +"调用合约上的`version`方法,查看合约是否已升级到V1版本。" #: src/ch01/upgradeable_contract.md:25 msgid "" @@ -4075,7 +4299,8 @@ msgid "" " }\n" "\n" " #[abi(embed_v0)]\n" -" impl UpgradeableContract of super::IUpgradeableContract {\n" +" impl UpgradeableContract of super::IUpgradeableContract " +"{\n" " fn upgrade(ref self: ContractState, impl_hash: ClassHash) {\n" " assert(!impl_hash.is_zero(), 'Class hash cannot be zero');\n" " starknet::replace_class_syscall(impl_hash).unwrap_syscall();\n" @@ -4120,7 +4345,8 @@ msgstr "" " }\n" "\n" " #[abi(embed_v0)]\n" -" impl UpgradeableContract of super::IUpgradeableContract {\n" +" impl UpgradeableContract of super::IUpgradeableContract " +"{\n" " fn upgrade(ref self: ContractState, impl_hash: ClassHash) {\n" " assert(!impl_hash.is_zero(), 'Class hash cannot be zero');\n" " starknet::replace_class_syscall(impl_hash).unwrap_syscall();\n" @@ -4136,12 +4362,13 @@ msgstr "" "```" #: src/ch01/upgradeable_contract.md:68 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x005300003ade5d10447d941a42d48b7141074cd8bade2b16520684896a5090ea) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch01-applications/upgradeable_contract/src/" +"blob/main/listings/applications/upgradeable_contract/src/" "upgradeable_contract_v0.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" @@ -4183,7 +4410,8 @@ msgid "" " }\n" "\n" " #[abi(embed_v0)]\n" -" impl UpgradeableContract of super::IUpgradeableContract {\n" +" impl UpgradeableContract of super::IUpgradeableContract " +"{\n" " fn upgrade(ref self: ContractState, impl_hash: ClassHash) {\n" " assert(!impl_hash.is_zero(), 'Class hash cannot be zero');\n" " starknet::replace_class_syscall(impl_hash).unwrap_syscall();\n" @@ -4228,7 +4456,8 @@ msgstr "" " }\n" "\n" " #[abi(embed_v0)]\n" -" impl UpgradeableContract of super::IUpgradeableContract {\n" +" impl UpgradeableContract of super::IUpgradeableContract " +"{\n" " fn upgrade(ref self: ContractState, impl_hash: ClassHash) {\n" " assert(!impl_hash.is_zero(), 'Class hash cannot be zero');\n" " starknet::replace_class_syscall(impl_hash).unwrap_syscall();\n" @@ -4244,12 +4473,13 @@ msgstr "" "```" #: src/ch01/upgradeable_contract.md:114 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x017c86152badd1d665b9836571bd6b0a484f028748aa13d9b2d5d9c9192fafc6) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch01-applications/upgradeable_contract/src/" +"blob/main/listings/applications/upgradeable_contract/src/" "upgradeable_contract_v1.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" @@ -4269,8 +4499,8 @@ msgid "" "solidity-by-example.org/defi/vault/).\n" "Here's how it works:" msgstr "" -"这是 [Solidity by example Vault](https://solidity-by-example.org/defi/vault/) " -"的Cairo版本\n" +"这是 [Solidity by example Vault](https://solidity-by-example.org/defi/" +"vault/) 的Cairo版本\n" "以下是它的工作原理:" #: src/ch01/simple_vault.md:6 @@ -4303,8 +4533,8 @@ msgid "" " fn balance_of(self: @TContractState, account: ContractAddress) -> u256;\n" " fn allowance(self: @TContractState, owner: ContractAddress, spender: " "ContractAddress) -> u256;\n" -" fn transfer(ref self: TContractState, recipient: ContractAddress, amount: " -"u256) -> bool;\n" +" fn transfer(ref self: TContractState, recipient: ContractAddress, " +"amount: u256) -> bool;\n" " fn transfer_from(\n" " ref self: TContractState, sender: ContractAddress, recipient: " "ContractAddress, amount: u256\n" @@ -4415,8 +4645,8 @@ msgstr "" " fn balance_of(self: @TContractState, account: ContractAddress) -> u256;\n" " fn allowance(self: @TContractState, owner: ContractAddress, spender: " "ContractAddress) -> u256;\n" -" fn transfer(ref self: TContractState, recipient: ContractAddress, amount: " -"u256) -> bool;\n" +" fn transfer(ref self: TContractState, recipient: ContractAddress, " +"amount: u256) -> bool;\n" " fn transfer_from(\n" " ref self: TContractState, sender: ContractAddress, recipient: " "ContractAddress, amount: u256\n" @@ -4513,10 +4743,11 @@ msgstr "" "```" #: src/ch01/simple_vault.md:113 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch01-applications/simple_vault/src/simple_vault.cairo)." +"blob/main/listings/applications/simple_vault/src/simple_vault.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." "com/NethermindEth/StarknetByExample/blob/main/listings/ch01-applications/" @@ -4535,7 +4766,8 @@ msgstr "" "ERC20 代币。它们用于代表可互换的资产。" #: src/ch01/erc20.md:5 -msgid "To create an ERC20 conctract, it must implement the following interface:" +msgid "" +"To create an ERC20 conctract, it must implement the following interface:" msgstr "要创建 ERC20 合约,必须实现以下接口:" #: src/ch01/erc20.md:7 @@ -4553,8 +4785,8 @@ msgid "" " self: @TContractState, owner: ContractAddress, spender: " "ContractAddress\n" " ) -> felt252;\n" -" fn transfer(ref self: TContractState, recipient: ContractAddress, amount: " -"felt252);\n" +" fn transfer(ref self: TContractState, recipient: ContractAddress, " +"amount: felt252);\n" " fn transfer_from(\n" " ref self: TContractState,\n" " sender: ContractAddress,\n" @@ -4563,11 +4795,11 @@ msgid "" " );\n" " fn approve(ref self: TContractState, spender: ContractAddress, amount: " "felt252);\n" -" fn increase_allowance(ref self: TContractState, spender: ContractAddress, " -"added_value: felt252);\n" +" fn increase_allowance(ref self: TContractState, spender: " +"ContractAddress, added_value: felt252);\n" " fn decrease_allowance(\n" -" ref self: TContractState, spender: ContractAddress, subtracted_value: " -"felt252\n" +" ref self: TContractState, spender: ContractAddress, " +"subtracted_value: felt252\n" " );\n" "}\n" "```" @@ -4585,8 +4817,8 @@ msgstr "" " self: @TContractState, owner: ContractAddress, spender: " "ContractAddress\n" " ) -> felt252;\n" -" fn transfer(ref self: TContractState, recipient: ContractAddress, amount: " -"felt252);\n" +" fn transfer(ref self: TContractState, recipient: ContractAddress, " +"amount: felt252);\n" " fn transfer_from(\n" " ref self: TContractState,\n" " sender: ContractAddress,\n" @@ -4595,11 +4827,11 @@ msgstr "" " );\n" " fn approve(ref self: TContractState, spender: ContractAddress, amount: " "felt252);\n" -" fn increase_allowance(ref self: TContractState, spender: ContractAddress, " -"added_value: felt252);\n" +" fn increase_allowance(ref self: TContractState, spender: " +"ContractAddress, added_value: felt252);\n" " fn decrease_allowance(\n" -" ref self: TContractState, spender: ContractAddress, subtracted_value: " -"felt252\n" +" ref self: TContractState, spender: ContractAddress, " +"subtracted_value: felt252\n" " );\n" "}\n" "```" @@ -4611,9 +4843,9 @@ msgid "" "The Starknet ERC20 interface is therefore slightly different from the " "Solidity ERC20 interface." msgstr "" -"在Starknet中,函数名应该使用*snake_case*(蛇形命名法)。而在Solidity中,函数名" -"使用*camelCase*(驼峰命名法)。因此,Starknet的ERC20接口与Solidity的ERC20接口" -"略有不同。" +"在Starknet中,函数名应该使用*snake_case*(蛇形命名法)。而在Solidity中,函数" +"名使用*camelCase*(驼峰命名法)。因此,Starknet的ERC20接口与Solidity的ERC20接" +"口略有不同。" #: src/ch01/erc20.md:36 msgid "Here's an implementation of the ERC20 interface in Cairo:" @@ -4730,8 +4962,8 @@ msgid "" " self._transfer(sender, recipient, amount);\n" " }\n" "\n" -" fn approve(ref self: ContractState, spender: ContractAddress, amount: " -"felt252) {\n" +" fn approve(ref self: ContractState, spender: ContractAddress, " +"amount: felt252) {\n" " let caller = get_caller_address();\n" " self.approve_helper(caller, spender, amount);\n" " }\n" @@ -4931,8 +5163,8 @@ msgstr "" " self._transfer(sender, recipient, amount);\n" " }\n" "\n" -" fn approve(ref self: ContractState, spender: ContractAddress, amount: " -"felt252) {\n" +" fn approve(ref self: ContractState, spender: ContractAddress, " +"amount: felt252) {\n" " let caller = get_caller_address();\n" " self.approve_helper(caller, spender, amount);\n" " }\n" @@ -5024,10 +5256,11 @@ msgstr "" "```" #: src/ch01/erc20.md:224 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch01-applications/erc20/src/token.cairo)." +"blob/main/listings/applications/erc20/src/token.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." "com/NethermindEth/StarknetByExample/blob/main/listings/ch01-applications/" @@ -5040,12 +5273,8 @@ msgid "" "(https://cairo-by-example.com/examples/erc20/) ones." msgstr "" "还有一些其他的实现,比如 [Open Zeppelin](https://docs.openzeppelin.com/" -"contracts-cairo/0.7.0/erc20) 或者 [Cairo By Example](https://cairo-by-example." -"com/examples/erc20/) 中的实现。" - -#: src/ch01/erc20.md:228 -msgid "
Last change: 2023-10-24
" -msgstr "
Last change: 2023-10-24
" +"contracts-cairo/0.7.0/erc20) 或者 [Cairo By Example](https://cairo-by-" +"example.com/examples/erc20/) 中的实现。" #: src/ch01/constant-product-amm.md:1 msgid "# Constant Product AMM" @@ -5053,8 +5282,8 @@ msgstr "# 恒定乘积自动做市商" #: src/ch01/constant-product-amm.md:3 msgid "" -"This is the Cairo adaptation of the [Solidity by example Constant Product AMM]" -"(https://solidity-by-example.org/defi/constant-product-amm/)." +"This is the Cairo adaptation of the [Solidity by example Constant Product " +"AMM](https://solidity-by-example.org/defi/constant-product-amm/)." msgstr "" "这个是 用Cairo 改编的 [Solidity by example Constant Product AMM](https://" "solidity-by-example.org/defi/constant-product-amm/)." @@ -5068,8 +5297,8 @@ msgid "" "trait IConstantProductAmm {\n" " fn swap(ref self: TContractState, token_in: ContractAddress, amount_in: " "u256) -> u256;\n" -" fn add_liquidity(ref self: TContractState, amount0: u256, amount1: u256) -" -"> u256;\n" +" fn add_liquidity(ref self: TContractState, amount0: u256, amount1: u256) " +"-> u256;\n" " fn remove_liquidity(ref self: TContractState, shares: u256) -> (u256, " "u256);\n" "}\n" @@ -5131,8 +5360,8 @@ msgid "" " }\n" "\n" " #[inline(always)]\n" -" fn select_token(self: @ContractState, token: ContractAddress) -> bool " -"{\n" +" fn select_token(self: @ContractState, token: ContractAddress) -> " +"bool {\n" " assert(\n" " token == self.token0.read().contract_address\n" " || token == self.token1.read().contract_address,\n" @@ -5187,8 +5416,8 @@ msgid "" "\n" " let amount_in_with_fee = (amount_in * (1000 - self.fee.read()." "into()) / 1000);\n" -" let amount_out = (reserve_out * amount_in_with_fee) / (reserve_in " -"+ amount_in_with_fee);\n" +" let amount_out = (reserve_out * amount_in_with_fee) / " +"(reserve_in + amount_in_with_fee);\n" "\n" " token_out.transfer(caller, amount_out);\n" "\n" @@ -5339,8 +5568,8 @@ msgid "" "\n" " // bal0 >= reserve0\n" " // bal1 >= reserve1\n" -" let (bal0, bal1): (u256, u256) = (token0.balance_of(this), token1." -"balance_of(this));\n" +" let (bal0, bal1): (u256, u256) = (token0.balance_of(this), " +"token1.balance_of(this));\n" "\n" " let total_supply = self.total_supply.read();\n" " let (amount0, amount1): (u256, u256) = (\n" @@ -5367,8 +5596,8 @@ msgstr "" "trait IConstantProductAmm {\n" " fn swap(ref self: TContractState, token_in: ContractAddress, amount_in: " "u256) -> u256;\n" -" fn add_liquidity(ref self: TContractState, amount0: u256, amount1: u256) -" -"> u256;\n" +" fn add_liquidity(ref self: TContractState, amount0: u256, amount1: u256) " +"-> u256;\n" " fn remove_liquidity(ref self: TContractState, shares: u256) -> (u256, " "u256);\n" "}\n" @@ -5430,8 +5659,8 @@ msgstr "" " }\n" "\n" " #[inline(always)]\n" -" fn select_token(self: @ContractState, token: ContractAddress) -> bool " -"{\n" +" fn select_token(self: @ContractState, token: ContractAddress) -> " +"bool {\n" " assert(\n" " token == self.token0.read().contract_address\n" " || token == self.token1.read().contract_address,\n" @@ -5486,8 +5715,8 @@ msgstr "" "\n" " let amount_in_with_fee = (amount_in * (1000 - self.fee.read()." "into()) / 1000);\n" -" let amount_out = (reserve_out * amount_in_with_fee) / (reserve_in " -"+ amount_in_with_fee);\n" +" let amount_out = (reserve_out * amount_in_with_fee) / " +"(reserve_in + amount_in_with_fee);\n" "\n" " token_out.transfer(caller, amount_out);\n" "\n" @@ -5638,8 +5867,8 @@ msgstr "" "\n" " // bal0 >= reserve0\n" " // bal1 >= reserve1\n" -" let (bal0, bal1): (u256, u256) = (token0.balance_of(this), token1." -"balance_of(this));\n" +" let (bal0, bal1): (u256, u256) = (token0.balance_of(this), " +"token1.balance_of(this));\n" "\n" " let total_supply = self.total_supply.read();\n" " let (amount0, amount1): (u256, u256) = (\n" @@ -5660,10 +5889,11 @@ msgstr "" "```" #: src/ch01/constant-product-amm.md:274 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch01-applications/constant_product_amm/src/" +"blob/main/listings/applications/constant_product_amm/src/" "constant_product_amm.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." @@ -5679,9 +5909,9 @@ msgid "" "On Starknet, a contract's storage is a map with 2^251 slots, where each slot " "is a felt which is initialized to 0.\n" "The address of storage variables is computed at compile time using the " -"formula: `storage variable address := pedersen(keccak(variable name), keys)`. " -"Interactions with storage variables are commonly performed using the `self." -"var.read()` and `self.var.write()` functions." +"formula: `storage variable address := pedersen(keccak(variable name), " +"keys)`. Interactions with storage variables are commonly performed using the " +"`self.var.read()` and `self.var.write()` functions." msgstr "" "在Starknet上,一个合约的存储是一个拥有 2^251 个槽的map,每个槽是一个初始化为 " "0 的 felt。存储变量的地址在编译时通过公式计算得出:`存储变量地址 := " @@ -5691,7 +5921,8 @@ msgstr "" #: src/ch02/write_to_any_slot.md:6 msgid "" "Nevertheless, we can use the `storage_write_syscall` and " -"`storage_read_syscall` syscalls, to write to and read from any storage slot.\n" +"`storage_read_syscall` syscalls, to write to and read from any storage " +"slot.\n" "This is useful when writing to storage variables that are not known at " "compile time, or to ensure that even if the contract is upgraded and the " "computation method of storage variable addresses changes, they remain " @@ -5699,8 +5930,8 @@ msgid "" msgstr "" "然而,我们可以使用 `storage_write_syscall` 和 `storage_read_syscall` 系统调" "用,来对任何存储槽进行写入和读取。\n" -"这在写入那些在编译时还未确定的存储变量时非常有用,这也可以确保即使合约升级且存" -"储变量地址的计算方法改变,这些变量仍然可访问。" +"这在写入那些在编译时还未确定的存储变量时非常有用,这也可以确保即使合约升级且" +"存储变量地址的计算方法改变,这些变量仍然可访问。" #: src/ch02/write_to_any_slot.md:9 msgid "" @@ -5710,9 +5941,9 @@ msgid "" "onchain computations. Once the address is computed, we use the storage " "syscalls to interact with it." msgstr "" -"在以下示例中,我们使用 Poseidon 哈希函数来计算存储变量的地址。Poseidon 是一个 " -"ZK 友好的哈希函数,比 Pedersen 更便宜、更快,是链上计算的绝佳选择。一旦地址被" -"计算出来,我们就使用存储的系统调用与之交互。" +"在以下示例中,我们使用 Poseidon 哈希函数来计算存储变量的地址。Poseidon 是一" +"个 ZK 友好的哈希函数,比 Pedersen 更便宜、更快,是链上计算的绝佳选择。一旦地" +"址被计算出来,我们就使用存储的系统调用与之交互。" #: src/ch02/write_to_any_slot.md:11 msgid "" @@ -5817,13 +6048,13 @@ msgstr "" "```" #: src/ch02/write_to_any_slot.md:56 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x033943CB781A4E63C9dcE0A1A09eAa3b617AA43CC61637C08c043a67f3fe0087) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch02-advanced-concepts/write_to_any_slot/src/contract." -"cairo)." +"blob/main/listings/advanced-concepts/write_to_any_slot/src/contract.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" "contract/0x033943CB781A4E63C9dcE0A1A09eAa3b617AA43CC61637C08c043a67f3fe0087) " @@ -5847,31 +6078,31 @@ msgid "" "for storing arrays in Cairo, so you will need to write your own " "implementation of the `Store` trait for the type of array you wish to store." msgstr "" -"在Starknet上,复杂值(例如元组或结构体)存储在以该存储变量地址开头的连续段中。" -"复杂存储值的大小有 256 个元素的限制,这意味着要在存储中存储超过 255 个元素的数" -"组,我们需要将其分割为大小 `n <= 255` 的段,并将这些段存储在多个存储地址中。目" -"前 Cairo 没有原生支持存储数组,所以你需要为你希望存储的数组类型实现自己的 " -"`Store` 特性。" +"在Starknet上,复杂值(例如元组或结构体)存储在以该存储变量地址开头的连续段" +"中。复杂存储值的大小有 256 个元素的限制,这意味着要在存储中存储超过 255 个元" +"素的数组,我们需要将其分割为大小 `n <= 255` 的段,并将这些段存储在多个存储地" +"址中。目前 Cairo 没有原生支持存储数组,所以你需要为你希望存储的数组类型实现自" +"己的 `Store` 特性。" #: src/ch02/storing_arrays.md:5 msgid "" "> Note: While storing arrays in storage is possible, it is not always " "recommended, as the read and write operations can get very costly. For " -"example, reading an array of size `n` requires `n` storage reads, and writing " -"to an array of size `n` requires `n` storage writes. If you only need to " -"access a single element of the array at a time, it is recommended to use a " -"`LegacyMap` and store the length in another variable instead." +"example, reading an array of size `n` requires `n` storage reads, and " +"writing to an array of size `n` requires `n` storage writes. If you only " +"need to access a single element of the array at a time, it is recommended to " +"use a `LegacyMap` and store the length in another variable instead." msgstr "" -"> 注:虽然在存储中保存数组是可行的,但并不总是推荐这么做,因为读写操作的成本可" -"能非常高。例如,读取一个大小为 n 的数组需要进行 `n` 次存储读取,而向一个大小" -"为 `n` 的数组写入需要进行 `n` 次存储写入。如果你只需要一次访问数组中的一个元" -"素,建议使用 `LegacyMap` 并在另一个变量中存储数组长度。" +"> 注:虽然在存储中保存数组是可行的,但并不总是推荐这么做,因为读写操作的成本" +"可能非常高。例如,读取一个大小为 n 的数组需要进行 `n` 次存储读取,而向一个大" +"小为 `n` 的数组写入需要进行 `n` 次存储写入。如果你只需要一次访问数组中的一个" +"元素,建议使用 `LegacyMap` 并在另一个变量中存储数组长度。" #: src/ch02/storing_arrays.md:7 msgid "" "The following example demonstrates how to write a simple implementation of " -"the `StorageAccess` trait for the `Array` type, allowing us to store " -"arrays of up to 255 `felt252` elements." +"the `StorageAccess` trait for the `Array` type, allowing us to " +"store arrays of up to 255 `felt252` elements." msgstr "" "以下示例展示了如何为 `Array` 类型实现一个简单的 `StorageAccess` 特" "性,使我们能够存储多达 255 个 `felt252` 元素的数组。" @@ -5886,7 +6117,8 @@ msgid "" " }\n" "\n" " fn write(\n" -" address_domain: u32, base: StorageBaseAddress, value: Array\n" +" address_domain: u32, base: StorageBaseAddress, value: " +"Array\n" " ) -> SyscallResult<()> {\n" " StoreFelt252Array::write_at_offset(address_domain, base, 0, value)\n" " }\n" @@ -5958,7 +6190,8 @@ msgstr "" " }\n" "\n" " fn write(\n" -" address_domain: u32, base: StorageBaseAddress, value: Array\n" +" address_domain: u32, base: StorageBaseAddress, value: " +"Array\n" " ) -> SyscallResult<()> {\n" " StoreFelt252Array::write_at_offset(address_domain, base, 0, value)\n" " }\n" @@ -6089,19 +6322,20 @@ msgstr "" "```" #: src/ch02/storing_arrays.md:103 +#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x008F8069a3Fcd7691Db46Dc3b6F9D2C0436f9200E861330957Fd780A3595da86) " "or play with it in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch02-advanced-concepts/storing_arrays/src/contract.cairo)." +"blob/main/listings/advanced-concepts/storing_arrays/src/contract.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" "contract/0x008F8069a3Fcd7691Db46Dc3b6F9D2C0436f9200E861330957Fd780A3595da86) " "上的合约,或者在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch02-advanced-concepts/storing_arrays/src/contract.cairo)上" -"测试." +"blob/main/listings/ch02-advanced-concepts/storing_arrays/src/contract.cairo)" +"上测试." #: src/ch02/struct-mapping-key.md:1 msgid "# Structs as mapping keys" @@ -6109,12 +6343,13 @@ msgstr "# 结构体作为映射键" #: src/ch02/struct-mapping-key.md:3 msgid "" -"In order to use structs as mapping keys, you can use `#[derive(Hash)]` on the " -"struct definition. This will automatically generate a hash function for the " -"struct that can be used to represent the struct as a key in a `LegacyMap`." +"In order to use structs as mapping keys, you can use `#[derive(Hash)]` on " +"the struct definition. This will automatically generate a hash function for " +"the struct that can be used to represent the struct as a key in a " +"`LegacyMap`." msgstr "" -"为了使用结构体作为映射键,您可以在结构体定义上使用 `#[derive(Hash)]`。这将为结" -"构体自动生成一个哈希函数,可以在 `LegacyMap` 中将该结构体作为键来使用。" +"为了使用结构体作为映射键,您可以在结构体定义上使用 `#[derive(Hash)]`。这将为" +"结构体自动生成一个哈希函数,可以在 `LegacyMap` 中将该结构体作为键来使用。" #: src/ch02/struct-mapping-key.md:5 msgid "" @@ -6123,9 +6358,9 @@ msgid "" "`name`, `age` and `owner`. We consider that the combination of these three " "fields uniquely identifies a pet." msgstr "" -"考虑以下示例,我们希望使用类型为 `Pet` 的对象作为 `LegacyMap` 中的键。`Pet` 结" -"构体有三个字段:`name` 、`age` 和 `owner`。假设这三个字段的组合能唯一地标识一" -"只宠物。" +"考虑以下示例,我们希望使用类型为 `Pet` 的对象作为 `LegacyMap` 中的键。`Pet` " +"结构体有三个字段:`name` 、`age` 和 `owner`。假设这三个字段的组合能唯一地标识" +"一只宠物。" #: src/ch02/struct-mapping-key.md:8 msgid "" @@ -6155,7 +6390,8 @@ msgid "" "\n" " #[abi(embed_v0)]\n" " impl PetRegistry of super::IPetRegistry {\n" -" fn register_pet(ref self: ContractState, key: Pet, timestamp: u64) {\n" +" fn register_pet(ref self: ContractState, key: Pet, timestamp: u64) " +"{\n" " self.registration_time.write(key, timestamp);\n" " }\n" "\n" @@ -6192,7 +6428,8 @@ msgstr "" "\n" " #[abi(embed_v0)]\n" " impl PetRegistry of super::IPetRegistry {\n" -" fn register_pet(ref self: ContractState, key: Pet, timestamp: u64) {\n" +" fn register_pet(ref self: ContractState, key: Pet, timestamp: u64) " +"{\n" " self.registration_time.write(key, timestamp);\n" " }\n" "\n" @@ -6204,15 +6441,16 @@ msgstr "" "```" #: src/ch02/struct-mapping-key.md:45 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch02-advanced-concepts/struct_as_mapping_key/src/contract." +"blob/main/listings/advanced-concepts/struct_as_mapping_key/src/contract." "cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch02-advanced-concepts/" -"struct_as_mapping_key/src/contract.cairo) 上测试这个合约." +"com/NethermindEth/StarknetByExample/blob/main/listings/ch02-advanced-" +"concepts/struct_as_mapping_key/src/contract.cairo) 上测试这个合约." #: src/ch02/hash-solidity-compatible.md:1 msgid "# Hash Solidity Compatible" @@ -6227,8 +6465,8 @@ msgid "" "result with `u128_byte_reverse`." msgstr "" "这个合约展示了在 Cairo 中进行 Keccak 哈希处理以匹配 Solidity 的 keccak256。尽" -"管两者都使用 Keccak,但它们的字节序不同:Cairo 是小端序,Solidity 是大端序。该" -"合约通过使用 `keccak_u256s_be_inputs` 以大端序进行哈希处理,并使用 " +"管两者都使用 Keccak,但它们的字节序不同:Cairo 是小端序,Solidity 是大端序。" +"该合约通过使用 `keccak_u256s_be_inputs` 以大端序进行哈希处理,并使用 " "`u128_byte_reverse` 反转结果的字节来实现兼容。" #: src/ch02/hash-solidity-compatible.md:7 @@ -6249,9 +6487,10 @@ msgid "" " struct Storage {}\n" "\n" " #[abi(embed_v0)]\n" -" impl SolidityHashExample of super::ISolidityHashExample {\n" -" fn hash_data(ref self: ContractState, input_data: Span) -> u256 " +" impl SolidityHashExample of super::ISolidityHashExample " "{\n" +" fn hash_data(ref self: ContractState, input_data: Span) -> " +"u256 {\n" " let hashed = keccak_u256s_be_inputs(input_data);\n" "\n" " // Split the hashed value into two 128-bit segments\n" @@ -6288,9 +6527,10 @@ msgstr "" " struct Storage {}\n" "\n" " #[abi(embed_v0)]\n" -" impl SolidityHashExample of super::ISolidityHashExample {\n" -" fn hash_data(ref self: ContractState, input_data: Span) -> u256 " +" impl SolidityHashExample of super::ISolidityHashExample " "{\n" +" fn hash_data(ref self: ContractState, input_data: Span) -> " +"u256 {\n" " let hashed = keccak_u256s_be_inputs(input_data);\n" "\n" " // Split the hashed value into two 128-bit segments\n" @@ -6312,19 +6552,16 @@ msgstr "" "```" #: src/ch02/hash-solidity-compatible.md:44 +#, fuzzy msgid "" "Play with the contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch02-advanced-concepts/hash_solidity_compatible/src/" -"contract.cairo)." +"blob/main/listings/advanced-concepts/hash_solidity_compatible/src/contract." +"cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch02-advanced-concepts/" -"hash_solidity_compatible/src/contract.cairo) 上测试这个合约." - -#: src/ch02/hash-solidity-compatible.md:46 -msgid "
Last change: 2023-11-21
" -msgstr "
Last change: 2023-11-21
" +"com/NethermindEth/StarknetByExample/blob/main/listings/ch02-advanced-" +"concepts/hash_solidity_compatible/src/contract.cairo) 上测试这个合约." #: src/ch02/optimisations/optimisations.md:1 msgid "# Optimisations " @@ -6372,19 +6609,19 @@ msgid "" "multiple values." msgstr "" "当存储多个值时,我们可以使用一种称为 **打包(packing)** 的技术。打包是一种允许" -"我们在单个 felt 值中存储多个值的技术。这是通过使用 felt 值的位来存储多个值来实" -"现的。" +"我们在单个 felt 值中存储多个值的技术。这是通过使用 felt 值的位来存储多个值来" +"实现的。" #: src/ch02/optimisations/store_using_packing.md:13 msgid "" -"For example, if we want to store two `u8` values, we can use the first 8 bits " -"of the felt value to store the first `u8` value, and the last 8 bits to store " -"the second `u8` value. This way, we can store two `u8` values in a single " -"felt value." +"For example, if we want to store two `u8` values, we can use the first 8 " +"bits of the felt value to store the first `u8` value, and the last 8 bits to " +"store the second `u8` value. This way, we can store two `u8` values in a " +"single felt value." msgstr "" "例如,如果我们想存储两个 `u8` 值,我们可以使用 felt 值的前 8 位来存储第一个 " -"`u8` 值,而使用后 8 位来存储第二个 `u8` 值。这样,我们就可以在单个 felt 值中存" -"储两个 `u8` 值。" +"`u8` 值,而使用后 8 位来存储第二个 `u8` 值。这样,我们就可以在单个 felt 值中" +"存储两个 `u8` 值。" #: src/ch02/optimisations/store_using_packing.md:15 msgid "" @@ -6411,22 +6648,23 @@ msgstr "" #: src/ch02/optimisations/store_using_packing.md:24 msgid "" -"This allows to store the type `T` by first packing it into the type `PackedT` " -"with the `pack` function, and then storing the `PackedT` value with it's " -"`Store` implementation. When reading the value, we first retrieve the " -"`PackedT` value, and then unpack it into the type `T` using the `unpack` " +"This allows to store the type `T` by first packing it into the type " +"`PackedT` with the `pack` function, and then storing the `PackedT` value " +"with it's `Store` implementation. When reading the value, we first retrieve " +"the `PackedT` value, and then unpack it into the type `T` using the `unpack` " "function." msgstr "" "这允许通过首先使用 `pack` 函数将类型 `T` 打包成 `PackedT` 类型,然后使用其 " -"`Store` 实现来存储 `PackedT` 值。在读取值时,我们首先获取 `PackedT` 值,然后使" -"用 `unpack` 函数将其解包为类型 `T`。" +"`Store` 实现来存储 `PackedT` 值。在读取值时,我们首先获取 `PackedT` 值,然后" +"使用 `unpack` 函数将其解包为类型 `T`。" #: src/ch02/optimisations/store_using_packing.md:26 msgid "" "Here's an example of storing a `Time` struct with two `u8` values using the " "`StorePacking` trait:" msgstr "" -"以下是一个使用 `StorePacking` 特性存储包含两个 `u8` 值的 `Time` 结构体的示例:" +"以下是一个使用 `StorePacking` 特性存储包含两个 `u8` 值的 `Time` 结构体的示" +"例:" #: src/ch02/optimisations/store_using_packing.md:28 msgid "" @@ -6486,8 +6724,8 @@ msgid "" " }\n" " fn get(self: @ContractState) -> Time {\n" " // This will read the felt252 value from storage\n" -" // and return the result of the unpack method of the TimePackable " -"trait\n" +" // and return the result of the unpack method of the " +"TimePackable trait\n" " return self.time.read();\n" " }\n" " }\n" @@ -6550,8 +6788,8 @@ msgstr "" " }\n" " fn get(self: @ContractState) -> Time {\n" " // This will read the felt252 value from storage\n" -" // and return the result of the unpack method of the TimePackable " -"trait\n" +" // and return the result of the unpack method of the " +"TimePackable trait\n" " return self.time.read();\n" " }\n" " }\n" @@ -6559,16 +6797,17 @@ msgstr "" "```" #: src/ch02/optimisations/store_using_packing.md:88 +#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet-cairo1-compiler&url=https://github.com/NethermindEth/" -"StarknetByExample/blob/main/listings/ch02-advanced-concepts/" -"store_using_packing/src/contract.cairo)." +"StarknetByExample/blob/main/listings/advanced-concepts/store_using_packing/" +"src/contract.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet-cairo1-" "compiler&url=https://github.com/NethermindEth/StarknetByExample/blob/main/" -"listings/ch02-advanced-concepts/store_using_packing/src/contract.cairo) 上测试" -"这个合约." +"listings/ch02-advanced-concepts/store_using_packing/src/contract.cairo) 上测" +"试这个合约." #: src/ch02/list.md:1 msgid "# List" @@ -6674,9 +6913,9 @@ msgid "" "trait. You can have the compiler derive it for you using the " "`#[derive(starknet::Store)]` attribute." msgstr "" -"`List` 默认支持大多数 corelib 类型。如果您想在 `List` 中存储自己的自定义类型," -"该类型必须实现 `Store` 特性。您可以使用 `#[derive(starknet::Store)]` 属性让编" -"译器自动生成。" +"`List` 默认支持大多数 corelib 类型。如果您想在 `List` 中存储自己的自定义类" +"型,该类型必须实现 `Store` 特性。您可以使用 `#[derive(starknet::Store)]` 属性" +"让编译器自动生成。" #: src/ch02/list.md:42 msgid "### Caveats" @@ -6694,8 +6933,8 @@ msgid "" "operations with a single inline statement. For example, `self.amounts.read()." "append(42);` will not work. You have to do it in 2 steps:" msgstr "" -"1. `append` 操作消耗 2 次存储写入操作 - 一次是为了值本身,另一次是为了更新列表" -"的长度。\n" +"1. `append` 操作消耗 2 次存储写入操作 - 一次是为了值本身,另一次是为了更新列" +"表的长度。\n" "2. 由于编译器的限制,不能使用单个内联语句进行变更操作。例如,`self.amounts." "read().append(42);` 是不行的。你必须分两步进行:" @@ -6781,8 +7020,8 @@ msgid "" " current_amount_list.append(number);\n" " }\n" "\n" -" fn add_in_task(ref self: ContractState, description: felt252, status: " -"felt252) {\n" +" fn add_in_task(ref self: ContractState, description: felt252, " +"status: felt252) {\n" " let new_task = Task { description: description, status: " "status };\n" " let mut current_tasks_list = self.tasks.read();\n" @@ -6860,8 +7099,8 @@ msgstr "" " current_amount_list.append(number);\n" " }\n" "\n" -" fn add_in_task(ref self: ContractState, description: felt252, status: " -"felt252) {\n" +" fn add_in_task(ref self: ContractState, description: felt252, " +"status: felt252) {\n" " let new_task = Task { description: description, status: " "status };\n" " let mut current_tasks_list = self.tasks.read();\n" @@ -6901,6 +7140,42 @@ msgstr "" "}\n" "```" -#: src/ch02/list.md:139 -msgid "
Last change: 2023-11-27
" -msgstr "
Last change: 2023-11-27
" +#~ msgid "Here's a list of other resources that you might find useful:" +#~ msgstr "以下是您可能会用到的其他资源清单:" + +#~ msgid "" +#~ "- [Starklings](https://github.com/shramee/starklings-cairo1): An " +#~ "interactive tutorial to get you up and running with Cairo v1 and " +#~ "Starknet \n" +#~ "- [Cairopractice](https://cairopractice.com/): A blog with a series of " +#~ "articles about Cairo and Starknet\n" +#~ "- [Cairo by example](https://cairo-by-example.com/): An introduction to " +#~ "Cairo, with simple examples" +#~ msgstr "" +#~ "- [Starklings](https://github.com/shramee/starklings-cairo1):让您使用 " +#~ "Cairo v1 和Starknet互动的教程\n" +#~ "- [Cairopractice](https://cairopractice.com/):关于Cairo和Starknet的一系列" +#~ "文章的博客\n" +#~ "- [Cairo by example](https://cairo-by-example.com/):Cairo 简介,附带简单" +#~ "示例" + +#~ msgid "
Last change: 2023-11-20
" +#~ msgstr "
Last change: 2023-11-20
" + +#~ msgid "
Last change: 2023-11-04
" +#~ msgstr "
Last change: 2023-11-04
" + +#~ msgid "
Last change: 2023-11-26
" +#~ msgstr "
Last change: 2023-11-26
" + +#~ msgid "
Last change: 2023-11-30
" +#~ msgstr "
Last change: 2023-11-30
" + +#~ msgid "
Last change: 2023-10-24
" +#~ msgstr "
Last change: 2023-10-24
" + +#~ msgid "
Last change: 2023-11-21
" +#~ msgstr "
Last change: 2023-11-21
" + +#~ msgid "
Last change: 2023-11-27
" +#~ msgstr "
Last change: 2023-11-27
" From a24df3104d4c14c424b88cc67c9413e656230e38 Mon Sep 17 00:00:00 2001 From: cryptonerdcn Date: Fri, 8 Dec 2023 14:49:51 +0900 Subject: [PATCH 3/3] Rebase&Fix links. --- po/zh-cn.po | 853 ++++++++++++++++++++++++---------------------------- 1 file changed, 398 insertions(+), 455 deletions(-) diff --git a/po/zh-cn.po b/po/zh-cn.po index af3218e9..43732e9b 100644 --- a/po/zh-cn.po +++ b/po/zh-cn.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: Starknet by Example\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2023-12-07 16:56+0900\n" +"PO-Revision-Date: 2023-12-08 14:49+0900\n" "Last-Translator: StarknetAstro \n" "Language-Team: Language zh-cn\n" "Language: zh_CN\n" @@ -133,9 +133,8 @@ msgid "Components How-To" msgstr "" #: src/SUMMARY.md:39 -#, fuzzy msgid "Applications" -msgstr "应用实例" +msgstr "应用" #: src/SUMMARY.md:40 msgid "Upgradeable Contract" @@ -194,8 +193,7 @@ msgid "" "Starknet By Example is a collection of examples of how to use the Cairo " "programming language to create smart contracts on Starknet." msgstr "" -"Starknet By Example是如何使用Cairo编程语言在Starknet上创建智能合约的范例" -"集。\n" +"Starknet By Example是如何使用Cairo编程语言在Starknet上创建智能合约的范例集。\n" "中文版由 [StarknetAstro](https://twitter.com/StarkNetAstroCN) 社区翻译。" #: src/starknet-by-example.md:5 @@ -209,12 +207,12 @@ msgstr "" #: src/starknet-by-example.md:7 msgid "" -"Starknet smart contracts are written in the Cairo language. Cairo is a " -"Turing-complete programming language designed to write provable programs, " +"Starknet smart contracts are written in the Cairo language. Cairo is a Turing-" +"complete programming language designed to write provable programs, " "abstracting the zk-STARK proof system away from the programmer." msgstr "" -"Starknet智能合约是用Cairo语言编写的。Cairo语言是一种图灵完备的编程语言,旨在" -"编写可证明的程序,将 zk-STARK 证明系统从程序员手中抽象出来。" +"Starknet智能合约是用Cairo语言编写的。Cairo语言是一种图灵完备的编程语言,旨在编" +"写可证明的程序,将 zk-STARK 证明系统从程序员手中抽象出来。" #: src/starknet-by-example.md:9 msgid "The current version of this book use:" @@ -248,8 +246,8 @@ msgid "" "smart contracts on Starknet using Cairo with some technical background in " "programming and blockchain." msgstr "" -"Starknet By Example适合想要快速学习如何使用 Cairo 在 Starknet 上编写智能合" -"约,并具有一定编程和区块链技术背景的人。" +"Starknet By Example适合想要快速学习如何使用 Cairo 在 Starknet 上编写智能合约," +"并具有一定编程和区块链技术背景的人。" #: src/starknet-by-example.md:21 msgid "" @@ -282,8 +280,8 @@ msgstr "" #: src/starknet-by-example.md:29 msgid "" -"For more resources, check [Awesome Starknet](https://github.com/keep-" -"starknet-strange/awesome-starknet)." +"For more resources, check [Awesome Starknet](https://github.com/keep-starknet-" +"strange/awesome-starknet)." msgstr "" #: src/starknet-by-example.md:31 src/ch00/basics/storage.md:34 @@ -294,8 +292,8 @@ msgstr "" #: src/ch00/basics/custom-types-in-entrypoints.md:39 #: src/ch00/interacting/interfaces-traits.md:129 #: src/ch00/interacting/calling_other_contracts.md:69 -#: src/ch00/testing/contract-testing.md:176 -#: src/ch00/cairo_cheatsheet/felt.md:15 src/ch00/cairo_cheatsheet/mapping.md:58 +#: src/ch00/testing/contract-testing.md:176 src/ch00/cairo_cheatsheet/felt.md:15 +#: src/ch00/cairo_cheatsheet/mapping.md:58 #: src/ch00/cairo_cheatsheet/arrays.md:42 src/ch00/cairo_cheatsheet/loop.md:23 #: src/ch00/cairo_cheatsheet/match.md:59 src/ch00/cairo_cheatsheet/tuples.md:18 #: src/ch00/cairo_cheatsheet/struct.md:15 @@ -305,9 +303,8 @@ msgstr "" #: src/ch02/write_to_any_slot.md:58 src/ch02/storing_arrays.md:105 #: src/ch02/struct-mapping-key.md:46 src/ch02/hash-solidity-compatible.md:46 #: src/ch02/optimisations/store_using_packing.md:90 src/ch02/list.md:139 -#, fuzzy msgid "
Last change: 2023-12-07
" -msgstr "
Last change: 2023-12-06
" +msgstr "
Last change: 2023-12-07
" #: src/ch00/basics/introduction.md:1 msgid "# Basics of Smart Contracts in Cairo" @@ -315,8 +312,8 @@ msgstr "# Cairo的智能合约基础知识" #: src/ch00/basics/introduction.md:3 msgid "" -"The following chapters will introduce you to Starknet smart contracts and " -"how to write them in Cairo." +"The following chapters will introduce you to Starknet smart contracts and how " +"to write them in Cairo." msgstr "以下章节将向你介绍Starknet智能合约以及如何用Cairo编写这些合约。" #: src/ch00/basics/introduction.md:5 src/ch02/optimisations/optimisations.md:5 @@ -353,8 +350,8 @@ msgstr "" msgid "" "Storage is a struct annoted with `#[storage]`. Every contract must have one " "and only one storage.\n" -"It's a key-value store, where each key will be mapped to a storage address " -"of the contract's storage space." +"It's a key-value store, where each key will be mapped to a storage address of " +"the contract's storage space." msgstr "" "存储是一个结构体,用 `#[storage]`标注。每个合约必须有且仅有一个存储空间。\n" "它是一个键值存储空间,其中每个键都将映射到合约存储空间的存储地址。" @@ -419,17 +416,17 @@ msgid "" "constructor function must be annotated with the `#[constructor]` attribute. " "Also, a good practice consists in naming that function `constructor`." msgstr "" -"构造函数是一种特殊类型的函数,只在部署合约时运行一次,可用于初始化合约的状" -"态。你的合约不能有一个以上的构造函数,而且构造函数必须使用 `#[constructor]` " -"属性注释。此外,一个好的做法是将该函数命名为 `constructor`。" +"构造函数是一种特殊类型的函数,只在部署合约时运行一次,可用于初始化合约的状态。" +"你的合约不能有一个以上的构造函数,而且构造函数必须使用 `#[constructor]` 属性注" +"释。此外,一个好的做法是将该函数命名为 `constructor`。" #: src/ch00/basics/constructor.md:5 msgid "" "Here's a simple example that demonstrates how to initialize the state of a " "contract on deployment by defining logic inside a constructor." msgstr "" -"下面是一个简单的示例,演示如何通过在构造函数中定义逻辑,在部署时初始化合约的" -"状态。" +"下面是一个简单的示例,演示如何通过在构造函数中定义逻辑,在部署时初始化合约的状" +"态。" #: src/ch00/basics/constructor.md:7 msgid "" @@ -474,7 +471,6 @@ msgstr "" "```" #: src/ch00/basics/constructor.md:25 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x017fd6558e67451dA583d123D77F4e2651E91502D08F8F8432355293b11e1f8F) " @@ -486,8 +482,8 @@ msgstr "" "contract/0x017fd6558e67451dA583d123D77F4e2651E91502D08F8F8432355293b11e1f8F) " "上的合约,或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/constructor/src/constructor.cairo) 中" -"尝试它。" +"blob/main/listings/getting-started/constructor/src/constructor.cairo) 中尝试" +"它。" #: src/ch00/basics/variables.md:1 msgid "# Variables" @@ -525,12 +521,12 @@ msgstr "## 局部变量" #: src/ch00/basics/variables.md:17 msgid "" -"Local variables are used and accessed within the scope of a specific " -"function or block of code. They are temporary and exist only for the " -"duration of that particular function or block execution." +"Local variables are used and accessed within the scope of a specific function " +"or block of code. They are temporary and exist only for the duration of that " +"particular function or block execution." msgstr "" -"局部变量在特定函数或代码块的范围内使用和访问。它们是临时的,只在特定函数或代" -"码块执行期间存在。" +"局部变量在特定函数或代码块的范围内使用和访问。它们是临时的,只在特定函数或代码" +"块执行期间存在。" #: src/ch00/basics/variables.md:19 msgid "" @@ -540,9 +536,9 @@ msgid "" "a specific context. They also make the code more readable by giving names to " "intermediate values." msgstr "" -"局部变量存储在内存中,不会存储在区块链上。这就意味着在执行过程中无法访问它" -"们。局部变量可用于存储仅在特定上下文中相关的临时数据。通过为中间值命名,它们" -"还能使代码更具可读性。" +"局部变量存储在内存中,不会存储在区块链上。这就意味着在执行过程中无法访问它们。" +"局部变量可用于存储仅在特定上下文中相关的临时数据。通过为中间值命名,它们还能使" +"代码更具可读性。" #: src/ch00/basics/variables.md:21 msgid "Here's a simple example of a contract with only local variables:" @@ -613,7 +609,6 @@ msgstr "" "```" #: src/ch00/basics/variables.md:50 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x015B3a10F9689BeD741Ca3C210017BC097122CeF76f3cAA191A20ff8b9b56b96) " @@ -621,12 +616,12 @@ msgid "" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" "blob/main/listings/getting-started/variables/src/local_variables.cairo)." msgstr "" -"访问 [Voyager](https://goerli.voyager.online/" +"访问 [Voyager](https://goerli.voyager.online/" "contract/0x015B3a10F9689BeD741Ca3C210017BC097122CeF76f3cAA191A20ff8b9b56b96) " "上的合约,或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/variables/src/local_variables.cairo) " -"中尝试它。" +"blob/main/listings/getting-started/variables/src/local_variables.cairo) 中尝试" +"它。" #: src/ch00/basics/variables.md:52 msgid "## Storage Variables" @@ -635,16 +630,16 @@ msgstr "## 存储用变量" #: src/ch00/basics/variables.md:54 msgid "" "Storage variables are persistent data stored on the blockchain. They can be " -"accessed from one execution to another, allowing the contract to remember " -"and update information over time." +"accessed from one execution to another, allowing the contract to remember and " +"update information over time." msgstr "" -"存储变量是存储在区块链上的持久数据。它们可以在不同的执行过程中被访问,从而使" -"合约能够保存和更新信息。" +"存储变量是存储在区块链上的持久数据。它们可以在不同的执行过程中被访问,从而使合" +"约能够保存和更新信息。" #: src/ch00/basics/variables.md:56 msgid "" -"To write or update a storage variable, you need to interact with the " -"contract through an external entrypoint by sending a transaction." +"To write or update a storage variable, you need to interact with the contract " +"through an external entrypoint by sending a transaction." msgstr "要写入或更新存储变量,需要通过外部入口点发送交易与合约交互。" #: src/ch00/basics/variables.md:58 @@ -726,7 +721,6 @@ msgstr "" "```" #: src/ch00/basics/variables.md:92 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x06eA827B32875483709b785A7F9e846a52776Cd8D42C3fE696218c2624b0DCCa) " @@ -738,8 +732,8 @@ msgstr "" "contract/0x06eA827B32875483709b785A7F9e846a52776Cd8D42C3fE696218c2624b0DCCa) " "上的合约,或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/variables/src/storage_variables." -"cairo) 中尝试它。" +"blob/main/listings/getting-started/variables/src/storage_variables.cairo)中尝" +"试它。" #: src/ch00/basics/variables.md:94 msgid "## Global Variables" @@ -748,11 +742,11 @@ msgstr "## 全局变量" #: src/ch00/basics/variables.md:96 msgid "" "Global variables are predefined variables that provide information about the " -"blockchain and the current execution environment. They can be accessed at " -"any time and from anywhere!" +"blockchain and the current execution environment. They can be accessed at any " +"time and from anywhere!" msgstr "" -"全局变量是预定义变量,可提供有关区块链和当前执行环境的信息。可以随时随地访问" -"它们!" +"全局变量是预定义变量,可提供有关区块链和当前执行环境的信息。可以随时随地访问它" +"们!" #: src/ch00/basics/variables.md:98 msgid "" @@ -767,8 +761,8 @@ msgid "" "caller of the current transaction, and the `get_contract_address` function " "returns the address of the current contract." msgstr "" -"例如,`get_caller_address`函数返回当前事务的调用者地址," -"`get_contract_address`函数返回当前合约的地址。" +"例如,`get_caller_address`函数返回当前事务的调用者地址,`get_contract_address`" +"函数返回当前合约的地址。" #: src/ch00/basics/variables.md:102 msgid "" @@ -823,7 +817,6 @@ msgstr "" "```" #: src/ch00/basics/variables.md:125 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x05bD2F3943bd4e030f85678b55b2EC2C1be939e32388530FB20ED967B3Be433F) " @@ -832,11 +825,11 @@ msgid "" "blob/main/listings/getting-started/variables/src/global_variables.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" -"contract/0x05bD2F3943bd4e030f85678b55b2EC2C1be939e32388530FB20ED967B3Be433F) " -"上的合约,或在 [Remix](https://remix.ethereum.org/?" +"contract/0x05bD2F3943bd4e030f85678b55b2EC2C1be939e32388530FB20ED967B3Be433F)上" +"的合约,或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/variables/src/global_variables." -"cairo) 中尝试它。" +"blob/main/listings/getting-started/variables/src/global_variables.cairo) 中尝" +"试它。" #: src/ch00/basics/visibility-mutability.md:1 msgid "# Visibility and Mutability" @@ -861,18 +854,18 @@ msgstr "" #: src/ch00/basics/visibility-mutability.md:10 msgid "" -"These functions are also typically divided into two different " -"implementations blocks. The first `impl` block for externally accessible " -"functions is explicitly annotated with an `#[abi(embed_v0)]` attribute. This " -"indicates that all the functions inside this block can be called either as a " +"These functions are also typically divided into two different implementations " +"blocks. The first `impl` block for externally accessible functions is " +"explicitly annotated with an `#[abi(embed_v0)]` attribute. This indicates " +"that all the functions inside this block can be called either as a " "transaction or as a view function. The second `impl` block for internally " "accessible functions is not annotated with any attribute, which means that " "all the functions inside this block are private by default." msgstr "" -"这些函数通常也分为两个不同的实现块。第一个`impl`块用于外部访问的函数,明确标" -"注了 `#[abi(embed_v0)]`属性。这表明该代码块中的所有函数都可以作为交易或视图函" -"数调用。第二个用于内部可访问函数的 `impl` 块没有注释任何属性,这意味着该块中" -"的所有函数默认都是私有的。" +"这些函数通常也分为两个不同的实现块。第一个`impl`块用于外部访问的函数,明确标注" +"了 `#[abi(embed_v0)]`属性。这表明该代码块中的所有函数都可以作为交易或视图函数" +"调用。第二个用于内部可访问函数的 `impl` 块没有注释任何属性,这意味着该块中的所" +"有函数默认都是私有的。" #: src/ch00/basics/visibility-mutability.md:12 msgid "## State Mutability" @@ -887,8 +880,8 @@ msgid "" "adding it as the first parameter of the function. This can be done in two " "different ways:" msgstr "" -"无论函数是内部函数还是外部函数,它都可以修改或不修改合约的状态。当我们在智能" -"合约中声明与存储变量交互的函数时,\n" +"无论函数是内部函数还是外部函数,它都可以修改或不修改合约的状态。当我们在智能合" +"约中声明与存储变量交互的函数时,\n" "我们需要将 `ContractState`添加为函数的第一个参数,明确说明我们正在访问 合约的" "状态。这有两种不同的方法:" @@ -918,8 +911,8 @@ msgstr "" #: src/ch00/basics/visibility-mutability.md:23 msgid "" -"Internal functions can't be called externally, but the same principle " -"applies regarding state mutability." +"Internal functions can't be called externally, but the same principle applies " +"regarding state mutability." msgstr "内部函数不能被外部调用,同样的原则也适用于状态可变性。" #: src/ch00/basics/visibility-mutability.md:25 @@ -943,8 +936,8 @@ msgid "" " }\n" "\n" "\n" -" // The `abi(embed_v0)` attribute indicates that all the functions in " -"this implementation can be called externally.\n" +" // The `abi(embed_v0)` attribute indicates that all the functions in this " +"implementation can be called externally.\n" " // Omitting this attribute would make all the functions in this " "implementation internal.\n" " #[abi(embed_v0)]\n" @@ -962,8 +955,8 @@ msgid "" " // However, it can't modify the contract's state is passed as a " "snapshot: it is only a \"view\" function.\n" " fn get(self: @ContractState) -> u32 {\n" -" // We can call an internal function from any functions within " -"the contract\n" +" // We can call an internal function from any functions within the " +"contract\n" " PrivateFunctionsTrait::_read_value(self)\n" " }\n" " }\n" @@ -1001,8 +994,8 @@ msgstr "" " }\n" "\n" "\n" -" // The `abi(embed_v0)` attribute indicates that all the functions in " -"this implementation can be called externally.\n" +" // The `abi(embed_v0)` attribute indicates that all the functions in this " +"implementation can be called externally.\n" " // Omitting this attribute would make all the functions in this " "implementation internal.\n" " #[abi(embed_v0)]\n" @@ -1020,8 +1013,8 @@ msgstr "" " // However, it can't modify the contract's state is passed as a " "snapshot: it is only a \"view\" function.\n" " fn get(self: @ContractState) -> u32 {\n" -" // We can call an internal function from any functions within " -"the contract\n" +" // We can call an internal function from any functions within the " +"contract\n" " PrivateFunctionsTrait::_read_value(self)\n" " }\n" " }\n" @@ -1045,7 +1038,6 @@ msgstr "" "```" #: src/ch00/basics/visibility-mutability.md:73 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x0071dE3093AB58053b0292C225aa0eED40293e7694A0042685FF6D813d39889F) " @@ -1054,11 +1046,10 @@ msgid "" "blob/main/listings/getting-started/visibility/src/visibility.cairo)." msgstr "" "访问 [Voyager](https://goerli.voyager.online/" -"contract/0x0071dE3093AB58053b0292C225aa0eED40293e7694A0042685FF6D813d39889F) " -"上的合约,或在 [Remix](https://remix.ethereum.org/?" +"contract/0x0071dE3093AB58053b0292C225aa0eED40293e7694A0042685FF6D813d39889F)上" +"的合约,或在[Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/visibility/src/visibility.cairo) 中尝" -"试它。" +"blob/main/listings/getting-started/visibility/src/visibility.cairo)中尝试它。" #: src/ch00/basics/counter.md:1 msgid "# Simple Counter" @@ -1174,7 +1165,6 @@ msgstr "" "```" #: src/ch00/basics/counter.md:54 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x01664a69Fe701a1df7Bb0ae4A353792d0cf4E27146ee860075cbf6108b1D5718) " @@ -1186,8 +1176,7 @@ msgstr "" "contract/0x01664a69Fe701a1df7Bb0ae4A353792d0cf4E27146ee860075cbf6108b1D5718) " "上的合约,或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/counter/src/contracts.cairo) 中尝试" -"它。" +"blob/main/listings/getting-started/counter/src/contracts.cairo) 中尝试它。" #: src/ch00/basics/mappings.md:1 msgid "# Mappings" @@ -1208,8 +1197,8 @@ msgstr "" msgid "" "Here we demonstrate how to use the `LegacyMap` type within a Cairo contract, " "to map between a key of type `ContractAddress` and value of type `felt252`. " -"The key-value types are specified within angular brackets <>. We write to " -"the map by calling the `write()` method, passing in both the key and value. " +"The key-value types are specified within angular brackets <>. We write to the " +"map by calling the `write()` method, passing in both the key and value. " "Similarly, we can read the value associated with a given key by calling the " "`read()` method and passing in the relevant key." msgstr "" @@ -1230,19 +1219,19 @@ msgid "" "\n" "- In mappings, the address of the value at key `k_1,...,k_n` is `h(..." "h(h(sn_keccak(variable_name),k_1),k_2),...,k_n)` where `ℎ` is the Pedersen " -"hash and the final value is taken `mod2251−256`. You can learn more about " -"the contract storage layout in the [Starknet Documentation](https://docs." -"starknet.io/documentation/architecture_and_concepts/Contracts/contract-" -"storage/#storage_variables)" +"hash and the final value is taken `mod2251−256`. You can learn more about the " +"contract storage layout in the [Starknet Documentation](https://docs.starknet." +"io/documentation/architecture_and_concepts/Contracts/contract-storage/" +"#storage_variables)" msgstr "" "- 也有更复杂的键值对映射,例如,我们可以使用 `LegacyMap::<(ContractAddress, " "ContractAddress), felt252>` 在 ERC20 代币合约上创建一个代币授权许可。\n" "\n" "- 在映射中,键`k_1,...,k_n`处的值的地址是`h(...h(h(sn_keccak(variable_name)," "k_1),k_2),...,k_n)`,其中 `ℎ` 是 Pedersen 哈希值,最终值取`mod2251-256`。有关" -"合约存储布局的更多信息,请参阅 [Starknet Documentation](https://docs." -"starknet.io/documentation/architecture_and_concepts/Contracts/contract-" -"storage/#storage_variables)。" +"合约存储布局的更多信息,请参阅 [Starknet Documentation](https://docs.starknet." +"io/documentation/architecture_and_concepts/Contracts/contract-storage/" +"#storage_variables)。" #: src/ch00/basics/mappings.md:13 msgid "" @@ -1268,8 +1257,8 @@ msgid "" "\n" " #[abi(embed_v0)]\n" " impl MapContractImpl of super::IMapContract {\n" -" fn set(ref self: ContractState, key: ContractAddress, value: " -"felt252) {\n" +" fn set(ref self: ContractState, key: ContractAddress, value: felt252) " +"{\n" " self.map.write(key, value);\n" " }\n" "\n" @@ -1302,8 +1291,8 @@ msgstr "" "\n" " #[abi(embed_v0)]\n" " impl MapContractImpl of super::IMapContract {\n" -" fn set(ref self: ContractState, key: ContractAddress, value: " -"felt252) {\n" +" fn set(ref self: ContractState, key: ContractAddress, value: felt252) " +"{\n" " self.map.write(key, value);\n" " }\n" "\n" @@ -1315,7 +1304,6 @@ msgstr "" "```" #: src/ch00/basics/mappings.md:44 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x06214AB4c23Cc545bf2221D465eB83aFb7412779AD498BD48a724B3F645E3505) " @@ -1327,8 +1315,7 @@ msgstr "" "contract/0x06214AB4c23Cc545bf2221D465eB83aFb7412779AD498BD48a724B3F645E3505) " "上的合约或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/mappings/src/mappings.cairo) 中尝试" -"它。" +"blob/main/listings/getting-started/mappings/src/mappings.cairo) 中尝试它。" #: src/ch00/basics/errors.md:1 msgid "# Errors" @@ -1339,12 +1326,11 @@ msgid "" "Errors can be used to handle validation and other conditions that may occur " "during the execution of a smart contract.\n" "If an error is thrown during the execution of a smart contract call, the " -"execution is stopped and any changes made during the transaction are " -"reverted." +"execution is stopped and any changes made during the transaction are reverted." msgstr "" "错误可用于处理智能合约执行过程中可能发生的验证和其他条件。\n" -"如果在执行智能合约调用期间抛出错误,则将停止执行,并恢复在交易期间所做的任何" -"更改。" +"如果在执行智能合约调用期间抛出错误,则将停止执行,并恢复在交易期间所做的任何更" +"改。" #: src/ch00/basics/errors.md:6 msgid "To throw an error, use the `assert` or `panic` functions:" @@ -1437,7 +1423,6 @@ msgstr "" "```" #: src/ch00/basics/errors.md:46 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x0022664463FF0b711CC9B549a9E87d65A0882bB1D29338C4108696B8F2216a40) " @@ -1449,8 +1434,7 @@ msgstr "" "contract/0x0022664463FF0b711CC9B549a9E87d65A0882bB1D29338C4108696B8F2216a40) " "上访问合约或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/errors/src/simple_errors.cairo) 中尝" -"试它。" +"blob/main/listings/getting-started/errors/src/simple_errors.cairo) 中尝试它。" #: src/ch00/basics/errors.md:48 msgid "## Custom errors" @@ -1458,8 +1442,8 @@ msgstr "## 自定义错误" #: src/ch00/basics/errors.md:50 msgid "" -"You can make error handling easier by defining your error codes in a " -"specific module." +"You can make error handling easier by defining your error codes in a specific " +"module." msgstr "您可以通过在特定模块中定义错误代码来简化错误处理。" #: src/ch00/basics/errors.md:52 @@ -1484,8 +1468,7 @@ msgid "" " struct Storage {}\n" "\n" " #[abi(embed_v0)]\n" -" impl CustomErrorsExample of super::ICustomErrorsExample " -"{\n" +" impl CustomErrorsExample of super::ICustomErrorsExample {\n" " fn test_assert(self: @ContractState, i: u256) {\n" " assert(i > 0, Errors::NOT_POSITIVE);\n" " }\n" @@ -1519,8 +1502,7 @@ msgstr "" " struct Storage {}\n" "\n" " #[abi(embed_v0)]\n" -" impl CustomErrorsExample of super::ICustomErrorsExample " -"{\n" +" impl CustomErrorsExample of super::ICustomErrorsExample {\n" " fn test_assert(self: @ContractState, i: u256) {\n" " assert(i > 0, Errors::NOT_POSITIVE);\n" " }\n" @@ -1535,7 +1517,6 @@ msgstr "" "```" #: src/ch00/basics/errors.md:85 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x0501CD5da5B453a18515B5A20b8029bd7583DFE7a399ad9f79c284F7829e4A57) " @@ -1547,8 +1528,7 @@ msgstr "" "contract/0x0501CD5da5B453a18515B5A20b8029bd7583DFE7a399ad9f79c284F7829e4A57) " "上访问 contract 或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/errors/src/custom_errors.cairo) 中尝" -"试它。" +"blob/main/listings/getting-started/errors/src/custom_errors.cairo)中尝试它。" #: src/ch00/basics/errors.md:87 msgid "## Vault example" @@ -1657,7 +1637,6 @@ msgstr "" "```" #: src/ch00/basics/errors.md:137 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x020C2da26F42A28Ef54ED428eF1810FE433784b055f9bF315C5d992b1579C268) " @@ -1666,11 +1645,10 @@ msgid "" "blob/main/listings/getting-started/errors/src/vault_errors.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" -"contract/0x020C2da26F42A28Ef54ED428eF1810FE433784b055f9bF315C5d992b1579C268) " +"contract/0x020C2da26F42A28Ef54ED428eF1810FE433784b055f9bF315C5d992b1579C268) " "上访问 contract 或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/errors/src/vault_errors.cairo) 中尝试" -"它。" +"blob/main/listings/getting-started/errors/src/vault_errors.cairo) 中尝试它。" #: src/ch00/basics/events.md:1 msgid "# Events" @@ -1688,9 +1666,9 @@ msgid "" msgstr "" "事件是从合约发出数据的一种方式。所有事件都必须在`Event`枚举中定义,该枚举必须" "使用`#[event]`属性进行注释。\n" -"事件被定义为派生`#[starknet::Event]`特征的结构。该结构的字段对应于将要发出的" -"数据。可以对事件编制索引,以便在以后查询数据时轻松快速地访问。可以通过向字段" -"成员添加`#[key]` 属性来索引事件数据。" +"事件被定义为派生`#[starknet::Event]`特征的结构。该结构的字段对应于将要发出的数" +"据。可以对事件编制索引,以便在以后查询数据时轻松快速地访问。可以通过向字段成员" +"添加`#[key]` 属性来索引事件数据。" #: src/ch00/basics/events.md:6 msgid "" @@ -1735,8 +1713,7 @@ msgid "" "\n" " #[derive(Drop, starknet::Event)]\n" " struct UserIncreaseCounter {\n" -" // The `#[key]` attribute indicates that this event will be " -"indexed.\n" +" // The `#[key]` attribute indicates that this event will be indexed.\n" " #[key]\n" " user: ContractAddress,\n" " new_value: u128,\n" @@ -1798,8 +1775,7 @@ msgstr "" "\n" " #[derive(Drop, starknet::Event)]\n" " struct UserIncreaseCounter {\n" -" // The `#[key]` attribute indicates that this event will be " -"indexed.\n" +" // The `#[key]` attribute indicates that this event will be indexed.\n" " #[key]\n" " user: ContractAddress,\n" " new_value: u128,\n" @@ -1829,7 +1805,6 @@ msgstr "" "```" #: src/ch00/basics/events.md:66 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x022e3B59518EA04aBb5da671ea04ecC3a154400f226d2Df38eFE146741b9E2F6) " @@ -1841,7 +1816,7 @@ msgstr "" "contract/0x022e3B59518EA04aBb5da671ea04ecC3a154400f226d2Df38eFE146741b9E2F6) " "上访问 合约 或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch00-getting-started/events/src/counter.cairo) 中尝试它。" +"blob/main/listings/getting-started/events/src/counter.cairo) 中尝试它。" #: src/ch00/basics/storing-custom-types.md:1 msgid "# Storing Custom Types" @@ -1852,14 +1827,14 @@ msgid "" "While native types can be stored in a contract's storage without any " "additional work, custom types require a bit more work. This is because at " "compile time, the compiler does not know how to store custom types in " -"storage. To solve this, we need to implement the `Store` trait for our " -"custom type. Hopefully, we can just derive this trait for our custom type - " -"unless it contains arrays or dictionaries." +"storage. To solve this, we need to implement the `Store` trait for our custom " +"type. Hopefully, we can just derive this trait for our custom type - unless " +"it contains arrays or dictionaries." msgstr "" -"虽然本机类型可以存储在合约的存储中,而无需任何额外的工作,但自定义类型需要更" -"多的工作。这是因为在编译时,编译器不知道如何在存储中存储自定义类型。为了解决" -"这个问题,我们需要为我们的自定义类型实现 `Store`特征。希望我们可以为我们的自" -"定义类型派生这个特征 - 除非它包含数组或字典。" +"虽然本机类型可以存储在合约的存储中,而无需任何额外的工作,但自定义类型需要更多" +"的工作。这是因为在编译时,编译器不知道如何在存储中存储自定义类型。为了解决这个" +"问题,我们需要为我们的自定义类型实现 `Store`特征。希望我们可以为我们的自定义类" +"型派生这个特征 - 除非它包含数组或字典。" #: src/ch00/basics/storing-custom-types.md:5 msgid "" @@ -1928,14 +1903,13 @@ msgstr "" "```" #: src/ch00/basics/storing-custom-types.md:37 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" "blob/main/listings/getting-started/storing_custom_types/src/contract.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" +"com/NethermindEth/StarknetByExample/blob/main/listings/getting-started/" "storing_custom_types/src/contract.cairo) 中尝试这个合约。" #: src/ch00/basics/custom-types-in-entrypoints.md:1 @@ -1951,10 +1925,10 @@ msgid "" "entrypoint, we need to be able to serialize it into an array of `felt252`.\n" "Thankfully, we can just derive the `Serde` trait for our custom type." msgstr "" -"在入口点中使用自定义类型需要我们的类型来实现`Serde`trait。这是因为在调用入口" -"点时,输入以`felt252` 数组的形式发送到入口点,我们需要能够将其反序列化为我们" -"的自定义类型。同样,当从入口点返回自定义类型时,我们需要能够将其序列化为" -"`felt252` 数组。\n" +"在入口点中使用自定义类型需要我们的类型来实现`Serde`trait。这是因为在调用入口点" +"时,输入以`felt252` 数组的形式发送到入口点,我们需要能够将其反序列化为我们的自" +"定义类型。同样,当从入口点返回自定义类型时,我们需要能够将其序列化为`felt252` " +"数组。\n" "值得庆幸的是,我们可以为我们的自定义类型派生`Serde` 特征。" #: src/ch00/basics/custom-types-in-entrypoints.md:6 @@ -2024,14 +1998,13 @@ msgstr "" "```" #: src/ch00/basics/custom-types-in-entrypoints.md:37 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" "blob/main/listings/getting-started/custom_type_serde/src/contract.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" +"com/NethermindEth/StarknetByExample/blob/main/listings/getting-started/" "custom_type_serde/src/contract.cairo) 中尝试这个合约。" #: src/ch00/basics/documentation.md:1 @@ -2075,8 +2048,8 @@ msgid "" msgstr "" "在智能合约中,你通常会有一个定义合约接口的trait(即带有`#[starknet::" "interface]`)。\n" -"这是包含详细文档的理想场所,这些文档解释了合约入口点的用途和功能。您可以遵循" -"以下模板:" +"这是包含详细文档的理想场所,这些文档解释了合约入口点的用途和功能。您可以遵循以" +"下模板:" #: src/ch00/basics/documentation.md:16 msgid "" @@ -2117,8 +2090,8 @@ msgstr "" #: src/ch00/basics/documentation.md:33 msgid "" "Keep in mind that this should not describe the implementation details of the " -"function, but rather the high-level purpose and functionality of the " -"contract from the perspective of a user." +"function, but rather the high-level purpose and functionality of the contract " +"from the perspective of a user." msgstr "" "请记住,这不应该描述函数的实现细节,而应该从用户的角度描述合约的高级目的和功" "能。" @@ -2135,8 +2108,7 @@ msgstr "在编写合约逻辑时,可以添加注释来描述函数的技术实 #: src/ch00/basics/documentation.md:39 msgid "" -"> Avoid over-commenting: Comments should provide additional value and " -"clarity." +"> Avoid over-commenting: Comments should provide additional value and clarity." msgstr "> 避免过度注释:注释应提供额外的价值和清晰度。" #: src/ch00/basics/documentation.md:41 @@ -2167,8 +2139,8 @@ msgid "" "the [Cairo Book](https://book.cairo-lang.org/ch99-01-02-a-simple-contract." "html)." msgstr "" -"合约接口定义合约的结构和行为,充当合约的公共 ABI。它们列出了合约公开的所有函" -"数签名。接口的详细说明可以参考 [Cairo之书](https://book.cairo-lang.org/" +"合约接口定义合约的结构和行为,充当合约的公共 ABI。它们列出了合约公开的所有函数" +"签名。接口的详细说明可以参考 [Cairo之书](https://book.cairo-lang.org/" "ch99-01-02-a-simple-contract.html)。" #: src/ch00/interacting/interfaces-traits.md:5 @@ -2203,9 +2175,9 @@ msgid "" "l1 handler." msgstr "" "您可以使用`#[generate_trait]`属性隐式生成特定实现块的特征。此属性会自动生成一" -"个特征,其功能与已实现块中的函数相同,将`self`参数替换为通用的" -"`TContractState`参数。但是,您需要使用`#[abi(per_item)]` 属性注释块,并且每个" -"函数都具有适当的属性,具体取决于它是外部函数、构造函数还是 l1 处理程序。" +"个特征,其功能与已实现块中的函数相同,将`self`参数替换为通用的`TContractState`" +"参数。但是,您需要使用`#[abi(per_item)]` 属性注释块,并且每个函数都具有适当的" +"属性,具体取决于它是外部函数、构造函数还是 l1 处理程序。" #: src/ch00/interacting/interfaces-traits.md:11 msgid "In summary, there's two ways to handle interfaces:" @@ -2285,15 +2257,14 @@ msgstr "" "```" #: src/ch00/interacting/interfaces-traits.md:45 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" "blob/main/listings/getting-started/interfaces_traits/src/explicit.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" -"interfaces_traits/src/explicit.cairo) 中尝试这个合约。" +"com/NethermindEth/StarknetByExample/blob/main/listings/getting-started/" +"interfaces_traits/src/explicit.cairo)中尝试这个合约。" #: src/ch00/interacting/interfaces-traits.md:47 msgid "## Implicit interface" @@ -2350,14 +2321,13 @@ msgstr "" "```" #: src/ch00/interacting/interfaces-traits.md:73 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" "blob/main/listings/getting-started/interfaces_traits/src/implicit.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" +"com/NethermindEth/StarknetByExample/blob/main/listings/getting-started/" "interfaces_traits/src/implicit.cairo) 中尝试这个合约。" #: src/ch00/interacting/interfaces-traits.md:75 @@ -2366,8 +2336,8 @@ msgid "" "contract::{GeneratedContractInterface}`. However, the `Dispatcher` will not " "be generated automatically." msgstr "" -"> 注意:您可以使用`use contract::{GeneratedContractInterface}`导入隐式生成的" -"合约接口。但是,`Dispatcher`不会自动生成。" +"> 注意:您可以使用`use contract::{GeneratedContractInterface}`导入隐式生成的合" +"约接口。但是,`Dispatcher`不会自动生成。" #: src/ch00/interacting/interfaces-traits.md:77 msgid "## Internal functions" @@ -2380,8 +2350,8 @@ msgid "" "pure functions as well (functions without the `self` parameter)." msgstr "" "您还可以将`#[generate_trait]`用于内部函数。\n" -"由于此特征是在合约的上下文中生成的,因此您也可以定义纯函数(没有“self”参数的" -"函数)。" +"由于此特征是在合约的上下文中生成的,因此您也可以定义纯函数(没有“self”参数的函" +"数)。" #: src/ch00/interacting/interfaces-traits.md:82 msgid "" @@ -2478,7 +2448,6 @@ msgstr "" "```" #: src/ch00/interacting/interfaces-traits.md:127 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" @@ -2486,7 +2455,7 @@ msgid "" "cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" +"com/NethermindEth/StarknetByExample/blob/main/listings/getting-started/" "interfaces_traits/src/implicit_internal.cairo) 中尝试这个合约。" #: src/ch00/interacting/calling_other_contracts.md:1 @@ -2507,8 +2476,8 @@ msgid "" msgstr "" "调用其他合约的最简单方法是使用要调用的合约的调度程序。\n" "您可以在 [Cairo Book](https://book.cairo-lang.org/ch99-02-02-contract-" -"dispatcher-library-dispatcher-and-system-calls.html#contract-dispatcher) 中" -"阅读有关 Dispatchers 的更多信息" +"dispatcher-library-dispatcher-and-system-calls.html#contract-dispatcher) 中阅" +"读有关 Dispatchers 的更多信息" #: src/ch00/interacting/calling_other_contracts.md:8 msgid "" @@ -2525,8 +2494,8 @@ msgid "" "interface]` attribute, and then import the `IContractDispatcher` and " "`IContractDispatcherTrait` items in your contract." msgstr "" -"为了使用调度程序调用其他合约,您需要将被调用合约的接口定义为使用 " -"`#[starknet::interface]` 属性注释的trait,然后将 `IContractDispatcher` 和 " +"为了使用调度程序调用其他合约,您需要将被调用合约的接口定义为使用 `#[starknet::" +"interface]` 属性注释的trait,然后将 `IContractDispatcher` 和 " "`IContractDispatcherTrait` 项导入到合约中。" #: src/ch00/interacting/calling_other_contracts.md:12 @@ -2578,7 +2547,6 @@ msgstr "" "```" #: src/ch00/interacting/calling_other_contracts.md:34 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x015c3Bb6D0DE26b64FEAF9A8f4655CfADb5c128bF4510398972704ee12775DB1) " @@ -2587,11 +2555,11 @@ msgid "" "blob/main/listings/getting-started/calling_other_contracts/src/callee.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" -"contract/0x015c3Bb6D0DE26b64FEAF9A8f4655CfADb5c128bF4510398972704ee12775DB1) " -"上访问 合约 或在 [Remix](https://remix.ethereum.org/?" +"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)中尝试它。" +"blob/main/listings/getting-started/calling_other_contracts/src/callee.cairo)中" +"尝试它。" #: src/ch00/interacting/calling_other_contracts.md:36 msgid "" @@ -2666,7 +2634,6 @@ msgstr "" "```" #: src/ch00/interacting/calling_other_contracts.md:68 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x05fa8aF796343d2f22c53C17149386b67B7AC4aB52D9e308Aa507C185aA44778) " @@ -2675,11 +2642,11 @@ msgid "" "blob/main/listings/getting-started/calling_other_contracts/src/caller.cairo)." msgstr "" "在 [Voyager](https://goerli.voyager.online/" -"contract/0x05fa8aF796343d2f22c53C17149386b67B7AC4aB52D9e308Aa507C185aA44778) " +"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) 中尝试它。" +"blob/main/listings/getting-started/calling_other_contracts/src/caller.cairo) " +"中尝试它。" #: src/ch00/interacting/factory.md:1 msgid "# Factory Pattern" @@ -2694,12 +2661,12 @@ 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." +"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" @@ -2707,24 +2674,24 @@ msgstr "## 类哈希(Class hash)和合约实例" #: src/ch00/interacting/factory.md:9 msgid "" -"In Starknet, there's a separation between contract's classes and instances. " -"A contract class serves as a blueprint, defined by the underling Cairo " +"In Starknet, there's a separation between contract's classes and instances. A " +"contract class serves as a blueprint, defined by the underling Cairo " "bytecode, contract's entrypoints, ABI and Sierra program hash. The contract " "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 程序哈希定义。合约类由类哈希标识。当您想向网络添加" -"一个新类时,首先需要声明它。" +"约的入口点、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." +"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 "" @@ -2759,8 +2726,8 @@ msgid "" " /// 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" +" /// 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" @@ -2834,8 +2801,8 @@ msgstr "" " /// 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" +" /// 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" @@ -2896,11 +2863,11 @@ msgstr "" #: src/ch00/interacting/factory.md:86 msgid "" -"" +"" +"\n" @@ -2937,7 +2903,7 @@ msgstr "" "\n" "\n" -"
Last change: 2023-10-19
" +"
Last change: 2023-12-07
" #: src/ch00/testing/contract-testing.md:1 msgid "# Contract Testing" @@ -2949,8 +2915,8 @@ msgid "" "contracts. In this section, we'll guide you through the basics of testing a " "smart contract on Starknet with `scarb`." msgstr "" -"测试在软件开发中起着至关重要的作用,尤其是对于智能合约而言。在本节中,我们将" -"通过Starknet上的`scarb` ,引导你了解智能合约测试的基础知识。" +"测试在软件开发中起着至关重要的作用,尤其是对于智能合约而言。在本节中,我们将通" +"过Starknet上的`scarb` ,引导你了解智能合约测试的基础知识。" #: src/ch00/testing/contract-testing.md:5 msgid "Let's start with a simple smart contract as an example:" @@ -3229,32 +3195,31 @@ msgstr "" "```" #: src/ch00/testing/contract-testing.md:132 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" "blob/main/listings/getting-started/testing_how_to/src/lib.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch00-getting-started/" -"testing_how_to/src/lib.cairo) 中与这个合约进行互动。" +"com/NethermindEth/StarknetByExample/blob/main/listings/getting-started/" +"testing_how_to/src/lib.cairo)中与这个合约进行互动。" #: src/ch00/testing/contract-testing.md:134 msgid "" -"To define our test, we use scarb, which allows us to create a separate " -"module guarded with `#[cfg(test)]`. This ensures that the test module is " -"only compiled when running tests using `scarb test`." +"To define our test, we use scarb, which allows us to create a separate module " +"guarded with `#[cfg(test)]`. This ensures that the test module is only " +"compiled when running tests using `scarb test`." msgstr "" -"为了定义我们的测试,我们使用 scarb,它允许我们创建一个被 `#[cfg(test)]` 保护" -"的独立模块。这样可以确保测试模块只在使用 `scarb test` 运行测试时被编译。" +"为了定义我们的测试,我们使用 scarb,它允许我们创建一个被 `#[cfg(test)]` 保护的" +"独立模块。这样可以确保测试模块只在使用 `scarb test` 运行测试时被编译。" #: src/ch00/testing/contract-testing.md:136 msgid "" -"Each test is defined as a function with the `#[test]` attribute. You can " -"also check if a test panics using the `#[should_panic]` attribute." +"Each test is defined as a function with the `#[test]` attribute. You can also " +"check if a test panics using the `#[should_panic]` attribute." msgstr "" -"每个测试都被定义为带有 `#[test]` 属性的函数。您还可以使用 `#[should_panic]` " -"属性检查测试是否会引发 panic。" +"每个测试都被定义为带有 `#[test]` 属性的函数。您还可以使用 `#[should_panic]` 属" +"性检查测试是否会引发 panic。" #: src/ch00/testing/contract-testing.md:138 msgid "" @@ -3286,8 +3251,8 @@ msgstr "" #: src/ch00/testing/contract-testing.md:146 msgid "" -"To make testing more convenient, the `testing` module of the corelib " -"provides some helpful functions:" +"To make testing more convenient, the `testing` module of the corelib provides " +"some helpful functions:" msgstr "为了使测试更加方便,corelib 的 `testing` 模块提供了一些有用的函数:" #: src/ch00/testing/contract-testing.md:147 @@ -3337,8 +3302,8 @@ msgid "" "book - Chapter 8](https://book.cairo-lang.org/ch08-01-how-to-write-tests." "html)." msgstr "" -"你可以在 [Starknet Corelib 仓库](https://github.com/starkware-libs/cairo/" -"tree/main/corelib/src/starknet) 中找到完整的函数列表。\n" +"你可以在 [Starknet Corelib 仓库](https://github.com/starkware-libs/cairo/tree/" +"main/corelib/src/starknet) 中找到完整的函数列表。\n" "你还可以在 [Cairo book 第8章](https://book.cairo-lang.org/ch08-01-how-to-" "write-tests.html) 中找到有关在 cairo 中进行测试的详细说明。" @@ -3356,8 +3321,8 @@ msgid "" "Starknet. It offers support for testing Starknet smart contracts on top of " "`scarb` with the `Forge` tool." msgstr "" -"Starknet Foundry是在Starknet上开发智能合约的强大工具包。它提供了对使用" -"`Forge` 工具在 `scarb` 上测试Starknet智能合约的支持。" +"Starknet Foundry是在Starknet上开发智能合约的强大工具包。它提供了对使用`Forge` " +"工具在 `scarb` 上测试Starknet智能合约的支持。" #: src/ch00/testing/contract-testing.md:172 msgid "" @@ -3367,8 +3332,8 @@ msgid "" "Starknet Foundry and incorporating it into your projects." msgstr "" "使用 `snforge` 进行测试与我们刚刚描述的过程类似,但更简化。此外,还有其他功能" -"正在开发中,包括作弊码或并行测试执行。我们强烈推荐探索Starknet Foundry并将其" -"纳入您你的项目中。" +"正在开发中,包括作弊码或并行测试执行。我们强烈推荐探索Starknet Foundry并将其纳" +"入您你的项目中。" #: src/ch00/testing/contract-testing.md:174 msgid "" @@ -3402,8 +3367,8 @@ msgstr "# Felt252" msgid "" "Felt252 is a fundamental data type in Cairo from which all other data types " "are derived.\n" -"Felt252 can also be used to store short-string representations with a " -"maximum length of 31 characters." +"Felt252 can also be used to store short-string representations with a maximum " +"length of 31 characters." msgstr "" "Felt252是Cairo中的基本数据类型,所有其他数据类型都派生自它。\n" "Felt252也可以用于存储最多31个字符长度的短字符串表示。" @@ -3451,8 +3416,8 @@ msgid "" " ref self: TContractState, student_add: ContractAddress, subject: " "felt252, score: u16\n" " );\n" -" fn view_student_name(self: @TContractState, student_add: " -"ContractAddress) -> felt252;\n" +" fn view_student_name(self: @TContractState, student_add: ContractAddress) " +"-> felt252;\n" " fn view_student_score(\n" " self: @TContractState, student_add: ContractAddress, subject: " "felt252\n" @@ -3515,8 +3480,8 @@ msgstr "" " ref self: TContractState, student_add: ContractAddress, subject: " "felt252, score: u16\n" " );\n" -" fn view_student_name(self: @TContractState, student_add: " -"ContractAddress) -> felt252;\n" +" fn view_student_name(self: @TContractState, student_add: ContractAddress) " +"-> felt252;\n" " fn view_student_score(\n" " self: @TContractState, student_add: ContractAddress, subject: " "felt252\n" @@ -3574,8 +3539,8 @@ msgstr "# 数组" #: src/ch00/cairo_cheatsheet/arrays.md:3 msgid "" "Arrays are collections of elements of the same type.\n" -"The possible operations on arrays are defined with the `array::ArrayTrait` " -"of the corelib:" +"The possible operations on arrays are defined with the `array::ArrayTrait` of " +"the corelib:" msgstr "" "数组是相同类型元素的集合。\n" "可以使用 corelib 的 `array::ArrayTrait` 来定义可能的数组操作:" @@ -3835,9 +3800,9 @@ msgid "" "created, its size cannot change.\n" "For example:" msgstr "" -"元组是一种数据类型,用于将固定数量的不同类型的项组合成一个单一的复合结构。与" -"数组不同,元组具有固定的长度,并且可以包含不同类型的元素。一旦创建了元组,其" -"大小就无法更改。\n" +"元组是一种数据类型,用于将固定数量的不同类型的项组合成一个单一的复合结构。与数" +"组不同,元组具有固定的长度,并且可以包含不同类型的元素。一旦创建了元组,其大小" +"就无法更改。\n" "例如:" #: src/ch00/cairo_cheatsheet/tuples.md:6 @@ -3910,13 +3875,13 @@ msgid "" "Cairo supports the conversion from one scalar types to another by using the " "into and try_into methods.\n" "`traits::Into` is used for conversion from a smaller data type to a larger " -"data type, while `traits::TryInto` is used when converting from a larger to " -"a smaller type that might not fit. \n" +"data type, while `traits::TryInto` is used when converting from a larger to a " +"smaller type that might not fit. \n" "For example:" msgstr "" "Cairo支持使用into和try_into方法将一个标量类型转换为另一个类型。\n" -"`traits::Into` 用于从较小的数据类型转换为较大的数据类型,而 `traits::" -"TryInto` 用于从较大的数据类型转换为较小的数据类型,可能会发生溢出的情况。\n" +"`traits::Into` 用于从较小的数据类型转换为较大的数据类型,而 `traits::TryInto` " +"用于从较大的数据类型转换为较小的数据类型,可能会发生溢出的情况。\n" "例如:" #: src/ch00/cairo_cheatsheet/type_casting.md:7 @@ -3925,8 +3890,7 @@ msgid "" " let a_number: u32 = 15;\n" " let my_felt252 = 15;\n" "\n" -" // Since a u32 might not fit in a u8 and a u16, we need to use " -"try_into,\n" +" // Since a u32 might not fit in a u8 and a u16, we need to use try_into,\n" " // then unwrap the Option type thats returned.\n" " let new_u8: u8 = a_number.try_into().unwrap();\n" " let new_u16: u16 = a_number.try_into().unwrap();\n" @@ -3936,8 +3900,8 @@ msgid "" " // or use the .into() method.\n" " let new_u32: u32 = a_number;\n" "\n" -" // When typecasting from a smaller size to an equal or larger size we " -"use the .into() method.\n" +" // When typecasting from a smaller size to an equal or larger size we use " +"the .into() method.\n" " // Note: u64 and u128 are larger than u32, so a u32 type will always fit " "into them.\n" " let new_u64: u64 = a_number.into();\n" @@ -3964,8 +3928,8 @@ msgstr "" " // 或使用 .into() 方法\n" " let new_u32: u32 = a_number;\n" "\n" -" // 当从较小的大小类型强制转换为相等或较大的大小类型时,我们使用 .into() " -"方法\n" +" // 当从较小的大小类型强制转换为相等或较大的大小类型时,我们使用 .into() 方" +"法\n" " // 注意:u64 和 u128 大于 u32,所以 u32 类型将始终适合其中\n" " let new_u64: u64 = a_number.into();\n" " let new_u128: u128 = a_number.into();\n" @@ -4016,7 +3980,6 @@ msgid "" msgstr "" #: src/components/how_to.md:17 -#, fuzzy msgid "" "```rust\n" "#[starknet::interface]\n" @@ -4068,41 +4031,47 @@ msgid "" msgstr "" "```rust\n" "#[starknet::interface]\n" -"trait ISimpleCounter {\n" -" fn get_current_count(self: @TContractState) -> u128;\n" -" fn increment(ref self: TContractState);\n" -" fn decrement(ref self: TContractState);\n" +"trait ISwitchComponent {\n" +" fn value(self: @TContractState) -> bool;\n" +" fn switch(ref self: TContractState);\n" "}\n" "\n" -"#[starknet::contract]\n" -"mod SimpleCounter {\n" +"#[starknet::component]\n" +"mod switch_component {\n" " #[storage]\n" " struct Storage {\n" -" // Counter variable\n" -" counter: u128,\n" +" value: bool,\n" " }\n" "\n" -" #[constructor]\n" -" fn constructor(ref self: ContractState, init_value: u128) {\n" -" // Store initial value\n" -" self.counter.write(init_value);\n" +" #[derive(Drop, starknet::Event)]\n" +" struct SwitchEvent {}\n" +"\n" +" #[event]\n" +" #[derive(Drop, starknet::Event)]\n" +" enum Event {\n" +" SwitchEvent: SwitchEvent,\n" " }\n" "\n" -" #[abi(embed_v0)]\n" -" impl SimpleCounter of super::ISimpleCounter {\n" -" fn get_current_count(self: @ContractState) -> u128 {\n" -" return self.counter.read();\n" +" #[embeddable_as(Switch)]\n" +" impl SwitchImpl<\n" +" TContractState, +HasComponent\n" +" > of super::ISwitchComponent> {\n" +" fn value(self: @ComponentState) -> bool {\n" +" self.value.read()\n" " }\n" "\n" -" fn increment(ref self: ContractState) {\n" -" // Store counter value + 1\n" -" let counter = self.counter.read() + 1;\n" -" self.counter.write(counter);\n" +" fn switch(ref self: ComponentState) {\n" +" self.value.write(!self.value.read());\n" +" self.emit(Event::SwitchEvent(SwitchEvent {}));\n" " }\n" -" fn decrement(ref self: ContractState) {\n" -" // Store counter value - 1\n" -" let counter = self.counter.read() - 1;\n" -" self.counter.write(counter);\n" +" }\n" +"\n" +" #[generate_trait]\n" +" impl InternalSwitchImpl<\n" +" TContractState, +HasComponent\n" +" > of InternalSwitchTrait {\n" +" fn _off(ref self: ComponentState) {\n" +" self.value.write(false);\n" " }\n" " }\n" "}\n" @@ -4148,8 +4117,7 @@ msgid "" "component.\n" " use components::switch::switch_component::InternalSwitchImpl;\n" "\n" -" component!(path: switch_component, storage: switch, event: " -"SwitchEvent);\n" +" component!(path: switch_component, storage: switch, event: SwitchEvent);\n" "\n" " #[abi(embed_v0)]\n" " impl SwitchImpl = switch_component::Switch;\n" @@ -4235,8 +4203,8 @@ msgid "" "name in an object-oriented programming language. A contract instance is a " "deployed contract corresponding to a class." msgstr "" -"每个类由其类哈希值标识,类似于面向对象编程语言中的类名。合约实例是对应于某个" -"类的已部署合约。" +"每个类由其类哈希值标识,类似于面向对象编程语言中的类名。合约实例是对应于某个类" +"的已部署合约。" #: src/ch01/upgradeable_contract.md:20 msgid "" @@ -4247,8 +4215,8 @@ msgid "" "the data stored in the contract will remain the same." msgstr "" "当调用`replace_class_syscall`函数,你可以将已部署的合约升级到更新的版本。通过" -"使用这个函数,你可以更新与已部署合约相关联的类哈希,从而有效地升级合约的实" -"现。然而,这不会修改合约中的存储,因此合约中存储的所有数据将保持不变。" +"使用这个函数,你可以更新与已部署合约相关联的类哈希,从而有效地升级合约的实现。" +"然而,这不会修改合约中的存储,因此合约中存储的所有数据将保持不变。" #: src/ch01/upgradeable_contract.md:22 msgid "" @@ -4258,14 +4226,14 @@ msgid "" "send a transaction that invokes the `upgrade` function, with the class hash " "of `UpgradeableContract_V1` as parameter to upgrade the class hash of the " "deployed contract to the `UpgradeableContract_V1` one. Then, call the " -"`version` method on the contract to see that the contract was upgraded to " -"the V1 version." +"`version` method on the contract to see that the contract was upgraded to the " +"V1 version." msgstr "" "为了说明这个概念,让我们以两个合约为例:`UpgradeableContract_V0`和" "`UpgradeableContract_V1`。\n" "首先,部署`UpgradeableContract_V0`作为初始版本。接下来,发送一个调用`upgrade`" -"函数的交易,将部署合约的类哈希升级为`UpgradeableContract_V1`的类哈希。然后," -"调用合约上的`version`方法,查看合约是否已升级到V1版本。" +"函数的交易,将部署合约的类哈希升级为`UpgradeableContract_V1`的类哈希。然后,调" +"用合约上的`version`方法,查看合约是否已升级到V1版本。" #: src/ch01/upgradeable_contract.md:25 msgid "" @@ -4299,8 +4267,7 @@ msgid "" " }\n" "\n" " #[abi(embed_v0)]\n" -" impl UpgradeableContract of super::IUpgradeableContract " -"{\n" +" impl UpgradeableContract of super::IUpgradeableContract {\n" " fn upgrade(ref self: ContractState, impl_hash: ClassHash) {\n" " assert(!impl_hash.is_zero(), 'Class hash cannot be zero');\n" " starknet::replace_class_syscall(impl_hash).unwrap_syscall();\n" @@ -4345,8 +4312,7 @@ msgstr "" " }\n" "\n" " #[abi(embed_v0)]\n" -" impl UpgradeableContract of super::IUpgradeableContract " -"{\n" +" impl UpgradeableContract of super::IUpgradeableContract {\n" " fn upgrade(ref self: ContractState, impl_hash: ClassHash) {\n" " assert(!impl_hash.is_zero(), 'Class hash cannot be zero');\n" " starknet::replace_class_syscall(impl_hash).unwrap_syscall();\n" @@ -4362,7 +4328,6 @@ msgstr "" "```" #: src/ch01/upgradeable_contract.md:68 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x005300003ade5d10447d941a42d48b7141074cd8bade2b16520684896a5090ea) " @@ -4371,11 +4336,11 @@ msgid "" "blob/main/listings/applications/upgradeable_contract/src/" "upgradeable_contract_v0.cairo)." msgstr "" -"在 [Voyager](https://goerli.voyager.online/" +"在 [Voyager](https://goerli.voyager.online/" "contract/0x005300003ade5d10447d941a42d48b7141074cd8bade2b16520684896a5090ea) " -"上访问合约或在 [Remix](https://remix.ethereum.org/?" +"上访问合约或在[Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch01-applications/upgradeable_contract/src/" +"blob/main/listings/applications/upgradeable_contract/src/" "upgradeable_contract_v0.cairo)中尝试它 。" #: src/ch01/upgradeable_contract.md:71 @@ -4410,8 +4375,7 @@ msgid "" " }\n" "\n" " #[abi(embed_v0)]\n" -" impl UpgradeableContract of super::IUpgradeableContract " -"{\n" +" impl UpgradeableContract of super::IUpgradeableContract {\n" " fn upgrade(ref self: ContractState, impl_hash: ClassHash) {\n" " assert(!impl_hash.is_zero(), 'Class hash cannot be zero');\n" " starknet::replace_class_syscall(impl_hash).unwrap_syscall();\n" @@ -4456,8 +4420,7 @@ msgstr "" " }\n" "\n" " #[abi(embed_v0)]\n" -" impl UpgradeableContract of super::IUpgradeableContract " -"{\n" +" impl UpgradeableContract of super::IUpgradeableContract {\n" " fn upgrade(ref self: ContractState, impl_hash: ClassHash) {\n" " assert(!impl_hash.is_zero(), 'Class hash cannot be zero');\n" " starknet::replace_class_syscall(impl_hash).unwrap_syscall();\n" @@ -4473,7 +4436,6 @@ msgstr "" "```" #: src/ch01/upgradeable_contract.md:114 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x017c86152badd1d665b9836571bd6b0a484f028748aa13d9b2d5d9c9192fafc6) " @@ -4486,7 +4448,7 @@ msgstr "" "contract/0x017c86152badd1d665b9836571bd6b0a484f028748aa13d9b2d5d9c9192fafc6) " "上访问合约或在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch01-applications/upgradeable_contract/src/" +"blob/main/listings/applications/upgradeable_contract/src/" "upgradeable_contract_v1.cairo) 中尝试它。" #: src/ch01/simple_vault.md:1 @@ -4499,8 +4461,8 @@ msgid "" "solidity-by-example.org/defi/vault/).\n" "Here's how it works:" msgstr "" -"这是 [Solidity by example Vault](https://solidity-by-example.org/defi/" -"vault/) 的Cairo版本\n" +"这是 [Solidity by example Vault](https://solidity-by-example.org/defi/vault/) " +"的Cairo版本\n" "以下是它的工作原理:" #: src/ch01/simple_vault.md:6 @@ -4533,8 +4495,8 @@ msgid "" " fn balance_of(self: @TContractState, account: ContractAddress) -> u256;\n" " fn allowance(self: @TContractState, owner: ContractAddress, spender: " "ContractAddress) -> u256;\n" -" fn transfer(ref self: TContractState, recipient: ContractAddress, " -"amount: u256) -> bool;\n" +" fn transfer(ref self: TContractState, recipient: ContractAddress, amount: " +"u256) -> bool;\n" " fn transfer_from(\n" " ref self: TContractState, sender: ContractAddress, recipient: " "ContractAddress, amount: u256\n" @@ -4645,8 +4607,8 @@ msgstr "" " fn balance_of(self: @TContractState, account: ContractAddress) -> u256;\n" " fn allowance(self: @TContractState, owner: ContractAddress, spender: " "ContractAddress) -> u256;\n" -" fn transfer(ref self: TContractState, recipient: ContractAddress, " -"amount: u256) -> bool;\n" +" fn transfer(ref self: TContractState, recipient: ContractAddress, amount: " +"u256) -> bool;\n" " fn transfer_from(\n" " ref self: TContractState, sender: ContractAddress, recipient: " "ContractAddress, amount: u256\n" @@ -4743,15 +4705,14 @@ msgstr "" "```" #: src/ch01/simple_vault.md:113 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" "blob/main/listings/applications/simple_vault/src/simple_vault.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch01-applications/" -"simple_vault/src/simple_vault.cairo) 中尝试这个合约。" +"com/NethermindEth/StarknetByExample/blob/main/listings/applications/" +"simple_vault/src/simple_vault.cairo) 中测试这个合约。" #: src/ch01/erc20.md:1 msgid "# ERC20 Token" @@ -4766,8 +4727,7 @@ msgstr "" "ERC20 代币。它们用于代表可互换的资产。" #: src/ch01/erc20.md:5 -msgid "" -"To create an ERC20 conctract, it must implement the following interface:" +msgid "To create an ERC20 conctract, it must implement the following interface:" msgstr "要创建 ERC20 合约,必须实现以下接口:" #: src/ch01/erc20.md:7 @@ -4785,8 +4745,8 @@ msgid "" " self: @TContractState, owner: ContractAddress, spender: " "ContractAddress\n" " ) -> felt252;\n" -" fn transfer(ref self: TContractState, recipient: ContractAddress, " -"amount: felt252);\n" +" fn transfer(ref self: TContractState, recipient: ContractAddress, amount: " +"felt252);\n" " fn transfer_from(\n" " ref self: TContractState,\n" " sender: ContractAddress,\n" @@ -4795,11 +4755,11 @@ msgid "" " );\n" " fn approve(ref self: TContractState, spender: ContractAddress, amount: " "felt252);\n" -" fn increase_allowance(ref self: TContractState, spender: " -"ContractAddress, added_value: felt252);\n" +" fn increase_allowance(ref self: TContractState, spender: ContractAddress, " +"added_value: felt252);\n" " fn decrease_allowance(\n" -" ref self: TContractState, spender: ContractAddress, " -"subtracted_value: felt252\n" +" ref self: TContractState, spender: ContractAddress, subtracted_value: " +"felt252\n" " );\n" "}\n" "```" @@ -4817,8 +4777,8 @@ msgstr "" " self: @TContractState, owner: ContractAddress, spender: " "ContractAddress\n" " ) -> felt252;\n" -" fn transfer(ref self: TContractState, recipient: ContractAddress, " -"amount: felt252);\n" +" fn transfer(ref self: TContractState, recipient: ContractAddress, amount: " +"felt252);\n" " fn transfer_from(\n" " ref self: TContractState,\n" " sender: ContractAddress,\n" @@ -4827,11 +4787,11 @@ msgstr "" " );\n" " fn approve(ref self: TContractState, spender: ContractAddress, amount: " "felt252);\n" -" fn increase_allowance(ref self: TContractState, spender: " -"ContractAddress, added_value: felt252);\n" +" fn increase_allowance(ref self: TContractState, spender: ContractAddress, " +"added_value: felt252);\n" " fn decrease_allowance(\n" -" ref self: TContractState, spender: ContractAddress, " -"subtracted_value: felt252\n" +" ref self: TContractState, spender: ContractAddress, subtracted_value: " +"felt252\n" " );\n" "}\n" "```" @@ -4843,9 +4803,9 @@ msgid "" "The Starknet ERC20 interface is therefore slightly different from the " "Solidity ERC20 interface." msgstr "" -"在Starknet中,函数名应该使用*snake_case*(蛇形命名法)。而在Solidity中,函数" -"名使用*camelCase*(驼峰命名法)。因此,Starknet的ERC20接口与Solidity的ERC20接" -"口略有不同。" +"在Starknet中,函数名应该使用*snake_case*(蛇形命名法)。而在Solidity中,函数名" +"使用*camelCase*(驼峰命名法)。因此,Starknet的ERC20接口与Solidity的ERC20接口" +"略有不同。" #: src/ch01/erc20.md:36 msgid "Here's an implementation of the ERC20 interface in Cairo:" @@ -4962,8 +4922,8 @@ msgid "" " self._transfer(sender, recipient, amount);\n" " }\n" "\n" -" fn approve(ref self: ContractState, spender: ContractAddress, " -"amount: felt252) {\n" +" fn approve(ref self: ContractState, spender: ContractAddress, amount: " +"felt252) {\n" " let caller = get_caller_address();\n" " self.approve_helper(caller, spender, amount);\n" " }\n" @@ -5163,8 +5123,8 @@ msgstr "" " self._transfer(sender, recipient, amount);\n" " }\n" "\n" -" fn approve(ref self: ContractState, spender: ContractAddress, " -"amount: felt252) {\n" +" fn approve(ref self: ContractState, spender: ContractAddress, amount: " +"felt252) {\n" " let caller = get_caller_address();\n" " self.approve_helper(caller, spender, amount);\n" " }\n" @@ -5256,15 +5216,14 @@ msgstr "" "```" #: src/ch01/erc20.md:224 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" "blob/main/listings/applications/erc20/src/token.cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch01-applications/" -"erc20/src/token.cairo) 中尝试这个合约。" +"com/NethermindEth/StarknetByExample/blob/main/listings/applications/erc20/src/" +"token.cairo) 中测试这个合约。" #: src/ch01/erc20.md:226 msgid "" @@ -5273,8 +5232,8 @@ msgid "" "(https://cairo-by-example.com/examples/erc20/) ones." msgstr "" "还有一些其他的实现,比如 [Open Zeppelin](https://docs.openzeppelin.com/" -"contracts-cairo/0.7.0/erc20) 或者 [Cairo By Example](https://cairo-by-" -"example.com/examples/erc20/) 中的实现。" +"contracts-cairo/0.7.0/erc20) 或者 [Cairo By Example](https://cairo-by-example." +"com/examples/erc20/) 中的实现。" #: src/ch01/constant-product-amm.md:1 msgid "# Constant Product AMM" @@ -5282,8 +5241,8 @@ msgstr "# 恒定乘积自动做市商" #: src/ch01/constant-product-amm.md:3 msgid "" -"This is the Cairo adaptation of the [Solidity by example Constant Product " -"AMM](https://solidity-by-example.org/defi/constant-product-amm/)." +"This is the Cairo adaptation of the [Solidity by example Constant Product AMM]" +"(https://solidity-by-example.org/defi/constant-product-amm/)." msgstr "" "这个是 用Cairo 改编的 [Solidity by example Constant Product AMM](https://" "solidity-by-example.org/defi/constant-product-amm/)." @@ -5297,8 +5256,8 @@ msgid "" "trait IConstantProductAmm {\n" " fn swap(ref self: TContractState, token_in: ContractAddress, amount_in: " "u256) -> u256;\n" -" fn add_liquidity(ref self: TContractState, amount0: u256, amount1: u256) " -"-> u256;\n" +" fn add_liquidity(ref self: TContractState, amount0: u256, amount1: u256) -" +"> u256;\n" " fn remove_liquidity(ref self: TContractState, shares: u256) -> (u256, " "u256);\n" "}\n" @@ -5360,8 +5319,8 @@ msgid "" " }\n" "\n" " #[inline(always)]\n" -" fn select_token(self: @ContractState, token: ContractAddress) -> " -"bool {\n" +" fn select_token(self: @ContractState, token: ContractAddress) -> bool " +"{\n" " assert(\n" " token == self.token0.read().contract_address\n" " || token == self.token1.read().contract_address,\n" @@ -5416,8 +5375,8 @@ msgid "" "\n" " let amount_in_with_fee = (amount_in * (1000 - self.fee.read()." "into()) / 1000);\n" -" let amount_out = (reserve_out * amount_in_with_fee) / " -"(reserve_in + amount_in_with_fee);\n" +" let amount_out = (reserve_out * amount_in_with_fee) / (reserve_in " +"+ amount_in_with_fee);\n" "\n" " token_out.transfer(caller, amount_out);\n" "\n" @@ -5568,8 +5527,8 @@ msgid "" "\n" " // bal0 >= reserve0\n" " // bal1 >= reserve1\n" -" let (bal0, bal1): (u256, u256) = (token0.balance_of(this), " -"token1.balance_of(this));\n" +" let (bal0, bal1): (u256, u256) = (token0.balance_of(this), token1." +"balance_of(this));\n" "\n" " let total_supply = self.total_supply.read();\n" " let (amount0, amount1): (u256, u256) = (\n" @@ -5596,8 +5555,8 @@ msgstr "" "trait IConstantProductAmm {\n" " fn swap(ref self: TContractState, token_in: ContractAddress, amount_in: " "u256) -> u256;\n" -" fn add_liquidity(ref self: TContractState, amount0: u256, amount1: u256) " -"-> u256;\n" +" fn add_liquidity(ref self: TContractState, amount0: u256, amount1: u256) -" +"> u256;\n" " fn remove_liquidity(ref self: TContractState, shares: u256) -> (u256, " "u256);\n" "}\n" @@ -5659,8 +5618,8 @@ msgstr "" " }\n" "\n" " #[inline(always)]\n" -" fn select_token(self: @ContractState, token: ContractAddress) -> " -"bool {\n" +" fn select_token(self: @ContractState, token: ContractAddress) -> bool " +"{\n" " assert(\n" " token == self.token0.read().contract_address\n" " || token == self.token1.read().contract_address,\n" @@ -5715,8 +5674,8 @@ msgstr "" "\n" " let amount_in_with_fee = (amount_in * (1000 - self.fee.read()." "into()) / 1000);\n" -" let amount_out = (reserve_out * amount_in_with_fee) / " -"(reserve_in + amount_in_with_fee);\n" +" let amount_out = (reserve_out * amount_in_with_fee) / (reserve_in " +"+ amount_in_with_fee);\n" "\n" " token_out.transfer(caller, amount_out);\n" "\n" @@ -5867,8 +5826,8 @@ msgstr "" "\n" " // bal0 >= reserve0\n" " // bal1 >= reserve1\n" -" let (bal0, bal1): (u256, u256) = (token0.balance_of(this), " -"token1.balance_of(this));\n" +" let (bal0, bal1): (u256, u256) = (token0.balance_of(this), token1." +"balance_of(this));\n" "\n" " let total_supply = self.total_supply.read();\n" " let (amount0, amount1): (u256, u256) = (\n" @@ -5889,16 +5848,15 @@ msgstr "" "```" #: src/ch01/constant-product-amm.md:274 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/applications/constant_product_amm/src/" -"constant_product_amm.cairo)." +"blob/main/listings/applications/constant_product_amm/src/constant_product_amm." +"cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch01-applications/" -"constant_product_amm/src/constant_product_amm.cairo) 中尝试这个合约。" +"com/NethermindEth/StarknetByExample/blob/main/listings/applications/" +"constant_product_amm/src/constant_product_amm.cairo) 中测试这个合约。" #: src/ch02/write_to_any_slot.md:1 msgid "# Writing to any storage slot" @@ -5909,9 +5867,9 @@ msgid "" "On Starknet, a contract's storage is a map with 2^251 slots, where each slot " "is a felt which is initialized to 0.\n" "The address of storage variables is computed at compile time using the " -"formula: `storage variable address := pedersen(keccak(variable name), " -"keys)`. Interactions with storage variables are commonly performed using the " -"`self.var.read()` and `self.var.write()` functions." +"formula: `storage variable address := pedersen(keccak(variable name), keys)`. " +"Interactions with storage variables are commonly performed using the `self." +"var.read()` and `self.var.write()` functions." msgstr "" "在Starknet上,一个合约的存储是一个拥有 2^251 个槽的map,每个槽是一个初始化为 " "0 的 felt。存储变量的地址在编译时通过公式计算得出:`存储变量地址 := " @@ -5921,8 +5879,7 @@ msgstr "" #: src/ch02/write_to_any_slot.md:6 msgid "" "Nevertheless, we can use the `storage_write_syscall` and " -"`storage_read_syscall` syscalls, to write to and read from any storage " -"slot.\n" +"`storage_read_syscall` syscalls, to write to and read from any storage slot.\n" "This is useful when writing to storage variables that are not known at " "compile time, or to ensure that even if the contract is upgraded and the " "computation method of storage variable addresses changes, they remain " @@ -5930,8 +5887,8 @@ msgid "" msgstr "" "然而,我们可以使用 `storage_write_syscall` 和 `storage_read_syscall` 系统调" "用,来对任何存储槽进行写入和读取。\n" -"这在写入那些在编译时还未确定的存储变量时非常有用,这也可以确保即使合约升级且" -"存储变量地址的计算方法改变,这些变量仍然可访问。" +"这在写入那些在编译时还未确定的存储变量时非常有用,这也可以确保即使合约升级且存" +"储变量地址的计算方法改变,这些变量仍然可访问。" #: src/ch02/write_to_any_slot.md:9 msgid "" @@ -5941,9 +5898,9 @@ msgid "" "onchain computations. Once the address is computed, we use the storage " "syscalls to interact with it." msgstr "" -"在以下示例中,我们使用 Poseidon 哈希函数来计算存储变量的地址。Poseidon 是一" -"个 ZK 友好的哈希函数,比 Pedersen 更便宜、更快,是链上计算的绝佳选择。一旦地" -"址被计算出来,我们就使用存储的系统调用与之交互。" +"在以下示例中,我们使用 Poseidon 哈希函数来计算存储变量的地址。Poseidon 是一个 " +"ZK 友好的哈希函数,比 Pedersen 更便宜、更快,是链上计算的绝佳选择。一旦地址被" +"计算出来,我们就使用存储的系统调用与之交互。" #: src/ch02/write_to_any_slot.md:11 msgid "" @@ -6048,7 +6005,6 @@ msgstr "" "```" #: src/ch02/write_to_any_slot.md:56 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x033943CB781A4E63C9dcE0A1A09eAa3b617AA43CC61637C08c043a67f3fe0087) " @@ -6060,8 +6016,8 @@ msgstr "" "contract/0x033943CB781A4E63C9dcE0A1A09eAa3b617AA43CC61637C08c043a67f3fe0087) " "上的合约,或者在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch02-advanced-concepts/write_to_any_slot/src/contract." -"cairo) 中测试它." +"blob/main/listings/advanced-concepts/write_to_any_slot/src/contract.cairo) 中" +"测试它." #: src/ch02/storing_arrays.md:1 msgid "# Storing Arrays" @@ -6078,31 +6034,31 @@ msgid "" "for storing arrays in Cairo, so you will need to write your own " "implementation of the `Store` trait for the type of array you wish to store." msgstr "" -"在Starknet上,复杂值(例如元组或结构体)存储在以该存储变量地址开头的连续段" -"中。复杂存储值的大小有 256 个元素的限制,这意味着要在存储中存储超过 255 个元" -"素的数组,我们需要将其分割为大小 `n <= 255` 的段,并将这些段存储在多个存储地" -"址中。目前 Cairo 没有原生支持存储数组,所以你需要为你希望存储的数组类型实现自" -"己的 `Store` 特性。" +"在Starknet上,复杂值(例如元组或结构体)存储在以该存储变量地址开头的连续段中。" +"复杂存储值的大小有 256 个元素的限制,这意味着要在存储中存储超过 255 个元素的数" +"组,我们需要将其分割为大小 `n <= 255` 的段,并将这些段存储在多个存储地址中。目" +"前 Cairo 没有原生支持存储数组,所以你需要为你希望存储的数组类型实现自己的 " +"`Store` 特性。" #: src/ch02/storing_arrays.md:5 msgid "" "> Note: While storing arrays in storage is possible, it is not always " "recommended, as the read and write operations can get very costly. For " -"example, reading an array of size `n` requires `n` storage reads, and " -"writing to an array of size `n` requires `n` storage writes. If you only " -"need to access a single element of the array at a time, it is recommended to " -"use a `LegacyMap` and store the length in another variable instead." +"example, reading an array of size `n` requires `n` storage reads, and writing " +"to an array of size `n` requires `n` storage writes. If you only need to " +"access a single element of the array at a time, it is recommended to use a " +"`LegacyMap` and store the length in another variable instead." msgstr "" -"> 注:虽然在存储中保存数组是可行的,但并不总是推荐这么做,因为读写操作的成本" -"可能非常高。例如,读取一个大小为 n 的数组需要进行 `n` 次存储读取,而向一个大" -"小为 `n` 的数组写入需要进行 `n` 次存储写入。如果你只需要一次访问数组中的一个" -"元素,建议使用 `LegacyMap` 并在另一个变量中存储数组长度。" +"> 注:虽然在存储中保存数组是可行的,但并不总是推荐这么做,因为读写操作的成本可" +"能非常高。例如,读取一个大小为 n 的数组需要进行 `n` 次存储读取,而向一个大小" +"为 `n` 的数组写入需要进行 `n` 次存储写入。如果你只需要一次访问数组中的一个元" +"素,建议使用 `LegacyMap` 并在另一个变量中存储数组长度。" #: src/ch02/storing_arrays.md:7 msgid "" "The following example demonstrates how to write a simple implementation of " -"the `StorageAccess` trait for the `Array` type, allowing us to " -"store arrays of up to 255 `felt252` elements." +"the `StorageAccess` trait for the `Array` type, allowing us to store " +"arrays of up to 255 `felt252` elements." msgstr "" "以下示例展示了如何为 `Array` 类型实现一个简单的 `StorageAccess` 特" "性,使我们能够存储多达 255 个 `felt252` 元素的数组。" @@ -6117,8 +6073,7 @@ msgid "" " }\n" "\n" " fn write(\n" -" address_domain: u32, base: StorageBaseAddress, value: " -"Array\n" +" address_domain: u32, base: StorageBaseAddress, value: Array\n" " ) -> SyscallResult<()> {\n" " StoreFelt252Array::write_at_offset(address_domain, base, 0, value)\n" " }\n" @@ -6190,8 +6145,7 @@ msgstr "" " }\n" "\n" " fn write(\n" -" address_domain: u32, base: StorageBaseAddress, value: " -"Array\n" +" address_domain: u32, base: StorageBaseAddress, value: Array\n" " ) -> SyscallResult<()> {\n" " StoreFelt252Array::write_at_offset(address_domain, base, 0, value)\n" " }\n" @@ -6322,7 +6276,6 @@ msgstr "" "```" #: src/ch02/storing_arrays.md:103 -#, fuzzy msgid "" "Visit contract on [Voyager](https://goerli.voyager.online/" "contract/0x008F8069a3Fcd7691Db46Dc3b6F9D2C0436f9200E861330957Fd780A3595da86) " @@ -6330,12 +6283,11 @@ msgid "" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" "blob/main/listings/advanced-concepts/storing_arrays/src/contract.cairo)." msgstr "" -"访问 [Voyager](https://goerli.voyager.online/" +"访问[Voyager](https://goerli.voyager.online/" "contract/0x008F8069a3Fcd7691Db46Dc3b6F9D2C0436f9200E861330957Fd780A3595da86) " "上的合约,或者在 [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" -"blob/main/listings/ch02-advanced-concepts/storing_arrays/src/contract.cairo)" -"上测试." +"blob/main/listings/advanced-concepts/storing_arrays/src/contract.cairo)上测试." #: src/ch02/struct-mapping-key.md:1 msgid "# Structs as mapping keys" @@ -6343,13 +6295,12 @@ msgstr "# 结构体作为映射键" #: src/ch02/struct-mapping-key.md:3 msgid "" -"In order to use structs as mapping keys, you can use `#[derive(Hash)]` on " -"the struct definition. This will automatically generate a hash function for " -"the struct that can be used to represent the struct as a key in a " -"`LegacyMap`." +"In order to use structs as mapping keys, you can use `#[derive(Hash)]` on the " +"struct definition. This will automatically generate a hash function for the " +"struct that can be used to represent the struct as a key in a `LegacyMap`." msgstr "" -"为了使用结构体作为映射键,您可以在结构体定义上使用 `#[derive(Hash)]`。这将为" -"结构体自动生成一个哈希函数,可以在 `LegacyMap` 中将该结构体作为键来使用。" +"为了使用结构体作为映射键,您可以在结构体定义上使用 `#[derive(Hash)]`。这将为结" +"构体自动生成一个哈希函数,可以在 `LegacyMap` 中将该结构体作为键来使用。" #: src/ch02/struct-mapping-key.md:5 msgid "" @@ -6358,9 +6309,9 @@ msgid "" "`name`, `age` and `owner`. We consider that the combination of these three " "fields uniquely identifies a pet." msgstr "" -"考虑以下示例,我们希望使用类型为 `Pet` 的对象作为 `LegacyMap` 中的键。`Pet` " -"结构体有三个字段:`name` 、`age` 和 `owner`。假设这三个字段的组合能唯一地标识" -"一只宠物。" +"考虑以下示例,我们希望使用类型为 `Pet` 的对象作为 `LegacyMap` 中的键。`Pet` 结" +"构体有三个字段:`name` 、`age` 和 `owner`。假设这三个字段的组合能唯一地标识一" +"只宠物。" #: src/ch02/struct-mapping-key.md:8 msgid "" @@ -6390,8 +6341,7 @@ msgid "" "\n" " #[abi(embed_v0)]\n" " impl PetRegistry of super::IPetRegistry {\n" -" fn register_pet(ref self: ContractState, key: Pet, timestamp: u64) " -"{\n" +" fn register_pet(ref self: ContractState, key: Pet, timestamp: u64) {\n" " self.registration_time.write(key, timestamp);\n" " }\n" "\n" @@ -6428,8 +6378,7 @@ msgstr "" "\n" " #[abi(embed_v0)]\n" " impl PetRegistry of super::IPetRegistry {\n" -" fn register_pet(ref self: ContractState, key: Pet, timestamp: u64) " -"{\n" +" fn register_pet(ref self: ContractState, key: Pet, timestamp: u64) {\n" " self.registration_time.write(key, timestamp);\n" " }\n" "\n" @@ -6441,7 +6390,6 @@ msgstr "" "```" #: src/ch02/struct-mapping-key.md:45 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" @@ -6449,8 +6397,8 @@ msgid "" "cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch02-advanced-" -"concepts/struct_as_mapping_key/src/contract.cairo) 上测试这个合约." +"com/NethermindEth/StarknetByExample/blob/main/listings/advanced-concepts/" +"struct_as_mapping_key/src/contract.cairo) 上测试这个合约." #: src/ch02/hash-solidity-compatible.md:1 msgid "# Hash Solidity Compatible" @@ -6465,8 +6413,8 @@ msgid "" "result with `u128_byte_reverse`." msgstr "" "这个合约展示了在 Cairo 中进行 Keccak 哈希处理以匹配 Solidity 的 keccak256。尽" -"管两者都使用 Keccak,但它们的字节序不同:Cairo 是小端序,Solidity 是大端序。" -"该合约通过使用 `keccak_u256s_be_inputs` 以大端序进行哈希处理,并使用 " +"管两者都使用 Keccak,但它们的字节序不同:Cairo 是小端序,Solidity 是大端序。该" +"合约通过使用 `keccak_u256s_be_inputs` 以大端序进行哈希处理,并使用 " "`u128_byte_reverse` 反转结果的字节来实现兼容。" #: src/ch02/hash-solidity-compatible.md:7 @@ -6487,10 +6435,9 @@ msgid "" " struct Storage {}\n" "\n" " #[abi(embed_v0)]\n" -" impl SolidityHashExample of super::ISolidityHashExample " +" impl SolidityHashExample of super::ISolidityHashExample {\n" +" fn hash_data(ref self: ContractState, input_data: Span) -> u256 " "{\n" -" fn hash_data(ref self: ContractState, input_data: Span) -> " -"u256 {\n" " let hashed = keccak_u256s_be_inputs(input_data);\n" "\n" " // Split the hashed value into two 128-bit segments\n" @@ -6527,10 +6474,9 @@ msgstr "" " struct Storage {}\n" "\n" " #[abi(embed_v0)]\n" -" impl SolidityHashExample of super::ISolidityHashExample " +" impl SolidityHashExample of super::ISolidityHashExample {\n" +" fn hash_data(ref self: ContractState, input_data: Span) -> u256 " "{\n" -" fn hash_data(ref self: ContractState, input_data: Span) -> " -"u256 {\n" " let hashed = keccak_u256s_be_inputs(input_data);\n" "\n" " // Split the hashed value into two 128-bit segments\n" @@ -6552,7 +6498,6 @@ msgstr "" "```" #: src/ch02/hash-solidity-compatible.md:44 -#, fuzzy msgid "" "Play with the contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet&url=https://github.com/NethermindEth/StarknetByExample/" @@ -6560,8 +6505,8 @@ msgid "" "cairo)." msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet&url=https://github." -"com/NethermindEth/StarknetByExample/blob/main/listings/ch02-advanced-" -"concepts/hash_solidity_compatible/src/contract.cairo) 上测试这个合约." +"com/NethermindEth/StarknetByExample/blob/main/listings/advanced-concepts/" +"hash_solidity_compatible/src/contract.cairo) 上测试这个合约." #: src/ch02/optimisations/optimisations.md:1 msgid "# Optimisations " @@ -6609,19 +6554,19 @@ msgid "" "multiple values." msgstr "" "当存储多个值时,我们可以使用一种称为 **打包(packing)** 的技术。打包是一种允许" -"我们在单个 felt 值中存储多个值的技术。这是通过使用 felt 值的位来存储多个值来" -"实现的。" +"我们在单个 felt 值中存储多个值的技术。这是通过使用 felt 值的位来存储多个值来实" +"现的。" #: src/ch02/optimisations/store_using_packing.md:13 msgid "" -"For example, if we want to store two `u8` values, we can use the first 8 " -"bits of the felt value to store the first `u8` value, and the last 8 bits to " -"store the second `u8` value. This way, we can store two `u8` values in a " -"single felt value." +"For example, if we want to store two `u8` values, we can use the first 8 bits " +"of the felt value to store the first `u8` value, and the last 8 bits to store " +"the second `u8` value. This way, we can store two `u8` values in a single " +"felt value." msgstr "" "例如,如果我们想存储两个 `u8` 值,我们可以使用 felt 值的前 8 位来存储第一个 " -"`u8` 值,而使用后 8 位来存储第二个 `u8` 值。这样,我们就可以在单个 felt 值中" -"存储两个 `u8` 值。" +"`u8` 值,而使用后 8 位来存储第二个 `u8` 值。这样,我们就可以在单个 felt 值中存" +"储两个 `u8` 值。" #: src/ch02/optimisations/store_using_packing.md:15 msgid "" @@ -6648,23 +6593,22 @@ msgstr "" #: src/ch02/optimisations/store_using_packing.md:24 msgid "" -"This allows to store the type `T` by first packing it into the type " -"`PackedT` with the `pack` function, and then storing the `PackedT` value " -"with it's `Store` implementation. When reading the value, we first retrieve " -"the `PackedT` value, and then unpack it into the type `T` using the `unpack` " +"This allows to store the type `T` by first packing it into the type `PackedT` " +"with the `pack` function, and then storing the `PackedT` value with it's " +"`Store` implementation. When reading the value, we first retrieve the " +"`PackedT` value, and then unpack it into the type `T` using the `unpack` " "function." msgstr "" "这允许通过首先使用 `pack` 函数将类型 `T` 打包成 `PackedT` 类型,然后使用其 " -"`Store` 实现来存储 `PackedT` 值。在读取值时,我们首先获取 `PackedT` 值,然后" -"使用 `unpack` 函数将其解包为类型 `T`。" +"`Store` 实现来存储 `PackedT` 值。在读取值时,我们首先获取 `PackedT` 值,然后使" +"用 `unpack` 函数将其解包为类型 `T`。" #: src/ch02/optimisations/store_using_packing.md:26 msgid "" "Here's an example of storing a `Time` struct with two `u8` values using the " "`StorePacking` trait:" msgstr "" -"以下是一个使用 `StorePacking` 特性存储包含两个 `u8` 值的 `Time` 结构体的示" -"例:" +"以下是一个使用 `StorePacking` 特性存储包含两个 `u8` 值的 `Time` 结构体的示例:" #: src/ch02/optimisations/store_using_packing.md:28 msgid "" @@ -6724,8 +6668,8 @@ msgid "" " }\n" " fn get(self: @ContractState) -> Time {\n" " // This will read the felt252 value from storage\n" -" // and return the result of the unpack method of the " -"TimePackable trait\n" +" // and return the result of the unpack method of the TimePackable " +"trait\n" " return self.time.read();\n" " }\n" " }\n" @@ -6788,8 +6732,8 @@ msgstr "" " }\n" " fn get(self: @ContractState) -> Time {\n" " // This will read the felt252 value from storage\n" -" // and return the result of the unpack method of the " -"TimePackable trait\n" +" // and return the result of the unpack method of the TimePackable " +"trait\n" " return self.time.read();\n" " }\n" " }\n" @@ -6797,7 +6741,6 @@ msgstr "" "```" #: src/ch02/optimisations/store_using_packing.md:88 -#, fuzzy msgid "" "Play with this contract in [Remix](https://remix.ethereum.org/?" "#activate=Starknet-cairo1-compiler&url=https://github.com/NethermindEth/" @@ -6806,8 +6749,8 @@ msgid "" msgstr "" "在 [Remix](https://remix.ethereum.org/?#activate=Starknet-cairo1-" "compiler&url=https://github.com/NethermindEth/StarknetByExample/blob/main/" -"listings/ch02-advanced-concepts/store_using_packing/src/contract.cairo) 上测" -"试这个合约." +"listings/advanced-concepts/store_using_packing/src/contract.cairo) 上测试这个" +"合约." #: src/ch02/list.md:1 msgid "# List" @@ -6913,9 +6856,9 @@ msgid "" "trait. You can have the compiler derive it for you using the " "`#[derive(starknet::Store)]` attribute." msgstr "" -"`List` 默认支持大多数 corelib 类型。如果您想在 `List` 中存储自己的自定义类" -"型,该类型必须实现 `Store` 特性。您可以使用 `#[derive(starknet::Store)]` 属性" -"让编译器自动生成。" +"`List` 默认支持大多数 corelib 类型。如果您想在 `List` 中存储自己的自定义类型," +"该类型必须实现 `Store` 特性。您可以使用 `#[derive(starknet::Store)]` 属性让编" +"译器自动生成。" #: src/ch02/list.md:42 msgid "### Caveats" @@ -6933,8 +6876,8 @@ msgid "" "operations with a single inline statement. For example, `self.amounts.read()." "append(42);` will not work. You have to do it in 2 steps:" msgstr "" -"1. `append` 操作消耗 2 次存储写入操作 - 一次是为了值本身,另一次是为了更新列" -"表的长度。\n" +"1. `append` 操作消耗 2 次存储写入操作 - 一次是为了值本身,另一次是为了更新列表" +"的长度。\n" "2. 由于编译器的限制,不能使用单个内联语句进行变更操作。例如,`self.amounts." "read().append(42);` 是不行的。你必须分两步进行:" @@ -7020,8 +6963,8 @@ msgid "" " current_amount_list.append(number);\n" " }\n" "\n" -" fn add_in_task(ref self: ContractState, description: felt252, " -"status: felt252) {\n" +" fn add_in_task(ref self: ContractState, description: felt252, status: " +"felt252) {\n" " let new_task = Task { description: description, status: " "status };\n" " let mut current_tasks_list = self.tasks.read();\n" @@ -7099,8 +7042,8 @@ msgstr "" " current_amount_list.append(number);\n" " }\n" "\n" -" fn add_in_task(ref self: ContractState, description: felt252, " -"status: felt252) {\n" +" fn add_in_task(ref self: ContractState, description: felt252, status: " +"felt252) {\n" " let new_task = Task { description: description, status: " "status };\n" " let mut current_tasks_list = self.tasks.read();\n" @@ -7156,8 +7099,8 @@ msgstr "" #~ "Cairo v1 和Starknet互动的教程\n" #~ "- [Cairopractice](https://cairopractice.com/):关于Cairo和Starknet的一系列" #~ "文章的博客\n" -#~ "- [Cairo by example](https://cairo-by-example.com/):Cairo 简介,附带简单" -#~ "示例" +#~ "- [Cairo by example](https://cairo-by-example.com/):Cairo 简介,附带简单示" +#~ "例" #~ msgid "
Last change: 2023-11-20
" #~ msgstr ""