Hi everyone. I cannot find information on how to work with optional object arguments in the documentation or on Google.
I have a function, that should accept Option<SharedObject>
because this object can exist only in certain circumstances.
If I pass an argument by reference like opt_arg: &mut Option<SharedObject>
code compiles and tested without any errors, but on the runtime I’m getting UnusedValueWithoutDrop { result_idx: 2, secondary_idx: 0 }
error, because tssdk under the hood performs a MoveCall
to create option::some()
or option::none()
.
If I pass an argument by value like opt_arg: Option<SharedObject>
, I should destroy the Option
object and re-share the SharedObject. But there is no way to re-share the object as transer::public_share_object
will emit the ESharedNonNewObject
error.
Also, there is no way to pass SharedObject to the Option
by reference to not re-share it later.
Is there any solution for this? Or I need to have 2 functions with this SharedObject argument and without it?