-
Notifications
You must be signed in to change notification settings - Fork 899
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 #1925 from supernovaYe/main
完成task2
- Loading branch information
Showing
9 changed files
with
273 additions
and
5 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,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" |
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 @@ | ||
[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
39
mover/supernovaYe/code/task2/faucetcoin/sources/faucetcoin.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,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); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
mover/supernovaYe/code/task2/faucetcoin/tests/faucetcoin_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 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 | ||
} | ||
*/ |
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,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" |
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 @@ | ||
[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" | ||
|
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,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
18
mover/supernovaYe/code/task2/mycoin/tests/mycoin_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 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 | ||
} | ||
*/ |
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