Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: anyhow result usage #230

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions src/app/server/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
use anyhow::Result;
use anyhow;
use mime_guess::from_path;
use rust_embed::RustEmbed;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -96,7 +96,7 @@ pub async fn run(
phone: String,
api: String,
captcha_challenge_result: CaptchaChallenge,
) -> Result<()> {
) -> anyhow::Result<()> {
let mut tera = Tera::default();
tera.add_raw_template("login.tera.html", include_str!("./public/login.tera.html"))?;

Expand Down
Loading