Skip to main content

Module sui::display_registry

use std::address;
use std::ascii;
use std::bcs;
use std::internal;
use std::option;
use std::string;
use std::type_name;
use std::vector;
use sui::accumulator;
use sui::accumulator_settlement;
use sui::address;
use sui::bcs;
use sui::derived_object;
use sui::display;
use sui::dynamic_field;
use sui::event;
use sui::hash;
use sui::hex;
use sui::object;
use sui::package;
use sui::party;
use sui::transfer;
use sui::tx_context;
use sui::types;
use sui::vec_map;

Struct DisplayRegistry

The root of display, to enable derivation of addresses.
The address is system-generated at 0xd

public struct DisplayRegistry has key
Click to open
Fields

Struct SystemMigrationCap

A singleton capability object to enable migrating all V1 displays into V2.

public struct SystemMigrationCap has key
Click to open
Fields

Struct Display

This is the struct that holds the display values for a type T.

public struct Display<phantom T> has key
Click to open
Fields
id: sui::object::UID
fields: sui::vec_map::VecMap<std::string::String, std::string::String>
All the (key,value) entries for a given display object.
cap_id: std::option::Option<sui::object::ID>
The capability object ID. It's Option because legacy Displays will need claiming.

Struct DisplayCap

The capability object that is used to manage the display.

public struct DisplayCap<phantom T> has key, store
Click to open
Fields

Struct DisplayKey

The key used for deriving the instance of Display.

public struct DisplayKey<phantom T> has copy, drop, store

Constants

This is a multi-sig address responsible for the migration of V1 displays into V2.

const SYSTEM_MIGRATION_ADDRESS: address = 0x80e8249451c1a94b0d4ec317d9dd040f11344dcce6f917218086caf2bb1d7bdd;
#[error]
const ENotSystemAddress: vector<u8> = b"This is only callable from system address.";
#[error]
const EDisplayAlreadyExists: vector<u8> = b"Display for the supplied type already exists.";
#[error]
const ECapAlreadyClaimed: vector<u8> = b"Cap for this display object has already been claimed.";
#[error]
const ENotValidPublisher: vector<u8> = b"The publisher is not valid for the supplied type.";
#[error]
const EFieldDoesNotExist: vector<u8> = b"Field does not exist in the display.";
#[error]
const ECapNotClaimed: vector<u8> = b"Cap for this display object has not been claimed so you cannot delete the legacy display yet.";

Function new

Create a new Display object for a given type T using internal::Permit to prove type ownership.

public fun new<T>(registry: &mut sui::display_registry::DisplayRegistry, _: std::internal::Permit<T>, ctx: &mut sui::tx_context::TxContext): (sui::display_registry::Display<T>, sui::display_registry::DisplayCap<T>)

Function new_with_publisher

Create a new display object using the Publisher object.

public fun new_with_publisher<T>(registry: &mut sui::display_registry::DisplayRegistry, publisher: &mut sui::package::Publisher, ctx: &mut sui::tx_context::TxContext): (sui::display_registry::Display<T>, sui::display_registry::DisplayCap<T>)

Function unset

Unset a key from display.

public fun unset<T>(display: &mut sui::display_registry::Display<T>, _: &sui::display_registry::DisplayCap<T>, name: std::string::String)

Function set

Set a value for the specified key, replaces existing value if it exists.

public fun set<T>(display: &mut sui::display_registry::Display<T>, _: &sui::display_registry::DisplayCap<T>, name: std::string::String, value: std::string::String)

Function clear

Clear the display vec_map, allowing a fresh re-creation of fields

public fun clear<T>(display: &mut sui::display_registry::Display<T>, _: &sui::display_registry::DisplayCap<T>)

Function share

Share the Display object to finalize the creation.

public fun share<T>(display: sui::display_registry::Display<T>)

Function claim

Allow a legacy Display holder to claim the capability object.

public fun claim<T: key>(display: &mut sui::display_registry::Display<T>, legacy: sui::display::Display<T>, ctx: &mut sui::tx_context::TxContext): sui::display_registry::DisplayCap<T>

Function claim_with_publisher

Allow claiming a new display using Publisher as proof of ownership.

public fun claim_with_publisher<T: key>(display: &mut sui::display_registry::Display<T>, publisher: &mut sui::package::Publisher, ctx: &mut sui::tx_context::TxContext): sui::display_registry::DisplayCap<T>

Function system_migration

Allow the SystemMigrationCap holder to create display objects with supplied values. The migration is performed once on launch of the DisplayRegistry, further migrations will have to be performed for each object, and will only be possible until legacy display methods are finally deprecated.

public fun system_migration<T: key>(registry: &mut sui::display_registry::DisplayRegistry, _: &sui::display_registry::SystemMigrationCap, keys: vector<std::string::String>, values: vector<std::string::String>, _ctx: &mut sui::tx_context::TxContext)

Function migrate_v1_to_v2

Enables migrating legacy display into the new one, if a new one has not yet been created.

public fun migrate_v1_to_v2<T: key>(registry: &mut sui::display_registry::DisplayRegistry, legacy: sui::display::Display<T>, ctx: &mut sui::tx_context::TxContext): (sui::display_registry::Display<T>, sui::display_registry::DisplayCap<T>)

Function destroy_system_migration_cap

Destroy the SystemMigrationCap after successfully migrating all V1 instances.

entry fun destroy_system_migration_cap(cap: sui::display_registry::SystemMigrationCap)

Function delete_legacy

Allow deleting legacy display objects, as long as the cap has been claimed first.

public fun delete_legacy<T: key>(display: &sui::display_registry::Display<T>, legacy: sui::display::Display<T>)

Function fields

Get a reference to the fields of display.

public fun fields<T>(display: &sui::display_registry::Display<T>): &sui::vec_map::VecMap<std::string::String, std::string::String>

Function cap_id

Get the cap ID for the display.

public fun cap_id<T>(display: &sui::display_registry::Display<T>): std::option::Option<sui::object::ID>

Function migration_cap_receiver

public(package) fun migration_cap_receiver(): address

Function new_display

fun new_display<T>(registry: &mut sui::display_registry::DisplayRegistry, ctx: &mut sui::tx_context::TxContext): (sui::display_registry::Display<T>, sui::display_registry::DisplayCap<T>)

Function create

Create a new display registry object callable only from 0x0 (end of epoch)

fun create(ctx: &mut sui::tx_context::TxContext)