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, execution_params::GetExecutionParams,
fs::default_config_path, fs::default_config_path,
monero, monero,
monero::{Amount, CreateWallet, GetAddress, OpenWallet}, monero::{Amount, CreateWallet, OpenWallet},
protocol::alice::EventLoop, protocol::alice::EventLoop,
seed::Seed, seed::Seed,
trace::init_tracing, trace::init_tracing,

View File

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

View File

@ -1,7 +1,7 @@
use crate::monero::{ use crate::monero::{
Amount, CreateWallet, CreateWalletForOutput, CreateWalletForOutputThenLoadDefaultWallet, Amount, CreateWallet, CreateWalletForOutput, CreateWalletForOutputThenLoadDefaultWallet,
GetAddress, InsufficientFunds, OpenWallet, PrivateViewKey, PublicViewKey, Refresh, Transfer, InsufficientFunds, OpenWallet, PrivateViewKey, PublicViewKey, Transfer, TransferProof, TxHash,
TransferProof, TxHash, WalletBlockHeight, WatchForTransfer, WatchForTransfer,
}; };
use ::monero::{Address, Network, PrivateKey, PublicKey}; use ::monero::{Address, Network, PrivateKey, PublicKey};
use anyhow::Result; use anyhow::Result;
@ -55,6 +55,19 @@ impl Wallet {
Ok(Amount::from_piconero(amount)) 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] #[async_trait]
@ -233,25 +246,3 @@ impl WatchForTransfer for Wallet {
Ok(()) 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, database::Database,
execution_params::ExecutionParams, execution_params::ExecutionParams,
monero, monero,
monero::{CreateWalletForOutputThenLoadDefaultWallet, WalletBlockHeight}, monero::CreateWalletForOutputThenLoadDefaultWallet,
monero_ext::ScalarExt, monero_ext::ScalarExt,
protocol::{ protocol::{
alice, alice,

View File

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

View File

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