use std::string;
use sui::package;
use sui::table;
Explore this module further in the Mover Registry: @sage/channel
Structs
AppChannelRegistry
Registry that maps all App
s to their respective ChannelRegistry
.
public struct AppChannelRegistry has key
id: sui::object::UID,
registry: sui::table::Table<address, address>
ChannelRegistry
Registry that maps all Channel
s for an App
.
public struct ChannelRegistry has key
id: sui::object::UID,
app: address,
registry: sui::table::Table<std::string::String, address>
Constants
The App
and ChannelRegistry
did not correspond with each other.
const EAppChannelRegistryMismatch: u64 = 370;
Functions
assert_app_channel_registry_match
Aborts with EAppChannelRegistryMismatch
if the App
and ChannelRegistry
do not correspond with each other.
public fun assert_app_channel_registry_match(channel_registry: &ChannelRegistry, app_address: address)
public fun assert_app_channel_registry_match(
channel_registry: &ChannelRegistry,
app_address: address
) {
assert!(app_address == channel_registry.app, EAppChannelRegistryMismatch);
}
borrow_channel_address
Gets address of the Channel
struct with the specified key.
public fun borrow_channel_address(channel_registry: &ChannelRegistry, channel_key: String): address
public fun borrow_channel_address(
channel_registry: &ChannelRegistry,
channel_key: String
): address {
*channel_registry.registry.borrow(channel_key)
}
borrow_channel_registry_address
Gets address of ChannelRegistry
struct with the specified App
address.
public fun borrow_channel_registry_address(app_channel_registry: &AppChannelRegistry, app_address: address): address
public fun borrow_channel_registry_address(
app_channel_registry: &AppChannelRegistry,
app_address: address
): address {
*app_channel_registry.registry.borrow(app_address)
}
has_record
Returns true or false based on whether the lowercase Channel
name currently exists in the registry.
public fun has_record(channel_registry: &ChannelRegistry, channel_key: String): bool
public fun has_record(
channel_registry: &ChannelRegistry,
channel_key: String
): bool {
channel_registry.registry.contains(channel_key)
}
has_channel_registry
Returns true or false based on whether the App
has a ChannelRegistry
.
public fun has_channel_registry(app_channel_registry: &AppChannelRegistry, app_address: address): bool
public fun has_channel_registry(
app_channel_registry: &AppChannelRegistry,
app_address: address
): bool {
app_channel_registry.registry.contains(app_address)
}