Skip to content

Commit

Permalink
fix: e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhart1o1 committed Jan 21, 2024
1 parent 9a9ef5a commit 1f355cd
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 34 deletions.
10 changes: 4 additions & 6 deletions src/app/file_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ pub fn get_data(file_type: &str) -> Result<Option<String>, AppError> {
if file_path.exists() {
let data = fs::read_to_string(&file_path)
.map_err(|_| TokenError::FailedToReadToken(file_path.clone()))?;
Ok(Some(data))
} else {
Ok(None)
return Ok(Some(data));
}
Ok(None)
}

pub fn save_data(file_type: &str, data: &str) -> Result<(), AppError> {
Expand All @@ -48,8 +47,7 @@ pub fn remove_data(file_type: &str) -> Result<(), AppError> {
if file_path.exists() {
fs::remove_file(&file_path)
.map_err(|_| TokenError::FailedToDeleteFile(file_path.clone()))?;
Ok(())
} else {
Err(AppError::TokenError(TokenError::TokenFileNotFound))
return Ok(());
}
Err(AppError::TokenError(TokenError::TokenFileNotFound))
}
3 changes: 2 additions & 1 deletion src/app/operations/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ impl QueryMeMe {
}

pub fn get_default_wallet_currency(&self) -> Option<&WalletCurrency> {
let default_wallet_id = &self.default_account.id;
#[allow(deprecated)]
let default_wallet_id = &self.default_account.default_wallet_id;
self.default_account
.wallets
.iter()
Expand Down
3 changes: 2 additions & 1 deletion src/app/operations/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ impl App {
wallet_ids: Vec<String>,
) -> anyhow::Result<()> {
let me = self.client.me().await?;
let default_wallet_id = me.default_account.id;
#[allow(deprecated)]
let default_wallet_id = me.default_account.default_wallet_id;
let wallets = &me.default_account.wallets;

let wallet_ids_set: HashSet<_> = wallet_ids.into_iter().collect();
Expand Down
10 changes: 4 additions & 6 deletions src/client/requests/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ impl GaloyClient {

let response = Client::new().post(&url).json(&request_body).send().await;

// TODO status code coming from backend are not appropriate need, will update this when correct status codes are added.
match response {
Ok(resp) => match resp.status() {
StatusCode::OK => Ok(true),
Expand All @@ -151,12 +150,11 @@ impl GaloyClient {
.await
.unwrap_or_else(|_| "Unknown error".to_string());
if error_details.contains("Request failed with status code 400") {
Ok(false)
} else {
Err(ClientError::ApiError(ApiError::RequestFailedWithError(
error_details,
)))
return Ok(false);
}
Err(ClientError::ApiError(ApiError::RequestFailedWithError(
error_details,
)))
}
_ => {
let status = resp.status();
Expand Down
7 changes: 3 additions & 4 deletions src/client/requests/default_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ impl GaloyClient {
.collect::<Vec<String>>()
.join(", ");

Err(ClientError::ApiError(ApiError::RequestFailedWithError(
return Err(ClientError::ApiError(ApiError::RequestFailedWithError(
error_string,
)))
} else {
Ok(())
)));
}
Ok(())
}
}
14 changes: 6 additions & 8 deletions src/client/requests/intraledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ impl GaloyClient {
.collect::<Vec<String>>()
.join(", ");

Err(ClientError::ApiError(ApiError::RequestFailedWithError(
return Err(ClientError::ApiError(ApiError::RequestFailedWithError(
error_string,
)))
} else {
Ok(())
)));
}
Ok(())
}

pub async fn intraleger_send_usd(
Expand Down Expand Up @@ -91,11 +90,10 @@ impl GaloyClient {
.collect::<Vec<String>>()
.join(", ");

Err(ClientError::ApiError(ApiError::RequestFailedWithError(
return Err(ClientError::ApiError(ApiError::RequestFailedWithError(
error_string,
)))
} else {
Ok(())
)));
}
Ok(())
}
}
7 changes: 3 additions & 4 deletions src/client/requests/onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ impl GaloyClient {
.collect::<Vec<String>>()
.join(", ");

Err(ClientError::ApiError(ApiError::RequestFailedWithError(
return Err(ClientError::ApiError(ApiError::RequestFailedWithError(
error_string,
)))
} else {
Ok(())
)));
}
Ok(())
}
}
7 changes: 3 additions & 4 deletions src/client/requests/set_username.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ impl GaloyClient {
.collect::<Vec<String>>()
.join(", ");

Err(ClientError::ApiError(ApiError::RequestFailedWithError(
return Err(ClientError::ApiError(ApiError::RequestFailedWithError(
error_string,
)))
} else {
Ok(())
)));
}
Ok(())
}
}

0 comments on commit 1f355cd

Please sign in to comment.