From 72a86430562d2352a31faa4b4b0dd30eaf37b0cf Mon Sep 17 00:00:00 2001 From: Qilol Date: Mon, 5 Feb 2024 00:00:22 -0500 Subject: [PATCH 1/2] Doc update --- .../BCS_encoding/lessons/BCS_encoding.md | 2 +- .../collections/sources/dynamic_fields.move | 2 ++ .../collections/sources/table.move | 2 ++ .../collections/sources/vector.move | 2 ++ .../marketplace/sources/marketplace.move | 14 ++++++++------ .../marketplace/sources/widget.move | 11 +++++++---- unit-four/lessons/1_homogeneous_collections.md | 4 ++-- unit-four/lessons/2_dynamic_fields.md | 4 ++-- unit-four/lessons/3_heterogeneous_collections.md | 2 +- unit-four/lessons/4_marketplace_contract.md | 2 +- unit-four/lessons/5_deployment_and_testing.md | 4 ++-- unit-one/lessons/2_sui_project_structure.md | 2 +- .../generics/sources/generics.move | 1 + unit-three/lessons/1_sui_framework.md | 12 ++++++------ .../4_the_coin_resource_and_create_currency.md | 6 +++--- unit-three/lessons/6_clock_and_locked_coin.md | 6 +++--- unit-two/lessons/1_working_with_sui_objects.md | 3 +++ 17 files changed, 47 insertions(+), 32 deletions(-) diff --git a/advanced-topics/BCS_encoding/lessons/BCS_encoding.md b/advanced-topics/BCS_encoding/lessons/BCS_encoding.md index 692a771..6fe51f0 100644 --- a/advanced-topics/BCS_encoding/lessons/BCS_encoding.md +++ b/advanced-topics/BCS_encoding/lessons/BCS_encoding.md @@ -160,7 +160,7 @@ Now, let's write the function to deserialize an object in a Sui contract. ``` -The varies `peel_*` methods in Sui Frame [`bcs` module](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/bcs.md) are used to "peel" each individual field from the BCS serialized bytes. Note that the order we peel the fields must be exactly the same as the order of the fields in the struct definition. +The varies `peel_*` methods in Sui Frame [`bcs` module](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/bcs.md) are used to "peel" each individual field from the BCS serialized bytes. Note that the order we peel the fields must be exactly the same as the order of the fields in the struct definition. _Quiz: Why are the results not the same from the first two `peel_address` calls on the same `bcs` object?_ diff --git a/unit-four/example_projects/collections/sources/dynamic_fields.move b/unit-four/example_projects/collections/sources/dynamic_fields.move index f138ff5..9684e3a 100644 --- a/unit-four/example_projects/collections/sources/dynamic_fields.move +++ b/unit-four/example_projects/collections/sources/dynamic_fields.move @@ -1,6 +1,8 @@ // Copyright (c) Sui Foundation, Inc. // SPDX-License-Identifier: Apache-2.0 +#[lint_allow(self_transfer)] + module collection::dynamic_fields { use sui::dynamic_object_field as ofield; diff --git a/unit-four/example_projects/collections/sources/table.move b/unit-four/example_projects/collections/sources/table.move index 83bc458..d8c648f 100644 --- a/unit-four/example_projects/collections/sources/table.move +++ b/unit-four/example_projects/collections/sources/table.move @@ -1,6 +1,8 @@ // Copyright (c) Sui Foundation, Inc. // SPDX-License-Identifier: Apache-2.0 +#[allow(unused_field)] + module collection::table { use sui::table::{Table, Self}; diff --git a/unit-four/example_projects/collections/sources/vector.move b/unit-four/example_projects/collections/sources/vector.move index 04843d5..d1030f4 100644 --- a/unit-four/example_projects/collections/sources/vector.move +++ b/unit-four/example_projects/collections/sources/vector.move @@ -1,6 +1,8 @@ // Copyright (c) Sui Foundation, Inc. // SPDX-License-Identifier: Apache-2.0 +#[allow(unused_field)] + module collection::vector { use std::vector; diff --git a/unit-four/example_projects/marketplace/sources/marketplace.move b/unit-four/example_projects/marketplace/sources/marketplace.move index 1cb5b48..5c0f963 100644 --- a/unit-four/example_projects/marketplace/sources/marketplace.move +++ b/unit-four/example_projects/marketplace/sources/marketplace.move @@ -1,8 +1,10 @@ -/// Copyright (c) Sui Foundation, Inc. -/// SPDX-License-Identifier: Apache-2.0 -/// -/// Modified from https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/nfts/sources/marketplace.move +// Copyright (c) Sui Foundation, Inc. +// SPDX-License-Identifier: Apache-2.0 +// Modified from https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/nfts/sources/marketplace.move + + +#[lint_allow(self_transfer)] module marketplace::marketplace { use sui::dynamic_object_field as ofield; use sui::tx_context::{Self, TxContext}; @@ -68,7 +70,7 @@ module marketplace::marketplace { fun delist( marketplace: &mut Marketplace, item_id: ID, - ctx: &mut TxContext + ctx: &TxContext ): T { let Listing { id, @@ -141,7 +143,7 @@ module marketplace::marketplace { /// Internal function to take profits from selling items on the `Marketplace`. fun take_profits( marketplace: &mut Marketplace, - ctx: &mut TxContext + ctx: &TxContext ): Coin { table::remove>(&mut marketplace.payments, tx_context::sender(ctx)) } diff --git a/unit-four/example_projects/marketplace/sources/widget.move b/unit-four/example_projects/marketplace/sources/widget.move index a4a8963..b57c55b 100644 --- a/unit-four/example_projects/marketplace/sources/widget.move +++ b/unit-four/example_projects/marketplace/sources/widget.move @@ -1,7 +1,10 @@ -/// Copyright (c) Sui Foundation, Inc. -/// SPDX-License-Identifier: Apache-2.0 -/// -/// Modified from https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/nfts/sources/marketplace.move +// Copyright (c) Sui Foundation, Inc. +// SPDX-License-Identifier: Apache-2.0 + +// Modified from https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/nfts/sources/marketplace.move + + +#[lint_allow(self_transfer)] module marketplace::widget { diff --git a/unit-four/lessons/1_homogeneous_collections.md b/unit-four/lessons/1_homogeneous_collections.md index 6742e74..0b454e8 100644 --- a/unit-four/lessons/1_homogeneous_collections.md +++ b/unit-four/lessons/1_homogeneous_collections.md @@ -55,11 +55,11 @@ It's important to note that while a vector defined with a generic type can accep ## Table -A `Table` is a map-like collection that dynamically stores key-value pairs. But unlike a traditional map collection, it's keys and values are not stored within the `Table` value, but instead are stored using Sui's object system. The `Table` struct acts only as a handle into the object system to retrieve those keys and values. +A `Table` is a map-like collection that dynamically stores key-value pairs. But unlike a traditional map collection, its keys and values are not stored within the `Table` value, but instead are stored using Sui's object system. The `Table` struct acts only as a handle into the object system to retrieve those keys and values. The `key` type of a `Table` must have the ability constraint of `copy + drop + store`, and the `value` type must have the ability constraint of `store`. -`Table` is also a type of _homogeneous_ collection where the key and value fields can be specified or generic types, but all values and all keys in a `Table` collection must be of the _same_ types. +`Table` is also a type of _homogeneous_ collection where the key and value fields can be specified or generic types, but all values and all keys in a `Table` collection must be of the _same_ type. *Quiz: Would two table objects containing the exact same key-value pairs be equal to each other when checked with the `===` operator? Try it out.* diff --git a/unit-four/lessons/2_dynamic_fields.md b/unit-four/lessons/2_dynamic_fields.md index 76bf8e4..5e7c6fd 100644 --- a/unit-four/lessons/2_dynamic_fields.md +++ b/unit-four/lessons/2_dynamic_fields.md @@ -4,7 +4,7 @@ To peek under how collections like `Table` are actually implemented in Sui Move, There are two sub-types of dynamic fields: - - **Dynamic Fields** can store any value that has the `store` ability, however an object stored in this kind of field will be considered wrapped and will not be accessible directly via its ID by external tools (explorers, wallets, etc) accessing storage. + - **Dynamic Fields** can store any value that has the `store` ability, however, an object stored in this kind of field will be considered wrapped and will not be accessible directly via its ID by external tools (explorers, wallets, etc) accessing storage. - **Dynamic Object Fields** values *must* be Sui objects (have the `key` and `store` abilities, and `id: UID` as the first field), but will still be directly accessible via their object ID after being attached. ## Dynamic Field Operations @@ -142,4 +142,4 @@ For a full explanation of the underlying reason, please check [this forum post]( Now we understand how dynamic fields work, we can think of the `Table` collection as a thin wrapper around dynamic field operations. -You can look through the [source code](https://github.com/MystenLabs/sui/blob/eb866def280bb050838d803f8f72e67e05bf1616/crates/sui-framework/packages/sui-framework/sources/table.move) of the `Table` type in Sui as an exercise, and see how each of the previously introduced operations map to dynamic field operations and with some additional logic to keep track of the size of the `Table`. +You can look through the [source code](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/table.move) of the `Table` type in Sui as an exercise, and see how each of the previously introduced operations map to dynamic field operations and with some additional logic to keep track of the size of the `Table`. diff --git a/unit-four/lessons/3_heterogeneous_collections.md b/unit-four/lessons/3_heterogeneous_collections.md index 335c449..72dcfac 100644 --- a/unit-four/lessons/3_heterogeneous_collections.md +++ b/unit-four/lessons/3_heterogeneous_collections.md @@ -2,7 +2,7 @@ Homogeneous collections like `Vector` and `Table` can work for marketplaces (or other types of applications) where we need to hold a collection of objects of the same type, but what if we need to hold objects of different types, or if we do not know at compile time what types the objects we need to hold are going to be? -For this type of marketplaces, we need to use a _heterogeneous_ collection to hold the items to be sold. Already having done the heavy lifting of understanding dynamic fields, heterogeneous collection in Sui should be very easy to understand. We will look at the `Bag` collection type more closely here. +For this type of marketplace, we need to use a _heterogeneous_ collection to hold the items to be sold. Already having done the heavy lifting of understanding dynamic fields, heterogeneous collection in Sui should be very easy to understand. We will look at the `Bag` collection type more closely here. ## The `Bag` Type diff --git a/unit-four/lessons/4_marketplace_contract.md b/unit-four/lessons/4_marketplace_contract.md index e9204f1..94f102b 100644 --- a/unit-four/lessons/4_marketplace_contract.md +++ b/unit-four/lessons/4_marketplace_contract.md @@ -156,7 +156,7 @@ Buying an item is similar to delisting but with additional logic for handling pa ``` -The first part is the same as delisting an item from listing, but we also check if the payment sent in is the right amount. The second part will insert the payment coin object into our `payments` `Table`, and depending on if the seller already has some balance, it will either do an a simple `table::add` or `table::borrow_mut` and `coin::join` to merge the payment to existing balance. +The first part is the same as delisting an item from listing, but we also check if the payment sent in is the right amount. The second part will insert the payment coin object into our `payments` `Table`, and depending on if the seller already has some balance, it will either do a simple `table::add` or `table::borrow_mut` and `coin::join` to merge the payment to existing balance. The entry function `buy_and_take` simply calls `buy` and transfers the purchased item to the buyer. diff --git a/unit-four/lessons/5_deployment_and_testing.md b/unit-four/lessons/5_deployment_and_testing.md index a2c9223..b88d5e5 100644 --- a/unit-four/lessons/5_deployment_and_testing.md +++ b/unit-four/lessons/5_deployment_and_testing.md @@ -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 10000000 + 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: @@ -106,7 +106,7 @@ Now, let's buy back the item that we just listed: 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`. +You should see a long list of transaction effects in the console after submitting 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`. ### Take Profits diff --git a/unit-one/lessons/2_sui_project_structure.md b/unit-one/lessons/2_sui_project_structure.md index 3b3d025..27f69ec 100644 --- a/unit-one/lessons/2_sui_project_structure.md +++ b/unit-one/lessons/2_sui_project_structure.md @@ -70,7 +70,7 @@ Sui = { local = "../sui/crates/sui-framework/packages/sui-framework" } ## Sui Module and Package Naming -- Sui Move module and package naming convention uses snake casing, i.e. this_is_snake_casing. +- Sui Move module and package naming convention use snake casing, i.e. this_is_snake_casing. - A Sui module name uses the Rust path separator `::` to divide the package name and the module name, examples: 1. `unit_one::hello_world` - `hello_world` module in `unit_one` package diff --git a/unit-three/example_projects/generics/sources/generics.move b/unit-three/example_projects/generics/sources/generics.move index 5d5ff2c..df379e6 100644 --- a/unit-three/example_projects/generics/sources/generics.move +++ b/unit-three/example_projects/generics/sources/generics.move @@ -1,6 +1,7 @@ // Copyright (c) 2022, Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 +#[lint_allow(self_transfer)] /// Basic generics example for Sui Move /// /// A part of the Sui Move intro course: diff --git a/unit-three/lessons/1_sui_framework.md b/unit-three/lessons/1_sui_framework.md index 31638ed..52fe6d5 100644 --- a/unit-three/lessons/1_sui_framework.md +++ b/unit-three/lessons/1_sui_framework.md @@ -4,20 +4,20 @@ A common use case for smart contracts is issuing custom fungible tokens (such as ## Sui Framework -[The Sui Framework](https://github.com/MystenLabs/sui/tree/main/crates/sui-framework/docs) is Sui's specific implementation of the Move VM. It contains Sui's native API's including its implementation of the Move standard library, as well as Sui-specific operations such as [crypto primitives](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/groth16.md) and Sui's implementation of [data structures](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/url.md) at the framework level. +[The Sui Framework](https://github.com/MystenLabs/sui/tree/main/crates/sui-framework/docs) is Sui's specific implementation of the Move VM. It contains Sui's native API's including its implementation of the Move standard library, as well as Sui-specific operations such as [crypto primitives](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/groth16.md) and Sui's implementation of [data structures](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/url.md) at the framework level. An implementation of a custom fungible token in Sui will heavily leverage some of the libraries in the Sui Framework. ## `sui::coin` -The main library we will use to implement a custom fungible token on Sui is the [`sui::coin`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/coin.md) module. +The main library we will use to implement a custom fungible token on Sui is the [`sui::coin`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/coin.md) module. The resources or methods we will directly use in our fungible token example are: -- Resource: [Coin](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/coin.md#resource-coin) -- Resource: [TreasuryCap](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/coin.md#resource-treasurycap) -- Resource: [CoinMetadata](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/coin.md#resource-coinmetadata) -- Method: [coin::create_currency](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/coin.md#function-create_currency) +- Resource: [Coin](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/coin.md#resource-coin) +- Resource: [TreasuryCap](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/coin.md#resource-treasurycap) +- Resource: [CoinMetadata](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/coin.md#resource-coinmetadata) +- Method: [coin::create_currency](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/coin.md#0x2_coin_create_currency) We will revisit each of these in more depth after introducing some new concepts in the next few sections. diff --git a/unit-three/lessons/4_the_coin_resource_and_create_currency.md b/unit-three/lessons/4_the_coin_resource_and_create_currency.md index 49b3d78..d52dd22 100644 --- a/unit-three/lessons/4_the_coin_resource_and_create_currency.md +++ b/unit-three/lessons/4_the_coin_resource_and_create_currency.md @@ -4,7 +4,7 @@ Now we know how generics and witness patterns work, let's revisit the `Coin` res ## The `Coin` Resource -Now we understand how generics work. We can revisit the `Coin` resource from `sui::coin`. It's [defined](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/coin.move#L29) as the following: +Now we understand how generics work. We can revisit the `Coin` resource from `sui::coin`. It's [defined](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/coin.move#L28) as the following: ```rust struct Coin has key, store { @@ -15,7 +15,7 @@ struct Coin has key, store { The `Coin` resource type is a struct that has a generic type `T` and two fields, `id` and `balance`. `id` is of the type `sui::object::UID`, which we have already seen before. -`balance` is of the type [`sui::balance::Balance`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/balance.md#0x2_balance_Balance), and is [defined](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/balance.move#L25) as: +`balance` is of the type [`sui::balance::Balance`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/balance.md#0x2_balance_Balance), and is [defined](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/balance.move#L29) as: ```rust struct Balance has store { @@ -29,7 +29,7 @@ Recall our discussion on [`phantom`](./3_witness_design_pattern.md#the-phantom-k ## The `create_currency` Method -Let's look at what `coin::create_currency` actually does in its [source code](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/coin.move#L251): +Let's look at what `coin::create_currency` actually does in its [source code](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/coin.move#L201): ```rust public fun create_currency( diff --git a/unit-three/lessons/6_clock_and_locked_coin.md b/unit-three/lessons/6_clock_and_locked_coin.md index b9e6465..180d2da 100644 --- a/unit-three/lessons/6_clock_and_locked_coin.md +++ b/unit-three/lessons/6_clock_and_locked_coin.md @@ -4,7 +4,7 @@ In the second fungible token example, we will introduce how to obtain time on-ch ## Clock -Sui Framework has a native [clock module](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/clock.md) that makes timestamps available in Move smart contracts. +Sui Framework has a native [clock module](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/clock.md) that makes timestamps available in Move smart contracts. The main method that you will need to access is the following: @@ -12,9 +12,9 @@ The main method that you will need to access is the following: public fun timestamp_ms(clock: &clock::Clock): u64 ``` -the [`timestamp_ms`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/clock.md#function-timestamp_ms) function returns the current system timestamp, as a running total of milliseconds since an arbitrary point in the past. +the [`timestamp_ms`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/clock.md#0x2_clock_timestamp_ms) function returns the current system timestamp, as a running total of milliseconds since an arbitrary point in the past. -The [`clock`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/clock.md#0x2_clock_Clock) object has a special reserved identifier, `0x6`, that needs to be passed into function calls using it as one of the inputs. +The [`clock`](https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/docs/sui-framework/clock.md#0x2_clock_Clock) object has a special reserved identifier, `0x6`, that needs to be passed into function calls using it as one of the inputs. ## Locked Coin diff --git a/unit-two/lessons/1_working_with_sui_objects.md b/unit-two/lessons/1_working_with_sui_objects.md index 738f70f..ed41582 100644 --- a/unit-two/lessons/1_working_with_sui_objects.md +++ b/unit-two/lessons/1_working_with_sui_objects.md @@ -51,4 +51,7 @@ public fun create_transcript_object(history: u8, math: u8, literature: u8, ctx: } ``` +*💡Note: the provided sample code generates a warning message: warning[Lint W01001]: non-composable transfer to sender. For further details, refer to the article ("Sui Linters and Warnings Update Increases Coder Velocity")[https://blog.sui.io/linter-compile-warnings-update/]* + *💡Note: Move supports field punning, which allows us to skip the field values if the field name happens to be the same as the name of the value variable it is bound to.* + From 41582eba1e2255211cf9cfcb5d4ab15c7a2be756 Mon Sep 17 00:00:00 2001 From: Qilol Date: Mon, 12 Feb 2024 13:43:08 -0500 Subject: [PATCH 2/2] Switch to function level lint --- .../example_projects/collections/sources/dynamic_fields.move | 2 +- unit-four/example_projects/collections/sources/table.move | 2 +- unit-four/example_projects/collections/sources/vector.move | 2 +- .../example_projects/marketplace/sources/marketplace.move | 2 +- unit-four/example_projects/marketplace/sources/widget.move | 2 +- unit-one/example_projects/hello_world/sources/hello_world.move | 2 +- unit-three/example_projects/generics/sources/generics.move | 3 ++- .../example_projects/locked_coin/sources/locked_coin.move | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/unit-four/example_projects/collections/sources/dynamic_fields.move b/unit-four/example_projects/collections/sources/dynamic_fields.move index 9684e3a..3e0a3e6 100644 --- a/unit-four/example_projects/collections/sources/dynamic_fields.move +++ b/unit-four/example_projects/collections/sources/dynamic_fields.move @@ -1,7 +1,6 @@ // Copyright (c) Sui Foundation, Inc. // SPDX-License-Identifier: Apache-2.0 -#[lint_allow(self_transfer)] module collection::dynamic_fields { @@ -92,6 +91,7 @@ module collection::dynamic_fields { object::delete(id); } + #[lint_allow(self_transfer)] // Removes a DOFChild from the parent object and transfer it to the caller public fun reclaim_dofchild(parent: &mut Parent, child_name: vector, ctx: &mut TxContext) { let child = remove_dofchild(parent, child_name); diff --git a/unit-four/example_projects/collections/sources/table.move b/unit-four/example_projects/collections/sources/table.move index d8c648f..b69bc82 100644 --- a/unit-four/example_projects/collections/sources/table.move +++ b/unit-four/example_projects/collections/sources/table.move @@ -1,13 +1,13 @@ // Copyright (c) Sui Foundation, Inc. // SPDX-License-Identifier: Apache-2.0 -#[allow(unused_field)] module collection::table { use sui::table::{Table, Self}; use sui::tx_context::{TxContext}; + #[allow(unused_field)] // Defining a table with specified types for the key and value struct IntegerTable { table_values: Table diff --git a/unit-four/example_projects/collections/sources/vector.move b/unit-four/example_projects/collections/sources/vector.move index d1030f4..bc93662 100644 --- a/unit-four/example_projects/collections/sources/vector.move +++ b/unit-four/example_projects/collections/sources/vector.move @@ -1,7 +1,6 @@ // Copyright (c) Sui Foundation, Inc. // SPDX-License-Identifier: Apache-2.0 -#[allow(unused_field)] module collection::vector { @@ -10,6 +9,7 @@ module collection::vector { struct Widget { } + #[allow(unused_field)] // Vector for a specified type struct WidgetVector { widgets: vector diff --git a/unit-four/example_projects/marketplace/sources/marketplace.move b/unit-four/example_projects/marketplace/sources/marketplace.move index 5c0f963..4598d1c 100644 --- a/unit-four/example_projects/marketplace/sources/marketplace.move +++ b/unit-four/example_projects/marketplace/sources/marketplace.move @@ -4,7 +4,6 @@ // Modified from https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/nfts/sources/marketplace.move -#[lint_allow(self_transfer)] module marketplace::marketplace { use sui::dynamic_object_field as ofield; use sui::tx_context::{Self, TxContext}; @@ -148,6 +147,7 @@ module marketplace::marketplace { table::remove>(&mut marketplace.payments, tx_context::sender(ctx)) } + #[lint_allow(self_transfer)] /// Call [`take_profits`] and transfer Coin object to the sender. public fun take_profits_and_keep( marketplace: &mut Marketplace, diff --git a/unit-four/example_projects/marketplace/sources/widget.move b/unit-four/example_projects/marketplace/sources/widget.move index b57c55b..421a8bc 100644 --- a/unit-four/example_projects/marketplace/sources/widget.move +++ b/unit-four/example_projects/marketplace/sources/widget.move @@ -4,7 +4,6 @@ // Modified from https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/nfts/sources/marketplace.move -#[lint_allow(self_transfer)] module marketplace::widget { @@ -16,6 +15,7 @@ module marketplace::widget { id: UID, } + #[lint_allow(self_transfer)] public fun mint(ctx: &mut TxContext) { let object = Widget { id: object::new(ctx) diff --git a/unit-one/example_projects/hello_world/sources/hello_world.move b/unit-one/example_projects/hello_world/sources/hello_world.move index 66a5ea0..85d1ff4 100644 --- a/unit-one/example_projects/hello_world/sources/hello_world.move +++ b/unit-one/example_projects/hello_world/sources/hello_world.move @@ -1,7 +1,6 @@ // Copyright (c) 2022, Sui Foundation // SPDX-License-Identifier: Apache-2.0 -#[lint_allow(self_transfer)] /// A basic Hello World example for Sui Move, part of the Sui Move intro course: /// https://github.com/sui-foundation/sui-move-intro-course /// @@ -19,6 +18,7 @@ module hello_world::hello_world { text: string::String } + #[lint_allow(self_transfer)] public fun mint(ctx: &mut TxContext) { let object = HelloWorldObject { id: object::new(ctx), diff --git a/unit-three/example_projects/generics/sources/generics.move b/unit-three/example_projects/generics/sources/generics.move index df379e6..b033dc2 100644 --- a/unit-three/example_projects/generics/sources/generics.move +++ b/unit-three/example_projects/generics/sources/generics.move @@ -1,7 +1,6 @@ // Copyright (c) 2022, Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -#[lint_allow(self_transfer)] /// Basic generics example for Sui Move /// /// A part of the Sui Move intro course: @@ -25,10 +24,12 @@ module generics::generics { id: UID, } + #[lint_allow(self_transfer)] public fun create_box(value: T, ctx: &mut TxContext){ transfer::transfer(Box {id: object::new(ctx), value }, tx_context::sender(ctx)) } + #[lint_allow(self_transfer)] public fun create_simple_box(value: u8, ctx: &mut TxContext){ transfer::transfer(SimpleBox {id: object::new(ctx), value }, tx_context::sender(ctx)) } diff --git a/unit-three/example_projects/locked_coin/sources/locked_coin.move b/unit-three/example_projects/locked_coin/sources/locked_coin.move index e44d62e..9182c24 100644 --- a/unit-three/example_projects/locked_coin/sources/locked_coin.move +++ b/unit-three/example_projects/locked_coin/sources/locked_coin.move @@ -1,7 +1,6 @@ // Copyright (c) 2022, Sui Foundation // SPDX-License-Identifier: Apache-2.0 -#[lint_allow(self_transfer)] /// Basic token locking and vesting example for Move on Sui. /// Part of the the Sui Move intro course: /// https://github.com/sui-foundation/sui-move-intro-course @@ -29,6 +28,7 @@ module locked_coin::locked_coin { /// Witness struct LOCKED_COIN has drop {} + #[lint_allow(self_transfer)] /// Withdraw the available vested amount assuming linear vesting /// public fun withdraw_vested(locker: &mut Locker, clock: &Clock, ctx: &mut TxContext){