Skip to content

Commit

Permalink
unlizhao完成task1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhao1 committed Dec 12, 2024
1 parent 15e3142 commit 1878cec
Show file tree
Hide file tree
Showing 29 changed files with 1,735 additions and 0 deletions.
34 changes: 34 additions & 0 deletions mover/unlizhao/code/task1/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 = "3001D37698DA5DA60FCDB6EC4763E31DC8621E1B5CC075C9AB8DEB3104BBAE1D"
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.38.2"
edition = "2024.beta"
flavor = "sui"

[env]

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0xef4313724094aa1b097cc648c11602b20f1e459851ecdebc51545e527f78a044"
latest-published-id = "0xef4313724094aa1b097cc648c11602b20f1e459851ecdebc51545e527f78a044"
published-version = "1"
47 changes: 47 additions & 0 deletions mover/unlizhao/code/task1/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Move.toml 是 Move 项目的配置文件,类似于 Rust 的 Cargo.toml

[package]
# 包名,用于标识这个 Move 项目
name = "task1"
# Move 编译器版本,使用 2024.beta 版本
# 如果要使用旧版 Move,可以设置 edition = "legacy"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# 项目许可证,例如 "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # 项目作者列表

# 依赖项配置
[dependencies]
# 导入 Sui 框架依赖
# git: 指定 Sui 框架的 GitHub 仓库地址
# subdir: 指定框架代码在仓库中的子目录
# rev: 指定使用的版本分支(这里使用 testnet 测试网络版本)
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }

# 远程依赖示例:使用 git 仓库作为依赖源
# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }

# 本地依赖示例:使用本地路径作为依赖源
# Local = { local = "../path/to" }

# 解决依赖冲突示例:强制使用特定版本
# Override = { local = "../conflicting/version", override = true }

# 命名地址配置
[addresses]
# 设置模块的发布地址
# 0x0 是占位符,部署时会被实际地址替换
task1 = "0x0"

# 命名地址可以在 Move 代码中通过 @name 访问
# 例如:标准库导出了 std = "0x1"
# alice = "0xA11CE"

# 测试环境依赖配置
[dev-dependencies]
# 仅在 --test 和 --dev 模式下使用的依赖
# Local = { local = "../path/to/dev-build" }

# 测试环境地址配置
[dev-addresses]
# 仅在 --test 和 --dev 模式下使用的命名地址
# alice = "0xB0B"
14 changes: 14 additions & 0 deletions mover/unlizhao/code/task1/note
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
d:/workdir/code/move/letsmove/mover/unlizhao/code/task1

让我们重新发布 task1.move 合约。首先构建项目:

Ran terminal command
d:/workdir/code/move/letsmove/mover/unlizhao/code/task1
> sui move build


构建成功,现在发布合约:

Ran terminal command
d:/workdir/code/move/letsmove/mover/unlizhao/code/task1
> sui client publish --gas-budget 100000000
27 changes: 27 additions & 0 deletions mover/unlizhao/code/task1/sources/task1.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 定义模块 task1::task1_hello
module task1::task1_hello {
// 导入需要使用的标准库和 Sui 框架
use std::string; // 用于处理字符串
use sui::object::{Self, UID}; // 用于创建和管理对象
use sui::transfer; // 用于转移对象所有权
use sui::tx_context::{Self, TxContext}; // 用于获取交易上下文

// 定义一个具有 key 和 store 能力的结构体
// key: 表示这个对象可以作为全局存储的键
// store: 表示这个对象可以被存储
public struct HelloObj has key, store {
id: UID, // 对象的唯一标识符
say: string::String // 存储问候消息的字符串
}

// 公共函数,用于创建新的 HelloObj 对象并转移给调用者
public fun mint(ctx: &mut TxContext) {
// 创建一个新的 HelloObj 实例
let object = HelloObj {
id: object::new(ctx), // 生成新的唯一标识符
say: string::utf8(b"Hello unlizhao!") // 设置问候消息
};
// 将创建的对象转移给交易发送者
transfer::public_transfer(object, tx_context::sender(ctx));
}
}
40 changes: 40 additions & 0 deletions mover/unlizhao/code/task2/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 = "727F9231DFA38FBC242FB6758B4A86DA5519A25C5953A62C6834005875817EA1"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

[[move.package]]
id = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates\\sui-framework\\packages\\move-stdlib" }

[[move.package]]
id = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[move.toolchain-version]
compiler-version = "1.38.2"
edition = "2024.beta"
flavor = "sui"

[env]

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

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

# 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]
task2 = "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"

Loading

0 comments on commit 1878cec

Please sign in to comment.