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

task2、task3、task4、task5 #2137

Merged
merged 6 commits into from
Dec 25, 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
34 changes: 34 additions & 0 deletions mover/M2887/code/task2/M2887_coin/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# @generated by Move, please check-in and do not edit manually.

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

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

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

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

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

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x5a3a556c1b4cb0d9e20595fc0819bef617de4a6b16c258e58f49e7d1c27d4cf9"
latest-published-id = "0x5a3a556c1b4cb0d9e20595fc0819bef617de4a6b16c258e58f49e7d1c27d4cf9"
published-version = "1"
37 changes: 37 additions & 0 deletions mover/M2887/code/task2/M2887_coin/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "M2887_coin"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"]

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

# 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]
m2887_coin = "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"

64 changes: 64 additions & 0 deletions mover/M2887/code/task2/M2887_coin/sources/m2887_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
/// Module: m2887_coin
module m2887_coin::m2887_coin;
*/
/*
/// Module: m2887_coin
module m2887_coin::m2887_coin;
*/

module m2887_coin::m2887_coin { // 定义模块 M2887_coin
use sui::coin::{Self, Coin, TreasuryCap}; // 引入 Coin 和 TreasuryCap 相关功能
use sui::url::{Self, Url}; // 引入 URL 相关功能

// 定义一种新的货币类型 M2887_COIN,且具有可丢弃的特性
public struct M2887_COIN has drop {}

// 初始化函数,用于创建该货币
fun init(
witness: M2887_COIN, // 货币的见证对象
ctx: &mut TxContext // 交易上下文
) {
// 调用 coin 模块创建货币,并设置相关参数
let (treasury_cap, metadata) = coin::create_currency<M2887_COIN>(
witness, // 见证对象
9, // 小数位数
b"M2887", // 货币符号
b"M2887_COIN", // 货币代码
b"M2887 Coin", // 货币名称
option::some<Url>( // 货币相关的 URL
url::new_unsafe_from_bytes(
b"https://avatars.githubusercontent.com/u/49989931" // 头像链接
)
),
ctx // 交易上下文
);
// 冻结元数据对象,确保其在交易过程中不会被修改
transfer::public_freeze_object(metadata);
// 将国库资本转移到交易的发送者地址
transfer::public_transfer(
treasury_cap,
tx_context::sender(ctx) // 获取发送者地址
)
}

// 公共入口函数,用于铸造新的 M2887_COIN 货币
public entry fun mint(
treasury_cap: &mut TreasuryCap<M2887_COIN>, // 货币国库
amount: u64, // 铸造的数量
recipient: address, // 接收地址
ctx: &mut TxContext // 交易上下文
) {
// 调用 coin 模块的铸造和转移函数
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}

// 公共函数,用于销毁 M2887_COIN 货币
public fun burn(
treasury_cap: &mut TreasuryCap<M2887_COIN>, // 货币国库
coin: Coin<M2887_COIN> // 需要销毁的货币
) {
// 调用 coin 模块的销毁函数
coin::burn(treasury_cap, coin);
}
}
18 changes: 18 additions & 0 deletions mover/M2887/code/task2/M2887_coin/tests/m2887_coin_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module m2887_coin::m2887_coin_tests;
// uncomment this line to import the module
// use m2887_coin::m2887_coin;

const ENotImplemented: u64 = 0;

#[test]
fun test_m2887_coin() {
// pass
}

#[test, expected_failure(abort_code = ::m2887_coin::m2887_coin_tests::ENotImplemented)]
fun test_m2887_coin_fail() {
abort ENotImplemented
}
*/
34 changes: 34 additions & 0 deletions mover/M2887/code/task2/M2887_faucet_coin/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# @generated by Move, please check-in and do not edit manually.

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

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

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

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

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

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x8526f8f3d7e23ca6e2c68c67855357745f03a9097d93a3dd3274a44290fc3faa"
latest-published-id = "0x8526f8f3d7e23ca6e2c68c67855357745f03a9097d93a3dd3274a44290fc3faa"
published-version = "1"
37 changes: 37 additions & 0 deletions mover/M2887/code/task2/M2887_faucet_coin/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "M2887_faucet_coin"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"]

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

# 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]
m2887_faucet_coin = "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"

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
/// Module: m2887_faucet_coin
module m2887_faucet_coin::m2887_faucet_coin;
*/
module m2887_faucet_coin::m2887_faucet_coin {
use sui::coin::{Self, Coin, TreasuryCap};
use sui::url::{Self, Url};

public struct M2887_FAUCET_COIN has drop {}

fun init(
witness: M2887_FAUCET_COIN,
ctx: &mut TxContext
) {
let (treasury_cap, metadata) = coin::create_currency<M2887_FAUCET_COIN>(
witness,
9,
b"CRF",
b"M2887_FAUCET_COIN",
b"M2887 Faucet Coin",
option::some<Url>(
url::new_unsafe_from_bytes(
b"https://avatars.githubusercontent.com/u/49989931"
)
),
ctx
);
transfer::public_freeze_object(metadata);
transfer::public_share_object(treasury_cap)
}

public entry fun mint(
treasury_cap: &mut TreasuryCap<M2887_FAUCET_COIN>,
amount: u64,
recipient: address,
ctx: &mut TxContext
) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}

public fun burn(
treasury_cap: &mut TreasuryCap<M2887_FAUCET_COIN>,
coin: Coin<M2887_FAUCET_COIN>
) {
coin::burn(treasury_cap, coin);

}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module m2887_faucet_coin::m2887_faucet_coin_tests;
// uncomment this line to import the module
// use m2887_faucet_coin::m2887_faucet_coin;

const ENotImplemented: u64 = 0;

#[test]
fun test_m2887_faucet_coin() {
// pass
}

#[test, expected_failure(abort_code = ::m2887_faucet_coin::m2887_faucet_coin_tests::ENotImplemented)]
fun test_m2887_faucet_coin_fail() {
abort ENotImplemented
}
*/
Loading
Loading