-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
628 additions
and
12 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,34 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 2 | ||
manifest_digest = "E7A65BF39B740E195045E87B46B06936199C063AFE29D8948B9C6B9B853033A8" | ||
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.31.1" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0xbe658db5ea4e83171182e59c6bb6852f27b53fe346945d9e21e8b5e480ea09a3" | ||
latest-published-id = "0xbe658db5ea4e83171182e59c6bb6852f27b53fe346945d9e21e8b5e480ea09a3" | ||
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 = "task2" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
# license = "" # e.g., "MIT", "GPL", "Apache 2.0" | ||
# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] | ||
|
||
[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] | ||
task2 = "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,50 @@ | ||
/// Module: faucet_coin | ||
module task2::faucet_coin { | ||
use sui::coin::{Self, Coin, TreasuryCap}; | ||
use sui::balance; | ||
|
||
public struct FAUCET_COIN has drop {} | ||
|
||
public struct MySupply has key, store { | ||
id: UID, | ||
supply: balance::Supply<FAUCET_COIN> | ||
} | ||
|
||
|
||
#[allow(lint(share_owned))] | ||
fun init(witness: FAUCET_COIN, ctx: &mut TxContext) { | ||
let (treasury_cap, coin_metadata) = coin::create_currency( | ||
witness, | ||
6, | ||
b"Muen", | ||
b"MUSS", | ||
b"MuyeC s Coin", | ||
option::none(), | ||
ctx | ||
); | ||
|
||
sui::transfer::public_share_object(coin_metadata); | ||
|
||
let supply = coin::treasury_into_supply(treasury_cap); | ||
transfer::public_transfer(MySupply { | ||
id: object::new(ctx), | ||
supply | ||
}, ctx.sender()); | ||
} | ||
|
||
public entry fun mint(supply: &mut MySupply, value: u64, ctx: &mut TxContext) { | ||
let balance = balance::increase_supply(&mut supply.supply, value); | ||
let coin = coin::from_balance(balance, ctx); | ||
transfer::public_transfer(coin, ctx.sender()); | ||
} | ||
|
||
public fun burn(treasury_cap: &mut TreasuryCap<FAUCET_COIN>, coin: Coin<FAUCET_COIN>) { | ||
coin::burn(treasury_cap, coin); | ||
} | ||
|
||
#[test_only] | ||
public fun test_init(ctx: &mut tx_context::TxContext) { | ||
init(FAUCET_COIN{}, ctx); | ||
} | ||
} | ||
|
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 task2::my_coin { | ||
|
||
use sui::coin::{Self, Coin, TreasuryCap}; | ||
|
||
public struct MY_COIN has drop {} | ||
|
||
fun init(witness: MY_COIN, ctx: &mut TxContext) { | ||
let (treasury, metadata) = coin::create_currency( | ||
witness, | ||
6, | ||
b"Muen", | ||
b"MUSS", | ||
b"MuyeC s Coin", | ||
option::none(), | ||
ctx | ||
); | ||
|
||
transfer::public_freeze_object(metadata); | ||
|
||
transfer::public_transfer(treasury, ctx.sender()); | ||
} | ||
|
||
public fun mint( | ||
treasury_cap: &mut TreasuryCap<MY_COIN>, amount: u64, recipient: address, ctx: &mut TxContext | ||
) { | ||
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx) | ||
} | ||
|
||
public fun burn(treasury_cap: &mut TreasuryCap<MY_COIN>, coin: Coin<MY_COIN>) { | ||
coin::burn(treasury_cap, coin); | ||
} | ||
|
||
#[test_only] | ||
public fun test_init(ctx: &mut TxContext) { | ||
init(MY_COIN {}, ctx) | ||
} | ||
} |
Empty file.
Empty file.
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 = "DEDE53BD567ECEDC2009BE853A86F47F6BDC3F1F03A6B00FAED274F07E74A18B" | ||
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.31.1" | ||
edition = "2024.beta" | ||
flavor = "sui" | ||
|
||
[env] | ||
|
||
[env.mainnet] | ||
chain-id = "35834a8a" | ||
original-published-id = "0x7e37624b8f748025fb30d058ebc01309f80a53efc75067dbf9ef908be63b1ccc" | ||
latest-published-id = "0x7e37624b8f748025fb30d058ebc01309f80a53efc75067dbf9ef908be63b1ccc" | ||
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 = "task3" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
# license = "" # e.g., "MIT", "GPL", "Apache 2.0" | ||
# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] | ||
|
||
[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] | ||
task3 = "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,51 @@ | ||
/// Module: mynft | ||
module task3::mynft { | ||
use std::string::utf8; | ||
use sui::package; | ||
use sui::display; | ||
|
||
public struct MYNFT has drop {} | ||
|
||
public struct NFT has key, store { | ||
id: UID, | ||
tokenId: u64, | ||
} | ||
|
||
public struct State has key { | ||
id: UID, | ||
count: u64, | ||
} | ||
|
||
fun init(witness: MYNFT, ctx: &mut TxContext) { | ||
let keys = vector[ | ||
utf8(b"name"), | ||
utf8(b"collection"), | ||
utf8(b"image_url"), | ||
utf8(b"description"), | ||
]; | ||
|
||
let values = vector[ | ||
utf8(b"MyNFT #{tokenID}"), | ||
utf8(b"MyNFT collection"), | ||
utf8(b"https://avatars.githubusercontent.com/u/97345728?v=4"), | ||
utf8(b"This is MyNFT"), | ||
]; | ||
|
||
let publisher = package::claim(witness, ctx); | ||
let mut display = display::new_with_fields<NFT>(&publisher, keys, values, ctx); | ||
display::update_version(&mut display); | ||
transfer::public_transfer(publisher, ctx.sender()); | ||
transfer::public_transfer(display, ctx.sender()); | ||
|
||
transfer::share_object(State{id: object::new(ctx), count: 0}); | ||
} | ||
|
||
entry public fun mint(state: &mut State, ctx: &mut TxContext) { | ||
state.count = state.count + 1; | ||
let nft = NFT { | ||
id: object::new(ctx), | ||
tokenId: state.count, | ||
}; | ||
transfer::public_transfer(nft, ctx.sender()); | ||
} | ||
} |
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,71 @@ | ||
/// Module: sui_nft | ||
module task3::sui_nft { | ||
use sui::tx_context::sender; | ||
use std::string::{utf8, String}; | ||
|
||
// The creator bundle: these two packages often go together. | ||
use sui::package; | ||
use sui::display; | ||
|
||
/// The Hero - an outstanding collection of digital art. | ||
public struct Hero has key, store { | ||
id: UID, | ||
name: String, | ||
image_url: String, | ||
} | ||
|
||
/// One-Time-Witness for the module. | ||
public struct SUI_NFT has drop {} | ||
|
||
fun init(otw: SUI_NFT, ctx: &mut TxContext) { | ||
let keys = vector[ | ||
utf8(b"name"), | ||
utf8(b"image_url"), | ||
utf8(b"description"), | ||
utf8(b"creator"), | ||
]; | ||
|
||
let values = vector[ | ||
// For `name` one can use the `Hero.name` property | ||
utf8(b"{name}"), | ||
// For `image_url` use an IPFS template + `image_url` property. | ||
utf8(b"{image_url}"), | ||
// Description is static for all `Hero` objects. | ||
utf8(b"A true Hero of the Sui ecosystem!"), | ||
// Creator field can be any | ||
utf8(b"Qiao") | ||
]; | ||
|
||
// Claim the `Publisher` for the package! | ||
let publisher = package::claim(otw, ctx); | ||
|
||
// Get a new `Display` object for the `Hero` type. | ||
let mut display = display::new_with_fields<Hero>( | ||
&publisher, keys, values, ctx | ||
); | ||
|
||
// Commit first version of `Display` to apply changes. | ||
display::update_version(&mut display); | ||
|
||
transfer::public_transfer(publisher, sender(ctx)); | ||
transfer::public_transfer(display, sender(ctx)); | ||
} | ||
|
||
/// Anyone can mint their `Hero`! | ||
public entry fun mint(name: String, image_url: String, ctx: &mut TxContext) { | ||
let id = object::new(ctx); | ||
let hero = Hero { id, name, image_url }; | ||
transfer::public_transfer(hero, ctx.sender()); | ||
} | ||
|
||
public entry fun transfer( | ||
nft: Hero, recipient: address, _: &mut TxContext | ||
) { | ||
transfer::public_transfer(nft, recipient) | ||
} | ||
|
||
public entry fun burn(hero: Hero, _: &mut TxContext) { | ||
let Hero { id, name: _, image_url: _ } = hero; | ||
object::delete(id) | ||
} | ||
} |
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 task3::task3_tests { | ||
// uncomment this line to import the module | ||
// use task3::task3; | ||
const ENotImplemented: u64 = 0; | ||
#[test] | ||
fun test_task3() { | ||
// pass | ||
} | ||
#[test, expected_failure(abort_code = ::task3::task3_tests::ENotImplemented)] | ||
fun test_task3_fail() { | ||
abort ENotImplemented | ||
} | ||
} | ||
*/ |
Oops, something went wrong.