-
Notifications
You must be signed in to change notification settings - Fork 896
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 #2052 from zhbbll/main
新增参加第三周和第四周课程学习每周答疑截图+task5
- Loading branch information
Showing
18 changed files
with
487 additions
and
7 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,20 @@ | ||
test | ||
zhbbll_coin | ||
package: 0x64edf6d07750a214174a1ed3df3c870cfbffebe53738aed5ecdc29e398c533ec | ||
treasure: 0x24cd09344552130b39806e89e76b4ad8b763461b899e771e83b4c4e6e4471695 | ||
coin: 0x0d93177a42e8daa5906c2018ab2d80fb04eb1e9af4ce9376f3664d8e419366d5 | ||
|
||
zhbbll_faucet_coin: | ||
package: 0x7dcbd41518b9ae5e771bf523616ec8834b0e1985cbbfa6323ba7a79a50c14f6f | ||
treasure: 0xc01a5bff64fb9929e56bf51ac96c51fb985c55cff69d8c64c8047008b6b64ca9 | ||
coin: 0x45288747398a67ee2aa26828431bcc1d1cc8fbc45064a8996493d4678403e636 | ||
|
||
swap | ||
package: 0x2ebee5b412450c2cc5658baa06f4c42a059f0f7e50d5ca2566def33eb7f47426 | ||
bank: 0x3db70535ee134c6f692f96ffeaa608cc97a7c2a582c4cb2bf028eaff1ed0435b | ||
adminCap: 0x024fe62e956a0d2ff83f08d99b383f9974b56da7f62d1088d068b47df5bcea7e | ||
|
||
main | ||
package: 0x302c31c249ba3c812342f5f72136e5708b390b739ff93d7ad3bf7814c2c3202b | ||
bank: 0x1d54c427ad50223ce2fd074c8894e50c136f27e7a90e0bee80d24894c96cef01 | ||
admincap: 0xa7c872e6bda45404253ba982bd5e21680b71ac0cb809044db94bc33bf1f8fed5 |
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,34 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 2 | ||
manifest_digest = "595254CBB9A72AD3D48CC9FCE491F0106E5230A719423568EA6632F23CA64A31" | ||
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" | ||
dependencies = [ | ||
{ name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "MoveStdlib" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates\\sui-framework\\packages\\move-stdlib" } | ||
|
||
[[move.package]] | ||
name = "Sui" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ name = "MoveStdlib" }, | ||
] | ||
|
||
[move.toolchain-version] | ||
compiler-version = "1.34.0" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0x7e15b359c7fb72be1f6467c9c3db1f216b6e5b72eb7b4a259ff896ad4fcf508f" | ||
latest-published-id = "0x7e15b359c7fb72be1f6467c9c3db1f216b6e5b72eb7b4a259ff896ad4fcf508f" | ||
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 = "zhbbll_coin" | ||
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://github.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] | ||
zhbbll_coin = "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" | ||
|
35 changes: 35 additions & 0 deletions
35
mover/zhbbll/code/task5/zhbbll_coin/sources/zhbbll_coin.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,35 @@ | ||
module zhbbll_coin::zhbbll_coin{ | ||
use sui::coin::{Self, Coin, TreasuryCap}; | ||
// create an OTW | ||
public struct ZHBBLL_COIN has drop {} | ||
|
||
fun init(witness: ZHBBLL_COIN, ctx: &mut TxContext){ | ||
let (treasury_cap, metadata) = coin::create_currency<ZHBBLL_COIN>( | ||
witness, | ||
9, | ||
b"ZHBBLL", | ||
b"ZHBBLL_COIN", | ||
b"ChainBabyCoin", | ||
option::none(), | ||
ctx | ||
); | ||
transfer::public_freeze_object(metadata); | ||
transfer::public_transfer(treasury_cap,tx_context::sender(ctx)); | ||
} | ||
// mint and transfer | ||
public entry fun mint( | ||
treasury_cap: &mut TreasuryCap<ZHBBLL_COIN>, | ||
amount: u64, | ||
recipient: address, | ||
ctx: &mut TxContext | ||
){ | ||
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx); | ||
} | ||
|
||
public fun burn( | ||
treasury_cap: &mut TreasuryCap<ZHBBLL_COIN>, | ||
coin: Coin<ZHBBLL_COIN> | ||
){ | ||
coin::burn(treasury_cap, coin); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
mover/zhbbll/code/task5/zhbbll_coin/tests/zhbbll_coin_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,19 @@ | ||
/* | ||
#[test_only] | ||
module zhbbll_coin::zhbbll_coin_tests { | ||
// uncomment this line to import the module | ||
// use zhbbll_coin::zhbbll_coin; | ||
const ENotImplemented: u64 = 0; | ||
#[test] | ||
fun test_zhbbll_coin() { | ||
// pass | ||
} | ||
#[test, expected_failure(abort_code = ::zhbbll_coin::zhbbll_coin_tests::ENotImplemented)] | ||
fun test_zhbbll_coin_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,34 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 2 | ||
manifest_digest = "1B240EFE1DF4B46347B0750B8D24AB4139C44ADDB7143ED7844C6644FE840620" | ||
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" | ||
dependencies = [ | ||
{ name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "MoveStdlib" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates\\sui-framework\\packages\\move-stdlib" } | ||
|
||
[[move.package]] | ||
name = "Sui" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ name = "MoveStdlib" }, | ||
] | ||
|
||
[move.toolchain-version] | ||
compiler-version = "1.34.0" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0xe7366828123241f6ec15bbd77b03a02bbe308ab9d95781c6bb82d3f66ea5e444" | ||
latest-published-id = "0xe7366828123241f6ec15bbd77b03a02bbe308ab9d95781c6bb82d3f66ea5e444" | ||
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 = "zhbbll_faucet_coin" | ||
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://github.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] | ||
zhbbll_faucet_coin = "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" | ||
|
36 changes: 36 additions & 0 deletions
36
mover/zhbbll/code/task5/zhbbll_faucet_coin/sources/zhbbll_faucet_coin.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,36 @@ | ||
module zhbbll_faucet_coin::zhbbll_faucet_coin{ | ||
use sui::coin::{Self, Coin, TreasuryCap}; | ||
// create an OTW | ||
public struct ZHBBLL_FAUCET_COIN has drop {} | ||
|
||
fun init(witness: ZHBBLL_FAUCET_COIN, ctx: &mut TxContext){ | ||
let (treasury_cap, metadata) = coin::create_currency<ZHBBLL_FAUCET_COIN>( | ||
witness, | ||
9, | ||
b"ZHBBLL_FAUCET", | ||
b"ZHBBLL_FAUCET_COIN", | ||
b"ChainBabyCoin", | ||
option::none(), | ||
ctx | ||
); | ||
transfer::public_freeze_object(metadata); | ||
// share object | ||
transfer::public_share_object(treasury_cap); | ||
} | ||
// mint and transfer | ||
public entry fun mint( | ||
treasury_cap: &mut TreasuryCap<ZHBBLL_FAUCET_COIN>, | ||
amount: u64, | ||
recipient: address, | ||
ctx: &mut TxContext | ||
){ | ||
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx); | ||
} | ||
|
||
public fun burn( | ||
treasury_cap: &mut TreasuryCap<ZHBBLL_FAUCET_COIN>, | ||
coin: Coin<ZHBBLL_FAUCET_COIN> | ||
){ | ||
coin::burn(treasury_cap, coin); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
mover/zhbbll/code/task5/zhbbll_faucet_coin/tests/zhbbll_faucet_coin_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,19 @@ | ||
/* | ||
#[test_only] | ||
module zhbbll_faucet_coin::zhbbll_faucet_coin_tests { | ||
// uncomment this line to import the module | ||
// use zhbbll_faucet_coin::zhbbll_faucet_coin; | ||
const ENotImplemented: u64 = 0; | ||
#[test] | ||
fun test_zhbbll_faucet_coin() { | ||
// pass | ||
} | ||
#[test, expected_failure(abort_code = ::zhbbll_faucet_coin::zhbbll_faucet_coin_tests::ENotImplemented)] | ||
fun test_zhbbll_faucet_coin_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,52 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 2 | ||
manifest_digest = "89342AB15DD46B039CD694B88BCB8939952D493E82F19EC3F5180709484A1936" | ||
deps_digest = "060AD7E57DFB13104F21BE5F5C3759D03F0553FC3229247D9A7A6B45F50D03A3" | ||
dependencies = [ | ||
{ name = "Sui" }, | ||
{ name = "zhbbll_coin" }, | ||
{ name = "zhbbll_faucet_coin" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "MoveStdlib" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates\\sui-framework\\packages\\move-stdlib" } | ||
|
||
[[move.package]] | ||
name = "Sui" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ name = "MoveStdlib" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "zhbbll_coin" | ||
source = { local = "..\\zhbbll_coin" } | ||
|
||
dependencies = [ | ||
{ name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "zhbbll_faucet_coin" | ||
source = { local = "..\\zhbbll_faucet_coin" } | ||
|
||
dependencies = [ | ||
{ name = "Sui" }, | ||
] | ||
|
||
[move.toolchain-version] | ||
compiler-version = "1.34.0" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0x302c31c249ba3c812342f5f72136e5708b390b739ff93d7ad3bf7814c2c3202b" | ||
latest-published-id = "0x302c31c249ba3c812342f5f72136e5708b390b739ff93d7ad3bf7814c2c3202b" | ||
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,41 @@ | ||
[package] | ||
name = "zhbbll_swap" | ||
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://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" } | ||
zhbbll_coin={local="../zhbbll_coin"} | ||
zhbbll_faucet_coin={local="../zhbbll_faucet_coin"} | ||
|
||
# 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] | ||
zhbbll_swap = "0x0" | ||
pub = "0xeb2539e24af3cefa817a23feb648f7d7af3c19f9b51dfa4f9d07bc925bd67889" | ||
coin_trea_id = "0x474e5318854d59734152a04213bd5e502943d46ae371dc5a2bdd010c60bd98d0" | ||
|
||
# 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" | ||
|
Oops, something went wrong.