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

已完成Task1 #1602

Merged
merged 10 commits into from
Oct 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
40 changes: 40 additions & 0 deletions mover/DYJJ/code/task1/hello_move/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "DC24100B500088544405AC31A41101CCED2A8F27DD593AA63ACCE809282B414A"
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.35.0"
edition = "2024.beta"
flavor = "sui"

[env]

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0x26bc718fb0cfd4897b7d7ca321814eca33215afc54ddffed7ebe1c981bf6f918"
latest-published-id = "0x26bc718fb0cfd4897b7d7ca321814eca33215afc54ddffed7ebe1c981bf6f918"
published-version = "1"

[env.ed25519]
chain-id = "4c78adac"
original-published-id = "0x4bf0828d07971f5419cf94580034a1db089d2d1a9adb2194c084fbcbc5f68f6a"
latest-published-id = "0x4bf0828d07971f5419cf94580034a1db089d2d1a9adb2194c084fbcbc5f68f6a"
published-version = "1"
36 changes: 36 additions & 0 deletions mover/DYJJ/code/task1/hello_move/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "hello_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]
hello_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"
43 changes: 43 additions & 0 deletions mover/DYJJ/code/task1/hello_move/sources/hello_move.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module 0x0::hello_move {
use std::string;
use sui::object::{UID, Self as Object};
use sui::transfer;
use sui::tx_context::{Self as TxContext, sender};

// 定义 HelloObj 结构体,包含 ID、消息和 GitHub ID
public struct HelloObj has key, store {
id: UID,
message: string::String,
github_id: string::String,
}

// 创建新的 HelloObj 对象并进行转移
public fun create_hello_object(ctx: &mut TxContext) {
let id = Object::new(ctx);
let hello_message = string::utf8(b"Hello DYJJ!");
let github_id = string::utf8(b"DYJJ");

let new_object = HelloObj {
id,
message: hello_message,
github_id,
};

transfer::public_transfer(new_object, sender(ctx));
}

// 修改 HelloObj 的消息
public fun update_message(obj: &mut HelloObj, new_message: string::String) {
obj.message = new_message;
}

// 获取 HelloObj 的消息
public fun get_message(obj: &HelloObj): string::String {
obj.message
}

// 获取 HelloObj 的 GitHub ID
public fun get_github_id(obj: &HelloObj): string::String {
obj.github_id
}
}
47 changes: 47 additions & 0 deletions mover/DYJJ/code/task1/hello_move/test/hello_move_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// #[test_only]
module 0x0::hello_move_tests {
use std::assert;
use sui::object::{UID};
use sui::tx_context::{TxContext};
use 0x0::hello_move::{HelloObj, create_hello_object, update_message, get_message, get_github_id};

const E_NOT_IMPLEMENTED: u64 = 0;

#[test]
public fun test_create_hello_object() {
let mut ctx = TxContext::new(/* 添加所需的初始化参数 */);

// 创建 HelloObj
create_hello_object(&mut ctx);

// 获取转移的对象
let object = ctx.get_transferred_object::<HelloObj>();
assert(object.is_some(), 1);

let hello_obj = object.unwrap();
assert(hello_obj.id != UID::zero(), 2);
assert(get_message(&hello_obj) == string::utf8(b"Hello DYJJ!"), 3);
assert(get_github_id(&hello_obj) == string::utf8(b"DYJJ"), 4);
}

#[test]
public fun test_update_message() {
let mut ctx = TxContext::new(/* 添加所需的初始化参数 */);

// 创建 HelloObj
create_hello_object(&mut ctx);
let object = ctx.get_transferred_object::<HelloObj>().unwrap();

// 更新消息
let new_message = string::utf8(b"Updated Message");
update_message(&mut object, new_message);

// 验证消息更新
assert(get_message(&object) == new_message, 5);
}

#[test, expected_failure(abort_code = E_NOT_IMPLEMENTED)]
public fun test_update_message_fail() {
abort E_NOT_IMPLEMENTED;
}
}
Binary file added mover/DYJJ/images/task1/Task1-suiscan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mover/DYJJ/images/task1/suiwallet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added mover/DYJJ/notes/readme.md
Empty file.
54 changes: 54 additions & 0 deletions mover/DYJJ/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## 基本信息
- Sui钱包地址: `0xeeb1048598abe3f587fd3fcc7cd247391458060c67e2230130ad0a759543622d`
> 首次参与需要完成第一个任务注册好钱包地址才被合并,并且后续学习奖励会打入这个地址
- github: `DYJJ`

## 个人简介
- 工作经验: 1年
- 技术栈: `react`
> 重要提示 请认真写自己的简介
- 多年web2开发经验,对Move特别感兴趣,想通过Move入门区块链
- 联系方式: wechat: `Dyj1242958255`

## 任务

## 01 hello move
- [] Sui cli version: sui 1.35.0-40d9ec7ecd5d
- [] Sui钱包截图: ![Sui钱包截图](./images/suiwallet.png)
- [] package id: 0xc9b4e1a5845d2074035bc844fb20c49d937955456f3148e4273dcef356f4fddd
- [] package id 在 scan上的查看截图:![Scan截图](./images/Task1-suiscan.png)

## 02 move coin
- [] My Coin package id :
- [] Faucet package id :
- [] 转账 `My Coin` hash:
- [] `Faucet Coin` address1 mint hash:
- [] `Faucet Coin` address2 mint hash:

## 03 move NFT
- [] nft package id :
- [] nft object id :
- [] 转账 nft hash:
- [] scan上的NFT截图:![Scan截图](./images/你的图片地址)

## 04 Move Game
- [] game package id :
- [] deposit Coin hash:
- [] withdraw `Coin` hash:
- [] play game hash:

## 05 Move Swap
- [] swap package id :
- [] call swap CoinA-> CoinB hash :
- [] call swap CoinB-> CoinA hash :

## 06 Dapp-kit SDK PTB
- [] save hash :

## 07 Move CTF Check In
- [] CLI call 截图 : ![截图](./images/你的图片地址)
- [] flag hash :

## 08 Move CTF Lets Move
- [] proof :
- [] flag hash :