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

Add Move Library section to Move doc #751

Merged
merged 1 commit into from
Mar 11, 2022
Merged

Add Move Library section to Move doc #751

merged 1 commit into from
Mar 11, 2022

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Mar 11, 2022

As a starting point, this PR adds the following to the Move doc:

  1. Move debugging tips
  2. A few Move library APIs, including all the various transfer functions, some TxContext functions.

Left out Collection and NFT to be filled up latter.

@Clay-Mysten
Copy link
Contributor

Fantastic work, Xun! Note, I'm moving this file to a doc/src/build subdirectory in PR #743.

Thank you so much!

doc/src/move.md Outdated Show resolved Hide resolved
doc/src/move.md Outdated
- Shared and mutable (work-in-progress).

**Transfer to Address**
The [`Transfer`](../../sui_programmability/framework/sources/Transfer.move) module provides all the APIs needed to manipuate the ownership of objects.
Copy link
Contributor

Choose a reason for hiding this comment

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

@Clay-Mysten do we plan to also serve this doc in the Dev Portal? The relative path to the source code will not work in Dev Portal right since they are not in the same Repo.

doc/src/move.md Outdated
Transfer::transfer(obj, recipient);
```
This call will fully consume the object, making it no longer accessible in the current transaction.
Once an account address owns an object, for any future use of this object, the signer of the transaction must be the owner of the object.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this also include "read" operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, including read operation.

doc/src/move.md Outdated Show resolved Hide resolved
doc/src/move.md Outdated
Transfer::share_object(obj);
```
After this call, `obj` stays mutable, but becomes shared by everyone, i.e. anyone can send a transaction to mutate this object. However, such an object cannot be deleted, transferred or embedded in another object as a field.
Shared mutable object can be powerful in that it will make programming a lot simpler in many cases, but it comes with the trade-off that it is significantly more expensive to use. One can see the difference of the two programming schemes between not using shared object vs using shared object by looking at the two different implementations of TicTacToe: [No Shared Object](../../sui_programmability/examples/games/sources/TicTacToe.move) vs [Shared Object](../../sui_programmability/examples/games/sources/TicTacToeV2.move).
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: define expensive here to help developers better understand the exact tradeoff(e.g., does it just cost more gas for the users or it's also higher latency, etc..)

@lxfind lxfind merged commit fa5ac73 into main Mar 11, 2022
@lxfind lxfind deleted the move-doc-more branch March 11, 2022 05:21
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.

None yet

3 participants