Skip to content

Commit

Permalink
finish task2
Browse files Browse the repository at this point in the history
  • Loading branch information
supernovaYe committed Nov 18, 2024
1 parent 625b10d commit ff1bfc2
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 5 deletions.
40 changes: 40 additions & 0 deletions mover/supernovaYe/code/task2/faucetcoin/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "631D71D64640D411A0A651627D182D827D415B67DE6F94B3C8A2311D1CC43A75"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

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

[[move.package]]
id = "Sui"
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[move.toolchain-version]
compiler-version = "1.37.1"
edition = "2024.beta"
flavor = "sui"

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x25f9b3ccc1cb677d5bd40a0375df3cca37fd333e1bc25bfbd1f3802986dd2638"
latest-published-id = "0x25f9b3ccc1cb677d5bd40a0375df3cca37fd333e1bc25bfbd1f3802986dd2638"
published-version = "1"

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0x4ceddf4c998593ca5b8d21f29b8d8770eb730617f0770beaf776c99c72177e04"
latest-published-id = "0x4ceddf4c998593ca5b8d21f29b8d8770eb730617f0770beaf776c99c72177e04"
published-version = "1"
37 changes: 37 additions & 0 deletions mover/supernovaYe/code/task2/faucetcoin/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "faucetcoin"
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]
faucetcoin = "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"

39 changes: 39 additions & 0 deletions mover/supernovaYe/code/task2/faucetcoin/sources/faucetcoin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
/// Module: faucetcoin
module faucetcoin::faucetcoin;
*/
module faucetcoin::faucetcoin {
use std::option;
use sui::coin::{Self, Coin, TreasuryCap};
use sui::transfer;
use sui::tx_context::{Self, TxContext};

public struct FAUCETCOIN has drop {}

/// Register the managed currency to acquire its `TreasuryCap`. Because
/// this is a module initializer, it ensures the currency only gets
/// registered once.
fun init(otw: FAUCETCOIN, ctx: &mut TxContext) {
// Get a treasury cap for the coin and give it to the transaction sender
let (treasury_cap, metadata) = coin::create_currency<FAUCETCOIN>(
otw,
2,
b"FAUCETCOIN",
b"FaucetCoin",
b"",
option::none(),
ctx);
transfer::public_freeze_object(metadata);
transfer::public_share_object(treasury_cap);
}

// mint new coins
public entry fun mint(treasury_cap: &mut TreasuryCap<FAUCETCOIN>, amount: u64, recipient: address, ctx: &mut TxContext) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}

// burn coins
public entry fun burn(treasury_cap: &mut TreasuryCap<FAUCETCOIN>, coin: Coin<FAUCETCOIN>) {
coin::burn(treasury_cap, coin);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module faucetcoin::faucetcoin_tests;
// uncomment this line to import the module
// use faucetcoin::faucetcoin;
const ENotImplemented: u64 = 0;
#[test]
fun test_faucetcoin() {
// pass
}
#[test, expected_failure(abort_code = ::faucetcoin::faucetcoin_tests::ENotImplemented)]
fun test_faucetcoin_fail() {
abort ENotImplemented
}
*/
40 changes: 40 additions & 0 deletions mover/supernovaYe/code/task2/mycoin/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "53D63BF37A5A75E12B16FA15616621B9469CA2B028AD484BE07CBC84DEE64DCE"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

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

[[move.package]]
id = "Sui"
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[move.toolchain-version]
compiler-version = "1.37.1"
edition = "2024.beta"
flavor = "sui"

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x4e428ffb725df4546e04b31630650a477b60b35bcd762411dd9bdccb819f4703"
latest-published-id = "0x4e428ffb725df4546e04b31630650a477b60b35bcd762411dd9bdccb819f4703"
published-version = "1"

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0x899bb237a3ac7909818216a753dbb4ff924573b1f7af8d7720d8026a7270fbcc"
latest-published-id = "0x899bb237a3ac7909818216a753dbb4ff924573b1f7af8d7720d8026a7270fbcc"
published-version = "1"
37 changes: 37 additions & 0 deletions mover/supernovaYe/code/task2/mycoin/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "mycoin"
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]
mycoin = "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"

39 changes: 39 additions & 0 deletions mover/supernovaYe/code/task2/mycoin/sources/mycoin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
/// Module: mycoin
module mycoin::mycoin;
*/
module mycoin::mycoin {
use std::option;
use sui::coin::{Self, Coin, TreasuryCap};
use sui::transfer;
use sui::tx_context::{Self, TxContext};

public struct MYCOIN has drop {}

/// Register the managed currency to acquire its `TreasuryCap`. Because
/// this is a module initializer, it ensures the currency only gets
/// registered once.
fun init(otw: MYCOIN, ctx: &mut TxContext) {
// Get a treasury cap for the coin and give it to the transaction sender
let (treasury_cap, metadata) = coin::create_currency<MYCOIN>(
otw,
2,
b"MYCOIN",
b"MyCoin",
b"",
option::none(),
ctx);
transfer::public_freeze_object(metadata);
transfer::public_transfer(treasury_cap, tx_context::sender(ctx))
}

// mint new coins
public entry fun mint(treasury_cap: &mut TreasuryCap<MYCOIN>, amount: u64, recipient: address, ctx: &mut TxContext) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}

// burn coins
public entry fun burn(treasury_cap: &mut TreasuryCap<MYCOIN>, coin: Coin<MYCOIN>) {
coin::burn(treasury_cap, coin);
}
}
18 changes: 18 additions & 0 deletions mover/supernovaYe/code/task2/mycoin/tests/mycoin_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module mycoin::mycoin_tests;
// uncomment this line to import the module
// use mycoin::mycoin;
const ENotImplemented: u64 = 0;
#[test]
fun test_mycoin() {
// pass
}
#[test, expected_failure(abort_code = ::mycoin::mycoin_tests::ENotImplemented)]
fun test_mycoin_fail() {
abort ENotImplemented
}
*/
10 changes: 5 additions & 5 deletions mover/supernovaYe/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
- [x] package id 在 scan上的查看截图:![Scan截图](./images/0x3662154617e9542cd2d82d48d8d07d81a1553b7360736ef8aa223dbfb068c924.png)

## 02 move coin
- [] My Coin package id :
- [] Faucet package id :
- [] 转账 `My Coin` hash:
- [] `Faucet Coin` address1 mint hash:
- [] `Faucet Coin` address2 mint hash:
- [] My Coin package id : 0x4e428ffb725df4546e04b31630650a477b60b35bcd762411dd9bdccb819f4703
- [] Faucet package id : 0x25f9b3ccc1cb677d5bd40a0375df3cca37fd333e1bc25bfbd1f3802986dd2638
- [] 转账 `My Coin` hash: GM4GGGSaYn8UatkB5etP51zJSTUdrEam7ScLRmKe7Rm8
- [] `Faucet Coin` address1 mint hash: 31x87KwgCfUKW6F4PPkFj5n13LE4d4pZ2uuxG6yYanqH
- [] `Faucet Coin` address2 mint hash: 4bQLLpjdgJy4tkmyidBYSm2Zihy4WWZhXej7EhNiLb1a

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

0 comments on commit ff1bfc2

Please sign in to comment.