-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Conversation
This is interesting. I was not aware objects could own other objects. |
@lxfind @sblackshear |
Yeah there will be some work needed in the client to support this, but don't worry about it at the moment. |
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). |
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
7f779f7
to
b8f6ea7
Compare
d44066e
to
9501a69
Compare
9501a69
to
35fa4d3
Compare
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.