spark_sdk/wallet/internal_handlers/implementations/
sync_chain.rs

1// use crate::{
2//     error::SparkSdkError, signer::traits::SparkSigner,
3//     wallet::internal_handlers::traits::sync_chain::SyncChainInternalHandlers, SparkSdk,
4// };
5// use tonic::async_trait;
6
7// #[async_trait]
8// impl<S: SparkSigner + Send + Sync> SyncChainInternalHandlers for SparkSdk<S> {
9//     async fn claim_l1_deposits(&self) -> Result<(), SparkSdkError> {
10//         let spark_client = self.config.spark_config.get_spark_connection(None).await?;
11
12//         let identity_public_key = self.get_identity_public_key();
13
14//         let deposits = spark_client
15//             .query_unused_deposit_addresses(identity_public_key)
16//             .await?;
17
18//         let mut deposit_nodes = Vec::new();
19//         for deposit in deposits.deposit_addresses {
20//             let tx = self.query_mempool_txs(&deposit.deposit_address).await?;
21
22//             if tx.is_none() {
23//                 continue;
24//             }
25
26//             let tx = tx.unwrap();
27//             let (deposit_tx, vout) = (tx.deposit_tx, tx.vout);
28
29//             if let Some(nodes) = self
30//                 .finalize_deposit(
31//                     deposit.user_signing_public_key,
32//                     deposit.verifying_public_key,
33//                     deposit_tx,
34//                     vout,
35//                 )
36//                 .await?
37//             {
38//                 deposit_nodes.extend(nodes);
39//             }
40//         }
41//         Ok(())
42//     }
43// }