Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
phklive committed Feb 23, 2024
1 parent 3eda77c commit 60b844e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
3 changes: 2 additions & 1 deletion faucet/src/handlers.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::{errors::FaucetError, FaucetState};
use actix_web::{get, http::header, web, HttpResponse, Result};
use miden_client::client::transactions::TransactionTemplate;
use miden_objects::{
accounts::AccountId, assets::FungibleAsset, notes::NoteId, utils::serde::Serializable,
};
use serde::Deserialize;

use crate::{errors::FaucetError, FaucetState};

#[derive(Deserialize)]
struct User {
account_id: String,
Expand Down
34 changes: 12 additions & 22 deletions faucet/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use std::{io, sync::Arc};

use actix_cors::Cors;
use actix_files::Files;
use actix_web::{web, App, HttpServer};
use async_mutex::Mutex;
use clap::Parser;
use cli::Cli;
use handlers::get_tokens;
use miden_client::client::rpc::TonicRpcClient;
use miden_client::client::Client;
use miden_client::config::{ClientConfig, RpcConfig, StoreConfig};
use miden_client::store::data_store::SqliteDataStore;
use miden_client::store::Store;
use miden_client::{
client::{rpc::TonicRpcClient, Client},
config::{ClientConfig, RpcConfig, StoreConfig},
store::{data_store::SqliteDataStore, Store},
};
use miden_objects::accounts::AccountId;
use std::io;
use std::sync::Arc;

mod cli;
mod errors;
Expand Down Expand Up @@ -56,32 +56,24 @@ async fn main() -> std::io::Result<()> {
} => {
amount = *asset_amount;
utils::create_fungible_faucet(token_symbol, decimals, max_supply, &mut client)
}
},
cli::Command::Import {
faucet_path,
asset_amount,
} => {
amount = *asset_amount;
utils::import_fungible_faucet(faucet_path, &mut client)
}
},
}
.map_err(|_| {
io::Error::new(
io::ErrorKind::InvalidData,
"Failed to create faucet account.",
)
})?;
.map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "Failed to create faucet account."))?;

// Sync client
client
.sync_state()
.await
.map_err(|_| io::Error::new(io::ErrorKind::ConnectionRefused, "Failed to sync state."))?;

println!(
"✅ Faucet setup successful, account id: {}",
faucet_account.id()
);
println!("✅ Faucet setup successful, account id: {}", faucet_account.id());

println!("🚀 Starting server on: http://127.0.0.1:8080");

Expand All @@ -93,9 +85,7 @@ async fn main() -> std::io::Result<()> {
};

HttpServer::new(move || {
let cors = Cors::default()
.allow_any_origin()
.allowed_methods(vec!["GET"]);
let cors = Cors::default().allow_any_origin().allowed_methods(vec!["GET"]);
App::new()
.app_data(web::Data::new(faucet_state.clone()))
.wrap(cors)
Expand Down
10 changes: 2 additions & 8 deletions faucet/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ pub fn create_fungible_faucet(
client
.insert_account(&account, account_seed, &AuthInfo::RpoFalcon512(keypair))
.map_err(|_| {
io::Error::new(
io::ErrorKind::InvalidData,
"Failed to insert account into client.",
)
io::Error::new(io::ErrorKind::InvalidData, "Failed to insert account into client.")
})?;

Ok(account)
Expand All @@ -72,10 +69,7 @@ pub fn import_fungible_faucet(
AccountData::read_from_bytes(&contents).expect("Failed to deserialize faucet from file.");

client.import_account(account_data.clone()).map_err(|_| {
io::Error::new(
io::ErrorKind::InvalidData,
"Failed to import account into client.",
)
io::Error::new(io::ErrorKind::InvalidData, "Failed to import account into client.")
})?;

Ok(account_data.account)
Expand Down

0 comments on commit 60b844e

Please sign in to comment.