Skip to content

Commit

Permalink
Fix Writing a package section of Move doc (MystenLabs#1172)
Browse files Browse the repository at this point in the history
* Update move.md

Fix Writing a package section of Move doc

* Update move.md

* Update move.md

* Update move.md

Updating change to reflect `my_move_package` and `sui` directories are parallel
  • Loading branch information
Clay-Mysten authored Apr 4, 2022
1 parent aa0521e commit d755dad
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions doc/src/build/move.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ instance of the `Coin` struct. Direct access to fields of a struct is
allowed only within the module defining a given struct as described in
[Privileged Struct Operations](https://github.com/diem/move/blob/main/language/documentation/book/src/structs-and-resources.md#privileged-struct-operations).
The body of the function simply retrieves the `value` field from the
`Coin` struct instance parameter and returns it. Please note that the
`Coin` struct instance parameter and returns it. Note that the
coin parameter is a read-only reference to the `Coin` struct instance,
indicated by the `&` preceding the parameter type. Move's type system
enforces an invariant that struct instance arguments passed by
Expand Down Expand Up @@ -284,9 +284,12 @@ wallet in [Calling Move code](wallet.md#calling-move-code).

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

Then clone the repository as described in
[Contributing to Sui](../contribute/index.md#download-and-learn-sui)
as this tutorial assumes you have a clone of Sui's repository in your current directory.

Refer to the code example developed for this tutorial 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
Expand All @@ -299,13 +302,20 @@ current_directory
```

For convenience, make sure the path to Sui binaries
(`sui/target/release`), including the sui-move command used throughout
this tutorial, is part of your system path.
(`~/.cargo/bin`), including the sui-move command used throughout
this tutorial, is part of your system path:

```
$ which sui-move
```

Now proceed to creating a package directory structure (in the current directory) with an
Now proceed to creating a package directory structure in the current
directory, parallel to the `sui` repository. It will contain an
empty manifest file and an empty module source file following the
[Move code organization](#move-code-organization)
described earlier:
described earlier.

So from the same directory containing the `sui` repository, run:

``` shell
mkdir -p my_move_package/sources
Expand Down Expand Up @@ -333,7 +343,10 @@ be an upgradable asset that can be shared between different players. A
sword asset can be defined similarly to another asset we are already
familiar with from our
[First look at Move source code](#first-look-at-move-source-code). That
is a `Coin` struct type. Let us put the following module and struct
is a `Coin` struct type.


Let us put the following module and struct
definitions in the `M1.move` file:

``` rust
Expand Down Expand Up @@ -391,25 +404,28 @@ version = "0.0.1"
# CI. The local dep is an unmodified version of the upstream stdlib
# Sui = { git = "https://github.com/MystenLabs/sui.git", subdir="sui_programmability/framework", rev="44b5702712c15df365989a3b3f80038b7bf6c2ef"}
# Assuming `sui` repo is at the same level of parent directory
# Assuming the `sui` repository is at the same level as the package parent directory
Sui = { local = "../sui/sui_programmability/framework/" }
[addresses]
MyFirstPackage = "0x0"
[dev-addresses]
MyFirstPackage = "0x0"
```

We can now go to the directory containing our package and build it:
Ensure you are in the `my_move_package` directory containing your package and build it:

``` shell
cd my_move_package
sui-move build
```

No output is expected on a successful build.
A successful build yields results resembling:

```shell
Build Successful
Artifacts path: "./build"
```

Now that we have designed our asset and its accessor functions, let us
test the code we have written.
Expand Down

0 comments on commit d755dad

Please sign in to comment.