Skip to main content

Module iota::labeler

Defines a LabelerCap used for creating labels in a iota::timelock::Timelock object. The LabelerCap can be created only be consuming an OTW, making then labels unique for each cap.

use iota::address; use iota::hex; use iota::object; use iota::tx_context; use iota::types; use std::ascii; use std::bcs; use std::option; use std::string; use std::vector;

Struct LabelerCap

LabelerCap allows to create labels of the specific type L. Can be publicly transferred like any other object.

public struct LabelerCap<phantom L> has key, store

Fields

Constants

Error code for when a type passed to the create_labeler_cap function is not a one-time witness.

const ENotOneTimeWitness: u64 = 0;

Function create_labeler_cap

Create a LabelerCap instance. Can be created only by consuming a one time witness.

public fun create_labeler_cap<L: drop>(witness: L, ctx: &mut iota::tx_context::TxContext): iota::labeler::LabelerCap<L>

Implementation

public fun create_labeler_cap<L: drop>(witness: L, ctx: &mut TxContext): LabelerCap<L> { assert!(iota::types::is_one_time_witness(&witness), ENotOneTimeWitness); LabelerCap<L> { id: object::new(ctx), } }

Function destroy_labeler_cap

Delete a LabelerCap instance. If a capability is destroyed, it is impossible to add the related labels.

public fun destroy_labeler_cap<L>(cap: iota::labeler::LabelerCap<L>)

Implementation

public fun destroy_labeler_cap<L>(cap: LabelerCap<L>) { let LabelerCap<L> { id, } = cap; object::delete(id); }