use moonproof_macros::async_trait;
use crate::error::Result;
use crate::tx_phase::{FinalizedTx, ProvenTx};
use crate::types::{CoinPublicKey, EncPublicKey};
#[async_trait]
pub trait WalletProvider: Send + Sync + std::fmt::Debug {
async fn balance_tx(&self, tx: ProvenTx, ttl_ms: Option<i64>) -> Result<FinalizedTx>;
fn coin_public_key(&self) -> CoinPublicKey;
fn encryption_public_key(&self) -> EncPublicKey;
}
#[async_trait]
impl<T: WalletProvider + ?Sized> WalletProvider for std::sync::Arc<T> {
async fn balance_tx(&self, tx: ProvenTx, ttl_ms: Option<i64>) -> Result<FinalizedTx> {
(**self).balance_tx(tx, ttl_ms).await
}
fn coin_public_key(&self) -> CoinPublicKey {
(**self).coin_public_key()
}
fn encryption_public_key(&self) -> EncPublicKey {
(**self).encryption_public_key()
}
}
#[async_trait]
impl<T: WalletProvider + ?Sized> WalletProvider for Box<T> {
async fn balance_tx(&self, tx: ProvenTx, ttl_ms: Option<i64>) -> Result<FinalizedTx> {
(**self).balance_tx(tx, ttl_ms).await
}
fn coin_public_key(&self) -> CoinPublicKey {
(**self).coin_public_key()
}
fn encryption_public_key(&self) -> EncPublicKey {
(**self).encryption_public_key()
}
}