diff --git a/mover/djendjcn/code/task3/nft/Move.lock b/mover/djendjcn/code/task3/nft/Move.lock new file mode 100644 index 000000000..4470423c3 --- /dev/null +++ b/mover/djendjcn/code/task3/nft/Move.lock @@ -0,0 +1,34 @@ +# @generated by Move, please check-in and do not edit manually. + +[move] +version = 2 +manifest_digest = "9D4FCF5807A34E3110DFBA44AD92FEFEC55EE3DE8CF58F3D302F55D3004E70D1" +deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" +dependencies = [ + { name = "Sui" }, +] + +[[move.package]] +name = "MoveStdlib" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/move-stdlib" } + +[[move.package]] +name = "Sui" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } + +dependencies = [ + { name = "MoveStdlib" }, +] + +[move.toolchain-version] +compiler-version = "1.30.1" +edition = "2024.beta" +flavor = "sui" + +[env] + +[env.mainnet] +chain-id = "35834a8a" +original-published-id = "0x4a01e79477622269cd815af0093a442111fac8322c61515c61e14f1c3b4b3964" +latest-published-id = "0x4a01e79477622269cd815af0093a442111fac8322c61515c61e14f1c3b4b3964" +published-version = "1" diff --git a/mover/djendjcn/code/task3/nft/Move.toml b/mover/djendjcn/code/task3/nft/Move.toml new file mode 100644 index 000000000..504c662e4 --- /dev/null +++ b/mover/djendjcn/code/task3/nft/Move.toml @@ -0,0 +1,37 @@ +[package] +name = "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 = "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] +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" + diff --git a/mover/djendjcn/code/task3/nft/sources/nft.move b/mover/djendjcn/code/task3/nft/sources/nft.move new file mode 100644 index 000000000..3971c19bf --- /dev/null +++ b/mover/djendjcn/code/task3/nft/sources/nft.move @@ -0,0 +1,61 @@ +module nft::nft { + + use std::string::{Self, utf8, String}; + use sui::url::{Self, Url}; + use sui::display; + use sui::package; + + public struct Nft has key, store { + id: UID, + name: String, + description: String, + creator: address, + url: Url, + } + + public struct NFT has drop {} + + #[allow(lint(share_owned))] + fun init(otw: NFT, ctx: &mut TxContext) { + let publisher = package::claim(otw, ctx); + + let keys = vector[ + utf8(b"name"), + utf8(b"description"), + utf8(b"creator"), + utf8(b"image_url"), + ]; + + let values = vector[ + utf8(b"{name}"), + utf8(b"{description}"), + utf8(b"{creator}"), + utf8(b"{url}"), + ]; + + let mut display = display::new_with_fields( + &publisher, + keys, + values, + ctx + ); + + display::update_version(&mut display); + + transfer::public_share_object(display); + transfer::public_transfer(publisher, tx_context::sender(ctx)); + } + + entry fun mint(recipient:address, ctx: &mut TxContext) { + let nft = Nft { + id: object::new(ctx), + name: string::utf8(b"djendjcn"), + description: string::utf8(b"djendjcn NFT"), + creator: tx_context::sender(ctx), + url: url::new_unsafe_from_bytes( + b"https://avatars.githubusercontent.com/u/176220540?v=4" + ) + }; + transfer::public_transfer(nft, recipient); + } +} \ No newline at end of file diff --git a/mover/djendjcn/code/task3/nft/tests/nft_tests.move b/mover/djendjcn/code/task3/nft/tests/nft_tests.move new file mode 100644 index 000000000..1e3625fad --- /dev/null +++ b/mover/djendjcn/code/task3/nft/tests/nft_tests.move @@ -0,0 +1,19 @@ +/* +#[test_only] +module nft::nft_tests { + // uncomment this line to import the module + // use nft::nft; + + const ENotImplemented: u64 = 0; + + #[test] + fun test_nft() { + // pass + } + + #[test, expected_failure(abort_code = ::nft::nft_tests::ENotImplemented)] + fun test_nft_fail() { + abort ENotImplemented + } +} +*/ diff --git a/mover/djendjcn/code/task7/check_in/Move.lock b/mover/djendjcn/code/task7/check_in/Move.lock new file mode 100644 index 000000000..335363ff3 --- /dev/null +++ b/mover/djendjcn/code/task7/check_in/Move.lock @@ -0,0 +1,34 @@ +# @generated by Move, please check-in and do not edit manually. + +[move] +version = 2 +manifest_digest = "60ED2B08562863E03B32E589CB9D813832DBE08E722E777386028AACAA9C2B4A" +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.27.2" +edition = "2024.beta" +flavor = "sui" + +[env] + +[env.testnet] +chain-id = "4c78adac" +original-published-id = "0x914099b4d1b4f5513acc8aaa4fdc1f67578522b81d818f61bae527d590c6d87d" +latest-published-id = "0x914099b4d1b4f5513acc8aaa4fdc1f67578522b81d818f61bae527d590c6d87d" +published-version = "1" \ No newline at end of file diff --git a/mover/djendjcn/code/task7/check_in/Move.toml b/mover/djendjcn/code/task7/check_in/Move.toml new file mode 100644 index 000000000..e0a4a7f1a --- /dev/null +++ b/mover/djendjcn/code/task7/check_in/Move.toml @@ -0,0 +1,36 @@ +[package] +name = "check_in" +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://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] +check_in = "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" diff --git a/mover/djendjcn/code/task7/check_in/sources/check_in.move b/mover/djendjcn/code/task7/check_in/sources/check_in.move new file mode 100644 index 000000000..9892ff2e9 --- /dev/null +++ b/mover/djendjcn/code/task7/check_in/sources/check_in.move @@ -0,0 +1,77 @@ +module check_in::check_in { + use std::ascii::{String, string}; + use std::bcs; + use std::hash::sha3_256; + use std::vector; + use sui::event; + use sui::object; + use sui::random; + use sui::random::Random; + use sui::transfer::share_object; + use sui::tx_context::{Self, TxContext}; + + const ESTRING: u64 = 0; + + public struct Flag has copy, drop { + sender: address, + flag: bool, + ture_num: u64, + github_id: String + } + + public struct FlagString has key { + id: UID, + str: String, + ture_num: u64 + } + + fun init(ctx: &mut TxContext) { + let flag_str = FlagString { + id: object::new(ctx), + str: string(b"LetsMoveCTF"), + ture_num: 0 + }; + share_object(flag_str); + } + + + entry fun get_flag( + flag: vector, + github_id: String, + flag_str: &mut FlagString, + rand: &Random, + ctx: &mut TxContext + ) { + let mut bcs_flag = bcs::to_bytes(&flag_str.str); + vector::append(&mut bcs_flag, *github_id.as_bytes()); + + assert!(flag == sha3_256(bcs_flag), ESTRING); + + flag_str.str = getRandomString(rand, ctx); + + flag_str.ture_num = flag_str.ture_num + 1; + + event::emit(Flag { + sender: tx_context::sender(ctx), + flag: true, + ture_num: flag_str.ture_num, + github_id + }); + } + + + fun getRandomString(rand: &Random, ctx: &mut TxContext): String { + let mut gen = random::new_generator(rand, ctx); + + let mut str_len = random::generate_u8_in_range(&mut gen, 4, 30); + + let mut rand: vector = b""; + while (str_len != 0) { + let rand_num = random::generate_u8_in_range(&mut gen, 34, 126); + vector::push_back(&mut rand, rand_num); + str_len = str_len - 1; + }; + + string(rand) + } +} diff --git a/mover/djendjcn/code/task7/check_in/tests/check_in_tests.move b/mover/djendjcn/code/task7/check_in/tests/check_in_tests.move new file mode 100644 index 000000000..c82b0a810 --- /dev/null +++ b/mover/djendjcn/code/task7/check_in/tests/check_in_tests.move @@ -0,0 +1,19 @@ +/* +#[test_only] +module check_in::check_in_tests { + // uncomment this line to import the module + // use check_in::check_in; + + const ENotImplemented: u64 = 0; + + #[test] + fun test_check_in() { + // pass + } + + #[test, expected_failure(abort_code = ::check_in::check_in_tests::ENotImplemented)] + fun test_check_in_fail() { + abort ENotImplemented + } +} +*/ \ No newline at end of file diff --git a/mover/djendjcn/code/task8/lets_move/Move.lock b/mover/djendjcn/code/task8/lets_move/Move.lock new file mode 100644 index 000000000..7cf3aee44 --- /dev/null +++ b/mover/djendjcn/code/task8/lets_move/Move.lock @@ -0,0 +1,34 @@ +# @generated by Move, please check-in and do not edit manually. + +[move] +version = 2 +manifest_digest = "786B91A5B97E30CFE4109DB806C7FDAA208AD34906C77AB899770D4D0AEB5DB1" +deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" +dependencies = [ + { name = "Sui" }, +] + +[[move.package]] +name = "MoveStdlib" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/move-stdlib" } + +[[move.package]] +name = "Sui" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } + +dependencies = [ + { name = "MoveStdlib" }, +] + +[move.toolchain-version] +compiler-version = "1.26.2" +edition = "2024.beta" +flavor = "sui" + +[env] + +[env.testnet] +chain-id = "4c78adac" +original-published-id = "0x097a3833b6b5c62ca6ad10f0509dffdadff7ce31e1d86e63e884a14860cedc0f" +latest-published-id = "0x097a3833b6b5c62ca6ad10f0509dffdadff7ce31e1d86e63e884a14860cedc0f" +published-version = "1" \ No newline at end of file diff --git a/mover/djendjcn/code/task8/lets_move/Move.toml b/mover/djendjcn/code/task8/lets_move/Move.toml new file mode 100644 index 000000000..ebe419700 --- /dev/null +++ b/mover/djendjcn/code/task8/lets_move/Move.toml @@ -0,0 +1,36 @@ +[package] +name = "lets_move" +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 = "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] +lets_move = "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" diff --git a/mover/djendjcn/code/task8/lets_move/sources/lets_move.move b/mover/djendjcn/code/task8/lets_move/sources/lets_move.move new file mode 100644 index 000000000..90a9ce252 --- /dev/null +++ b/mover/djendjcn/code/task8/lets_move/sources/lets_move.move @@ -0,0 +1,86 @@ +module lets_move::lets_move { + use std::ascii::{String, string}; + use std::hash; + use sui::event; + use sui::bcs; + use sui::random; + use sui::random::Random; + use sui::transfer::share_object; + + const EPROOF: u64 = 0; + + public struct Flag has copy, drop { + sender: address, + flag: bool, + ture_num: u64, + github_id: String + } + + public struct Challenge has key { + id: UID, + str: String, + difficulity: u64, + ture_num: u64 + } + + fun init(ctx: &mut TxContext) { + let flag_str = Challenge { + id: object::new(ctx), + str: string(b"LetsMoveCTF"), + difficulity: 3, + ture_num: 0, + }; + share_object(flag_str); + } + + + entry fun get_flag( + proof: vector, + github_id: String, + challenge: &mut Challenge, + rand: &Random, + ctx: &mut TxContext + ) { + let mut full_proof: vector = vector::empty(); + vector::append(&mut full_proof, proof); + vector::append(&mut full_proof, tx_context::sender(ctx).to_bytes()); + vector::append(&mut full_proof, bcs::to_bytes(challenge)); + + let hash: vector = hash::sha3_256(full_proof); + + let mut prefix_sum: u32 = 0; + let mut i: u64 = 0; + while (i < challenge.difficulity) { + prefix_sum = prefix_sum + (*vector::borrow(&hash, i) as u32); + i = i + 1; + }; + + assert!(prefix_sum == 0, EPROOF); + + challenge.str = getRandomString(rand, ctx); + challenge.ture_num = challenge.ture_num + 1; + + event::emit(Flag { + sender: tx_context::sender(ctx), + flag: true, + ture_num: challenge.ture_num, + github_id + }); + } + + + fun getRandomString(rand: &Random, ctx: &mut TxContext): String { + let mut gen = random::new_generator(rand, ctx); + + let mut str_len = random::generate_u8_in_range(&mut gen, 4, 30); + + let mut rand: vector = b""; + while (str_len != 0) { + let rand_num = random::generate_u8_in_range(&mut gen, 34, 126); + vector::push_back(&mut rand, rand_num); + str_len = str_len - 1; + }; + + string(rand) + } +} diff --git a/mover/djendjcn/code/task8/lets_move/tests/lets_move_tests.move b/mover/djendjcn/code/task8/lets_move/tests/lets_move_tests.move new file mode 100644 index 000000000..7cfc393f9 --- /dev/null +++ b/mover/djendjcn/code/task8/lets_move/tests/lets_move_tests.move @@ -0,0 +1,19 @@ +/* +#[test_only] +module lets_move::lets_move_tests { + // uncomment this line to import the module + // use lets_move::lets_move; + + const ENotImplemented: u64 = 0; + + #[test] + fun test_lets_move() { + // pass + } + + #[test, expected_failure(abort_code = ::lets_move::lets_move_tests::ENotImplemented)] + fun test_lets_move_fail() { + abort ENotImplemented + } +} +*/ \ No newline at end of file diff --git a/mover/djendjcn/img/3.png b/mover/djendjcn/img/3.png new file mode 100644 index 000000000..7805758f0 Binary files /dev/null and b/mover/djendjcn/img/3.png differ diff --git a/mover/djendjcn/readme.md b/mover/djendjcn/readme.md index 60515d880..91e3a9234 100644 --- a/mover/djendjcn/readme.md +++ b/mover/djendjcn/readme.md @@ -26,10 +26,10 @@ - [] `Faucet Coin` address2 mint hash: ## 03 move NFT -- [] nft package id : -- [] nft object id : -- [] 转账 nft hash: -- [] scan上的NFT截图:![Scan截图](./images/你的图片地址) +- [] nft package id : 0x4a01e79477622269cd815af0093a442111fac8322c61515c61e14f1c3b4b3964 +- [] nft object id : 0xde3b558a2e26c2d72f544e354e32b180aa35dc329f0e351ff78d86a6908fc5d7 +- [] 转账 nft hash: 3cTPXXNWCu1Yo91wNv9PvYrAwH94oztecVJ5KSkoY2Ud +- [] scan上的NFT截图:![Scan截图](./img/3.png) ## 04 Move Game - [] game package id :