Skip to main content

Module iota::package_metadata

Package metadata management module An IOTA package can have associated metadata that provides, on-chain, additional information about the package.

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

Structs

struct PackageMetadataKey

Key type for deriving the package metadata object address

public struct PackageMetadataKey has copy, drop, store

Fields

struct PackageMetadataV1

Represents the metadata of a Move package. This includes information such as the storage ID, runtime ID, version, and metadata for the functions contained within the package.

public struct PackageMetadataV1 has key

Fields
id: iota::object::UID
storage_id: iota::object::ID

Storage ID of the package represented by this metadata The object id of the runtime package metadata object is derived from this value.

runtime_id: iota::object::ID

Runtime ID of the package represented by this metadata. Runtime ID is the Storage ID of the first version of a package.

package_version: u64

Version of the package represented by this metadata

modules_metadata: iota::vec_map::VecMap<std::ascii::String, iota::package_metadata::ModuleMetadataV1>

pub modules_metadata_v1

Borrow the module metadata list of the package represented by this metadata. Aborts if the module is not found.

public fun modules_metadata_v1(self: &iota::package_metadata::PackageMetadataV1, module_name: &std::ascii::String): &iota::package_metadata::ModuleMetadataV1

Implementation

public fun modules_metadata_v1(     self: &PackageMetadataV1,     module_name: &ascii::String, ): &ModuleMetadataV1 {     assert!(self.modules_metadata.contains(module_name), EModuleMetadataNotFound);     self.modules_metadata.get(module_name) }

pub package_version

Return the version of the package represented by this metadata

public fun package_version(metadata: &iota::package_metadata::PackageMetadataV1): u64

Implementation

public fun package_version(metadata: &PackageMetadataV1): u64 {     metadata.package_version }

pub runtime_id

Return the runtime ID of the package represented by this metadata

public fun runtime_id(metadata: &iota::package_metadata::PackageMetadataV1): iota::object::ID

Implementation

public fun runtime_id(metadata: &PackageMetadataV1): ID {     metadata.runtime_id }

pub storage_id

Return the storage ID of the package represented by this metadata

public fun storage_id(metadata: &iota::package_metadata::PackageMetadataV1): iota::object::ID

Implementation

public fun storage_id(metadata: &PackageMetadataV1): ID {     metadata.storage_id }

pub try_get_modules_metadata_v1

Safely get the module metadata list of the package represented by this metadata

public fun try_get_modules_metadata_v1(self: &iota::package_metadata::PackageMetadataV1, module_name: &std::ascii::String): std::option::Option<iota::package_metadata::ModuleMetadataV1>

Implementation

public fun try_get_modules_metadata_v1(     self: &PackageMetadataV1,     module_name: &ascii::String, ): Option<ModuleMetadataV1> {     self.modules_metadata.try_get(module_name) }

struct ModuleMetadataV1

Represents metadata associated with a module in the package. V1 includes only the authenticator functions information.

public struct ModuleMetadataV1 has copy, drop, store

Fields
authenticator_metadata: vector<iota::package_metadata::AuthenticatorMetadataV1>

pub authenticator_metadata_v1

Borrow the AuthenticatorMetadataV1 associated with the specified function_name. Aborts if the authenticator metadata is not found for that function.

public fun authenticator_metadata_v1(self: &iota::package_metadata::ModuleMetadataV1, function_name: &std::ascii::String): &iota::package_metadata::AuthenticatorMetadataV1

Implementation

public fun authenticator_metadata_v1(     self: &ModuleMetadataV1,     function_name: &ascii::String, ): &AuthenticatorMetadataV1 {     let mut index = self.authenticator_metadata.find_index!(|m| m.function_name == *function_name);     assert!(index.is_some(), EAuthenticatorMetadataNotFound);     &self.authenticator_metadata[index.extract()] }

pub try_get_authenticator_metadata_v1

Safely get the AuthenticatorMetadataV1 associated with the specified function_name within the module metadata.

public fun try_get_authenticator_metadata_v1(self: &iota::package_metadata::ModuleMetadataV1, function_name: &std::ascii::String): std::option::Option<iota::package_metadata::AuthenticatorMetadataV1>

Implementation

public fun try_get_authenticator_metadata_v1(     self: &ModuleMetadataV1,     function_name: &ascii::String, ): Option<AuthenticatorMetadataV1> {     self.authenticator_metadata.find_index!(|m| m.function_name == *function_name).and!(|index| {         option::some(self.authenticator_metadata[index])     }) }

struct AuthenticatorMetadataV1

Represents metadata for an authenticator within the package. It includes the name of the authenticate function and the TypeName of the first parameter (i.e., the account object type).

public struct AuthenticatorMetadataV1 has copy, drop, store

Fields

pub account_type

Return the account type of the authenticator represented by this metadata

public fun account_type(self: &iota::package_metadata::AuthenticatorMetadataV1): std::type_name::TypeName

Implementation

public fun account_type(self: &AuthenticatorMetadataV1): TypeName {     self.account_type }

Constants

err EModuleMetadataNotFound

#[error] const EModuleMetadataNotFound: vector<u8> = b"The requested module metadata was not found in the package metadata.";

err EAuthenticatorMetadataNotFound

#[error] const EAuthenticatorMetadataNotFound: vector<u8> = b"The requested authenticator metadata was not found in the module metadata.";