Skip to main content

Module iota::authenticator_function

use iota::address; use iota::hex; use iota::object; use iota::package_metadata; 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;

Struct AuthenticatorFunctionRefV1

Represents a validated authenticate function.

public struct AuthenticatorFunctionRefV1<phantom Account: key> has copy, drop, store

Fields

Constants

#[error] const EAuthenticatorFunctionRefV1NotCompatibleWithAccount: vector<u8> = b"The provided <Link to="../iota/authenticator_function#iota_authenticator_function_AuthenticatorFunctionRefV1">AuthenticatorFunctionRefV1</Link> is not compatible with the account type.";

Function create_auth_function_ref_v1

Create an "AuthenticatorFunctionRefV1" using an authenticate function defined outside of this version of the package

The referred package, module_name, function_name can refer to any valid authenticate function, regardless of package dependencies or versions. For example package A has two versions V1 and V2. V2 of package A may refer to an authenticate function defined in V1. Or it can refer to any package B with an appropriate authenticate function even if package A does not have a dependency on package B. In fact package A may have a dependency on package B version 1, but can still refer to an authenticate function defined in package B version 2. Referring to an authenticate function with create_auth_function_ref_v1 is a strictly runtime dependency and it does not collide with any compile time restrictions.

This function cannot be used in move unit tests as there is no mechanism to refer to the package being tested.

public fun create_auth_function_ref_v1<Account: key>(package_metadata: &iota::package_metadata::PackageMetadataV1, module_name: std::ascii::String, function_name: std::ascii::String): iota::authenticator_function::AuthenticatorFunctionRefV1<Account>

Implementation

public fun create_auth_function_ref_v1<Account: key>( package_metadata: &PackageMetadataV1, module_name: ascii::String, function_name: ascii::String, ): AuthenticatorFunctionRefV1<Account> { let authenticator_metadata = package_metadata .modules_metadata_v1( &module_name, ) .authenticator_metadata_v1(&function_name); assert!( type_name::get<Account>() == authenticator_metadata.account_type(), EAuthenticatorFunctionRefV1NotCompatibleWithAccount, ); AuthenticatorFunctionRefV1 { package: package_metadata.storage_id(), module_name, function_name, } }

Function package

Return the storage ID of the package represented by AuthenticatorFunctionRefV1.

public fun package<Account: key>(self: &iota::authenticator_function::AuthenticatorFunctionRefV1<Account>): iota::object::ID

Implementation

public fun package<Account: key>(self: &AuthenticatorFunctionRefV1<Account>): ID { self.package }

Function module_name

Return the name of the module represented by AuthenticatorFunctionRefV1.

public fun module_name<Account: key>(self: &iota::authenticator_function::AuthenticatorFunctionRefV1<Account>): &std::ascii::String

Implementation

public fun module_name<Account: key>(self: &AuthenticatorFunctionRefV1<Account>): &ascii::String { &self.module_name }

Function function_name

Return the name of the function represented by AuthenticatorFunctionRefV1.

public fun function_name<Account: key>(self: &iota::authenticator_function::AuthenticatorFunctionRefV1<Account>): &std::ascii::String

Implementation

public fun function_name<Account: key>(self: &AuthenticatorFunctionRefV1<Account>): &ascii::String { &self.function_name }