Skip to content

Commit

Permalink
Fix case in links from Chapter 1 to .move files (MystenLabs#2578)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clay-Mysten authored Jun 16, 2022
1 parent d7063b7 commit e985d98
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/src/build/programming-with-objects/ch1-object-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Color {
}
```
The above `struct` defines a data structure that can represent RGB color. `struct`s like this can be used to organize data with complicated semantics. However, instances of `struct`s like `Color` are not Sui objects yet.
To define a struct that represents a Sui object type, we must add a `key` capability to the definition, and the first field of the struct must be the `id` of the object with type `VersionedID` from the [ID library](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/sources/ID.move):
To define a struct that represents a Sui object type, we must add a `key` capability to the definition, and the first field of the struct must be the `id` of the object with type `VersionedID` from the [ID library](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/sources/id.move):
```rust
use sui::id::VersionedID;

Expand Down Expand Up @@ -50,7 +50,7 @@ fun new(red: u8, green: u8, blue: u8, ctx: &mut TxContext): ColorObject {
### Store Sui object
We have defined a constructor for the `ColorObject`. Calling this constructor will put the value in a local variable where it can be returned from the current function, passed to other functions, or stored inside another struct. And of course, the object can be placed in persistent global storage so it can be read by the outside world and accessed in subsequent transactions.

All of the APIs for adding objects to persistent storage live in the [`Transfer`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/sources/Transfer.move) module. One key API is:
All of the APIs for adding objects to persistent storage live in the [`Transfer`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/sources/transfer.move) module. One key API is:
```rust
public fun transfer<T: key>(obj: T, recipient: address)
```
Expand Down Expand Up @@ -80,7 +80,7 @@ public fun get_color(self: &ColorObject): (u8, u8, u8) {
}
```

Find the full code online in [ColorObject.move](https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/objects_tutorial/sources/ColorObject.move).
Find the full code online in [color_object.move](https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/objects_tutorial/sources/color_object.move).

To compile the code, make sure you have [installed Sui](../install.md) so that `sui-move` is in `PATH`. In the code root directory (where `Move.toml` is), run:
```
Expand Down Expand Up @@ -138,7 +138,7 @@ test_scenario::next_tx(scenario, &owner);
`test_scenario::take_owned` removes the object of given type from global storage that's owned by the current transaction sender (it also implicitly checks `can_take_owned`). If this line of code succeeds, it means that `owner` indeed owns an object of type `ColorObject`.
We also check that the field values of the object match with what we set in creation. At the end, we must return the object back to the global storage by calling `test_scenario::return_owned` so that it's back to the global storage. This also ensures that if any mutations happened to the object during the test, the global storage is aware of the changes.

Again, you can find the full code in [ColorObject.move](https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/objects_tutorial/sources/ColorObject.move).
Again, you can find the full code in [color_object.move](https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/objects_tutorial/sources/color_object.move).

To run the test, simply run the following in the code root directory:
```
Expand Down

0 comments on commit e985d98

Please sign in to comment.