Skip to content

Commit

Permalink
[doc] update move repo links and fix a few typos
Browse files Browse the repository at this point in the history
  • Loading branch information
emmazzz committed May 23, 2022
1 parent 05f9e04 commit 619f717
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
40 changes: 20 additions & 20 deletions doc/src/build/move.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ and existing platforms (e.g.,


The Move language documentation is available in the
[Move GitHub](https://github.com/diem/move) repository and includes a
[tutorial](https://github.com/diem/move/blob/main/language/documentation/tutorial/README.md)
[Move GitHub](https://github.com/move-language/move) repository and includes a
[tutorial](https://github.com/move-language/move/blob/main/language/documentation/tutorial/README.md)
and a
[book](https://github.com/diem/move/blob/main/language/documentation/book/src/SUMMARY.md)
[book](https://github.com/move-language/move/blob/main/language/documentation/book/src/SUMMARY.md)
describing language features in detail. These are invaluable resources
to deepen your understanding of the Move language but not strict prerequisites
to following the Sui tutorial, which we strived to make self-contained.
Expand All @@ -53,7 +53,7 @@ files with the `.move` extension. These files include Move functions and
type definitions. A package must include the `Move.toml` manifest file
describing package configuration, for example package metadata or
package dependencies. See
[Move.toml](https://github.com/diem/move/blob/main/language/documentation/book/src/packages.md#movetoml)
[Move.toml](https://github.com/move-language/move/blob/main/language/documentation/book/src/packages.md#movetoml)
for more information about package manifest files.

The minimal package source directory structure looks as follows and
Expand All @@ -68,7 +68,7 @@ my_move_package
```

See
[Package Layout and Manifest Syntax](https://github.com/diem/move/blob/main/language/documentation/book/src/packages.md#package-layout-and-manifest-syntax)
[Package Layout and Manifest Syntax](https://github.com/move-language/move/blob/main/language/documentation/book/src/packages.md#package-layout-and-manifest-syntax)
for more information on package layout.

We are now ready to look at some Move code! You can either keep
Expand All @@ -79,7 +79,7 @@ Move language constructs or you can jump straight into the code by [writing a si

The Sui platform includes _framework_ Move code that is needed to
bootstrap Sui operations. In particular, Sui supports multiple
user-defined coin types, which are custom assets define in the Move
user-defined coin types, which are custom assets defined 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
Expand All @@ -99,7 +99,7 @@ module Sui::Coin {

(Let's not worry about the rest of the module contents for now; you can
read more about
[modules](https://github.com/diem/move/blob/main/language/documentation/book/src/modules-and-scripts.md#modules)
[modules](https://github.com/move-language/move/blob/main/language/documentation/book/src/modules-and-scripts.md#modules)
in the Move book later.)

As we can see, when defining a module we specify the module name
Expand Down Expand Up @@ -145,8 +145,8 @@ of typed fields. In particular, struct fields can be of a primitive
type, such as an integer type, or of a struct type.

You can read more about
Move [primitive types](https://github.com/diem/move/blob/main/language/documentation/book/src/SUMMARY.md#primitive-types)
and [structs](https://github.com/diem/move/blob/main/language/documentation/book/src/structs-and-resources.md)
Move [primitive types](https://github.com/move-language/move/blob/main/language/documentation/book/src/SUMMARY.md#primitive-types)
and [structs](https://github.com/move-language/move/blob/main/language/documentation/book/src/structs-and-resources.md)
in the Move book.

In order for a Move struct type to define a Sui object type such as
Expand All @@ -161,7 +161,7 @@ lack thereof) helps enforcing various properties on a definition or on
instances of a given struct.

You can read more about struct
[abilities](https://github.com/diem/move/blob/main/language/documentation/book/src/abilities.md)
[abilities](https://github.com/move-language/move/blob/main/language/documentation/book/src/abilities.md)
in the Move book.

The reason that the `Coin` struct can represent different types of
Expand All @@ -171,16 +171,16 @@ be passed an arbitrary concrete Move type (e.g. another struct type)
to distinguish different types of coins from one another.

Learn about Move type parameters known as
[generics](https://github.com/diem/move/blob/main/language/documentation/book/src/generics.md)
[generics](https://github.com/move-language/move/blob/main/language/documentation/book/src/generics.md)
and also about the optional
[phantom keyword](https://github.com/diem/move/blob/main/language/documentation/book/src/generics.md#phantom-type-parameters))
[phantom keyword](https://github.com/move-language/move/blob/main/language/documentation/book/src/generics.md#phantom-type-parameters))
at your leisure.

In particular, one type of custom coin already defined in Sui is
`Coin<SUI>`, which represents a token used to pay for Sui
computations (more generally known as _gas_) - in this case, the concrete type used to parameterize the
`Coin` struct is the `SUI` struct in the
[Coin module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/Coin.move):
[SUI module](https://github.com/MystenLabs/sui/blob/main/sui_programmability/framework/sources/SUI.move):

``` rust
struct SUI has drop {}
Expand Down Expand Up @@ -208,7 +208,7 @@ This _public_ function can be called by functions in other modules to
return the unsigned integer value currently stored in a given
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).
[Privileged Struct Operations](https://github.com/move-language/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. Note that the
coin parameter is a read-only reference to the `Coin` struct instance,
Expand All @@ -218,7 +218,7 @@ read-only references (as opposed to mutable references) cannot be
modified in the body of a function.

You can read more about Move
[references](https://github.com/diem/move/blob/main/language/documentation/book/src/references.md#references) in the Move book.
[references](https://github.com/move-language/move/blob/main/language/documentation/book/src/references.md#references) in the Move book.

We will show how to call Move functions from other functions and how
to define the new ones in the section describing how to
Expand All @@ -234,7 +234,7 @@ must satisfy a certain set of properties.
#### Entry functions

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)
[addresses](https://github.com/move-language/move/blob/main/language/documentation/book/src/address.md)
representing individual users. And one of the
simplest entry functions is defined in the
[SUI module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/SUI.move)
Expand All @@ -257,12 +257,12 @@ In general, an entry function, must satisfy the following properties:
- have a mutable reference to an instance of the `TxContext` struct
defined in the [TxContext module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/TxContext.move) as the last parameter

More, concretely, the `transfer` function is public, has no return
More concretely, the `transfer` function is public, has no return
value, and has three parameters:

- `c` - represents a gas object whose ownership is to be
transferred
- `recipient` - the [address](https://github.com/diem/move/blob/main/language/documentation/book/src/address.md)
- `recipient` - the [address](https://github.com/move-language/move/blob/main/language/documentation/book/src/address.md)
of the intended recipient
- `_ctx` - a mutable reference to an instance of the `TxContext`
struct (in this particular case, this parameter is not actually used
Expand Down Expand Up @@ -420,7 +420,7 @@ test the code we have written.
## Testing a package

Sui includes support for the
[Move testing framework](https://github.com/diem/move/blob/main/language/documentation/book/src/unit-testing.md)
[Move testing framework](https://github.com/move-language/move/blob/main/language/documentation/book/src/unit-testing.md)
that allows you to write unit tests to test Move code much like test
frameworks for other languages (e.g., the built-in
[Rust testing framework](https://doc.rust-lang.org/rust-by-example/testing/unit_testing.html)
Expand Down Expand Up @@ -593,7 +593,7 @@ Sui-specific testing is supported via the
[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).
[testing framework](https://github.com/move-language/move/blob/main/language/documentation/book/src/unit-testing.md).
The main concept in the `TestScenario` is a scenario that emulates a
series of Sui transactions, each executed by a (potentially) different
Expand Down
2 changes: 1 addition & 1 deletion doc/src/build/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Objects

The basic unit of storage in Sui is **object**. In contrast to many other blockchains where storage is centered around accounts and each account contains a key-value store, Sui's storage is centered around objects. A smart contract is an object (called **Move Package**), and these smart contracts manipulate **Move objects**:
* *Move Package*: a set of Move bytecode modules. Each module has a name that's unique within the package. The combination of the package ID and the name of a module uniquely identify the module. When we publish smart contracts to Sui, a package is the unit of publishing. Once a package object is published, it is immutable and can never be changed or removed. A package object can depend on other package objects that were previously published to the Sui ledger.
* *Move Object*: typed data governed by a particular Move [*module*](https://github.com/diem/move/blob/main/language/documentation/book/src/modules-and-scripts.md) from a Move package. Each object value is a [struct](https://github.com/diem/move/blob/main/language/documentation/book/src/structs-and-resources.md) with fields that can contain primitive types (e.g. integers, addresses), other objects, and non-object structs. Each object value is mutable and owned by an account address at the time of its creation, but can subsequently be *frozen* and become permanently immutable, or be *shared* and thus become accessible by other addresses.
* *Move Object*: typed data governed by a particular Move [*module*](https://github.com/move-language/move/blob/main/language/documentation/book/src/modules-and-scripts.md) from a Move package. Each object value is a [struct](https://github.com/move-language/move/blob/main/language/documentation/book/src/structs-and-resources.md) with fields that can contain primitive types (e.g. integers, addresses), other objects, and non-object structs. Each object value is mutable and owned by an account address at the time of its creation, but can subsequently be *frozen* and become permanently immutable, or be *shared* and thus become accessible by other addresses.

## Object metadata

Expand Down
4 changes: 2 additions & 2 deletions doc/src/build/programming-with-objects/ch1-object-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct ColorObject has key {
}
```
Now `ColorObject` represents a Sui object type and can be used to create Sui objects that can be eventually stored on the Sui chain.
> :books: In both core Move and Sui Move, the [key ability](https://github.com/diem/move/blob/main/language/documentation/book/src/abilities.md#key) denotes a type that can appear as a key in global storage. However, the structure of global storage is a bit different: core Move uses a (type, `address`)-indexed map, whereas Sui Move uses a map keyed by object IDs.
> :books: In both core Move and Sui Move, the [key ability](https://github.com/move-language/move/blob/main/language/documentation/book/src/abilities.md#key) denotes a type that can appear as a key in global storage. However, the structure of global storage is a bit different: core Move uses a (type, `address`)-indexed map, whereas Sui Move uses a map keyed by object IDs.
> :bulb: The `VersionedID` type is internal to Sui, and you most likely won't need to deal with it directly. For curious readers, it contains the unique `ID` of the object and the version of the object. Each time a mutable object is used in a transaction, its version will increase by 1.
Expand Down Expand Up @@ -54,7 +54,7 @@ public fun transfer<T: key>(obj: T, recipient: address)
```
This places `obj` in global storage along with metadata that records `recipient` as the owner of the object. In Sui, every object must have an owner, which can be either an account address, another object, or "shared"--see [object ownership](../objects.md#object-ownership) for more details.

> :bulb: In core Move, we would call `move_to<T>(a: address, t: T)` to add the entry `(a, T) -> t` to the global storage. But because (as explained above) the schema of Sui Move's global storage is different, we use the `Transfer` APIs instead of `move_to` or the other [global storage operators](https://github.com/diem/move/blob/main/language/documentation/book/src/global-storage-operators.md) in core Move. These operators cannot be used in Sui Move.
> :bulb: In core Move, we would call `move_to<T>(a: address, t: T)` to add the entry `(a, T) -> t` to the global storage. But because (as explained above) the schema of Sui Move's global storage is different, we use the `Transfer` APIs instead of `move_to` or the other [global storage operators](https://github.com/move-language/move/blob/main/language/documentation/book/src/global-storage-operators.md) in core Move. These operators cannot be used in Sui Move.
A common use of this API is to transfer the object to the sender/signer of the current transaction (e.g., mint an NFT owned by you). The only way to obtain the sender of the current transaction is to rely on the transaction context passed in from an entry function. The last argument to an entry function must be the current transaction context, defined as `ctx: &mut TxContext`.
To obtain the current signer's address, one can call `TxContext::sender(ctx)`.
Expand Down
4 changes: 2 additions & 2 deletions doc/src/build/programming-with-objects/ch2-using-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ TestScenario::next_tx(scenario, &owner);
### Pass objects by value
Objects can also be passed by value into an entry function. By doing so, the object is moved out of Sui storage (a.k.a. deleted). It is then up to the Move code to decide where this object should go.

> :books: Since every [Sui object struct type](./ch1-object-basics.md#define-sui-object) must include `VersionedID` as a field, and the [VersionedID struct](https://github.com/MystenLabs/sui/blob/main/sui_programmability/framework/sources/ID.move) does not have the `drop` ability, the Sui object struct type [must not](https://github.com/diem/move/blob/main/language/documentation/book/src/abilities.md#drop) have `drop` ability either. Hence, any Sui object cannot be arbitrarily dropped and must be either consumed or unpacked.
> :books: Since every [Sui object struct type](./ch1-object-basics.md#define-sui-object) must include `VersionedID` as a field, and the [VersionedID struct](https://github.com/MystenLabs/sui/blob/main/sui_programmability/framework/sources/ID.move) does not have the `drop` ability, the Sui object struct type [must not](https://github.com/move-language/move/blob/main/language/documentation/book/src/abilities.md#drop) have `drop` ability either. Hence, any Sui object cannot be arbitrarily dropped and must be either consumed or unpacked.
There are two ways we can deal with a pass-by-value Sui object in Move:

#### Option 1. Delete the object
If the intention is to actually delete the object, we can unpack the object. This can be done only in the module that defined the struct type, due to Move's [privileged struct operations rules](https://github.com/diem/move/blob/main/language/documentation/book/src/structs-and-resources.md#privileged-struct-operations). Upon unpacking, if any field is also of struct type, recursive unpacking and deletion will be required.
If the intention is to actually delete the object, we can unpack the object. This can be done only in the module that defined the struct type, due to Move's [privileged struct operations rules](https://github.com/move-language/move/blob/main/language/documentation/book/src/structs-and-resources.md#privileged-struct-operations). Upon unpacking, if any field is also of struct type, recursive unpacking and deletion will be required.

However, the `id` field of a Sui object requires special handling. We must call the following API in the [ID](https://github.com/MystenLabs/sui/blob/main/sui_programmability/framework/sources/ID.move) module to signal Sui that we intend to delete this object:
```rust
Expand Down
2 changes: 1 addition & 1 deletion doc/src/learn/how-sui-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ Sui smart contracts are written in the [Move language](https://github.com/Mysten

Find a more thorough explanation of Move’s features in:

* the [Move Programming Language book](https://github.com/diem/move/blob/main/language/documentation/book/src/introduction.md)
* the [Move Programming Language book](https://github.com/move-language/move/blob/main/language/documentation/book/src/introduction.md)
* Sui-specific [Move instructions](../build/move.md) and [differences](sui-move-diffs.md) on this site
* the [Sui whitepaper](https://github.com/MystenLabs/sui/blob/main/doc/paper/sui.pdf) and its formal description of Move in the context of Sui
8 changes: 4 additions & 4 deletions doc/src/learn/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ Take note of these related repositories of information to make best use of the k

* [Move & Sui podcast](https://zeroknowledge.fm/228-2/) on Zero Knowledge where programmable objects are described in detail.
* Original [Move Book](https://move-book.com/index.html) written by a member of the Sui team.
* [Core Move](https://github.com/diem/move/tree/main/language/documentation) documentation, including:
* [Tutorial](https://github.com/diem/move/blob/main/language/documentation/tutorial/README.md) - A step-by-step guide through writing a Move module.
* [Book](https://github.com/diem/move/blob/main/language/documentation/book/src/introduction.md) - A summary with pages on [various topics](https://github.com/diem/move/tree/main/language/documentation/book/src).
* [Examples](https://github.com/diem/move/tree/main/language/documentation/examples/experimental) - A set of samples, such as for [defining a coin](https://github.com/diem/move/tree/main/language/documentation/examples/experimental/basic-coin) and [swapping it](https://github.com/diem/move/tree/main/language/documentation/examples/experimental/coin-swap).
* [Core Move](https://github.com/move-language/move/tree/main/language/documentation) documentation, including:
* [Tutorial](https://github.com/move-language/move/blob/main/language/documentation/tutorial/README.md) - A step-by-step guide through writing a Move module.
* [Book](https://github.com/move-language/move/blob/main/language/documentation/book/src/introduction.md) - A summary with pages on [various topics](https://github.com/move-language/move/tree/main/language/documentation/book/src).
* [Examples](https://github.com/move-language/move/tree/main/language/documentation/examples/experimental) - A set of samples, such as for [defining a coin](https://github.com/move-language/move/tree/main/language/documentation/examples/experimental/basic-coin) and [swapping it](https://github.com/move-language/move/tree/main/language/documentation/examples/experimental/coin-swap).
* [Awesome Move](https://github.com/MystenLabs/awesome-move/blob/main/README.md) - A summary of resources related to Move, from blockchains through code samples.
* [Sui API Reference](https://playground.open-rpc.org/?uiSchema%5BappBar%5D%5Bui:splitView%5D=false&schemaUrl=https://raw.githubusercontent.com/MystenLabs/sui/main/sui/open_rpc/spec/openrpc.json&uiSchema%5BappBar%5D%5Bui:input%5D=false) - The reference files for the [Sui JSON-RPC API](../build/json-rpc.md).
Loading

0 comments on commit 619f717

Please sign in to comment.