-
Notifications
You must be signed in to change notification settings - Fork 908
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1759 from sleepingF0x/sleepingF0x
完成task2
- Loading branch information
Showing
6 changed files
with
134 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters