Skip to content

Commit

Permalink
Merge pull request #2153 from guoying2026/guoying2026
Browse files Browse the repository at this point in the history
task2 move coin,task3 move NFT,task4 Move Game,task5 Move Swap_共学营
  • Loading branch information
Sifotd authored Dec 12, 2024
2 parents b0c8cf2 + 2d1e70b commit 30c187a
Show file tree
Hide file tree
Showing 37 changed files with 5,897 additions and 16 deletions.
Binary file added mover/guoying2026/co-learn-2411/images/task3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions mover/guoying2026/code/task2/faucet_coin/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "CBB3CC5A9E8592FF42747F012E0254A9D6CE0A60E787C05E35CE361BFFA87B01"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

[[move.package]]
id = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" }

[[move.package]]
id = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

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

[env]

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0x243114c09b5e5e9ada0876d155ab4142c8b50ac45c23cf9715d92bf7fe8efcb7"
latest-published-id = "0x243114c09b5e5e9ada0876d155ab4142c8b50ac45c23cf9715d92bf7fe8efcb7"
published-version = "1"

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x6388a5b287e979f5f51632e320c6ae0cfdd96b39b087113ae58c3b26c5d03d4e"
latest-published-id = "0x6388a5b287e979f5f51632e320c6ae0cfdd96b39b087113ae58c3b26c5d03d4e"
published-version = "1"
39 changes: 39 additions & 0 deletions mover/guoying2026/code/task2/faucet_coin/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "faucet_coin"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
publish-at = "0x6388a5b287e979f5f51632e320c6ae0cfdd96b39b087113ae58c3b26c5d03d4e"
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" }

# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }

# For local dependencies use `local = path`. Path is relative to the package root
# Local = { local = "../path/to" }

# To resolve a version conflict and force a specific version for dependency
# override use `override = true`
# Override = { local = "../conflicting/version", override = true }

[addresses]
#faucet_coin = "0x0"
faucet_coin = "0x6388a5b287e979f5f51632e320c6ae0cfdd96b39b087113ae58c3b26c5d03d4e"

# Named addresses will be accessible in Move as `@name`. They're also exported:
# for example, `std = "0x1"` is exported by the Standard Library.
# alice = "0xA11CE"

[dev-dependencies]
# The dev-dependencies section allows overriding dependencies for `--test` and
# `--dev` modes. You can introduce test-only dependencies here.
# Local = { local = "../path/to/dev-build" }

[dev-addresses]
# The dev-addresses section allows overwriting named addresses for the `--test`
# and `--dev` modes.
# alice = "0xB0B"

