renegade_sdk/renegade_wallet_client/actions/
get_account_seeds.rs

1//! Get an account's seed CSPRNG states from the relayer
2
3use renegade_darkpool_types::csprng::PoseidonCSPRNG;
4use renegade_external_api::http::account::{GET_ACCOUNT_SEEDS_ROUTE, GetAccountSeedsResponse};
5
6use crate::{RenegadeClientError, actions::construct_http_path, client::RenegadeClient};
7
8impl RenegadeClient {
9    /// Get an account's seed CSPRNG states from the relayer.
10    /// These are the CSPRNGs used to sample seeds with which to create new
11    /// state objects.
12    ///
13    /// Returns a tuple of (recovery stream seeds CSPRNG, share stream seeds
14    /// CSPRNG)
15    // TODO: Store the CSPRNGs in the client behind a Mutex
16    pub async fn get_account_seeds(
17        &self,
18    ) -> Result<(PoseidonCSPRNG, PoseidonCSPRNG), RenegadeClientError> {
19        let path =
20            construct_http_path!(GET_ACCOUNT_SEEDS_ROUTE, "account_id" => self.get_account_id());
21
22        let GetAccountSeedsResponse { recovery_seed_csprng, share_seed_csprng } =
23            self.relayer_client.get(&path).await?;
24
25        Ok((recovery_seed_csprng.into(), share_seed_csprng.into()))
26    }
27}