Skip to content

Commit

Permalink
[move examples] add README with summary of available examples, discla…
Browse files Browse the repository at this point in the history
…imer

In addition, move the auction code to `nfts`. That folder was a bit lonely, and auctioning NFT's is a popular use-case that our audience should be familiar with.
  • Loading branch information
sblackshear committed Mar 19, 2022
1 parent f15ac22 commit 7e70f86
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
11 changes: 11 additions & 0 deletions sui_programmability/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Lots of Move code examples, partitioned by category:

* basics: The very simplest examples of Sui programming.
* defi: DeFi primitives like escrows, atomic swaps, flash loans, DEXes.
* fungible_tokens: Implementations of fungible tokens with different minting and burning policies.
* games: Various classic and not-so-classic on-chain games.
* nfts: Example NFT implementations and related functionality like auctions and marketplaces.

We welcome third-party examples--please just submit a pull request!

DISCLAIMER: This is example code provided for demonstration purposes only. These examples have not been thoroughly tested, verified, or audited. Please do not use the example code or derivatives in production without proper diligence.
2 changes: 0 additions & 2 deletions sui_programmability/examples/defi/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# DeFi

* FlashLoan: a flash loan is a loan that must be initiated and repaid during the same transaction. This implementation works for any currency type, and is a good illustration of the power of Move [abilities](https://diem.github.io/move/abilities.html) and the "hot potato" design pattern.
* Auction: example implementation of the [English auction](https://en.wikipedia.org/wiki/English_auction) using single-owner objects only
* SharedAuction: example implementation of the [English auction](https://en.wikipedia.org/wiki/English_auction) using shared objects
* Escrow: an atomic swap leveraging an escrow agent that is trusted for liveness, but not safety (i.e., the agent cannot steal the goods being swapped).
* Uniswap 1.0-style DEX (coming soon).
3 changes: 2 additions & 1 deletion sui_programmability/examples/nfts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Num: Issuing the first ten natural numbers as collectible NFT's.
* Geniteam: NFTs representing collectible monsters and cosmetics used in a farming game.
* Auction: example implementation of an [English auction](https://en.wikipedia.org/wiki/English_auction) using single-owner objects only.
* SharedAuction: example implementation of an [English auction](https://en.wikipedia.org/wiki/English_auction) using shared objects.
* ImageNFT: an NFT wrapping a URL pointing to an image stored off-chain (coming soon).
* Auction: a first-price auction (coming soon).
* Marketplace: An NFT marketplace (coming soon).
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@
/// - otherwise the funds accumulated in the auction go to the
/// original owner and the item goes to the bidder that won the
/// auction
module DeFi::Auction {
module NFTs::Auction {
use Sui::Coin::Coin;
use Sui::GAS::GAS;
use Sui::ID::{Self, ID, VersionedID};
use Sui::Transfer;
use Sui::TxContext::{Self,TxContext};

use DeFi::AuctionLib::{Self, Auction};
use NFTs::AuctionLib::{Self, Auction};


// Error codes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// English auction (https://en.wikipedia.org/wiki/English_auction),
/// one using single-owner objects only and the other using shared
/// objects.
module DeFi::AuctionLib {
module NFTs::AuctionLib {
use Std::Option::{Self, Option};

use Sui::Coin::{Self, Coin};
Expand All @@ -11,8 +11,8 @@ module DeFi::AuctionLib {
use Sui::Transfer;
use Sui::TxContext::{Self,TxContext};

friend DeFi::Auction;
friend DeFi::SharedAuction;
friend NFTs::Auction;
friend NFTs::SharedAuction;

/// Stores information about an auction bid.
struct BidData has store {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
/// - otherwise the funds accumulated in the auction go to the owner
/// and the item goes to the bidder that won the auction
module DeFi::SharedAuction {
module NFTs::SharedAuction {
use Sui::Coin::Coin;
use Sui::GAS::GAS;
use Sui::Transfer;
use Sui::TxContext::{Self,TxContext};

use DeFi::AuctionLib::{Self, Auction};
use NFTs::AuctionLib::{Self, Auction};

// Error codes.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[test_only]
module DeFi::AuctionTests {
module NFTs::AuctionTests {
use Std::Vector;

use Sui::Coin::{Self, Coin};
Expand All @@ -8,8 +8,8 @@ module DeFi::AuctionTests {
use Sui::TestScenario::Self;
use Sui::TxContext::{Self, TxContext};

use DeFi::Auction::{Self, Bid};
use DeFi::AuctionLib::Auction;
use NFTs::Auction::{Self, Bid};
use NFTs::AuctionLib::Auction;

// Error codes.
const EWRONG_ITEM_VALUE: u64 = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[test_only]
module DeFi::SharedAuctionTests {
module NFTs::SharedAuctionTests {
use Std::Vector;

use Sui::Coin::{Self, Coin};
Expand All @@ -8,8 +8,8 @@ module DeFi::SharedAuctionTests {
use Sui::TestScenario::Self;
use Sui::TxContext::{Self, TxContext};

use DeFi::SharedAuction;
use DeFi::AuctionLib::Auction;
use NFTs::SharedAuction;
use NFTs::AuctionLib::Auction;


const COIN_VALUE: u64 = 100;
Expand Down

0 comments on commit 7e70f86

Please sign in to comment.