Skip to content

Commit

Permalink
feat: check code
Browse files Browse the repository at this point in the history
  • Loading branch information
uvd committed Aug 25, 2023
1 parent 6809027 commit 70b32af
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion unit-four/lessons/1_homogeneous_collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Before we delve into the main topic of building a marketplace on Sui, let's learn about collections in Move first.

## Vectors
## vectors

`Vector` in Move is similar to those in other languages such as C++. It's a way to dynamically allocate memory at runtime and manage a group of a single type, which can be a specific type or a [generic type](../../unit-three/lessons/2_intro_to_generics.md).

Expand Down
14 changes: 7 additions & 7 deletions unit-four/lessons/5_deployment_and_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This is basically the Hello World project from Unit One, but made even simpler.
First we publish both the package with:

```bash
sui client publish --gas-budget 3000
sui client publish --gas-budget 10000000
```

You should see both `marketplace` and `widget` modules published on the explorer:
Expand All @@ -49,7 +49,7 @@ Export the package object ID into an environmental variable:
Next, we need to initialize the marketplace contract by calling the `create` entry function. We want to pass it a type argument to specify which type of fungible token this marketplace will accept. It's easiest to just use the `Sui` native token here. We can use the following CLI command:

```bash
sui client call --function create --module marketplace --package $PACKAGE_ID --type-args 0x2::sui::SUI --gas-budget 1000
sui client call --function create --module marketplace --package $PACKAGE_ID --type-args 0x2::sui::SUI --gas-budget 10000000
```

Note the syntax for passing in the type argument for `SUI` token.
Expand All @@ -65,7 +65,7 @@ Export the `Marketplace` shared object's ID into an environmental variable:
First, we mint a `widget` item to be listed:

```bash
sui client call --function mint --module widget --package $PACKAGE_ID --gas-budget 1000
sui client call --function mint --module widget --package $PACKAGE_ID --gas-budget 10000000
```

Save the object item of the minted `widget` to an environmental variable:
Expand All @@ -77,7 +77,7 @@ Save the object item of the minted `widget` to an environmental variable:
Then we list this item to our marketplace:

```bash
sui client call --function list --module marketplace --package $PACKAGE_ID --args $MARKET_ID $ITEM_ID 1 --type-args $PACKAGE_ID::widget::Widget 0x2::sui::SUI --gas-budget 1000
sui client call --function list --module marketplace --package $PACKAGE_ID --args $MARKET_ID $ITEM_ID 1 --type-args $PACKAGE_ID::widget::Widget 0x2::sui::SUI --gas-budget 10000000
```

We need to submit two type arguments here, first is the type of the item to be listed and second is the fungible coin type for the payment. The above example uses a listing price of `1`.
Expand All @@ -91,7 +91,7 @@ After submitting this transaction, you can check the newly created listing on th
Split out a `SUI` coin object of amount `1` to use as the payment object. You can use the `sui client gas` CLI command to see a list of available `SUI` coins under your account and pick one to be split.

```bash
sui client split-coin --coin-id <object ID of the coin to be split> --amounts 1 --gas-budget 1000
sui client split-coin --coin-id <object ID of the coin to be split> --amounts 1 --gas-budget 10000000
```

Export the object ID of the newly split `SUI` coin with balance `1`:
Expand All @@ -105,7 +105,7 @@ _Quiz: As an exercise, modify the marketplace contract to accept any payment tha
Now, let's buy back the item that we just listed:

```bash
sui client call --function buy_and_take --module marketplace --package $PACKAGE_ID --args $MARKET_ID $ITEM_ID $PAYMENT_ID --type-args $PACKAGE_ID::widget::Widget 0x2::sui::SUI --gas-budget 1000
sui client call --function buy_and_take --module marketplace --package $PACKAGE_ID --args $MARKET_ID $ITEM_ID $PAYMENT_ID --type-args $PACKAGE_ID::widget::Widget 0x2::sui::SUI --gas-budget 10000000
```

You should see a long list of transaction effects in the console after submit this transaction. We can verify that the `widget` is owned by our address, and the `payments` `Table` now has an entry with the key of our address and should be of size `1`.
Expand All @@ -115,7 +115,7 @@ You should see a long list of transaction effects in the console after submit th
Finally, we can claim our earnings by calling the `take_profits_and_keep` method:

```bash
sui client call --function take_profits_and_keep --module marketplace --package $PACKAGE_ID --args $MARKET_ID --type-args 0x2::sui::SUI --gas-budget 1000
sui client call --function take_profits_and_keep --module marketplace --package $PACKAGE_ID --args $MARKET_ID --type-args 0x2::sui::SUI --gas-budget 10000000
```

