-
Notifications
You must be signed in to change notification settings - Fork 898
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 #1932 from Jmagicc/main
feat: task2 by share and private object;
- Loading branch information
Showing
3 changed files
with
85 additions
and
11 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,37 @@ | ||
module jmagicc_coin::jmagicc_coin { | ||
use sui::coin::{Self}; | ||
use sui::url::{Url,Self}; | ||
|
||
public struct JMAGICC_COIN has drop {} | ||
|
||
|
||
fun init(witness: JMAGICC_COIN, ctx: &mut TxContext) { | ||
let (treasury, metadata) = coin::create_currency( | ||
witness, | ||
9, // decimals | ||
b"JMAGICC", // symbol | ||
b"Jmagicc Coin", // name | ||
b"Jmagicc Coin", // description | ||
option::some<Url>(url::new_unsafe_from_bytes(b"https://avatars.githubusercontent.com/u/58356228")), // icon url | ||
ctx | ||
); | ||
|
||
// transfer the `TreasuryCap` to the sender, so they can mint and burn | ||
transfer::public_transfer(treasury, tx_context::sender(ctx)); | ||
|
||
// metadata is typically frozen after creation | ||
transfer::public_freeze_object(metadata); | ||
} | ||
|
||
|
||
public entry fun mint( | ||
treasury_cap: &mut coin::TreasuryCap<JMAGICC_COIN>, amount: u64, recipient: address, ctx: &mut TxContext | ||
) { | ||
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx); | ||
} | ||
|
||
|
||
public entry fun burn(treasury_cap: &mut coin::TreasuryCap<JMAGICC_COIN>, target: coin::Coin<JMAGICC_COIN>) { | ||
coin::burn(treasury_cap, target); | ||
} | ||
} |
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 jmagicc_faucet_coin::jmagicc_faucet_coin { | ||
use sui::coin::{Self}; | ||
use sui::url::{Url,Self}; | ||
|
||
public struct JMAGICC_FAUCET_COIN has drop {} | ||
|
||
|
||
fun init(witness: JMAGICC_FAUCET_COIN, ctx: &mut TxContext) { | ||
let (treasury_cap, metadata) = coin::create_currency( | ||
witness, | ||
9, // decimals | ||
b"JMAGICC FAUCET", // symbol | ||
b"Jmagicc Faucet Coin", // name | ||
b"Jmagicc Faucet Coin", // description | ||
option::some<Url>(url::new_unsafe_from_bytes(b"https://avatars.githubusercontent.com/u/58356228")), // icon url | ||
ctx | ||
); | ||
|
||
transfer::public_freeze_object(metadata); | ||
|
||
transfer::public_share_object(treasury_cap) | ||
} | ||
|
||
|
||
public entry fun mint( | ||
treasury_cap: &mut coin::TreasuryCap<JMAGICC_FAUCET_COIN>, amount: u64, recipient: address, ctx: &mut TxContext | ||
) { | ||
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx); | ||
} | ||
|
||
|
||
public entry fun burn(treasury_cap: &mut coin::TreasuryCap<JMAGICC_FAUCET_COIN>, target: coin::Coin<JMAGICC_FAUCET_COIN>) { | ||
coin::burn(treasury_cap, target); | ||
} | ||
} | ||
|
||
|
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