remove unused enum variant

This commit is contained in:
creating2morrow 2023-05-30 05:34:16 -04:00
parent 43cc2ee744
commit 06cab5460e
11 changed files with 88 additions and 81 deletions

View file

@ -374,12 +374,33 @@ impl Order {
pub fn to_db(o: &Order) -> String {
format!(
"{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}",
o.cid, o.pid, o.cust_kex_1, o.cust_kex_2, o.cust_kex_3, o.cust_msig_make,
o.cust_msig_prepare, o.cust_msig_txset, o.date, o.deliver_date,
o.hash, o.mediator_msig_make, o.mediator_msig_prepare, o.mediator_kex_1,
o.mediator_kex_2, o.mediator_kex_3, o.ship_date, o.subaddress, o.status,
o.quantity, o.vend_kex_1, o.vend_kex_2, o.vend_kex_3, o.vend_msig_make,
o.vend_msig_prepare, o.vend_msig_txset, o.xmr_address,
o.cid,
o.pid,
o.cust_kex_1,
o.cust_kex_2,
o.cust_kex_3,
o.cust_msig_make,
o.cust_msig_prepare,
o.cust_msig_txset,
o.date,
o.deliver_date,
o.hash,
o.mediator_msig_make,
o.mediator_msig_prepare,
o.mediator_kex_1,
o.mediator_kex_2,
o.mediator_kex_3,
o.ship_date,
o.subaddress,
o.status,
o.quantity,
o.vend_kex_1,
o.vend_kex_2,
o.vend_kex_3,
o.vend_msig_make,
o.vend_msig_prepare,
o.vend_msig_txset,
o.xmr_address,
)
}
pub fn from_db(k: String, v: String) -> Order {
@ -456,10 +477,7 @@ impl Order {
xmr_address,
}
}
pub fn update(
orid: String,
o: Order,
) -> Order {
pub fn update(orid: String, o: Order) -> Order {
Order {
orid,
cid: String::from(&o.cid),

View file

@ -30,7 +30,6 @@ enum RpcFields {
CreateWallet,
ExchangeMultisigKeys,
Export,
Finalize,
GetTxProof,
GetTxById,
GetVersion,
@ -58,7 +57,6 @@ impl RpcFields {
RpcFields::CreateWallet => String::from("create_wallet"),
RpcFields::ExchangeMultisigKeys => String::from("exchange_multisig_keys"),
RpcFields::Export => String::from("export_multisig_info"),
RpcFields::Finalize => String::from("finalize_multisig"),
RpcFields::GetTxProof => String::from("get_tx_proof"),
RpcFields::GetTxById => String::from("get_transfer_by_txid"),
RpcFields::GetVersion => String::from("get_version"),
@ -400,10 +398,7 @@ pub async fn close_wallet(filename: String, password: String) -> bool {
info!("executing {}", RpcFields::Close.value());
let client = reqwest::Client::new();
let host = get_rpc_host();
let params = reqres::XmrRpcOpenWalletParams {
filename,
password,
};
let params = reqres::XmrRpcOpenWalletParams { filename, password };
let req = reqres::XmrRpcOpenRequest {
jsonrpc: RpcFields::JsonRpcVersion.value(),
id: RpcFields::Id.value(),

View file

@ -419,8 +419,8 @@ pub async fn start_up() {
// wait for rpc server for a bit
tokio::time::sleep(std::time::Duration::new(5, 0)).await;
monero::check_rpc_connection().await;
let wallet_password = std::env::var(crate::MONERO_WALLET_PASSWORD)
.unwrap_or(String::from("password"));
let wallet_password =
std::env::var(crate::MONERO_WALLET_PASSWORD).unwrap_or(String::from("password"));
gen_app_wallet(&wallet_password).await;
i2p::start().await;
gen_app_gpg().await;

View file

@ -1,11 +1,18 @@
use rocket::http::Status;
use rocket::response::status::Custom;
use rocket::serde::json::Json;
use rocket::{get, patch, post};
use rocket::{
get,
http::Status,
patch,
post,
response::status::Custom,
serde::json::Json,
};
use nevmes_core::*;
use crate::{dispute, product};
use crate::{
dispute,
product,
};
// JSON APIs
@ -16,24 +23,18 @@ pub async fn create_product(
_token: auth::BearerToken,
) -> Custom<Json<models::Product>> {
let m_product: models::Product = product::create(req_product);
Custom(
Status::Ok,
Json(m_product),
)
Custom(Status::Ok, Json(m_product))
}
/// Update product information
#[patch("/<_address>/update", data="<product>")]
#[patch("/<_address>/update", data = "<product>")]
pub async fn update_product(
_address: String,
product: Json<models::Product>,
_token: auth::BearerToken,
) -> Custom<Json<models::Product>> {
let m_product: models::Product = product::modify(product);
Custom(
Status::Ok,
Json(m_product),
)
Custom(Status::Ok, Json(m_product))
}
// /// Initialize order
@ -89,22 +90,13 @@ pub async fn create_dispute(
_token: auth::BearerToken,
) -> Custom<Json<models::Dispute>> {
let m_dispute: models::Dispute = dispute::create(dispute);
Custom(
Status::Ok,
Json(m_dispute),
)
Custom(Status::Ok, Json(m_dispute))
}
/// Create a dispute
#[get("/<did>")]
pub async fn get_dispute(
_token: auth::BearerToken,
did: String,
) -> Custom<Json<models::Dispute>> {
pub async fn get_dispute(_token: auth::BearerToken, did: String) -> Custom<Json<models::Dispute>> {
let m_dispute: models::Dispute = dispute::find(&did);
Custom(
Status::Ok,
Json(m_dispute),
)
Custom(Status::Ok, Json(m_dispute))
}
// END JSON APIs

View file

@ -1,6 +1,14 @@
use nevmes_core::{db, models::*, utils};
use log::{
debug,
error,
info,
};
use nevmes_core::{
db,
models::*,
utils,
};
use rocket::serde::json::Json;
use log::{debug, error, info};
/// Create a new dispute
pub fn create(d: Json<Dispute>) -> Dispute {
@ -25,7 +33,7 @@ pub fn find(did: &String) -> Dispute {
let r = db::Interface::read(&s.env, &s.handle, &String::from(did));
if r == utils::empty_string() {
error!("dispute not found");
return Default::default()
return Default::default();
}
Dispute::from_db(String::from(did), r)
}

View file

@ -15,8 +15,14 @@ async fn rocket() -> _ {
env_logger::init();
log::info!("nevmes-auth is online");
rocket::custom(&config)
.mount("/dispute", routes![controller::create_dispute, controller::get_dispute])
.mount(
"/dispute",
routes![controller::create_dispute, controller::get_dispute],
)
// .mount("/order", routes![controller::initialize_order, controller::update_order])
// .mount("/orders", routes![controller::get_orders])
.mount("/product", routes![controller::create_product, controller::update_product])
.mount(
"/product",
routes![controller::create_product, controller::update_product],
)
}

View file

@ -21,7 +21,6 @@
// }
// }
// /// Create a skeleton for order
// pub fn create(cid: String, pid: String) -> models::Order {
// let ts = chrono::offset::Utc::now().timestamp();
@ -78,7 +77,6 @@
// new_order
// }
// /// Lookup order
// pub fn find(oid: String) -> models::Order {
// let s = db::Interface::open();

View file

@ -1,6 +1,14 @@
// Product repo/service layer
use nevmes_core::{db, models::*, utils};
use log::{debug, error, info};
use log::{
debug,
error,
info,
};
use nevmes_core::{
db,
models::*,
utils,
};
use rocket::serde::json::Json;
/// Create a new product
@ -26,7 +34,10 @@ pub fn create(d: Json<Product>) -> Product {
debug!("creating product index");
}
let product_list = [r, String::from(&pid)].join(",");
debug!("writing product index {} for id: {}", product_list, list_key);
debug!(
"writing product index {} for id: {}",
product_list, list_key
);
db::Interface::write(&s.env, &s.handle, &String::from(list_key), &product_list);
new_product
}

View file

@ -21,21 +21,6 @@ pub async fn get_version(_jwp: proof::PaymentProof) -> Custom<Json<reqres::XmrRp
Custom(Status::Ok, Json(monero::get_version().await))
}
#[get("/test")]
pub async fn test() -> Custom<Json<models::User>> {
let mut v: Vec<String> = Vec::new();
v.push("t1".to_string());
v.push("t2".to_string());
v.push("t3".to_string());
let u: models::User = models::User {
uid: v.remove(0),
xmr_address: v.remove(0),
name: v.remove(0),
};
Custom(Status::Ok, Json(u))
}
/// If i2p not in the state of rejecting tunnels this will return `open: true`
///
/// Protected: false
@ -97,12 +82,7 @@ pub async fn gen_jwp(proof: Json<proof::TxProof>) -> Custom<Json<reqres::Jwp>> {
///
/// Protected: true
#[get("/products")]
pub async fn get_products(
_jwp: proof::PaymentProof,
) -> Custom<Json<Vec<models::Product>>> {
pub async fn get_products(_jwp: proof::PaymentProof) -> Custom<Json<Vec<models::Product>>> {
let m_products: Vec<models::Product> = product::find_all();
Custom(
Status::Ok,
Json(m_products),
)
Custom(Status::Ok, Json(m_products))
}

View file

@ -59,5 +59,4 @@ async fn rocket() -> _ {
.mount("/i2p", routes![controller::get_i2p_status])
.mount("/xmr/rpc", routes![controller::get_version])
.mount("/market", routes![controller::get_products])
.mount("/test", routes![controller::test])
}