This will reap the balance from the `payments` `Table` object and return its size to `0`. Verify this on the explorer.
2 changes: 1 addition & 1 deletion unit-one/lessons/2_sui_project_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- Module starts with the `module` keyword, which is followed by the module name and curly braces - inside them, module contents are placed:

```rust
module hello_world {
module hello_world::hello_world {
// module contents
}
```
Expand Down
8 changes: 4 additions & 4 deletions unit-one/lessons/3_custom_types_and_abilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Abilities are crucial to defining how objects behave in Sui Move at the language

For now, just know that there are four abilities in Sui Move:

- **Copy**: value can be copied (or cloned by value)
- **Drop**: value can be dropped by the end of the scope
- **Key**: value can be used as a key for global storage operations
- **Store**: value can be stored inside global storage
- **copy**: value can be copied (or cloned by value)
- **drop**: value can be dropped by the end of the scope
- **key**: value can be used as a key for global storage operations
- **store**: value can be stored inside global storage

Custom types that have the abilities `key` and `store` are considered to be **assets** in Sui Move. Assets are stored in global storage and can be transferred between accounts.

Expand Down
16 changes: 8 additions & 8 deletions unit-three/lessons/2_intro_to_generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Let's look at a basic example of how to use generics to create a container `Box`
First, without generics, we can define a `Box` that holds a `u64` type as the following:

```rust
module Storage {
module generics::storage {
struct Box {
value: u64
}
Expand All @@ -23,7 +23,7 @@ module Storage {
However, this type will only be able to hold a value of type `u64`, to make our `Box` able to hold any generic type, we will need to use generics. The code would be modified as following:

```rust
module Storage {
module generics::storage {
struct Box<T> {
value: T
}
Expand All @@ -35,7 +35,7 @@ module Storage {
We can add conditions to enforce that the type passed into the generic must have certain abilities. The syntax looks like the following:

```rust
module Storage {
module generics::storage {
// T must be copyable and droppable
struct Box<T: store + drop> has key, store {
value: T
Expand Down Expand Up @@ -76,10 +76,10 @@ This will only accept inputs of the type `u64` for the `create_box` method, whil
To call a function with a signature that contains generics, we must specify the type in square brackets, as in the following syntax:

```rust
// value will be of type Storage::Box<bool>
let bool_box = Storage::create_box<bool>(true);
// value will be of the type Storage::Box<u64>
let u64_box = Storage::create_box<u64>(1000000);
// value will be of type storage::Box<bool>
let bool_box = storage::create_box<bool>(true);
// value will be of the type storage::Box<u64>
let u64_box = storage::create_box<u64>(1000000);
```

#### Calling Functions with Generics using Sui CLI
Expand All @@ -89,7 +89,7 @@ To call a function with generics in its signature from the Sui CLI, you must def
The following is an example that calls the `create_box` function to create a box that contains a coin of the type `0x2::sui::SUI`:

```bash
sui client call --package $PACKAGE --module $MODULE --function "create_box" --args $OBJECT_ID --type-args 0x2::sui::SUI --gas-budget 10000
sui client call --package $PACKAGE --module $MODULE --function "create_box" --args $OBJECT_ID --type-args 0x2::sui::SUI --gas-budget 10000000
```

## Advanced Generics Syntax
Expand Down
6 changes: 3 additions & 3 deletions unit-three/lessons/5_managed_coin.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The `TreasuryCap` [Capability](../../unit-two/lessons/6_capability_design_patter
Under the [fungible_tokens](../example_projects/fungible_tokens/) project folder, run:

```bash
sui client publish --gas-budget 30000
sui client publish --gas-budget 10000000
```

You should see console output similar to:
Expand All @@ -44,7 +44,7 @@ export TREASURYCAP_ID=<treasury cap object ID from previous output>
To mint some `MNG` tokens, we can use the following CLI command:

```bash
sui client call --function mint --module managed --package $PACKAGE_ID --args $TREASURYCAP_ID \"<amount to mint>\" <recipient address> --gas-budget 3000
sui client call --function mint --module managed --package $PACKAGE_ID --args $TREASURYCAP_ID \"<amount to mint>\" <recipient address> --gas-budget 10000000
```

*💡Note: as of Sui binary version 0.21.0, `u64` inputs must be escaped as strings, thus the above CLI command format. This might change in a future version.*
Expand All @@ -64,7 +64,7 @@ Verify that the `Supply` field under the `TreasuryCap<MANAGED>` object should be
To burn an existing `COIN<MANAGED>` object, we use the following CLI command:

```bash
sui client call --function burn --module managed --package $PACKAGE_ID --args $TREASURYCAP_ID $COIN_ID --gas-budget 3000
sui client call --function burn --module managed --package $PACKAGE_ID --args $TREASURYCAP_ID $COIN_ID --gas-budget 10000000
```

![Burning](../images/burning.png)
Expand Down

0 comments on commit 70b32af

Please sign in to comment.