acta-maker-sdk 0.8.2

Rust SDK for the Acta options RFQ venue on Solana: maker and vault-operator WebSocket clients, order signing, chain builders
Documentation
use std::sync::Arc;
use std::time::Duration;

use crate::orders::SignerLike;
use crate::ws::managed::{ChallengeSigning, ManagedWsConfig};
use crate::ws::types::HelloData;

#[derive(Clone)]
pub struct VaultOperatorConfig {
    pub managed: ManagedWsConfig,
    pub request_timeout: Duration,
    pub(super) vault_pda: crate::Address32,
    pub(super) operator: Arc<dyn SignerLike + Send + Sync>,
}

impl VaultOperatorConfig {
    #[must_use]
    pub fn new(
        products: crate::ProductSet,
        url: impl Into<String>,
        hello: HelloData,
        vault_pda: impl Into<crate::Address32>,
        operator: Arc<dyn SignerLike + Send + Sync>,
    ) -> Self {
        let vault_pda = vault_pda.into();
        let managed = ManagedWsConfig::new_with_signing(
            url,
            hello,
            crate::Address32::new(operator.pubkey_bytes()),
            ChallengeSigning::Local(Arc::clone(&operator)),
        )
        .with_vault_auth(vault_pda, products);
        Self {
            managed,
            request_timeout: Duration::from_secs(5),
            vault_pda,
            operator,
        }
    }

    #[must_use]
    pub fn with_managed(mut self, adjust: impl FnOnce(ManagedWsConfig) -> ManagedWsConfig) -> Self {
        self.managed = adjust(self.managed);
        self
    }

    #[must_use]
    pub const fn with_request_timeout(mut self, timeout: Duration) -> Self {
        self.request_timeout = timeout;
        self
    }

    #[must_use]
    pub fn vault_pda(&self) -> &crate::Address32 {
        &self.vault_pda
    }

    #[must_use]
    pub fn operator_pubkey(&self) -> crate::Address32 {
        crate::Address32::new(self.operator.pubkey_bytes())
    }
}