Skip to content

Commit

Permalink
add Display
Browse files Browse the repository at this point in the history
  • Loading branch information
WGB5445 committed Oct 16, 2023
1 parent c849b42 commit 4a8a68c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/rooch-framework/sources/nft/collection.move
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module rooch_framework::collection{
creator,
collection
);

event::emit(
ctx,
CreateCollectionEvent {
Expand All @@ -98,6 +99,14 @@ module rooch_framework::collection{
mutator_ref
}

public fun destroy_mutator_ref(mutator_ref :ObjectRef<MutatorRef>):ObjectID{
assert_mutator_exist_of_ref(&mutator_ref);
let MutatorRef {
collection
} = object_ref::remove(mutator_ref);
collection
}

public fun get_collection_id(mutator: &ObjectRef<MutatorRef>): ObjectID{
assert_mutator_exist_of_ref(mutator);
let mutator_object_ref = object_ref::borrow(mutator);
Expand Down
42 changes: 42 additions & 0 deletions crates/rooch-framework/sources/nft/display.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module rooch_framework::display{
use std::ascii::String;
use moveos_std::simple_map;

struct Display has key, store,drop,copy {
sample_map: simple_map::SimpleMap<String, String>
}

public fun new (): Display {
Display {
sample_map: simple_map::create()
}
}

public fun set (self: &mut Display, key: String, value: String) {
simple_map::add(&mut self.sample_map, key, value);
}

public fun borrow (self: & Display, key: String): &String {
simple_map::borrow(&mut self.sample_map, &key)
}

public fun borrow_mut (self: &mut Display, key: String): &mut String {
simple_map::borrow_mut(&mut self.sample_map, &key)
}

public fun remove (self: &mut Display, key: String) {
simple_map::remove(&mut self.sample_map, &key);
}

public fun keys (self: & Display): vector<String> {
simple_map::keys(& self.sample_map)
}

public fun values (self: & Display): vector<String> {
simple_map::values(& self.sample_map)
}

public fun contains_key (self: & Display, key: String) -> bool {
simple_map::contains(& self.sample_map, key)
}
}
27 changes: 27 additions & 0 deletions crates/rooch-framework/sources/nft/nft.move
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,33 @@ module rooch_framework::nft {
mutator_ref
}

public fun destroy_mutator_ref(mutator_ref :ObjectRef<MutatorRef>):ObjectID{
assert_mutator_exist_of_ref(&mutator_ref);
let MutatorRef {
nft
} = object_ref::remove(mutator_ref);
nft
}

public fun generate_burner_ref(nft_object_ref: &ObjectRef<NFT>, ctx: &mut Context):ObjectRef<BurnerRef>{
let burner_ref = context::new_object_with_owner(
ctx,
object_ref::owner(nft_object_ref),
BurnerRef {
nft: object_ref::id(nft_object_ref),
}
);
burner_ref
}

public fun destroy_burner_ref(burner_ref :ObjectRef<BurnerRef>):ObjectID{
assert_burner_exist_of_ref(&burner_ref);
let BurnerRef {
nft
} = object_ref::remove(burner_ref);
nft
}

// assert
public fun assert_nft_exist_of_id(objectId: ObjectID, ctx: &Context) {
assert!(context::exist_object(ctx, objectId), ENftNotExist);
Expand Down

0 comments on commit 4a8a68c

Please sign in to comment.