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 by Helen2022a #2062

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions mover/Helen2022a/code/task2/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 = "F8CFCF256E2F1BB7CD401C27799A09C40777C5C100F0DFA253E86DD7F0D4ED1B"
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.37.1"
edition = "2024.beta"
flavor = "sui"

[env]

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

26 changes: 26 additions & 0 deletions mover/Helen2022a/code/task2/faucet_coin/sources/faucet_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module faucet_coin::faucet_coin{
use std::option;
use sui::coin;
use sui::coin::{mint_and_transfer,TreasuryCap};
use sui::transfer::{public_share_object,public_freeze_object};
use sui::tx_context::TxContext;

//一次性见证者的名字是模块名的大写,如模块名为faucet_coin,则一次性见证者的名字则为FAUCET_COIN。一次性见证者只拥有drop能力
public struct FAUCET_COIN has drop{}

fun init (witness:FAUCET_COIN,ctx:&mut TxContext){
//treasury_cap,faucet_coin分别是指代币的铸币权和代币信息
//从左往右输入的参数依次是一次性见证者,代币的精度(例如微信最低是分),代币符号,代币名称,代币描述,代币图标的链接,特殊参数(不需要指定)
let (treasury_cap,faucet_coin) = coin::create_currency(witness,8,b"Helen2022a_faucet",b"Helen2022a_faucet_coin",b"First faucet coin created by Helen2022a", option::none(),ctx);

//使用冻结函数确保faucet_coin的信息不更改
public_freeze_object(faucet_coin);
//权限转移,faucet_coin的铸造权通过 public_share_object函数共享给每个人
public_share_object(treasury_cap);
}

public entry fun mint_and_send(treasury_cap:&mut TreasuryCap<FAUCET_COIN>,amount:u64,recipient:address,ctx:&mut TxContext){
//先铸造再发送
mint_and_transfer(treasury_cap,amount,recipient,ctx);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module faucet_coin::faucet_coin_tests;
// uncomment this line to import the module
// use faucet_coin::faucet_coin;
const ENotImplemented: u64 = 0;
#[test]
fun test_faucet_coin() {
// pass
}
#[test, expected_failure(abort_code = ::faucet_coin::faucet_coin_tests::ENotImplemented)]
fun test_faucet_coin_fail() {
abort ENotImplemented
}
*/
34 changes: 34 additions & 0 deletions mover/Helen2022a/code/task2/my_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 = "0A4652D38CF3C3FDB79EC6C1C98FCFF7B2E933E12B84A1DA267DB28F66AFECE3"
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.37.1"
edition = "2024.beta"
flavor = "sui"

[env]

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

25 changes: 25 additions & 0 deletions mover/Helen2022a/code/task2/my_coin/sources/my_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module my_coin::my_coin{
use std::option;
use sui::coin;
use sui::coin::{mint_and_transfer,TreasuryCap};
use sui::transfer::{public_transfer,public_freeze_object};
use sui::tx_context::TxContext;

//一次性见证者的名字是模块名的大写,如模块名为my_coin,则一次性见证者的名字则为MY_COIN。一次性见证者只拥有drop能力
public struct MY_COIN has drop{}

fun init (witness:MY_COIN,ctx:&mut TxContext){
//treasury_cap,my_coin分别是指代币的铸币权和代币信息
//从左往右输入的参数依次是一次性见证者,代币的精度(例如微信最低是分),代币符号,代币名称,代币描述,代币图标的链接,特殊参数(不需要指定)
let (treasury_cap,my_coin) = coin::create_currency(witness,8,b"Helen2022a",b"Helen2022a_coin",b"First coin created by Helen2022a", option::none(),ctx);
//使用冻结函数确保my_coin的信息不更改
public_freeze_object(my_coin);
//权限转移,my_coin的铸造权通过 public_share_object函数共享给每个人
public_transfer(treasury_cap, tx_context::sender(ctx));
}

public entry fun mint_and_send(treasury_cap:&mut TreasuryCap<MY_COIN>,amount:u64,recipient:address,ctx:&mut TxContext){
//先铸造再发送
mint_and_transfer(treasury_cap,amount,recipient,ctx);
}
}
18 changes: 18 additions & 0 deletions mover/Helen2022a/code/task2/my_coin/tests/my_coin_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module my_coin::my_coin_tests;
// uncomment this line to import the module
// use my_coin::my_coin;
const ENotImplemented: u64 = 0;
#[test]
fun test_my_coin() {
// pass
}
#[test, expected_failure(abort_code = ::my_coin::my_coin_tests::ENotImplemented)]
fun test_my_coin_fail() {
abort ENotImplemented
}
*/
16 changes: 11 additions & 5 deletions mover/Helen2022a/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
- [✓] package id 在 scan上的查看截图:![Scan截图](./images/suivision_code.png)

## 02 move coin
- [] My Coin package id :
- [] Faucet package id :
- [] 转账 `My Coin` hash:
- [] `Faucet Coin` address1 mint hash:
- [] `Faucet Coin` address2 mint hash:
- [] My Coin package id : 0x5c3a6b4a55686eb982ce65be5cb4b0d7935765c8be1dc1902de031efd945866e
- [] Faucet package id : 0x5d2aad9075f6d13961d0d08545eaf9e3194b466f9775bc45492e87395ba3059b
- [] 转账 `My Coin` hash: 7wJH7ELc7Wzw25jUzrdnMdeQkvw169kHrWSt5M5j2yNk
相关命令:
sui client call --package 0x5c3a6b4a55686eb982ce65be5cb4b0d7935765c8be1dc1902de031efd945866e --module my_coin --function mint_and_send --args 0x2e8acd5b90955411516907a58fe2f16317230449829bc71ac99d3c35215aa578 100000000 0x7b8e0864967427679b4e129f79dc332a885c6087ec9e187b53451a9006ee15f2
- [] `Faucet Coin` address1 mint hash: 8ByUxcx9r6SqiARUSSTUPThC2FEjFG6t5SVzxk5zE5yv
相关命令:
sui client call --package 0x5d2aad9075f6d13961d0d08545eaf9e3194b466f9775bc45492e87395ba3059b --module faucet_coin --function mint_and_send --args 0xe6c8a1222e5143b21a4e762d5441d575a27471efde1c320628c139991748c6d4 100000000 0xb81710e52a8fdc6fb6c7d103032d0dfc076752b35a6deac950e015011fabf772
- [] `Faucet Coin` address2 mint hash: 3nrvJwHZ8fV7XYZk1VxjjzLqprbAKCC5FD1U3RH8rfut
相关命令:
sui client call --package 0x5d2aad9075f6d13961d0d08545eaf9e3194b466f9775bc45492e87395ba3059b --module faucet_coin --function mint_and_send --args 0xe6c8a1222e5143b21a4e762d5441d575a27471efde1c320628c139991748c6d4 100000000 0x7b8e0864967427679b4e129f79dc332a885c6087ec9e187b53451a9006ee15f2

## 03 move NFT
- [] nft package id :
Expand Down