Skip to content

Commit

Permalink
update display page
Browse files Browse the repository at this point in the history
  • Loading branch information
damirka committed Nov 5, 2024
1 parent d38f141 commit d6d8b3c
Showing 1 changed file with 48 additions and 43 deletions.
91 changes: 48 additions & 43 deletions docs/content/standards/display.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The following represents the template the `init` function defines:
{
"name": "{name}",
"link": "https://sui-heroes.io/hero/{id}",
"image_url": "ipfs://{image_url}",
"image_url": "https://sui-heroes.io/hero/{image_url}",
"description": "A true Hero of the Sui ecosystem!",
"project_url": "https://sui-heroes.io",
"creator": "Unknown Sui Fan"
Expand All @@ -45,8 +45,7 @@ The following represents the template the `init` function defines:
/// to use it to get the `Display<Hero>` object - a way to describe a
/// type for the ecosystem.
module examples::my_hero {
use sui::tx_context::{sender};
use std::string::{utf8, String};
use std::string::String;
// The creator bundle: these two packages often go together.
use sui::package;
Expand All @@ -71,27 +70,27 @@ module examples::my_hero {
/// set after publishing if a `Publisher` object was created.
fun init(otw: MY_HERO, ctx: &mut TxContext) {
let keys = vector[
utf8(b"name"),
utf8(b"link"),
utf8(b"image_url"),
utf8(b"description"),
utf8(b"project_url"),
utf8(b"creator"),
b"name".to_string(),
b"link".to_string(),
b"image_url".to_string(),
b"description".to_string(),
b"project_url".to_string(),
b"creator".to_string(),
];
let values = vector[
// For `name` one can use the `Hero.name` property
utf8(b"{name}"),
b"{name}".to_string(),
// For `link` one can build a URL using an `id` property
utf8(b"https://sui-heroes.io/hero/{id}"),
b"https://sui-heroes.io/hero/{id}".to_string(),
// For `image_url` use an IPFS template + `image_url` property.
utf8(b"ipfs://{image_url}"),
b"ipfs://{image_url}".to_string(),
// Description is static for all `Hero` objects.
utf8(b"A true Hero of the Sui ecosystem!"),
b"A true Hero of the Sui ecosystem!".to_string(),
// Project URL is usually static
utf8(b"https://sui-heroes.io"),
b"https://sui-heroes.io".to_string(),
// Creator field can be any
utf8(b"Unknown Sui Fan")
b"Unknown Sui Fan".to_string(),
];
// Claim the `Publisher` for the package!
Expand All @@ -103,16 +102,19 @@ module examples::my_hero {
);
// Commit first version of `Display` to apply changes.
display::update_version(&mut display);
display.update_version();
transfer::public_transfer(publisher, sender(ctx));
transfer::public_transfer(display, sender(ctx));
transfer::public_transfer(publisher, ctx.sender());
transfer::public_transfer(display, ctx.sender());
}
/// Anyone can mint their `Hero`!
public fun mint(name: String, image_url: String, ctx: &mut TxContext): Hero {
let id = object::new(ctx);
Hero { id, name, image_url }
Hero {
id: object::new(ctx),
name,
image_url
}
}
}
```
Expand Down Expand Up @@ -170,10 +172,9 @@ The following example demonstrates how to create a capy capability:

```move
module capy::utility {
/// A capability which grants Capy Manager permission to add
/// new genes and manage the Capy Market
struct CapyManagerCap has key, store {
id: UID }
/// A capability which grants Capy Manager permission to add
/// new genes and manage the Capy Market
public struct CapyManagerCap has key, store { id: UID }
}
```

Expand All @@ -186,12 +187,14 @@ The following example demonstrates how to create a Capy:

```move
module capy::capy_items {
/// A wearable Capy item. For some items there can be an
/// unlimited supply. And items with the same name are identical.
struct CapyItem has key, store {
use std::string::String;
/// A wearable Capy item. For some items there can be an
/// unlimited supply. And items with the same name are identical.
public struct CapyItem has key, store {
id: UID,
name: String
}
}
}
```

Expand All @@ -205,13 +208,13 @@ The following example demonstrates how to implement dynamic image generation:

```move
module capy::capy {
/// A Capy - very diverse object with different combination
/// of genes. Created dynamically + for images a dynamic SVG
/// generation is used.
struct Capy has key, store {
id: UID,
genes: vector<u8>
}
/// A Capy - very diverse object with different combination
/// of genes. Created dynamically + for images a dynamic SVG
/// generation is used.
public struct Capy has key, store {
id: UID,
genes: vector<u8>
}
}
```

Expand All @@ -221,13 +224,15 @@ This is the simplest scenario - an object represents everything itself. It is ve

```move
module sui::devnet_nft {
/// A Collectible with a static data. URL, name, description are
/// set only once on a mint event
struct DevNetNFT has key, store {
id: UID,
name: String,
description: String,
url: Url,
}
use std::string::String;
/// A Collectible with a static data. URL, name, description are
/// set only once on a mint event
public struct DevNetNFT has key, store {
id: UID,
name: String,
description: String,
url: String,
}
}
```

0 comments on commit d6d8b3c

Please sign in to comment.