-
Notifications
You must be signed in to change notification settings - Fork 886
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
721 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "F319757101C76AC32711872ACE409FA2B960E03B5C74885B39111315E98A81E5" | ||
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" | ||
dependencies = [ | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "MoveStdlib" | ||
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" } | ||
|
||
[[move.package]] | ||
id = "Sui" | ||
source = { git = "https://gitee.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.37.1" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0x4e4ca0ff3a45ec5a9f81abe87a2c87ca13c95b73a2007eeab1f1d92a5b704e5f" | ||
latest-published-id = "0x4e4ca0ff3a45ec5a9f81abe87a2c87ca13c95b73a2007eeab1f1d92a5b704e5f" | ||
published-version = "1" | ||
|
||
[env.testnet] | ||
chain-id = "4c78adac" | ||
original-published-id = "0x3260cd250964b8b4ada708ed11a5f91f01972c162c82fbae0778c55b9704e156" | ||
latest-published-id = "0x3260cd250964b8b4ada708ed11a5f91f01972c162c82fbae0778c55b9704e156" | ||
published-version = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "faucetcoin" | ||
edition = "2024.beta" | ||
|
||
[dependencies] | ||
Sui = { git = "https://gitee.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } | ||
|
||
[addresses] | ||
faucetcoin = "0x4e4ca0ff3a45ec5a9f81abe87a2c87ca13c95b73a2007eeab1f1d92a5b704e5f" | ||
|
32 changes: 32 additions & 0 deletions
32
mover/yueliao11/code/task2/faucetcoin/sources/faucetcoin.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module faucetcoin::bright_faucet_coin { | ||
use sui::tx_context::TxContext; | ||
use sui::coin::{Self, TreasuryCap}; | ||
use sui::transfer; | ||
use std::option; | ||
|
||
public struct BRIGHT_FAUCET_COIN has drop {} | ||
|
||
fun init(witness: BRIGHT_FAUCET_COIN, ctx: &mut TxContext) { | ||
let (treasury, metadata) = coin::create_currency( | ||
witness, | ||
6, | ||
b"BrightFaucet", | ||
b"bright faucet coin", | ||
b"faucet_token", | ||
option::none(), | ||
ctx | ||
); | ||
transfer::public_freeze_object(metadata); | ||
transfer::public_share_object(treasury); | ||
} | ||
|
||
public entry fun mint( | ||
treasury_cap: &mut TreasuryCap<BRIGHT_FAUCET_COIN>, | ||
amount: u64, | ||
recipient: address, | ||
ctx: &mut TxContext | ||
) { | ||
let coin = coin::mint(treasury_cap, amount, ctx); | ||
transfer::public_transfer(coin, recipient); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
mover/yueliao11/code/task2/faucetcoin/tests/faucetcoin_tests.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
#[test_only] | ||
module faucetcoin::faucetcoin_tests; | ||
// uncomment this line to import the module | ||
// use faucetcoin::faucetcoin; | ||
const ENotImplemented: u64 = 0; | ||
#[test] | ||
fun test_faucetcoin() { | ||
// pass | ||
} | ||
#[test, expected_failure(abort_code = ::faucetcoin::faucetcoin_tests::ENotImplemented)] | ||
fun test_faucetcoin_fail() { | ||
abort ENotImplemented | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "DECC9EB2274321432CD4DABBA08132B41CE06461E4B9CD413D17687299796FE3" | ||
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.37.1" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0xc542cb63bd5b818c97a381cc9a9e412f39fc8931ea3b649d56a8ee160feb8809" | ||
latest-published-id = "0xc542cb63bd5b818c97a381cc9a9e412f39fc8931ea3b649d56a8ee160feb8809" | ||
published-version = "1" | ||
|
||
[env.testnet] | ||
chain-id = "4c78adac" | ||
original-published-id = "0x38af19420b13562d2d5ae5f8870ad512fcf0112dab29be447a6a0c86f5ca55be" | ||
latest-published-id = "0x38af19420b13562d2d5ae5f8870ad512fcf0112dab29be447a6a0c86f5ca55be" | ||
published-version = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "mycoin" | ||
edition = "2024.beta" | ||
|
||
[dependencies] | ||
Sui = { git = "https://gitee.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } | ||
|
||
[addresses] | ||
mycoin = "0xc542cb63bd5b818c97a381cc9a9e412f39fc8931ea3b649d56a8ee160feb8809" | ||
|
26 changes: 26 additions & 0 deletions
26
mover/yueliao11/code/task2/mycoin/sources/bright_coin.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
/// Module: mycoin | ||
module mycoin::mycoin; | ||
*/ | ||
module mycoin::bright_coin{ | ||
use sui::coin::{Self,TreasuryCap}; | ||
|
||
// Witness 是一种标记为 drop 的一次性使用资源。 | ||
// 这意味着它在使用后会被自动销毁,从而确保相关资源只被使用一次,防止其被重复用于创建同一资源的多个实例。 | ||
public struct BRIGHT_COIN has drop {} | ||
|
||
fun init (witness:BRIGHT_COIN,ctx:&mut TxContext){ | ||
let (treasury, metadata) = coin::create_currency(witness, 6, b"Bright", b"bright coin", b"My_token", option::none(), ctx ); | ||
// 冻结 metadata 对象,阻止后续的修改 | ||
transfer::public_freeze_object(metadata); | ||
// 将铸币的权限凭证转移到合约部署者 | ||
transfer::public_transfer(treasury, tx_context::sender(ctx)); | ||
|
||
} | ||
|
||
public fun mint_in_my_module(treasury_cap: &mut TreasuryCap<BRIGHT_COIN>, amount: u64, recipient: address, ctx: &mut TxContext) { | ||
let coin = coin::mint(treasury_cap, amount, ctx); | ||
transfer::public_transfer(coin, recipient); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
#[test_only] | ||
module mycoin::mycoin_tests; | ||
// uncomment this line to import the module | ||
// use mycoin::mycoin; | ||
const ENotImplemented: u64 = 0; | ||
#[test] | ||
fun test_mycoin() { | ||
// pass | ||
} | ||
#[test, expected_failure(abort_code = ::mycoin::mycoin_tests::ENotImplemented)] | ||
fun test_mycoin_fail() { | ||
abort ENotImplemented | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "2B41AE4822173E239CEBD326CC63067D6D4C241D88384DA0A128A80EB8E156C9" | ||
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" | ||
dependencies = [ | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "MoveStdlib" | ||
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" } | ||
|
||
[[move.package]] | ||
id = "Sui" | ||
source = { git = "https://gitee.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.37.1" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0x3da83250affdd9e22d0a601dac90a9d927149bb94292cf781650ef1fdda6da68" | ||
latest-published-id = "0x3da83250affdd9e22d0a601dac90a9d927149bb94292cf781650ef1fdda6da68" | ||
published-version = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "task3" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
# license = "" # e.g., "MIT", "GPL", "Apache 2.0" | ||
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"] | ||
|
||
[dependencies] | ||
Sui = { git = "https://gitee.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] | ||
task3 = "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" | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
``` | ||
sui move build | ||
sui client publish --gas-budget 100000000 | ||
sui client call --function mint \ | ||
--module yueliaoNFT \ | ||
--package 0x3da83250affdd9e22d0a601dac90a9d927149bb94292cf781650ef1fdda6da68 \ | ||
--args "yueliao11" "NFT for yueliao11" 0x7865c7cbd6dc262645ba44713f260e62a66ea99d74746e8823658270cb4a4398 \ | ||
--gas-budget 100000000 | ||
# mint 一个 NFT 到指定地址 | ||
sui client call --function mint \ | ||
--module yueliaoNFT \ | ||
--package 0x3da83250affdd9e22d0a601dac90a9d927149bb94292cf781650ef1fdda6da68 \ | ||
--args "yueliao11" "NFT for yueliao11" "0x7b8e0864967427679b4e129f79dc332a885c6087ec9e187b53451a9006ee15f2" \ | ||
--gas-budget 100000000 \ | ||
![NFT Mint Screenshot](./nft.jpg) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module task3::yueliaoNFT { | ||
use sui::tx_context::{Self, TxContext}; | ||
use sui::display; | ||
use sui::object::{Self, UID}; | ||
use sui::package; | ||
use sui::transfer; | ||
use std::string::{String, utf8}; | ||
|
||
public struct YUELIAONFT has drop {} | ||
|
||
public struct YUELIAO has key, store { | ||
id: UID, | ||
name: String, | ||
description: String, | ||
} | ||
|
||
fun init(otw: YUELIAONFT, ctx: &mut TxContext) { | ||
let keys = vector[ | ||
utf8(b"name"), | ||
utf8(b"description"), | ||
utf8(b"image_url") | ||
]; | ||
let values = vector[ | ||
utf8(b"yueliao11"), | ||
utf8(b"NFT for yueliao11"), | ||
utf8(b"https://avatars.githubusercontent.com/u/187120306?u=1902a0c17e07b76b0bb5ff5a93144d78ed5c1ed8&v=4&size=64") | ||
]; | ||
let publisher = package::claim(otw, ctx); | ||
let mut display = display::new_with_fields<YUELIAO>(&publisher, keys, values, ctx); | ||
display::update_version(&mut display); | ||
|
||
let deployer = tx_context::sender(ctx); | ||
transfer::public_transfer(publisher, deployer); | ||
transfer::public_transfer(display, deployer); | ||
} | ||
|
||
public entry fun mint(name: vector<u8>, description: vector<u8>, recipient: address, ctx: &mut TxContext) { | ||
let nft = YUELIAO { | ||
id: object::new(ctx), | ||
name: utf8(name), | ||
description: utf8(description), | ||
}; | ||
transfer::public_transfer(nft, recipient); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 3 | ||
manifest_digest = "C47266F6F7D2D0BF19570C6292569246654387B57DFF40C1F2B235CF8358780D" | ||
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" | ||
dependencies = [ | ||
{ id = "Sui", name = "Sui" }, | ||
{ id = "faucetcoin", name = "faucetcoin" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "MoveStdlib" | ||
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" } | ||
|
||
[[move.package]] | ||
id = "Sui" | ||
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ id = "MoveStdlib", name = "MoveStdlib" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "faucetcoin" | ||
source = { local = "../task2/faucetcoin" } | ||
|
||
dependencies = [ | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[move.toolchain-version] | ||
compiler-version = "1.37.1" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0x85847018fa1e086c87dbec5921e81988c5ecd4113862b4cea12a8b70162fc40e" | ||
latest-published-id = "0x85847018fa1e086c87dbec5921e81988c5ecd4113862b4cea12a8b70162fc40e" | ||
published-version = "1" |
Oops, something went wrong.