Skip to content

Commit

Permalink
Merge pull request #1915 from looikaizhi/main
Browse files Browse the repository at this point in the history
task2&3
  • Loading branch information
Sifotd authored Nov 18, 2024
2 parents caaf6c2 + f8b0d0c commit 5554dec
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 9 deletions.
40 changes: 40 additions & 0 deletions mover/looikaizhi/code/task2/generate_coin/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 = "A236805D79A413A3B07C3DCC6F251FE22E504BD8453FE8F1D79388B523090A81"
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.testnet]
chain-id = "4c78adac"
original-published-id = "0x798d058dd7a4ad2668f579bae7ae99729cf8c800c3de8a29d446fc683197f500"
latest-published-id = "0x798d058dd7a4ad2668f579bae7ae99729cf8c800c3de8a29d446fc683197f500"
published-version = "1"

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

39 changes: 39 additions & 0 deletions mover/looikaizhi/code/task2/generate_coin/sources/faucet_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module generate_coin::faucet_coin{
use sui::coin::{Self, TreasuryCap};
use sui::tx_context::TxContext;

public struct FAUCET_COIN has drop{}

public struct TreasuryCaoHolder has key, store{
id: UID,
treasury_cap: TreasuryCap<FAUCET_COIN>,
}

// otw = One-time witness,确保只能在init初始化调用一次,同时1结构体只有drop能力
fun init(otw:FAUCET_COIN, ctx: &mut TxContext){
let (treasury_cap, metadata) = coin::create_currency(
otw,
6,
b"looikaizhi_Faucet",
b"LKZF",
b"Who can let me become a memecoin!!(This is faucet)",
option::none(),
ctx
);
transfer::public_freeze_object(metadata);

let treasury_cap_holder = TreasuryCaoHolder{
id: object::new(ctx),
treasury_cap,
};
transfer::share_object(treasury_cap_holder);

}

public entry fun mint(treasury: &mut TreasuryCaoHolder, ctx: &mut TxContext){
let sender = tx_context::sender(ctx);
let treasury_cap = &mut treasury.treasury_cap;
let coin = coin::mint(treasury_cap, 10, ctx); // mint代币
transfer::public_transfer(coin, sender); // 转移至指定地址
}
}
49 changes: 49 additions & 0 deletions mover/looikaizhi/code/task2/generate_coin/sources/my_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module generate_coin::my_coin {
use sui::coin::{Self, TreasuryCap};
use sui::tx_context::TxContext;

public struct MY_COIN has drop{}

public struct TreasuryCaoHolder has key, store{
id: UID,
treasury_cap: TreasuryCap<MY_COIN>,
}

const Minter:address = @0x7b8e0864967427679b4e129f79dc332a885c6087ec9e187b53451a9006ee15f2;
const MAX_SUPPLY: u64 = 1_000_000_000;


fun init(otw: MY_COIN, ctx: &mut TxContext){
let (treasury_cap, metadata) = coin::create_currency(
otw,
6,
b"looikaizhi",
b"LKZ",
b"Who can let me become a memecoin!!",
option::none(),
ctx
);

transfer::public_freeze_object(metadata); // 冻结 metadata,以确保其内容不可更改

let treasury_cap_holder = TreasuryCaoHolder{
id: object::new(ctx),
treasury_cap,
};
transfer::public_transfer(treasury_cap_holder, tx_context::sender(ctx)); //将 TreasuryCap 赋予Minter地址

}

public entry fun mint(treasury: &mut TreasuryCaoHolder, minter: address, amount: u64, ctx: &mut TxContext){
assert!(minter == Minter, 0); // 确保是指定地址

let treasury_cap = &mut treasury.treasury_cap;
let current_supply:u64 = coin::total_supply<MY_COIN>(treasury_cap); // 当前代币的总量
assert!((current_supply + amount) <= MAX_SUPPLY, 0); // 确保不会超出最大供应量

let coin = coin::mint(treasury_cap, amount, ctx); // mint代币
transfer::public_transfer(coin, minter); // 转移至指定地址
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module generate_coin::generate_coin_tests;
// uncomment this line to import the module
// use generate_coin::generate_coin;
const ENotImplemented: u64 = 0;
#[test]
fun test_generate_coin() {
// pass
}
#[test, expected_failure(abort_code = ::generate_coin::generate_coin_tests::ENotImplemented)]
fun test_generate_coin_fail() {
abort ENotImplemented
}
*/
40 changes: 40 additions & 0 deletions mover/looikaizhi/code/task3/generate_NFT/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 = "DC3595091D0FF8B4EA079E2AC5459C03D25A297D44F2480119C7700E4FB53CA0"
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.testnet]
chain-id = "4c78adac"
original-published-id = "0x8cdbb3bd9c005ed5d59eb1cbc1da523d30aea54a214658dd3785d83e5bcc86a2"
latest-published-id = "0x8cdbb3bd9c005ed5d59eb1cbc1da523d30aea54a214658dd3785d83e5bcc86a2"
published-version = "1"

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

55 changes: 55 additions & 0 deletions mover/looikaizhi/code/task3/generate_NFT/sources/nft.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module generate_nft::nft{
use std::string::{utf8, String};
use sui::package;
use sui::display;
use sui::transfer;

public struct MyNFT has key, store{
id: UID,
name: String
}

public struct NFT has drop{}

fun init(otw: NFT, ctx: &mut TxContext){
let keys = vector[
utf8(b"name"),
utf8(b"link"),
utf8(b"image_url"),
utf8(b"description"),
utf8(b"project_url"),
utf8(b"creator"),
];

let values = vector[
utf8(b"{name}"),
utf8(b"https://sui-heroes.io/hero/{id}"),
utf8(b"https://pbs.twimg.com/profile_images/1809913909513699328/6IF8so7d_400x400.jpg"),
utf8(b"A Meme NFT of the Sui ecosystem!"),
utf8(b"https://docs.sui.io/standards/display"),
utf8(b"looikaizhi"),
];

let publisher = package::claim(otw, ctx);

let mut display = display::new_with_fields<MyNFT>(
&publisher, keys, values, ctx
);

display.update_version();

transfer::public_transfer(publisher, ctx.sender());
transfer::public_transfer(display, ctx.sender());
}

public entry fun mint(name: String, minter:address, ctx: &mut TxContext){
let nft = MyNFT{
id: object::new(ctx),
name
};

transfer::public_transfer(nft, minter);
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module generate_nft::generate_nft_tests;
// uncomment this line to import the module
// use generate_nft::generate_nft;
const ENotImplemented: u64 = 0;
#[test]
fun test_generate_nft() {
// pass
}
#[test, expected_failure(abort_code = ::generate_nft::generate_nft_tests::ENotImplemented)]
fun test_generate_nft_fail() {
abort ENotImplemented
}
*/
Binary file added mover/looikaizhi/images/NFTScreeenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions mover/looikaizhi/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
- [x] package id 在 scan上的查看截图:![Scan截图](./images/SuiScanScreenshot.png)

## 02 move coin
- [] My Coin package id :
- [] Faucet package id :
- [] 转账 `My Coin` hash:
- [] `Faucet Coin` address1 mint hash:
- [] `Faucet Coin` address2 mint hash:
- [x] My Coin package id :`0x8865d5e7cedd69aa766fb758b2436b54439546e6e6956050e2c146dc228738ff`
- [x] Faucet package id : `0x8865d5e7cedd69aa766fb758b2436b54439546e6e6956050e2c146dc228738ff`
- [x] 转账 `My Coin` hash: `D5ZUpJuwDsqfHTLvobQGk7fXkn5EpK1FRTZVAZsNrb7K`
- [x] `Faucet Coin` address1 mint hash: `CDDRtDmFi7VCBdAm8zratdqtyMEVanDkBkuFefjPxKss`
- [x] `Faucet Coin` address2 mint hash: `DC2LTw5eyyFDL6LABuoSYBnJTgKRgiJbY2Udw3YMvnLk`

## 03 move NFT
- [] nft package id :
- [] nft object id :
- [] 转账 nft hash:
- [] scan上的NFT截图:![Scan截图](./images/你的图片地址)
- [x] nft package id : `0xd1f718046bdc4071742938fb13b2976eec402bd793db9aaf0ea6c0e2221637fe`
- [x] nft object id : `0x9cc8f7c63407ae66b63b7c0cdfa3ce35dfd785030a5d9208bf8b601032125cf0`
- [x] 转账 nft hash: `9wYjDBRCofpAsgmsqp9Uc8AWM8wsRGeWHUJEJ3eshYX5`
- [x] scan上的NFT截图:![Scan截图](./images/NFTScreeenshot.png)

## 04 Move Game
- [] game package id :
Expand Down

0 comments on commit 5554dec

Please sign in to comment.