Skip to content

Commit

Permalink
Merge pull request #2043 from Jmagicc/main
Browse files Browse the repository at this point in the history
fix:task3 add a tick;
  • Loading branch information
Sifotd authored Nov 30, 2024
2 parents 63077b2 + 78b4c76 commit ce85322
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 4 deletions.
117 changes: 117 additions & 0 deletions mover/Jmagicc/code/task3/sources/jmagiccnft.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/// Module: jmagiccnft
module jmagiccnft::jmagiccnft {
use std::debug;
use std::ascii::string;
use sui::url::{Self, Url};
use std::string;
use sui::object::{Self, ID, UID};
use sui::event;
use sui::transfer;
use sui::tx_context::{Self, TxContext};


public struct JmagiccNFT has key, store {
id: UID,
name: string::String,
description: string::String,
url: Url,
ex_param: string::String,
}

// ===== Events =====
public struct NFTMinted has copy, drop {
object_id: ID,
creator: address,
name: string::String,
}

// ===== Public view functions =====
/// Get the NFT's `name`
public fun name(nft: &JmagiccNFT): &string::String {
&nft.name
}

/// Get the NFT's `description`
public fun description(nft: &JmagiccNFT): &string::String {
&nft.description
}

/// Get the NFT's `url`
public fun url(nft: &JmagiccNFT): &Url {
&nft.url
}

// ===== Entrypoints ===== 入口函数
#[allow(unused_variable)]
public entry fun mint_ntf(ctx: &mut TxContext)
{
debug::print(&string(b"mint ntf"));
let sender = tx_context::sender(ctx);

let nft = JmagiccNFT {
id: object::new(ctx),
name: string::utf8(b"Jmagicc NTF"),
description: string::utf8(b"This is the description of Jmagicc NTF"),
url: url::new_unsafe_from_bytes(b"https://avatars.githubusercontent.com/u/58356228"),
ex_param: string::utf8(b"ex param"),
};

event::emit(NFTMinted {
object_id: object::id(&nft),
creator: sender,
name: nft.name,
});

transfer::public_transfer(nft, sender);

}

/// Create a new devnet_nft
public entry fun mint_to_sender(
name: vector<u8>,
description: vector<u8>,
url: vector<u8>,
exparam: vector<u8>,
ctx: &mut TxContext
) {
let sender = tx_context::sender(ctx);
let nft = JmagiccNFT {
id: object::new(ctx),
name: string::utf8(name),
description: string::utf8(description),
url: url::new_unsafe_from_bytes(url),
ex_param: string::utf8(exparam),
};

event::emit(NFTMinted {
object_id: object::id(&nft),
creator: sender,
name: nft.name,
});

transfer::public_transfer(nft, sender);
}

/// Transfer `nft` to `recipient`
public entry fun transfer(
nft: JmagiccNFT, recipient: address, _: &mut TxContext
) {
transfer::public_transfer(nft, recipient)
}

/// Update the `description` of `nft` to `new_description`
public entry fun update_description(
nft: &mut JmagiccNFT,
new_description: vector<u8>,
_: &mut TxContext
) {
nft.description = string::utf8(new_description)
}

/// Permanently delete `nft`
public entry fun burn(nft: JmagiccNFT, _: &mut TxContext) {
let JmagiccNFT { id, name: _, description: _, url: _, ex_param: _ } = nft;
object::delete(id)
}

}
Binary file added mover/Jmagicc/images/jmagicc-nft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions mover/Jmagicc/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
- [x] `Faucet Coin` address2 mint hash: 2pnVPpT3mMCrHVgCgpXoP9VSbDeV75VA2yB57Fe3X2ib

## 03 move NFT
- [] nft package id :
- [] nft object id :
- [] 转账 nft hash:
- [] scan上的NFT截图:![Scan截图](./images/你的图片地址)
- [x] nft package id : 0xf2ff2aa355b94f3bb4f0f4781d7c4df708002192d27c7e84ae509fd3a0889de0
- [x] nft object id : 0x2ac6f5f1f162fd6607bd3880c9438d60c2808074190a73720d7d36bbd86ceee3
- [x] 转账 nft hash: JEF88V2kwZbEviS9rDvG5LPz7yyaxQ8zSqSmSJqrgTEp
- [x] scan上的NFT截图:![Scan截图](./images/jmagicc-nft.png)

## 04 Move Game
- [] game package id :
Expand Down

0 comments on commit ce85322

Please sign in to comment.