From 5aca07f68683f7bc8e136a1ce62738b59e96550f Mon Sep 17 00:00:00 2001 From: Daniel Lam Date: Mon, 8 Apr 2024 17:02:54 +0700 Subject: [PATCH] fix: change `rust` to `move` for code example --- unit-five/lessons/2_hot_potato_pattern.md | 8 ++++---- unit-five/lessons/4_kiosk_basic_usage.md | 8 ++++---- unit-five/lessons/5_transfer_policy.md | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/unit-five/lessons/2_hot_potato_pattern.md b/unit-five/lessons/2_hot_potato_pattern.md index a8fa6eb..e0173ff 100644 --- a/unit-five/lessons/2_hot_potato_pattern.md +++ b/unit-five/lessons/2_hot_potato_pattern.md @@ -4,7 +4,7 @@ A hot potato is a struct that has no capabilities, therefore you can only pack a ## Type Definitions -```rust +```move module flashloan::flashloan { // === Imports === use sui::sui::SUI; @@ -38,7 +38,7 @@ We have a `LoanPool` shared object acting as a money vault ready for users to bo ## Borrow -```rust +```move /// Function allows users to borrow from the loan pool. /// It returns the borrowed [`Coin`] and the [`Loan`] position /// enforcing users to fulfill before the PTB ends. @@ -58,7 +58,7 @@ Users can borrow the money from the `LoanPool` by calling `borrow()`. Basically, ## Repay -```rust +```move /// Repay the loan /// Users must execute this function to ensure the loan is repaid before the transaction ends. public fun repay(pool: &mut LoanPool, loan: Loan, payment: Coin) { @@ -75,7 +75,7 @@ Users at some point must `repay()` the loan before the PTB ends. We consume the Let's try to create an example with flashloan where we borrow some SUI amount, use it to mint a dummy NFT and sell it to repay the debt. We will learn how to use PTB with Sui CLI to execute this all in one transaction. -```rust +```move /// A dummy NFT to represent the flashloan functionality struct NFT has key{ id: UID, diff --git a/unit-five/lessons/4_kiosk_basic_usage.md b/unit-five/lessons/4_kiosk_basic_usage.md index 131197a..2e40e02 100644 --- a/unit-five/lessons/4_kiosk_basic_usage.md +++ b/unit-five/lessons/4_kiosk_basic_usage.md @@ -7,7 +7,7 @@ Let's first deploy the example kiosk smart contract and export the package ID fo export KIOSK_PACKAGE_ID= ``` -```rust +```move module kiosk::kiosk { use sui::kiosk::{Self, Kiosk, KioskOwnerCap}; use sui::tx_context::{TxContext}; @@ -39,7 +39,7 @@ _💡Note: Kiosk is heterogenous collection by default so that's why it doesn't ## Place Item inside Kiosk -```rust +```move struct TShirt has key, store { id: UID, } @@ -60,7 +60,7 @@ We can use `kiosk::place()` API to place an item inside kiosk. Remember that onl ## Withdraw Item from Kiosk -```rust +```move /// Withdraw item from Kiosk public fun withdraw(kiosk: &mut Kiosk, cap: &KioskOwnerCap, item_id: object::ID): TShirt { kiosk::take(kiosk, cap, item_id) @@ -71,7 +71,7 @@ We can use `kiosk::take()` API to withdraw an item from kiosk. Remember that onl ## List Item for Sale -```rust +```move /// List item for sale public fun list(kiosk: &mut Kiosk, cap: &KioskOwnerCap, item_id: object::ID, price: u64) { kiosk::list(kiosk, cap, item_id, price) diff --git a/unit-five/lessons/5_transfer_policy.md b/unit-five/lessons/5_transfer_policy.md index 4229a74..9733cfa 100644 --- a/unit-five/lessons/5_transfer_policy.md +++ b/unit-five/lessons/5_transfer_policy.md @@ -7,7 +7,7 @@ In this section, we will learn how to create a `TransferPolicy` and use it to en `TransferPolicy` for type `T` must be created for that type `T` to be tradeable in the Kiosk system. `TransferPolicy` is a shared object acting as a central authority enforcing everyone to check their purchase is valid against the defined policy before the purchased item is transferred to the buyers. -```rust +```move use sui::tx_context::{TxContext, sender}; use sui::transfer_policy::{Self, TransferRequest, TransferPolicy, TransferPolicyCap}; use sui::package::{Self, Publisher}; @@ -56,7 +56,7 @@ _💡Note: There is a standard approach to implement the rules. Please checkout #### Rule Witness & Rule Config -```rust +```move module kiosk::fixed_royalty_rule { /// The `amount_bp` passed is more than 100%. const EIncorrectArgument: u64 = 0; @@ -83,7 +83,7 @@ module kiosk::fixed_royalty_rule { #### Add Rule to TransferPolicy -```rust +```move /// Function that adds a Rule to the `TransferPolicy`. /// Requires `TransferPolicyCap` to make sure the rules are /// added only by the publisher of T. @@ -108,7 +108,7 @@ sui client call --package $KIOSK_PACKAGE_ID --module fixed_royalty_rule --functi #### Satisfy the Rule -```rust +```move /// Buyer action: Pay the royalty fee for the transfer. public fun pay( policy: &mut TransferPolicy, @@ -145,7 +145,7 @@ We need a helper `fee_amount()` to calculate the royalty fee given the policy an ## Buy Item from Kiosk -```rust +```move use sui::transfer_policy::{Self, TransferRequest, TransferPolicy}; /// Buy listed item