Skip to content

Commit

Permalink
formatted + reference structure created
Browse files Browse the repository at this point in the history
  • Loading branch information
damirka committed Mar 26, 2024
1 parent b1b28c6 commit 8e6e1c6
Show file tree
Hide file tree
Showing 76 changed files with 339 additions and 233 deletions.
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}
202 changes: 99 additions & 103 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
-->


<!--
comparison to docs.sui.io
Expand Down Expand Up @@ -54,54 +53,54 @@ comparison to docs.sui.io
- [Foreword]() <!-- foreword.md) -->
- [History](history.md)
- [Before we begin](before-we-begin/README.md)
- [Install Sui](before-we-begin/install-sui.md)
- [Set up your IDE](before-we-begin/ide-support.md)
- [Move 2024](before-we-begin/move-2024.md)
- [Install Sui](before-we-begin/install-sui.md)
- [Set up your IDE](before-we-begin/ide-support.md)
- [Move 2024](before-we-begin/move-2024.md)
- [Your First Move](your-first-move/README.md)
- [Hello World!](your-first-move/hello-world.md)
- [Your First Sui App]() <!-- ./hello-sui/README.md) -->
- [Publishing]()
- [Hello Sui!]() <!-- ./hello-sui/hello-sui.md) -->
- [Using Objects]()<!-- (./hello-sui/module-structure.md) -->
- [Adding Tests]() <!-- your-first-move/adding-tests.md) -->
- [Debugging]() <!-- your-first-move/debugging.md) -->
- [Generating Docs]() <!-- your-first-move/generating-docs.md) -->
- [Hello World!](your-first-move/hello-world.md)
- [Your First Sui App]() <!-- ./hello-sui/README.md) -->
- [Publishing]()
- [Hello Sui!]() <!-- ./hello-sui/hello-sui.md) -->
- [Using Objects]()<!-- (./hello-sui/module-structure.md) -->
- [Adding Tests]() <!-- your-first-move/adding-tests.md) -->
- [Debugging]() <!-- your-first-move/debugging.md) -->
- [Generating Docs]() <!-- your-first-move/generating-docs.md) -->
<!-- TODO: -->
<!-- - [Send a Transaction]() -->
- [Concepts](./concepts/README.md)
- [What is a Package](./concepts/packages.md)
- [Manifest](./concepts/manifest.md)
- [Addresses](./concepts/address.md)
- [Module](./concepts/modules.md)
- [Interacting with a Package](./concepts/user-interaction.md)
- [Account](./concepts/what-is-an-account.md)
- [Transaction](./concepts/what-is-a-transaction.md)
- [Object Model](./concepts/object-model.md)
- [What is a Package](./concepts/packages.md)
- [Manifest](./concepts/manifest.md)
- [Addresses](./concepts/address.md)
- [Module](./concepts/modules.md)
- [Interacting with a Package](./concepts/user-interaction.md)
- [Account](./concepts/what-is-an-account.md)
- [Transaction](./concepts/what-is-a-transaction.md)
- [Object Model](./concepts/object-model.md)
- [Syntax Basics](./basic-syntax/README.md)
- [Module](./basic-syntax/module.md)
- [Comments](./basic-syntax/comments.md)
- [Primitive Types](./basic-syntax/primitive-types.md)
- [Address Type](./basic-syntax/address.md)
- [Expression](./basic-syntax/expression.md)
- [Struct](./basic-syntax/struct.md)
- [Ability: Drop](./basic-syntax/drop-ability.md)
- [Importing Modules](./basic-syntax/importing-modules.md)
- [Standard Library](./basic-syntax/standard-library.md)
- [Vector](./basic-syntax/vector.md)
- [Option](./basic-syntax/option.md) <!-- Option requires vector -->
- [String](./basic-syntax/string.md) <!-- String requires vector and option for try_* -->
- [Control Flow](./basic-syntax/control-flow.md)
- [Constants](./basic-syntax/constants.md)
- [Assert and Abort](./basic-syntax/assert-and-abort.md)
- [Function](./basic-syntax/function.md)
- [Struct Methods](./basic-syntax/struct-methods.md)
- [Visibility Modifiers](./basic-syntax/visibility.md)
- [Ownership and Scope](./basic-syntax/ownership-and-scope.md)
- [Ability: Copy](./basic-syntax/copy-ability.md)
- [References](./basic-syntax/references.md)
- [Generics](./basic-syntax/generics.md)
- [Type Reflection](./basic-syntax/type-reflection.md)
- [Testing](./basic-syntax/testing.md)
- [Module](./basic-syntax/module.md)
- [Comments](./basic-syntax/comments.md)
- [Primitive Types](./basic-syntax/primitive-types.md)
- [Address Type](./basic-syntax/address.md)
- [Expression](./basic-syntax/expression.md)
- [Struct](./basic-syntax/struct.md)
- [Ability: Drop](./basic-syntax/drop-ability.md)
- [Importing Modules](./basic-syntax/importing-modules.md)
- [Standard Library](./basic-syntax/standard-library.md)
- [Vector](./basic-syntax/vector.md)
- [Option](./basic-syntax/option.md) <!-- Option requires vector -->
- [String](./basic-syntax/string.md) <!-- String requires vector and option for try_* -->
- [Control Flow](./basic-syntax/control-flow.md)
- [Constants](./basic-syntax/constants.md)
- [Assert and Abort](./basic-syntax/assert-and-abort.md)
- [Function](./basic-syntax/function.md)
- [Struct Methods](./basic-syntax/struct-methods.md)
- [Visibility Modifiers](./basic-syntax/visibility.md)
- [Ownership and Scope](./basic-syntax/ownership-and-scope.md)
- [Ability: Copy](./basic-syntax/copy-ability.md)
- [References](./basic-syntax/references.md)
- [Generics](./basic-syntax/generics.md)
- [Type Reflection](./basic-syntax/type-reflection.md)
- [Testing](./basic-syntax/testing.md)
<!-- - [Enums]() (./basic-syntax/enums.md) -->
<!-- - [Macro Functions]() (./basic-syntax/macro-functions.md) -->
<!--
Expand All @@ -118,70 +117,67 @@ comparison to docs.sui.io
- [Asset Ownership]()
- [Asset Metadata]() -->
- [It starts with an Object](./object/README.md)
- [Ability: Key](./object/key-ability.md)
- [What is an Object]() <!-- (./object/what-is-an-object.md) -->
- [True Ownership]() <!-- (./object/true-ownership.md) -->
- [Transfer Restrictions]() <!-- (./object/transfer-restrictions.md) -->
- [Ability: Store]() <!-- ./object/store-ability.md) -->
- [Shared State]() <!-- (./object/shared-state.md) -->
- [Transfer to Object?]()<!-- (./object/transfer-to-object.md) -->
- [Ability: Key](./object/key-ability.md)
- [What is an Object]() <!-- (./object/what-is-an-object.md) -->
- [True Ownership]() <!-- (./object/true-ownership.md) -->
- [Transfer Restrictions]() <!-- (./object/transfer-restrictions.md) -->
- [Ability: Store]() <!-- ./object/store-ability.md) -->
- [Shared State]() <!-- (./object/shared-state.md) -->
- [Transfer to Object?]()<!-- (./object/transfer-to-object.md) -->
- [Advanced Programmability](./programmability/README.md)
- [Transaction Context](./programmability/transaction-context.md)
- [Module Initializer](./programmability/module-initializer.md)
- [Pattern: Capability](./programmability/capability.md)
- [Epoch and Time](./programmability/epoch-and-time.md)
- [Fast Path](./programmability/fast-path.md)
- [Collections](./programmability/collections.md)
- [Dynamic Fields](./programmability/dynamic-fields.md)
- [Dynamic Object Fields](./programmability/dynamic-object-fields.md)
- [Dynamic Collections](./programmability/dynamic-collections.md)
- [Package Upgrades]()<!-- (./programmability/package-upgrades.md) -->
- [Pattern: Witness]() <!-- ./programmability/witness-pattern.md) <!-- Block: from Witness to Display -->
- [One Time Witness](./programmability/one-time-witness.md)
- [Publisher Authority](./programmability/publisher.md)
- [Display](./programmability/display.md) <!-- End Block: from Witness to Display -->
- [Events](./programmability/events.md)
- [Balance & Coin]() <!-- ./programmability/balance-and-coin.md) -->
- [Sui Framework](./programmability/sui-framework.md)
- [Pattern: Request]() <!-- - [Witness and Abstract Implementation](./programmability/witness-and-abstract-implementation.md) -->
- [Pattern: Hot Potato]()
- [Pattern: Object Capability]()
- [Transaction Blocks]()<!-- (./programmability/transaction-blocks.md) -->
- [Authorization Patterns]()<!-- (./programmability/authorization-patterns.md) -->
- [Cryptography and Hashing]()<!-- (./programmability/cryptography-and-hashing.md) -->
- [Randomness]()<!-- (./programmability/randomness.md) -->
- [BCS](./programmability/bcs.md)
- [Transaction Context](./programmability/transaction-context.md)
- [Module Initializer](./programmability/module-initializer.md)
- [Pattern: Capability](./programmability/capability.md)
- [Epoch and Time](./programmability/epoch-and-time.md)
- [Fast Path](./programmability/fast-path.md)
- [Collections](./programmability/collections.md)
- [Dynamic Fields](./programmability/dynamic-fields.md)
- [Dynamic Object Fields](./programmability/dynamic-object-fields.md)
- [Dynamic Collections](./programmability/dynamic-collections.md)
- [Package Upgrades]()<!-- (./programmability/package-upgrades.md) -->
- [Pattern: Witness]() <!-- ./programmability/witness-pattern.md) <!-- Block: from Witness to Display -->
- [One Time Witness](./programmability/one-time-witness.md)
- [Publisher Authority](./programmability/publisher.md)
- [Display](./programmability/display.md) <!-- End Block: from Witness to Display -->
- [Events](./programmability/events.md)
- [Balance & Coin]() <!-- ./programmability/balance-and-coin.md) -->
- [Sui Framework](./programmability/sui-framework.md)
- [Pattern: Request]() <!-- - [Witness and Abstract Implementation](./programmability/witness-and-abstract-implementation.md) -->
- [Pattern: Hot Potato]()
- [Pattern: Object Capability]()
- [Transaction Blocks]()<!-- (./programmability/transaction-blocks.md) -->
- [Authorization Patterns]()<!-- (./programmability/authorization-patterns.md) -->
- [Cryptography and Hashing]()<!-- (./programmability/cryptography-and-hashing.md) -->
- [Randomness]()<!-- (./programmability/randomness.md) -->
- [BCS](./programmability/bcs.md)
- [Patterns (?)]()
- [Getters and Setters]()
- [Abstract Class]()
- [Hot Potato]()
- [Request]()
- [Object Capability]()
- [Witness Registry]()
- [Getters and Setters]()
- [Abstract Class]()
- [Hot Potato]()
- [Request]()
- [Object Capability]()
- [Witness Registry]()
- [Standards]()
- [Balance]()
- [Coin]()
- [Closed Loop Token]()
- [Transfer Policy]()
- [Kiosk]()
- [Balance]()
- [Coin]()
- [Closed Loop Token]()
- [Transfer Policy]()
- [Kiosk]()
- [Guides](./guides/README.md)
- [2024 Migration Guide](./guides/2024-migration-guide.md)
- [Upgradability Practices](./guides/upgradeability-practices.md)
- [Building against Limits](./guides/building-against-limits.md)
- [Better error handling](./guides/better-error-handling.md)
- [Open-sourcing Libraries]()
- [Testing]()<!-- (./guides/testing.md) -->
- [Debugging]()<!-- (./guides/debugging.md) -->
- [Coding Conventions]()
- [2024 Migration Guide](./guides/2024-migration-guide.md)
- [Upgradability Practices](./guides/upgradeability-practices.md)
- [Building against Limits](./guides/building-against-limits.md)
- [Better error handling](./guides/better-error-handling.md)
- [Open-sourcing Libraries]()
- [Testing]()<!-- (./guides/testing.md) -->
- [Debugging]()<!-- (./guides/debugging.md) -->
- [Coding Conventions]()
- [Appendix]()
- [A - Glossary](./appendix/glossary.md)
- [B - Publications]() <!-- ./appendix/publications.md) -->
- [C - References]() <!-- (./appendix/references.md) -->
- [D - Contributing](./appendix/contributing.md)
- [E - Acknowledgements]() <!-- (./appendix/acknowledgements.md) -->



