-
Notifications
You must be signed in to change notification settings - Fork 890
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
5 changed files
with
250 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,122 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 3 | ||
manifest_digest = "626B61B466ECA1260F24FE1298C9CC4124587FB871F6BCF2B714095FE6E2B207" | ||
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" | ||
dependencies = [ | ||
{ id = "NftProtocol", name = "NftProtocol" }, | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "Allowlist" | ||
source = { git = "https://github.com/Origin-Byte/nft-protocol.git", rev = "main", subdir = "contracts\\allowlist" } | ||
|
||
dependencies = [ | ||
{ id = "Permissions", name = "Permissions" }, | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "Authlist" | ||
source = { git = "https://github.com/Origin-Byte/nft-protocol.git", rev = "main", subdir = "contracts\\authlist" } | ||
|
||
dependencies = [ | ||
{ id = "Permissions", name = "Permissions" }, | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "Kiosk" | ||
source = { git = "https://github.com/Origin-Byte/nft-protocol.git", rev = "main", subdir = "contracts\\kiosk" } | ||
|
||
dependencies = [ | ||
{ id = "Permissions", name = "Permissions" }, | ||
{ id = "Request", name = "Request" }, | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "MoveStdlib" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates\\sui-framework\\packages\\move-stdlib" } | ||
|
||
[[move.package]] | ||
id = "NftProtocol" | ||
source = { git = "https://github.com/Origin-Byte/nft-protocol.git", rev = "main", subdir = "contracts/nft_protocol" } | ||
|
||
dependencies = [ | ||
{ id = "Allowlist", name = "Allowlist" }, | ||
{ id = "Authlist", name = "Authlist" }, | ||
{ id = "Kiosk", name = "Kiosk" }, | ||
{ id = "Originmate", name = "Originmate" }, | ||
{ id = "Permissions", name = "Permissions" }, | ||
{ id = "Pseudorandom", name = "Pseudorandom" }, | ||
{ id = "Request", name = "Request" }, | ||
{ id = "Sui", name = "Sui" }, | ||
{ id = "Utils", name = "Utils" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "Originmate" | ||
source = { git = "https://github.com/Origin-Byte/nft-protocol.git", rev = "main", subdir = "contracts\\originmate" } | ||
|
||
dependencies = [ | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "Permissions" | ||
source = { git = "https://github.com/Origin-Byte/nft-protocol.git", rev = "main", subdir = "contracts\\permissions" } | ||
|
||
dependencies = [ | ||
{ id = "Sui", name = "Sui" }, | ||
{ id = "Utils", name = "Utils" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "Pseudorandom" | ||
source = { git = "https://github.com/Origin-Byte/nft-protocol.git", rev = "main", subdir = "contracts\\pseudorandom" } | ||
|
||
dependencies = [ | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "Request" | ||
source = { git = "https://github.com/Origin-Byte/nft-protocol.git", rev = "main", subdir = "contracts\\request" } | ||
|
||
dependencies = [ | ||
{ id = "Permissions", name = "Permissions" }, | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "Sui" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.19.1", subdir = "crates/sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ id = "MoveStdlib", name = "MoveStdlib" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "Utils" | ||
source = { git = "https://github.com/Origin-Byte/nft-protocol.git", rev = "main", subdir = "contracts\\utils" } | ||
|
||
dependencies = [ | ||
{ id = "Pseudorandom", name = "Pseudorandom" }, | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[move.toolchain-version] | ||
compiler-version = "1.38.3" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0xda51f62ad654d484ff0e2b23cabcf87a590bcdf5127bce3f4150f5499de6a7ed" | ||
latest-published-id = "0xda51f62ad654d484ff0e2b23cabcf87a590bcdf5127bce3f4150f5499de6a7ed" | ||
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 = "M2887_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 (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] | ||
|
||
[dependencies] | ||
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.19.1" } | ||
NftProtocol = { git = "https://github.com/Origin-Byte/nft-protocol.git", subdir = "contracts/nft_protocol", rev = "main" } | ||
# 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_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" | ||
|
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,73 @@ | ||
/* | ||
/// Module: m2887_nft | ||
module m2887_nft::m2887_nft; | ||
*/ | ||
module m2887_nft::m2887_nft { | ||
use nft_protocol::attributes::{Self, Attributes}; | ||
use nft_protocol::collection; | ||
use std::ascii::String; | ||
use std::string; | ||
use sui::url::{Self, Url}; | ||
use nft_protocol::display_info; | ||
use nft_protocol::mint_cap::{Self, MintCap}; | ||
use nft_protocol::mint_event; | ||
use ob_permissions::witness; | ||
|
||
public struct M2887_NFT has drop {} | ||
|
||
/// 可用于创建后授权其他操作。至关重要的是,这个结构体不能随意提供给任何合约,因为它充当了授权令牌。 | ||
public struct Witness has drop {} | ||
|
||
public struct NFT has key, store { | ||
id: UID, | ||
name: String, | ||
description: String, | ||
url: Url, | ||
attributes: Attributes, | ||
} | ||
|
||
fun init(otw: M2887_NFT, ctx: &mut TxContext) { | ||
let (mut collection, mint_cap) = collection::create_with_mint_cap<M2887_NFT, NFT>( | ||
&otw, option::none(), ctx | ||
); | ||
let delegated_witness = witness::from_witness(Witness {}); | ||
|
||
collection::add_domain( | ||
delegated_witness, | ||
&mut collection, | ||
display_info::new( | ||
string::utf8(b"M2887_NFT"), | ||
string::utf8(b"A NFT collection of M2887_NFT on Sui"), | ||
), | ||
); | ||
transfer::public_share_object(collection); | ||
transfer::public_share_object(mint_cap); | ||
} | ||
|
||
public entry fun mint_nft( | ||
mint_cap: &MintCap<NFT>, | ||
name: String, | ||
description: String, | ||
url: String, | ||
ctx: &mut TxContext, | ||
) { | ||
let nft = NFT { | ||
id: object::new(ctx), | ||
name, | ||
description, | ||
url: url::new_unsafe(url), | ||
attributes: attributes::from_vec(vector[], vector[]) | ||
}; | ||
|
||
mint_event::emit_mint( | ||
witness::from_witness(Witness {}), | ||
mint_cap::collection_id(mint_cap), | ||
&nft, | ||
); | ||
transfer::public_transfer(nft, tx_context::sender(ctx)); | ||
} | ||
|
||
public entry fun transfer_nft(nft: NFT, to: address) { | ||
transfer::public_transfer(nft, to); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
mover/M2887/code/task3/M2887_NFT/tests/m2887_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 m2887_nft::m2887_nft_tests; | ||
// uncomment this line to import the module | ||
// use m2887_nft::m2887_nft; | ||
const ENotImplemented: u64 = 0; | ||
#[test] | ||
fun test_m2887_nft() { | ||
// pass | ||
} | ||
#[test, expected_failure(abort_code = ::m2887_nft::m2887_nft_tests::ENotImplemented)] | ||
fun test_m2887_nft_fail() { | ||
abort ENotImplemented | ||
} | ||
*/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.