use dynamic_waas_sdk_core::Result;
use tracing::{debug, instrument};
use crate::client::{DynamicWalletClient, DynamicWalletClientOpts};
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct DelegatedWalletClientOpts {
pub environment_id: String,
pub wallet_api_key: String,
pub base_api_url: Option<String>,
pub base_mpc_relay_url: Option<String>,
}
impl DelegatedWalletClientOpts {
pub fn new(environment_id: impl Into<String>, wallet_api_key: impl Into<String>) -> Self {
Self {
environment_id: environment_id.into(),
wallet_api_key: wallet_api_key.into(),
base_api_url: None,
base_mpc_relay_url: None,
}
}
#[must_use]
pub fn base_api_url(mut self, url: impl Into<String>) -> Self {
self.base_api_url = Some(url.into());
self
}
#[must_use]
pub fn base_mpc_relay_url(mut self, url: impl Into<String>) -> Self {
self.base_mpc_relay_url = Some(url.into());
self
}
}
pub struct DelegatedWalletClient {
inner: DynamicWalletClient,
}
impl DelegatedWalletClient {
pub fn new(opts: DelegatedWalletClientOpts) -> Result<Self> {
let wallet_api_key = opts.wallet_api_key.clone();
let inner_opts = DynamicWalletClientOpts {
environment_id: opts.environment_id,
base_api_url: opts.base_api_url,
base_mpc_relay_url: opts.base_mpc_relay_url,
};
let inner = DynamicWalletClient::new_delegated(inner_opts, wallet_api_key)?;
Ok(Self { inner })
}
pub fn inner(&self) -> &DynamicWalletClient {
&self.inner
}
pub fn environment_id(&self) -> &str {
self.inner.environment_id()
}
#[instrument(skip(self), level = "debug")]
pub async fn revoke_delegation(&self, wallet_id: &str) -> Result<()> {
debug!(
wallet_id,
"delegation revoke requested — endpoint is a stub, no API call made"
);
Ok(())
}
}