Remove traits in favour of public functions

This commit is contained in:
Daniel Karzel 2021-02-25 10:34:22 +11:00
parent 578d23d7fc
commit 0945cee459
6 changed files with 19 additions and 29 deletions

View File

@ -31,7 +31,7 @@ use swap::{
execution_params::GetExecutionParams,
fs::default_config_path,
monero,
monero::{Amount, CreateWallet, GetAddress, OpenWallet},
monero::{Amount, CreateWallet, OpenWallet},
protocol::alice::EventLoop,
seed::Seed,
trace::init_tracing,

View File

@ -30,7 +30,7 @@ use swap::{
execution_params::GetExecutionParams,
fs::default_config_path,
monero,
monero::{CreateWallet, OpenWallet, WalletBlockHeight},
monero::{CreateWallet, OpenWallet},
protocol::{
bob,
bob::{cancel::CancelError, Builder},

View File

@ -1,7 +1,7 @@
use crate::monero::{
Amount, CreateWallet, CreateWalletForOutput, CreateWalletForOutputThenLoadDefaultWallet,
GetAddress, InsufficientFunds, OpenWallet, PrivateViewKey, PublicViewKey, Refresh, Transfer,
TransferProof, TxHash, WalletBlockHeight, WatchForTransfer,
InsufficientFunds, OpenWallet, PrivateViewKey, PublicViewKey, Transfer, TransferProof, TxHash,
WatchForTransfer,
};
use ::monero::{Address, Network, PrivateKey, PublicKey};
use anyhow::Result;
@ -55,6 +55,19 @@ impl Wallet {
Ok(Amount::from_piconero(amount))
}
pub async fn block_height(&self) -> Result<BlockHeight> {
self.inner.lock().await.block_height().await
}
pub async fn get_main_address(&self) -> Result<Address> {
let address = self.inner.lock().await.get_address(0).await?;
Ok(Address::from_str(address.address.as_str())?)
}
pub async fn refresh(&self) -> Result<Refreshed> {
self.inner.lock().await.refresh().await
}
}
#[async_trait]
@ -233,25 +246,3 @@ impl WatchForTransfer for Wallet {
Ok(())
}
}
#[async_trait]
impl WalletBlockHeight for Wallet {
async fn block_height(&self) -> Result<BlockHeight> {
self.inner.lock().await.block_height().await
}
}
#[async_trait]
impl GetAddress for Wallet {
async fn get_main_address(&self) -> Result<Address> {
let address = self.inner.lock().await.get_address(0).await?;
Ok(Address::from_str(address.address.as_str())?)
}
}
#[async_trait]
impl Refresh for Wallet {
async fn refresh(&self) -> Result<Refreshed> {
self.inner.lock().await.refresh().await
}
}

View File

@ -10,7 +10,7 @@ use crate::{
database::Database,
execution_params::ExecutionParams,
monero,
monero::{CreateWalletForOutputThenLoadDefaultWallet, WalletBlockHeight},
monero::CreateWalletForOutputThenLoadDefaultWallet,
monero_ext::ScalarExt,
protocol::{
alice,

View File

@ -4,7 +4,7 @@ use crate::{
database::{Database, Swap},
execution_params::ExecutionParams,
monero,
monero::{InsufficientFunds, WalletBlockHeight},
monero::InsufficientFunds,
protocol::bob::{self, event_loop::EventLoopHandle, state::*, QuoteRequest},
};
use anyhow::{bail, Result};

View File

@ -21,7 +21,6 @@ use swap::{
execution_params,
execution_params::{ExecutionParams, GetExecutionParams},
monero,
monero::Refresh,
protocol::{alice, alice::AliceState, bob, bob::BobState},
seed::Seed,
};