0xaa::relayer_discovery_v0
RelayerDiscovery_v0
new
set_transaction
remove_transaction
get_transaction
version_control
allow_function
disallow_function
use 0x1::ascii;
use 0x2::object;
use 0x2::table;
use 0x2::tx_context;
use 0xaa::events;
use 0xaa::transaction;
use 0xb0::version_control;
RelayerDiscovery_v0
A central shared object that stores discovery configuration for the Relayer. The Relayer will use this object to discover and execute the transactions when a message is targeted at specific channel.
struct RelayerDiscovery_v0 has store
configurations: table::Table<object::ID, transaction::Transaction>
version_control: version_control::VersionControl
#[error]
const EChannelNotFound: vector<u8> = b"channel not found";
new
public(friend) fun new(version_control: version_control::VersionControl, ctx: &mut tx_context::TxContext): relayer_discovery_v0::RelayerDiscovery_v0
public(package) fun new(
version_control: VersionControl,
ctx: &mut TxContext,
): RelayerDiscovery_v0 {
RelayerDiscovery_v0 {
configurations: table::new<ID, Transaction>(ctx),
version_control,
}
}
set_transaction
public(friend) fun set_transaction(self: &mut relayer_discovery_v0::RelayerDiscovery_v0, id: object::ID, transaction: transaction::Transaction)
public(package) fun set_transaction(
self: &mut RelayerDiscovery_v0,
id: ID,
transaction: Transaction,
) {
if (self.configurations.contains(id)) {
self.configurations.remove(id);
};
self.configurations.add(id, transaction);
events::transaction_registered(id, transaction);
}
remove_transaction
public(friend) fun remove_transaction(self: &mut relayer_discovery_v0::RelayerDiscovery_v0, id: object::ID): transaction::Transaction
public(package) fun remove_transaction(
self: &mut RelayerDiscovery_v0,
id: ID,
): Transaction {
assert!(self.configurations.contains(id), EChannelNotFound);
let tx = self.configurations.remove(id);
events::transaction_removed(id);
tx
}
get_transaction
public(friend) fun get_transaction(self: &relayer_discovery_v0::RelayerDiscovery_v0, id: object::ID): transaction::Transaction
public(package) fun get_transaction(
self: &RelayerDiscovery_v0,
id: ID,
): Transaction {
assert!(self.configurations.contains(id), EChannelNotFound);
self.configurations[id]
}
version_control
public(friend) fun version_control(self: &relayer_discovery_v0::RelayerDiscovery_v0): &version_control::VersionControl
public(package) fun version_control(
self: &RelayerDiscovery_v0,
): &VersionControl {
&self.version_control
}
allow_function
public(friend) fun allow_function(self: &mut relayer_discovery_v0::RelayerDiscovery_v0, version: u64, function_name: ascii::String)
public(package) fun allow_function(
self: &mut RelayerDiscovery_v0,
version: u64,
function_name: String,
) {
self.version_control.allow_function(version, function_name);
}
disallow_function
public(friend) fun disallow_function(self: &mut relayer_discovery_v0::RelayerDiscovery_v0, version: u64, function_name: ascii::String)
public(package) fun disallow_function(
self: &mut RelayerDiscovery_v0,
version: u64,
function_name: String,
) {
self.version_control.disallow_function(version, function_name);
}