Skip to content

Commit

Permalink
[docs] Added Sui installation section and updated relevant docs to re…
Browse files Browse the repository at this point in the history
…fer to it (MystenLabs#860)

* [docs] Added Sui installation section and updated relevant docs to refer to it

* Update index.md

Replace repeat start with begin

* Update move.md

Make link text clear, remove important information from parenthesis

* Update wallet.md

Make install link text more clear
No "here" links: https://www.w3.org/QA/Tips/noClickHere

* Update tutorials.md

Fixing more "here" links: https://www.w3.org/QA/Tips/noClickHere

* Added forgotten new file

* Update doc/src/build/move.md

Co-authored-by: Adam Welc <[email protected]>

* Update doc/src/build/move.md

Co-authored-by: Adam Welc <[email protected]>

* Update doc/src/build/move.md

Co-authored-by: Adam Welc <[email protected]>

* Update move.md

Remove TODO regarding module and package names

* Update install.md

Make small edits to Install doc

* Update move.md

Fix relative paths to sui_programmability

Co-authored-by: Clay-Mysten <[email protected]>
  • Loading branch information
awelc and Clay-Mysten authored Mar 16, 2022
1 parent 0b688b4 commit 03d1e84
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 81 deletions.
2 changes: 1 addition & 1 deletion doc/src/build/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Building Sui
---

Now that you've [learned about Sui](../learn/index.md), it's time to build it yourself. Start by becoming familiar with these key concepts:
Now that you've [learned about Sui](../learn/index.md), it's time to [install](install.md) all the required tools and start building. Begin by becoming familiar with these key concepts:

* [Smart Contracts with Move](move.md) - Move is an open source language for writing safe smart contracts. In Sui, Move is used to define,
create and manage programmable Sui objects representing user-level assets.
Expand Down
27 changes: 27 additions & 0 deletions doc/src/build/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Install Sui
---

Sui is written in Rust, and we are using Cargo to build and manage the
dependencies. As a prerequisite, you will need to [install
cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)
version 1.59.0 or higher in order to build and install Sui on your machine.

If you'd like to install only Sui binaries (`sui`, `wallet`, and
`sui-move`), use the following command:

```shell
cargo install --git ssh://[email protected]/MystenLabs/sui.git
```

