Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate lessons into Japanese from lesson 21 in Solidity 102 #736

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
829ca5a
translate lesson 21 into ja
thurendous Jun 1, 2024
674f589
translated lesson 22 and code
thurendous Jun 2, 2024
244270d
adding content of lesson 23 and fix lesson 20 (WIP)
thurendous Jun 2, 2024
dfdaea8
adding content of lesson 23 and fix some folder names, imgs (WIP)
thurendous Jun 3, 2024
5c24d6a
finishing translating lesson 23 and change imgs
thurendous Jun 3, 2024
f8398ae
translate Create.sol
thurendous Jun 3, 2024
19931c0
translate lesson 24 into ja
thurendous Jun 3, 2024
49f1256
add lesson 24
thurendous Jun 3, 2024
dfcfe2d
minor fix about lesson 24
thurendous Jun 3, 2024
f14a789
fix lesson 20
thurendous Jun 16, 2024
edce0c6
minor fix
thurendous Jun 16, 2024
18109de
minor fix about deleting chinese part
thurendous Jun 16, 2024
2cfdd23
update imgs
thurendous Jun 16, 2024
c0f8f5d
add lesson 26 Crete2
thurendous Jun 16, 2024
86b9579
minor fix
thurendous Jun 16, 2024
ba3d1d9
fix image in lesosn 25
thurendous Jun 16, 2024
1789a8e
Merge branch 'main' of https://github.com/thurendous/WTFSolidity into…
thurendous Jul 6, 2024
edb497b
add lesson 26 in ja
thurendous Jul 6, 2024
1a5584a
add lesson 27 in ja
thurendous Jul 6, 2024
2034bd5
fixed some sentences
thurendous Jul 13, 2024
33242ef
fixed a word
thurendous Jul 13, 2024
8a03a97
Merge branch 'main' of https://github.com/thurendous/WTFSolidity into…
thurendous Jul 13, 2024
dbd6018
add lesson 28 #736
thurendous Jul 13, 2024
074fb19
add content in lesson 28 #736
thurendous Jul 13, 2024
b108e59
add lesson 29 #736
thurendous Jul 13, 2024
74c2d8e
add code of lesson 30 #736
thurendous Jul 13, 2024
b2093ab
add lesson 30 #736
thurendous Jul 13, 2024
71ee97a
fix some minor mistakes
thurendous Jul 28, 2024
c57a633
fix minor mistake
thurendous Jul 28, 2024
1cc5e44
add some translated images
thurendous Jul 28, 2024
a2603c8
add some translated images of lesson 23
thurendous Jul 28, 2024
f6a7f79
add translated images of lesson 26
thurendous Jul 28, 2024
d109ed7
add translated images of lesson 27
thurendous Jul 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Languages/ja/21_CallContract_ja/img/21-1.png
thurendous marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Languages/ja/21_CallContract_ja/img/21-2.png
thurendous marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Languages/ja/21_CallContract_ja/img/21-3.png
thurendous marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Languages/ja/21_CallContract_ja/img/21-4.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thurendous
これは後回しにせずなんとかならない?画像日本語版にしようよ
終わったら、コメントのタイムライン末尾に"完了"とチェックマーク✅をよろしく!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Languages/ja/21_CallContract_ja/img/21-5.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thurendous
これは後回しにせずなんとかならない?画像日本語版にしようよ
終わったら、コメントのタイムライン末尾に"完了"とチェックマーク✅をよろしく!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Languages/ja/21_CallContract_ja/img/21-6.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thurendous
これは後回しにせずなんとかならない?画像日本語版にしようよ
終わったら、コメントのタイムライン末尾に"完了"とチェックマーク✅をよろしく!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Languages/ja/21_CallContract_ja/img/21-7.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thurendous
これは後回しにせずなんとかならない?画像日本語版にしようよ
終わったら、コメントのタイムライン末尾に"完了"とチェックマーク✅をよろしく!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Languages/ja/21_CallContract_ja/img/21-8.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thurendous
これは後回しにせずなんとかならない?画像日本語版にしようよ
終わったら、コメントのタイムライン末尾に"完了"とチェックマーク✅をよろしく!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Languages/ja/21_CallContract_ja/img/21-9.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thurendous
これは後回しにせずなんとかならない?画像日本語版にしようよ
終わったら、コメントのタイムライン末尾に"完了"とチェックマーク✅をよろしく!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions Languages/ja/23_Delegatecall_ja/Delegatecall.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

// delegatecall和call类似,都是低级函数
// call: B call C, 上下文为 C (msg.sender = B, C中的状态变量受影响)
// delegatecall: B delegatecall C, 上下文为B (msg.sender = A, B中的状态变量受影响)
// delegatecallはcallと似ており、低レベル関数である
// callの場合、BがCをcallすると、コンテキストはCとなる。(msg.sender = B, Cの中の状態変数は影響を受ける)
// delegatecallの場合、BがCをdelegatecallすると、コンテキストはBとなる。(msg.sender = A, Bの中の状態変数が影響を受ける)
// 注意B和C的数据存储布局必须相同!变量类型、声明的前后顺序要相同,不然会搞砸合约。
// 注意したいのは、B, Cにあるストレージのストラクチャが同じでなければならないこと。そうでないとごちゃまぜになってしまいます。

