Skip to content

Commit

Permalink
Merge pull request #1839 from Tornoto/main
Browse files Browse the repository at this point in the history
完成 task 1 2
  • Loading branch information
Sifotd authored Nov 14, 2024
2 parents dac7df1 + d85cbcd commit fa09c73
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 5 deletions.
37 changes: 37 additions & 0 deletions mover/Tornoto/code/task2/custom_coin/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "custom_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://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]
custom_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/Tornoto/code/task2/custom_coin/sources/faucet_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module custom_coin::faucet_coin;
use custom_coin::MY_COIN::MY_COIN;
use sui::coin::TreasuryCap;

// MY_COIN 的 decimal 是 6,每次给 1 个
const FAUCET_AMOUNT: u64 = 1_000_000;

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

public entry
fun create_faucet(treasury_cap: TreasuryCap<MY_COIN>, ctx: &mut TxContext) {
let faucet = Faucet {
id: object::new(ctx),
treasury_cap,
};
transfer::share_object(faucet);
}

public entry
fun request_coin(faucet: &mut Faucet, recipient: address, ctx: &mut TxContext) {
custom_coin::MY_COIN::mint(&mut faucet.treasury_cap, FAUCET_AMOUNT, recipient, ctx);
}
28 changes: 28 additions & 0 deletions mover/Tornoto/code/task2/custom_coin/sources/my_coin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// Module: custom_coin
module custom_coin::MY_COIN;
use sui::coin;
use sui::coin::TreasuryCap;

public struct MY_COIN has drop {}

fun init(witness: MY_COIN, ctx: &mut TxContext) {
let (treasury_cap, coin_metadata) = coin::create_currency(
witness,
6,
b"Fc",
b"fish_coin",
b"you fish, your fish",
option::none(),
ctx
);
transfer::public_transfer(treasury_cap, tx_context::sender(ctx));
transfer::public_freeze_object(coin_metadata);
}

public
fun mint(treasury_cap: &mut TreasuryCap<MY_COIN>,
amount: u64,
recipient: address,
ctx: &mut TxContext) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}
10 changes: 5 additions & 5 deletions mover/Tornoto/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

## 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 :0xfcae7534403e4e6c0899c1a85864af7a3016e1c55fa681e223a74f5d23ee2fbc
- [x] Faucet package id :0xfcae7534403e4e6c0899c1a85864af7a3016e1c55fa681e223a74f5d23ee2fbc
- [x] 转账 `My Coin` hash:2VTNQ2ZWsgsnQid5ks7DBEorkxJoaGBZFcdeoHRTgsX8
- [x] `Faucet Coin` address1 mint hash:841BygAzkEFTGyHAiWq1dLH8gCGYbCcqWhnQgduDwMBx
- [x] `Faucet Coin` address2 mint hash:4YJ3xjdBHwGUFNLqANU6A7JGS7HyThfftm7wxfrcZSBf

## 03 move NFT

Expand Down

0 comments on commit fa09c73

Please sign in to comment.