Skip to content

Commit

Permalink
emit example event in DevNetNFT module (MystenLabs#2295)
Browse files Browse the repository at this point in the history
  • Loading branch information
longbowlu authored May 27, 2022
1 parent 2f53a78 commit fadebee
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions crates/sui-framework/sources/DevNetNFT.move
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
module Sui::DevNetNFT {
use Sui::Url::{Self, Url};
use Sui::UTF8;
use Sui::ID::{Self, VersionedID};
use Sui::ID::{Self, ID, VersionedID};
use Sui::Event;
use Sui::Transfer;
use Sui::TxContext::{Self, TxContext};

Expand All @@ -24,6 +25,15 @@ module Sui::DevNetNFT {
// TODO: allow custom attributes
}

struct MintNFTEvent has copy, drop {
// The Object ID of the NFT
object_id: ID,
// The creator of the NFT
creator: address,
// The name of the NFT
name: UTF8::String,
}

/// Create a new DevNetNFT
public(script) fun mint(
name: vector<u8>,
Expand All @@ -37,7 +47,13 @@ module Sui::DevNetNFT {
description: UTF8::string_unsafe(description),
url: Url::new_unsafe_from_bytes(url)
};
Transfer::transfer(nft, TxContext::sender(ctx))
let sender = TxContext::sender(ctx);
Event::emit(MintNFTEvent {
object_id: *ID::inner(&nft.id),
creator: sender,
name: nft.name,
});
Transfer::transfer(nft, sender);
}

/// Transfer `nft` to `recipient`
Expand Down

0 comments on commit fadebee

Please sign in to comment.