In the library, when the users issue new collections, they will create a display object when the contract init.
The indexer needs a mark to know the object is to the display type.
#[private_generics(T)]
/// Create or borrow_mut Display object for resource `T`
/// Only the module of `T` can call this function.
public fun resource_display<T: key>(): &mut Object<Display<T>> {
let object_id = object::named_object_id<Display<T>>();
if (!object::exists_object(object_id)) {
let display_obj = object::new_named_object(Display<T> {
sample_map: simple_map::create()
});
//We transfer the display object to the moveos_std
//And the caller do not need to care about the display object
object::transfer_extend(display_obj, @moveos_std);
};
object::borrow_mut_object_extend<Display<T>>(object_id)
}
#[private_generics(T)]
/// Create or borrow_mut Display object for `Object<T>`
/// Only the module of `T` can call this function.
public fun object_display<T: key>(): &mut Object<Display<Object<T>>> {
let object_id = object::named_object_id<Display<Object<T>>>();
if (!object::exists_object(object_id)) {
let display_obj = object::new_named_object(Display<Object<T>> {
sample_map: simple_map::create()
});
//We transfer the display object to the moveos_std
//And the caller do not need to care about the display object
object::transfer_extend(display_obj, @moveos_std);
};
object::borrow_mut_object_extend<Display<Object<T>>>(object_id)
}
The solution is here
#[private_generics(T)]
/// Create or borrow_mut Display object for resource `T`
/// Only the module of `T` can call this function.
public fun resource_display<T: key>(): &mut Object<Display<T>> {
let object_id = object::named_object_id<Display<T>>();
if (!object::exists_object(object_id)) {
let display_obj = object::new_named_object(Display<T> {
sample_map: simple_map::create()
});
//We transfer the display object to the moveos_std
//And the caller do not need to care about the display object
object::transfer_extend(display_obj, @moveos_std);
};
//emit display create event
emit display_create<Display<T>>();
object::borrow_mut_object_extend<Display<T>>(object_id)
}
#[private_generics(T)]
/// Create or borrow_mut Display object for `Object<T>`
/// Only the module of `T` can call this function.
public fun object_display<T: key>(): &mut Object<Display<Object<T>>> {
let object_id = object::named_object_id<Display<Object<T>>>();
if (!object::exists_object(object_id)) {
let display_obj = object::new_named_object(Display<Object<T>> {
sample_map: simple_map::create()
});
//We transfer the display object to the moveos_std
//And the caller do not need to care about the display object
object::transfer_extend(display_obj, @moveos_std);
};
// emit display create event
emit display_create<Display<T>>();
object::borrow_mut_object_extend<Display<Object<T>>>(object_id)
}
Is nothing todo with the event . just claim the new display resoures has been create
In the library, when the users issue new collections, they will create a display object when the contract init.
The indexer needs a mark to know the object is to the display type.
The solution is here
Is nothing todo with the event . just claim the new display resoures has been create