Skip to main content

Module sui::address_alias

use std::ascii;
use std::bcs;
use std::option;
use std::string;
use std::vector;
use sui::address;
use sui::derived_object;
use sui::dynamic_field;
use sui::hex;
use sui::object;
use sui::party;
use sui::transfer;
use sui::tx_context;
use sui::vec_map;
use sui::vec_set;

Struct AddressAliasState​

Singleton shared object which manages creation of AddressAliases state.
The actual alias configs are created as derived objects with this object as the parent.

public struct AddressAliasState has key
Click to open
Fields
id: sui::object::UID
version: u64

Struct AddressAliases​

Tracks the set of addresses allowed to act as a given sender.

An alias allows transactions signed by the alias address to act as the original address. For example, if address X sets an alias of address Y, then then a transaction signed by Y can set its sender address to X.

public struct AddressAliases has key
Click to open
Fields
id: sui::object::UID
aliases: sui::vec_set::VecSet<address>

Struct AliasKey​

Internal key used for derivation of AddressAliases object addresses.

public struct AliasKey has copy, drop, store
Click to open
Fields
0: address

Constants​

#[error]
const ENotSystemAddress: vector<u8> = b"Only the system can create the alias state object.";
#[error]
const ENoSuchAlias: vector<u8> = b"Given alias does not exist.";
#[error]
const EAliasAlreadyExists: vector<u8> = b"Alias already exists.";
#[error]
const ECannotRemoveLastAlias: vector<u8> = b"Cannot remove the last alias.";
#[error]
const ETooManyAliases: vector<u8> = b"The number of aliases exceeds the maximum allowed.";
const CURRENT_VERSION: u64 = 0;
const MAX_ALIASES: u64 = 8;

Function create​

Create and share the AddressAliasState object. This function is called exactly once, when the address alias state object is first created.
Can only be called by genesis or change_epoch transactions.

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

Function enable​

Enables address alias configuration for the sender address.

By default, an address is its own alias. The provided AddressAliases object can be used to change the set of allowed aliases after enabling.

entry fun enable(address_alias_state: &mut sui::address_alias::AddressAliasState, ctx: &sui::tx_context::TxContext)

Function add​

Adds the provided address to the set of aliases for the sender.

entry fun add(aliases: &mut sui::address_alias::AddressAliases, alias: address)

Function replace_all​

Overwrites the aliases for the sender's address with the given set.

entry fun replace_all(aliases: &mut sui::address_alias::AddressAliases, new_aliases: vector<address>)

Function remove​

Removes the given alias from the set of aliases for the sender's address.

entry fun remove(aliases: &mut sui::address_alias::AddressAliases, alias: address)