Skip to content

Commit

Permalink
fix: change rust to move for code example
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellam258 committed Apr 8, 2024
1 parent 5801092 commit 5aca07f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions unit-five/lessons/2_hot_potato_pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<SUI>`] and the [`Loan`] position
/// enforcing users to fulfill before the PTB ends.
Expand All @@ -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<SUI>) {
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions unit-five/lessons/4_kiosk_basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Let's first deploy the example kiosk smart contract and export the package ID fo
export KIOSK_PACKAGE_ID=<Package ID of example kiosk smart contract>
```

```rust
```move
module kiosk::kiosk {
use sui::kiosk::{Self, Kiosk, KioskOwnerCap};
use sui::tx_context::{TxContext};
Expand Down Expand Up @@ -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,
}
Expand All @@ -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)
Expand All @@ -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<TShirt>(kiosk, cap, item_id, price)
Expand Down
10 changes: 5 additions & 5 deletions unit-five/lessons/5_transfer_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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<T: key + store>(
policy: &mut TransferPolicy<T>,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5aca07f

Please sign in to comment.