37 changes: 37 additions & 0 deletions mover/guoying2026/code/task2/faucet_coin/sources/faucet_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module faucet_coin::rmb {
use sui::coin::{TreasuryCap, mint_and_transfer, burn, Coin};

public struct RMB has drop {}

/// 创建 `GY` 的 `TreasuryCap`
/// 使用 `public_transfer` 模拟独享 mint 权限
/// 为什么不用entry。是为了不让外部调用r
/// 去掉public,也不要被其他模块调用
/// gy是无法外部构造:GY 的实例只能由模块内部逻辑控制。
fun init(rmb: RMB,ctx: &mut TxContext) {
let (treasury_cap, metadata) = sui::coin::create_currency<RMB>(
rmb,
8, // decimals
b"RMB", // symbol
b"RMB", // name
b"Guoying2026RMB", // description
option::none(), // icon_url
ctx
);

// 冻结 metadata
transfer::public_freeze_object(metadata);
// 将 `TreasuryCap` 共享给所有人
transfer::public_share_object(treasury_cap);
}

/// 独享 mint 权限
public entry fun my_mint(treasury_cap: &mut TreasuryCap<RMB>, amount: u64, recipient: address, ctx: &mut TxContext) {
mint_and_transfer(treasury_cap, amount, recipient, ctx);
}

/// 支持销毁功能
public entry fun my_burn(treasury_cap: &mut TreasuryCap<RMB>, coin: Coin<RMB>) {
burn(treasury_cap, coin);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module faucet_coin::faucet_coin_tests;
// uncomment this line to import the module
// use faucet_coin::faucet_coin;
const ENotImplemented: u64 = 0;
#[test]
fun test_faucet_coin() {
// pass
}
#[test, expected_failure(abort_code = ::faucet_coin::faucet_coin_tests::ENotImplemented)]
fun test_faucet_coin_fail() {
abort ENotImplemented
}
*/
40 changes: 40 additions & 0 deletions mover/guoying2026/code/task2/my_coin/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "7002DBE24734823232A716A11AFBF882473B67DB23061D728E37BA8ADBF81E6E"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

[[move.package]]
id = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" }

[[move.package]]
id = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

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

[env]

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0x01dff513bd84a31b131c25a69abf08a3e754394a9f7a4e189ace62f0afb71eb4"
latest-published-id = "0x01dff513bd84a31b131c25a69abf08a3e754394a9f7a4e189ace62f0afb71eb4"
published-version = "1"

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x8712a36ab8b40aeb50d18951fccf4f6775eb9404119ac9312c8ae623bb006c5b"
latest-published-id = "0x8712a36ab8b40aeb50d18951fccf4f6775eb9404119ac9312c8ae623bb006c5b"
published-version = "1"
39 changes: 39 additions & 0 deletions mover/guoying2026/code/task2/my_coin/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "my_coin"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
publish-at = "0x8712a36ab8b40aeb50d18951fccf4f6775eb9404119ac9312c8ae623bb006c5b"
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" }

# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }

# For local dependencies use `local = path`. Path is relative to the package root
# Local = { local = "../path/to" }

# To resolve a version conflict and force a specific version for dependency
# override use `override = true`
# Override = { local = "../conflicting/version", override = true }

[addresses]
#my_coin = "0x0"
my_coin = "0x8712a36ab8b40aeb50d18951fccf4f6775eb9404119ac9312c8ae623bb006c5b"

# Named addresses will be accessible in Move as `@name`. They're also exported:
# for example, `std = "0x1"` is exported by the Standard Library.
# alice = "0xA11CE"

[dev-dependencies]
# The dev-dependencies section allows overriding dependencies for `--test` and
# `--dev` modes. You can introduce test-only dependencies here.
# Local = { local = "../path/to/dev-build" }

[dev-addresses]
# The dev-addresses section allows overwriting named addresses for the `--test`
# and `--dev` modes.
# alice = "0xB0B"

5 changes: 5 additions & 0 deletions mover/guoying2026/code/task2/my_coin/call.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sui client call --package 0x32646a35941423b6782a9a9ee2337dc9a1527fec36e8a0e902bd8a5fae2e47ae \
--module gy \
--function mint_and_transfer \
--type-args 0x32646a35941423b6782a9a9ee2337dc9a1527fec36e8a0e902bd8a5fae2e47ae::gy::GY \
--args 0x0fddc9fbcf9e340fe1b64ea3160d3905eeea39a1951c5084f4522be193fcdcb1 9999999900000000
38 changes: 38 additions & 0 deletions mover/guoying2026/code/task2/my_coin/sources/my_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module my_coin::gy {
use sui::coin::{TreasuryCap, mint_and_transfer, burn, Coin};

/// 定义 `GY` 类型
public struct GY has drop {}

/// 创建 `GY` 的 `TreasuryCap`
/// 使用 `public_transfer` 模拟独享 mint 权限
/// 为什么不用entry。是为了不让外部调用
/// 去掉public,也不要被其他模块调用
/// gy是无法外部构造:GY 的实例只能由模块内部逻辑控制。
fun init(gy: GY,ctx: &mut TxContext) {
let (treasury_cap, metadata) = sui::coin::create_currency<GY>(
gy,
8, // decimals
b"GY", // symbol
b"GuoyingCoin", // name
b"Guoying2026Coin", // description
option::none(), // icon_url
ctx
);

// 冻结 metadata
transfer::public_freeze_object(metadata);
// 将 `TreasuryCap` 转移给调用者
transfer::public_transfer(treasury_cap, tx_context::sender(ctx));
}

/// 独享 mint 权限
public entry fun my_mint(treasury_cap: &mut TreasuryCap<GY>, amount: u64, recipient: address, ctx: &mut TxContext) {
mint_and_transfer(treasury_cap, amount, recipient, ctx);
}

/// 支持销毁功能
public entry fun my_burn(treasury_cap: &mut TreasuryCap<GY>, coin: Coin<GY>) {
burn(treasury_cap, coin);
}
}
18 changes: 18 additions & 0 deletions mover/guoying2026/code/task2/my_coin/tests/my_coin_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module my_coin::my_coin_tests;
// uncomment this line to import the module
// use my_coin::my_coin;
const ENotImplemented: u64 = 0;
#[test]
fun test_my_coin() {
// pass
}
#[test, expected_failure(abort_code = ::my_coin::my_coin_tests::ENotImplemented)]
fun test_my_coin_fail() {
abort ENotImplemented
}
*/
40 changes: 40 additions & 0 deletions mover/guoying2026/code/task3/move_nft/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "69E5CE9B0CEB3C01D41830AF62DE6283DAED6EC78C590E28C4673D5122BD2A0D"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

[[move.package]]
id = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" }

[[move.package]]
id = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

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

[env]

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0xc19b04eb7f3f1a77732fce398d1aebd81525212fbe3a53c2165943b376f3bbb7"
latest-published-id = "0xc19b04eb7f3f1a77732fce398d1aebd81525212fbe3a53c2165943b376f3bbb7"
published-version = "1"

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0xff70ac31d8492bd0917c65004ebf345b44d5651dd28cf79c9bae8be0704456b8"
latest-published-id = "0xff70ac31d8492bd0917c65004ebf345b44d5651dd28cf79c9bae8be0704456b8"
published-version = "1"
38 changes: 38 additions & 0 deletions mover/guoying2026/code/task3/move_nft/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "move_nft"
version="0.0.1"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
authors = ["guoying ([email protected])"] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

[dependencies]
#Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" }
# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }

# For local dependencies use `local = path`. Path is relative to the package root
# Local = { local = "../path/to" }

# To resolve a version conflict and force a specific version for dependency
# override use `override = true`
# Override = { local = "../conflicting/version", override = true }

[addresses]
move_nft = "0x0"

# Named addresses will be accessible in Move as `@name`. They're also exported:
# for example, `std = "0x1"` is exported by the Standard Library.
# alice = "0xA11CE"

[dev-dependencies]
# The dev-dependencies section allows overriding dependencies for `--test` and
# `--dev` modes. You can introduce test-only dependencies here.
# Local = { local = "../path/to/dev-build" }

[dev-addresses]
# The dev-addresses section allows overwriting named addresses for the `--test`
# and `--dev` modes.
# alice = "0xB0B"

24 changes: 24 additions & 0 deletions mover/guoying2026/code/task3/move_nft/sources/move_nft.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module move_nft::move_nft {
use std::string;

/// 定义 NFT 的结构体
public struct MoveNFT has key, store {
id: object::UID,
name: string::String, // 使用标准库的 String 类型
image_url: string::String, // 使用标准库的 String 类型
}

/// 铸造 NFT
public entry fun mint(name: string::String, url: string::String, ctx: &mut tx_context::TxContext) {
// 创建 NFT 实例
let my_nft = MoveNFT {
id: object::new(ctx),
name,
image_url: url,
};

// 获取发送者地址并转移 NFT
let recipient = tx_context::sender(ctx);
transfer::public_transfer(my_nft, recipient);
}
}
Loading

0 comments on commit 30c187a

Please sign in to comment.