Skip to content

Commit

Permalink
task/task3
Browse files Browse the repository at this point in the history
  • Loading branch information
linqining committed Nov 18, 2024
1 parent d7f97f5 commit 16e2f36
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mover/linqining/code/task2/faucet_coin/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# 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/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.
Expand Down
34 changes: 34 additions & 0 deletions mover/linqining/code/task3/display_nft/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 = "6B7A8AED2C1EF029F8D2281D36C6E8AADD6050481843FF50F3E1DB6F5CE02FC4"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

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

[[move.package]]
id = "Sui"
source = { git = "https://github.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.37.1"
edition = "2024.beta"
flavor = "sui"

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x08e4c88ca1eb4233b4ea72e3b762d94ae48e3fd6e73939a7244fd31b2ade8db9"
latest-published-id = "0x08e4c88ca1eb4233b4ea72e3b762d94ae48e3fd6e73939a7244fd31b2ade8db9"
published-version = "1"
37 changes: 37 additions & 0 deletions mover/linqining/code/task3/display_nft/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "display_nft"
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://github.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]
display_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"

70 changes: 70 additions & 0 deletions mover/linqining/code/task3/display_nft/sources/display_nft.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module display_nft::display_nft;
use std::string::String;
use std::string;
use sui::package;
use sui::display;

public struct MyNFT has key,store{
id: UID,
name:String,
image_url:String,
}

public struct DISPLAY_NFT has drop{

}

fun init(otw:DISPLAY_NFT,ctx:&mut TxContext){

let keys = vector[
b"name".to_string(),
b"link".to_string(),
b"image_url".to_string(),
b"description".to_string(),
b"project_url".to_string(),
b"creator".to_string(),
];
let values = vector[
// For `name` one can use the `Hero.name` property
b"{name}".to_string(),
// For `link` one can build a URL using an `id` property
b"https://sui-heroes.io/hero/{id}".to_string(),
// For `image_url` use an IPFS template + `image_url` property.
b"{image_url}".to_string(),
// Description is static for all `Hero` objects.
b"A true Hero of the Sui ecosystem!".to_string(),
// Project URL is usually static
b"https://sui-heroes.io".to_string(),
// Creator field can be any
b"Unknown Sui Fan".to_string(),
];

// Claim the `Publisher` for the package!
let publisher = package::claim(otw, ctx);

// Get a new `Display` object for the `Hero` type.
let mut display = display::new_with_fields<MyNFT>(
&publisher, keys, values, ctx
);

// Commit first version of `Display` to apply changes.
display.update_version();
transfer::public_transfer(publisher,ctx.sender());
transfer::public_transfer(display,ctx.sender());

let my_nft = MyNFT{
id: object::new(ctx),
name:string::utf8(b"linqining"),
image_url: string::utf8(b"https://avatars.githubusercontent.com/u/18323181?s=400&u=1a7a274db375e0ffe9f303939d3283c5cedc1e25&v=4"),
};
transfer::public_transfer(my_nft,ctx.sender())
}

public entry fun mint(url:String,ctx:&mut TxContext){
let my_nft = MyNFT{
id: object::new(ctx),
name:string::utf8(b"linqining"),
image_url: url,
};
transfer::public_transfer(my_nft,ctx.sender());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module display_nft::display_nft_tests;
// uncomment this line to import the module
// use display_nft::display_nft;
const ENotImplemented: u64 = 0;
#[test]
fun test_display_nft() {
// pass
}
#[test, expected_failure(abort_code = ::display_nft::display_nft_tests::ENotImplemented)]
fun test_display_nft_fail() {
abort ENotImplemented
}
*/
6 changes: 6 additions & 0 deletions mover/linqining/code/task3/nft/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ chain-id = "4c78adac"
original-published-id = "0x34caeefe0d3b271ec280a386a37090cae86a35b5caadb9ed1b19c42698e2a92c"
latest-published-id = "0x34caeefe0d3b271ec280a386a37090cae86a35b5caadb9ed1b19c42698e2a92c"
published-version = "1"

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0xd274bf8a1ad63e7969ac9f653c2017c684e3a3762dff2bd48d7c5b7796a4263a"
latest-published-id = "0xd274bf8a1ad63e7969ac9f653c2017c684e3a3762dff2bd48d7c5b7796a4263a"
published-version = "1"
43 changes: 39 additions & 4 deletions mover/linqining/code/task3/nft/sources/nft.move
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public struct MyNFT has key{
image_url:String,
}

// public fun mint() {
//
// }
public struct DisplayNft has drop{

fun init(ctx:&mut TxContext){
}

fun init(otw:DisplayNft,ctx:&mut TxContext){
let my_nft = MyNFT{
id: object::new(ctx),
name:string::utf8(b"linqining"),
Expand All @@ -28,5 +28,40 @@ public entry fun mint(url:String,ctx:&mut TxContext){
name:string::utf8(b"linqining"),
image_url: url,
};
let keys = vector[
b"name".to_string(),
b"link".to_string(),
b"image_url".to_string(),
b"description".to_string(),
b"project_url".to_string(),
b"creator".to_string(),
];

let values = vector[
// For `name` one can use the `Hero.name` property
b"{name}".to_string(),
// For `link` one can build a URL using an `id` property
b"https://sui-heroes.io/hero/{id}".to_string(),
// For `image_url` use an IPFS template + `image_url` property.
b"ipfs://{image_url}".to_string(),
// Description is static for all `Hero` objects.
b"A true Hero of the Sui ecosystem!".to_string(),
// Project URL is usually static
b"https://sui-heroes.io".to_string(),
// Creator field can be any
b"Unknown Sui Fan".to_string(),
];

// Claim the `Publisher` for the package!
let publisher = package::claim(otw, ctx);

// Get a new `Display` object for the `Hero` type.
let mut display = display::new_with_fields<Hero>(
&publisher, keys, values, ctx
);

// Commit first version of `Display` to apply changes.
display.update_version(&display);
transfer(my_nft,ctx.sender());
transfer(display,ctx.sender());
}
Binary file added mover/linqining/images/nft_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions mover/linqining/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
- [x] `Faucet Coin` address2(0xc1f4704452819f75c258fe3a01e54d6561899e3478f818625ee8be716fbdd007) mint hash: HYr5URs9WbfP4sEUxQJtbfPg16U33XCmNnGwv7MPyVVM

## 03 move NFT
- [x] nft package id : 0x34caeefe0d3b271ec280a386a37090cae86a35b5caadb9ed1b19c42698e2a92c
- [x] nft object id : 0x3511e9b3d9e88acb2da73ecca408e9e86ab55d28fc41b946ecdaabfe6ed1b4ba
- [] 转账 nft hash:
- [] scan上的NFT截图:![Scan截图](./images/你的图片地址)
- [x] nft package id : 0x08e4c88ca1eb4233b4ea72e3b762d94ae48e3fd6e73939a7244fd31b2ade8db9
- [x] nft object id : 0x2f7c23c9e1e90dde2164fd15bdded9e8d43e6f19e81822883a3beb93f4495899
- [x] 转账 nft hash: PmWjBzc9RfS8UnQ14URBZKktEptWv4r1x3FN8dUCDqt
- [x] scan上的NFT截图:![Scan截图](./images/nft_mint.png)


## 04 Move Game
- [] game package id :
Expand Down

0 comments on commit 16e2f36

Please sign in to comment.