diff --git a/crates/sui-framework/docs/stardust/alias.md b/crates/sui-framework/docs/stardust/alias.md index 2866a74843c..5adba9d4333 100644 --- a/crates/sui-framework/docs/stardust/alias.md +++ b/crates/sui-framework/docs/stardust/alias.md @@ -322,7 +322,7 @@ Get the Alias's id. Implementation -
public(package) fun id(self: &mut Alias): &mut UID {
+
public(package) fun id(self: &mut Alias): &mut UID {
     &mut self.id
 }
 
diff --git a/crates/sui-framework/docs/stardust/alias_output.md b/crates/sui-framework/docs/stardust/alias_output.md index 6503af0e98e..aed06e34d51 100644 --- a/crates/sui-framework/docs/stardust/alias_output.md +++ b/crates/sui-framework/docs/stardust/alias_output.md @@ -136,7 +136,7 @@ Other modules in the Stardust package can call this function to receive an Implementation -
public(package) fun receive(parent: &mut UID, output: Receiving<AliasOutput>) : AliasOutput {
+
public(package) fun receive(parent: &mut UID, output: Receiving<AliasOutput>) : AliasOutput {
     transfer::receive(parent, output)
 }
 
diff --git a/crates/sui-framework/docs/stardust/basic_output.md b/crates/sui-framework/docs/stardust/basic_output.md index cacf74e72ef..5ab7def228d 100644 --- a/crates/sui-framework/docs/stardust/basic_output.md +++ b/crates/sui-framework/docs/stardust/basic_output.md @@ -188,7 +188,7 @@ Other modules in the Stardust package can call this function to receive a basic Implementation -
public(package) fun receive(parent: &mut UID, output: Receiving<BasicOutput>) : BasicOutput {
+
public(package) fun receive(parent: &mut UID, output: Receiving<BasicOutput>) : BasicOutput {
     transfer::receive(parent, output)
 }
 
diff --git a/crates/sui-framework/docs/stardust/nft.md b/crates/sui-framework/docs/stardust/nft.md index 45d2c6b8076..5ed57650055 100644 --- a/crates/sui-framework/docs/stardust/nft.md +++ b/crates/sui-framework/docs/stardust/nft.md @@ -4,7 +4,9 @@ title: Module `0x107a::nft` +- [Struct `NFT`](#0x107a_nft_NFT) - [Resource `Nft`](#0x107a_nft_Nft) +- [Function `init`](#0x107a_nft_init) - [Function `destroy`](#0x107a_nft_destroy) - [Function `legacy_sender`](#0x107a_nft_legacy_sender) - [Function `metadata`](#0x107a_nft_metadata) @@ -16,11 +18,44 @@ title: Module `0x107a::nft`
use 0x107a::irc27;
 use 0x1::option;
+use 0x1::string;
+use 0x2::display;
 use 0x2::object;
+use 0x2::package;
+use 0x2::transfer;
+use 0x2::tx_context;
 
+ + +## Struct `NFT` + +One Time Witness. + + +
struct NFT has drop
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ + +
+ ## Resource `Nft` @@ -78,6 +113,75 @@ The Stardust NFT representation. + + + + +## Function `init` + +The Nft module initializer. + + +
fun init(otw: nft::NFT, ctx: &mut tx_context::TxContext)
+
+ + + +
+Implementation + + +
fun init(otw: NFT, ctx: &mut TxContext) {
+    // Claim the module publisher.
+    let publisher = package::claim(otw, ctx);
+
+    // Build a `Display` object.
+    let keys = vector[
+        // The Sui standard fields.
+        string::utf8(b"name"),
+        string::utf8(b"image_url"),
+        string::utf8(b"description"),
+        string::utf8(b"creator"),
+
+        // The extra IRC27-nested fileds.
+        string::utf8(b"version"),
+        string::utf8(b"media_type"),
+        string::utf8(b"collection_name"),
+    ];
+
+    let values = vector[
+        // The Sui standard fields.
+        string::utf8(b"{immutable_metadata.name}"),
+        string::utf8(b"{immutable_metadata.uri}"),
+        string::utf8(b"{immutable_metadata.description}"),
+        string::utf8(b"{immutable_metadata.issuer_name}"),
+
+        // The extra IRC27-nested fileds.
+        string::utf8(b"{immutable_metadata.version}"),
+        string::utf8(b"{immutable_metadata.media_type}"),
+        string::utf8(b"{immutable_metadata.collection_name}"),
+    ];
+
+    let mut display = display::new_with_fields<Nft>(
+        &publisher,
+        keys,
+        values,
+        ctx
+    );
+
+    // Commit the first version of `Display` to apply changes.
+    display.update_version();
+
+    // Burn the publisher object.
+    package::burn_publisher(publisher);
+
+    // Freeze the display object.
+    sui::transfer::public_freeze_object(display);
+}
+
+ + +
@@ -257,7 +361,7 @@ Get the Nft's id. Implementation -
public(package) fun id(self: &mut Nft): &mut UID {
+
public(package) fun id(self: &mut Nft): &mut UID {
     &mut self.id
 }
 
diff --git a/crates/sui-framework/docs/stardust/nft_output.md b/crates/sui-framework/docs/stardust/nft_output.md index 8c0cc0a1f5d..0ed18a67ee2 100644 --- a/crates/sui-framework/docs/stardust/nft_output.md +++ b/crates/sui-framework/docs/stardust/nft_output.md @@ -203,7 +203,7 @@ Other modules in the stardust package can call this function to receive an Implementation -
public(package) fun receive(parent: &mut UID, nft: Receiving<NftOutput>) : NftOutput {
+
public(package) fun receive(parent: &mut UID, nft: Receiving<NftOutput>) : NftOutput {
     transfer::receive(parent, nft)
 }
 
diff --git a/crates/sui-framework/packages/stardust/sources/nft/nft.move b/crates/sui-framework/packages/stardust/sources/nft/nft.move index 9174a4f4628..d5c17921d51 100644 --- a/crates/sui-framework/packages/stardust/sources/nft/nft.move +++ b/crates/sui-framework/packages/stardust/sources/nft/nft.move @@ -3,8 +3,16 @@ module stardust::nft { + use std::string; + + use sui::display; + use sui::package; + use stardust::irc27::{Self, Irc27Metadata}; + /// One Time Witness. + public struct NFT has drop {} + /// The Stardust NFT representation. public struct Nft has key, store { /// The Nft's ID is nested from Stardust. @@ -24,6 +32,55 @@ module stardust::nft { immutable_metadata: Irc27Metadata, } + /// The `Nft` module initializer. + fun init(otw: NFT, ctx: &mut TxContext) { + // Claim the module publisher. + let publisher = package::claim(otw, ctx); + + // Build a `Display` object. + let keys = vector[ + // The Sui standard fields. + string::utf8(b"name"), + string::utf8(b"image_url"), + string::utf8(b"description"), + string::utf8(b"creator"), + + // The extra IRC27-nested fileds. + string::utf8(b"version"), + string::utf8(b"media_type"), + string::utf8(b"collection_name"), + ]; + + let values = vector[ + // The Sui standard fields. + string::utf8(b"{immutable_metadata.name}"), + string::utf8(b"{immutable_metadata.uri}"), + string::utf8(b"{immutable_metadata.description}"), + string::utf8(b"{immutable_metadata.issuer_name}"), + + // The extra IRC27-nested fileds. + string::utf8(b"{immutable_metadata.version}"), + string::utf8(b"{immutable_metadata.media_type}"), + string::utf8(b"{immutable_metadata.collection_name}"), + ]; + + let mut display = display::new_with_fields( + &publisher, + keys, + values, + ctx + ); + + // Commit the first version of `Display` to apply changes. + display.update_version(); + + // Burn the publisher object. + package::burn_publisher(publisher); + + // Freeze the display object. + sui::transfer::public_freeze_object(display); + } + /// Permanently destroy an `Nft` object. public fun destroy(nft: Nft) { let Nft {