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

提交Task2与Task3 #1962

Merged
merged 2 commits into from
Nov 21, 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
Empty file.
6 changes: 6 additions & 0 deletions mover/hwen227/code/task2/hwen_coin/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ chain-id = "4c78adac"
original-published-id = "0x14a832d436ae3c6156d76db46ea64574abf29643b29788221b6cee5ddfa8e5fc"
latest-published-id = "0x14a832d436ae3c6156d76db46ea64574abf29643b29788221b6cee5ddfa8e5fc"
published-version = "1"

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x025c077dd399fe7d9a18271df29ea6b4922782d64f6aee06e218c0af9586546b"
latest-published-id = "0x025c077dd399fe7d9a18271df29ea6b4922782d64f6aee06e218c0af9586546b"
published-version = "1"
34 changes: 34 additions & 0 deletions mover/hwen227/code/task2/hwen_faucet_coin/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 = "9D642DF2896AE1BF9C5C9ED6CCB3EF1135524A84D3489A37B7AB887B0A3699BC"
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.36.2"
edition = "2024.beta"
flavor = "sui"

[env]

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module hwen_faucet_coin::hwen_faucet_coin {
use sui::coin::{Self, Coin, TreasuryCap};
use sui::url::{Self, Url};

public struct HWEN_FAUCET_COIN has drop {}

fun init(
witness: HWEN_FAUCET_COIN,
ctx: &mut TxContext
) {
let (treasury_cap, metadata) = coin::create_currency<HWEN_FAUCET_COIN>(
witness,
9,
b"HFC",
b"HWEN_FAUCET_COIN",
b"Hwen Faucet Coin",
option::some<Url>(
url::new_unsafe_from_bytes(
b"https://postimg.cc/ZWLQPcWp"
)
),
ctx
);
transfer::public_freeze_object(metadata);
transfer::public_share_object(treasury_cap)
}

public entry fun mint(
treasury_cap: &mut TreasuryCap<HWEN_FAUCET_COIN>,
amount: u64,
recipient: address,
ctx: &mut TxContext
) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}

public fun burn(
treasury_cap: &mut TreasuryCap<HWEN_FAUCET_COIN>,
coin: Coin<HWEN_FAUCET_COIN>
) {
coin::burn(treasury_cap, coin);

}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module hwen_faucet_coin::hwen_faucet_coin_tests;
// uncomment this line to import the module
// use hwen_faucet_coin::hwen_faucet_coin;

const ENotImplemented: u64 = 0;

#[test]
fun test_hwen_faucet_coin() {
// pass
}

#[test, expected_failure(abort_code = ::hwen_faucet_coin::hwen_faucet_coin_tests::ENotImplemented)]
fun test_hwen_faucet_coin_fail() {
abort ENotImplemented
}
*/
122 changes: 122 additions & 0 deletions mover/hwen227/code/task3/hwen_nft/Move.lock
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 = "847DCC043D286198AFF2797D1ED0D735FAD15667396A013AE0DF40BE5EC722D3"
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.36.2"
edition = "2024.beta"
flavor = "sui"

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x8e2e51ec7307cd7a525e46b158e932d971fbf4c46cd7e7dd0b0ed90e5413d223"
latest-published-id = "0x8e2e51ec7307cd7a525e46b158e932d971fbf4c46cd7e7dd0b0ed90e5413d223"
published-version = "1"
39 changes: 39 additions & 0 deletions mover/hwen227/code/task3/hwen_nft/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "hwen_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 = "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]
hwen_nft = "0x0"
std = "0x1"
sui = "0x2"

# 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"
83 changes: 83 additions & 0 deletions mover/hwen227/code/task3/hwen_nft/sources/hwen_nft.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
module hwen_nft::hwen {
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;
use sui::vec_map;

public struct HWEN has drop {}

public struct Witness has drop {}

public struct HwenNFT has key, store {
id: UID,
name: String,
description: String,
url: Url,
attributes: Attributes,
}

fun init(otw: HWEN, ctx: &mut TxContext) {
let (mut collection, mint_cap) = collection::create_with_mint_cap<HWEN, HwenNFT>(
&otw, option::none(), ctx
);
let delegated_witness = witness::from_witness(Witness {});

collection::add_domain(
delegated_witness,
&mut collection,
display_info::new(
string::utf8(b"Hwen"),
string::utf8(b"A NFT collection of Hwen on Sui"),
),
);
transfer::public_share_object(collection);
transfer::public_share_object(mint_cap);
}

public entry fun mint_nft(
mint_cap: &MintCap<HwenNFT>,
name: String,
description: String,
url: String,
ctx: &mut TxContext,
) {
let nft = HwenNFT {
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 add_new_attributes(
rex_nft: &mut HwenNFT,
new_attribute_name: String,
new_attribute_value: String
) {
let mut add_new_attributes = vec_map::empty<String, String>();
vec_map::insert(
&mut add_new_attributes,
new_attribute_name,
new_attribute_value
);
attributes::add_new(&mut rex_nft.id, add_new_attributes);
}

public entry fun transfer_nft(rex_nft: HwenNFT, to: address) {
transfer::public_transfer(rex_nft, to);
}
}
Loading