Skip to content

Commit

Permalink
Merge pull request #1759 from sleepingF0x/sleepingF0x
Browse files Browse the repository at this point in the history
完成task2
  • Loading branch information
uvd authored Dec 25, 2024
2 parents 3b94d2d + dda79a7 commit 0294111
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 9 deletions.
34 changes: 34 additions & 0 deletions mover/sleepingF0x/code/task2/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 = "BDE01E145CFCA056F1875839F7EECD3849D53C5ED2E569FEC2ED3B7D2FCF1752"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

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

[[move.package]]
id = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet", 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.mainnet]
chain-id = "35834a8a"
original-published-id = "0xfc70c94b6be5bfba42eace8b8d7f77b0aa86794e7ad0254326a43fdbdc8c4e70"
latest-published-id = "0xfc70c94b6be5bfba42eace8b8d7f77b0aa86794e7ad0254326a43fdbdc8c4e70"
published-version = "1"
13 changes: 13 additions & 0 deletions mover/sleepingF0x/code/task2/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "mycoin"
version = "0.0.1"

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

[addresses]
mycoin = "0x0"

[dev-dependencies]

[dev-addresses]
37 changes: 37 additions & 0 deletions mover/sleepingF0x/code/task2/sources/faucet.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module mycoin::faucet {
use sui::object::{Self, UID};
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use sui::coin::{Self, TreasuryCap};
use mycoin::mycoin::MYCOIN;

/// Amount of tokens that can be requested each time (10 tokens considering 9 decimals)
const FAUCET_AMOUNT: u64 = 10_000_000_000;

/// The Faucet resource
struct Faucet has key {
id: UID,
treasury_cap: TreasuryCap<MYCOIN>
}

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

/// Request tokens from the faucet
public entry fun request_coins(
faucet: &mut Faucet,
ctx: &mut TxContext
) {
let coins = coin::mint(&mut faucet.treasury_cap, FAUCET_AMOUNT, ctx);
transfer::public_transfer(coins, tx_context::sender(ctx));
}
}
22 changes: 22 additions & 0 deletions mover/sleepingF0x/code/task2/sources/mycoin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module mycoin::mycoin {
use std::option;
use sui::coin;
use sui::transfer;
use sui::tx_context::{Self, TxContext};

struct MYCOIN has drop {}

fun init(witness: MYCOIN, ctx: &mut TxContext) {
let (treasury_cap, metadata) = coin::create_currency<MYCOIN>(
witness,
9,
b"MYCOIN",
b"My Test Coin",
b"A test coin for faucet",
option::none(),
ctx
);
transfer::public_transfer(treasury_cap, tx_context::sender(ctx));
transfer::public_freeze_object(metadata);
}
}
19 changes: 19 additions & 0 deletions mover/sleepingF0x/code/task2/tests/task2_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
#[test_only]
module task2::task2_tests {
// uncomment this line to import the module
// use task2::task2;
const ENotImplemented: u64 = 0;
#[test]
fun test_task2() {
// pass
}
#[test, expected_failure(abort_code = ::task2::task2_tests::ENotImplemented)]
fun test_task2_fail() {
abort ENotImplemented
}
}
*/
18 changes: 9 additions & 9 deletions mover/sleepingF0x/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
## 任务

## 01 hello move
- [] Sui cli version: sui 1.37.1-7839b9501066
- [] Sui钱包截图: ![Sui钱包截图](./images/wallet-address.png)
- [] package id: 0x6a581c4aa11d136cb79a5cc7aeedff1190e384fdd72a4e77a6a64556b564ef58
- [] package id 在 scan上的查看截图:![Scan截图](./images/package-id.png)
- [x] Sui cli version: sui 1.37.1-7839b9501066
- [x] Sui钱包截图: ![Sui钱包截图](./images/wallet-address.png)
- [x] package id: 0x6a581c4aa11d136cb79a5cc7aeedff1190e384fdd72a4e77a6a64556b564ef58
- [x] package id 在 scan上的查看截图:![Scan截图](./images/package-id.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 : 0xfc70c94b6be5bfba42eace8b8d7f77b0aa86794e7ad0254326a43fdbdc8c4e70
- [x] Faucet package id : 0xfc70c94b6be5bfba42eace8b8d7f77b0aa86794e7ad0254326a43fdbdc8c4e70
- [x] 转账 `My Coin` hash: 57AKPvgysvDgiK6SrBFhNB5zvPqLL2cP8Y3vM8KG7Eoe
- [x] `Faucet Coin` address1 mint hash: 82ixufmGLqHZtjLjqbRB5qxqBFHi3yMyHQS2DZD6N1Qm
- [x] `Faucet Coin` address2 mint hash: 853f6jY7bYgW12MvS9EtziovvQbsUbAdGMSUAjJ3uYwi

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

0 comments on commit 0294111

Please sign in to comment.