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

新增三篇笔记分享及输出 #2151

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion mover/ctianming/co-learn-2411/images/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,19 @@ b站关注
第三周学课程学习

![alt text](Screenshot_2024-12-02-20-05-18-395_com.tencent.we.jpg)
12.3会议
12.3会议

![alt text](image.png)
第八、九、十篇笔记分享

![alt text](image.png)
第十一、十二、十三篇笔记分享

![alt text](image.png)
第四周课程学习

![alt text](image.png)
12.9会议

![alt text](image.png)
推特关注截图
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion mover/ctianming/co-learn-2411/project/move_coin/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.37.3"
compiler-version = "1.38.3"
edition = "2024.beta"
flavor = "sui"

Expand Down
168 changes: 82 additions & 86 deletions mover/ctianming/co-learn-2411/project/move_coin/sources/move_coin.move
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,51 @@
module move_coin::move_coin;
*/
module move_coin::my_coin {
use sui::coin::{Self, Coin, TreasuryCap};
use std::debug;
use std::ascii::string;

public struct MY_COIN has drop {}

fun init(witness: MY_COIN, ctx: &mut TxContext) {
let (treasury, metadata) = coin::create_currency(
witness,
6,
b"MOON",
b"CTIANMING_MY_COIN",
b"MOON_COIN",
option::none(),
ctx);
debug::print(&string(b"init MY_COIN"));
transfer::public_freeze_object(metadata);
transfer::public_transfer(treasury, ctx.sender())
}

public entry fun mint(
treasury_cap: &mut TreasuryCap<MY_COIN>,
amount: u64,
recipient: address,
ctx: &mut TxContext,
) {
debug::print(&string(b"my_coin mint"));
let coin = coin::mint(treasury_cap, amount, ctx);
transfer::public_transfer(coin, recipient)
}

public entry fun burn(
treasury_cap: &mut TreasuryCap<MY_COIN>,
coin: Coin<MY_COIN>
) {
debug::print(&string(b"burn"));
coin::burn(treasury_cap, coin);
}

#[test_only]
use std::ascii::string;
use std::debug;
use sui::coin::{Self, Coin, TreasuryCap};

public struct MY_COIN has drop {}

fun init(witness: MY_COIN, ctx: &mut TxContext) {
let (treasury, metadata) = coin::create_currency(
witness,
6,
b"MOON",
b"CTIANMING_MY_COIN",
b"MOON_COIN",
option::none(),
ctx,
);
debug::print(&string(b"init MY_COIN"));
transfer::public_freeze_object(metadata);
transfer::public_transfer(treasury, ctx.sender())
}

public entry fun mint(
treasury_cap: &mut TreasuryCap<MY_COIN>,
amount: u64,
recipient: address,
ctx: &mut TxContext,
) {
debug::print(&string(b"my_coin mint"));
let coin = coin::mint(treasury_cap, amount, ctx);
transfer::public_transfer(coin, recipient)
}

public entry fun burn(treasury_cap: &mut TreasuryCap<MY_COIN>, coin: Coin<MY_COIN>) {
debug::print(&string(b"burn"));
coin::burn(treasury_cap, coin);
}

#[test_only]
use sui::test_scenario as ts;

#[test]
fun test_self_mint() {
let admin = @0xA;
let mut scenario = ts::begin(admin);

// init
ts::next_tx(&mut scenario, admin);
{
Expand Down Expand Up @@ -100,7 +98,7 @@ module move_coin::my_coin {
};

// mint 100 coin => user1
ts::next_tx(&mut scenario, admin); // if change to user1, failed!
ts::next_tx(&mut scenario, admin); // if change to user1, failed!
{
let mut treasurycap = ts::take_from_sender<TreasuryCap<MY_COIN>>(&scenario);
mint(&mut treasurycap, 100, user1, scenario.ctx());
Expand All @@ -127,53 +125,51 @@ module move_coin::my_coin {
}

module move_coin::faucet_coin {
use sui::coin::{Self, Coin,TreasuryCap};
use std::debug;
use std::ascii::string;

public struct FAUCET_COIN has drop {}

fun init(witness: FAUCET_COIN, ctx: &mut TxContext) {
let (treasury, metadata) = coin::create_currency(
witness,
6,
b"MOON",
b"CTIANMING_FAUCET_COIN",
b"MOON_COIN",
option::none(),
ctx);
debug::print(&string(b"init FAUCET_COIN"));
transfer::public_freeze_object(metadata);
transfer::public_share_object(treasury)
}

public entry fun mint(
treasury_cap: &mut TreasuryCap<FAUCET_COIN>,
amount: u64,
recipient: address,
ctx: &mut TxContext,
) {
debug::print(&string(b"faucet_coin mint"));
let coin = coin::mint(treasury_cap, amount, ctx);
transfer::public_transfer(coin, recipient)
}

public entry fun burn(
treasury_cap: &mut TreasuryCap<FAUCET_COIN>,
coin: Coin<FAUCET_COIN>
) {
debug::print(&string(b"burn"));
coin::burn(treasury_cap, coin);
}

#[test_only]
use std::ascii::string;
use std::debug;
use sui::coin::{Self, Coin, TreasuryCap};

public struct FAUCET_COIN has drop {}

fun init(witness: FAUCET_COIN, ctx: &mut TxContext) {
let (treasury, metadata) = coin::create_currency(
witness,
6,
b"MOON",
b"CTIANMING_FAUCET_COIN",
b"MOON_COIN",
option::none(),
ctx,
);
debug::print(&string(b"init FAUCET_COIN"));
transfer::public_freeze_object(metadata);
transfer::public_share_object(treasury)
}

public entry fun mint(
treasury_cap: &mut TreasuryCap<FAUCET_COIN>,
amount: u64,
recipient: address,
ctx: &mut TxContext,
) {
debug::print(&string(b"faucet_coin mint"));
let coin = coin::mint(treasury_cap, amount, ctx);
transfer::public_transfer(coin, recipient)
}

public entry fun burn(treasury_cap: &mut TreasuryCap<FAUCET_COIN>, coin: Coin<FAUCET_COIN>) {
debug::print(&string(b"burn"));
coin::burn(treasury_cap, coin);
}

#[test_only]
use sui::test_scenario as ts;

#[test]
fun test_faucet_coin() {
let admin = @0xCAFE;
let user0 = @0xFECA;
let user1 = @0xABCD;
let user1 = @0xABCD;
let mut scenario = ts::begin(admin);

// init
Expand Down Expand Up @@ -214,7 +210,7 @@ module move_coin::faucet_coin {
ts::return_to_sender<Coin<FAUCET_COIN>>(&scenario, coin);
};

// query [user1] coin
// query [user1] coin
ts::next_tx(&mut scenario, user1);
{
let coin = ts::take_from_sender<Coin<FAUCET_COIN>>(&scenario);
Expand All @@ -240,7 +236,7 @@ module move_coin::faucet_coin {
ts::return_shared<TreasuryCap<FAUCET_COIN>>(treasurycap);
};

// burn [user1] coin,共享所有权,可以分别对自己的coin操作!
// burn [user1] coin,共享所有权,可以分别对自己的coin操作!
ts::next_tx(&mut scenario, user1);
{
let coin = ts::take_from_sender<Coin<FAUCET_COIN>>(&scenario);
Expand All @@ -252,4 +248,4 @@ module move_coin::faucet_coin {
ts::end(scenario);
// pass
}
}
}
20 changes: 17 additions & 3 deletions mover/ctianming/co-learn-2411/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## b站,推特关注

- [x] b站,推特关注截图: ![关注截图](./images/b_follow.png)
- [x] b站关注截图: ![关注截图](./images/b_follow.png)
- [x] b站关注截图: ![关注截图](./images/x_follow.png)


## 为共学营宣传(在朋友圈或者群聊中转发海报/文章)

Expand All @@ -13,14 +15,14 @@
- [x] 第一周:![学习记录截图](./images/lesson_1.png)
- [x] 第二周:![学习记录截图](./images/lesson_2.png)
- [x] 第三周:![学习记录截图](./images/lesson_3.png)
- [] 第四周:![学习记录截图](./images/你的图片地址)
- [x] 第四周:![学习记录截图](./images/lesson_4.png)

## 参加直播答疑

- [x] 第一周:![学习记录截图](./images/meeting_1.jpg)
- [x] 第二周:![学习记录截图](./images/meeting_2.png)
- [x] 第三周:![学习记录截图](./images/meeting_3.jpg)
- [] 第四周:![学习记录截图](./images/你的图片地址)
- [x] 第四周:![学习记录截图](./images/meeting_4.png)

## 群里分享学习笔记

Expand All @@ -31,6 +33,12 @@
- [x] 第五篇笔记: ![第五篇笔记分享](./images/note_share_5.png)
- [x] 第六篇笔记: ![第六篇笔记分享](./images/note_share_6.png)
- [x] 第七篇笔记: ![第七篇笔记分享](./images/note_share_7.png)
- [x] 第八篇笔记: ![第八篇笔记分享](./images/note_share_8_9_10.png)
- [x] 第九篇笔记: ![第九篇笔记分享](./images/note_share_8_9_10.png)
- [x] 第十篇笔记: ![第十篇笔记分享](./images/note_share_8_9_10.png)
- [x] 第十一篇笔记: ![第十一篇笔记分享](./images/note_share_11_12_13.png)
- [x] 第十二篇笔记: ![第十二篇笔记分享](./images/note_share_11_12_13.png)
- [x] 第十三篇笔记: ![第十三篇笔记分享](./images/note_share_11_12_13.png)

## 对外输出学习笔记

Expand All @@ -41,6 +49,12 @@
- [x] 第五篇笔记【https://learnblockchain.cn/article/9969】
- [x] 第六篇笔记【https://learnblockchain.cn/article/10021】
- [x] 第七篇笔记【https://learnblockchain.cn/article/10171】
- [x] 第八篇笔记【https://learnblockchain.cn/article/10199】
- [x] 第九篇笔记【https://learnblockchain.cn/article/10201】
- [x] 第十篇笔记【https://learnblockchain.cn/article/10202】
- [x] 第十一篇笔记【https://learnblockchain.cn/article/10215】
- [x] 第十二篇笔记【https://learnblockchain.cn/article/10216】
- [x] 第十三篇笔记【https://learnblockchain.cn/article/10220】

## 在HOH社区公众号发布自己的技术文章

Expand Down
Binary file added mover/ctianming/notes/call_by_interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mover/ctianming/notes/image-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public fun create_currency<T: drop>(
```

我们来逐一解释一下该函数的参数:
- witness 是一个类型 `T` 的一次性证明者,确保货币只被创建一次。通过 sui::types::is_one_time_witness 进行检查。具体参考:https://move.sui-book.com/programmability/witness-pattern.html
- witness 是一个类型 `T` 的一次性见证者,确保货币只被创建一次。通过 sui::types::is_one_time_witness 进行检查。具体参考:https://move.sui-book.com/programmability/witness-pattern.html
- decimals 指定货币支持的小数位数,定义其精度。
- symbol 是一个字节向量,表示货币的符号,例如 "USD" 或 "BTC"。
- name 指定货币的名称。
Expand Down
Loading
Loading