diff --git a/mover/sleepingF0x/code/task2/Move.lock b/mover/sleepingF0x/code/task2/Move.lock new file mode 100644 index 000000000..3c84429ae --- /dev/null +++ b/mover/sleepingF0x/code/task2/Move.lock @@ -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" diff --git a/mover/sleepingF0x/code/task2/Move.toml b/mover/sleepingF0x/code/task2/Move.toml new file mode 100644 index 000000000..bc41e7189 --- /dev/null +++ b/mover/sleepingF0x/code/task2/Move.toml @@ -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] diff --git a/mover/sleepingF0x/code/task2/sources/faucet.move b/mover/sleepingF0x/code/task2/sources/faucet.move new file mode 100644 index 000000000..02033004d --- /dev/null +++ b/mover/sleepingF0x/code/task2/sources/faucet.move @@ -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 + } + + /// Create a new faucet + public entry fun create_faucet( + treasury_cap: TreasuryCap, + 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)); + } +} \ No newline at end of file diff --git a/mover/sleepingF0x/code/task2/sources/mycoin.move b/mover/sleepingF0x/code/task2/sources/mycoin.move new file mode 100644 index 000000000..92f989052 --- /dev/null +++ b/mover/sleepingF0x/code/task2/sources/mycoin.move @@ -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( + 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); + } +} \ No newline at end of file diff --git a/mover/sleepingF0x/code/task2/tests/task2_tests.move b/mover/sleepingF0x/code/task2/tests/task2_tests.move new file mode 100644 index 000000000..81e8c886d --- /dev/null +++ b/mover/sleepingF0x/code/task2/tests/task2_tests.move @@ -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 + } +} +*/ diff --git a/mover/sleepingF0x/readme.md b/mover/sleepingF0x/readme.md index 55dec3693..39bb1e77f 100644 --- a/mover/sleepingF0x/readme.md +++ b/mover/sleepingF0x/readme.md @@ -11,17 +11,17 @@ ## 任务 ## 01 hello move -- [] Sui cli version: sui 1.37.1-7839b9501066 -- [] Sui钱包截图: ![Sui钱包截图](./images/wallet-address.png) -- [] package id: 0x6a581c4aa11d136cb79a5cc7aeedff1190e384fdd72a4e77a6a64556b564ef58 -- [] package id 在 scan上的查看截图:![Scan截图](./images/package-id.png) +- [x] Sui cli version: sui 1.37.1-7839b9501066 +- [x] Sui钱包截图: ![Sui钱包截图](./images/wallet-address.png) +- [x] package id: 0x6a581c4aa11d136cb79a5cc7aeedff1190e384fdd72a4e77a6a64556b564ef58 +- [x] package id 在 scan上的查看截图:![Scan截图](./images/package-id.png) ## 02 move coin -- [] My Coin package id : -- [] Faucet package id : -- [] 转账 `My Coin` hash: -- [] `Faucet Coin` address1 mint hash: -- [] `Faucet Coin` address2 mint hash: +- [x] My Coin package id : 0xfc70c94b6be5bfba42eace8b8d7f77b0aa86794e7ad0254326a43fdbdc8c4e70 +- [x] Faucet package id : 0xfc70c94b6be5bfba42eace8b8d7f77b0aa86794e7ad0254326a43fdbdc8c4e70 +- [x] 转账 `My Coin` hash: 57AKPvgysvDgiK6SrBFhNB5zvPqLL2cP8Y3vM8KG7Eoe +- [x] `Faucet Coin` address1 mint hash: 82ixufmGLqHZtjLjqbRB5qxqBFHi3yMyHQS2DZD6N1Qm +- [x] `Faucet Coin` address2 mint hash: 853f6jY7bYgW12MvS9EtziovvQbsUbAdGMSUAjJ3uYwi ## 03 move NFT - [] nft package id :