Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Object Ownership #2] Add trasfer_to_object API in Transfer.move #293

Merged
merged 1 commit into from
Jan 31, 2022

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Jan 28, 2022

This is the second step towards #99.
It allows us to transfer an object to another object in Move.
To do so we added a transfer_to_object API in the Transfer module, which then invokes a native function to emit the corresponding event.
Latter in the adapter we process the event and change the owner accordingly.

@oxade
Copy link
Contributor

oxade commented Jan 28, 2022

This is interesting. I was not aware objects could own other objects.
This changes my design for client object storage because we might now have to walk the tree of descendant objects and store them.

@oxade
Copy link
Contributor

oxade commented Jan 28, 2022

@lxfind @sblackshear
If my object owns X another object Y, and X gets frozen, does Y get frozen too from my POV?

@lxfind
Copy link
Contributor Author

lxfind commented Jan 28, 2022

Yeah there will be some work needed in the client to support this, but don't worry about it at the moment.
I would wait till our client refactoring finishes before getting this into the client.

@lxfind
Copy link
Contributor Author

lxfind commented Jan 28, 2022

@lxfind @sblackshear If my object owns X another object Y, and X gets frozen, does Y get frozen too from my POV?

Based on the current design, yes. If X owns Y, and we freeze X, Y is also frozen (all objects owned by X will be frozen).

@lxfind lxfind changed the title Add trasfer_to_object API in Transfer.move [Object Ownership #2] Add trasfer_to_object API in Transfer.move Jan 28, 2022
public native fun transfer_to_id<T: key>(obj: T, id: IDBytes);*/
/// Transfer ownership of `obj` to another object `owner`.
// TODO: Add option to freeze after transfer.
public fun transfer_to_object<T: key, R: key>(obj: T, owner: &mut R) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to make this a friend function if we're only planning to expose it in certain collection published in genesis. But let's see how it shakes out.

}

/// Transfer ownership of `obj` to another object with `id`.
native fun transfer_to_object_id<T: key>(obj: T, id: IDBytes);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a caution--if you try to test this, I think it will crash due to #309.

Copy link
Collaborator

@gdanezis gdanezis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am far from expert when it comes to framework, but looks good. A couple of tests on transfer and freeze to addresses and objects would make me sleep better.

@lxfind lxfind force-pushed the add-authenticator branch from 7f779f7 to b8f6ea7 Compare January 31, 2022 18:13
Base automatically changed from add-authenticator to main January 31, 2022 18:31
@lxfind lxfind force-pushed the allow-transfer-to-object branch from d44066e to 9501a69 Compare January 31, 2022 18:56
@lxfind lxfind force-pushed the allow-transfer-to-object branch from 9501a69 to 35fa4d3 Compare January 31, 2022 18:59
@lxfind lxfind merged commit fa042de into main Jan 31, 2022
@lxfind lxfind deleted the allow-transfer-to-object branch January 31, 2022 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants