-
Notifications
You must be signed in to change notification settings - Fork 124
[book] transfer to object #106
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
base: main
Are you sure you want to change the base?
Conversation
|
||
Transfer to Object is not the only way to create a relationship between objects. There are more | ||
flexible and feature-rich ways, such as the | ||
[Dynamic Fields](./../programmability/dynamic-fields.md), which we explore in the |
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 do not know if this is the place for this comment, however as dynamic fields are referenced here, here it is:
Something that comes up a lot:
Should I use dynamic fields or TTO?
One major difference is that one does not need to have ownership of the owner-object in order to transfer an object to it.
Dynamic fields on the other hand can be seen as having more "control" on what is added "below" the owner object.
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.
Been thinking about it a lot and still don't have an answer. Technically, in the book, it is too early to mention dynamic fields (they come mid next chapter), yet dynamic fields are too far from transfer to object. Very good point, and very much worth discussing!
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.
In my mind it's not really an either/or of TTO vs dynamic fields. TTO is about transfer, dynamic fields are about ownership -- i.e. it's perfectly valid to have a protocol where you use TTO to transfer something to an object, and then when it is received, it is turned into a dynamic field on the object it was received on.
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.
@amnn I agree that they're not replacing each other (though, in some situations they do), but more of a guide which one is suited for which purpose.
Every object in Sui has its own `UID` which is represented by the | ||
[address type](./../move-basics/address.md). This address can be used to query the object's data, |
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.
This may be a bit confusing to folks, because depending on context, an object's ID can be represented by a UID
, ID
, or address
type. On this page the address
representation is the most interesting/novel one, but in other circumstances (e.g. for dynamic fields) UID
is more interesting, and in other circumstances (e.g. ID pointer) ID
is more interesting.
Here seems like the wrong place to discuss this concept in detail, but it seems like something we should document somewhere.
/// For objects without `store` (though, they would require special handling), we | ||
/// can implement the non-public version of the `receive` function. | ||
public fun receive<T: key>(po: &mut PostOffice, to_receive: Receiving<T>): T { | ||
transfer::receive(&mut po.id, to_receive) | ||
} |
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.
Does this work? I would expect it to fail because of custom transfer rules (the non-public_
receive is being called on type T
from a module that does not define T
).
|
||
Transfer to Object is not the only way to create a relationship between objects. There are more | ||
flexible and feature-rich ways, such as the | ||
[Dynamic Fields](./../programmability/dynamic-fields.md), which we explore in the |
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.
In my mind it's not really an either/or of TTO vs dynamic fields. TTO is about transfer, dynamic fields are about ownership -- i.e. it's perfectly valid to have a protocol where you use TTO to transfer something to an object, and then when it is received, it is turned into a dynamic field on the object it was received on.
Co-authored-by: Ashok Menon <[email protected]>
of the cases it is an account address, it can also be an address of an object. In this case, | ||
Previously, we have explained how [transfer](./storage-functions.md#transfer) works in relation to | ||
accounts. However, there is an additional behaviour allowed by the | ||
[Sui Object Model](./../object/object-model.md) - transferring objects to other objects. If certain |
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.
[Sui Object Model](./../object/object-model.md) - transferring objects to other objects. If certain | |
[Sui Object Model](./../object/object-model.md) — transferring objects to other objects. If certain |
[Object Model](../object/index.html). | ||
- Receiving object argument: a special argument that is used to receive an object transferred to | ||
another object. We cover this in more detail in the | ||
[Transfer to Object](../storage/transfer-to-object.html) section. |
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.
It would be good to have an example and/or more detail on how you actually create a receiving object, either on this page or that one
@@ -31,21 +31,27 @@ Transactions consist of: | |||
|
|||
## Inputs | |||
|
|||
Transaction inputs are the arguments for the transaction and are split between 2 types: | |||
Transaction inputs are the arguments for the transaction and are split between 3 types: |
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 feel like the term "PTB" should be mentioned somewhere on this page.
Adds missing Transfer to Object chapter