Skip to content

Commit

Permalink
task 2 3 4
Browse files Browse the repository at this point in the history
  • Loading branch information
StarryDesert authored and StarryDesert committed Aug 30, 2024
1 parent 3f3310d commit 73b276b
Show file tree
Hide file tree
Showing 26 changed files with 998 additions and 13 deletions.
40 changes: 40 additions & 0 deletions mover/StarryDeserts/code/task2/faucet_coin/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 = 2
manifest_digest = "F8CFCF256E2F1BB7CD401C27799A09C40777C5C100F0DFA253E86DD7F0D4ED1B"
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.32.0"
edition = "2024.beta"
flavor = "sui"

[env]

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// Module: faucet_coin
module faucet_coin::faucet_coin {
use sui::coin::{Self, TreasuryCap};

public struct FAUCET_COIN has drop {}

#[allow(lint(share_owned))]
fun init(witness: FAUCET_COIN, ctx: &mut TxContext) {
let (treasury_cap, coin_metadata) = coin::create_currency(
witness,
6,
b"SDF",
b"StarryDesertsFaucet",
b"this is StarryDeserts coin",
option::none(),
ctx
);
sui::transfer::public_freeze_object(coin_metadata);
sui::transfer::public_share_object(treasury_cap);
}

public fun mint_in_my_module(treasury_cap: &mut TreasuryCap<FAUCET_COIN>, amount: u64, recipient: address, ctx: &mut TxContext) {
let coin = coin::mint(treasury_cap, amount, ctx);
transfer::public_transfer(coin, recipient);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
#[test_only]
module faucet_coin::faucet_coin_tests {
// uncomment this line to import the module
// use faucet_coin::faucet_coin;
const ENotImplemented: u64 = 0;
#[test]
fun test_faucet_coin() {
// pass
}
#[test, expected_failure(abort_code = ::faucet_coin::faucet_coin_tests::ENotImplemented)]
fun test_faucet_coin_fail() {
abort ENotImplemented
}
}
*/
40 changes: 40 additions & 0 deletions mover/StarryDeserts/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 = 2
manifest_digest = "4A2A5B4571B81869E1178D96A6539ACB68F917738CFC685E63B4375C00B328CD"
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.32.0"
edition = "2024.beta"
flavor = "sui"

[env]

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

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0xf3371a5dcfcb000e61ee76990cf1e61083b9f3f342bbaae2b449b9be97661152"
latest-published-id = "0xf3371a5dcfcb000e61ee76990cf1e61083b9f3f342bbaae2b449b9be97661152"
published-version = "1"
37 changes: 37 additions & 0 deletions mover/StarryDeserts/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://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]
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"

35 changes: 35 additions & 0 deletions mover/StarryDeserts/code/task2/myCoin/sources/mycoin.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// Module: mycoin
module mycoin::mycoin {
use sui::coin::{Self, Coin, TreasuryCap};

public struct MYCOIN has drop {}

fun init(witness: MYCOIN, ctx: &mut TxContext) {
let (treasury, metadata) = coin::create_currency(
witness,
6,
b"SD",
b"StarryDeserts",
b"this is StarryDeserts coin",
option::none(),
ctx
);

transfer::public_freeze_object(metadata);

transfer::public_transfer(treasury, ctx.sender());
}

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

public fun burn(treasury_cap: &mut TreasuryCap<MYCOIN>, coin: Coin<MYCOIN>) {
coin::burn(treasury_cap, coin);
}
}





19 changes: 19 additions & 0 deletions mover/StarryDeserts/code/task2/myCoin/tests/mycoin_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
#[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
}
}
*/
34 changes: 34 additions & 0 deletions mover/StarryDeserts/code/task3/mynft/Move.lock
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 = "8616F2E3855F9CD22C6339699001728147605815419FEB1EF09E72CF5A05E332"
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 = "0x16ddf0671a7c0aebd5a68279c56c87239ce454569c60db3baa6baae57375bf82"
latest-published-id = "0x16ddf0671a7c0aebd5a68279c56c87239ce454569c60db3baa6baae57375bf82"
published-version = "1"
37 changes: 37 additions & 0 deletions mover/StarryDeserts/code/task3/mynft/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "mynft"
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]
mynft = "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"

53 changes: 53 additions & 0 deletions mover/StarryDeserts/code/task3/mynft/sources/mynft.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/// Module: mynft
module mynft::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/86464159?s=400&u=140a967736ff67d13e882f43ead3dc508c6644e2&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());
}
}


Loading

0 comments on commit 73b276b

Please sign in to comment.