// 被调用的合约C
// 呼び出されるコントラクトC
contract C {
uint public num;
address public sender;
Expand All @@ -17,19 +18,19 @@ contract C {
}
}

// 发起delegatecall的合约B
// delegatecallをする側のコントラクトB
contract B {
uint public num;
address public sender;

// 通过call来调用C的setVars()函数,将改变合约C里的状态变量
// callを通じてCコントラクトを呼び出すと、Cのストレージが影響を受ける
function callSetVars(address _addr, uint _num) external payable{
// call setVars()
(bool success, bytes memory data) = _addr.call(
abi.encodeWithSignature("setVars(uint256)", _num)
);
}
// 通过delegatecall来调用C的setVars()函数,将改变合约B里的状态变量
// delegatecallを通じてCのsetVars()関数を呼び出し、コントラクトBの状態変数が変更される
function delegatecallSetVars(address _addr, uint _num) external payable{
// delegatecall setVars()
(bool success, bytes memory data) = _addr.delegatecall(
Expand Down
15 changes: 8 additions & 7 deletions Languages/ja/23_Delegatecall_ja/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ tags:

ユーザー`A`がコントラクト`B`を通してコントラクト`C`を`call`すると、コントラクト`C`の関数が実行され、`Context`(コンテキスト:状態変数のストレージ、msg.sender など)もコントラクト`C`になります。この場合、`msg.sender`は`B`のアドレスであり、関数がいくつかの状態変数を変更する場合、その効果はコントラクト`C`の変数に影響を与えます。

![call的上下文](https://images.mirror-media.xyz/publication-images/VgMR533pA8WYtE5Lr65mQ.png?height=698&width=1860)
![call的上下文](./img/23-1.png)

### `delegatecall`の場合

ユーザー`A`がコントラクト`B`を通してコントラクト`C`を`delegatecall`すると、コントラクト`C`の関数が実行されますが、`Context`(コンテキスト:状態変数のストレージ、msg.sender など)はコントラクト`B`になります。この場合、`msg.sender`は`A`のアドレスであり、関数がいくつかの状態変数を変更する場合、その効果はコントラクト`B`の変数に影響を与えます。

![delegatecallのコンテキスト](https://images.mirror-media.xyz/publication-images/JucQiWVixdlmJl6zHjCSI.png?height=702&width=1862)
![delegatecallのコンテキスト](./img/23-2.png)

皆さんはこのように理解するとよいです。投資家(ユーザー`A`)は彼自身の資産(`B`コントラクトの`状態変数`)をリスク投資代理(`C`コントラクト)に管理させます。実行されるのはリスク投資代理の関数ですが、変更されるのは資産の状態です
皆さんはこのように理解するとよいです。投資家(ユーザー`A`)は彼自身の資産(`B`コントラクトの`状態変数`)を資産管理会社(`C`コントラクト)に管理させてます。実行されるのは資産管理会社の関数(`C`)ですが、変更されるのは資産(`B`)の状態です

`delegatecall`の文法は`call`と似ています。

Expand All @@ -56,8 +56,6 @@ abi.encodeWithSignature("関数シグネチャ", カンマ区切りの引数);

`call`との違いとしては、`delegatecall`は`gas`を指定できますが、`ETH`の量を指定できません。

````solidity

> ***注意***: `delegatecall`を使うにはセキュリティリスクがあります。ときにはターゲットコントラクトがコントラクトとのストレージストラクチャが同じであることが求められます。そうでない場合、資産がなくされる可能性があります。

## どのような場合に`delegatecall`を使用するのか?
Expand Down Expand Up @@ -103,8 +101,10 @@ contract B {

次に、それらの違いを理解するために、私たちはそれぞれ`call`や`delegatecall`を使ってコントラクト`C`の`setVars`関数を呼び出します。

`callSetVars`函数通过`call`来调用`setVars`。它有两个参数`_addr`和`_num`,分别对应合约`C`的地址和`setVars`的参数。
`callSetVars`関数は`call`を使って`setVars`を呼び出します。2つの引数があり、`_addr`、`_num`があります。それぞれはコントラクト`C`のアドレスと`setVars`の引数二対応しています。
`callSetVars`関数は`call`を通じて`setVars`を呼び出します。2つの引数`_addr`、`_num`があり、コントラクト`C`のアドレスや`setVars`の引数を意味しています。


以下はコントラクトBの一部です。

```solidity
// callを使ってCのsetVars()関数を呼び出す。これはCコントラクトの状態変数を変更する
Expand All @@ -117,6 +117,7 @@ function callSetVars(address _addr, uint _num) external payable{
```

而`delegatecallSetVars`函数通过`delegatecall`来调用`setVars`。与上面的`callSetVars`函数相同,有两个参数`_addr`和`_num`,分别对应合约`C`的地址和`setVars`的参数。
一方で、`delegatecallSetVars`関数は
thurendous marked this conversation as resolved.
Show resolved Hide resolved

```solidity
// 通过delegatecall来调用C的setVars()函数,将改变合约B里的状态变量
Expand Down
Loading