Alternatively, clone the Sui [Sui
GitHub](https://github.com/MystenLabs/sui) repository and then `cargo
install` with the repository clone:

```shell
git clone https://github.com/MystenLabs/sui.git
cargo install --path sui
```

In both cases, this will install `sui`, `wallet`, and `sui-move`
binaries in a `~/.cargo/bin` directory that can be executed directly.
41 changes: 21 additions & 20 deletions doc/src/build/move.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ user-defined coin types, which are custom assets define in the Move
language. Sui framework code contains the `Coin` module supporting
creation and management of custom coins. The `Coin` module is
located in the
[sui_programmability/framework/sources/Coin.move](../../../sui_programmability/framework/sources/Coin.move)
[sui_programmability/framework/sources/Coin.move](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/Coin.move)
file. As you would expect, the manifest file describing how to build the
package containing the `Coin` module is located in the corresponding
[sui_programmability/framework/Move.toml](../../../sui_programmability/framework/Move.toml)
[sui_programmability/framework/Move.toml](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/Move.toml)
file.

Let's see what module definition in the `Coin` module file looks like:
Expand All @@ -108,17 +108,14 @@ As we can see, when defining a module we specify the module name
is used to uniquely identify a module in Move source code (e.g., to be
able to use if from other modules). The package name is globally
unique, but different packages can contain modules with the same name.
Module names are not unique, but combined with unique package name renders
a unique combination.

For example, if you have package "P" that has been published, you cannot
publish another package named "P". At the same time you can have module
"P1::M1", "P2::M1", and "P1::M2" but not another, say, "P1::M1" in the system
at the same time.

TODO: Clarify this last sentence. How is the package name globally
unique then? Or are you saying the aforementioned *combination* is
globally unique?


In addition to having a presence at the source code level, as we
discussed in [Move code organization](#move-code-organization), a
package in Sui is also a Sui object and must have a unique numeric
Expand Down Expand Up @@ -158,7 +155,7 @@ in the Move book.
In order for a Move struct type to define a Sui object type such as
`Coin`, its first field must be `id: VersionedID`, which is a
struct type defined in the
[ID module](../../../sui_programmability/framework/sources/ID.move). The
[ID module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/ID.move). The
Move struct type must
also have the `key` ability, which allows the object to be persisted
in Sui's global storage. Abilities of a Move struct are listed after
Expand Down Expand Up @@ -186,7 +183,7 @@ In particular, one type of custom coin already defined in Sui is
`Coin<GAS>`, which represents a token used to pay for gas used in Sui
computations - in this case, the concrete type used to parameterize the
`Coin` struct is the `GAS` struct in the
[Coin module](../../../sui_programmability/framework/sources/Coin.move):
[Coin module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/Coin.move):

``` rust
struct GAS has drop {}
Expand All @@ -201,7 +198,7 @@ section describing how to
Similarly to other popular programming languages, the main unit of
computation in Move is a function. Let us look at one of the simplest
functions defined in the
[Coin module](../../../sui_programmability/framework/sources/Coin.move), that is
[Coin module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/Coin.move), that is
the `value` function.

``` rust
Expand Down Expand Up @@ -243,7 +240,7 @@ One of the basic operations in Sui is transfer of gas objects between
[addresses](https://github.com/diem/move/blob/main/language/documentation/book/src/address.md)
representing individual users. And one of the
simplest entry functions is defined in the GAS
[module](../../../sui_programmability/framework/sources/GAS.move) to
[module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/GAS.move) to
implement gas object transfer:

```rust
Expand All @@ -265,7 +262,7 @@ In general, an entry function, must satisfy the following properties:
- one or more primitive types (or vectors of such types)
- a mutable reference to an instance of the `TxContext` struct
defined in the
[TxContext module](../../../sui_programmability/framework/sources/TxContext.move)
[TxContext module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/TxContext.move)

More, concretely, the `transfer` function is public, has no return
value, and has three parameters:
Expand All @@ -284,8 +281,12 @@ wallet in [Calling Move code](wallet.md#calling-move-code).

## Writing a package

In order to be able to build a Move package and run code defined in this package
first install Sui binaries as described [here](wallet.md#installing-the-binaries).
In order to build a Move package and run code defined in
this package, first [install Sui binaries](install.md).
Please clone the repository as
described in the installation instructions as this tutorial assumes that you have a clone of Sui's repository in your current directory, and the code example
developed in this tutorial can also be found in the
[M1.move](https://github.com/MystenLabs/sui/tree/main/sui_programmability/tutorial/sources/M1.move) file.

The directory structure used in this tutorial should at the moment
look as follows (assuming Sui has been cloned to a directory called
Expand Down Expand Up @@ -350,7 +351,7 @@ Since we are developing a fantasy game, in addition to the mandatory
`Coin` struct), our asset has both `magic` and `strength` fields
describing its respective attribute values. Please note that we need
to import the
[ID package](../../../sui_programmability/framework/sources/ID.move) from
[ID package](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/ID.move) from
Sui framework to gain access to the `VersionedID` struct type defined
in this package.

Expand Down Expand Up @@ -518,7 +519,7 @@ problem is to transfer ownership of the sword.
In order to get our test to work, we then add the following line to
the beginning of our testing function to import the
[Transfer module](../../../sui_programmability/framework/sources/Transfer.move):
[Transfer module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/Transfer.move):
``` rust
use Sui::Transfer;
Expand Down Expand Up @@ -575,7 +576,7 @@ transactions within a single test (e.g. one transaction creating an
object and the other one transferring it).
Sui-specific testing is supported via the
[TestScenario module](../../../sui_programmability/framework/sources/TestScenario.move)
[TestScenario module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/TestScenario.move)
that provides Sui-related testing functionality otherwise unavailable
in *pure Move* and its
[testing framework](https://github.com/diem/move/blob/main/language/documentation/book/src/unit-testing.md).
Expand Down Expand Up @@ -871,7 +872,7 @@ encounter compilation errors in the existing tests due to the
required for the tests to run again as an exercise for the reader. The
entire source code for the package we have developed (with all the
tests properly adjusted) can be found in
[M1.move](../../../sui_programmability/tutorial/sources/M1.move).
[M1.move](https://github.com/MystenLabs/sui/tree/main/sui_programmability/tutorial/sources/M1.move).
## Sui Move Library
Sui provides a list of Move library functions that allows us to manipulate objects in Sui.
Expand All @@ -884,7 +885,7 @@ Objects in Sui can have different ownership types. Specifically, they are:
- 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.
The [`Transfer`](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/Transfer.move) module provides all the APIs needed to manipuate the ownership of objects.
The most common case is to transfer an object to an account address. For example, when a new object is created, it is typically transferred to an account address so that the address owns the object. To transfer an object `obj` to an account address `recipient`:
```
Expand Down Expand Up @@ -950,7 +951,7 @@ To make an object `obj` shared and mutable, one can call:
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. However shared object is also more expensive to use: it requires a full sequencer (a.k.a. a consensus engine) to order the transactions that touch the shared object, which means longer latency/lower throughput and higher gas cost. 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).
Shared mutable object can be powerful in that it will make programming a lot simpler in many cases. However shared object is also more expensive to use: it requires a full sequencer (a.k.a. a consensus engine) to order the transactions that touch the shared object, which means longer latency/lower throughput and higher gas cost. 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](https://github.com/MystenLabs/sui/tree/main/sui_programmability/examples/games/sources/TicTacToe.move) vs [Shared Object](https://github.com/MystenLabs/sui/tree/main/sui_programmability/examples/games/sources/TicTacToeV2.move).
### Transaction Context
`TxContext` module provides a few important APIs that operate based on the current transaction context.
Expand Down
23 changes: 3 additions & 20 deletions doc/src/build/wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,13 @@ interface, *Wallet CLI*.

## Setup

### Installing the binaries

Sui is written in Rust, and we are using Cargo to build and manage the dependencies.
As a prerequisite, you will need to [install cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)
in order to build and install Sui on your machine.

Check out the [Sui GitHub](https://github.com/MystenLabs/sui) repository.

To install the `sui` and `wallet` binaries, use the following commands.
```shell
cargo install --git ssh://[email protected]/MystenLabs/sui.git
```
or
```shell
cargo install --path <Path to Sui project>/sui
```

This will install `sui` and `wallet` binaries in `~/.cargo/bin`directory that can be executed directly.
Follow the instructions to [install Sui binaries](install.md).

## Genesis
```shell
sui genesis
```
NOTE: For logs, set `RUST_LOG=debug` before invoking `./sui genesis`.
NOTE: For logs, set `RUST_LOG=debug` before invoking `sui genesis`.

The `genesis` command creates four authorities and five user accounts
each with five gas objects. These are Sui [objects](objects.md) used
Expand Down Expand Up @@ -134,7 +117,7 @@ or
```shell
sui start --config [config file path]
```
NOTE: For logs, set `RUST_LOG=debug` before invoking `./sui start`.
NOTE: For logs, set `RUST_LOG=debug` before invoking `sui start`.

The network config file path defaults to `./network.conf` if not
specified.
Expand Down
Loading

0 comments on commit 03d1e84

Please sign in to comment.