pub struct HostApi { /* private fields */ }Expand description
Shared host implementation. Handles decoded requests, returns encoded responses.
Implementations§
Source§impl HostApi
impl HostApi
pub fn new() -> Self
Sourcepub fn set_accounts(&mut self, accounts: Vec<Account>)
pub fn set_accounts(&mut self, accounts: Vec<Account>)
Set the accounts that will be returned by host_get_non_product_accounts.
SECURITY: This exposes account identifiers to any product that requests them. Will be replaced by scoped per-product identities via host-sso.
Sourcepub fn set_supported_chains(
&mut self,
chains: impl IntoIterator<Item = [u8; 32]>,
)
pub fn set_supported_chains( &mut self, chains: impl IntoIterator<Item = [u8; 32]>, )
Set the chain genesis hashes that this host supports. Each hash is 32 bytes (raw, not hex-encoded).
Sourcepub fn handle_message(&mut self, raw: &[u8], app_id: &str) -> HostApiOutcome
pub fn handle_message(&mut self, raw: &[u8], app_id: &str) -> HostApiOutcome
Process a raw binary message from the app.
Returns HostApiOutcome::Response for immediate replies,
HostApiOutcome::NeedsSign for sign requests that need wallet approval,
or HostApiOutcome::Silent for fire-and-forget messages.
app_id identifies the product — the host must use this value to scope
storage when acting on NeedsStorageRead, NeedsStorageWrite, and
NeedsStorageClear outcomes. It is not embedded in the outcome itself.