- [A - Glossary](./appendix/glossary.md)
- [B - Publications]() <!-- ./appendix/publications.md) -->
- [C - References]() <!-- (./appendix/references.md) -->
- [D - Contributing](./appendix/contributing.md)
- [E - Acknowledgements]() <!-- (./appendix/acknowledgements.md) -->

<!-- - [Syntax Basics](basic-syntax/README.md)
- [Module](modules.md)
Expand Down
3 changes: 3 additions & 0 deletions book/src/basic-syntax/address.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ An address literal starts with the `@` symbol followed by a hexadecimal number o
Sui Framework offers a set of helper functions to work with addresses. Given that the address type is a 32 byte value, it can be converted to a `u256` type and vice versa. It can also be converted to and from a `vector<u8>` type.

Example: Convert an address to a `u256` type and back.

```move
{{#include ../../../packages/samples/sources/basic-syntax/address.move:to_u256}}
```

Example: Convert an address to a `vector<u8>` type and back.

```move
{{#include ../../../packages/samples/sources/basic-syntax/address.move:to_bytes}}
```

Example: Convert an address into a string.

```move
{{#include ../../../packages/samples/sources/basic-syntax/address.move:to_string}}
```
2 changes: 0 additions & 2 deletions book/src/basic-syntax/assert-and-abort.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Assert and Abort



