-
Notifications
You must be signed in to change notification settings - Fork 891
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 #1941 from YXZ252426/main
yxz252426的提交
- Loading branch information
Showing
5 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
mover/YXZ252426/code/task2/YXZ252426/sources/yxz252426.move
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,51 @@ | ||
/* | ||
/// Module: yxz252426 | ||
module yxz252426::yxz252426; | ||
*/ | ||
module yxz252426::yxz252426 { | ||
use sui::coin::{Self, Coin, TreasuryCap}; | ||
use sui::url::{Self, Url}; | ||
|
||
public struct YXZ252426 has drop {} | ||
|
||
fun init( | ||
witness: YXZ252426, | ||
ctx: &mut TxContext | ||
) { | ||
let (treasury_cap, metadata) = coin::create_currency<YXZ252426>( | ||
witness, | ||
9, | ||
b"YXZ", | ||
b"YXZ252426", | ||
b"YXZ Coin", | ||
option::some<Url>( | ||
url::new_unsafe_from_bytes( | ||
b"https://avatars.githubusercontent.com/u/76983474" | ||
) | ||
), | ||
ctx | ||
); | ||
transfer::public_freeze_object(metadata); | ||
transfer::public_transfer( | ||
treasury_cap, | ||
tx_context::sender(ctx) | ||
) | ||
} | ||
|
||
public entry fun mint( | ||
treasury_cap: &mut TreasuryCap<YXZ252426>, | ||
amount: u64, | ||
recipient: address, | ||
ctx: &mut TxContext | ||
) { | ||
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx); | ||
} | ||
|
||
public fun burn( | ||
treasury_cap: &mut TreasuryCap<YXZ252426>, | ||
coin: Coin<YXZ252426> | ||
) { | ||
coin::burn(treasury_cap, coin); | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
mover/YXZ252426/code/task2/YXZ252426/tests/yxz252426_tests.move
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,18 @@ | ||
/* | ||
#[test_only] | ||
module yxz252426::yxz252426_tests; | ||
// uncomment this line to import the module | ||
// use yxz252426::yxz252426; | ||
const ENotImplemented: u64 = 0; | ||
#[test] | ||
fun test_yxz252426() { | ||
// pass | ||
} | ||
#[test, expected_failure(abort_code = ::yxz252426::yxz252426_tests::ENotImplemented)] | ||
fun test_yxz252426_fail() { | ||
abort ENotImplemented | ||
} | ||
*/ |
50 changes: 50 additions & 0 deletions
50
mover/YXZ252426/code/task2/YXZ252426_faucet/sources/yxz252426_faucet.move
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,50 @@ | ||
/* | ||
/// Module: yxz252426_faucet | ||
module yxz252426_faucet::yxz252426_faucet; | ||
*/ | ||
module yxz252426_faucet::yxz252426_faucet { | ||
use sui::coin::{Self, Coin, TreasuryCap}; | ||
use sui::url::{Self, Url}; | ||
|
||
public struct YXZ252426_FAUCET has drop {} | ||
|
||
fun init( | ||
witness: YXZ252426_FAUCET, | ||
ctx: &mut TxContext | ||
) { | ||
let (treasury_cap, metadata) = coin::create_currency<YXZ252426_FAUCET>( | ||
witness, | ||
9, | ||
b"YXZ", | ||
b"YXZ252426_FAUCET", | ||
b"YXZ252426 Faucet Coin", | ||
option::some<Url>( | ||
url::new_unsafe_from_bytes( | ||
b"https://avatars.githubusercontent.com/u/76983474" | ||
) | ||
), | ||
ctx | ||
); | ||
transfer::public_freeze_object(metadata); | ||
transfer::public_share_object(treasury_cap) | ||
} | ||
|
||
public entry fun mint( | ||
treasury_cap: &mut TreasuryCap<YXZ252426_FAUCET>, | ||
amount: u64, | ||
recipient: address, | ||
ctx: &mut TxContext | ||
) { | ||
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx); | ||
} | ||
|
||
public fun burn( | ||
treasury_cap: &mut TreasuryCap<YXZ252426_FAUCET>, | ||
coin: Coin<YXZ252426_FAUCET> | ||
) { | ||
coin::burn(treasury_cap, coin); | ||
|
||
} | ||
} | ||
|
||
|
18 changes: 18 additions & 0 deletions
18
mover/YXZ252426/code/task2/YXZ252426_faucet/tests/yxz252426_faucet_tests.move
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,18 @@ | ||
/* | ||
#[test_only] | ||
module yxz252426_faucet::yxz252426_faucet_tests; | ||
// uncomment this line to import the module | ||
// use yxz252426_faucet::yxz252426_faucet; | ||
const ENotImplemented: u64 = 0; | ||
#[test] | ||
fun test_yxz252426_faucet() { | ||
// pass | ||
} | ||
#[test, expected_failure(abort_code = ::yxz252426_faucet::yxz252426_faucet_tests::ENotImplemented)] | ||
fun test_yxz252426_faucet_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