-
Notifications
You must be signed in to change notification settings - Fork 896
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
9 changed files
with
210 additions
and
9 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 |
---|---|---|
|
@@ -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. | ||
|
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 = "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" |
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 = "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
70
mover/linqining/code/task3/display_nft/sources/display_nft.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,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()); | ||
} |
18 changes: 18 additions & 0 deletions
18
mover/linqining/code/task3/display_nft/tests/display_nft_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 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 | ||
} | ||
*/ |
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
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
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