Skip to content

Commit

Permalink
chore: refactor anyhow result
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhart1o1 committed Jan 19, 2024
1 parent bd597eb commit e7397c5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/app/operations/globals.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::{Context, Result};
use anyhow::Context;

use crate::app::App;

impl App {
pub async fn globals(&self) -> Result<()> {
pub async fn globals(&self) -> anyhow::Result<()> {
let globals = self
.client
.globals()
Expand Down
4 changes: 2 additions & 2 deletions src/app/operations/intraledger.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{Context, Result};
use anyhow::Context;

use rust_decimal::Decimal;

Expand All @@ -12,7 +12,7 @@ impl App {
cents: Option<Decimal>,
sats: Option<Decimal>,
memo: Option<String>,
) -> Result<()> {
) -> anyhow::Result<()> {
let recipient_wallet_id = self.client.default_wallet(username.clone()).await?;

match (wallet, sats, cents) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/operations/onchain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{Context, Result};
use anyhow::Context;
use rust_decimal::Decimal;

use crate::{
Expand All @@ -14,7 +14,7 @@ impl App {
cents: Option<Decimal>,
sats: Option<Decimal>,
memo: Option<String>,
) -> Result<()> {
) -> anyhow::Result<()> {
match (wallet, sats, cents) {
(Wallet::Btc, Some(sats), _) => {
let btc_wallet_id = self.get_user_btc_wallet_id().await?;
Expand Down
6 changes: 3 additions & 3 deletions src/app/operations/request_code.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{Context, Result};
use anyhow::Context;
use std::net::TcpListener;
use webbrowser;

Expand All @@ -7,7 +7,7 @@ use crate::app::{file_manager, server::server::run, App};
const PORT: u16 = 42909;

impl App {
pub async fn request_phone_code(&self, phone: String) -> Result<()> {
pub async fn request_phone_code(&self, phone: String) -> anyhow::Result<()> {
let listener = TcpListener::bind(format!("127.0.0.1:{}", PORT))?;

let url = format!("http://127.0.0.1:{}/login", PORT);
Expand All @@ -26,7 +26,7 @@ impl App {
.await?
}

pub async fn request_email_code(&self, email: String) -> Result<()> {
pub async fn request_email_code(&self, email: String) -> anyhow::Result<()> {
let result = self
.client
.request_email_code(email)
Expand Down
12 changes: 6 additions & 6 deletions src/app/operations/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;

use anyhow::{Context, Result};
use anyhow::Context;

use crate::{
app::{errors::payment_error::PaymentError, App},
Expand All @@ -11,7 +11,7 @@ use crate::{
};

impl App {
pub async fn default_wallet(&self, username: String) -> Result<()> {
pub async fn default_wallet(&self, username: String) -> anyhow::Result<()> {
let result = self
.client
.default_wallet(username.clone())
Expand All @@ -26,7 +26,7 @@ impl App {
&self,
wallet: Option<Wallet>,
wallet_id: Option<String>,
) -> Result<()> {
) -> anyhow::Result<()> {
let wallet_id = if let Some(wallet_id) = wallet_id {
wallet_id
} else {
Expand Down Expand Up @@ -59,7 +59,7 @@ impl App {
btc: bool,
usd: bool,
wallet_ids: Vec<String>,
) -> Result<()> {
) -> anyhow::Result<()> {
let me = self.client.me().await?;
let default_wallet_id = me.default_account.default_wallet_id;
let wallets = &me.default_account.wallets;
Expand Down Expand Up @@ -95,7 +95,7 @@ impl App {
Ok(())
}

pub async fn get_user_btc_wallet_id(&self) -> Result<String> {
pub async fn get_user_btc_wallet_id(&self) -> anyhow::Result<String> {
let me = self.client.me().await?;
let wallets = me.default_account.wallets;

Expand All @@ -108,7 +108,7 @@ impl App {
Ok(btc_wallet_id)
}

pub async fn get_user_usd_wallet_id(&self) -> Result<String> {
pub async fn get_user_usd_wallet_id(&self) -> anyhow::Result<String> {
let me = self.client.me().await?;
let wallets = me.default_account.wallets;

Expand Down

0 comments on commit e7397c5

Please sign in to comment.