<!--
Chapter: Basic Syntax
Expand Down
3 changes: 2 additions & 1 deletion book/src/basic-syntax/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ Infinite loops on their own are not very useful in Move, since every operation i
As we already mentioned, infinite loops are rather useless on their own. And that's where we introduce the `break` and `continue` statements. They are used to exit a loop early, and to skip the rest of the current iteration, respectively.

Syntax for the `break` statement is (without a semicolon):

```move
break
```


The `break` statement is used to stop the execution of a loop and exit it early. It is often used in combination with a conditional statement to exit the loop when a certain condition is met. To illustrate this point, let's turn the infinite `loop` from the previous example into something that looks and behaves more like a `while` loop:

```move
Expand All @@ -124,6 +124,7 @@ Almost identical to the `while` loop, right? The `break` statement is used to ex
The `continue` statement is used to skip the rest of the current iteration and start the next one. Similarly to `break`, it is used in combination with a conditional statement to skip the rest of the iteration when a certain condition is met.

Syntax for the `continue` statement is (without a semicolon):

```move
continue
```
Expand Down
12 changes: 6 additions & 6 deletions book/src/basic-syntax/copy-ability.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Abilities: Copy

In Move, the *copy* ability on a type indicates that the instance or the value of the type can be copied. While this behavior may feel very natural when working with numbers or other simple types, it is not the default for custom types in Move. This is because Move is designed to express digital assets and resources, and inability to copy is a key element of the resource model.
In Move, the _copy_ ability on a type indicates that the instance or the value of the type can be copied. While this behavior may feel very natural when working with numbers or other simple types, it is not the default for custom types in Move. This is because Move is designed to express digital assets and resources, and inability to copy is a key element of the resource model.

However, Move type system allows you to define custom types with the *copy* ability.
However, Move type system allows you to define custom types with the _copy_ ability.

```move
{{#include ../../../packages/samples/sources/basic-syntax/copy-ability.move:copyable}}
```

In the example above, we define a custom type `Copyable` with the *copy* ability. This means that instances of `Copyable` can be copied, both implicitly and explicitly.
In the example above, we define a custom type `Copyable` with the _copy_ ability. This means that instances of `Copyable` can be copied, both implicitly and explicitly.

```move
{{#include ../../../packages/samples/sources/basic-syntax/copy-ability.move:copyable_test}}
```

In the example above, `a` is copied to `b` implicitly, and then explicitly copied to `c` using the dereference operator. If `Copyable` did not have the *copy* ability, the code would not compile, and the Move compiler would raise an error.
In the example above, `a` is copied to `b` implicitly, and then explicitly copied to `c` using the dereference operator. If `Copyable` did not have the _copy_ ability, the code would not compile, and the Move compiler would raise an error.

## Copying and Drop

The `copy` ability is closely related to [`drop` ability](./drop-ability.md). If a type has the *copy* ability, very likely that it should have `drop` too. This is because the *drop* ability is required to clean up the resources when the instance is no longer needed. If a type has only *copy*, then managing its instances gets more complicated, as the values cannot be ignored.
The `copy` ability is closely related to [`drop` ability](./drop-ability.md). If a type has the _copy_ ability, very likely that it should have `drop` too. This is because the _drop_ ability is required to clean up the resources when the instance is no longer needed. If a type has only _copy_, then managing its instances gets more complicated, as the values cannot be ignored.

```move
{{#include ../../../packages/samples/sources/basic-syntax/copy-ability.move:copy_drop}}
```

All of the primitive types in Move behave as if they have the *copy* and *drop* abilities. This means that they can be copied and dropped, and the Move compiler will handle the memory management for them.
All of the primitive types in Move behave as if they have the _copy_ and _drop_ abilities. This means that they can be copied and dropped, and the Move compiler will handle the memory management for them.
Loading

0 comments on commit 8e6e1c6

Please sign in to comment.