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

feat: task 3 #1234

Merged
merged 1 commit into from
Jul 20, 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/tutu-stack/code/task3/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 = 2
manifest_digest = "A49D1E9E7549E19E70A78ED65CAE86472B25D880120E65E7848F9D9EEFEC445B"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ name = "Sui" },
]

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

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

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

[move.toolchain-version]
compiler-version = "1.28.2"
edition = "legacy"
flavor = "sui"

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x38acd0378b9badb7f8d22395623d5c5b33aea27ca3adbe14d81b40f5cef04893"
latest-published-id = "0x38acd0378b9badb7f8d22395623d5c5b33aea27ca3adbe14d81b40f5cef04893"
published-version = "1"
37 changes: 37 additions & 0 deletions mover/tutu-stack/code/task3/Move.toml
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/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]
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"

102 changes: 102 additions & 0 deletions mover/tutu-stack/code/task3/sources/ntf_tutustack.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/// Module: task3
module task3::nft_tutustack {
use sui::url::{Url, Self};
use std::string;
use sui::object::{Self, ID, UID};
use sui::event;
use sui::transfer;
use sui::tx_context::{TxContext, Self};

struct TutustackNFT has key, store {
id: UID,
name: string::String,
description: string::String,
url: Url,
}

struct TutustackNFTTransferEvent has copy, drop {
object_id: ID,
from: address,
to: address,
}

struct TutustackNFTMintEvent has copy, drop {
object_id: ID,
creator: address,
name: string::String,
}

struct TutustackNFTBurnEvent has copy, drop {
object_id: ID,
}

public fun name(nft: &TutustackNFT): string::String {
nft.name
}

public fun description(nft: &TutustackNFT): string::String {
nft.description
}

public fun url(nft: &TutustackNFT): Url {
nft.url
}

public entry fun mint_nft(
name: vector<u8>,
description: vector<u8>,
url: vector<u8>,
ctx: &mut TxContext
) {
let sender = tx_context::sender(ctx);
let nft = TutustackNFT {
id: object::new(ctx),
name: string::utf8(name),
description: string::utf8(description),
url: url::new_unsafe_from_bytes(url),
};

event::emit(TutustackNFTMintEvent {
object_id: object::id(&nft),
creator: sender,
name: nft.name,
});

transfer::public_transfer(nft, sender);
}

public entry fun transfer_nft(
nft: TutustackNFT,
recipient: address,
_: &mut TxContext,
) {
event::emit(TutustackNFTTransferEvent {
object_id: object::id(&nft),
from: tx_context::sender(_),
to: recipient,
});

transfer::public_transfer(nft, recipient);
}

public entry fun update_description(
nft: &mut TutustackNFT,
description: vector<u8>,
_: &mut TxContext
) {
nft.description = string::utf8(description);
}

public entry fun burn(
nft: TutustackNFT,
_: &mut TxContext
) {
let TutustackNFT {id, name: _, description: _, url: _} = nft;
event::emit(TutustackNFTBurnEvent {
object_id: object::uid_to_inner(&id),
});

object::delete(id);
}

}
Binary file added mover/tutu-stack/images/Snipaste_2024-07-18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions mover/tutu-stack/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@
- [x] 转账 `My Coin` hash: HZA4QqF58VmZHpT1nLFyTZt3SfoDnjDoRZuDaZbN3oxr
- [x] `Faucet Coin` address1 mint hash: 5Fq43TfQ3BrAB7Bm7KzpjGg6jXxgTm2CMjtWyyGtMBzw
- [x] `Faucet Coin` address2 mint hash: 2jSAHu4VkiUuoEpUFc7syX2wzdPojToUM7DwnMDsc2sz

## 03 move NFT
- [x] nft package id :0x38acd0378b9badb7f8d22395623d5c5b33aea27ca3adbe14d81b40f5cef04893
- [x] nft object id : 0x6cc4431fb16ae3a77d2de72777616a9aa547bab25b3693e8275f3015451b6ae3
- [x] 转账 nft hash: 2Qc3JjyahEjjPL3GdkXiWJsuzFAMDtFNPPisnYaL76mE
- [x] scan上的NFT截图:![Scan截图](./images/Snipaste_2024-07-18.png)